Merge "Initial commit of TaskBar on keyguard" into sc-v2-dev am: 5219c563be
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14738711 Change-Id: Ibdd38d7f528b490727049568fe3a776da7b27e5c
This commit is contained in:
@@ -55,6 +55,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
private AlphaProperty mIconAlphaForHome;
|
||||
private @Nullable Animator mAnimator;
|
||||
private boolean mIsAnimatingToLauncher;
|
||||
private TaskbarKeyguardController mKeyguardController;
|
||||
|
||||
public LauncherTaskbarUIController(
|
||||
BaseQuickstepLauncher launcher, TaskbarActivityContext context) {
|
||||
@@ -81,6 +82,7 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
mHotseatController.init();
|
||||
setTaskbarViewVisible(!mLauncher.hasBeenResumed());
|
||||
mLauncher.setTaskbarUIController(this);
|
||||
mKeyguardController = taskbarControllers.taskbarKeyguardController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,6 +119,15 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
|
||||
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
|
||||
*/
|
||||
public void onLauncherResumedOrPaused(boolean isResumed) {
|
||||
if (mKeyguardController.isScreenOff()) {
|
||||
if (!isResumed) {
|
||||
return;
|
||||
} else {
|
||||
// Resuming implicitly means device unlocked
|
||||
mKeyguardController.setScreenOn();
|
||||
}
|
||||
}
|
||||
|
||||
long duration = QuickstepTransitionManager.CONTENT_ALPHA_DURATION;
|
||||
if (mAnimator != null) {
|
||||
mAnimator.cancel();
|
||||
|
||||
@@ -22,6 +22,7 @@ import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_HO
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_IME_SWITCH;
|
||||
import static com.android.launcher3.taskbar.TaskbarNavButtonController.BUTTON_RECENTS;
|
||||
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_IME;
|
||||
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_KEYGUARD;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING;
|
||||
@@ -65,6 +66,8 @@ public class NavbarButtonsViewController {
|
||||
private static final int FLAG_IME_VISIBLE = 1 << 1;
|
||||
private static final int FLAG_ROTATION_BUTTON_VISIBLE = 1 << 2;
|
||||
private static final int FLAG_A11Y_VISIBLE = 1 << 3;
|
||||
private static final int FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE = 1 << 4;
|
||||
private static final int FLAG_KEYGUARD_VISIBLE = 1 << 5;
|
||||
|
||||
private static final int MASK_IME_SWITCHER_VISIBLE = FLAG_SWITCHER_SUPPORTED | FLAG_IME_VISIBLE;
|
||||
|
||||
@@ -114,6 +117,10 @@ public class NavbarButtonsViewController {
|
||||
mControllers.taskbarViewController.getTaskbarIconAlpha()
|
||||
.getProperty(ALPHA_INDEX_IME),
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0, MultiValueAlpha.VALUE, 1, 0));
|
||||
mPropertyHolders.add(new StatePropertyHolder(
|
||||
mControllers.taskbarViewController.getTaskbarIconAlpha()
|
||||
.getProperty(ALPHA_INDEX_KEYGUARD),
|
||||
flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, MultiValueAlpha.VALUE, 1, 0));
|
||||
|
||||
// Rotation button
|
||||
RotationButton rotationButton = new RotationButtonImpl(addButton(mEndContainer));
|
||||
@@ -136,16 +143,21 @@ public class NavbarButtonsViewController {
|
||||
mPropertyHolders.add(new StatePropertyHolder(backButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0, View.ROTATION, 0,
|
||||
Utilities.isRtl(mContext.getResources()) ? 90 : -90));
|
||||
mPropertyHolders.add(new StatePropertyHolder(backButton,
|
||||
flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0 ||
|
||||
(flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0));
|
||||
|
||||
// home and recents buttons
|
||||
View homeButton = addButton(R.drawable.ic_sysbar_home, BUTTON_HOME, startContainer,
|
||||
navButtonController);
|
||||
mPropertyHolders.add(new StatePropertyHolder(homeButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0));
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0 &&
|
||||
(flags & FLAG_KEYGUARD_VISIBLE) == 0));
|
||||
View recentsButton = addButton(R.drawable.ic_sysbar_recent, BUTTON_RECENTS,
|
||||
startContainer, navButtonController);
|
||||
mPropertyHolders.add(new StatePropertyHolder(recentsButton,
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0));
|
||||
flags -> (flags & FLAG_IME_VISIBLE) == 0 &&
|
||||
(flags & FLAG_KEYGUARD_VISIBLE) == 0));
|
||||
|
||||
// IME switcher
|
||||
View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
|
||||
@@ -183,6 +195,22 @@ public class NavbarButtonsViewController {
|
||||
applyState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when we need to show back button for bouncer
|
||||
*/
|
||||
public void setBackForBouncer(boolean isBouncerVisible) {
|
||||
updateStateForFlag(FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE, isBouncerVisible);
|
||||
applyState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Slightly misnamed, but should be called when only keyguard OR AOD is showing
|
||||
*/
|
||||
public void setKeyguardVisible(boolean isKeyguardVisible) {
|
||||
updateStateForFlag(FLAG_KEYGUARD_VISIBLE, isKeyguardVisible);
|
||||
applyState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if IME bar is visible
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.launcher3.taskbar;
|
||||
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
|
||||
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
|
||||
@@ -123,7 +124,8 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
||||
new RotationButtonController(this, R.color.popup_color_primary_light,
|
||||
R.color.popup_color_primary_light),
|
||||
new TaskbarDragLayerController(this, mDragLayer),
|
||||
new TaskbarViewController(this, taskbarView));
|
||||
new TaskbarViewController(this, taskbarView),
|
||||
new TaskbarKeyguardController(this));
|
||||
|
||||
Display display = windowContext.getDisplay();
|
||||
Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
|
||||
@@ -137,7 +139,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
||||
mWindowLayoutParams = new WindowManager.LayoutParams(
|
||||
MATCH_PARENT,
|
||||
mLastRequestedNonFullscreenHeight,
|
||||
TYPE_APPLICATION_OVERLAY,
|
||||
TYPE_NAVIGATION_BAR_PANEL,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
|
||||
PixelFormat.TRANSLUCENT);
|
||||
mWindowLayoutParams.setTitle(WINDOW_TITLE);
|
||||
@@ -146,7 +148,6 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
||||
mWindowLayoutParams.setFitInsetsTypes(0);
|
||||
mWindowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING;
|
||||
mWindowLayoutParams.layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
mWindowLayoutParams.setSystemApplicationOverlay(true);
|
||||
|
||||
WindowManagerWrapper wmWrapper = WindowManagerWrapper.getInstance();
|
||||
wmWrapper.setProvidesInsetsTypes(
|
||||
@@ -220,17 +221,19 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
|
||||
systemUiStateFlags, forceUpdate);
|
||||
mControllers.taskbarViewController.setImeIsVisible(
|
||||
mControllers.navbarButtonsViewController.isImeVisible());
|
||||
mControllers.taskbarKeyguardController.updateStateForSysuiFlags(systemUiStateFlags);
|
||||
}
|
||||
|
||||
public void onRotationProposal(int rotation, boolean isValid) {
|
||||
mControllers.rotationButtonController.onRotationProposal(rotation, isValid);
|
||||
}
|
||||
|
||||
public void disable(int displayId, int state1, int state2, boolean animate) {
|
||||
public void disableNavBarElements(int displayId, int state1, int state2, boolean animate) {
|
||||
if (displayId != getDisplayId()) {
|
||||
return;
|
||||
}
|
||||
mControllers.rotationButtonController.onDisable2FlagChanged(state2);
|
||||
mControllers.taskbarKeyguardController.disableNavbarElements(state1, state2);
|
||||
}
|
||||
|
||||
public void onSystemBarAttributesChanged(int displayId, int behavior) {
|
||||
|
||||
@@ -31,6 +31,7 @@ public class TaskbarControllers {
|
||||
public final RotationButtonController rotationButtonController;
|
||||
public final TaskbarDragLayerController taskbarDragLayerController;
|
||||
public final TaskbarViewController taskbarViewController;
|
||||
public final TaskbarKeyguardController taskbarKeyguardController;
|
||||
|
||||
/** Do not store this controller, as it may change at runtime. */
|
||||
@NonNull public TaskbarUIController uiController = TaskbarUIController.DEFAULT;
|
||||
@@ -41,7 +42,8 @@ public class TaskbarControllers {
|
||||
NavbarButtonsViewController navbarButtonsViewController,
|
||||
RotationButtonController rotationButtonController,
|
||||
TaskbarDragLayerController taskbarDragLayerController,
|
||||
TaskbarViewController taskbarViewController) {
|
||||
TaskbarViewController taskbarViewController,
|
||||
TaskbarKeyguardController taskbarKeyguardController) {
|
||||
this.taskbarActivityContext = taskbarActivityContext;
|
||||
this.taskbarDragController = taskbarDragController;
|
||||
this.navButtonController = navButtonController;
|
||||
@@ -49,6 +51,7 @@ public class TaskbarControllers {
|
||||
this.rotationButtonController = rotationButtonController;
|
||||
this.taskbarDragLayerController = taskbarDragLayerController;
|
||||
this.taskbarViewController = taskbarViewController;
|
||||
this.taskbarKeyguardController = taskbarKeyguardController;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,6 +66,7 @@ public class TaskbarControllers {
|
||||
}
|
||||
taskbarDragLayerController.init(this);
|
||||
taskbarViewController.init(this);
|
||||
taskbarKeyguardController.init(navbarButtonsViewController);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,5 +76,6 @@ public class TaskbarControllers {
|
||||
uiController.onDestroy();
|
||||
rotationButtonController.onDestroy();
|
||||
taskbarDragLayerController.onDestroy();
|
||||
taskbarKeyguardController.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_DEVICE_DOZING;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* Controller for managing keyguard state for taskbar
|
||||
*/
|
||||
public class TaskbarKeyguardController {
|
||||
|
||||
private static final int KEYGUARD_SYSUI_FLAGS = SYSUI_STATE_BOUNCER_SHOWING |
|
||||
SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING | SYSUI_STATE_DEVICE_DOZING;
|
||||
|
||||
private final TaskbarActivityContext mContext;
|
||||
private int mDisabledNavIcons;
|
||||
private int mKeyguardSysuiFlags;
|
||||
private boolean mBouncerShowing;
|
||||
private NavbarButtonsViewController mNavbarButtonsViewController;
|
||||
private final KeyguardManager mKeyguardManager;
|
||||
private boolean mIsScreenOff;
|
||||
|
||||
private final BroadcastReceiver mScreenOffReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mIsScreenOff = true;
|
||||
}
|
||||
};
|
||||
|
||||
public TaskbarKeyguardController(TaskbarActivityContext context) {
|
||||
mContext = context;
|
||||
mKeyguardManager = mContext.getSystemService(KeyguardManager.class);
|
||||
}
|
||||
|
||||
public void init(NavbarButtonsViewController navbarButtonUIController) {
|
||||
mNavbarButtonsViewController = navbarButtonUIController;
|
||||
mContext.registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
|
||||
}
|
||||
|
||||
public void updateStateForSysuiFlags(int systemUiStateFlags) {
|
||||
boolean bouncerShowing = (systemUiStateFlags & SYSUI_STATE_BOUNCER_SHOWING) != 0;
|
||||
boolean keyguardShowing = (systemUiStateFlags & SYSUI_STATE_STATUS_BAR_KEYGUARD_SHOWING)
|
||||
!= 0;
|
||||
boolean dozing = (systemUiStateFlags & SYSUI_STATE_DEVICE_DOZING) != 0;
|
||||
|
||||
int interestingKeyguardFlags = systemUiStateFlags & KEYGUARD_SYSUI_FLAGS;
|
||||
if (interestingKeyguardFlags == mKeyguardSysuiFlags) {
|
||||
return;
|
||||
}
|
||||
mKeyguardSysuiFlags = interestingKeyguardFlags;
|
||||
|
||||
mBouncerShowing = bouncerShowing;
|
||||
if (!mContext.canShowNavButtons()) {
|
||||
// For gesture nav we don't need to deal with bouncer or showing taskbar when locked
|
||||
return;
|
||||
}
|
||||
|
||||
mNavbarButtonsViewController.setKeyguardVisible(keyguardShowing || dozing);
|
||||
updateIconsForBouncer();
|
||||
}
|
||||
|
||||
public boolean isScreenOff() {
|
||||
return mIsScreenOff;
|
||||
}
|
||||
|
||||
public void setScreenOn() {
|
||||
mIsScreenOff = false;
|
||||
}
|
||||
|
||||
public void disableNavbarElements(int state1, int state2) {
|
||||
if (mDisabledNavIcons == state1) {
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
mDisabledNavIcons = state1;
|
||||
updateIconsForBouncer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hides/shows taskbar when keyguard is up
|
||||
*/
|
||||
private void updateIconsForBouncer() {
|
||||
boolean disableBack = (mDisabledNavIcons & View.STATUS_BAR_DISABLE_BACK) != 0;
|
||||
boolean disableRecent = (mDisabledNavIcons & View.STATUS_BAR_DISABLE_RECENT) != 0;
|
||||
boolean disableHome = (mDisabledNavIcons & View.STATUS_BAR_DISABLE_HOME) != 0;
|
||||
boolean onlyBackEnabled = !disableBack && disableRecent && disableHome;
|
||||
|
||||
boolean showBackForBouncer = onlyBackEnabled &&
|
||||
mKeyguardManager.isDeviceSecure() &&
|
||||
mBouncerShowing;
|
||||
mNavbarButtonsViewController.setBackForBouncer(showBackForBouncer);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
mContext.unregisterReceiver(mScreenOffReceiver);
|
||||
}
|
||||
}
|
||||
@@ -136,10 +136,6 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
|
||||
onSysuiFlagsChangedInternal(mSysuiStateFlags, true /* forceUpdate */);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link com.android.systemui.shared.system.QuickStepContract.SystemUiStateFlags}
|
||||
* @param systemUiStateFlags The latest SystemUiStateFlags
|
||||
*/
|
||||
public void onSystemUiFlagsChanged(int systemUiStateFlags) {
|
||||
onSysuiFlagsChangedInternal(systemUiStateFlags, false /* forceUpdate */);
|
||||
}
|
||||
@@ -157,9 +153,9 @@ public class TaskbarManager implements DisplayController.DisplayInfoChangeListen
|
||||
}
|
||||
}
|
||||
|
||||
public void disable(int displayId, int state1, int state2, boolean animate) {
|
||||
public void disableNavBarElements(int displayId, int state1, int state2, boolean animate) {
|
||||
if (mTaskbarActivityContext != null) {
|
||||
mTaskbarActivityContext.disable(displayId, state1, state2, animate);
|
||||
mTaskbarActivityContext.disableNavBarElements(displayId, state1, state2, animate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ public class TaskbarViewController {
|
||||
public static final int ALPHA_INDEX_HOME = 0;
|
||||
public static final int ALPHA_INDEX_LAUNCHER_STATE = 1;
|
||||
public static final int ALPHA_INDEX_IME = 2;
|
||||
public static final int ALPHA_INDEX_KEYGUARD = 3;
|
||||
|
||||
private final TaskbarActivityContext mActivity;
|
||||
private final TaskbarView mTaskbarView;
|
||||
@@ -38,7 +39,7 @@ public class TaskbarViewController {
|
||||
public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
|
||||
mActivity = activity;
|
||||
mTaskbarView = taskbarView;
|
||||
mTaskbarIconAlpha = new MultiValueAlpha(mTaskbarView, 3);
|
||||
mTaskbarIconAlpha = new MultiValueAlpha(mTaskbarView, 4);
|
||||
mTaskbarIconAlpha.setUpdateVisibility(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
@Override
|
||||
public void disable(int displayId, int state1, int state2, boolean animate) {
|
||||
executeForTaskbarManager(() -> mTaskbarManager
|
||||
.disable(displayId, state1, state2, animate));
|
||||
.disableNavBarElements(displayId, state1, state2, animate));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user