From 96985e74261a0dacec66cb127821d7f2248f8438 Mon Sep 17 00:00:00 2001 From: Matthew Ng Date: Tue, 8 May 2018 15:46:13 -0700 Subject: [PATCH] Fade back button in and out tied with the overview/shelf (1/2) Back button changes opacity when moving the shelf during swipe up between home screen and overview. The alpha changes depending on the progress of the swipe up animation. When going from app to home and vice versa, the fade animation does not tie with the swipe up progress. The fade animation also masks the back button drawable when ime visibility changes. Change-Id: Idaf219923af58732715d0f0b59386dea7ab0d0ad Fixes: 74581837 Fixes: 76900236 Test: swipe up from home screen to overview --- .../shared/recents/ISystemUiProxy.aidl | 6 +++ .../shared/system/NavigationBarCompat.java | 8 +--- .../systemui/OverviewProxyService.java | 14 +++++++ .../statusbar/phone/ButtonDispatcher.java | 42 +++++++++++-------- .../phone/NavigationBarFragment.java | 7 ++++ .../statusbar/phone/NavigationBarView.java | 5 +-- 6 files changed, 53 insertions(+), 29 deletions(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl index 3ecf89cebc475..ebfadd881c19a 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/ISystemUiProxy.aidl @@ -54,4 +54,10 @@ interface ISystemUiProxy { * Get the secondary split screen app's rectangle when not minimized. */ Rect getNonMinimizedSplitScreenSecondaryBounds() = 7; + + /** + * Control the {@param alpha} of the back button in the navigation bar and {@param animate} if + * needed from current value + */ + void setBackButtonAlpha(float alpha, boolean animate) = 8; } diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/NavigationBarCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/NavigationBarCompat.java index cc536a50bfc0f..96ec232a7cbb8 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/NavigationBarCompat.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/NavigationBarCompat.java @@ -62,8 +62,7 @@ public class NavigationBarCompat { @Retention(RetentionPolicy.SOURCE) @IntDef({FLAG_DISABLE_SWIPE_UP, FLAG_DISABLE_QUICK_SCRUB, - FLAG_SHOW_OVERVIEW_BUTTON, - FLAG_HIDE_BACK_BUTTON + FLAG_SHOW_OVERVIEW_BUTTON }) public @interface InteractionType {} @@ -82,11 +81,6 @@ public class NavigationBarCompat { */ public static final int FLAG_SHOW_OVERVIEW_BUTTON = 0x4; - /** - * Interaction type: show/hide the back button while this service is connected to launcher - */ - public static final int FLAG_HIDE_BACK_BUTTON = 0x8; - private static int convertDpToPixel(float dp){ return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } diff --git a/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java index 9307c224ef270..42bd66ae4a90d 100644 --- a/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/OverviewProxyService.java @@ -161,6 +161,19 @@ public class OverviewProxyService implements CallbackController { + for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) { + mConnectionCallbacks.get(i).onBackButtonAlphaChanged(alpha, animate); + } + }); + } finally { + Binder.restoreCallingIdentity(token); + } + } }; private final Runnable mDeferredConnectionCallback = () -> { @@ -389,5 +402,6 @@ public class OverviewProxyService implements CallbackController getViews() { return mViews; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 2ddae74868594..2a37845fb4fb2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -186,6 +186,13 @@ public class NavigationBarFragment extends Fragment implements Callbacks { mNavigationBarView.updateStates(); updateScreenPinningGestures(); } + + @Override + public void onBackButtonAlphaChanged(float alpha, boolean animate) { + final ButtonDispatcher backButton = mNavigationBarView.getBackButton(); + backButton.setVisibility(alpha > 0 ? View.VISIBLE : View.INVISIBLE); + backButton.setAlpha(alpha, animate); + } }; // ----- Fragment Lifecycle Callbacks ----- diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 98f9f1abd301b..64fed7a39b8eb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -85,7 +85,6 @@ import java.io.PrintWriter; import java.util.function.Consumer; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_DISABLE_QUICK_SCRUB; -import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_HIDE_BACK_BUTTON; import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_OVERVIEW; import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_ROTATION; @@ -655,8 +654,6 @@ public class NavigationBarView extends FrameLayout implements PluginListener