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 diff --git a/src/com/android/launcher3/util/window/WindowManagerProxy.java b/src/com/android/launcher3/util/window/WindowManagerProxy.java index 25e1e69606..5e46d5e52f 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);