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

Commit 91b225d4 authored by Winson's avatar Winson
Browse files

Disabling history

- Fixing regression in scrolling from the back of the stack to the front
  where bindVisibleTaskViews() would be called early causing jank and
  task views to be returned to the view pool before the animation was
  complete.

Change-Id: Ib68495a2e3b34f92a4971dd6b32b7bc6c616ac23
parent 31eb784f
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
     * Dismisses the history view back into the stack view.
     */
    boolean dismissHistory() {
        if (mRecentsView.isHistoryVisible()) {
        if (RecentsDebugFlags.Static.EnableHistory && mRecentsView.isHistoryVisible()) {
            EventBus.getDefault().send(new HideHistoryEvent(true /* animate */));
            return true;
        }
@@ -447,7 +447,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD

        // Reset some states
        mIgnoreAltTabRelease = false;
        if (mRecentsView.isHistoryVisible()) {
        if (RecentsDebugFlags.Static.EnableHistory && mRecentsView.isHistoryVisible()) {
            EventBus.getDefault().send(new HideHistoryEvent(false /* animate */));
        }

@@ -503,13 +503,16 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (RecentsDebugFlags.Static.EnableHistory) {
            outState.putBoolean(KEY_SAVED_STATE_HISTORY_VISIBLE, mRecentsView.isHistoryVisible());
        }
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        if (savedInstanceState.getBoolean(KEY_SAVED_STATE_HISTORY_VISIBLE, false)) {
        if (RecentsDebugFlags.Static.EnableHistory &&
                savedInstanceState.getBoolean(KEY_SAVED_STATE_HISTORY_VISIBLE, false)) {
            EventBus.getDefault().send(new ShowHistoryEvent());
        }
    }
@@ -603,7 +606,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    /**** EventBus events ****/

    public final void onBusEvent(ToggleRecentsEvent event) {
        if (!dismissHistory()) {
        if (!RecentsDebugFlags.Static.EnableHistory || !dismissHistory()) {
            RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
            if (launchState.launchedFromHome) {
                dismissRecentsToHome(true /* animateTaskViews */);
@@ -614,7 +617,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    }

    public final void onBusEvent(IterateRecentsEvent event) {
        if (!dismissHistory()) {
        if (!RecentsDebugFlags.Static.EnableHistory || !dismissHistory()) {
            final RecentsDebugFlags debugFlags = Recents.getDebugFlags();

            // Start dozing after the recents button is clicked
@@ -651,7 +654,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            }
        } else if (event.triggeredFromHomeKey) {
            // Otherwise, dismiss Recents to Home
            if (mRecentsView.isHistoryVisible()) {
            if (RecentsDebugFlags.Static.EnableHistory && mRecentsView.isHistoryVisible()) {
                // If the history view is visible, then just cross-fade home
                ActivityOptions opts = ActivityOptions.makeCustomAnimation(RecentsActivity.this,
                                R.anim.recents_to_launcher_enter,
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ public class RecentsDebugFlags implements TunerService.Tunable {
        public static final boolean DisableBackgroundCache = false;
        // Enables the task affiliations
        public static final boolean EnableAffiliatedTaskGroups = true;
        // Enables the history
        public static final boolean EnableHistory = false;
        // Overrides the Tuner flags and enables the fast toggle and timeout
        public static final boolean EnableFastToggleTimeoutOverride = true;

+110 −62
Original line number Diff line number Diff line
@@ -143,7 +143,9 @@ public class RecentsView extends FrameLayout {
        final float cornerRadius = context.getResources().getDimensionPixelSize(
                R.dimen.recents_task_view_rounded_corners_radius);
        LayoutInflater inflater = LayoutInflater.from(context);
        mHistoryButton = (TextView) inflater.inflate(R.layout.recents_history_button, this, false);
        if (RecentsDebugFlags.Static.EnableHistory) {
            mHistoryButton = (TextView) inflater.inflate(R.layout.recents_history_button, this,
                    false);
            mHistoryButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
@@ -158,6 +160,7 @@ public class RecentsView extends FrameLayout {
                    outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), cornerRadius);
                }
            });
        }
        mEmptyView = inflater.inflate(R.layout.recents_empty, this, false);
        addView(mEmptyView);

@@ -331,8 +334,10 @@ public class RecentsView extends FrameLayout {
        mTaskStackView.setVisibility(View.INVISIBLE);
        mEmptyView.setVisibility(View.VISIBLE);
        mEmptyView.bringToFront();
        if (RecentsDebugFlags.Static.EnableHistory) {
            mHistoryButton.bringToFront();
        }
    }

    /**
     * Shows the task stack and hides the empty view.
@@ -347,8 +352,10 @@ public class RecentsView extends FrameLayout {
        if (mSearchBar != null) {
            mSearchBar.bringToFront();
        }
        if (RecentsDebugFlags.Static.EnableHistory) {
            mHistoryButton.bringToFront();
        }
    }

    @Override
    protected void onAttachedToWindow() {
@@ -397,6 +404,7 @@ public class RecentsView extends FrameLayout {
                    MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
        }

        if (RecentsDebugFlags.Static.EnableHistory) {
            // Measure the history view
            if (mHistoryView != null && mHistoryView.getVisibility() != GONE) {
                measureChild(mHistoryView, MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
@@ -413,6 +421,7 @@ public class RecentsView extends FrameLayout {
                    MeasureSpec.makeMeasureSpec(historyButtonRect.width(), MeasureSpec.AT_MOST),
                    MeasureSpec.makeMeasureSpec(historyButtonRect.height(), MeasureSpec.AT_MOST));
            }
        }

        setMeasuredDimension(width, height);
    }
@@ -443,6 +452,7 @@ public class RecentsView extends FrameLayout {
            mEmptyView.layout(left, top, right, bottom);
        }

        if (RecentsDebugFlags.Static.EnableHistory) {
            // Layout the history view
            if (mHistoryView != null && mHistoryView.getVisibility() != GONE) {
                mHistoryView.layout(left, top, right, bottom);
@@ -469,11 +479,13 @@ public class RecentsView extends FrameLayout {
                        : historyButtonRect.right + mHistoryClearAllButton.getPaddingStart()
                        - mHistoryClearAllButton.getMeasuredWidth();
                int clearAllTop = historyButtonRect.top +
                    (historyButtonRect.height() - mHistoryClearAllButton.getMeasuredHeight()) / 2;
                        (historyButtonRect.height() - mHistoryClearAllButton.getMeasuredHeight()) /
                                2;
                mHistoryClearAllButton.layout(clearAllLeft, clearAllTop,
                        clearAllLeft + mHistoryClearAllButton.getMeasuredWidth(),
                        clearAllTop + mHistoryClearAllButton.getMeasuredHeight());
            }
        }

        if (mAwaitingFirstLayout) {
            mAwaitingFirstLayout = false;
@@ -540,9 +552,11 @@ public class RecentsView extends FrameLayout {
    }

    public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) {
        // Hide the history button
        int taskViewExitToHomeDuration = TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION;
        if (RecentsDebugFlags.Static.EnableHistory) {
            // Hide the history button
            hideHistoryButton(taskViewExitToHomeDuration, false /* translate */);
        }
        animateBackgroundScrim(0f, taskViewExitToHomeDuration);
    }

@@ -675,11 +689,17 @@ public class RecentsView extends FrameLayout {
            // Reset the view state
            mAwaitingFirstLayout = true;
            mLastTaskLaunchedWasFreeform = false;
            if (RecentsDebugFlags.Static.EnableHistory) {
                hideHistoryButton(0, false /* translate */);
            }
        }
    }

    public final void onBusEvent(ToggleHistoryEvent event) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        if (mHistoryView != null && mHistoryView.isVisible()) {
            EventBus.getDefault().send(new HideHistoryEvent(true /* animate */));
        } else {
@@ -688,6 +708,10 @@ public class RecentsView extends FrameLayout {
    }

    public final void onBusEvent(ShowHistoryEvent event) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        if (mHistoryView == null) {
            LayoutInflater inflater = LayoutInflater.from(getContext());
            mHistoryView = (RecentsHistoryView) inflater.inflate(R.layout.recents_history, this,
@@ -746,6 +770,10 @@ public class RecentsView extends FrameLayout {
    }

    public final void onBusEvent(HideHistoryEvent event) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        // Animate the empty view in parallel with the history view (the task view animations are
        // handled in TaskStackView)
        Rect stackRect = mTaskStackView.mLayoutAlgorithm.mStackRect;
@@ -765,10 +793,18 @@ public class RecentsView extends FrameLayout {
    }

    public final void onBusEvent(ShowHistoryButtonEvent event) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        showHistoryButton(150, event.translate);
    }

    public final void onBusEvent(HideHistoryButtonEvent event) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        hideHistoryButton(100, true /* translate */);
    }

@@ -776,6 +812,10 @@ public class RecentsView extends FrameLayout {
     * Shows the history button.
     */
    private void showHistoryButton(final int duration, final boolean translate) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger();
        if (mHistoryButton.getVisibility() == View.INVISIBLE) {
            mHistoryButton.setVisibility(View.VISIBLE);
@@ -808,6 +848,10 @@ public class RecentsView extends FrameLayout {
     * Hides the history button.
     */
    private void hideHistoryButton(int duration, boolean translate) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger();
        hideHistoryButton(duration, translate, postAnimationTrigger);
        postAnimationTrigger.flushLastDecrementRunnables();
@@ -818,6 +862,10 @@ public class RecentsView extends FrameLayout {
     */
    private void hideHistoryButton(int duration, boolean translate,
            final ReferenceCountedTrigger postAnimationTrigger) {
        if (!RecentsDebugFlags.Static.EnableHistory) {
            return;
        }

        if (mHistoryButton.getVisibility() == View.VISIBLE) {
            if (translate) {
                mHistoryButton.animate()
+6 −4
Original line number Diff line number Diff line
@@ -467,12 +467,13 @@ public class TaskStackAnimationHelper {

        // Setup the end listener to return all the hidden views to the view pool after the
        // focus animation
        AnimatorListenerAdapter endListener = new AnimatorListenerAdapter() {
        ReferenceCountedTrigger postAnimTrigger = new ReferenceCountedTrigger();
        postAnimTrigger.addLastDecrementRunnable(new Runnable() {
            @Override
            public void onAnimationEnd(Animator animation) {
            public void run() {
                mStackView.bindVisibleTaskViews(newScroll);
            }
        };
        });

        List<TaskView> taskViews = mStackView.getTaskViews();
        int taskViewCount = taskViews.size();
@@ -513,7 +514,8 @@ public class TaskStackAnimationHelper {
            AnimationProps anim = new AnimationProps()
                    .setDuration(AnimationProps.BOUNDS, duration)
                    .setInterpolator(AnimationProps.BOUNDS, interpolator)
                    .setListener(endListener);
                    .setListener(postAnimTrigger.decrementOnAnimationEnd());
            postAnimTrigger.increment();
            mStackView.updateTaskViewToTransform(tv, toTransform, anim);
        }
        return willScroll;