From 99c442b015f3b6fcd929b6838ca129ac632d2d0d Mon Sep 17 00:00:00 2001 From: Sukesh Ram Date: Mon, 28 Oct 2024 17:26:47 +0000 Subject: [PATCH] Revert "Fix Taskbar Y-Translation with Visible Bottom Sheet" This reverts commit d82503fc42c6ae238d23f3ef287feb8f8172c7ce. Reason for revert: Introduced crashes Change-Id: I0956f746e25ccfe655169580fd802d33f99c0652 --- .../taskbar/LauncherTaskbarUIController.java | 45 +++---------------- .../taskbar/NavbarButtonsViewController.java | 32 +++++++------ .../taskbar/TaskbarUIController.java | 8 ---- .../taskbar/TaskbarViewController.java | 2 +- .../uioverrides/QuickstepLauncher.java | 6 ++- src/com/android/launcher3/BaseActivity.java | 4 -- 6 files changed, 26 insertions(+), 71 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 042bc9a8ab..09dbeb6fb9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -36,7 +36,6 @@ import com.android.launcher3.Flags; import com.android.launcher3.LauncherState; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatedFloat; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.InstanceId; import com.android.launcher3.logging.InstanceIdSequence; import com.android.launcher3.model.data.ItemInfo; @@ -69,17 +68,14 @@ public class LauncherTaskbarUIController extends TaskbarUIController { public static final int ALL_APPS_PAGE_PROGRESS_INDEX = 1; public static final int WIDGETS_PAGE_PROGRESS_INDEX = 2; public static final int SYSUI_SURFACE_PROGRESS_INDEX = 3; - public static final int LAUNCHER_PAUSE_PROGRESS_INDEX = 4; - public static final int DISPLAY_PROGRESS_COUNT = 5; + public static final int DISPLAY_PROGRESS_COUNT = 4; private final AnimatedFloat mTaskbarInAppDisplayProgress = new AnimatedFloat( this::onInAppDisplayProgressChanged); private final MultiPropertyFactory mTaskbarInAppDisplayProgressMultiProp = new MultiPropertyFactory<>(mTaskbarInAppDisplayProgress, AnimatedFloat.VALUE, DISPLAY_PROGRESS_COUNT, Float::max); - private final AnimatedFloat mLauncherPauseProgress = new AnimatedFloat( - this::launcherPauseProgressUpdate); private final QuickstepLauncher mLauncher; private final HomeVisibilityState mHomeState; @@ -194,33 +190,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController { placeholderDuration)); } - /** - * Called when Launcher Activity is paused/resumed. - *

- * To avoid UI clash between taskbar & bottom sheet, shift nav buttons down on launcher - * pause/resume at home. - * @param paused if launcher is currently paused. - */ - public void onLauncherPausedOrResumed(boolean paused) { - if (!FeatureFlags.enableHomeTransitionListener()) { - onLauncherVisibilityChanged(mLauncher.hasBeenResumed()); - return; - } - - // Animate navbar iff pause/resume from home, NOT to/from app (avoid overriding existing - // animations). - boolean launcherPauseOrResumeFromHome = mHomeState.isHomeVisible() && mControllers - .taskbarAutohideSuspendController.isSuspendedForTransientTaskbarInLauncher(); - if (launcherPauseOrResumeFromHome) { - mLauncherPauseProgress.animateToValue(paused ? 1.0f : 0.0f).start(); - } - } - - private void launcherPauseProgressUpdate() { - onTaskbarInAppDisplayProgressUpdate( - mLauncherPauseProgress.value, LAUNCHER_PAUSE_PROGRESS_INDEX); - } - /** * Should be called from onResume() and onPause(), and animates the Taskbar accordingly. */ @@ -395,20 +364,18 @@ public class LauncherTaskbarUIController extends TaskbarUIController { } if (mControllers.uiController.isIconAlignedWithHotseat() && !mTaskbarLauncherStateController.isAnimatingToLauncher()) { - // Only animate nav button position while home and not animating home, otherwise let + // Only animate the nav buttons while home and not animating home, otherwise let // the TaskbarViewController handle it. mControllers.navbarButtonsViewController - .getNavButtonTranslationYForInAppDisplay() + .getTaskbarNavButtonTranslationYForInAppDisplay() .updateValue(mLauncher.getDeviceProfile().getTaskbarOffsetY() * mTaskbarInAppDisplayProgress.value); - if (!mLauncher.isPaused()) { - mControllers.navbarButtonsViewController - .getOnTaskbarBackgroundNavButtonColorOverride().updateValue(progress); - } + mControllers.navbarButtonsViewController + .getOnTaskbarBackgroundNavButtonColorOverride().updateValue(progress); } } - @Override + /** Returns true iff any in-app display progress > 0. */ public boolean shouldUseInAppLayout() { return mTaskbarInAppDisplayProgress.value > 0; } diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index cfcbd2f552..7d8e93ce00 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -183,7 +183,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat( this::updateNavButtonTranslationY); - private final AnimatedFloat mNavButtonTranslationYForInAppDisplay = new AnimatedFloat( + private final AnimatedFloat mTaskbarNavButtonTranslationYForInAppDisplay = new AnimatedFloat( this::updateNavButtonTranslationY); private final AnimatedFloat mTaskbarNavButtonTranslationYForIme = new AnimatedFloat( this::updateNavButtonTranslationY); @@ -704,8 +704,8 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT } /** Use to set the translationY for the all nav+contextual buttons when in Launcher */ - public AnimatedFloat getNavButtonTranslationYForInAppDisplay() { - return mNavButtonTranslationYForInAppDisplay; + public AnimatedFloat getTaskbarNavButtonTranslationYForInAppDisplay() { + return mTaskbarNavButtonTranslationYForInAppDisplay; } /** Use to set the dark intensity for the all nav+contextual buttons */ @@ -751,20 +751,18 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT if (mContext.isPhoneButtonNavMode()) { return; } - mLastSetNavButtonTranslationY = calculateNavButtonTranslationY(); - mNavButtonsView.setTranslationY(mLastSetNavButtonTranslationY); - } + final float normalTranslationY = mTaskbarNavButtonTranslationY.value; + final float imeAdjustmentTranslationY = mTaskbarNavButtonTranslationYForIme.value; + TaskbarUIController uiController = mControllers.uiController; + final float inAppDisplayAdjustmentTranslationY = + (uiController instanceof LauncherTaskbarUIController + && ((LauncherTaskbarUIController) uiController).shouldUseInAppLayout()) + ? mTaskbarNavButtonTranslationYForInAppDisplay.value : 0; - /** - * Calculates the translationY of the nav buttons based on the current device state. - */ - private float calculateNavButtonTranslationY() { - float translationY = - mTaskbarNavButtonTranslationY.value + mTaskbarNavButtonTranslationYForIme.value; - if (mControllers.uiController.shouldUseInAppLayout()) { - translationY += mNavButtonTranslationYForInAppDisplay.value; - } - return translationY; + mLastSetNavButtonTranslationY = normalTranslationY + + imeAdjustmentTranslationY + + inAppDisplayAdjustmentTranslationY; + mNavButtonsView.setTranslationY(mLastSetNavButtonTranslationY); } /** @@ -1164,7 +1162,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT pw.println(prefix + "\t\tmTaskbarNavButtonTranslationY=" + mTaskbarNavButtonTranslationY.value); pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForInAppDisplay=" - + mNavButtonTranslationYForInAppDisplay.value); + + mTaskbarNavButtonTranslationYForInAppDisplay.value); pw.println(prefix + "\t\tmTaskbarNavButtonTranslationYForIme=" + mTaskbarNavButtonTranslationYForIme.value); pw.println(prefix + "\t\tmTaskbarNavButtonDarkIntensity=" diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index 7030088287..b80aaf8840 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -90,14 +90,6 @@ public class TaskbarUIController implements BubbleBarController.BubbleBarLocatio protected void onStashedInAppChanged() { } - /** - * Whether the Taskbar should use in-app layout. - * @return {@code true} iff in-app display progress > 0 or Launcher Activity paused. - */ - public boolean shouldUseInAppLayout() { - return false; - } - /** * Called when taskbar icon layout bounds change. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index c4d9e5028a..bc61c72212 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -234,7 +234,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mTaskbarNavButtonTranslationY = controllers.navbarButtonsViewController.getTaskbarNavButtonTranslationY(); mTaskbarNavButtonTranslationYForInAppDisplay = controllers.navbarButtonsViewController - .getNavButtonTranslationYForInAppDisplay(); + .getTaskbarNavButtonTranslationYForInAppDisplay(); mActivity.addOnDeviceProfileChangeListener(mDeviceProfileChangeListener); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index ce4e9807e5..39bf6ac814 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -419,8 +419,10 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, mDepthController.setActivityStarted(isStarted()); } - if ((changeBits & ACTIVITY_STATE_RESUMED) != 0 && mTaskbarUIController != null) { - mTaskbarUIController.onLauncherPausedOrResumed(isPaused()); + if ((changeBits & ACTIVITY_STATE_RESUMED) != 0) { + if (!FeatureFlags.enableHomeTransitionListener() && mTaskbarUIController != null) { + mTaskbarUIController.onLauncherVisibilityChanged(hasBeenResumed()); + } } super.onActivityFlagsChanged(changeBits); diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index 3774ae3afe..2e7526192d 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -306,10 +306,6 @@ public abstract class BaseActivity extends Activity implements ActivityContext { removeActivityFlags(ACTIVITY_STATE_RESUMED | ACTIVITY_STATE_DEFERRED_RESUMED); } - public boolean isPaused() { - return !hasBeenResumed() && (mActivityFlags & ACTIVITY_STATE_DEFERRED_RESUMED) == 0; - } - /** * Sets the activity to appear as resumed. */