Merge "Keeps magnification button StartDelay for 3 secs even remove animations settings is on"
This commit is contained in:
@@ -43,6 +43,7 @@ class MagnificationModeSwitch {
|
|||||||
|
|
||||||
private static final int DURATION_MS = 5000;
|
private static final int DURATION_MS = 5000;
|
||||||
private static final int START_DELAY_MS = 3000;
|
private static final int START_DELAY_MS = 3000;
|
||||||
|
private final Runnable mAnimationTask;
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final WindowManager mWindowManager;
|
private final WindowManager mWindowManager;
|
||||||
@@ -70,6 +71,14 @@ class MagnificationModeSwitch {
|
|||||||
applyResourcesValues();
|
applyResourcesValues();
|
||||||
mImageView.setImageResource(getIconResId(mMagnificationMode));
|
mImageView.setImageResource(getIconResId(mMagnificationMode));
|
||||||
mImageView.setOnTouchListener(this::onTouch);
|
mImageView.setOnTouchListener(this::onTouch);
|
||||||
|
|
||||||
|
mAnimationTask = () -> {
|
||||||
|
mImageView.animate()
|
||||||
|
.alpha(0f)
|
||||||
|
.setDuration(DURATION_MS)
|
||||||
|
.withEndAction(() -> removeButton())
|
||||||
|
.start();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyResourcesValues() {
|
private void applyResourcesValues() {
|
||||||
@@ -147,13 +156,8 @@ class MagnificationModeSwitch {
|
|||||||
// Dismiss the magnification switch button after the button is displayed for a period of
|
// Dismiss the magnification switch button after the button is displayed for a period of
|
||||||
// time.
|
// time.
|
||||||
mImageView.animate().cancel();
|
mImageView.animate().cancel();
|
||||||
mImageView.animate()
|
mImageView.removeCallbacks(mAnimationTask);
|
||||||
.alpha(0f)
|
mImageView.postDelayed(mAnimationTask, START_DELAY_MS);
|
||||||
.setStartDelay(START_DELAY_MS)
|
|
||||||
.setDuration(DURATION_MS)
|
|
||||||
.withEndAction(
|
|
||||||
() -> removeButton())
|
|
||||||
.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onConfigurationChanged(int configDiff) {
|
void onConfigurationChanged(int configDiff) {
|
||||||
|
|||||||
@@ -231,7 +231,6 @@ public class MagnificationModeSwitchTest extends SysuiTestCase {
|
|||||||
private void assertShowButtonAnimation() {
|
private void assertShowButtonAnimation() {
|
||||||
verify(mViewPropertyAnimator).cancel();
|
verify(mViewPropertyAnimator).cancel();
|
||||||
verify(mViewPropertyAnimator).setDuration(anyLong());
|
verify(mViewPropertyAnimator).setDuration(anyLong());
|
||||||
verify(mViewPropertyAnimator).setStartDelay(anyLong());
|
|
||||||
verify(mViewPropertyAnimator).alpha(anyFloat());
|
verify(mViewPropertyAnimator).alpha(anyFloat());
|
||||||
verify(mViewPropertyAnimator).start();
|
verify(mViewPropertyAnimator).start();
|
||||||
}
|
}
|
||||||
@@ -239,11 +238,15 @@ public class MagnificationModeSwitchTest extends SysuiTestCase {
|
|||||||
private void initMockImageViewAndAnimator() {
|
private void initMockImageViewAndAnimator() {
|
||||||
when(mViewPropertyAnimator.setDuration(anyLong())).thenReturn(mViewPropertyAnimator);
|
when(mViewPropertyAnimator.setDuration(anyLong())).thenReturn(mViewPropertyAnimator);
|
||||||
when(mViewPropertyAnimator.alpha(anyFloat())).thenReturn(mViewPropertyAnimator);
|
when(mViewPropertyAnimator.alpha(anyFloat())).thenReturn(mViewPropertyAnimator);
|
||||||
when(mViewPropertyAnimator.setStartDelay(anyLong())).thenReturn(mViewPropertyAnimator);
|
|
||||||
when(mViewPropertyAnimator.withEndAction(any(Runnable.class))).thenReturn(
|
when(mViewPropertyAnimator.withEndAction(any(Runnable.class))).thenReturn(
|
||||||
mViewPropertyAnimator);
|
mViewPropertyAnimator);
|
||||||
|
|
||||||
when(mSpyImageView.animate()).thenReturn(mViewPropertyAnimator);
|
when(mSpyImageView.animate()).thenReturn(mViewPropertyAnimator);
|
||||||
|
doAnswer(invocation -> {
|
||||||
|
Runnable run = invocation.getArgument(0);
|
||||||
|
run.run();
|
||||||
|
return null;
|
||||||
|
}).when(mSpyImageView).postDelayed(any(), anyLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetMockImageViewAndAnimator() {
|
private void resetMockImageViewAndAnimator() {
|
||||||
|
|||||||
Reference in New Issue
Block a user