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

Commit ed1e01d7 authored by George Mount's avatar George Mount
Browse files

Allow customization of background fade duration.

Bug 15195468

Change-Id: I02c1ef446cfa8aaedce640ab5694b6d9245bb9f7
parent 0811cbee
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1343,6 +1343,7 @@ package android {
    field public static final int windowTitleBackgroundStyle = 16842844; // 0x101005c
    field public static final int windowTitleSize = 16842842; // 0x101005a
    field public static final int windowTitleStyle = 16842843; // 0x101005b
    field public static final int windowTransitionBackgroundFadeDuration = 16843875; // 0x1010463
    field public static final int windowTranslucentNavigation = 16843760; // 0x10103f0
    field public static final int windowTranslucentStatus = 16843759; // 0x10103ef
    field public static final int writePermission = 16842760; // 0x1010008
@@ -33518,6 +33519,7 @@ package android.view {
    method public android.transition.Transition getSharedElementEnterTransition();
    method public android.transition.Transition getSharedElementExitTransition();
    method public abstract int getStatusBarColor();
    method public long getTransitionBackgroundFadeDuration();
    method public android.transition.TransitionManager getTransitionManager();
    method public abstract int getVolumeControlStream();
    method public android.view.WindowManager getWindowManager();
@@ -33576,6 +33578,7 @@ package android.view {
    method public abstract void setStatusBarColor(int);
    method public abstract void setTitle(java.lang.CharSequence);
    method public abstract deprecated void setTitleColor(int);
    method public void setTransitionBackgroundFadeDuration(long);
    method public void setTransitionManager(android.transition.TransitionManager);
    method public void setType(int);
    method public void setUiOptions(int);
+4 −3
Original line number Diff line number Diff line
@@ -129,9 +129,6 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
    protected static final String KEY_SCALE_TYPE = "shared_element:scaleType";
    protected static final String KEY_IMAGE_MATRIX = "shared_element:imageMatrix";

    // The background fade in/out duration. TODO: Enable tuning this.
    public static final int FADE_BACKGROUND_DURATION_MS = 300;

    protected static final ImageView.ScaleType[] SCALE_TYPE_VALUES = ImageView.ScaleType.values();

    /**
@@ -512,6 +509,10 @@ abstract class ActivityTransitionCoordinator extends ResultReceiver {
        return bundle;
    }

    protected long getFadeDuration() {
        return getWindow().getTransitionBackgroundFadeDuration();
    }

    /**
     * Captures placement information for Views with a shared element name for
     * Activity Transitions.
+11 −10
Original line number Diff line number Diff line
@@ -66,7 +66,8 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator {
        Bundle resultReceiverBundle = new Bundle();
        resultReceiverBundle.putParcelable(KEY_REMOTE_RECEIVER, this);
        mResultReceiver.send(MSG_SET_REMOTE_RECEIVER, resultReceiverBundle);
        getDecor().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        getDecor().getViewTreeObserver().addOnPreDrawListener(
                new ViewTreeObserver.OnPreDrawListener() {
                    @Override
                    public boolean onPreDraw() {
                        if (mIsReadyForTransition) {
@@ -315,7 +316,7 @@ class EnterTransitionCoordinator extends ActivityTransitionCoordinator {
            if (background != null) {
                background = background.mutate();
                mBackgroundAnimator = ObjectAnimator.ofInt(background, "alpha", 255);
                mBackgroundAnimator.setDuration(FADE_BACKGROUND_DURATION_MS);
                mBackgroundAnimator.setDuration(getFadeDuration());
                mBackgroundAnimator.addListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
+1 −1
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ class ExitTransitionCoordinator extends ActivityTransitionCoordinator {
                    }
                }
            });
            mBackgroundAnimator.setDuration(FADE_BACKGROUND_DURATION_MS);
            mBackgroundAnimator.setDuration(getFadeDuration());
            mBackgroundAnimator.start();
        }
    }
+23 −0
Original line number Diff line number Diff line
@@ -1515,6 +1515,29 @@ public abstract class Window {
     */
    public boolean getAllowExitTransitionOverlap() { return true; }

    /**
     * Returns the duration, in milliseconds, of the window background fade
     * when transitioning into or away from an Activity when called with an Activity Transition.
     * <p>When executing the enter transition, the background starts transparent
     * and fades in. This requires {@link #FEATURE_CONTENT_TRANSITIONS}. The default is
     * 300 milliseconds.</p>
     * @return The duration of the window background fade to opaque during enter transition.
     * @see #getEnterTransition()
     */
    public long getTransitionBackgroundFadeDuration() { return 0; }

    /**
     * Sets the duration, in milliseconds, of the window background fade
     * when transitioning into or away from an Activity when called with an Activity Transition.
     * <p>When executing the enter transition, the background starts transparent
     * and fades in. This requires {@link #FEATURE_CONTENT_TRANSITIONS}. The default is
     * 300 milliseconds.</p>
     * @param fadeDurationMillis The duration of the window background fade to or from opaque
     *                           during enter transition.
     * @see #setEnterTransition(android.transition.Transition)
     */
    public void setTransitionBackgroundFadeDuration(long fadeDurationMillis) { }

    /**
     * @return the color of the status bar.
     */
Loading