diff --git a/app/src/main/assets/changelog.html b/app/src/main/assets/changelog.html
index a2ccf9cb..c42b50cb 100644
--- a/app/src/main/assets/changelog.html
+++ b/app/src/main/assets/changelog.html
@@ -28,6 +28,8 @@
Version 0.9.43 beta2
+ - IMPROVEMENT: Transition between the bar colors should be a bit smoother now.
+
- FIX: Playlist view having wrong background color on dark theme.
- FIX: Bottom bar sometimes disappearing from itself after changing the theme.
diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/base/AbsSlidingMusicPanelActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/base/AbsSlidingMusicPanelActivity.java
index ab211e0e..8b2269a2 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/base/AbsSlidingMusicPanelActivity.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/base/AbsSlidingMusicPanelActivity.java
@@ -1,6 +1,7 @@
package com.kabouzeid.gramophone.ui.activities.base;
import android.animation.Animator;
+import android.animation.AnimatorSet;
import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Intent;
@@ -121,6 +122,8 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
ImageButton shuffleButton;
@Bind(R.id.player_media_controller_container)
RelativeLayout mediaControllerContainer;
+ @Bind(R.id.player_media_controller_container_background)
+ View mediaControllerContainerBackground;
@Bind(R.id.player_footer_frame)
LinearLayout footerFrame;
@Bind(R.id.player_album_art_background)
@@ -138,9 +141,9 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
TextView songTotalTime;
SeekBar progressSlider;
- private int lastFooterColor = -1;
- private int lastTitleTextColor = -2;
- private int lastCaptionTextColor = -2;
+ private int lastFooterColor;
+ private int lastTitleTextColor;
+ private int lastCaptionTextColor;
private int navigationBarColor;
private int taskColor;
@@ -158,6 +161,8 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
private PlayPauseDrawable playPauseDrawable;
+ private AnimatorSet colorTransitionAnimator;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -554,7 +559,7 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
private void setUpPlaybackControllerCard() {
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() {
@@ -807,7 +812,6 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
private void setColors(int color) {
animateColorChange(color);
- animateTextColorChange(ColorUtil.getPrimaryTextColorForBackground(this, color), ColorUtil.getSecondaryTextColorForBackground(this, color));
if (slidingUpPanelLayout.getPanelState() == SlidingUpPanelLayout.PanelState.EXPANDED) {
super.notifyTaskColorChange(color);
@@ -818,59 +822,39 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
}
private void animateColorChange(final int newColor) {
- if (lastFooterColor != -1 && lastFooterColor != newColor) {
- ViewUtil.animateViewColor(footer, lastFooterColor, newColor);
-
- if (opaqueToolBar) {
- ViewUtil.animateViewColor(playerToolbar, lastFooterColor, newColor);
- } else {
- playerToolbar.setBackgroundColor(Color.TRANSPARENT);
- }
-
- if (opaqueStatusBar) {
- int newStatusbarColor = newColor;
- int oldStatusbarColor = lastFooterColor;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- newStatusbarColor = ColorUtil.shiftColorDown(newStatusbarColor);
- oldStatusbarColor = ColorUtil.shiftColorDown(oldStatusbarColor);
- }
- ViewUtil.animateViewColor(playerStatusbar, oldStatusbarColor, newStatusbarColor);
- } else {
- playerStatusbar.setBackgroundColor(Color.TRANSPARENT);
- }
- } else {
- footer.setBackgroundColor(newColor);
-
- if (opaqueToolBar) {
- playerToolbar.setBackgroundColor(newColor);
- } else {
- playerToolbar.setBackgroundColor(Color.TRANSPARENT);
- }
-
- 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);
- }
+ if (colorTransitionAnimator != null && colorTransitionAnimator.isStarted()) {
+ colorTransitionAnimator.cancel();
}
+ colorTransitionAnimator = new AnimatorSet();
+ AnimatorSet.Builder animatorSetBuilder = colorTransitionAnimator.play(ViewUtil.createBackgroundColorTransition(footer, lastFooterColor, newColor));
+
+ if (opaqueToolBar) {
+ animatorSetBuilder.with(ViewUtil.createBackgroundColorTransition(playerToolbar, lastFooterColor, newColor));
+ } else {
+ playerToolbar.setBackgroundColor(Color.TRANSPARENT);
+ }
+
+ if (opaqueStatusBar) {
+ int newStatusbarColor = newColor;
+ int oldStatusbarColor = lastFooterColor;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ newStatusbarColor = ColorUtil.shiftColorDown(newStatusbarColor);
+ oldStatusbarColor = ColorUtil.shiftColorDown(oldStatusbarColor);
+ }
+ animatorSetBuilder.with(ViewUtil.createBackgroundColorTransition(playerStatusbar, oldStatusbarColor, newStatusbarColor));
+ } else {
+ playerStatusbar.setBackgroundColor(Color.TRANSPARENT);
+ }
+
+ int titleTextColor = ColorUtil.getPrimaryTextColorForBackground(this, newColor);
+ int captionTextColor = ColorUtil.getSecondaryTextColorForBackground(this, newColor);
+
+ animatorSetBuilder.with(ViewUtil.createTextColorTransition(songTitle, lastTitleTextColor, titleTextColor));
+ animatorSetBuilder.with(ViewUtil.createTextColorTransition(songText, lastCaptionTextColor, captionTextColor));
+
+ colorTransitionAnimator.start();
+
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;
lastCaptionTextColor = captionTextColor;
}
diff --git a/app/src/main/java/com/kabouzeid/gramophone/util/ViewUtil.java b/app/src/main/java/com/kabouzeid/gramophone/util/ViewUtil.java
index 12e74afb..3262f95b 100644
--- a/app/src/main/java/com/kabouzeid/gramophone/util/ViewUtil.java
+++ b/app/src/main/java/com/kabouzeid/gramophone/util/ViewUtil.java
@@ -1,5 +1,6 @@
package com.kabouzeid.gramophone.util;
+import android.animation.Animator;
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.os.Build;
@@ -29,36 +30,26 @@ import java.lang.reflect.Field;
* @author Karim Abou Zeid (kabouzeid)
*/
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 static void animateViewColor(final View v, final int startColor, final int endColor) {
- animateViewColor(v, startColor, endColor, DEFAULT_COLOR_ANIMATION_DURATION);
- }
-
- public static void animateViewColor(final View v, final int startColor, final int endColor, final int duration) {
- ObjectAnimator animator = ObjectAnimator.ofObject(v, "backgroundColor",
+ private static Animator createColorAnimator(Object target, String propertyName, int startColor, int endColor) {
+ ObjectAnimator animator = ObjectAnimator.ofObject(target, propertyName,
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 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();
+ animator.setDuration(DEFAULT_COLOR_ANIMATION_DURATION);
+ return animator;
}
public static void setBackgroundAlpha(@NonNull View view, float alpha, int baseColor) {
diff --git a/app/src/main/res/layout/player.xml b/app/src/main/res/layout/player.xml
index 2041bd68..1b7e6e00 100644
--- a/app/src/main/res/layout/player.xml
+++ b/app/src/main/res/layout/player.xml
@@ -98,9 +98,14 @@
android:id="@+id/player_media_controller_container"
android:layout_width="match_parent"
android:layout_height="@dimen/media_controller_container_height"
- android:background="?music_controller_container_color"
tools:ignore="ContentDescription,UnusedAttribute">
+
+
+ android:elevation="@dimen/toolbar_elevation"
+ tools:ignore="UnusedAttribute" />