Merge "Fix Squashing Issue on UMO Background" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7d130a7e1f
@@ -48,6 +48,7 @@ import android.os.Process;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Interpolator;
|
import android.view.animation.Interpolator;
|
||||||
@@ -619,6 +620,12 @@ public class MediaControlPanel {
|
|||||||
// the metadata changes).
|
// the metadata changes).
|
||||||
TransitionDrawable transitionDrawable = new TransitionDrawable(
|
TransitionDrawable transitionDrawable = new TransitionDrawable(
|
||||||
new Drawable[]{mPrevArtwork, artwork});
|
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);
|
albumView.setImageDrawable(transitionDrawable);
|
||||||
transitionDrawable.startTransition(isArtworkBound ? 333 : 80);
|
transitionDrawable.startTransition(isArtworkBound ? 333 : 80);
|
||||||
}
|
}
|
||||||
@@ -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) {
|
private void bindActionButtons(MediaData data) {
|
||||||
MediaButton semanticActions = data.getSemanticActions();
|
MediaButton semanticActions = data.getSemanticActions();
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.graphics.drawable.Drawable
|
|||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
import android.graphics.drawable.RippleDrawable
|
import android.graphics.drawable.RippleDrawable
|
||||||
|
import android.graphics.drawable.TransitionDrawable
|
||||||
import android.media.MediaMetadata
|
import android.media.MediaMetadata
|
||||||
import android.media.session.MediaSession
|
import android.media.session.MediaSession
|
||||||
import android.media.session.PlaybackState
|
import android.media.session.PlaybackState
|
||||||
@@ -74,6 +75,7 @@ import com.android.systemui.util.mockito.withArgCaptor
|
|||||||
import com.android.systemui.util.time.FakeSystemClock
|
import com.android.systemui.util.time.FakeSystemClock
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
@@ -579,9 +581,11 @@ public class MediaControlPanelTest : SysuiTestCase() {
|
|||||||
player.bindPlayer(state1, PACKAGE)
|
player.bindPlayer(state1, PACKAGE)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
mainExecutor.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)
|
player.bindPlayer(state2, PACKAGE)
|
||||||
bgExecutor.runAllReady()
|
bgExecutor.runAllReady()
|
||||||
mainExecutor.runAllReady()
|
mainExecutor.runAllReady()
|
||||||
|
|||||||
Reference in New Issue
Block a user