From d89732ef8598108095a29f182fb113bfa5d64bda Mon Sep 17 00:00:00 2001 From: mpodolian Date: Fri, 4 Oct 2024 16:25:57 -0700 Subject: [PATCH] Made the taskbar touchable during animation to home. Enabled taskbar touch processing while animating to home. Also excluded quick search bar from touch region, so it is not interactable during the animation & removed corresponding TODO from TaskbarView. Fixes: 368419997 Test: Manual. Enable gesture navigation. Open any application. Swipe up to go to the launcher home screen. Click any taskbar icon - the corresponding application will open. If clicking on Quick search, launcher search will be opened. Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/g6UWhF9dQZq3QsFyH0EwtK Perform the same test for buttons navigation mode. Video: http://recall/-/gx8ASgewUeUS3QYohfrd1J/gvuoSRnQfXQlejewBG1Ex8 Flag: EXEMPT bug fix Change-Id: I07280bce70dd25d5ab78210302f08c0614309130 --- .../taskbar/LauncherTaskbarUIController.java | 16 +++-- .../taskbar/TaskbarInsetsController.kt | 69 ++++++++++++------- .../TaskbarLauncherStateController.java | 24 ++++++- .../taskbar/TaskbarUIController.java | 10 ++- .../launcher3/taskbar/TaskbarView.java | 1 - 5 files changed, 87 insertions(+), 33 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 09dbeb6fb9..61563b9a34 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -150,12 +150,6 @@ public class LauncherTaskbarUIController extends TaskbarUIController { } } - @Override - protected boolean isTaskbarTouchable() { - return !(mTaskbarLauncherStateController.isAnimatingToLauncher() - && mTaskbarLauncherStateController.isTaskbarAlignedWithHotseat()); - } - public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) { mTaskbarLauncherStateController.setShouldDelayLauncherStateAnim( shouldDelayLauncherStateAnim); @@ -419,6 +413,16 @@ public class LauncherTaskbarUIController extends TaskbarUIController { .getValue() == 0; } + @Override + public boolean isHotseatVisibleForTaskBarAlignment() { + return mTaskbarLauncherStateController.isHotseatVisibleForTaskbarAlignment(); + } + + @Override + public boolean isAnimatingToLauncher() { + return mTaskbarLauncherStateController.isAnimatingToLauncher(); + } + @Override protected boolean isInOverviewUi() { return mTaskbarLauncherStateController.isInOverviewUi(); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt index 685c109eec..1141a01726 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt @@ -47,6 +47,7 @@ import androidx.core.graphics.toRegion import com.android.internal.policy.GestureNavigationSettingsObserver import com.android.launcher3.DeviceProfile import com.android.launcher3.R +import com.android.launcher3.Utilities import com.android.launcher3.anim.AlphaUpdateListener import com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION import com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate @@ -82,7 +83,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas context.mainThreadHandler, Executors.UI_HELPER_EXECUTOR.handler, context, - this::onTaskbarOrBubblebarWindowHeightOrInsetsChanged + this::onTaskbarOrBubblebarWindowHeightOrInsetsChanged, ) private val debugTouchableRegion = DebugTouchableRegion() @@ -120,7 +121,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas if (enableTaskbarNoRecreate() && controllers.sharedState != null) { getProvidedInsets( controllers.sharedState!!.insetsFrameProviders, - insetsRoundedCornerFlag + insetsRoundedCornerFlag, ) } else { getProvidedInsets(insetsRoundedCornerFlag) @@ -133,9 +134,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas } val bubbleControllers = controllers.bubbleControllers.getOrNull() - val taskbarTouchableHeight = taskbarStashController.touchableHeight - val bubblesTouchableHeight = - bubbleControllers?.bubbleStashController?.getTouchableHeight() ?: 0 // reset touch bounds defaultTouchableRegion.setEmpty() if (bubbleControllers != null) { @@ -147,16 +145,45 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas defaultTouchableRegion.addBoundsToRegion(bubbleBarViewController.bubbleBarBounds) } } + val uiController = controllers.uiController if ( - taskbarStashController.isInApp || - taskbarStashController.isInOverview || + !uiController.isHotseatVisibleForTaskBarAlignment || DisplayController.showLockedTaskbarOnHome(context) ) { - // only add the taskbar touch region if not on home + // adding the taskbar touch region + val touchableHeight: Int + var left = 0 + var right = context.deviceProfile.widthPx + var bubbleBarAdjustment = 0 + if (uiController.isAnimatingToLauncher) { + val dp = controllers.taskbarActivityContext.deviceProfile + touchableHeight = windowLayoutParams.height + if (dp.isQsbInline) { + // if Qsb is inline need to exclude search icon from touch region + val isRtl = Utilities.isRtl(context.resources) + bubbleControllers?.bubbleBarViewController?.let { + if (dp.shouldAdjustHotseatOnBubblesLocationUpdate(context)) { + val isBubblesOnLeft = it.bubbleBarLocation.isOnLeft(isRtl) + bubbleBarAdjustment = + dp.getHotseatTranslationXForBubbleBar(isBubblesOnLeft, isRtl) + } + } + val hotseatPadding: Rect = dp.getHotseatLayoutPadding(context) + val borderSpacing: Int = dp.hotseatBorderSpace + if (isRtl) { + right = + dp.widthPx - hotseatPadding.right + borderSpacing + bubbleBarAdjustment + } else { + left = hotseatPadding.left - borderSpacing + bubbleBarAdjustment + } + } + } else { + // if not animating to launcher use the taskbar touchanle height + touchableHeight = taskbarStashController.touchableHeight + } val bottom = windowLayoutParams.height - val top = bottom - taskbarTouchableHeight - val right = context.deviceProfile.widthPx - defaultTouchableRegion.addBoundsToRegion(Rect(/* left= */ 0, top, right, bottom)) + val top = bottom - touchableHeight + defaultTouchableRegion.addBoundsToRegion(Rect(left, top, right, bottom)) } // Pre-calculate insets for different providers across different rotations for this gravity @@ -181,7 +208,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas */ private fun getProvidedInsets( providedInsets: Array, - insetsRoundedCornerFlag: Int + insetsRoundedCornerFlag: Int, ): Array { val navBarsFlag = (if (context.isGestureNav) FLAG_SUPPRESS_SCRIM else 0) or insetsRoundedCornerFlag @@ -207,14 +234,14 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas InsetsFrameProvider(insetsOwner, 0, navigationBars()) .setFlags( navBarsFlag, - FLAG_SUPPRESS_SCRIM or FLAG_ANIMATE_RESIZING or FLAG_INSETS_ROUNDED_CORNER + FLAG_SUPPRESS_SCRIM or FLAG_ANIMATE_RESIZING or FLAG_INSETS_ROUNDED_CORNER, ), InsetsFrameProvider(insetsOwner, 0, tappableElement()), InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures()), InsetsFrameProvider(insetsOwner, INDEX_LEFT, systemGestures()) .setSource(SOURCE_DISPLAY), InsetsFrameProvider(insetsOwner, INDEX_RIGHT, systemGestures()) - .setSource(SOURCE_DISPLAY) + .setSource(SOURCE_DISPLAY), ) } @@ -232,7 +259,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas val gestureHeight = ResourceUtils.getNavbarSize( ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, - context.resources + context.resources, ) val isPinnedTaskbar = context.deviceProfile.isTaskbarPresent && @@ -272,8 +299,8 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas // override below (insetsSizeOverrides must have the same length and // types after the window is added according to // WindowManagerService#relayoutWindow) - provider.insetsSize - ) + provider.insetsSize, + ), ) // Use 0 tappableElement insets for the VoiceInteractionWindow when gesture nav is enabled. val visInsetsSizeForTappableElement = @@ -284,7 +311,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas InsetsFrameProvider.InsetsSizeOverride(TYPE_INPUT_METHOD, imeInsetsSize), InsetsFrameProvider.InsetsSizeOverride( TYPE_VOICE_INTERACTION, - visInsetsSizeForTappableElement + visInsetsSizeForTappableElement, ), ) if ( @@ -368,10 +395,6 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas // Let touches pass through us. insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) debugTouchableRegion.lastSetTouchableReason = "Stashed over IME" - } else if (!controllers.uiController.isTaskbarTouchable) { - // Let touches pass through us. - insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) - debugTouchableRegion.lastSetTouchableReason = "Taskbar is not touchable" } else if (controllers.taskbarDragController.isSystemDragInProgress) { // Let touches pass through us. insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) @@ -427,7 +450,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext) : LoggableTas // Always have nav buttons be touchable controllers.navbarButtonsViewController.addVisibleButtonsRegion( context.dragLayer, - insetsInfo.touchableRegion + insetsInfo.touchableRegion, ) debugTouchableRegion.lastSetTouchableBounds.set(insetsInfo.touchableRegion.bounds) context.excludeFromMagnificationRegion(insetsIsTouchableRegion) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index 707d4b3a60..39aef28d45 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -192,6 +192,8 @@ public class TaskbarLauncherStateController { private boolean mIsQsbInline; + private boolean mIsHotseatVisibleForTaskbarAlignment; + private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener = new DeviceProfile.OnDeviceProfileChangeListener() { @Override @@ -738,6 +740,7 @@ public class TaskbarLauncherStateController { boolean committed) { boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher); TaskbarStashController stashController = mControllers.taskbarStashController; + TaskbarInsetsController insetsController = mControllers.taskbarInsetsController; stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState); Animator stashAnimator = stashController.createApplyStateAnimator(duration); if (stashAnimator != null) { @@ -746,7 +749,11 @@ public class TaskbarLauncherStateController { public void onAnimationEnd(Animator animation) { if (isInStashedState && committed) { // Reset hotseat alpha to default - mLauncher.getHotseat().setIconsAlpha(1, ALPHA_CHANNEL_TASKBAR_ALIGNMENT); + updateIconAlphaForHome( + /* taskbarAlpha = */ 0, + ALPHA_CHANNEL_TASKBAR_ALIGNMENT, + /* updateTaskbarAlpha = */ false + ); } } @@ -871,6 +878,14 @@ public class TaskbarLauncherStateController { if (mIsQsbInline) { mLauncher.getHotseat().setQsbAlpha(targetAlpha, alphaChannel); } + if (alphaChannel == ALPHA_CHANNEL_TASKBAR_ALIGNMENT) { + boolean isHotseatVisibleForTaskbarAlignment = isHotseatVisibleForTaskbarAlignment(); + if (mIsHotseatVisibleForTaskbarAlignment != isHotseatVisibleForTaskbarAlignment) { + mIsHotseatVisibleForTaskbarAlignment = isHotseatVisibleForTaskbarAlignment; + mControllers.taskbarInsetsController + .onTaskbarOrBubblebarWindowHeightOrInsetsChanged(); + } + } } /** Updates launcher home screen appearance accordingly to the bubble bar location. */ @@ -932,6 +947,13 @@ public class TaskbarLauncherStateController { translationXAnimation.start(); } + /** Returns true if hotseat icons visible for the taskbar alignment */ + public boolean isHotseatVisibleForTaskbarAlignment() { + return mLauncher.getHotseat() + .getIconsAlpha(ALPHA_CHANNEL_TASKBAR_ALIGNMENT).getValue() == 1; + } + + private final class TaskBarRecentsAnimationListener implements RecentsAnimationCallbacks.RecentsAnimationListener { private final RecentsAnimationCallbacks mCallbacks; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java index b80aaf8840..5c51fda276 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java @@ -75,8 +75,14 @@ public class TaskbarUIController implements BubbleBarController.BubbleBarLocatio mControllers = null; } - protected boolean isTaskbarTouchable() { - return true; + /** Returns true if transition animation to launcher home is being played. */ + public boolean isAnimatingToLauncher() { + return false; + } + + /** Returns true if hotseat icons visible for the taskbar alignment. */ + public boolean isHotseatVisibleForTaskBarAlignment() { + return false; } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index ec9416017e..435ee5b6d0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -185,7 +185,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar resources.getDrawable(R.drawable.taskbar_overflow_icon)); mTaskbarOverflowView.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding); } - // TODO: Disable touch events on QSB otherwise it can crash. mQsb = LayoutInflater.from(context).inflate(R.layout.search_container_hotseat, this, false); mMaxNumIcons = calculateMaxNumIcons();