Merge "Hiding home handle while on home in no-button mode" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-06-18 00:10:17 +00:00
committed by Android (Google) Code Review
3 changed files with 35 additions and 25 deletions

View File

@@ -55,9 +55,16 @@ interface ISystemUiProxy {
/** /**
* Control the {@param alpha} of the back button in the navigation bar and {@param animate} if * Control the {@param alpha} of the back button in the navigation bar and {@param animate} if
* needed from current value * needed from current value
* @deprecated
*/ */
void setBackButtonAlpha(float alpha, boolean animate) = 8; void setBackButtonAlpha(float alpha, boolean animate) = 8;
/**
* Control the {@param alpha} of the option nav bar button (back-button in 2 button mode
* and home bar in no-button mode) and {@param animate} if needed from current value
*/
void setNavBarButtonAlpha(float alpha, boolean animate) = 19;
/** /**
* Proxies motion events from the homescreen UI to the status bar. Only called when * Proxies motion events from the homescreen UI to the status bar. Only called when
* swipe down is detected on WORKSPACE. The sender guarantees the following order of events on * swipe down is detected on WORKSPACE. The sender guarantees the following order of events on

View File

@@ -118,7 +118,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
private boolean mBound; private boolean mBound;
private boolean mIsEnabled; private boolean mIsEnabled;
private int mCurrentBoundedUserId = -1; private int mCurrentBoundedUserId = -1;
private float mBackButtonAlpha; private float mNavBarButtonAlpha;
private MotionEvent mStatusBarGestureDownEvent; private MotionEvent mStatusBarGestureDownEvent;
private float mWindowCornerRadius; private float mWindowCornerRadius;
private boolean mSupportsRoundedCornersOnWindows; private boolean mSupportsRoundedCornersOnWindows;
@@ -244,21 +244,24 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
} }
@Override @Override
public void setBackButtonAlpha(float alpha, boolean animate) { public void setNavBarButtonAlpha(float alpha, boolean animate) {
if (!verifyCaller("setBackButtonAlpha")) { if (!verifyCaller("setNavBarButtonAlpha")) {
return; return;
} }
long token = Binder.clearCallingIdentity(); long token = Binder.clearCallingIdentity();
try { try {
mBackButtonAlpha = alpha; mNavBarButtonAlpha = alpha;
mHandler.post(() -> { mHandler.post(() -> notifyNavBarButtonAlphaChanged(alpha, animate));
notifyBackButtonAlphaChanged(alpha, animate);
});
} finally { } finally {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
} }
@Override
public void setBackButtonAlpha(float alpha, boolean animate) {
setNavBarButtonAlpha(alpha, animate);
}
@Override @Override
public void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) { public void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {
if (!verifyCaller("onAssistantProgress")) { if (!verifyCaller("onAssistantProgress")) {
@@ -470,7 +473,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
.supportsRoundedCornersOnWindows(mContext.getResources()); .supportsRoundedCornersOnWindows(mContext.getResources());
// Assumes device always starts with back button until launcher tells it that it does not // Assumes device always starts with back button until launcher tells it that it does not
mBackButtonAlpha = 1.0f; mNavBarButtonAlpha = 1.0f;
// Listen for nav bar mode changes // Listen for nav bar mode changes
mNavBarMode = navModeController.addListener(this); mNavBarMode = navModeController.addListener(this);
@@ -583,7 +586,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
} }
public float getBackButtonAlpha() { public float getBackButtonAlpha() {
return mBackButtonAlpha; return mNavBarButtonAlpha;
} }
public void cleanupAfterDeath() { public void cleanupAfterDeath() {
@@ -655,7 +658,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
public void addCallback(OverviewProxyListener listener) { public void addCallback(OverviewProxyListener listener) {
mConnectionCallbacks.add(listener); mConnectionCallbacks.add(listener);
listener.onConnectionChanged(mOverviewProxy != null); listener.onConnectionChanged(mOverviewProxy != null);
listener.onBackButtonAlphaChanged(mBackButtonAlpha, false); listener.onNavBarButtonAlphaChanged(mNavBarButtonAlpha, false);
listener.onSystemUiStateChanged(mSysUiStateFlags); listener.onSystemUiStateChanged(mSysUiStateFlags);
} }
@@ -686,14 +689,14 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
if (mOverviewProxy != null) { if (mOverviewProxy != null) {
mOverviewProxy.asBinder().unlinkToDeath(mOverviewServiceDeathRcpt, 0); mOverviewProxy.asBinder().unlinkToDeath(mOverviewServiceDeathRcpt, 0);
mOverviewProxy = null; mOverviewProxy = null;
notifyBackButtonAlphaChanged(1f, false /* animate */); notifyNavBarButtonAlphaChanged(1f, false /* animate */);
notifyConnectionChanged(); notifyConnectionChanged();
} }
} }
private void notifyBackButtonAlphaChanged(float alpha, boolean animate) { private void notifyNavBarButtonAlphaChanged(float alpha, boolean animate) {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) { for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onBackButtonAlphaChanged(alpha, animate); mConnectionCallbacks.get(i).onNavBarButtonAlphaChanged(alpha, animate);
} }
} }
@@ -784,7 +787,8 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
default void onQuickStepStarted() {} default void onQuickStepStarted() {}
default void onOverviewShown(boolean fromHome) {} default void onOverviewShown(boolean fromHome) {}
default void onQuickScrubStarted() {} default void onQuickScrubStarted() {}
default void onBackButtonAlphaChanged(float alpha, boolean animate) {} /** Notify changes in the nav bar button alpha */
default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
default void onSystemUiStateChanged(int sysuiStateFlags) {} default void onSystemUiStateChanged(int sysuiStateFlags) {}
default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {} default void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
default void onAssistantGestureCompletion(float velocity) {} default void onAssistantGestureCompletion(float velocity) {}

View File

@@ -203,17 +203,16 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
} }
@Override @Override
public void onBackButtonAlphaChanged(float alpha, boolean animate) { public void onNavBarButtonAlphaChanged(float alpha, boolean animate) {
final ButtonDispatcher backButton = mNavigationBarView.getBackButton(); ButtonDispatcher buttonDispatcher = null;
final boolean useAltBack = if (QuickStepContract.isSwipeUpMode(mNavBarMode)) {
(mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) != 0; buttonDispatcher = mNavigationBarView.getBackButton();
if (QuickStepContract.isGesturalMode(mNavBarMode) && !useAltBack) { } else if (QuickStepContract.isGesturalMode(mNavBarMode)) {
// If property was changed to hide/show back button, going home will trigger buttonDispatcher = mNavigationBarView.getHomeHandle();
// launcher to to change the back button alpha to reflect property change }
backButton.setVisibility(View.GONE); if (buttonDispatcher != null) {
} else { buttonDispatcher.setVisibility(alpha > 0 ? View.VISIBLE : View.INVISIBLE);
backButton.setVisibility(alpha > 0 ? View.VISIBLE : View.INVISIBLE); buttonDispatcher.setAlpha(alpha, animate);
backButton.setAlpha(alpha, animate);
} }
} }
}; };