Merge "Fade back button in and out tied with the overview/shelf (1/2)" into pi-dev
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 -----
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user