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

Commit 4b9cded1 authored by Winson's avatar Winson
Browse files

Enabling fast switching for all users.

- Consolidating notion of fast toggling and indicator in the tuner - if 
  it is enabled, the indicator will be enabled
- Upon entering recents, immediately enable the timer to jump to the 
  previous task
- Allowing for multiple durations in the first and subsequent toggles
- Disabling fast-toggle on freeform devices and when touch exploration 
  is enabled
- Simplifying UserInteractionEvent to a reusable event

Change-Id: Id1ca3cd035f4eded5141b2b333a2cab5434b79ee
parent 5012919b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -181,7 +181,10 @@
    <integer name="recents_animate_task_stack_scroll_duration">200</integer>

    <!-- The animation duration for scrolling the stack to a particular item. -->
    <integer name="recents_auto_advance_duration">2000</integer>
    <integer name="recents_auto_advance_duration">750</integer>

    <!-- The animation duration for subsequent scrolling the stack to a particular item. -->
    <integer name="recents_subsequent_auto_advance_duration">1000</integer>

    <!-- The animation duration for entering and exiting the history. -->
    <integer name="recents_history_transition_duration">250</integer>
+0 −5
Original line number Diff line number Diff line
@@ -1179,11 +1179,6 @@
    <!-- Description for the toggle for fast-toggling recents via the recents button. DO NOT TRANSLATE -->
    <string name="overview_fast_toggle_via_button_desc">Enable launch timeout while paging</string>

    <!-- Toggles the fast-toggling indicator. DO NOT TRANSLATE -->
    <string name="overview_fast_toggle_indicator">Enable fast toggle indicator</string>
    <!-- Description for the fast-toggling indicator. DO NOT TRANSLATE -->
    <string name="overview_fast_toggle_indicator_desc">Show an indicator for the launch timeout</string>

    <!-- Toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
    <string name="overview_initial_state_paging">Initialize to paging</string>
    <!-- Description for the toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
+0 −6
Original line number Diff line number Diff line
@@ -122,12 +122,6 @@
            android:title="@string/overview_fast_toggle_via_button"
            android:summary="@string/overview_fast_toggle_via_button_desc" />

        <com.android.systemui.tuner.TunerSwitch
            android:key="overview_fast_toggle_indicator"
            android:title="@string/overview_fast_toggle_indicator"
            android:summary="@string/overview_fast_toggle_indicator_desc"
            android:dependency="overview_fast_toggle_via_button" />

    </PreferenceScreen>

    <SwitchPreference
+31 −11
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEven
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsTaskStackAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent;
@@ -116,6 +117,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    // The trigger to automatically launch the current task
    private int mFocusTimerDuration;
    private DozeTrigger mIterateTrigger;
    private final UserInteractionEvent mUserInteractionEvent = new UserInteractionEvent();

    /**
     * A common Runnable to finish Recents by launching Home with an animation depending on the
@@ -549,7 +551,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
                        EventBus.getDefault().send(new FocusPreviousTaskViewEvent());
                    } else {
                        EventBus.getDefault().send(
                                new FocusNextTaskViewEvent(false /* showTimerIndicator */));
                                new FocusNextTaskViewEvent(0 /* timerIndicatorDuration */));
                    }
                    mLastTabKeyEventTime = SystemClock.elapsedRealtime();

@@ -562,7 +564,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            }
            case KeyEvent.KEYCODE_DPAD_UP: {
                EventBus.getDefault().send(
                        new FocusNextTaskViewEvent(false /* showTimerIndicator */));
                        new FocusNextTaskViewEvent(0 /* timerIndicatorDuration */));
                return true;
            }
            case KeyEvent.KEYCODE_DPAD_DOWN: {
@@ -588,10 +590,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD

    @Override
    public void onUserInteraction() {
        // TODO: Prevent creating so many events here
        final RecentsDebugFlags debugFlags = Recents.getDebugFlags();
        EventBus.getDefault().send(new UserInteractionEvent(debugFlags.isFastToggleRecentsEnabled()
                && debugFlags.isFastToggleIndicatorEnabled()));
        EventBus.getDefault().send(mUserInteractionEvent);
    }

    @Override
@@ -617,13 +616,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        if (!dismissHistory()) {
            final RecentsDebugFlags debugFlags = Recents.getDebugFlags();

            // Focus the next task
            EventBus.getDefault().send(
                    new FocusNextTaskViewEvent(debugFlags.isFastToggleRecentsEnabled()
                            && debugFlags.isFastToggleIndicatorEnabled()));

            // Start dozing after the recents button is clicked
            int timerIndicatorDuration = 0;
            if (debugFlags.isFastToggleRecentsEnabled()) {
                timerIndicatorDuration = getResources().getInteger(
                        R.integer.recents_subsequent_auto_advance_duration);

                mIterateTrigger.setDozeDuration(timerIndicatorDuration);
                if (!mIterateTrigger.isDozing()) {
                    mIterateTrigger.startDozing();
                } else {
@@ -631,6 +630,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
                }
            }

            // Focus the next task
            EventBus.getDefault().send(new FocusNextTaskViewEvent(timerIndicatorDuration));

            MetricsLogger.action(this, MetricsLogger.ACTION_OVERVIEW_PAGE);
        }
    }
@@ -660,6 +662,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
            } else {
                dismissRecentsToHome(true /* animateTaskViews */);
            }

            // Cancel any pending dozes
            EventBus.getDefault().send(mUserInteractionEvent);
        } else {
            // Do nothing
        }
@@ -682,6 +687,21 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        }
    }

    public final void onBusEvent(EnterRecentsTaskStackAnimationCompletedEvent event) {
        RecentsDebugFlags debugFlags = Recents.getDebugFlags();
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        if (!launchState.launchedWithAltTab && debugFlags.isFastToggleRecentsEnabled() &&
                RecentsDebugFlags.Static.EnableFastToggleTimeoutOnEnter) {
            mIterateTrigger.setDozeDuration(
                    getResources().getInteger(R.integer.recents_auto_advance_duration));
            if (!mIterateTrigger.isDozing()) {
                mIterateTrigger.startDozing();
            } else {
                mIterateTrigger.poke();
            }
        }
    }

    public final void onBusEvent(EnterRecentsWindowLastAnimationFrameEvent event) {
        EventBus.getDefault().send(new UpdateFreeformTaskViewVisibilityEvent(true));
        mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
+5 −20
Original line number Diff line number Diff line
@@ -52,27 +52,12 @@ public class RecentsActivityLaunchState {
     * Returns the task to focus given the current launch state.
     */
    public int getInitialFocusTaskIndex(int numTasks) {
        RecentsDebugFlags flags = Recents.getDebugFlags();
        if (launchedWithAltTab) {
        if (launchedFromAppWithThumbnail) {
                // If alt-tabbing from another app, focus the next task
            // If coming from another app, focus the next task
            return numTasks - 2;
        } else {
                // If alt-tabbing from home, focus the first task
            // If coming from home, focus the first task
            return numTasks - 1;
        }
        } else {
            if (launchedFromHome) {
                return numTasks - 1;
            } else {
                if (flags.isFastToggleRecentsEnabled() || !flags.isInitialStatePaging()) {
                    // If we are not fast-toggling or are starting in the non-focused mode, then
                    // we should assume the front most task has focus
                    return numTasks - 1;
                } else {
                    return numTasks - 2;
                }
            }
        }
    }
}
Loading