New tablet layout for now playing screen

This commit is contained in:
Karim Abou Zeid 2015-12-24 00:47:43 +01:00
commit fa79772d21
3 changed files with 199 additions and 7 deletions

View file

@ -2,7 +2,6 @@ package com.kabouzeid.gramophone.ui.fragments.player;
import android.animation.Animator;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.v4.view.ViewPager;
import android.view.GestureDetector;
import android.view.LayoutInflater;
@ -90,6 +89,8 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements
private void updatePlayingQueue() {
viewPager.setAdapter(new AlbumCoverPagerAdapter(getFragmentManager(), MusicPlayerRemote.getPlayingQueue()));
viewPager.setCurrentItem(MusicPlayerRemote.getPosition());
// doesn't get called automatically for some reason
onPageSelected(MusicPlayerRemote.getPosition());
}
@Override
@ -120,11 +121,6 @@ public class PlayerAlbumCoverFragment extends AbsMusicServiceFragment implements
}
private static class ColorHolder {
@ColorInt
public int color;
}
public void showHeartAnimation() {
favoriteIcon.clearAnimation();

View file

@ -22,6 +22,7 @@ import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.adapter.base.MediaEntryViewHolder;
import com.kabouzeid.gramophone.adapter.song.PlayingQueueAdapter;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.loader.ArtistLoader;
import com.kabouzeid.gramophone.misc.DragSortRecycler;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
@ -30,6 +31,11 @@ import com.kabouzeid.gramophone.util.MusicUtil;
import com.kabouzeid.gramophone.util.Util;
import com.kabouzeid.gramophone.util.ViewUtil;
import com.kabouzeid.gramophone.views.WidthFitSquareLayout;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import org.solovyev.android.views.llm.LinearLayoutManager;
@ -67,7 +73,9 @@ public class PlayerFragment extends AbsPlayerFragment implements PlayerAlbumCove
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (Util.isLandscape(getResources())) {
if (Util.isTablet(getResources())) {
impl = new TabletImpl();
} else if (Util.isLandscape(getResources())) {
impl = new LandscapeImpl();
} else {
impl = new PortraitImpl();
@ -399,4 +407,44 @@ public class PlayerFragment extends AbsPlayerFragment implements PlayerAlbumCove
animatorSet.start();
}
}
@SuppressWarnings("ConstantConditions")
private static class TabletImpl extends PortraitImpl {
ImageView playerBackground;
@Override
public void init(PlayerFragment fragment) {
super.init(fragment);
playerBackground = ((ImageView) fragment.getView().findViewById(R.id.player_background));
playerBackground.setAlpha(0.5f);
}
@Override
public void animateColorChange(PlayerFragment fragment, int newColor) {
fragment.slidingUpPanelLayout.setBackgroundColor(fragment.lastColor);
AnimatorSet animatorSet = createDefaultColorChangeAnimatorSet(fragment, newColor);
animatorSet.play(ViewUtil.createBackgroundColorTransition(fragment.getView(), ColorUtil.shiftColorDown(fragment.lastColor), ColorUtil.shiftColorDown(newColor)));
animatorSet.start();
ImageLoader.getInstance().displayImage(
MusicUtil.getArtistImageLoaderString(ArtistLoader.getArtist(fragment.getActivity(), MusicPlayerRemote.getCurrentSong().artistId), false),
playerBackground,
new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisk(true)
.resetViewBeforeLoading(true)
.showImageOnFail(R.drawable.default_artist_image)
//.postProcessor(new BlurProcessor.Builder(fragment.getActivity()).build())
.displayer(new FadeInBitmapDisplayer(ViewUtil.PHONOGRAPH_ANIM_TIME, true, true, false))
.build(),
new SimpleImageLoadingListener() {
@Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
FadeInBitmapDisplayer.animate(view, ViewUtil.PHONOGRAPH_ANIM_TIME);
}
}
);
}
}
}

View file

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/player_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
tools:ignore="ContentDescription" />
<include layout="@layout/shadow_statusbar_actionbar" />
<android.support.v7.widget.Toolbar
android:id="@+id/player_toolbar"
style="@style/Toolbar"
android:layout_marginTop="@dimen/status_bar_padding"
android:background="@android:color/transparent" />
<!--The unused FrameLayout layout is necessary to prevent a crash on rotate-->
<com.sothree.slidinguppanel.SlidingUpPanelLayout android:id="@+id/player_sliding_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:layout_width="360dp"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:layout_marginTop="120dp"
android:clickable="false"
android:elevation="@dimen/toolbar_elevation"
android:focusable="true"
android:gravity="bottom"
app:ignore="UnusedAttribute"
sothree:umanoFadeColor="#00000000"
sothree:umanoOverlay="true"
sothree:umanoPanelHeight="0dp"
sothree:umanoScrollableView="@+id/player_recycler_view"
sothree:umanoShadowHeight="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<View
android:id="@+id/color_background"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:id="@+id/player_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.kabouzeid.gramophone.views.WidthFitSquareLayout
android:id="@+id/album_cover_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<fragment
android:id="@+id/player_album_cover_fragment"
class="com.kabouzeid.gramophone.ui.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.kabouzeid.gramophone.views.WidthFitSquareLayout>
<fragment
android:id="@+id/playback_controls_fragment"
class="com.kabouzeid.gramophone.ui.fragments.player.PlaybackControlsFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/album_cover_container" />
</RelativeLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/player_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="@+id/playing_queue_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="@dimen/status_bar_padding"
app:cardBackgroundColor="?cardBackgroundColor"
app:cardElevation="@dimen/card_elevation"
app:cardUseCompatPadding="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--This is necessary for the drag sorting to work at the top-->
<View
android:id="@+id/draggable_area"
android:layout_width="72dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/card_content"
android:layout_alignTop="@+id/card_content"
android:layout_marginTop="120dp" />
<LinearLayout
android:id="@+id/card_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/current_song"
layout="@layout/item_list" />
<TextView
android:id="@+id/player_queue_sub_header"
android:layout_width="match_parent"
android:layout_height="48dp"
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/up_next"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textColor="?android:textColorSecondary" />
<android.support.v7.widget.RecyclerView
android:id="@+id/player_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</FrameLayout>
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
</FrameLayout>