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
* needed from current value
* @deprecated
*/
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
* 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 mIsEnabled;
private int mCurrentBoundedUserId = -1;
private float mBackButtonAlpha;
private float mNavBarButtonAlpha;
private MotionEvent mStatusBarGestureDownEvent;
private float mWindowCornerRadius;
private boolean mSupportsRoundedCornersOnWindows;
@@ -244,21 +244,24 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
@Override
public void setBackButtonAlpha(float alpha, boolean animate) {
if (!verifyCaller("setBackButtonAlpha")) {
public void setNavBarButtonAlpha(float alpha, boolean animate) {
if (!verifyCaller("setNavBarButtonAlpha")) {
return;
}
long token = Binder.clearCallingIdentity();
try {
mBackButtonAlpha = alpha;
mHandler.post(() -> {
notifyBackButtonAlphaChanged(alpha, animate);
});
mNavBarButtonAlpha = alpha;
mHandler.post(() -> notifyNavBarButtonAlphaChanged(alpha, animate));
} finally {
Binder.restoreCallingIdentity(token);
}
}
@Override
public void setBackButtonAlpha(float alpha, boolean animate) {
setNavBarButtonAlpha(alpha, animate);
}
@Override
public void onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {
if (!verifyCaller("onAssistantProgress")) {
@@ -470,7 +473,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
.supportsRoundedCornersOnWindows(mContext.getResources());
// 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
mNavBarMode = navModeController.addListener(this);
@@ -583,7 +586,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
public float getBackButtonAlpha() {
return mBackButtonAlpha;
return mNavBarButtonAlpha;
}
public void cleanupAfterDeath() {
@@ -655,7 +658,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
public void addCallback(OverviewProxyListener listener) {
mConnectionCallbacks.add(listener);
listener.onConnectionChanged(mOverviewProxy != null);
listener.onBackButtonAlphaChanged(mBackButtonAlpha, false);
listener.onNavBarButtonAlphaChanged(mNavBarButtonAlpha, false);
listener.onSystemUiStateChanged(mSysUiStateFlags);
}
@@ -686,14 +689,14 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
if (mOverviewProxy != null) {
mOverviewProxy.asBinder().unlinkToDeath(mOverviewServiceDeathRcpt, 0);
mOverviewProxy = null;
notifyBackButtonAlphaChanged(1f, false /* animate */);
notifyNavBarButtonAlphaChanged(1f, false /* animate */);
notifyConnectionChanged();
}
}
private void notifyBackButtonAlphaChanged(float alpha, boolean animate) {
private void notifyNavBarButtonAlphaChanged(float alpha, boolean animate) {
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 onOverviewShown(boolean fromHome) {}
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 onAssistantProgress(@FloatRange(from = 0.0, to = 1.0) float progress) {}
default void onAssistantGestureCompletion(float velocity) {}

View File

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