Merge "Hide taskbar background when notification shade is expanded" into sc-v2-dev

This commit is contained in:
Tony Wickham
2021-10-26 02:56:47 +00:00
committed by Android (Google) Code Review
4 changed files with 49 additions and 20 deletions
@@ -30,7 +30,9 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_B
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_HOME_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SWITCHER_SHOWING;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_OVERVIEW_DISABLED;
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
import android.animation.ObjectAnimator;
import android.annotation.DrawableRes;
@@ -81,6 +83,7 @@ public class NavbarButtonsViewController {
private static final int FLAG_DISABLE_HOME = 1 << 7;
private static final int FLAG_DISABLE_RECENTS = 1 << 8;
private static final int FLAG_DISABLE_BACK = 1 << 9;
private static final int FLAG_NOTIFICATION_SHADE_EXPANDED = 1 << 10;
private static final int MASK_IME_SWITCHER_VISIBLE = FLAG_SWITCHER_SUPPORTED | FLAG_IME_VISIBLE;
@@ -98,6 +101,8 @@ public class NavbarButtonsViewController {
private final AnimatedFloat mTaskbarNavButtonTranslationY = new AnimatedFloat(
this::updateNavButtonTranslationY);
private final AnimatedFloat mNavButtonTranslationYMultiplier = new AnimatedFloat(
this::updateNavButtonTranslationY);
// Initialized in init.
private TaskbarControllers mControllers;
@@ -120,6 +125,7 @@ public class NavbarButtonsViewController {
mControllers = controllers;
mNavButtonsView.getLayoutParams().height = mContext.getDeviceProfile().taskbarSize;
parseSystemUiFlags(sharedState.sysuiStateFlags);
mNavButtonTranslationYMultiplier.value = 1;
mA11yLongClickListener = view -> {
mControllers.navButtonController.onButtonClick(BUTTON_A11Y_LONG_CLICK);
@@ -149,6 +155,11 @@ public class NavbarButtonsViewController {
.getKeyguardBgTaskbar(),
flags -> (flags & FLAG_KEYGUARD_VISIBLE) == 0, AnimatedFloat.VALUE, 1, 0));
// Make sure to remove nav bar buttons translation when notification shade is expanded.
mPropertyHolders.add(new StatePropertyHolder(mNavButtonTranslationYMultiplier,
flags -> (flags & FLAG_NOTIFICATION_SHADE_EXPANDED) != 0, AnimatedFloat.VALUE,
0, 1));
// Force nav buttons (specifically back button) to be visible during setup wizard.
boolean isInSetup = !mContext.isUserSetupComplete();
if (isThreeButtonNav || isInSetup) {
@@ -176,12 +187,12 @@ public class NavbarButtonsViewController {
}
}
// Animate taskbar background when IME shows
// Animate taskbar background when any of these flags are enabled
int flagsToShowBg = FLAG_IME_VISIBLE | FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE
| FLAG_NOTIFICATION_SHADE_EXPANDED;
mPropertyHolders.add(new StatePropertyHolder(
mControllers.taskbarDragLayerController.getNavbarBackgroundAlpha(),
flags -> (flags & FLAG_IME_VISIBLE) != 0 ||
(flags & FLAG_ONLY_BACK_FOR_BOUNCER_VISIBLE) != 0,
AnimatedFloat.VALUE, 1, 0));
flags -> (flags & flagsToShowBg) != 0, AnimatedFloat.VALUE, 1, 0));
// Rotation button
RotationButton rotationButton = new RotationButtonImpl(
@@ -258,6 +269,9 @@ public class NavbarButtonsViewController {
boolean isHomeDisabled = (sysUiStateFlags & SYSUI_STATE_HOME_DISABLED) != 0;
boolean isRecentsDisabled = (sysUiStateFlags & SYSUI_STATE_OVERVIEW_DISABLED) != 0;
boolean isBackDisabled = (sysUiStateFlags & SYSUI_STATE_BACK_DISABLED) != 0;
int shadeExpandedFlags = SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
boolean isNotificationShadeExpanded = (sysUiStateFlags & shadeExpandedFlags) != 0;
// TODO(b/202218289) we're getting IME as not visible on lockscreen from system
updateStateForFlag(FLAG_IME_VISIBLE, isImeVisible);
@@ -266,6 +280,7 @@ public class NavbarButtonsViewController {
updateStateForFlag(FLAG_DISABLE_HOME, isHomeDisabled);
updateStateForFlag(FLAG_DISABLE_RECENTS, isRecentsDisabled);
updateStateForFlag(FLAG_DISABLE_BACK, isBackDisabled);
updateStateForFlag(FLAG_NOTIFICATION_SHADE_EXPANDED, isNotificationShadeExpanded);
if (mA11yButton != null) {
// Only used in 3 button
@@ -360,7 +375,8 @@ public class NavbarButtonsViewController {
}
private void updateNavButtonTranslationY() {
mNavButtonsView.setTranslationY(mTaskbarNavButtonTranslationY.value);
mNavButtonsView.setTranslationY(mTaskbarNavButtonTranslationY.value
* mNavButtonTranslationYMultiplier.value);
}
private ImageView addButton(@DrawableRes int drawableId, @TaskbarButton int buttonType,
@@ -25,6 +25,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_Q
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
import android.animation.AnimatorSet;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -328,10 +329,9 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
mControllers.navbarButtonsViewController.updateStateForSysuiFlags(systemUiStateFlags);
mControllers.taskbarViewController.setImeIsVisible(
mControllers.navbarButtonsViewController.isImeVisible());
boolean panelExpanded = (systemUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) != 0;
boolean inSettings = (systemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) != 0;
mControllers.taskbarViewController.setNotificationShadeIsExpanded(
panelExpanded || inSettings);
int shadeExpandedFlags = SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED
| SYSUI_STATE_QUICK_SETTINGS_EXPANDED;
onNotificationShadeExpandChanged((systemUiStateFlags & shadeExpandedFlags) != 0);
mControllers.taskbarViewController.setRecentsButtonDisabled(
mControllers.navbarButtonsViewController.isRecentsDisabled());
mControllers.stashedHandleViewController.setIsHomeButtonDisabled(
@@ -341,6 +341,21 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
mControllers.taskbarScrimViewController.updateStateForSysuiFlags(systemUiStateFlags);
}
/**
* Hides the taskbar icons and background when the notication shade is expanded.
*/
private void onNotificationShadeExpandChanged(boolean isExpanded) {
float alpha = isExpanded ? 0 : 1;
AnimatorSet anim = new AnimatorSet();
anim.play(mControllers.taskbarViewController.getTaskbarIconAlpha().getProperty(
TaskbarViewController.ALPHA_INDEX_NOTIFICATION_EXPANDED).animateToValue(alpha));
if (!isThreeButtonNav()) {
anim.play(mControllers.taskbarDragLayerController.getNotificationShadeBgTaskbar()
.animateToValue(alpha));
}
anim.start();
}
public void onRotationProposal(int rotation, boolean isValid) {
mControllers.rotationButtonController.onRotationProposal(rotation, isValid);
}
@@ -42,6 +42,8 @@ public class TaskbarDragLayerController {
private final AnimatedFloat mBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
private final AnimatedFloat mBgNavbar = new AnimatedFloat(this::updateBackgroundAlpha);
private final AnimatedFloat mKeyguardBgTaskbar = new AnimatedFloat(this::updateBackgroundAlpha);
private final AnimatedFloat mNotificationShadeBgTaskbar = new AnimatedFloat(
this::updateBackgroundAlpha);
// Used to hide our background color when someone else (e.g. ScrimView) is handling it.
private final AnimatedFloat mBgOverride = new AnimatedFloat(this::updateBackgroundAlpha);
@@ -65,6 +67,7 @@ public class TaskbarDragLayerController {
mBgTaskbar.value = 1;
mKeyguardBgTaskbar.value = 1;
mNotificationShadeBgTaskbar.value = 1;
mBgOverride.value = 1;
updateBackgroundAlpha();
}
@@ -95,6 +98,10 @@ public class TaskbarDragLayerController {
return mKeyguardBgTaskbar;
}
public AnimatedFloat getNotificationShadeBgTaskbar() {
return mNotificationShadeBgTaskbar;
}
public AnimatedFloat getOverrideBackgroundAlpha() {
return mBgOverride;
}
@@ -105,7 +112,8 @@ public class TaskbarDragLayerController {
private void updateBackgroundAlpha() {
final float bgNavbar = mBgNavbar.value;
final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value;
final float bgTaskbar = mBgTaskbar.value * mKeyguardBgTaskbar.value
* mNotificationShadeBgTaskbar.value;
mTaskbarDragLayer.setTaskbarBackgroundAlpha(
mBgOverride.value * Math.max(bgNavbar, bgTaskbar)
);
@@ -115,16 +115,6 @@ public class TaskbarViewController {
mTaskbarView.setTouchesEnabled(!isImeVisible);
}
/**
* Should be called when the notification shade is expanded, so we can hide taskbar icons as
* well. Note that we are animating icons to appear / disappear.
*/
public void setNotificationShadeIsExpanded(boolean isNotificationShadeExpanded) {
mTaskbarIconAlpha.getProperty(ALPHA_INDEX_NOTIFICATION_EXPANDED)
.animateToValue(isNotificationShadeExpanded ? 0 : 1)
.start();
}
/**
* Should be called when the recents button is disabled, so we can hide taskbar icons as well.
*/