From 9e233b3aa158532f0b3eddcf2191d15f02b91e2a Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Wed, 9 Apr 2025 22:14:22 +0000 Subject: [PATCH 1/2] Update home tappable insets when taskbar is shown on home On desktop devices pinned taskbar is shown on home, so the home layout needs to take taskbar insets into account. Bug: 399708241 Flag: EXEMPT bugfix Test: On desktop device, go to home, and open all apps, or widget picker. Scroll all the way down, and verify that the bottom row or apps is not cut-off by taskbar. Change-Id: Ib8e83f84b71972313a25ae01619046be3c88d7ca --- .../util/window/WindowManagerProxy.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/util/window/WindowManagerProxy.java b/src/com/android/launcher3/util/window/WindowManagerProxy.java index 79f39a9c03..95e005402a 100644 --- a/src/com/android/launcher3/util/window/WindowManagerProxy.java +++ b/src/com/android/launcher3/util/window/WindowManagerProxy.java @@ -55,6 +55,7 @@ import com.android.launcher3.dagger.LauncherAppSingleton; import com.android.launcher3.dagger.LauncherBaseAppComponent; import com.android.launcher3.testing.shared.ResourceUtils; import com.android.launcher3.util.DaggerSingletonObject; +import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.NavigationMode; import com.android.launcher3.util.WindowBounds; @@ -142,15 +143,29 @@ public class WindowManagerProxy { WindowMetrics windowMetrics = displayInfoContext.getSystemService(WindowManager.class) .getMaximumWindowMetrics(); Rect insets = new Rect(); - normalizeWindowInsets(displayInfoContext, windowMetrics.getWindowInsets(), insets); + // NOTE: Unable to use `normalizeWindowInsets(Context, WidnowInsets, Rect)` because + // uses DisplayController instance to determine whether taskbar is shown on home, and this + // method gets called while initializing DisaplayController. + normalizeWindowInsets(displayInfoContext, + showLockedTaskbarOnHome(displayInfoContext) || showDesktopTaskbarForFreeformDisplay( + displayInfoContext), windowMetrics.getWindowInsets(), insets); return new WindowBounds(windowMetrics.getBounds(), insets, info.rotation); } /** * Returns an updated insets, accounting for various Launcher UI specific overrides like taskbar */ - public WindowInsets normalizeWindowInsets(Context context, WindowInsets oldInsets, + public WindowInsets normalizeWindowInsets(Context context, + WindowInsets oldInsets, Rect outInsets) { + return normalizeWindowInsets(context, + DisplayController.showLockedTaskbarOnHome(context) + || DisplayController.showDesktopTaskbarForFreeformDisplay(context), + oldInsets, outInsets); + } + + WindowInsets normalizeWindowInsets(Context context, boolean taskbarShownOnHome, + WindowInsets oldInsets, Rect outInsets) { if (!mTaskbarDrawnInProcess) { outInsets.set(oldInsets.getSystemWindowInsetLeft(), oldInsets.getSystemWindowInsetTop(), oldInsets.getSystemWindowInsetRight(), oldInsets.getSystemWindowInsetBottom()); @@ -202,7 +217,7 @@ public class WindowManagerProxy { // Override the tappable insets to be 0 on the bottom for gesture nav (otherwise taskbar // would count towards it). This is used for the bottom protection in All Apps for example. - if (isGesture) { + if (isGesture && !taskbarShownOnHome) { Insets oldTappableInsets = oldInsets.getInsets(WindowInsets.Type.tappableElement()); Insets newTappableInsets = Insets.of(oldTappableInsets.left, oldTappableInsets.top, oldTappableInsets.right, 0); From e5fc903495e3283f12344227c53c885d8fddc3df Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Thu, 10 Apr 2025 05:04:22 +0000 Subject: [PATCH 2/2] Disable pinning popup when transient taskbar is disabled On freeform displays where taskbar is always pinned, toggling "Always show taskbar" option is no-op, as the taskbar won't transition to transient taskbar. Left a TODO to reevaluate behavior once desktop taskbar transient behavior gets updated. Bug: 390665752 Flag: com.android.window.flags.enable_desktop_taskbar_on_freeform_displays Test: Manual. Change-Id: Icfe7cd26e77de48ab34bfe4932bfedfe21923ef1 --- .../launcher3/taskbar/TaskbarControllers.java | 1 + .../launcher3/taskbar/TaskbarView.java | 22 ++++++++++++------- .../taskbar/TaskbarViewController.java | 11 ++++++++++ .../customization/TaskbarDividerContainer.kt | 6 ++--- .../customization/TaskbarFeatureEvaluator.kt | 4 +++- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 503cb7e663..ef002fcd85 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -248,6 +248,7 @@ public class TaskbarControllers { }, () -> uiController.onBubbleBarLocationUpdated(null)); // Notify that the ui controller has changed navbarButtonsViewController.onUiControllerChanged(); + taskbarViewController.onUiControllerChanged(); } @Nullable diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index b4eb16d0b6..17dd4f9394 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -350,26 +350,32 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar mIconLongClickListener = mControllerCallbacks.getIconOnLongClickListener(); mAllAppsButtonContainer.setUpCallbacks(callbacks); - if (mTaskbarDividerContainer != null - && mActivityContext.getTaskbarFeatureEvaluator().getSupportsPinningPopup()) { - mTaskbarDividerContainer.setUpCallbacks(callbacks); - } if (mTaskbarOverflowView != null) { mTaskbarOverflowView.setOnClickListener( mControllerCallbacks.getOverflowOnClickListener()); mTaskbarOverflowView.setOnLongClickListener( mControllerCallbacks.getOverflowOnLongClickListener()); } - if (Flags.showTaskbarPinningPopupFromAnywhere() - && mActivityContext.getTaskbarFeatureEvaluator().getSupportsPinningPopup()) { - setOnTouchListener(mControllerCallbacks.getTaskbarTouchListener()); - } if (Flags.taskbarOverflow()) { mMaxNumIcons = calculateMaxNumIcons(); } } + void updatePinningPopupEventHandlers() { + boolean supportsPinningPopup = + mActivityContext.getTaskbarFeatureEvaluator().getSupportsPinningPopup(); + if (mTaskbarDividerContainer != null) { + mTaskbarDividerContainer.setUpCallbacks( + supportsPinningPopup ? mControllerCallbacks : null); + } + + if (Flags.showTaskbarPinningPopupFromAnywhere()) { + setOnTouchListener( + supportsPinningPopup ? mControllerCallbacks.getTaskbarTouchListener() : null); + } + } + private void removeAndRecycle(View view) { removeView(view); view.setOnClickListener(null); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index c7d8a50383..2b3d05da3e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -266,6 +266,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mTaskbarView.init(TaskbarViewCallbacksFactory.newInstance(mActivity).create( mActivity, mControllers, mTaskbarView)); + // Pinning popup feature availability depends on taskbar controllers, wait for the + // controllers state initialization before evaluating the feature. + mControllers.runAfterInit(mTaskbarView::updatePinningPopupEventHandlers); mTaskbarView.getLayoutParams().height = mActivity.isPhoneMode() ? mActivity.getResources().getDimensionPixelSize(R.dimen.taskbar_phone_size) : mActivity.getDeviceProfile().taskbarHeight; @@ -302,6 +305,14 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar } } + /** + * Called whenever a new ui controller is set. + */ + public void onUiControllerChanged() { + // Pinning availability may depend on UI state when home has "locked" pinned taskbar. + mTaskbarView.updatePinningPopupEventHandlers(); + } + /** Adjusts start aligned taskbar layout accordingly to the bubble bar position. */ @Override public void onBubbleBarLocationUpdated(BubbleBarLocation location) { diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarDividerContainer.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarDividerContainer.kt index 08a1b48acf..ef0cd8e4b7 100644 --- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarDividerContainer.kt +++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarDividerContainer.kt @@ -67,8 +67,8 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 } @SuppressLint("ClickableViewAccessibility") - fun setUpCallbacks(callbacks: TaskbarViewCallbacks) { - setOnLongClickListener(callbacks.taskbarDividerLongClickListener) - setOnTouchListener(callbacks.taskbarDividerRightClickListener) + fun setUpCallbacks(callbacks: TaskbarViewCallbacks?) { + setOnLongClickListener(callbacks?.taskbarDividerLongClickListener) + setOnTouchListener(callbacks?.taskbarDividerRightClickListener) } } diff --git a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt index a14c5a47e6..856e0d0e94 100644 --- a/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt +++ b/quickstep/src/com/android/launcher3/taskbar/customization/TaskbarFeatureEvaluator.kt @@ -41,7 +41,9 @@ private constructor(private val taskbarActivityContext: TaskbarActivityContext) get() = taskbarActivityContext.deviceProfile.isLandscape val supportsPinningPopup: Boolean - get() = !hasNavButtons + // TODO(b/381535785): Allow pinning for desktop taskbar when desktop mode transient behavior + // gets updated to retain pinned UI, but translate the taskbar offscreen. + get() = !hasNavButtons && !taskbarActivityContext.isTaskbarShowingDesktopTasks fun onDestroy() { taskbarFeatureEvaluator = null