diff options
| author | 2018-05-19 04:36:16 +0000 | |
|---|---|---|
| committer | 2018-05-19 04:36:16 +0000 | |
| commit | d51bbc5fe48ee7573f4290e08d7760af78cfb669 (patch) | |
| tree | 7c84087853c5f08214a75253b6a57aee289dec9f | |
| parent | bca78e76b3cd28b2d9873a781ab31851a1fe071d (diff) | |
| parent | 96985e74261a0dacec66cb127821d7f2248f8438 (diff) | |
Merge "Fade back button in and out tied with the overview/shelf (1/2)" into pi-dev
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 3ecf89cebc47..ebfadd881c19 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 cc536a50bfc0..96ec232a7cbb 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 9307c224ef27..42bd66ae4a90 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<OverviewProxyLis Binder.restoreCallingIdentity(token); } } + + public void setBackButtonAlpha(float alpha, boolean animate) { + long token = Binder.clearCallingIdentity(); + try { + mHandler.post(() -> { + 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<OverviewProxyLis default void onInteractionFlagsChanged(@InteractionType int flags) {} default void onOverviewShown(boolean fromHome) {} default void onQuickScrubStarted() {} + default void onBackButtonAlphaChanged(float alpha, boolean animate) {} } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java index fb94756c2319..3c0b22660c17 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ButtonDispatcher.java @@ -14,13 +14,15 @@ package com.android.systemui.statusbar.phone; +import static com.android.systemui.Interpolators.ALPHA_IN; +import static com.android.systemui.Interpolators.ALPHA_OUT; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.view.View; import android.view.View.AccessibilityDelegate; -import com.android.systemui.Interpolators; import com.android.systemui.plugins.statusbar.phone.NavBarButtonProvider.ButtonInterface; import com.android.systemui.statusbar.policy.KeyButtonDrawable; @@ -150,10 +152,27 @@ public class ButtonDispatcher { } public void setAlpha(float alpha) { - mAlpha = alpha; - final int N = mViews.size(); - for (int i = 0; i < N; i++) { - mViews.get(i).setAlpha(alpha); + setAlpha(alpha, false /* animate */); + } + + public void setAlpha(float alpha, boolean animate) { + if (animate) { + if (mFadeAnimator != null) { + mFadeAnimator.cancel(); + } + mFadeAnimator = ValueAnimator.ofFloat(getAlpha(), alpha); + mFadeAnimator.setDuration(getAlpha() < alpha? FADE_DURATION_IN : FADE_DURATION_OUT); + mFadeAnimator.setInterpolator(getAlpha() < alpha ? ALPHA_IN : ALPHA_OUT); + mFadeAnimator.addListener(mFadeListener); + mFadeAnimator.addUpdateListener(mAlphaListener); + mFadeAnimator.start(); + setVisibility(View.VISIBLE); + } else { + mAlpha = alpha; + final int N = mViews.size(); + for (int i = 0; i < N; i++) { + mViews.get(i).setAlpha(alpha); + } } } @@ -233,19 +252,6 @@ public class ButtonDispatcher { } } - public void animateFade(boolean in) { - if (mFadeAnimator != null) { - mFadeAnimator.cancel(); - } - mFadeAnimator = ValueAnimator.ofFloat(getAlpha(), in ? 1 : 0); - mFadeAnimator.setDuration(in? FADE_DURATION_IN : FADE_DURATION_OUT); - mFadeAnimator.setInterpolator(in ? Interpolators.ALPHA_IN : Interpolators.ALPHA_OUT); - mFadeAnimator.addListener(mFadeListener); - mFadeAnimator.addUpdateListener(mAlphaListener); - mFadeAnimator.start(); - setVisibility(View.VISIBLE); - } - public ArrayList<View> 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 2ddae7486859..2a37845fb4fb 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 28bbf5ba65f2..98672b238c4e 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<Nav disableRecent |= (flags & FLAG_SHOW_OVERVIEW_BUTTON) == 0; if (pinningActive) { disableBack = disableHome = false; - } else { - disableBack |= (flags & FLAG_HIDE_BACK_BUTTON) != 0; } } else if (pinningActive) { disableBack = disableRecent = false; @@ -863,7 +860,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav public boolean isRotateButtonVisible() { return mShowRotateButton; } public void setMenuContainerVisibility(boolean visible) { - getMenuContainer().animateFade(visible); + getMenuContainer().setAlpha(visible ? 1 : 0, true /* animate */); } @Override |