Loading quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +7 −0 Original line number Diff line number Diff line Loading @@ -413,6 +413,13 @@ public class LauncherTaskbarUIController extends TaskbarUIController { return mTaskbarLauncherStateController.isInOverview(); } @Override protected boolean canToggleHomeAllApps() { return mLauncher.isResumed() && !mTaskbarLauncherStateController.isInOverview() && !mLauncher.areFreeformTasksVisible(); } @Override public RecentsView getRecentsView() { return mLauncher.getOverviewPanel(); Loading quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +9 −0 Original line number Diff line number Diff line Loading @@ -1560,4 +1560,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext { public float getStashedTaskbarScale() { return mControllers.stashedHandleViewController.getStashedHandleHintScale().value; } /** Closes the KeyboardQuickSwitchView without an animation if open. */ public void closeKeyboardQuickSwitchView() { mControllers.keyboardQuickSwitchController.closeQuickSwitchView(false); } boolean canToggleHomeAllApps() { return mControllers.uiController.canToggleHomeAllApps(); } } quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +17 −19 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static com.android.launcher3.BaseActivity.EVENT_DESTROYED; import static com.android.launcher3.Flags.enableUnfoldStateAnimation; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION; import static com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate; import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY; Loading Loading @@ -67,6 +66,7 @@ import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.SettingsCache; import com.android.launcher3.util.SimpleBroadcastReceiver; import com.android.quickstep.AllAppsActionManager; import com.android.quickstep.RecentsActivity; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TouchInteractionService; Loading Loading @@ -155,6 +155,8 @@ public class TaskbarManager { private final SimpleBroadcastReceiver mTaskbarBroadcastReceiver = new SimpleBroadcastReceiver(this::showTaskbarFromBroadcast); private final AllAppsActionManager mAllAppsActionManager; private final Runnable mActivityOnDestroyCallback = new Runnable() { @Override public void run() { Loading Loading @@ -205,12 +207,14 @@ public class TaskbarManager { }; @SuppressLint("WrongConstant") public TaskbarManager(TouchInteractionService service) { public TaskbarManager( TouchInteractionService service, AllAppsActionManager allAppsActionManager) { Display display = service.getSystemService(DisplayManager.class).getDisplay(DEFAULT_DISPLAY); mContext = service.createWindowContext(display, ENABLE_TASKBAR_NAVBAR_UNIFICATION ? TYPE_NAVIGATION_BAR : TYPE_NAVIGATION_BAR_PANEL, null); mAllAppsActionManager = allAppsActionManager; mNavigationBarPanelContext = ENABLE_TASKBAR_NAVBAR_UNIFICATION ? service.createWindowContext(display, TYPE_NAVIGATION_BAR_PANEL, null) : null; Loading Loading @@ -261,10 +265,10 @@ public class TaskbarManager { recreateTaskbar(); } else { // Config change might be handled without re-creating the taskbar if (dp != null && !isTaskbarPresent(dp)) { if (dp != null && !isTaskbarEnabled(dp)) { destroyExistingTaskbar(); } else { if (dp != null && isTaskbarPresent(dp)) { if (dp != null && isTaskbarEnabled(dp)) { if (ENABLE_TASKBAR_NAVBAR_UNIFICATION) { // Re-initialize for screen size change? Should this be done // by looking at screen-size change flag in configDiff in the Loading Loading @@ -319,7 +323,7 @@ public class TaskbarManager { } DeviceProfile dp = mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null; if (dp == null || !isTaskbarPresent(dp)) { if (dp == null || !isTaskbarEnabled(dp)) { removeTaskbarRootViewFromWindow(); } } Loading @@ -339,21 +343,12 @@ public class TaskbarManager { * @param homeAllAppsIntent Intent used if Taskbar is not enabled or Launcher is resumed. */ public void toggleAllApps(Intent homeAllAppsIntent) { if (mTaskbarActivityContext == null) { mContext.startActivity(homeAllAppsIntent); return; } if (mActivity != null && mActivity.isResumed() && !mActivity.isInState(OVERVIEW) && !(mActivity instanceof QuickstepLauncher l && l.areFreeformTasksVisible())) { if (mTaskbarActivityContext == null || mTaskbarActivityContext.canToggleHomeAllApps()) { mContext.startActivity(homeAllAppsIntent); return; } } else { mTaskbarActivityContext.toggleAllAppsSearch(); } } /** * Displays a frame of the first Launcher reveal animation. Loading Loading @@ -447,9 +442,12 @@ public class TaskbarManager { DeviceProfile dp = mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null; // All Apps action is unrelated to navbar unification, so we only need to check DP. mAllAppsActionManager.setTaskbarPresent(dp != null && dp.isTaskbarPresent); destroyExistingTaskbar(); boolean isTaskbarEnabled = dp != null && isTaskbarPresent(dp); boolean isTaskbarEnabled = dp != null && isTaskbarEnabled(dp); debugWhyTaskbarNotDestroyed("recreateTaskbar: isTaskbarEnabled=" + isTaskbarEnabled + " [dp != null (i.e. mUserUnlocked)]=" + (dp != null) + " FLAG_HIDE_NAVBAR_WINDOW=" + ENABLE_TASKBAR_NAVBAR_UNIFICATION Loading Loading @@ -514,7 +512,7 @@ public class TaskbarManager { } } private static boolean isTaskbarPresent(DeviceProfile deviceProfile) { private static boolean isTaskbarEnabled(DeviceProfile deviceProfile) { return ENABLE_TASKBAR_NAVBAR_UNIFICATION || deviceProfile.isTaskbarPresent; } Loading quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +5 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,11 @@ public class TaskbarUIController { return false; } /** Returns {@code true} if Home All Apps available instead of Taskbar All Apps. */ protected boolean canToggleHomeAllApps() { return false; } @CallSuper protected void dumpLogs(String prefix, PrintWriter pw) { pw.println(String.format( Loading quickstep/src/com/android/quickstep/AllAppsActionManager.kt 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.quickstep import android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS import android.app.PendingIntent import android.app.RemoteAction import android.content.Context import android.graphics.drawable.Icon import android.view.accessibility.AccessibilityManager import com.android.launcher3.R import java.util.concurrent.Executor /** * Registers a [RemoteAction] for toggling All Apps if needed. * * We need this action when either [isHomeAndOverviewSame] or [isTaskbarPresent] is `true`. When * home and overview are the same, we can control Launcher's or Taskbar's All Apps tray. If they are * not the same, but Taskbar is present, we can only control Taskbar's tray. */ class AllAppsActionManager( private val context: Context, private val bgExecutor: Executor, private val createAllAppsPendingIntent: () -> PendingIntent, ) { /** `true` if home and overview are the same Activity. */ var isHomeAndOverviewSame = false set(value) { field = value updateSystemAction() } /** `true` if Taskbar is enabled. */ var isTaskbarPresent = false set(value) { field = value updateSystemAction() } /** `true` if the action should be registered. */ var isActionRegistered = false private set private fun updateSystemAction() { val shouldRegisterAction = isHomeAndOverviewSame || isTaskbarPresent if (isActionRegistered == shouldRegisterAction) return isActionRegistered = shouldRegisterAction bgExecutor.execute { val accessibilityManager = context.getSystemService(AccessibilityManager::class.java) ?: return@execute if (shouldRegisterAction) { accessibilityManager.registerSystemAction( RemoteAction( Icon.createWithResource(context, R.drawable.ic_apps), context.getString(R.string.all_apps_label), context.getString(R.string.all_apps_label), createAllAppsPendingIntent(), ), GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS, ) } else { accessibilityManager.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS) } } } fun onDestroy() { context .getSystemService(AccessibilityManager::class.java) ?.unregisterSystemAction( GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS, ) } } Loading
quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +7 −0 Original line number Diff line number Diff line Loading @@ -413,6 +413,13 @@ public class LauncherTaskbarUIController extends TaskbarUIController { return mTaskbarLauncherStateController.isInOverview(); } @Override protected boolean canToggleHomeAllApps() { return mLauncher.isResumed() && !mTaskbarLauncherStateController.isInOverview() && !mLauncher.areFreeformTasksVisible(); } @Override public RecentsView getRecentsView() { return mLauncher.getOverviewPanel(); Loading
quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +9 −0 Original line number Diff line number Diff line Loading @@ -1560,4 +1560,13 @@ public class TaskbarActivityContext extends BaseTaskbarContext { public float getStashedTaskbarScale() { return mControllers.stashedHandleViewController.getStashedHandleHintScale().value; } /** Closes the KeyboardQuickSwitchView without an animation if open. */ public void closeKeyboardQuickSwitchView() { mControllers.keyboardQuickSwitchController.closeQuickSwitchView(false); } boolean canToggleHomeAllApps() { return mControllers.uiController.canToggleHomeAllApps(); } }
quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +17 −19 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; import static com.android.launcher3.BaseActivity.EVENT_DESTROYED; import static com.android.launcher3.Flags.enableUnfoldStateAnimation; import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION; import static com.android.launcher3.config.FeatureFlags.enableTaskbarNoRecreate; import static com.android.launcher3.util.DisplayController.CHANGE_DENSITY; Loading Loading @@ -67,6 +66,7 @@ import com.android.launcher3.uioverrides.QuickstepLauncher; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.SettingsCache; import com.android.launcher3.util.SimpleBroadcastReceiver; import com.android.quickstep.AllAppsActionManager; import com.android.quickstep.RecentsActivity; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TouchInteractionService; Loading Loading @@ -155,6 +155,8 @@ public class TaskbarManager { private final SimpleBroadcastReceiver mTaskbarBroadcastReceiver = new SimpleBroadcastReceiver(this::showTaskbarFromBroadcast); private final AllAppsActionManager mAllAppsActionManager; private final Runnable mActivityOnDestroyCallback = new Runnable() { @Override public void run() { Loading Loading @@ -205,12 +207,14 @@ public class TaskbarManager { }; @SuppressLint("WrongConstant") public TaskbarManager(TouchInteractionService service) { public TaskbarManager( TouchInteractionService service, AllAppsActionManager allAppsActionManager) { Display display = service.getSystemService(DisplayManager.class).getDisplay(DEFAULT_DISPLAY); mContext = service.createWindowContext(display, ENABLE_TASKBAR_NAVBAR_UNIFICATION ? TYPE_NAVIGATION_BAR : TYPE_NAVIGATION_BAR_PANEL, null); mAllAppsActionManager = allAppsActionManager; mNavigationBarPanelContext = ENABLE_TASKBAR_NAVBAR_UNIFICATION ? service.createWindowContext(display, TYPE_NAVIGATION_BAR_PANEL, null) : null; Loading Loading @@ -261,10 +265,10 @@ public class TaskbarManager { recreateTaskbar(); } else { // Config change might be handled without re-creating the taskbar if (dp != null && !isTaskbarPresent(dp)) { if (dp != null && !isTaskbarEnabled(dp)) { destroyExistingTaskbar(); } else { if (dp != null && isTaskbarPresent(dp)) { if (dp != null && isTaskbarEnabled(dp)) { if (ENABLE_TASKBAR_NAVBAR_UNIFICATION) { // Re-initialize for screen size change? Should this be done // by looking at screen-size change flag in configDiff in the Loading Loading @@ -319,7 +323,7 @@ public class TaskbarManager { } DeviceProfile dp = mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null; if (dp == null || !isTaskbarPresent(dp)) { if (dp == null || !isTaskbarEnabled(dp)) { removeTaskbarRootViewFromWindow(); } } Loading @@ -339,21 +343,12 @@ public class TaskbarManager { * @param homeAllAppsIntent Intent used if Taskbar is not enabled or Launcher is resumed. */ public void toggleAllApps(Intent homeAllAppsIntent) { if (mTaskbarActivityContext == null) { mContext.startActivity(homeAllAppsIntent); return; } if (mActivity != null && mActivity.isResumed() && !mActivity.isInState(OVERVIEW) && !(mActivity instanceof QuickstepLauncher l && l.areFreeformTasksVisible())) { if (mTaskbarActivityContext == null || mTaskbarActivityContext.canToggleHomeAllApps()) { mContext.startActivity(homeAllAppsIntent); return; } } else { mTaskbarActivityContext.toggleAllAppsSearch(); } } /** * Displays a frame of the first Launcher reveal animation. Loading Loading @@ -447,9 +442,12 @@ public class TaskbarManager { DeviceProfile dp = mUserUnlocked ? LauncherAppState.getIDP(mContext).getDeviceProfile(mContext) : null; // All Apps action is unrelated to navbar unification, so we only need to check DP. mAllAppsActionManager.setTaskbarPresent(dp != null && dp.isTaskbarPresent); destroyExistingTaskbar(); boolean isTaskbarEnabled = dp != null && isTaskbarPresent(dp); boolean isTaskbarEnabled = dp != null && isTaskbarEnabled(dp); debugWhyTaskbarNotDestroyed("recreateTaskbar: isTaskbarEnabled=" + isTaskbarEnabled + " [dp != null (i.e. mUserUnlocked)]=" + (dp != null) + " FLAG_HIDE_NAVBAR_WINDOW=" + ENABLE_TASKBAR_NAVBAR_UNIFICATION Loading Loading @@ -514,7 +512,7 @@ public class TaskbarManager { } } private static boolean isTaskbarPresent(DeviceProfile deviceProfile) { private static boolean isTaskbarEnabled(DeviceProfile deviceProfile) { return ENABLE_TASKBAR_NAVBAR_UNIFICATION || deviceProfile.isTaskbarPresent; } Loading
quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java +5 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,11 @@ public class TaskbarUIController { return false; } /** Returns {@code true} if Home All Apps available instead of Taskbar All Apps. */ protected boolean canToggleHomeAllApps() { return false; } @CallSuper protected void dumpLogs(String prefix, PrintWriter pw) { pw.println(String.format( Loading
quickstep/src/com/android/quickstep/AllAppsActionManager.kt 0 → 100644 +90 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.quickstep import android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS import android.app.PendingIntent import android.app.RemoteAction import android.content.Context import android.graphics.drawable.Icon import android.view.accessibility.AccessibilityManager import com.android.launcher3.R import java.util.concurrent.Executor /** * Registers a [RemoteAction] for toggling All Apps if needed. * * We need this action when either [isHomeAndOverviewSame] or [isTaskbarPresent] is `true`. When * home and overview are the same, we can control Launcher's or Taskbar's All Apps tray. If they are * not the same, but Taskbar is present, we can only control Taskbar's tray. */ class AllAppsActionManager( private val context: Context, private val bgExecutor: Executor, private val createAllAppsPendingIntent: () -> PendingIntent, ) { /** `true` if home and overview are the same Activity. */ var isHomeAndOverviewSame = false set(value) { field = value updateSystemAction() } /** `true` if Taskbar is enabled. */ var isTaskbarPresent = false set(value) { field = value updateSystemAction() } /** `true` if the action should be registered. */ var isActionRegistered = false private set private fun updateSystemAction() { val shouldRegisterAction = isHomeAndOverviewSame || isTaskbarPresent if (isActionRegistered == shouldRegisterAction) return isActionRegistered = shouldRegisterAction bgExecutor.execute { val accessibilityManager = context.getSystemService(AccessibilityManager::class.java) ?: return@execute if (shouldRegisterAction) { accessibilityManager.registerSystemAction( RemoteAction( Icon.createWithResource(context, R.drawable.ic_apps), context.getString(R.string.all_apps_label), context.getString(R.string.all_apps_label), createAllAppsPendingIntent(), ), GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS, ) } else { accessibilityManager.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS) } } } fun onDestroy() { context .getSystemService(AccessibilityManager::class.java) ?.unregisterSystemAction( GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS, ) } }