summaryrefslogtreecommitdiff
path: root/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
diff options
context:
space:
mode:
Diffstat (limited to 'quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java')
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java256
1 files changed, 178 insertions, 78 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index a1390aeabb..b15dda2de1 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -49,14 +49,15 @@ import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.hardware.display.DisplayManager;
import android.os.Process;
-import android.os.SystemProperties;
import android.os.Trace;
import android.provider.Settings;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.RoundedCorner;
+import android.view.Surface;
import android.view.View;
+import android.view.WindowInsets;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.Toast;
@@ -90,6 +91,8 @@ import com.android.launcher3.taskbar.bubbles.BubbleBarController;
import com.android.launcher3.taskbar.bubbles.BubbleBarView;
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController;
import com.android.launcher3.taskbar.bubbles.BubbleControllers;
+import com.android.launcher3.taskbar.bubbles.BubbleDismissController;
+import com.android.launcher3.taskbar.bubbles.BubbleDragController;
import com.android.launcher3.taskbar.bubbles.BubbleStashController;
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController;
import com.android.launcher3.taskbar.overlay.TaskbarOverlayController;
@@ -117,6 +120,7 @@ import com.android.systemui.unfold.updates.RotationChangeProvider;
import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider;
import java.io.PrintWriter;
+import java.util.Collections;
import java.util.Optional;
/**
@@ -128,8 +132,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private static final String IME_DRAWS_IME_NAV_BAR_RES_NAME = "config_imeDrawsImeNavBar";
- private static final boolean ENABLE_THREE_BUTTON_TASKBAR =
- SystemProperties.getBoolean("persist.debug.taskbar_three_button", false);
private static final String TAG = "TaskbarActivityContext";
private static final String WINDOW_TITLE = "Taskbar";
@@ -146,7 +148,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
private int mLastRequestedNonFullscreenHeight;
private NavigationMode mNavMode;
- private final boolean mImeDrawsImeNavBar;
+ private boolean mImeDrawsImeNavBar;
private final ViewCache mViewCache = new ViewCache();
private final boolean mIsSafeModeEnabled;
@@ -169,30 +171,27 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
unfoldTransitionProgressProvider) {
super(windowContext);
- final Resources resources = getResources();
- matchDeviceProfile(launcherDp, getResources());
+ applyDeviceProfile(launcherDp);
+
+ final Resources resources = getResources();
- mNavMode = DisplayController.getNavigationMode(windowContext);
mImeDrawsImeNavBar = getBoolByName(IME_DRAWS_IME_NAV_BAR_RES_NAME, resources, false);
mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
() -> getPackageManager().isSafeMode());
+
+ // TODO(b/244231596) For shared Taskbar window, update this value in applyDeviceProfile()
+ // instead so to get correct value when recreating the taskbar
SettingsCache settingsCache = SettingsCache.INSTANCE.get(this);
mIsUserSetupComplete = settingsCache.getValue(
Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), 0);
- mIsNavBarForceVisible = settingsCache.getValue(
- Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
-
- // TODO(b/244231596) For shared Taskbar window, update this value in init() instead so
- // to get correct value when recreating the taskbar
mIsNavBarKidsMode = settingsCache.getValue(
Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
+ mIsNavBarForceVisible = mIsNavBarKidsMode;
// Get display and corners first, as views might use them in constructor.
Display display = windowContext.getDisplay();
- Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
- ? windowContext.getApplicationContext()
- : windowContext.getApplicationContext().createDisplayContext(display);
+ Context c = getApplicationContext();
mWindowManager = c.getSystemService(WindowManager.class);
mLeftCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_LEFT);
mRightCorner = display.getRoundedCorner(RoundedCorner.POSITION_BOTTOM_RIGHT);
@@ -216,29 +215,34 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
// If Bubble bar is present, TaskbarControllers depends on it so build it first.
Optional<BubbleControllers> bubbleControllersOptional = Optional.empty();
- if (BubbleBarController.BUBBLE_BAR_ENABLED) {
+ if (BubbleBarController.BUBBLE_BAR_ENABLED && bubbleBarView != null) {
bubbleControllersOptional = Optional.of(new BubbleControllers(
new BubbleBarController(this, bubbleBarView),
new BubbleBarViewController(this, bubbleBarView),
new BubbleStashController(this),
- new BubbleStashedHandleViewController(this, bubbleHandleView)));
+ new BubbleStashedHandleViewController(this, bubbleHandleView),
+ new BubbleDragController(this),
+ new BubbleDismissController(this, mDragLayer)));
}
// Construct controllers.
+ RotationButtonController rotationButtonController = new RotationButtonController(this,
+ c.getColor(R.color.floating_rotation_button_light_color),
+ c.getColor(R.color.floating_rotation_button_dark_color),
+ R.drawable.ic_sysbar_rotate_button_ccw_start_0,
+ R.drawable.ic_sysbar_rotate_button_ccw_start_90,
+ R.drawable.ic_sysbar_rotate_button_cw_start_0,
+ R.drawable.ic_sysbar_rotate_button_cw_start_90,
+ () -> getDisplay().getRotation());
+ rotationButtonController.setBgExecutor(Executors.THREAD_POOL_EXECUTOR);
+
mControllers = new TaskbarControllers(this,
new TaskbarDragController(this),
buttonController,
isDesktopMode
? new DesktopNavbarButtonsViewController(this, navButtonsView)
: new NavbarButtonsViewController(this, navButtonsView),
- new RotationButtonController(this,
- c.getColor(R.color.floating_rotation_button_light_color),
- c.getColor(R.color.floating_rotation_button_dark_color),
- R.drawable.ic_sysbar_rotate_button_ccw_start_0,
- R.drawable.ic_sysbar_rotate_button_ccw_start_90,
- R.drawable.ic_sysbar_rotate_button_cw_start_0,
- R.drawable.ic_sysbar_rotate_button_cw_start_90,
- () -> getDisplay().getRotation()),
+ rotationButtonController,
new TaskbarDragLayerController(this, mDragLayer),
new TaskbarViewController(this, taskbarView),
new TaskbarScrimViewController(this, taskbarScrimView),
@@ -267,13 +271,48 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
bubbleControllersOptional);
}
+ /** Updates {@link DeviceProfile} instances for any Taskbar windows. */
+ public void updateDeviceProfile(DeviceProfile launcherDp) {
+ applyDeviceProfile(launcherDp);
+
+ mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
+ AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
+ // Reapply fullscreen to take potential new screen size into account.
+ setTaskbarWindowFullscreen(mIsFullscreen);
+
+ dispatchDeviceProfileChanged();
+ }
+
+ /**
+ * Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update
+ * the icon size
+ */
+ private void applyDeviceProfile(DeviceProfile originDeviceProfile) {
+ mDeviceProfile = originDeviceProfile.toBuilder(this)
+ .withDimensionsOverride(deviceProfile -> {
+ // Taskbar should match the number of icons of hotseat
+ deviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
+ // Same QSB width to have a smooth animation
+ deviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
+
+ // Update icon size
+ deviceProfile.iconSizePx = deviceProfile.taskbarIconSize;
+ deviceProfile.updateIconSize(1f, getResources());
+ }).build();
+ mNavMode = DisplayController.getNavigationMode(this);
+ }
+
+
public void init(@NonNull TaskbarSharedState sharedState) {
+ mImeDrawsImeNavBar = getBoolByName(IME_DRAWS_IME_NAV_BAR_RES_NAME, getResources(), false);
mLastRequestedNonFullscreenHeight = getDefaultTaskbarWindowHeight();
- mWindowLayoutParams =
- createDefaultWindowLayoutParams(TYPE_NAVIGATION_BAR_PANEL, WINDOW_TITLE);
+ mWindowLayoutParams = createAllWindowParams();
// Initialize controllers after all are constructed.
mControllers.init(sharedState);
+ // This may not be necessary and can be reverted once we move towards recreating all
+ // controllers without re-creating the window
+ mControllers.rotationButtonController.onNavigationModeChanged(mNavMode.resValue);
updateSysuiStateFlags(sharedState.sysuiStateFlags, true /* fromInit */);
disableNavBarElements(sharedState.disableNavBarDisplayId, sharedState.disableNavBarState1,
sharedState.disableNavBarState2, false /* animate */);
@@ -303,24 +342,16 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mControllers.taskbarStashController.showTaskbarFromBroadcast();
}
+ /** Toggles Taskbar All Apps overlay. */
+ public void toggleAllApps() {
+ mControllers.taskbarAllAppsController.toggle();
+ }
+
@Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
}
- /** Updates {@link DeviceProfile} instances for any Taskbar windows. */
- public void updateDeviceProfile(DeviceProfile launcherDp, NavigationMode navMode) {
- mNavMode = navMode;
- mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
- matchDeviceProfile(launcherDp, getResources());
-
- AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
- // Reapply fullscreen to take potential new screen size into account.
- setTaskbarWindowFullscreen(mIsFullscreen);
-
- dispatchDeviceProfileChanged();
- }
-
@Override
public void dispatchDeviceProfileChanged() {
super.dispatchDeviceProfileChanged();
@@ -329,24 +360,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
/**
- * Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update
- * the icon size
- */
- private void matchDeviceProfile(DeviceProfile originDeviceProfile, Resources resources) {
- mDeviceProfile = originDeviceProfile.toBuilder(this)
- .withDimensionsOverride(deviceProfile -> {
- // Taskbar should match the number of icons of hotseat
- deviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
- // Same QSB width to have a smooth animation
- deviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
-
- // Update icon size
- deviceProfile.iconSizePx = deviceProfile.taskbarIconSize;
- deviceProfile.updateIconSize(1f, resources);
- }).build();
- }
-
- /**
* Returns the View bounds of transient taskbar.
*/
public Rect getTransientTaskbarBounds() {
@@ -365,11 +378,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
* @param title The window title to pass to the created WindowManager.LayoutParams.
*/
public WindowManager.LayoutParams createDefaultWindowLayoutParams(int type, String title) {
- DeviceProfile deviceProfile = getDeviceProfile();
- // Taskbar is on the logical bottom of the screen
- boolean isVerticalBarLayout = TaskbarManager.isPhoneButtonNavMode(this) &&
- deviceProfile.isLandscape;
-
int windowFlags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_SLIPPERY
| WindowManager.LayoutParams.FLAG_SPLIT_TOUCH;
@@ -378,17 +386,14 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH;
}
WindowManager.LayoutParams windowLayoutParams = new WindowManager.LayoutParams(
- isVerticalBarLayout ? mLastRequestedNonFullscreenHeight : MATCH_PARENT,
- isVerticalBarLayout ? MATCH_PARENT : mLastRequestedNonFullscreenHeight,
+ MATCH_PARENT,
+ mLastRequestedNonFullscreenHeight,
type,
windowFlags,
PixelFormat.TRANSLUCENT);
windowLayoutParams.setTitle(title);
windowLayoutParams.packageName = getPackageName();
- windowLayoutParams.gravity = !isVerticalBarLayout ?
- Gravity.BOTTOM :
- Gravity.END; // TODO(b/230394142): seascape
-
+ windowLayoutParams.gravity = Gravity.BOTTOM;
windowLayoutParams.setFitInsetsTypes(0);
windowLayoutParams.receiveInsetsIgnoringZOrder = true;
windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
@@ -399,6 +404,64 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
TaskbarManager.isPhoneMode(mDeviceProfile)
? R.string.taskbar_phone_a11y_title
: R.string.taskbar_a11y_title);
+
+ return windowLayoutParams;
+ }
+
+ /**
+ * Creates {@link WindowManager.LayoutParams} for Taskbar, and also sets LP.paramsForRotation
+ * for taskbar showing as navigation bar
+ */
+ private WindowManager.LayoutParams createAllWindowParams() {
+ WindowManager.LayoutParams windowLayoutParams =
+ createDefaultWindowLayoutParams(TYPE_NAVIGATION_BAR_PANEL,
+ TaskbarActivityContext.WINDOW_TITLE);
+ boolean isPhoneNavMode = TaskbarManager.isPhoneButtonNavMode(this);
+ if (!isPhoneNavMode) {
+ return windowLayoutParams;
+ }
+
+ // Provide WM layout params for all rotations to cache, see NavigationBar#getBarLayoutParams
+ int width = WindowManager.LayoutParams.MATCH_PARENT;
+ int height = WindowManager.LayoutParams.MATCH_PARENT;
+ int gravity = Gravity.BOTTOM;
+ windowLayoutParams.paramsForRotation = new WindowManager.LayoutParams[4];
+ for (int rot = Surface.ROTATION_0; rot <= Surface.ROTATION_270; rot++) {
+ WindowManager.LayoutParams lp =
+ createDefaultWindowLayoutParams(TYPE_NAVIGATION_BAR_PANEL,
+ TaskbarActivityContext.WINDOW_TITLE);
+ switch (rot) {
+ case Surface.ROTATION_0, Surface.ROTATION_180 -> {
+ // Defaults are fine
+ width = WindowManager.LayoutParams.MATCH_PARENT;
+ height = mLastRequestedNonFullscreenHeight;
+ gravity = Gravity.BOTTOM;
+ }
+ case Surface.ROTATION_90 -> {
+ width = mLastRequestedNonFullscreenHeight;
+ height = WindowManager.LayoutParams.MATCH_PARENT;
+ gravity = Gravity.END;
+ }
+ case Surface.ROTATION_270 -> {
+ width = mLastRequestedNonFullscreenHeight;
+ height = WindowManager.LayoutParams.MATCH_PARENT;
+ gravity = Gravity.START;
+ }
+
+ }
+ lp.width = width;
+ lp.height = height;
+ lp.gravity = gravity;
+ windowLayoutParams.paramsForRotation[rot] = lp;
+ }
+
+ // Override current layout params
+ WindowManager.LayoutParams currentParams =
+ windowLayoutParams.paramsForRotation[getDisplay().getRotation()];
+ windowLayoutParams.width = currentParams.width;
+ windowLayoutParams.height = currentParams.height;
+ windowLayoutParams.gravity = currentParams.gravity;
+
return windowLayoutParams;
}
@@ -448,6 +511,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
return mControllers.taskbarDragController;
}
+ @Nullable
+ public BubbleControllers getBubbleControllers() {
+ return mControllers.bubbleControllers.orElse(null);
+ }
+
@Override
public ViewCache getViewCache() {
return mViewCache;
@@ -579,6 +647,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
Executors.MAIN_EXECUTOR.getHandler(), null,
elapsedRealTime -> callbacks.executeAllAndDestroy());
options.setSplashScreenStyle(splashScreenStyle);
+ options.setPendingIntentBackgroundActivityStartMode(
+ ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
return new ActivityOptionsWrapper(options, callbacks);
}
@@ -638,8 +708,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
mControllers.taskbarForceVisibleImmersiveController.updateSysuiFlags(systemUiStateFlags);
mControllers.voiceInteractionWindowController.setIsVoiceInteractionWindowVisible(
(systemUiStateFlags & SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING) != 0, fromInit);
-
mControllers.uiController.updateStateForSysuiFlags(systemUiStateFlags);
+ mControllers.bubbleControllers.ifPresent(controllers -> {
+ controllers.bubbleBarController.updateStateForSysuiFlags(systemUiStateFlags);
+ controllers.bubbleStashedHandleViewController.setIsHomeButtonDisabled(
+ mControllers.navbarButtonsViewController.isHomeDisabled());
+ });
}
/**
@@ -735,7 +809,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
}
mWindowLayoutParams.height = height;
- mControllers.taskbarInsetsController.onTaskbarWindowHeightOrInsetsChanged();
+ mControllers.taskbarInsetsController.onTaskbarOrBubblebarWindowHeightOrInsetsChanged();
mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
}
@@ -783,6 +857,21 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
/**
+ * Applies forcibly show flag to taskbar window iff transient taskbar is unstashed.
+ */
+ public void applyForciblyShownFlagWhileTransientTaskbarUnstashed(boolean shouldForceShow) {
+ if (!DisplayController.isTransientTaskbar(this)) {
+ return;
+ }
+ if (shouldForceShow) {
+ mWindowLayoutParams.forciblyShownTypes |= WindowInsets.Type.navigationBars();
+ } else {
+ mWindowLayoutParams.forciblyShownTypes &= ~WindowInsets.Type.navigationBars();
+ }
+ notifyUpdateLayoutParams();
+ }
+
+ /**
* Either adds or removes {@link WindowManager.LayoutParams#FLAG_NOT_FOCUSABLE} on the taskbar
* window. If we're now focusable, also move nav buttons to a separate window above IME.
*/
@@ -888,8 +977,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
}
} catch (NullPointerException
- | ActivityNotFoundException
- | SecurityException e) {
+ | ActivityNotFoundException
+ | SecurityException e) {
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
.show();
Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
@@ -936,9 +1025,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
if (recents == null) {
return;
}
- recents.getSplitSelectController().findLastActiveTaskAndRunCallback(
- info.getComponentKey(),
- foundTask -> {
+ recents.getSplitSelectController().findLastActiveTasksAndRunCallback(
+ Collections.singletonList(info.getComponentKey()),
+ foundTasks -> {
+ @Nullable Task foundTask = foundTasks.get(0);
if (foundTask != null) {
TaskView foundTaskView =
recents.getTaskViewByTaskId(foundTask.key.id);
@@ -982,6 +1072,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
/**
* Called when we detect a long press in the nav region before passing the gesture slop.
+ *
* @return Whether taskbar handled the long press, and thus should cancel the gesture.
*/
public boolean onLongPressToUnstashTaskbar() {
@@ -992,10 +1083,19 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
* Called when we want to unstash taskbar when user performs swipes up gesture.
*/
public void onSwipeToUnstashTaskbar() {
- mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
+ mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(/* stash= */ false);
mControllers.taskbarEduTooltipController.hide();
}
+ /**
+ * Called when we want to open bubblebar when user performs swipes up gesture.
+ */
+ public void onSwipeToOpenBubblebar() {
+ mControllers.bubbleControllers.ifPresent(controllers -> {
+ controllers.bubbleStashController.showBubbleBar(/* expandBubbles= */ true);
+ });
+ }
+
/** Returns {@code true} if Taskbar All Apps is open. */
public boolean isTaskbarAllAppsOpen() {
return mControllers.taskbarAllAppsController.isOpen();
@@ -1041,7 +1141,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
* Called when we detect a motion down or up/cancel in the nav region while stashed.
*
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
- * @param forceUnstash Whether we force the unstash hint.
+ * @param forceUnstash Whether we force the unstash hint.
*/
public void startTaskbarUnstashHint(boolean animateForward, boolean forceUnstash) {
// TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.