Fixed album cover in landscape now playing screen
This commit is contained in:
parent
4dc8178012
commit
ff55c8edd0
7 changed files with 87 additions and 25 deletions
|
|
@ -29,7 +29,7 @@ import com.kabouzeid.gramophone.util.ColorUtil;
|
||||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||||
import com.kabouzeid.gramophone.util.Util;
|
import com.kabouzeid.gramophone.util.Util;
|
||||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||||
import com.kabouzeid.gramophone.views.SquareLayout;
|
import com.kabouzeid.gramophone.views.WidthFitSquareLayout;
|
||||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||||
|
|
||||||
import org.solovyev.android.views.llm.LinearLayoutManager;
|
import org.solovyev.android.views.llm.LinearLayoutManager;
|
||||||
|
|
@ -339,7 +339,7 @@ public class PlayerFragment extends AbsPlayerFragment implements PlayerAlbumCove
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUpPanelAndAlbumCoverHeight(PlayerFragment fragment) {
|
public void setUpPanelAndAlbumCoverHeight(PlayerFragment fragment) {
|
||||||
SquareLayout albumCoverContainer = (SquareLayout) fragment.getView().findViewById(R.id.album_cover_container);
|
WidthFitSquareLayout albumCoverContainer = (WidthFitSquareLayout) fragment.getView().findViewById(R.id.album_cover_container);
|
||||||
int topMargin = fragment.getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
int topMargin = fragment.getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||||
|
|
||||||
final int availablePanelHeight = fragment.slidingUpPanelLayout.getHeight() - fragment.getView().findViewById(R.id.player_content).getHeight() + topMargin;
|
final int availablePanelHeight = fragment.slidingUpPanelLayout.getHeight() - fragment.getView().findViewById(R.id.player_content).getHeight() + topMargin;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.kabouzeid.gramophone.views;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
|
*/
|
||||||
|
public class HeightFitSquareLayout extends FrameLayout {
|
||||||
|
|
||||||
|
private boolean forceSquare = true;
|
||||||
|
|
||||||
|
public HeightFitSquareLayout(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeightFitSquareLayout(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HeightFitSquareLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public HeightFitSquareLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
//noinspection SuspiciousNameCombination
|
||||||
|
super.onMeasure(forceSquare ? heightMeasureSpec : widthMeasureSpec, heightMeasureSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forceSquare(boolean forceSquare) {
|
||||||
|
this.forceSquare = forceSquare;
|
||||||
|
requestLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
package com.kabouzeid.gramophone.views;
|
package com.kabouzeid.gramophone.views;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.NonNull;
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
|
@ -14,12 +15,17 @@ public class WidthFitSquareImageView extends ImageView {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidthFitSquareImageView(@NonNull Context context, AttributeSet attrs) {
|
public WidthFitSquareImageView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidthFitSquareImageView(@NonNull Context context, AttributeSet attrs, int defStyle) {
|
public WidthFitSquareImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyleAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public WidthFitSquareImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,24 @@ import android.widget.FrameLayout;
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class SquareLayout extends FrameLayout {
|
public class WidthFitSquareLayout extends FrameLayout {
|
||||||
|
|
||||||
private boolean forceSquare = true;
|
private boolean forceSquare = true;
|
||||||
|
|
||||||
public SquareLayout(Context context) {
|
public WidthFitSquareLayout(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SquareLayout(Context context, AttributeSet attrs) {
|
public WidthFitSquareLayout(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SquareLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
public WidthFitSquareLayout(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
public SquareLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
public WidthFitSquareLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -20,16 +20,22 @@
|
||||||
style="@style/Toolbar"
|
style="@style/Toolbar"
|
||||||
android:background="@android:color/transparent" />
|
android:background="@android:color/transparent" />
|
||||||
|
|
||||||
<android.support.percent.PercentRelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<!--suppress AndroidDomInspection -->
|
<com.kabouzeid.gramophone.views.HeightFitSquareLayout
|
||||||
<fragment
|
android:id="@+id/cover_container"
|
||||||
android:id="@+id/player_album_cover_fragment"
|
android:layout_width="match_parent"
|
||||||
class="com.kabouzeid.gramophone.ui.fragments.player.PlayerAlbumCoverFragment"
|
android:layout_height="match_parent">
|
||||||
app:layout_aspectRatio="100%"
|
|
||||||
app:layout_heightPercent="100%" />
|
<fragment
|
||||||
|
android:id="@+id/player_album_cover_fragment"
|
||||||
|
class="com.kabouzeid.gramophone.ui.fragments.player.PlayerAlbumCoverFragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
</com.kabouzeid.gramophone.views.HeightFitSquareLayout>
|
||||||
|
|
||||||
<com.sothree.slidinguppanel.SlidingUpPanelLayout android:id="@+id/player_sliding_layout"
|
<com.sothree.slidinguppanel.SlidingUpPanelLayout android:id="@+id/player_sliding_layout"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
|
@ -37,8 +43,8 @@
|
||||||
xmlns:sothree="http://schemas.android.com/apk/res-auto"
|
xmlns:sothree="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_toEndOf="@+id/player_album_cover_fragment"
|
android:layout_toEndOf="@+id/cover_container"
|
||||||
android:layout_toRightOf="@+id/player_album_cover_fragment"
|
android:layout_toRightOf="@+id/cover_container"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:gravity="bottom"
|
android:gravity="bottom"
|
||||||
|
|
@ -127,7 +133,7 @@
|
||||||
|
|
||||||
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
|
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
|
||||||
|
|
||||||
</android.support.percent.PercentRelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
@ -4,13 +4,20 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@android:color/transparent">
|
android:background="@android:color/black">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.views.WidthFitSquareImageView
|
<ImageView
|
||||||
android:id="@+id/player_image"
|
android:id="@+id/player_image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
tools:ignore="ContentDescription,UnusedAttribute" />
|
tools:ignore="ContentDescription,UnusedAttribute" />
|
||||||
|
|
||||||
|
<!--<ImageView-->
|
||||||
|
<!--android:id="@+id/player_image_background"-->
|
||||||
|
<!--android:layout_width="match_parent"-->
|
||||||
|
<!--android:layout_height="match_parent"-->
|
||||||
|
<!--android:scaleType="centerCrop"-->
|
||||||
|
<!--tools:ignore="ContentDescription,UnusedAttribute" />-->
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.kabouzeid.gramophone.views.SquareLayout
|
<com.kabouzeid.gramophone.views.WidthFitSquareLayout
|
||||||
android:id="@+id/album_cover_container"
|
android:id="@+id/album_cover_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</com.kabouzeid.gramophone.views.SquareLayout>
|
</com.kabouzeid.gramophone.views.WidthFitSquareLayout>
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/playback_controls_fragment"
|
android:id="@+id/playback_controls_fragment"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue