Merge "Remove ENABLE_QUICKSTEP_LIVE_TILE flag" into tm-qpr-dev
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index c85e71c..fb78ef7 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -258,7 +258,7 @@
<dimen name="taskbar_contextual_button_padding">16dp</dimen>
<dimen name="taskbar_contextual_padding_top">8dp</dimen>
<dimen name="taskbar_nav_buttons_size">44dp</dimen>
- <dimen name="taskbar_contextual_button_margin">47dp</dimen>
+ <dimen name="taskbar_contextual_button_margin">48dp</dimen>
<dimen name="taskbar_hotseat_nav_spacing">24dp</dimen>
<dimen name="taskbar_contextual_buttons_size">35dp</dimen>
<dimen name="taskbar_stashed_size">24dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
index 1c345a6..725ce11 100644
--- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java
@@ -126,7 +126,8 @@
public static final int ALPHA_INDEX_IMMERSIVE_MODE = 0;
public static final int ALPHA_INDEX_KEYGUARD_OR_DISABLE = 1;
- private static final int NUM_ALPHA_CHANNELS = 2;
+ public static final int ALPHA_INDEX_SUW = 2;
+ private static final int NUM_ALPHA_CHANNELS = 3;
private final ArrayList<StatePropertyHolder> mPropertyHolders = new ArrayList<>();
private final ArrayList<ImageView> mAllButtons = new ArrayList<>();
@@ -270,11 +271,17 @@
// end-aligned, so start-align instead.
FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
mNavButtonContainer.getLayoutParams();
- navButtonsLayoutParams.setMarginStart(navButtonsLayoutParams.getMarginEnd());
+ navButtonsLayoutParams.setMarginStart(
+ resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin));
navButtonsLayoutParams.setMarginEnd(0);
navButtonsLayoutParams.gravity = Gravity.START;
mNavButtonContainer.requestLayout();
+ // Hide back button in SUW if keyboard is showing (IME draws its own back).
+ mPropertyHolders.add(new StatePropertyHolder(
+ mBackButtonAlpha.getProperty(ALPHA_INDEX_SUW),
+ flags -> (flags & FLAG_IME_VISIBLE) == 0));
+
// TODO(b/210906568) Dark intensity is currently not propagated during setup, so set
// it based on dark theme for now.
int mode = resources.getConfiguration().uiMode
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 58c689b..de37b70 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -50,7 +50,6 @@
import java.util.HashMap;
import java.util.StringJoiner;
import java.util.function.Consumer;
-import java.util.function.Supplier;
/**
* Track LauncherState, RecentsAnimation, resumed state for task bar in one place here and animate
@@ -65,15 +64,12 @@
public static final int FLAG_RECENTS_ANIMATION_RUNNING = 1 << 1;
public static final int FLAG_TRANSITION_STATE_RUNNING = 1 << 2;
+ private static final int FLAGS_LAUNCHER = FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING;
/** Equivalent to an int with all 1s for binary operation purposes */
private static final int FLAGS_ALL = ~0;
- private final AnimatedFloat mIconAlignmentForResumedState =
- new AnimatedFloat(this::onIconAlignmentRatioChangedForAppAndHomeTransition);
- private final AnimatedFloat mIconAlignmentForGestureState =
- new AnimatedFloat(this::onIconAlignmentRatioChangedForAppAndHomeTransition);
- private final AnimatedFloat mIconAlignmentForLauncherState =
- new AnimatedFloat(this::onIconAlignmentRatioChangedForStateTransition);
+ private final AnimatedFloat mIconAlignment =
+ new AnimatedFloat(this::onIconAlignmentRatioChanged);
private TaskbarControllers mControllers;
private AnimatedFloat mTaskbarBackgroundAlpha;
@@ -86,8 +82,7 @@
private @Nullable TaskBarRecentsAnimationListener mTaskBarRecentsAnimationListener;
- private boolean mIsAnimatingToLauncherViaGesture;
- private boolean mIsAnimatingToLauncherViaResume;
+ private boolean mIsAnimatingToLauncher;
private boolean mShouldDelayLauncherStateAnim;
@@ -148,8 +143,8 @@
mIconAlphaForHome = taskbarIconAlpha.getProperty(ALPHA_INDEX_HOME);
mIconAlphaForHome.setConsumer(mIconAlphaForHomeConsumer);
- mIconAlignmentForResumedState.finishAnimation();
- onIconAlignmentRatioChangedForAppAndHomeTransition();
+ mIconAlignment.finishAnimation();
+ onIconAlignmentRatioChanged();
mLauncher.getStateManager().addStateListener(mStateListener);
@@ -165,9 +160,7 @@
public void onDestroy() {
mCanSyncViews = false;
- mIconAlignmentForResumedState.finishAnimation();
- mIconAlignmentForGestureState.finishAnimation();
- mIconAlignmentForLauncherState.finishAnimation();
+ mIconAlignment.finishAnimation();
mIconAlphaForHome.setConsumer(null);
mLauncher.getHotseat().setIconsAlpha(1f);
@@ -187,6 +180,9 @@
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
toState.isTaskbarStashed(mLauncher));
+ if (DEBUG) {
+ Log.d(TAG, "createAnimToLauncher - FLAG_IN_APP: " + false);
+ }
stashController.updateStateForFlag(FLAG_IN_APP, false);
updateStateForFlag(FLAG_RECENTS_ANIMATION_RUNNING, true);
@@ -201,7 +197,7 @@
}
public boolean isAnimatingToLauncher() {
- return mIsAnimatingToLauncherViaResume || mIsAnimatingToLauncherViaGesture;
+ return mIsAnimatingToLauncher;
}
public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) {
@@ -261,11 +257,29 @@
}
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
+ boolean goingToLauncher = isInLauncher();
+ final float toAlignment;
+ if (goingToLauncher) {
+ boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
+ boolean willStashVisually = isInStashedState
+ && mControllers.taskbarStashController.supportsVisualStashing();
+ boolean isTaskbarAlignedWithHotseat =
+ mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
+ toAlignment = isTaskbarAlignedWithHotseat && !willStashVisually ? 1 : 0;
+ } else {
+ toAlignment = 0;
+ }
+ if (DEBUG) {
+ Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState)
+ + ", changedFlags: " + getStateString(changedFlags)
+ + ", goingToLauncher: " + goingToLauncher
+ + ", mLauncherState: " + mLauncherState
+ + ", toAlignment: " + toAlignment);
+ }
AnimatorSet animatorSet = new AnimatorSet();
// Add the state animation first to ensure FLAG_IN_STASHED_LAUNCHER_STATE is set and we can
// determine whether goingToUnstashedLauncherStateChanged.
- boolean wasGoingToUnstashedLauncherState = goingToUnstashedLauncherState();
if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
playStateTransitionAnim(animatorSet, duration, committed);
@@ -276,95 +290,69 @@
applyState(0 /* duration */);
}
}
- boolean goingToUnstashedLauncherStateChanged = wasGoingToUnstashedLauncherState
- != goingToUnstashedLauncherState();
- boolean launcherStateChangedDuringAnimToResumeAlignment =
- mIconAlignmentForResumedState.isAnimating() && goingToUnstashedLauncherStateChanged;
- if (hasAnyFlag(changedFlags, FLAG_RESUMED)
- || launcherStateChangedDuringAnimToResumeAlignment) {
- boolean isResumed = isResumed();
- // If launcher is resumed, we show the icons when going to an unstashed launcher state
- // or launcher state is not changed (e.g. in overview, launcher is paused and resumed).
- float toAlignmentForResumedState = isResumed && (goingToUnstashedLauncherState()
- || !goingToUnstashedLauncherStateChanged) ? 1 : 0;
- // If we're already animating to the value, just leave it be instead of restarting it.
- if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) {
- ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState
- .animateToValue(toAlignmentForResumedState)
- .setDuration(duration);
- if (DEBUG) {
- Log.d(TAG, "mIconAlignmentForResumedState - "
- + mIconAlignmentForResumedState.value
- + " -> " + toAlignmentForResumedState + ": " + duration);
+ if (hasAnyFlag(changedFlags, FLAGS_LAUNCHER)) {
+ animatorSet.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mIsAnimatingToLauncher = false;
}
- resumeAlignAnim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mIsAnimatingToLauncherViaResume = false;
+ @Override
+ public void onAnimationStart(Animator animation) {
+ mIsAnimatingToLauncher = goingToLauncher;
+
+ TaskbarStashController stashController =
+ mControllers.taskbarStashController;
+ if (DEBUG) {
+ Log.d(TAG, "onAnimationStart - FLAG_IN_APP: " + !goingToLauncher);
}
-
- @Override
- public void onAnimationStart(Animator animation) {
- mIsAnimatingToLauncherViaResume = isResumed;
-
- TaskbarStashController stashController =
- mControllers.taskbarStashController;
- stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
- stashController.applyState(duration);
- }
- });
- animatorSet.play(resumeAlignAnim);
- }
- }
-
-
- boolean launcherStateChangedDuringAnimToGestureAlignment =
- mIconAlignmentForGestureState.isAnimating() && goingToUnstashedLauncherStateChanged;
- if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)
- || launcherStateChangedDuringAnimToGestureAlignment) {
- boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
- float toAlignmentForGestureState = isRecentsAnimationRunning
- && goingToUnstashedLauncherState() ? 1 : 0;
- // If we're already animating to the value, just leave it be instead of restarting it.
- if (!mIconAlignmentForGestureState.isAnimatingToValue(toAlignmentForGestureState)) {
- Animator gestureAlignAnim = mIconAlignmentForGestureState
- .animateToValue(toAlignmentForGestureState);
- if (isRecentsAnimationRunning) {
- gestureAlignAnim.setDuration(duration);
+ stashController.updateStateForFlag(FLAG_IN_APP, !goingToLauncher);
+ stashController.applyState(duration);
}
- if (DEBUG) {
- Log.d(TAG, "mIconAlignmentForGestureState - "
- + mIconAlignmentForGestureState.value
- + " -> " + toAlignmentForGestureState + ": " + duration);
- }
- gestureAlignAnim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mIsAnimatingToLauncherViaGesture = false;
- }
+ });
- @Override
- public void onAnimationStart(Animator animation) {
- mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
- }
- });
- animatorSet.play(gestureAlignAnim);
- }
- }
-
- if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
- boolean goingToLauncher = hasAnyFlag(FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING);
if (goingToLauncher) {
// Handle closing open popups when going home/overview
AbstractFloatingView.closeAllOpenViews(mControllers.taskbarActivityContext);
}
- animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(goingToLauncher ? 0 : 1)
+ }
+
+ float backgroundAlpha =
+ goingToLauncher && mLauncherState.isTaskbarAlignedWithHotseat(mLauncher)
+ ? 0 : 1;
+ // Don't animate if background has reached desired value.
+ if (mTaskbarBackgroundAlpha.isAnimating()
+ || mTaskbarBackgroundAlpha.value != backgroundAlpha) {
+ mTaskbarBackgroundAlpha.cancelAnimation();
+ if (DEBUG) {
+ Log.d(TAG, "onStateChangeApplied - taskbarBackgroundAlpha - "
+ + mTaskbarBackgroundAlpha.value
+ + " -> " + backgroundAlpha + ": " + duration);
+ }
+ animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(backgroundAlpha)
.setDuration(duration));
}
+ if (mIconAlignment.isAnimatingToValue(toAlignment)
+ || mIconAlignment.isSettledOnValue(toAlignment)) {
+ // Already at desired value, but make sure we run the callback at the end.
+ animatorSet.addListener(AnimatorListeners.forEndCallback(
+ this::onIconAlignmentRatioChanged));
+ } else {
+ mIconAlignment.cancelAnimation();
+ ObjectAnimator iconAlignAnim = mIconAlignment
+ .animateToValue(toAlignment)
+ .setDuration(duration);
+ if (DEBUG) {
+ Log.d(TAG, "onStateChangeApplied - iconAlignment - "
+ + mIconAlignment.value
+ + " -> " + toAlignment + ": " + duration);
+ }
+ animatorSet.play(iconAlignAnim);
+ }
animatorSet.setInterpolator(EMPHASIZED);
+
if (start) {
animatorSet.start();
}
@@ -372,18 +360,13 @@
}
/** Returns whether we're going to a state where taskbar icons should align with launcher. */
- private boolean goingToUnstashedLauncherState() {
- return !mControllers.taskbarStashController.isInStashedLauncherState();
+ public boolean goingToAlignedLauncherState() {
+ return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
}
private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
boolean committed) {
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
- boolean willStashVisually =
- isInStashedState && mControllers.taskbarStashController.supportsVisualStashing();
- float toAlignment =
- mLauncherState.isTaskbarAlignedWithHotseat(mLauncher) && !willStashVisually ? 1 : 0;
-
TaskbarStashController stashController = mControllers.taskbarStashController;
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
Animator stashAnimator = stashController.applyStateWithoutStart(duration);
@@ -406,55 +389,23 @@
});
animatorSet.play(stashAnimator);
}
- if (mIconAlignmentForLauncherState.value == toAlignment) {
- // Already at expected value, but make sure we run the callback at the end.
- animatorSet.addListener(AnimatorListeners.forEndCallback(
- this::onIconAlignmentRatioChangedForStateTransition));
- }
- if (!mIconAlignmentForLauncherState.isAnimatingToValue(toAlignment)) {
- // If we're already animating to the value, just leave it be instead of restarting it.
- mIconAlignmentForLauncherState.finishAnimation();
- animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
- .setDuration(duration));
- if (DEBUG) {
- Log.d(TAG, "mIconAlignmentForLauncherState - "
- + mIconAlignmentForLauncherState.value
- + " -> " + toAlignment + ": " + duration);
- }
- animatorSet.setInterpolator(EMPHASIZED);
- }
}
- private boolean isResumed() {
- return (mState & FLAG_RESUMED) != 0;
+ private boolean isInLauncher() {
+ return (mState & FLAGS_LAUNCHER) != 0;
}
- private boolean isRecentsAnimationRunning() {
- return (mState & FLAG_RECENTS_ANIMATION_RUNNING) != 0;
- }
-
- private void onIconAlignmentRatioChangedForStateTransition() {
- if (!isResumed() && mTaskBarRecentsAnimationListener == null) {
- return;
- }
- onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioForLauncherState);
- }
-
- private void onIconAlignmentRatioChangedForAppAndHomeTransition() {
- onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioBetweenAppAndHome);
- }
-
- private void onIconAlignmentRatioChanged(Supplier<AnimatedFloat> alignmentSupplier) {
- if (mControllers == null) {
- return;
- }
- AnimatedFloat animatedFloat = alignmentSupplier.get();
+ private void onIconAlignmentRatioChanged() {
float currentValue = mIconAlphaForHome.getValue();
- boolean taskbarWillBeVisible = animatedFloat.value < 1;
+ boolean taskbarWillBeVisible = mIconAlignment.value < 1;
boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
- updateIconAlignment(animatedFloat.value, animatedFloat.getEndValue());
+ mControllers.taskbarViewController.setLauncherIconAlignment(
+ mIconAlignment.value, mIconAlignment.getEndValue(), mLauncher.getDeviceProfile());
+ mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
+ // Switch taskbar and hotseat in last frame
+ mIconAlphaForHome.setValue(taskbarWillBeVisible ? 1 : 0);
// Sync the first frame where we swap taskbar and hotseat.
if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
@@ -464,28 +415,6 @@
}
}
- private void updateIconAlignment(float alignment, Float endAlignment) {
- mControllers.taskbarViewController.setLauncherIconAlignment(
- alignment, endAlignment, mLauncher.getDeviceProfile());
-
- // Switch taskbar and hotseat in last frame
- setTaskbarViewVisible(alignment < 1);
- mControllers.navbarButtonsViewController.updateTaskbarAlignment(alignment);
- }
-
- private AnimatedFloat getCurrentIconAlignmentRatioBetweenAppAndHome() {
- return mIconAlignmentForResumedState.value > mIconAlignmentForGestureState.value
- ? mIconAlignmentForResumedState : mIconAlignmentForGestureState;
- }
-
- private AnimatedFloat getCurrentIconAlignmentRatioForLauncherState() {
- return mIconAlignmentForLauncherState;
- }
-
- private void setTaskbarViewVisible(boolean isVisible) {
- mIconAlphaForHome.setValue(isVisible ? 1 : 0);
- }
-
private final class TaskBarRecentsAnimationListener implements
RecentsAnimationCallbacks.RecentsAnimationListener {
private final RecentsAnimationCallbacks mCallbacks;
@@ -515,11 +444,11 @@
updateStateForFlag(FLAG_RECENTS_ANIMATION_RUNNING, false);
updateStateForFlag(FLAG_RESUMED, launcherResumed);
applyState();
- // Set this last because applyState() might also animate it.
- mIconAlignmentForResumedState.cancelAnimation();
- mIconAlignmentForResumedState.updateValue(launcherResumed ? 1 : 0);
TaskbarStashController controller = mControllers.taskbarStashController;
+ if (DEBUG) {
+ Log.d(TAG, "endGestureStateOverride - FLAG_IN_APP: " + finishedToApp);
+ }
controller.updateStateForFlag(FLAG_IN_APP, finishedToApp);
controller.applyState();
}
@@ -527,29 +456,24 @@
private static String getStateString(int flags) {
StringJoiner str = new StringJoiner("|");
- str.add((flags & FLAG_RESUMED) != 0 ? "FLAG_RESUMED" : "");
- str.add((flags & FLAG_RECENTS_ANIMATION_RUNNING) != 0
- ? "FLAG_RECENTS_ANIMATION_RUNNING" : "");
- str.add((flags & FLAG_TRANSITION_STATE_RUNNING) != 0
- ? "FLAG_TRANSITION_STATE_RUNNING" : "");
+ if ((flags & FLAG_RESUMED) != 0) {
+ str.add("FLAG_RESUMED");
+ }
+ if ((flags & FLAG_RECENTS_ANIMATION_RUNNING) != 0) {
+ str.add("FLAG_RECENTS_ANIMATION_RUNNING");
+ }
+ if ((flags & FLAG_TRANSITION_STATE_RUNNING) != 0) {
+ str.add("FLAG_TRANSITION_STATE_RUNNING");
+ }
return str.toString();
}
protected void dumpLogs(String prefix, PrintWriter pw) {
pw.println(prefix + "TaskbarLauncherStateController:");
-
pw.println(String.format(
- "%s\tmIconAlignmentForResumedState=%.2f",
+ "%s\tmIconAlignment=%.2f",
prefix,
- mIconAlignmentForResumedState.value));
- pw.println(String.format(
- "%s\tmIconAlignmentForGestureState=%.2f",
- prefix,
- mIconAlignmentForGestureState.value));
- pw.println(String.format(
- "%s\tmIconAlignmentForLauncherState=%.2f",
- prefix,
- mIconAlignmentForLauncherState.value));
+ mIconAlignment.value));
pw.println(String.format(
"%s\tmTaskbarBackgroundAlpha=%.2f", prefix, mTaskbarBackgroundAlpha.value));
pw.println(String.format(
@@ -558,13 +482,9 @@
pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState)));
pw.println(String.format("%s\tmLauncherState=%s", prefix, mLauncherState));
pw.println(String.format(
- "%s\tmIsAnimatingToLauncherViaGesture=%b",
+ "%s\tmIsAnimatingToLauncher=%b",
prefix,
- mIsAnimatingToLauncherViaGesture));
- pw.println(String.format(
- "%s\tmIsAnimatingToLauncherViaResume=%b",
- prefix,
- mIsAnimatingToLauncherViaResume));
+ mIsAnimatingToLauncher));
pw.println(String.format(
"%s\tmShouldDelayLauncherStateAnim=%b", prefix, mShouldDelayLauncherStateAnim));
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
index 00d5083..16dd90d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java
@@ -102,6 +102,9 @@
private int mThemeIconsColor;
+ private final DeviceProfile.OnDeviceProfileChangeListener mDeviceProfileChangeListener =
+ dp -> commitRunningAppsToUI();
+
public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
mActivity = activity;
mTaskbarView = taskbarView;
@@ -129,10 +132,13 @@
controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY();
mTaskbarNavButtonTranslationYForInAppDisplay = controllers.navbarButtonsViewController
.getTaskbarNavButtonTranslationYForInAppDisplay();
+
+ mActivity.addOnDeviceProfileChangeListener(mDeviceProfileChangeListener);
}
public void onDestroy() {
LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks);
+ mActivity.removeOnDeviceProfileChangeListener(mDeviceProfileChangeListener);
mModelCallbacks.unregisterListeners();
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt
index 81acda3..076900c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/VoiceInteractionWindowController.kt
@@ -77,7 +77,7 @@
fadeStashedHandle.end()
}
- moveTaskbarBackgroundToAppropriateLayer()
+ moveTaskbarBackgroundToAppropriateLayer(skipAnim)
}
/**
@@ -86,24 +86,28 @@
* OR
* Removes the temporary window and show the TaskbarDragLayer background again.
*/
- private fun moveTaskbarBackgroundToAppropriateLayer() {
+ private fun moveTaskbarBackgroundToAppropriateLayer(skipAnim: Boolean) {
val taskbarBackgroundOverride = controllers.taskbarDragLayerController
.overrideBackgroundAlpha
val moveToLowerLayer = isVoiceInteractionWindowVisible
- if (moveToLowerLayer) {
+ val onWindowsSynchronized = if (moveToLowerLayer) {
// First add the temporary window, then hide the overlapping taskbar background.
- context.addWindowView(separateWindowForTaskbarBackground, separateWindowLayoutParams)
- ViewRootSync.synchronizeNextDraw(separateWindowForTaskbarBackground, context.dragLayer
- ) {
- taskbarBackgroundOverride.updateValue(0f)
- }
+ context.addWindowView(separateWindowForTaskbarBackground, separateWindowLayoutParams);
+ { taskbarBackgroundOverride.updateValue(0f) }
} else {
// First reapply the original taskbar background, then remove the temporary window.
- taskbarBackgroundOverride.updateValue(1f)
- ViewRootSync.synchronizeNextDraw(separateWindowForTaskbarBackground, context.dragLayer
- ) {
- context.removeWindowView(separateWindowForTaskbarBackground)
- }
+ taskbarBackgroundOverride.updateValue(1f);
+ { context.removeWindowView(separateWindowForTaskbarBackground) }
+ }
+
+ if (skipAnim) {
+ onWindowsSynchronized()
+ } else {
+ ViewRootSync.synchronizeNextDraw(
+ separateWindowForTaskbarBackground,
+ context.dragLayer,
+ onWindowsSynchronized
+ )
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
index cbb9ad1..910b99b 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/RecentsViewStateController.java
@@ -130,10 +130,11 @@
mRecentsView.createSplitSelectInitAnimation(builder,
toState.getTransitionDuration(mLauncher, true /* isToState */));
- // Add properties to shift remaining taskViews to get out of placeholder view
+ // Shift tasks vertically downward to get out of placeholder view
builder.setFloat(mRecentsView, taskViewsFloat.first,
toState.getSplitSelectTranslation(mLauncher),
timings.getGridSlidePrimaryInterpolator());
+ // Zero out horizontal translation
builder.setFloat(mRecentsView, taskViewsFloat.second,
0,
timings.getGridSlideSecondaryInterpolator());
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
index bcd722f..da07edf 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/QuickstepAtomicAnimationFactory.java
@@ -197,7 +197,8 @@
config.setInterpolator(ANIM_OVERVIEW_ACTIONS_FADE, clampToProgress(LINEAR,
timings.getActionsFadeStartOffset(),
timings.getActionsFadeEndOffset()));
- } else if (fromState == NORMAL && toState == OVERVIEW_SPLIT_SELECT) {
+ } else if ((fromState == NORMAL || fromState == ALL_APPS)
+ && toState == OVERVIEW_SPLIT_SELECT) {
// Splitting from Home is currently only available on tablets
SplitAnimationTimings timings = SplitAnimationTimings.TABLET_HOME_TO_SPLIT;
config.setInterpolator(ANIM_SCRIM_FADE, clampToProgress(LINEAR,
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index a78142d..9106a8f 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -999,8 +999,8 @@
switch (endTarget) {
case HOME:
mStateCallback.setState(STATE_SCALED_CONTROLLER_HOME | STATE_CAPTURE_SCREENSHOT);
- // Notify swipe-to-home (recents animation) is finished
- SystemUiProxy.INSTANCE.get(mContext).notifySwipeToHomeFinished();
+ // Notify the SysUI to use fade-in animation when entering PiP
+ SystemUiProxy.INSTANCE.get(mContext).setPipAnimationTypeToAlpha();
break;
case RECENTS:
mStateCallback.setState(STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT
diff --git a/quickstep/src/com/android/quickstep/AnimatedFloat.java b/quickstep/src/com/android/quickstep/AnimatedFloat.java
index a166553..b06b894 100644
--- a/quickstep/src/com/android/quickstep/AnimatedFloat.java
+++ b/quickstep/src/com/android/quickstep/AnimatedFloat.java
@@ -135,6 +135,13 @@
}
/**
+ * Returns whether we are currently not animating, and the animation's value matches the given.
+ */
+ public boolean isSettledOnValue(float endValue) {
+ return !isAnimating() && value == endValue;
+ }
+
+ /**
* Returns the value we are animating to, or {@code null} if we are not currently animating.
*/
public Float getEndValue() {
diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
index 36ca993..d1533f0 100644
--- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
+++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java
@@ -84,7 +84,8 @@
final View workspaceView = findWorkspaceView(launchCookies,
mRecentsView.getRunningTaskView());
- boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow();
+ boolean canUseWorkspaceView = workspaceView != null && workspaceView.isAttachedToWindow()
+ && workspaceView.getHeight() > 0;
mActivity.getRootView().setForceHideBackArrow(true);
if (!TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java
index 3b2df31..35d7394 100644
--- a/quickstep/src/com/android/quickstep/SystemUiProxy.java
+++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java
@@ -187,7 +187,7 @@
linkToDeath();
// re-attach the listeners once missing due to setProxy has not been initialized yet.
if (mPipAnimationListener != null && mPip != null) {
- setPinnedStackAnimationListener(mPipAnimationListener);
+ setPipAnimationListener(mPipAnimationListener);
}
if (mSplitScreenListener != null && mSplitScreen != null) {
registerSplitScreenListener(mSplitScreenListener);
@@ -357,20 +357,6 @@
}
}
- /**
- * Notifies that swipe-to-home action is finished.
- */
- @Override
- public void notifySwipeToHomeFinished() {
- if (mSystemUiProxy != null) {
- try {
- mSystemUiProxy.notifySwipeToHomeFinished();
- } catch (RemoteException e) {
- Log.w(TAG, "Failed call notifySwipeToHomeFinished", e);
- }
- }
- }
-
@Override
public void notifyPrioritizedRotation(int rotation) {
if (mSystemUiProxy != null) {
@@ -475,12 +461,12 @@
}
/**
- * Sets listener to get pinned stack animation callbacks.
+ * Sets listener to get pip animation callbacks.
*/
- public void setPinnedStackAnimationListener(IPipAnimationListener listener) {
+ public void setPipAnimationListener(IPipAnimationListener listener) {
if (mPip != null) {
try {
- mPip.setPinnedStackAnimationListener(listener);
+ mPip.setPipAnimationListener(listener);
} catch (RemoteException e) {
Log.w(TAG, "Failed call setPinnedStackAnimationListener", e);
}
@@ -522,6 +508,19 @@
}
}
+ /**
+ * Sets the next pip animation type to be the alpha animation.
+ */
+ public void setPipAnimationTypeToAlpha() {
+ if (mPip != null) {
+ try {
+ mPip.setPipAnimationTypeToAlpha();
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed call setPipAnimationTypeToAlpha", e);
+ }
+ }
+ }
+
//
// Splitscreen
//
diff --git a/quickstep/src/com/android/quickstep/util/OverviewToSplitTimings.java b/quickstep/src/com/android/quickstep/util/OverviewToSplitTimings.java
index d46c0f8..e189a66 100644
--- a/quickstep/src/com/android/quickstep/util/OverviewToSplitTimings.java
+++ b/quickstep/src/com/android/quickstep/util/OverviewToSplitTimings.java
@@ -16,6 +16,9 @@
package com.android.quickstep.util;
+import static com.android.launcher3.anim.Interpolators.EMPHASIZED;
+import static com.android.launcher3.anim.Interpolators.INSTANT;
+
import android.view.animation.Interpolator;
/**
@@ -44,14 +47,14 @@
public int getInstructionsTextFadeInEnd() { return 300; }
public int getInstructionsUnfoldStart() { return 167; }
public int getInstructionsUnfoldEnd() { return 500; }
+ public Interpolator getGridSlidePrimaryInterpolator() { return EMPHASIZED; }
+ public Interpolator getGridSlideSecondaryInterpolator() { return INSTANT; }
abstract public int getDuration();
abstract public Interpolator getStagedRectXInterpolator();
abstract public Interpolator getStagedRectYInterpolator();
abstract public Interpolator getStagedRectScaleXInterpolator();
abstract public Interpolator getStagedRectScaleYInterpolator();
- abstract public Interpolator getGridSlidePrimaryInterpolator();
- abstract public Interpolator getGridSlideSecondaryInterpolator();
public float getGridSlideStartOffset() {
return (float) getGridSlideStart() / getDuration();
diff --git a/quickstep/src/com/android/quickstep/util/PhoneOverviewToSplitTimings.java b/quickstep/src/com/android/quickstep/util/PhoneOverviewToSplitTimings.java
index 66c41d6..f1dde53 100644
--- a/quickstep/src/com/android/quickstep/util/PhoneOverviewToSplitTimings.java
+++ b/quickstep/src/com/android/quickstep/util/PhoneOverviewToSplitTimings.java
@@ -17,7 +17,6 @@
package com.android.quickstep.util;
import static com.android.launcher3.anim.Interpolators.EMPHASIZED;
-import static com.android.launcher3.anim.Interpolators.INSTANT;
import android.view.animation.Interpolator;
@@ -41,6 +40,4 @@
public Interpolator getStagedRectYInterpolator() { return EMPHASIZED; }
public Interpolator getStagedRectScaleXInterpolator() { return EMPHASIZED; }
public Interpolator getStagedRectScaleYInterpolator() { return EMPHASIZED; }
- public Interpolator getGridSlidePrimaryInterpolator() { return EMPHASIZED; }
- public Interpolator getGridSlideSecondaryInterpolator() { return INSTANT; }
}
diff --git a/quickstep/src/com/android/quickstep/util/TabletOverviewToSplitTimings.java b/quickstep/src/com/android/quickstep/util/TabletOverviewToSplitTimings.java
index 30defa7..cbf46bf 100644
--- a/quickstep/src/com/android/quickstep/util/TabletOverviewToSplitTimings.java
+++ b/quickstep/src/com/android/quickstep/util/TabletOverviewToSplitTimings.java
@@ -17,7 +17,6 @@
package com.android.quickstep.util;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
-import static com.android.launcher3.anim.Interpolators.LINEAR;
import android.view.animation.Interpolator;
@@ -41,6 +40,4 @@
public Interpolator getStagedRectYInterpolator() { return DEACCEL_2; }
public Interpolator getStagedRectScaleXInterpolator() { return DEACCEL_2; }
public Interpolator getStagedRectScaleYInterpolator() { return DEACCEL_2; }
- public Interpolator getGridSlidePrimaryInterpolator() { return LINEAR; }
- public Interpolator getGridSlideSecondaryInterpolator() { return LINEAR; }
}
diff --git a/quickstep/src/com/android/quickstep/util/ViewCapture.java b/quickstep/src/com/android/quickstep/util/ViewCapture.java
index cfcfce0..6171c5d 100644
--- a/quickstep/src/com/android/quickstep/util/ViewCapture.java
+++ b/quickstep/src/com/android/quickstep/util/ViewCapture.java
@@ -421,7 +421,6 @@
out.visibility = this.visibility;
out.willNotDraw = this.willNotDraw;
out.clipChildren = this.clipChildren;
- out.next = this.next;
out.elevation = this.elevation;
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 4fba8d6..d9a4be8 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -939,7 +939,7 @@
.setSyncTransactionApplier(mSyncTransactionApplier));
RecentsModel.INSTANCE.get(getContext()).addThumbnailChangeListener(this);
mIPipAnimationListener.setActivityAndRecentsView(mActivity, this);
- SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(
+ SystemUiProxy.INSTANCE.get(getContext()).setPipAnimationListener(
mIPipAnimationListener);
mOrientationState.initListeners();
SplitScreenBounds.INSTANCE.addOnChangeListener(this);
@@ -958,7 +958,7 @@
.setSyncTransactionApplier(null));
executeSideTaskLaunchCallback();
RecentsModel.INSTANCE.get(getContext()).removeThumbnailChangeListener(this);
- SystemUiProxy.INSTANCE.get(getContext()).setPinnedStackAnimationListener(null);
+ SystemUiProxy.INSTANCE.get(getContext()).setPipAnimationListener(null);
SplitScreenBounds.INSTANCE.removeOnChangeListener(this);
mIPipAnimationListener.setActivityAndRecentsView(null, null);
mOrientationState.destroyListeners();
@@ -1720,6 +1720,7 @@
// Changed orientations, update controllers so they intercept accordingly.
mActivity.getDragLayer().recreateControllers();
onOrientationChanged();
+ resetTaskVisuals();
}
boolean isInLandscape = mOrientationState.getTouchRotation() != ROTATION_0
@@ -3104,6 +3105,7 @@
+ splitTimings.getGridSlideDurationOffset(), 0f, 1f)
: 1f;
+ // Slide tiles in horizontally to fill dismissed area
anim.setFloat(child, translationProperty, scrollDiff,
clampToProgress(
splitTimings.getGridSlidePrimaryInterpolator(),
@@ -4139,6 +4141,9 @@
null /* onFinishComplete */);
}
+ /**
+ * Called when staging a split from Home/AllApps, using the icon long-press menu.
+ */
public void initiateSplitSelect(QuickstepSystemShortcut.SplitSelectSource splitSelectSource) {
mSplitSelectSource = splitSelectSource;
mSplitSelectStateController.setInitialTaskSelect(splitSelectSource.intent,
@@ -4269,8 +4274,18 @@
snapToPageImmediately(pageToSnapTo);
}
onLayout(false /* changed */, getLeft(), getTop(), getRight(), getBottom());
+
+ // We are leaving split selection state, so it is safe to reset thumbnail translations for
+ // the next time split is invoked.
+ setTaskViewsPrimarySplitTranslation(0);
+ setTaskViewsSecondarySplitTranslation(0);
+
resetTaskVisuals();
mSplitHiddenTaskViewIndex = -1;
+ if (mSplitHiddenTaskView != null) {
+ mSplitHiddenTaskView.setThumbnailVisibility(VISIBLE);
+ mSplitHiddenTaskView = null;
+ }
}
private void safeRemoveDragLayerView(@Nullable View viewToRemove) {
@@ -4687,7 +4702,7 @@
if (sendUserLeaveHint) {
// Notify the SysUI to use fade-in animation when entering PiP from live tile.
final SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(getContext());
- systemUiProxy.notifySwipeToHomeFinished();
+ systemUiProxy.setPipAnimationTypeToAlpha();
systemUiProxy.setShelfHeight(true, mActivity.getDeviceProfile().hotseatBarSizePx);
// Transaction to hide the task to avoid flicker for entering PiP from split-screen.
// See also {@link AbsSwipeUpHandler#maybeFinishSwipeToHome}.
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index e0b4951..368a373 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -42,25 +42,29 @@
BaseAllAppsAdapter<T> {
public static final String TAG = "AppsGridAdapter";
- private final GridLayoutManager mGridLayoutMgr;
- private final GridSpanSizer mGridSizer;
+ private final AppsGridLayoutManager mGridLayoutMgr;
public AllAppsGridAdapter(T activityContext, LayoutInflater inflater,
AlphabeticalAppsList apps, BaseAdapterProvider[] adapterProviders) {
super(activityContext, inflater, apps, adapterProviders);
- mGridSizer = new GridSpanSizer();
mGridLayoutMgr = new AppsGridLayoutManager(mActivityContext);
- mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
+ mGridLayoutMgr.setSpanSizeLookup(new GridSpanSizer());
setAppsPerRow(activityContext.getDeviceProfile().numShownAllAppsColumns);
}
/**
* Returns the grid layout manager.
*/
- public RecyclerView.LayoutManager getLayoutManager() {
+ public AppsGridLayoutManager getLayoutManager() {
return mGridLayoutMgr;
}
+ /** @return the column index that the given adapter index falls. */
+ public int getSpanIndex(int adapterIndex) {
+ AppsGridLayoutManager lm = getLayoutManager();
+ return lm.getSpanSizeLookup().getSpanIndex(adapterIndex, lm.getSpanCount());
+ }
+
/**
* A subclass of GridLayoutManager that overrides accessibility values during app search.
*/
diff --git a/src/com/android/launcher3/allapps/SearchTransitionController.java b/src/com/android/launcher3/allapps/SearchTransitionController.java
index 8fc7965..a1f5bc6 100644
--- a/src/com/android/launcher3/allapps/SearchTransitionController.java
+++ b/src/com/android/launcher3/allapps/SearchTransitionController.java
@@ -29,6 +29,7 @@
import android.animation.ObjectAnimator;
import android.graphics.drawable.Drawable;
import android.util.FloatProperty;
+import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;
@@ -36,10 +37,13 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
/** Coordinates the transition between Search and A-Z in All Apps. */
public class SearchTransitionController {
+ private static final String LOG_TAG = "SearchTransitionCtrl";
+
// Interpolator when the user taps the QSB while already in All Apps.
private static final Interpolator INTERPOLATOR_WITHIN_ALL_APPS = DEACCEL_1_7;
// Interpolator when the user taps the QSB from home screen, so transition to all apps is
@@ -171,6 +175,7 @@
int appRowHeight = 0;
Integer top = null;
SearchRecyclerView searchRecyclerView = getSearchRecyclerView();
+
for (int i = 0; i < searchRecyclerView.getChildCount(); i++) {
View searchResultView = searchRecyclerView.getChildAt(i);
if (searchResultView == null) {
@@ -226,15 +231,43 @@
float scaleY = 1 - mSearchToAzProgress;
int scaledHeight = (int) (searchResultView.getHeight() * scaleY);
searchResultView.setScaleY(scaleY);
- searchResultView.setY(top + totalHeight);
- numSearchResultsAnimated++;
- totalHeight += scaledHeight;
+ // For rows with multiple elements, only count the height once and translate elements to
+ // the same y position.
+ int y = top + totalHeight;
+ int spanIndex = getSpanIndex(searchRecyclerView, adapterPosition);
+ if (spanIndex > 0) {
+ // Continuation of an existing row; move this item into the row.
+ y -= scaledHeight;
+ } else {
+ // Start of a new row contributes to total height and animation stagger.
+ numSearchResultsAnimated++;
+ totalHeight += scaledHeight;
+ }
+ searchResultView.setY(y);
}
return totalHeight - appRowHeight;
}
+ /** @return the column that the view at this position is found (0 assumed if indeterminate). */
+ private int getSpanIndex(SearchRecyclerView searchRecyclerView, int adapterPosition) {
+ if (adapterPosition == NO_POSITION) {
+ Log.w(LOG_TAG, "Can't determine span index - child not found in adapter");
+ return 0;
+ }
+ if (!(searchRecyclerView.getAdapter() instanceof AllAppsGridAdapter<?>)) {
+ Log.e(LOG_TAG, "Search RV doesn't have an AllAppsGridAdapter?");
+ // This case shouldn't happen, but for debug devices we will continue to create a more
+ // visible crash.
+ if (!Utilities.IS_DEBUG_DEVICE) {
+ return 0;
+ }
+ }
+ AllAppsGridAdapter<?> adapter = (AllAppsGridAdapter<?>) searchRecyclerView.getAdapter();
+ return adapter.getSpanIndex(adapterPosition);
+ }
+
/** Called just before a child is attached to the SearchRecyclerView. */
private void onSearchChildAttached(View child) {
// Avoid allocating hardware layers for alpha changes.
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 28e0b68..b4cb0ee 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -153,6 +153,7 @@
@Override
public void setScroll(int currentScroll, int totalScroll) {
if (mNumPages <= 1) {
+ mCurrentScroll = 0;
return;
}
@@ -296,8 +297,12 @@
for (int i = 0; i < mEntryAnimationRadiusFactors.length; i++) {
mPaginationPaint.setAlpha(i == mActivePage ? PAGE_INDICATOR_ALPHA : DOT_ALPHA);
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
- canvas.drawCircle(x, y, getRadius(x) * mEntryAnimationRadiusFactors[i],
- mPaginationPaint);
+ if (i != mActivePage) {
+ canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i],
+ mPaginationPaint);
+ } else {
+ drawPageIndicator(canvas, mEntryAnimationRadiusFactors[i]);
+ }
} else {
canvas.drawCircle(x, y, mDotRadius * mEntryAnimationRadiusFactors[i],
mPaginationPaint);
@@ -319,20 +324,7 @@
// Here we draw the current page indicator
mPaginationPaint.setAlpha(PAGE_INDICATOR_ALPHA);
if (SHOW_DELIGHTFUL_PAGINATION_FOLDER.get()) {
- RectF currRect = getActiveRect();
-
- // Moves the canvas to start at the top left corner of the page indicator
- canvas.translate(currRect.left, currRect.top);
-
- int scrollPerPage = getScrollPerPage();
- // This IF is to avoid division by 0
- if (scrollPerPage != 0) {
- int delta = mCurrentScroll % scrollPerPage;
- canvas.rotate((INDICATOR_ROTATION * delta) / scrollPerPage,
- mPageIndicatorRadius, mPageIndicatorRadius);
- }
-
- mPageIndicatorDrawable.draw(canvas);
+ drawPageIndicator(canvas, 1);
} else {
canvas.drawRoundRect(getActiveRect(), mDotRadius, mDotRadius, mPaginationPaint);
}
@@ -340,6 +332,36 @@
}
/**
+ * Draws the page indicator, denoting the currently selected page
+ *
+ * @param canvas is used to draw the page indicator and to rotate it as we scroll
+ * @param scale is used to set the scale of our canvas
+ */
+ private void drawPageIndicator(Canvas canvas, float scale) {
+ RectF currRect = getActiveRect();
+
+ // saves the canvas so we can later restore it to its original scale
+ canvas.save();
+
+ // Moves the canvas to start at the top left corner of the page indicator
+ canvas.translate(currRect.left, currRect.top);
+
+ // Scales the canvas in place to animate the indicator on entry
+ canvas.scale(scale, scale, mPageIndicatorRadius, mPageIndicatorRadius);
+
+ int scrollPerPage = getScrollPerPage();
+ // This IF is to avoid division by 0
+ if (scrollPerPage != 0) {
+ int delta = mCurrentScroll % scrollPerPage;
+ canvas.rotate((INDICATOR_ROTATION * delta) / scrollPerPage,
+ mPageIndicatorRadius, mPageIndicatorRadius);
+ }
+
+ mPageIndicatorDrawable.draw(canvas);
+ canvas.restore();
+ }
+
+ /**
* Returns the radius of the circle based on how close the page indicator is to it
*
* @param dotPositionX is the position the dot is located at in the x-axis