Transition between the bar colors should be a bit smoother now. Also cleaned up some methods.
This commit is contained in:
parent
0dca677175
commit
b18be272bc
4 changed files with 55 additions and 72 deletions
|
|
@ -28,6 +28,8 @@
|
||||||
<h3>Version 0.9.43 beta2</h3>
|
<h3>Version 0.9.43 beta2</h3>
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
|
<li><b>IMPROVEMENT:</b> Transition between the bar colors should be a bit smoother now.
|
||||||
|
</li>
|
||||||
<li><b>FIX:</b> Playlist view having wrong background color on dark theme.
|
<li><b>FIX:</b> Playlist view having wrong background color on dark theme.
|
||||||
</li>
|
</li>
|
||||||
<li><b>FIX:</b> Bottom bar sometimes disappearing from itself after changing the theme.
|
<li><b>FIX:</b> Bottom bar sometimes disappearing from itself after changing the theme.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.kabouzeid.gramophone.ui.activities.base;
|
package com.kabouzeid.gramophone.ui.activities.base;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorSet;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
@ -121,6 +122,8 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
ImageButton shuffleButton;
|
ImageButton shuffleButton;
|
||||||
@Bind(R.id.player_media_controller_container)
|
@Bind(R.id.player_media_controller_container)
|
||||||
RelativeLayout mediaControllerContainer;
|
RelativeLayout mediaControllerContainer;
|
||||||
|
@Bind(R.id.player_media_controller_container_background)
|
||||||
|
View mediaControllerContainerBackground;
|
||||||
@Bind(R.id.player_footer_frame)
|
@Bind(R.id.player_footer_frame)
|
||||||
LinearLayout footerFrame;
|
LinearLayout footerFrame;
|
||||||
@Bind(R.id.player_album_art_background)
|
@Bind(R.id.player_album_art_background)
|
||||||
|
|
@ -138,9 +141,9 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
TextView songTotalTime;
|
TextView songTotalTime;
|
||||||
SeekBar progressSlider;
|
SeekBar progressSlider;
|
||||||
|
|
||||||
private int lastFooterColor = -1;
|
private int lastFooterColor;
|
||||||
private int lastTitleTextColor = -2;
|
private int lastTitleTextColor;
|
||||||
private int lastCaptionTextColor = -2;
|
private int lastCaptionTextColor;
|
||||||
|
|
||||||
private int navigationBarColor;
|
private int navigationBarColor;
|
||||||
private int taskColor;
|
private int taskColor;
|
||||||
|
|
@ -158,6 +161,8 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
|
|
||||||
private PlayPauseDrawable playPauseDrawable;
|
private PlayPauseDrawable playPauseDrawable;
|
||||||
|
|
||||||
|
private AnimatorSet colorTransitionAnimator;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
@ -554,7 +559,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
|
|
||||||
private void setUpPlaybackControllerCard() {
|
private void setUpPlaybackControllerCard() {
|
||||||
playbackControllerCard.setVisibility(showPlaybackControllerCard ? View.VISIBLE : View.GONE);
|
playbackControllerCard.setVisibility(showPlaybackControllerCard ? View.VISIBLE : View.GONE);
|
||||||
mediaControllerContainer.setBackgroundColor(showPlaybackControllerCard ? Color.TRANSPARENT : ColorUtil.resolveColor(this, R.attr.music_controller_container_color));
|
mediaControllerContainerBackground.setVisibility(showPlaybackControllerCard ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpMusicControllers() {
|
private void setUpMusicControllers() {
|
||||||
|
|
@ -807,7 +812,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
|
|
||||||
private void setColors(int color) {
|
private void setColors(int color) {
|
||||||
animateColorChange(color);
|
animateColorChange(color);
|
||||||
animateTextColorChange(ColorUtil.getPrimaryTextColorForBackground(this, color), ColorUtil.getSecondaryTextColorForBackground(this, color));
|
|
||||||
|
|
||||||
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
|
||||||
super.notifyTaskColorChange(color);
|
super.notifyTaskColorChange(color);
|
||||||
|
|
@ -818,11 +822,14 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
}
|
}
|
||||||
|
|
||||||
private void animateColorChange(final int newColor) {
|
private void animateColorChange(final int newColor) {
|
||||||
if (lastFooterColor != -1 && lastFooterColor != newColor) {
|
if (colorTransitionAnimator != null && colorTransitionAnimator.isStarted()) {
|
||||||
ViewUtil.animateViewColor(footer, lastFooterColor, newColor);
|
colorTransitionAnimator.cancel();
|
||||||
|
}
|
||||||
|
colorTransitionAnimator = new AnimatorSet();
|
||||||
|
AnimatorSet.Builder animatorSetBuilder = colorTransitionAnimator.play(ViewUtil.createBackgroundColorTransition(footer, lastFooterColor, newColor));
|
||||||
|
|
||||||
if (opaqueToolBar) {
|
if (opaqueToolBar) {
|
||||||
ViewUtil.animateViewColor(playerToolbar, lastFooterColor, newColor);
|
animatorSetBuilder.with(ViewUtil.createBackgroundColorTransition(playerToolbar, lastFooterColor, newColor));
|
||||||
} else {
|
} else {
|
||||||
playerToolbar.setBackgroundColor(Color.TRANSPARENT);
|
playerToolbar.setBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
@ -834,43 +841,20 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
newStatusbarColor = ColorUtil.shiftColorDown(newStatusbarColor);
|
newStatusbarColor = ColorUtil.shiftColorDown(newStatusbarColor);
|
||||||
oldStatusbarColor = ColorUtil.shiftColorDown(oldStatusbarColor);
|
oldStatusbarColor = ColorUtil.shiftColorDown(oldStatusbarColor);
|
||||||
}
|
}
|
||||||
ViewUtil.animateViewColor(playerStatusbar, oldStatusbarColor, newStatusbarColor);
|
animatorSetBuilder.with(ViewUtil.createBackgroundColorTransition(playerStatusbar, oldStatusbarColor, newStatusbarColor));
|
||||||
} else {
|
} else {
|
||||||
playerStatusbar.setBackgroundColor(Color.TRANSPARENT);
|
playerStatusbar.setBackgroundColor(Color.TRANSPARENT);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
footer.setBackgroundColor(newColor);
|
|
||||||
|
|
||||||
if (opaqueToolBar) {
|
int titleTextColor = ColorUtil.getPrimaryTextColorForBackground(this, newColor);
|
||||||
playerToolbar.setBackgroundColor(newColor);
|
int captionTextColor = ColorUtil.getSecondaryTextColorForBackground(this, newColor);
|
||||||
} else {
|
|
||||||
playerToolbar.setBackgroundColor(Color.TRANSPARENT);
|
animatorSetBuilder.with(ViewUtil.createTextColorTransition(songTitle, lastTitleTextColor, titleTextColor));
|
||||||
}
|
animatorSetBuilder.with(ViewUtil.createTextColorTransition(songText, lastCaptionTextColor, captionTextColor));
|
||||||
|
|
||||||
|
colorTransitionAnimator.start();
|
||||||
|
|
||||||
if (opaqueStatusBar) {
|
|
||||||
int newStatusbarColor = newColor;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
newStatusbarColor = ColorUtil.shiftColorDown(newColor);
|
|
||||||
}
|
|
||||||
playerStatusbar.setBackgroundColor(newStatusbarColor);
|
|
||||||
} else {
|
|
||||||
playerStatusbar.setBackgroundColor(Color.TRANSPARENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lastFooterColor = newColor;
|
lastFooterColor = newColor;
|
||||||
}
|
|
||||||
|
|
||||||
private void animateTextColorChange(int titleTextColor, int captionTextColor) {
|
|
||||||
if (lastTitleTextColor != -2 && lastTitleTextColor != titleTextColor) {
|
|
||||||
ViewUtil.animateTextColor(songTitle, lastTitleTextColor, titleTextColor);
|
|
||||||
} else {
|
|
||||||
songTitle.setTextColor(titleTextColor);
|
|
||||||
}
|
|
||||||
if (lastCaptionTextColor != -2 && lastCaptionTextColor != captionTextColor) {
|
|
||||||
ViewUtil.animateTextColor(songText, lastCaptionTextColor, captionTextColor);
|
|
||||||
} else {
|
|
||||||
songText.setTextColor(captionTextColor);
|
|
||||||
}
|
|
||||||
lastTitleTextColor = titleTextColor;
|
lastTitleTextColor = titleTextColor;
|
||||||
lastCaptionTextColor = captionTextColor;
|
lastCaptionTextColor = captionTextColor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.kabouzeid.gramophone.util;
|
package com.kabouzeid.gramophone.util;
|
||||||
|
|
||||||
|
import android.animation.Animator;
|
||||||
import android.animation.ArgbEvaluator;
|
import android.animation.ArgbEvaluator;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
@ -29,36 +30,26 @@ import java.lang.reflect.Field;
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
*/
|
*/
|
||||||
public class ViewUtil {
|
public class ViewUtil {
|
||||||
|
|
||||||
|
public static Animator createBackgroundColorTransition(final View v, final int startColor, final int endColor) {
|
||||||
|
return createColorAnimator(v, "backgroundColor", startColor, endColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Animator createTextColorTransition(final TextView v, final int startColor, final int endColor) {
|
||||||
|
return createColorAnimator(v, "textColor", startColor, endColor);
|
||||||
|
}
|
||||||
|
|
||||||
public final static int DEFAULT_COLOR_ANIMATION_DURATION = 500;
|
public final static int DEFAULT_COLOR_ANIMATION_DURATION = 500;
|
||||||
|
|
||||||
public static void animateViewColor(final View v, final int startColor, final int endColor) {
|
private static Animator createColorAnimator(Object target, String propertyName, int startColor, int endColor) {
|
||||||
animateViewColor(v, startColor, endColor, DEFAULT_COLOR_ANIMATION_DURATION);
|
ObjectAnimator animator = ObjectAnimator.ofObject(target, propertyName,
|
||||||
}
|
|
||||||
|
|
||||||
public static void animateViewColor(final View v, final int startColor, final int endColor, final int duration) {
|
|
||||||
ObjectAnimator animator = ObjectAnimator.ofObject(v, "backgroundColor",
|
|
||||||
new ArgbEvaluator(), startColor, endColor);
|
new ArgbEvaluator(), startColor, endColor);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
|
animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
|
||||||
}
|
}
|
||||||
animator.setDuration(duration);
|
animator.setDuration(DEFAULT_COLOR_ANIMATION_DURATION);
|
||||||
animator.start();
|
return animator;
|
||||||
}
|
|
||||||
|
|
||||||
public static void animateTextColor(final TextView v, final int startColor, final int endColor) {
|
|
||||||
animateTextColor(v, startColor, endColor, DEFAULT_COLOR_ANIMATION_DURATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void animateTextColor(final TextView v, final int startColor, final int endColor, final int duration) {
|
|
||||||
ObjectAnimator animator = ObjectAnimator.ofObject(v, "textColor",
|
|
||||||
new ArgbEvaluator(), startColor, endColor);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
||||||
animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
|
|
||||||
}
|
|
||||||
animator.setDuration(duration);
|
|
||||||
animator.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBackgroundAlpha(@NonNull View view, float alpha, int baseColor) {
|
public static void setBackgroundAlpha(@NonNull View view, float alpha, int baseColor) {
|
||||||
|
|
|
||||||
|
|
@ -98,9 +98,14 @@
|
||||||
android:id="@+id/player_media_controller_container"
|
android:id="@+id/player_media_controller_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/media_controller_container_height"
|
android:layout_height="@dimen/media_controller_container_height"
|
||||||
android:background="?music_controller_container_color"
|
|
||||||
tools:ignore="ContentDescription,UnusedAttribute">
|
tools:ignore="ContentDescription,UnusedAttribute">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/player_media_controller_container_background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?music_controller_container_color" />
|
||||||
|
|
||||||
<android.support.v7.widget.CardView
|
<android.support.v7.widget.CardView
|
||||||
android:id="@+id/player_playback_controller_card"
|
android:id="@+id/player_playback_controller_card"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -271,7 +276,8 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/status_bar_padding"
|
android:layout_height="@dimen/status_bar_padding"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:elevation="@dimen/toolbar_elevation" />
|
android:elevation="@dimen/toolbar_elevation"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/player_toolbar"
|
android:id="@+id/player_toolbar"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue