Made a huge progress with new playing screen. Almost done now.
This commit is contained in:
parent
60bdc1819e
commit
c5ebe5a64c
8 changed files with 133 additions and 40 deletions
|
|
@ -69,12 +69,22 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
});
|
||||
}
|
||||
|
||||
public void setAntiDragView(View antiDragView) {
|
||||
slidingUpPanelLayout.setAntiDragView(antiDragView);
|
||||
}
|
||||
|
||||
protected abstract View createContentView();
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
public void onPlayingMetaChanged() {
|
||||
super.onPlayingMetaChanged();
|
||||
hideBottomBar(MusicPlayerRemote.getPlayingQueue().isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
super.onServiceConnected(name, service);
|
||||
hideBottomBar(MusicPlayerRemote.getPlayingQueue().isEmpty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -133,6 +143,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
|
||||
public void hideBottomBar(boolean hide) {
|
||||
if (hide) {
|
||||
slidingUpPanelLayout.setPanelHeight(0);
|
||||
slidingUpPanelLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -140,6 +151,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
}
|
||||
});
|
||||
} else {
|
||||
slidingUpPanelLayout.setPanelHeight(getResources().getDimensionPixelSize(R.dimen.mini_player_height));
|
||||
slidingUpPanelLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
@ -159,6 +171,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (playerFragment.onBackPressed()) return;
|
||||
if (!isPanelCollapsed()) {
|
||||
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.kabouzeid.gramophone.ui.fragments.player;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
|
@ -13,6 +14,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.RelativeLayout;
|
||||
|
|
@ -31,22 +33,22 @@ import com.kabouzeid.gramophone.interfaces.PaletteColorHolder;
|
|||
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||
import com.kabouzeid.gramophone.model.Song;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsMusicServiceActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsSlidingMusicPanelActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.tageditor.AbsTagEditorActivity;
|
||||
import com.kabouzeid.gramophone.ui.activities.tageditor.SongTagEditorActivity;
|
||||
import com.kabouzeid.gramophone.util.ColorUtil;
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
import com.kabouzeid.gramophone.util.ViewUtil;
|
||||
import com.kabouzeid.gramophone.views.SlidingUpPanelLayout;
|
||||
import com.kabouzeid.gramophone.views.SquareLayout;
|
||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||
|
||||
import org.solovyev.android.views.llm.LinearLayoutManager;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
public class PlayerFragment extends Fragment implements MusicServiceEventListener, Toolbar.OnMenuItemClickListener, PaletteColorHolder, PlayerAlbumCoverFragment.OnColorChangedListener {
|
||||
public class PlayerFragment extends Fragment implements MusicServiceEventListener, Toolbar.OnMenuItemClickListener, PaletteColorHolder, PlayerAlbumCoverFragment.OnColorChangedListener, SlidingUpPanelLayout.PanelSlideListener {
|
||||
public static final String TAG = PlayerFragment.class.getSimpleName();
|
||||
|
||||
@Bind(R.id.player_toolbar)
|
||||
|
|
@ -61,6 +63,8 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
SquareLayout albumCoverContainer;
|
||||
@Bind(R.id.player_content)
|
||||
RelativeLayout playerContent;
|
||||
@Bind(R.id.color_background)
|
||||
View colorBackground;
|
||||
|
||||
private int lastColor;
|
||||
|
||||
|
|
@ -70,6 +74,8 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
private PlaybackControlsFragment playbackControlsFragment;
|
||||
private PlayerAlbumCoverFragment playerAlbumCoverFragment;
|
||||
|
||||
private LinearLayoutManager layoutManager;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
|
|
@ -115,7 +121,11 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
((CabHolder) getActivity())));
|
||||
|
||||
// TODO set child size
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
layoutManager = new LinearLayoutManager(getActivity());
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
|
||||
//slidingUpPanelLayout.setParallaxOffset(Util.resolveDimensionPixelSize(activity, R.attr.actionBarSize) + getResources().getDimensionPixelSize(R.dimen.status_bar_padding));
|
||||
slidingUpPanelLayout.setPanelSlideListener(this);
|
||||
|
||||
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
|
|
@ -125,8 +135,6 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
activity.addMusicServiceEventListener(this);
|
||||
}
|
||||
|
||||
|
|
@ -163,13 +171,16 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
}
|
||||
|
||||
private void setUpPanelAndAlbumCoverHeight() {
|
||||
final int availablePanelHeight = slidingUpPanelLayout.getHeight() - playerContent.getHeight();
|
||||
final int minPanelHeight = (int) getResources().getDisplayMetrics().density * (72 + 32);
|
||||
int topMargin = getResources().getDimensionPixelSize(R.dimen.status_bar_padding);
|
||||
|
||||
final int availablePanelHeight = slidingUpPanelLayout.getHeight() - playerContent.getHeight() + topMargin;
|
||||
final int minPanelHeight = (int) getResources().getDisplayMetrics().density * (72 + 32) + topMargin;
|
||||
if (availablePanelHeight < minPanelHeight) {
|
||||
albumCoverContainer.getLayoutParams().height = albumCoverContainer.getHeight() - (minPanelHeight - availablePanelHeight);
|
||||
albumCoverContainer.forceSquare(false);
|
||||
}
|
||||
slidingUpPanelLayout.setPanelHeight(Math.max(minPanelHeight, availablePanelHeight));
|
||||
((AbsSlidingMusicPanelActivity) activity).setAntiDragView(slidingUpPanelLayout.findViewById(R.id.player_panel));
|
||||
}
|
||||
|
||||
private void setUpSubFragments() {
|
||||
|
|
@ -193,7 +204,7 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
|
||||
private void updatePlayerMenu() {
|
||||
boolean isFavorite = MusicUtil.isFavorite(activity, MusicPlayerRemote.getCurrentSong());
|
||||
Drawable favoriteIcon = Util.getTintedDrawable(activity, isFavorite ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_outline_white_24dp, ViewUtil.getToolbarIconColor(activity, ColorUtil.useDarkTextColorOnBackground(lastColor)));
|
||||
Drawable favoriteIcon = Util.getTintedDrawable(activity, isFavorite ? R.drawable.ic_favorite_white_24dp : R.drawable.ic_favorite_outline_white_24dp, ViewUtil.getToolbarIconColor(activity, false));
|
||||
toolbar.getMenu().findItem(R.id.action_toggle_favorite)
|
||||
.setIcon(favoriteIcon)
|
||||
.setTitle(isFavorite ? getString(R.string.action_remove_from_favorites) : getString(R.string.action_add_to_favorites));
|
||||
|
|
@ -205,8 +216,17 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
return lastColor;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private void animateColorChange(final int newColor) {
|
||||
getView().setBackgroundColor(newColor);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
int x = (int) (playbackControlsFragment.playPauseFab.getX() + playbackControlsFragment.playPauseFab.getWidth() / 2 + playbackControlsFragment.getView().getX());
|
||||
int y = (int) (playbackControlsFragment.playPauseFab.getY() + playbackControlsFragment.playPauseFab.getHeight() / 2 + playbackControlsFragment.getView().getY());
|
||||
float startRadius = 0;
|
||||
float endRadius = Math.max(colorBackground.getWidth(), colorBackground.getHeight());
|
||||
slidingUpPanelLayout.setBackgroundColor(lastColor);
|
||||
colorBackground.setBackgroundColor(newColor);
|
||||
ViewAnimationUtils.createCircularReveal(colorBackground, x, y, startRadius, endRadius).setDuration(1000).start();
|
||||
}
|
||||
lastColor = newColor;
|
||||
}
|
||||
|
||||
|
|
@ -265,6 +285,14 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
playbackControlsFragment.resetShowControlsAnimation();
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||
slidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onColorChanged(int color) {
|
||||
animateColorChange(color);
|
||||
|
|
@ -272,9 +300,39 @@ public class PlayerFragment extends Fragment implements MusicServiceEventListene
|
|||
callbacks.onPaletteColorChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelSlide(View view, float slide) {
|
||||
float density = getResources().getDisplayMetrics().density;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
playingQueueCard.setCardElevation(density * 6 * slide + 2 * density);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelCollapsed(View view) {
|
||||
if (layoutManager.findLastVisibleItemPosition() < 50) {
|
||||
recyclerView.smoothScrollToPosition(0);
|
||||
} else {
|
||||
recyclerView.scrollToPosition(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelExpanded(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelAnchored(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPanelHidden(View view) {
|
||||
|
||||
}
|
||||
|
||||
public interface Callbacks {
|
||||
void onPaletteColorChanged();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,6 +89,13 @@ public class Util {
|
|||
return drawable;
|
||||
}
|
||||
|
||||
public static int resolveDimensionPixelSize(@NonNull Context context, @AttrRes int dimenAttr) {
|
||||
TypedArray a = context.obtainStyledAttributes(new int[]{dimenAttr});
|
||||
int dimensionPixelSize = a.getDimensionPixelSize(0, 0);
|
||||
a.recycle();
|
||||
return dimensionPixelSize;
|
||||
}
|
||||
|
||||
public static Drawable getTintedDrawable(@NonNull Context context, @DrawableRes int drawableResId, int color) {
|
||||
Drawable drawable = ContextCompat.getDrawable(context, drawableResId);
|
||||
if (drawable != null) {
|
||||
|
|
|
|||
|
|
@ -6,43 +6,52 @@
|
|||
xmlns:sothree="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="true"
|
||||
android:clickable="false"
|
||||
android:focusable="true"
|
||||
android:gravity="bottom"
|
||||
sothree:umanoDragView="@+id/player_panel"
|
||||
sothree:umanoFadeColor="#00000000"
|
||||
sothree:umanoOverlay="true"
|
||||
sothree:umanoPanelHeight="0dp"
|
||||
sothree:umanoScrollableView="@+id/player_recycler_view"
|
||||
sothree:umanoParallaxOffset="32dp"
|
||||
sothree:umanoShadowHeight="0dp">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/player_content"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.kabouzeid.gramophone.views.SquareLayout
|
||||
android:id="@+id/album_cover_container"
|
||||
<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:layout_alignParentTop="true">
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.kabouzeid.gramophone.views.SquareLayout
|
||||
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.SquareLayout>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/player_album_cover_fragment"
|
||||
class="com.kabouzeid.gramophone.ui.fragments.player.PlayerAlbumCoverFragment"
|
||||
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_height="wrap_content"
|
||||
android:layout_below="@id/album_cover_container" />
|
||||
|
||||
</com.kabouzeid.gramophone.views.SquareLayout>
|
||||
|
||||
<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>
|
||||
|
||||
<include layout="@layout/shadow_statusbar_actionbar" />
|
||||
|
||||
|
|
@ -51,7 +60,8 @@
|
|||
style="@style/Toolbar"
|
||||
android:layout_marginTop="@dimen/status_bar_padding"
|
||||
android:background="@android:color/transparent" />
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/player_panel"
|
||||
|
|
@ -62,11 +72,13 @@
|
|||
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="true">
|
||||
app:cardUseCompatPadding="false">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/player_recycler_view"
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="bottom"
|
||||
sothree:umanoScrollableView="@+id/sliding_panel"
|
||||
sothree:umanoDragView="@+id/sliding_panel"
|
||||
sothree:umanoOverlay="false"
|
||||
sothree:umanoPanelHeight="@dimen/mini_player_height"
|
||||
sothree:umanoShadowHeight="@dimen/card_elevation">
|
||||
|
||||
|
|
|
|||
4
app/src/main/res/values-v23/dimens.xml
Normal file
4
app/src/main/res/values-v23/dimens.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="status_bar_padding">24dp</dimen>
|
||||
</resources>
|
||||
|
|
@ -32,7 +32,7 @@
|
|||
<style name="Toolbar">
|
||||
<item name="titleMarginStart">16dp</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">?attr/actionBarSize</item>
|
||||
<item name="android:layout_height">?actionBarSize</item>
|
||||
<item name="android:theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
|
||||
<item name="popupTheme">?toolbarPopupTheme</item>
|
||||
<item name="android:elevation" tools:ignore="NewApi">@dimen/toolbar_elevation</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue