Merge "Relying on the controller state instead of animator state for icon alignment" into tm-qpr-dev
This commit is contained in:
commit
eeaba0903a
5 files changed
+35
-40
No files matched your search
@@ -355,6 +355,11 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
|||||||
mTaskbarLauncherStateController.applyState();
|
mTaskbarLauncherStateController.applyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isIconAlignedWithHotseat() {
|
||||||
|
return mTaskbarLauncherStateController.isIconAlignedWithHotseat();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dumpLogs(String prefix, PrintWriter pw) {
|
public void dumpLogs(String prefix, PrintWriter pw) {
|
||||||
super.dumpLogs(prefix, pw);
|
super.dumpLogs(prefix, pw);
|
||||||
|
|||||||
@@ -38,9 +38,8 @@ import com.android.launcher3.Utilities;
|
|||||||
import com.android.launcher3.anim.AnimatorListeners;
|
import com.android.launcher3.anim.AnimatorListeners;
|
||||||
import com.android.launcher3.statemanager.StateManager;
|
import com.android.launcher3.statemanager.StateManager;
|
||||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||||
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
|
|
||||||
import com.android.launcher3.uioverrides.states.OverviewState;
|
import com.android.launcher3.uioverrides.states.OverviewState;
|
||||||
import com.android.launcher3.util.MultiValueAlpha;
|
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
|
||||||
import com.android.quickstep.AnimatedFloat;
|
import com.android.quickstep.AnimatedFloat;
|
||||||
import com.android.quickstep.RecentsAnimationCallbacks;
|
import com.android.quickstep.RecentsAnimationCallbacks;
|
||||||
import com.android.quickstep.RecentsAnimationController;
|
import com.android.quickstep.RecentsAnimationController;
|
||||||
@@ -251,17 +250,7 @@ import java.util.StringJoiner;
|
|||||||
|
|
||||||
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
|
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
|
||||||
boolean goingToLauncher = isInLauncher();
|
boolean goingToLauncher = isInLauncher();
|
||||||
final float toAlignment;
|
final float toAlignment = isIconAlignedWithHotseat() ? 1 : 0;
|
||||||
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) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState)
|
Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState)
|
||||||
+ ", changedFlags: " + getStateString(changedFlags)
|
+ ", changedFlags: " + getStateString(changedFlags)
|
||||||
@@ -357,6 +346,22 @@ import java.util.StringJoiner;
|
|||||||
return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
|
return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if icons should be aligned to hotseat in the current transition
|
||||||
|
*/
|
||||||
|
public boolean isIconAlignedWithHotseat() {
|
||||||
|
if (isInLauncher()) {
|
||||||
|
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
|
||||||
|
boolean willStashVisually = isInStashedState
|
||||||
|
&& mControllers.taskbarStashController.supportsVisualStashing();
|
||||||
|
boolean isTaskbarAlignedWithHotseat =
|
||||||
|
mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
|
||||||
|
return isTaskbarAlignedWithHotseat && !willStashVisually;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
|
private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
|
||||||
boolean committed) {
|
boolean committed) {
|
||||||
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
|
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
|
||||||
@@ -395,7 +400,7 @@ import java.util.StringJoiner;
|
|||||||
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
|
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
|
||||||
|
|
||||||
mControllers.taskbarViewController.setLauncherIconAlignment(
|
mControllers.taskbarViewController.setLauncherIconAlignment(
|
||||||
mIconAlignment.value, mIconAlignment.getEndValue(), mLauncher.getDeviceProfile());
|
mIconAlignment.value, mLauncher.getDeviceProfile());
|
||||||
mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
|
mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
|
||||||
// Switch taskbar and hotseat in last frame
|
// Switch taskbar and hotseat in last frame
|
||||||
updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
|
updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
|
||||||
|
|||||||
@@ -114,6 +114,13 @@ public class TaskbarUIController {
|
|||||||
|| mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
|
|| mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if icons should be aligned to hotseat in the current transition.
|
||||||
|
*/
|
||||||
|
public boolean isIconAlignedWithHotseat() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@CallSuper
|
@CallSuper
|
||||||
protected void dumpLogs(String prefix, PrintWriter pw) {
|
protected void dumpLogs(String prefix, PrintWriter pw) {
|
||||||
pw.println(String.format(
|
pw.println(String.format(
|
||||||
|
|||||||
@@ -280,10 +280,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
|||||||
* 0 => not aligned
|
* 0 => not aligned
|
||||||
* 1 => fully aligned
|
* 1 => fully aligned
|
||||||
*/
|
*/
|
||||||
public void setLauncherIconAlignment(float alignmentRatio, Float endAlignment,
|
public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) {
|
||||||
DeviceProfile launcherDp) {
|
|
||||||
if (mIconAlignControllerLazy == null) {
|
if (mIconAlignControllerLazy == null) {
|
||||||
mIconAlignControllerLazy = createIconAlignmentController(launcherDp, endAlignment);
|
mIconAlignControllerLazy = createIconAlignmentController(launcherDp);
|
||||||
}
|
}
|
||||||
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
|
mIconAlignControllerLazy.setPlayFraction(alignmentRatio);
|
||||||
if (alignmentRatio <= 0 || alignmentRatio >= 1) {
|
if (alignmentRatio <= 0 || alignmentRatio >= 1) {
|
||||||
@@ -295,8 +294,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
|||||||
/**
|
/**
|
||||||
* Creates an animation for aligning the taskbar icons with the provided Launcher device profile
|
* Creates an animation for aligning the taskbar icons with the provided Launcher device profile
|
||||||
*/
|
*/
|
||||||
private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp,
|
private AnimatorPlaybackController createIconAlignmentController(DeviceProfile launcherDp) {
|
||||||
Float endAlignment) {
|
|
||||||
mOnControllerPreCreateCallback.run();
|
mOnControllerPreCreateCallback.run();
|
||||||
PendingAnimation setter = new PendingAnimation(100);
|
PendingAnimation setter = new PendingAnimation(100);
|
||||||
DeviceProfile taskbarDp = mActivity.getDeviceProfile();
|
DeviceProfile taskbarDp = mActivity.getDeviceProfile();
|
||||||
@@ -322,7 +320,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
|||||||
setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
|
setter.addOnFrameListener(anim -> mActivity.setTaskbarWindowHeight(
|
||||||
anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
|
anim.getAnimatedFraction() > 0 ? expandedHeight : collapsedHeight));
|
||||||
|
|
||||||
boolean isToHome = endAlignment != null && endAlignment == 1;
|
boolean isToHome = mControllers.uiController.isIconAlignedWithHotseat();
|
||||||
for (int i = 0; i < mTaskbarView.getChildCount(); i++) {
|
for (int i = 0; i < mTaskbarView.getChildCount(); i++) {
|
||||||
View child = mTaskbarView.getChildAt(i);
|
View child = mTaskbarView.getChildAt(i);
|
||||||
int positionInHotseat;
|
int positionInHotseat;
|
||||||
|
|||||||
@@ -98,15 +98,6 @@ public class AnimatedFloat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the animation.
|
|
||||||
*/
|
|
||||||
public void startAnimation() {
|
|
||||||
if (mValueAnimator != null) {
|
|
||||||
mValueAnimator.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancelAnimation() {
|
public void cancelAnimation() {
|
||||||
if (mValueAnimator != null) {
|
if (mValueAnimator != null) {
|
||||||
mValueAnimator.cancel();
|
mValueAnimator.cancel();
|
||||||
@@ -119,10 +110,6 @@ public class AnimatedFloat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectAnimator getCurrentAnimation() {
|
|
||||||
return mValueAnimator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAnimating() {
|
public boolean isAnimating() {
|
||||||
return mValueAnimator != null;
|
return mValueAnimator != null;
|
||||||
}
|
}
|
||||||
@@ -140,11 +127,4 @@ public class AnimatedFloat {
|
|||||||
public boolean isSettledOnValue(float endValue) {
|
public boolean isSettledOnValue(float endValue) {
|
||||||
return !isAnimating() && value == endValue;
|
return !isAnimating() && value == endValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value we are animating to, or {@code null} if we are not currently animating.
|
|
||||||
*/
|
|
||||||
public Float getEndValue() {
|
|
||||||
return mEndValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user