Merge "Only animate when the slice is actually animating" into pi-dev
This commit is contained in:
@@ -84,10 +84,9 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
|
|||||||
private LiveData<Slice> mLiveData;
|
private LiveData<Slice> mLiveData;
|
||||||
private int mIconSize;
|
private int mIconSize;
|
||||||
/**
|
/**
|
||||||
* Listener called whenever the view contents change.
|
* Runnable called whenever the view contents change.
|
||||||
* Boolean will be true when the change happens animated.
|
|
||||||
*/
|
*/
|
||||||
private Consumer<Boolean> mContentChangeListener;
|
private Runnable mContentChangeListener;
|
||||||
private boolean mHasHeader;
|
private boolean mHasHeader;
|
||||||
private Slice mSlice;
|
private Slice mSlice;
|
||||||
private boolean mPulsing;
|
private boolean mPulsing;
|
||||||
@@ -150,7 +149,9 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
|
|||||||
if (mPulsing || mSlice == null) {
|
if (mPulsing || mSlice == null) {
|
||||||
mTitle.setVisibility(GONE);
|
mTitle.setVisibility(GONE);
|
||||||
mRow.setVisibility(GONE);
|
mRow.setVisibility(GONE);
|
||||||
mContentChangeListener.accept(getLayoutTransition() != null);
|
if (mContentChangeListener != null) {
|
||||||
|
mContentChangeListener.run();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,7 +224,7 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mContentChangeListener != null) {
|
if (mContentChangeListener != null) {
|
||||||
mContentChangeListener.accept(getLayoutTransition() != null);
|
mContentChangeListener.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -310,11 +311,10 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listener that gets invoked every time the title or the row visibility changes.
|
* Runnable that gets invoked every time the title or the row visibility changes.
|
||||||
* Parameter will be {@code true} whenever the change happens animated.
|
|
||||||
* @param contentChangeListener The listener.
|
* @param contentChangeListener The listener.
|
||||||
*/
|
*/
|
||||||
public void setContentChangeListener(Consumer<Boolean> contentChangeListener) {
|
public void setContentChangeListener(Runnable contentChangeListener) {
|
||||||
mContentChangeListener = contentChangeListener;
|
mContentChangeListener = contentChangeListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ public class KeyguardStatusView extends GridLayout implements
|
|||||||
private float mDarkAmount = 0;
|
private float mDarkAmount = 0;
|
||||||
private int mTextColor;
|
private int mTextColor;
|
||||||
private float mWidgetPadding;
|
private float mWidgetPadding;
|
||||||
private boolean mAnimateLayout;
|
|
||||||
private int mLastLayoutHeight;
|
private int mLastLayoutHeight;
|
||||||
|
|
||||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
@@ -185,7 +184,7 @@ public class KeyguardStatusView extends GridLayout implements
|
|||||||
mClockView.addOnLayoutChangeListener(this);
|
mClockView.addOnLayoutChangeListener(this);
|
||||||
mClockSeparator.addOnLayoutChangeListener(this);
|
mClockSeparator.addOnLayoutChangeListener(this);
|
||||||
mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);
|
mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);
|
||||||
onSliceContentChanged(false /* animated */);
|
onSliceContentChanged();
|
||||||
|
|
||||||
boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
|
boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
|
||||||
setEnableMarquee(shouldMarquee);
|
setEnableMarquee(shouldMarquee);
|
||||||
@@ -199,8 +198,7 @@ public class KeyguardStatusView extends GridLayout implements
|
|||||||
mClockView.setElegantTextHeight(false);
|
mClockView.setElegantTextHeight(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSliceContentChanged(boolean animated) {
|
private void onSliceContentChanged() {
|
||||||
mAnimateLayout = animated;
|
|
||||||
boolean smallClock = mKeyguardSlice.hasHeader() || mPulsing;
|
boolean smallClock = mKeyguardSlice.hasHeader() || mPulsing;
|
||||||
float clockScale = smallClock ? mSmallClockScale : 1;
|
float clockScale = smallClock ? mSmallClockScale : 1;
|
||||||
|
|
||||||
@@ -228,10 +226,12 @@ public class KeyguardStatusView extends GridLayout implements
|
|||||||
long duration = KeyguardSliceView.DEFAULT_ANIM_DURATION;
|
long duration = KeyguardSliceView.DEFAULT_ANIM_DURATION;
|
||||||
long delay = smallClock ? 0 : duration / 4;
|
long delay = smallClock ? 0 : duration / 4;
|
||||||
|
|
||||||
|
boolean shouldAnimate = mKeyguardSlice.getLayoutTransition() != null
|
||||||
|
&& mKeyguardSlice.getLayoutTransition().isRunning();
|
||||||
if (view == mClockView) {
|
if (view == mClockView) {
|
||||||
float clockScale = smallClock ? mSmallClockScale : 1;
|
float clockScale = smallClock ? mSmallClockScale : 1;
|
||||||
Paint.Style style = smallClock ? Paint.Style.FILL_AND_STROKE : Paint.Style.FILL;
|
Paint.Style style = smallClock ? Paint.Style.FILL_AND_STROKE : Paint.Style.FILL;
|
||||||
if (mAnimateLayout) {
|
if (shouldAnimate) {
|
||||||
mClockView.setY(oldTop + heightOffset);
|
mClockView.setY(oldTop + heightOffset);
|
||||||
mClockView.animate().cancel();
|
mClockView.animate().cancel();
|
||||||
mClockView.animate()
|
mClockView.animate()
|
||||||
@@ -257,7 +257,7 @@ public class KeyguardStatusView extends GridLayout implements
|
|||||||
} else if (view == mClockSeparator) {
|
} else if (view == mClockSeparator) {
|
||||||
boolean hasSeparator = hasHeader && !mPulsing;
|
boolean hasSeparator = hasHeader && !mPulsing;
|
||||||
float alpha = hasSeparator ? 1 : 0;
|
float alpha = hasSeparator ? 1 : 0;
|
||||||
if (mAnimateLayout) {
|
if (shouldAnimate) {
|
||||||
boolean isAwake = mDarkAmount != 0;
|
boolean isAwake = mDarkAmount != 0;
|
||||||
mClockSeparator.setY(oldTop + heightOffset);
|
mClockSeparator.setY(oldTop + heightOffset);
|
||||||
mClockSeparator.animate().cancel();
|
mClockSeparator.animate().cancel();
|
||||||
|
|||||||
@@ -57,9 +57,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase {
|
|||||||
public void showSlice_notifiesListener() {
|
public void showSlice_notifiesListener() {
|
||||||
ListBuilder builder = new ListBuilder(getContext(), mSliceUri);
|
ListBuilder builder = new ListBuilder(getContext(), mSliceUri);
|
||||||
AtomicBoolean notified = new AtomicBoolean();
|
AtomicBoolean notified = new AtomicBoolean();
|
||||||
mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
|
mKeyguardSliceView.setContentChangeListener(()-> notified.set(true));
|
||||||
notified.set(true);
|
|
||||||
});
|
|
||||||
mKeyguardSliceView.onChanged(builder.build());
|
mKeyguardSliceView.onChanged(builder.build());
|
||||||
Assert.assertTrue("Listener should be notified about slice changes.",
|
Assert.assertTrue("Listener should be notified about slice changes.",
|
||||||
notified.get());
|
notified.get());
|
||||||
@@ -68,9 +66,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void showSlice_emptySliceNotifiesListener() {
|
public void showSlice_emptySliceNotifiesListener() {
|
||||||
AtomicBoolean notified = new AtomicBoolean();
|
AtomicBoolean notified = new AtomicBoolean();
|
||||||
mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
|
mKeyguardSliceView.setContentChangeListener(()-> notified.set(true));
|
||||||
notified.set(true);
|
|
||||||
});
|
|
||||||
mKeyguardSliceView.onChanged(null);
|
mKeyguardSliceView.onChanged(null);
|
||||||
Assert.assertTrue("Listener should be notified about slice changes.",
|
Assert.assertTrue("Listener should be notified about slice changes.",
|
||||||
notified.get());
|
notified.get());
|
||||||
@@ -92,9 +88,7 @@ public class KeyguardSliceViewTest extends SysuiTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void refresh_replacesSliceContentAndNotifiesListener() {
|
public void refresh_replacesSliceContentAndNotifiesListener() {
|
||||||
AtomicBoolean notified = new AtomicBoolean();
|
AtomicBoolean notified = new AtomicBoolean();
|
||||||
mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
|
mKeyguardSliceView.setContentChangeListener(()-> notified.set(true));
|
||||||
notified.set(true);
|
|
||||||
});
|
|
||||||
mKeyguardSliceView.refresh();
|
mKeyguardSliceView.refresh();
|
||||||
Assert.assertTrue("Listener should be notified about slice changes.",
|
Assert.assertTrue("Listener should be notified about slice changes.",
|
||||||
notified.get());
|
notified.get());
|
||||||
|
|||||||
Reference in New Issue
Block a user