Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d51bbc5f authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Fade back button in and out tied with the overview/shelf (1/2)" into pi-dev

parents bca78e76 96985e74
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;
}
+1 −7
Original line number Diff line number Diff line
@@ -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);
    }
+14 −0
Original line number Diff line number Diff line
@@ -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) {}
    }
}
+24 −18
Original line number Diff line number Diff line
@@ -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,12 +152,29 @@ public class ButtonDispatcher {
    }

    public void setAlpha(float 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);
            }
        }
    }

    public void setDarkIntensity(float darkIntensity) {
        mDarkIntensity = darkIntensity;
@@ -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;
    }
+7 −0
Original line number Diff line number Diff line
@@ -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 -----
Loading