Loading packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java +31 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.os.Process; import android.text.TextUtils; import android.util.Log; import android.util.Pair; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.animation.Interpolator; Loading Loading @@ -619,6 +620,12 @@ public class MediaControlPanel { // the metadata changes). TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[]{mPrevArtwork, artwork}); scaleTransitionDrawableLayer(transitionDrawable, 0, width, height); scaleTransitionDrawableLayer(transitionDrawable, 1, width, height); transitionDrawable.setLayerGravity(0, Gravity.CENTER); transitionDrawable.setLayerGravity(1, Gravity.CENTER); albumView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(isArtworkBound ? 333 : 80); } Loading Loading @@ -652,6 +659,30 @@ public class MediaControlPanel { }); } private void scaleTransitionDrawableLayer(TransitionDrawable transitionDrawable, int layer, int targetWidth, int targetHeight) { Drawable drawable = transitionDrawable.getDrawable(layer); if (drawable == null) { return; } int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); if (width == 0 || height == 0 || targetWidth == 0 || targetHeight == 0) { return; } float scale; if ((width / (float) height) > (targetWidth / (float) targetHeight)) { // Drawable is wider than target view, scale to match height scale = targetHeight / (float) height; } else { // Drawable is taller than target view, scale to match width scale = targetWidth / (float) width; } transitionDrawable.setLayerSize(layer, (int) (scale * width), (int) (scale * height)); } private void bindActionButtons(MediaData data) { MediaButton semanticActions = data.getSemanticActions(); Loading packages/SystemUI/tests/src/com/android/systemui/media/MediaControlPanelTest.kt +6 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable import android.graphics.drawable.Icon import android.graphics.drawable.RippleDrawable import android.graphics.drawable.TransitionDrawable import android.media.MediaMetadata import android.media.session.MediaSession import android.media.session.PlaybackState Loading Loading @@ -74,6 +75,7 @@ import com.android.systemui.util.mockito.withArgCaptor import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat import dagger.Lazy import junit.framework.Assert.assertTrue import org.junit.After import org.junit.Before import org.junit.Rule Loading Loading @@ -579,9 +581,11 @@ public class MediaControlPanelTest : SysuiTestCase() { player.bindPlayer(state1, PACKAGE) bgExecutor.runAllReady() mainExecutor.runAllReady() verify(albumView, times(2)).setImageDrawable(any(Drawable::class.java)) val drawableCaptor = argumentCaptor<Drawable>() verify(albumView, times(2)).setImageDrawable(drawableCaptor.capture()) assertTrue(drawableCaptor.allValues[1] is TransitionDrawable) // Third binding does run transition or update background // Third binding doesn't run transition or update background player.bindPlayer(state2, PACKAGE) bgExecutor.runAllReady() mainExecutor.runAllReady() Loading Loading
packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java +31 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import android.os.Process; import android.text.TextUtils; import android.util.Log; import android.util.Pair; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.view.animation.Interpolator; Loading Loading @@ -619,6 +620,12 @@ public class MediaControlPanel { // the metadata changes). TransitionDrawable transitionDrawable = new TransitionDrawable( new Drawable[]{mPrevArtwork, artwork}); scaleTransitionDrawableLayer(transitionDrawable, 0, width, height); scaleTransitionDrawableLayer(transitionDrawable, 1, width, height); transitionDrawable.setLayerGravity(0, Gravity.CENTER); transitionDrawable.setLayerGravity(1, Gravity.CENTER); albumView.setImageDrawable(transitionDrawable); transitionDrawable.startTransition(isArtworkBound ? 333 : 80); } Loading Loading @@ -652,6 +659,30 @@ public class MediaControlPanel { }); } private void scaleTransitionDrawableLayer(TransitionDrawable transitionDrawable, int layer, int targetWidth, int targetHeight) { Drawable drawable = transitionDrawable.getDrawable(layer); if (drawable == null) { return; } int width = drawable.getIntrinsicWidth(); int height = drawable.getIntrinsicHeight(); if (width == 0 || height == 0 || targetWidth == 0 || targetHeight == 0) { return; } float scale; if ((width / (float) height) > (targetWidth / (float) targetHeight)) { // Drawable is wider than target view, scale to match height scale = targetHeight / (float) height; } else { // Drawable is taller than target view, scale to match width scale = targetWidth / (float) width; } transitionDrawable.setLayerSize(layer, (int) (scale * width), (int) (scale * height)); } private void bindActionButtons(MediaData data) { MediaButton semanticActions = data.getSemanticActions(); Loading
packages/SystemUI/tests/src/com/android/systemui/media/MediaControlPanelTest.kt +6 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.graphics.drawable.Drawable import android.graphics.drawable.GradientDrawable import android.graphics.drawable.Icon import android.graphics.drawable.RippleDrawable import android.graphics.drawable.TransitionDrawable import android.media.MediaMetadata import android.media.session.MediaSession import android.media.session.PlaybackState Loading Loading @@ -74,6 +75,7 @@ import com.android.systemui.util.mockito.withArgCaptor import com.android.systemui.util.time.FakeSystemClock import com.google.common.truth.Truth.assertThat import dagger.Lazy import junit.framework.Assert.assertTrue import org.junit.After import org.junit.Before import org.junit.Rule Loading Loading @@ -579,9 +581,11 @@ public class MediaControlPanelTest : SysuiTestCase() { player.bindPlayer(state1, PACKAGE) bgExecutor.runAllReady() mainExecutor.runAllReady() verify(albumView, times(2)).setImageDrawable(any(Drawable::class.java)) val drawableCaptor = argumentCaptor<Drawable>() verify(albumView, times(2)).setImageDrawable(drawableCaptor.capture()) assertTrue(drawableCaptor.allValues[1] is TransitionDrawable) // Third binding does run transition or update background // Third binding doesn't run transition or update background player.bindPlayer(state2, PACKAGE) bgExecutor.runAllReady() mainExecutor.runAllReady() Loading