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

Commit b61e654b authored by Winson's avatar Winson
Browse files

Fallback 1 for Recents timeout behaviour

- Removing initial timeout
- Adding double tap to switch tasks

Change-Id: Ice6a508b842377809bf0dcea0997522164d0ccdf
parent 3e85f9e4
Loading
Loading
Loading
Loading
+3 −21
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ 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;
@@ -438,12 +437,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    protected void onPause() {
        super.onPause();

        RecentsDebugFlags flags = Recents.getDebugFlags();
        if (flags.isFastToggleRecentsEnabled()) {
        // Stop the fast-toggle dozer
        mIterateTrigger.stopDozing();
    }
    }

    @Override
    protected void onStop() {
@@ -649,6 +645,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
    }

    public final void onBusEvent(UserInteractionEvent event) {
        // Stop the fast-toggle dozer
        mIterateTrigger.stopDozing();
    }

@@ -695,21 +692,6 @@ 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);
+13 −0
Original line number Diff line number Diff line
@@ -52,10 +52,23 @@ public class RecentsActivityLaunchState {
     * Returns the task to focus given the current launch state.
     */
    public int getInitialFocusTaskIndex(int numTasks) {
        RecentsDebugFlags debugFlags = Recents.getDebugFlags();
        if (launchedFromAppWithThumbnail) {
            if (debugFlags.isFastToggleRecentsEnabled()) {
                // If fast toggling, focus the front most task so that the next tap will focus the
                // N-1 task
                return numTasks - 1;
            }

            // If coming from another app, focus the next task
            return numTasks - 2;
        } else {
            if (debugFlags.isFastToggleRecentsEnabled()) {
                // If fast toggling, defer focusing until the next tap (which will automatically
                // focus the front most task)
                return -1;
            }

            // If coming from home, focus the first task
            return numTasks - 1;
        }
+0 −5
Original line number Diff line number Diff line
@@ -39,8 +39,6 @@ public class RecentsDebugFlags implements TunerService.Tunable {
        public static final boolean EnableAffiliatedTaskGroups = true;
        // Overrides the Tuner flags and enables the fast toggle and timeout
        public static final boolean EnableFastToggleTimeoutOverride = true;
        // Enables toggling the fast-toggle timeout immediately after entering Recents
        public static final boolean EnableFastToggleTimeoutOnEnter = true;

        // Enables us to create mock recents tasks
        public static final boolean EnableMockTasks = false;
@@ -90,9 +88,6 @@ public class RecentsDebugFlags implements TunerService.Tunable {
     * @return whether the initial stack state is paging.
     */
    public boolean isInitialStatePaging() {
        if (Static.EnableFastToggleTimeoutOnEnter) {
            return true;
        }
        return mInitialStatePaging;
    }

+18 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.util.MutableBoolean;
import android.view.AppTransitionAnimationSpec;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewConfiguration;

import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs;
@@ -48,6 +49,7 @@ import com.android.systemui.recents.events.activity.DockingTopTaskEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent;
import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent;
import com.android.systemui.recents.events.activity.ToggleRecentsEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
@@ -81,8 +83,10 @@ import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener {

    private final static String TAG = "RecentsImpl";

    // The minimum amount of time between each recents button press that we will handle
    private final static int MIN_TOGGLE_DELAY_MS = 350;

    // The duration within which the user releasing the alt tab (from when they pressed alt tab)
    // that the fast alt-tab animation will run.  If the user's alt-tab takes longer than this
    // duration, then we will toggle recents after this duration.
@@ -337,21 +341,31 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
        mTriggeredFromAltTab = false;

        try {
            ViewConfiguration viewConfig = ViewConfiguration.get(mContext);
            SystemServicesProxy ssp = Recents.getSystemServices();
            ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask();
            MutableBoolean isTopTaskHome = new MutableBoolean(true);
            long elapsedTime = SystemClock.elapsedRealtime() - mLastToggleTime;

            if (topTask != null && ssp.isRecentsTopMost(topTask, isTopTaskHome)) {
                RecentsConfiguration config = Recents.getConfiguration();
                RecentsActivityLaunchState launchState = config.getLaunchState();
                if (!launchState.launchedWithAltTab) {
                    // If the user taps quickly
                    if (ViewConfiguration.getDoubleTapMinTime() < elapsedTime &&
                            elapsedTime < ViewConfiguration.getDoubleTapTimeout()) {
                        // Launch the next focused task
                        EventBus.getDefault().post(new LaunchNextTaskRequestEvent());
                    } else {
                        // Notify recents to move onto the next task
                        EventBus.getDefault().post(new IterateRecentsEvent());
                    }
                } else {
                    // If the user has toggled it too quickly, then just eat up the event here (it's
                    // better than showing a janky screenshot).
                    // NOTE: Ideally, the screenshot mechanism would take the window transform into
                    // account
                    if ((SystemClock.elapsedRealtime() - mLastToggleTime) < MIN_TOGGLE_DELAY_MS) {
                    if (elapsedTime < MIN_TOGGLE_DELAY_MS) {
                        return;
                    }

@@ -364,7 +378,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
                // better than showing a janky screenshot).
                // NOTE: Ideally, the screenshot mechanism would take the window transform into
                // account
                if ((SystemClock.elapsedRealtime() - mLastToggleTime) < MIN_TOGGLE_DELAY_MS) {
                if (elapsedTime < MIN_TOGGLE_DELAY_MS) {
                    return;
                }

+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.recents.events.activity;

import com.android.systemui.recents.events.EventBus;

/**
 * This event is sent to request that the next task is launched after a double-tap on the Recents
 * button.
 */
public class LaunchNextTaskRequestEvent extends EventBus.Event {
    // Simple event
}
Loading