Merge "Restore proper nav buttons translation when taskbar is recreated" into tm-qpr-dev am: 3292947a73 am: 75a0c72d00

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/22090087

Change-Id: I7e4613202ceaa9e66e4592438668fadb057fc993
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Tony Wickham authored and Automerger Merge Worker committed 2023-03-22 16:26:40 +00:00
commit 38e185ddcb
3 files changed
+44 -7

No files matched your search

@@ -64,9 +64,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2; public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2;
public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3; public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3;
private static final int DISPLAY_PROGRESS_COUNT = 4; public static final int DISPLAY_PROGRESS_COUNT = 4;
private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat(); private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat(
this::onInAppDisplayProgressChanged);
private final MultiPropertyFactory<AnimatedFloat> mTaskbarInAppDisplayProgressMultiProp = private final MultiPropertyFactory<AnimatedFloat> mTaskbarInAppDisplayProgressMultiProp =
new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress, new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress,
AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max); AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max);
@@ -103,6 +104,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
mTaskbarLauncherStateController.updateStateForSysuiFlags( mTaskbarLauncherStateController.updateStateForSysuiFlags(
mControllers.getSharedState().sysuiStateFlags, true /* fromInit */); mControllers.getSharedState().sysuiStateFlags, true /* fromInit */);
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener); mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
// Restore the in-app display progress from before Taskbar was recreated.
float[] prevProgresses = mControllers.getSharedState().inAppDisplayProgressMultiPropValues;
for (int i = 0; i < prevProgresses.length; i++) {
mTaskbarInAppDisplayProgressMultiProp.get(i).setValue(prevProgresses[i]);
}
} }
@Override @Override
@@ -116,6 +123,18 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
updateTaskTransitionSpec(true); updateTaskTransitionSpec(true);
} }
private void onInAppDisplayProgressChanged() {
if (mControllers != null) {
// Update our shared state so we can restore it if taskbar gets recreated.
for (int i = 0; i < DISPLAY_PROGRESS_COUNT; i++) {
mControllers.getSharedState().inAppDisplayProgressMultiPropValues[i] =
mTaskbarInAppDisplayProgressMultiProp.get(i).getValue();
}
// Ensure nav buttons react to our latest state if necessary.
mControllers.navbarButtonsViewController.updateNavButtonTranslationY();
}
}
@Override @Override
protected boolean isTaskbarTouchable() { protected boolean isTaskbarTouchable() {
return !(mTaskbarLauncherStateController.isAnimatingToLauncher() return !(mTaskbarLauncherStateController.isAnimatingToLauncher()
@@ -359,9 +378,10 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
public void dumpLogs(String prefix, PrintWriter pw) { public void dumpLogs(String prefix, PrintWriter pw) {
super.dumpLogs(prefix, pw); super.dumpLogs(prefix, pw);
pw.println(String.format("%s\tTaskbar in-app display progress:", prefix)); pw.println(String.format("%s\tTaskbar in-app display progress: %.2f", prefix,
mTaskbarInAppDisplayProgress.value));
mTaskbarInAppDisplayProgressMultiProp.dump( mTaskbarInAppDisplayProgressMultiProp.dump(
prefix + "\t", prefix + "\t\t",
pw, pw,
"mTaskbarInAppDisplayProgressMultiProp", "mTaskbarInAppDisplayProgressMultiProp",
"MINUS_ONE_PAGE_PROGRESS_INDEX", "MINUS_ONE_PAGE_PROGRESS_INDEX",
@@ -159,6 +159,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
this::updateNavButtonTranslationY); this::updateNavButtonTranslationY);
private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat( private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat(
this::updateNavButtonTranslationY); this::updateNavButtonTranslationY);
private float mLastSetNavButtonTranslationY;
// Used for System UI state updates that should translate the nav button for in-app display. // Used for System UI state updates that should translate the nav button for in-app display.
private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat( private final AnimatedFloat mNavButtonInAppDisplayProgressForSysui = new AnimatedFloat(
this::updateNavButtonInAppDisplayProgressForSysui); this::updateNavButtonInAppDisplayProgressForSysui);
@@ -606,7 +607,10 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
} }
} }
private void updateNavButtonTranslationY() { /**
* Sets the translationY of the nav buttons based on the current device state.
*/
public void updateNavButtonTranslationY() {
if (isPhoneButtonNavMode(mContext)) { if (isPhoneButtonNavMode(mContext)) {
return; return;
} }
@@ -618,9 +622,10 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
&& ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout()) && ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout())
? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0; ? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0;
mNavButtonsView.setTranslationY(normalTranslationY mLastSetNavButtonTranslationY = normalTranslationY
+ imeAdjustmentTranslationY + imeAdjustmentTranslationY
+ inAppDisplayAdjustmentTranslationY); + inAppDisplayAdjustmentTranslationY;
mNavButtonsView.setTranslationY(mLastSetNavButtonTranslationY);
} }
private void updateNavButtonColor() { private void updateNavButtonColor() {
@@ -924,6 +929,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
pw.println(prefix + "\tmFloatingRotationButtonBounds=" + mFloatingRotationButtonBounds); pw.println(prefix + "\tmFloatingRotationButtonBounds=" + mFloatingRotationButtonBounds);
pw.println(prefix + "\tmSysuiStateFlags=" + QuickStepContract.getSystemUiStateString( pw.println(prefix + "\tmSysuiStateFlags=" + QuickStepContract.getSystemUiStateString(
mSysuiStateFlags)); mSysuiStateFlags));
pw.println(prefix + "\tLast set nav button translationY=" + mLastSetNavButtonTranslationY);
pw.println(prefix + "\t\tmTaskbarNavButtonTranslationY="
+ mTaskbarNavButtonTranslationY.value);
pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForInAppDisplay="
+ mTaskbarNavButtonTranslationYForInAppDisplay.value);
pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForIme="
+ mTaskbarNavButtonTranslationYForIme.value);
} }
private static String getStateString(int flags) { private static String getStateString(int flags) {
@@ -15,6 +15,8 @@
*/ */
package com.android.launcher3.taskbar; package com.android.launcher3.taskbar;
import static com.android.launcher3.taskbar.LauncherTaskbarUIController.DISPLAY_PROGRESS_COUNT;
/** /**
* State shared across different taskbar instance * State shared across different taskbar instance
*/ */
@@ -38,4 +40,7 @@ public class TaskbarSharedState {
public boolean setupUIVisible = false; public boolean setupUIVisible = false;
public boolean allAppsVisible = false; public boolean allAppsVisible = false;
// LauncherTaskbarUIController#mTaskbarInAppDisplayProgressMultiProp
public float[] inAppDisplayProgressMultiPropValues = new float[DISPLAY_PROGRESS_COUNT];
} }