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

Commit 7c149b52 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Add gesture to drag in recents from navigation bar"

parents 1fae5028 dd98d41e
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -31,5 +31,20 @@ public interface RecentsComponent {
    /**
     * Docks the top-most task and opens recents.
     */
    void dockTopTask();
    void dockTopTask(boolean draggingInRecents);

    /**
     * Called during a drag-from-navbar-in gesture.
     *
     * @param distanceFromTop the distance of the current drag in gesture from the top of the
     *                        screen
     */
    void onDraggingInRecents(float distanceFromTop);

    /**
     * Called when the gesture to drag in recents ended.
     *
     * @param velocity the velocity of the finger when releasing it in pixels per second
     */
    void onDraggingInRecentsEnded(float velocity);
}
+1 −1
Original line number Diff line number Diff line
@@ -48,12 +48,12 @@ public class SystemUIApplication extends Application {
            com.android.systemui.keyguard.KeyguardViewMediator.class,
            com.android.systemui.recents.Recents.class,
            com.android.systemui.volume.VolumeUI.class,
            Divider.class,
            com.android.systemui.statusbar.SystemBars.class,
            com.android.systemui.usb.StorageNotification.class,
            com.android.systemui.power.PowerUI.class,
            com.android.systemui.media.RingtonePlayer.class,
            com.android.systemui.keyboard.KeyboardUI.class,
            Divider.class
    };

    /**
+3 −1
Original line number Diff line number Diff line
@@ -24,8 +24,10 @@ package com.android.systemui.recents;
oneway interface IRecentsNonSystemUserCallbacks {
    void preloadRecents();
    void cancelPreloadingRecents();
    void showRecents(boolean triggeredFromAltTab);
    void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents);
    void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
    void toggleRecents();
    void onConfigurationChanged();
    void onDraggingInRecents(float distanceFromTop);
    void onDraggingInRecentsEnded(float velocity);
}
+54 −4
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ public class Recents extends SystemUI

    private Handler mHandler;
    private RecentsImpl mImpl;
    private int mDraggingInRecentsCurrentUser;

    // Only For system user, this is the callbacks instance we return to each secondary user
    private RecentsSystemUser mSystemUserCallbacks;
@@ -213,14 +214,14 @@ public class Recents extends SystemUI

        int currentUser = sSystemServicesProxy.getCurrentUser();
        if (sSystemServicesProxy.isSystemUser(currentUser)) {
            mImpl.showRecents(triggeredFromAltTab);
            mImpl.showRecents(triggeredFromAltTab, false /* draggingInRecents */);
        } else {
            if (mSystemUserCallbacks != null) {
                IRecentsNonSystemUserCallbacks callbacks =
                        mSystemUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
                if (callbacks != null) {
                    try {
                        callbacks.showRecents(triggeredFromAltTab);
                        callbacks.showRecents(triggeredFromAltTab, false /* draggingInRecents */);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Callback failed", e);
                    }
@@ -361,8 +362,57 @@ public class Recents extends SystemUI
    }

    @Override
    public void dockTopTask() {
        mImpl.dockTopTask();
    public void dockTopTask(boolean draggingInRecents) {
        mImpl.dockTopTask(draggingInRecents);
        if (draggingInRecents) {
            mDraggingInRecentsCurrentUser = sSystemServicesProxy.getCurrentUser();
        }
    }

    @Override
    public void onDraggingInRecents(float distanceFromTop) {
        if (sSystemServicesProxy.isSystemUser(mDraggingInRecentsCurrentUser)) {
            mImpl.onDraggingInRecents(distanceFromTop);
        } else {
            if (mSystemUserCallbacks != null) {
                IRecentsNonSystemUserCallbacks callbacks =
                        mSystemUserCallbacks.getNonSystemUserRecentsForUser(
                                mDraggingInRecentsCurrentUser);
                if (callbacks != null) {
                    try {
                        callbacks.onDraggingInRecents(distanceFromTop);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Callback failed", e);
                    }
                } else {
                    Log.e(TAG, "No SystemUI callbacks found for user: "
                            + mDraggingInRecentsCurrentUser);
                }
            }
        }
    }

    @Override
    public void onDraggingInRecentsEnded(float velocity) {
        if (sSystemServicesProxy.isSystemUser(mDraggingInRecentsCurrentUser)) {
            mImpl.onDraggingInRecentsEnded(velocity);
        } else {
            if (mSystemUserCallbacks != null) {
                IRecentsNonSystemUserCallbacks callbacks =
                        mSystemUserCallbacks.getNonSystemUserRecentsForUser(
                                mDraggingInRecentsCurrentUser);
                if (callbacks != null) {
                    try {
                        callbacks.onDraggingInRecentsEnded(velocity);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Callback failed", e);
                    }
                } else {
                    Log.e(TAG, "No SystemUI callbacks found for user: "
                            + mDraggingInRecentsCurrentUser);
                }
            }
        }
    }

    @Override
+21 −6
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import com.android.systemui.recents.events.activity.IterateRecentsEvent;
import com.android.systemui.recents.events.activity.ToggleRecentsEvent;
import com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent;
import com.android.systemui.recents.events.component.ScreenPinningRequestEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEndedEvent;
import com.android.systemui.recents.events.ui.DraggingInRecentsEvent;
import com.android.systemui.recents.misc.DozeTrigger;
import com.android.systemui.recents.misc.ForegroundThread;
import com.android.systemui.recents.misc.SystemServicesProxy;
@@ -140,6 +142,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
    RecentsAppWidgetHost mAppWidgetHost;
    boolean mBootCompleted;
    boolean mCanReuseTaskStackViews = true;
    boolean mDraggingInRecents;

    // Task launching
    Rect mSearchBarBounds = new Rect();
@@ -164,14 +167,13 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        public void run() {
            // When this fires, then the user has not released alt-tab for at least
            // FAST_ALT_TAB_DELAY_MS milliseconds
            showRecents(mTriggeredFromAltTab);
            showRecents(mTriggeredFromAltTab, false /* draggingInRecents */);
        }
    });

    Bitmap mThumbnailTransitionBitmapCache;
    Task mThumbnailTransitionBitmapCacheKey;


    public RecentsImpl(Context context) {
        mContext = context;
        mHandler = new Handler();
@@ -248,8 +250,9 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
    }

    @Override
    public void showRecents(boolean triggeredFromAltTab) {
    public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents) {
        mTriggeredFromAltTab = triggeredFromAltTab;
        mDraggingInRecents = draggingInRecents;
        if (mFastAltTabTrigger.hasTriggered()) {
            // We are calling this from the doze trigger, so just fall through to show Recents
            mFastAltTabTrigger.resetTrigger();
@@ -315,6 +318,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
            return;
        }

        mDraggingInRecents = false;
        mTriggeredFromAltTab = false;

        try {
@@ -385,6 +389,16 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        // Do nothing
    }

    @Override
    public void onDraggingInRecents(float distanceFromTop) {
        EventBus.getDefault().sendOntoMainThread(new DraggingInRecentsEvent(distanceFromTop));
    }

    @Override
    public void onDraggingInRecentsEnded(float velocity) {
        EventBus.getDefault().sendOntoMainThread(new DraggingInRecentsEndedEvent(velocity));
    }

    /**
     * Transitions to the next recent task in the stack.
     */
@@ -521,13 +535,13 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        showRelativeAffiliatedTask(false);
    }

    public void dockTopTask() {
    public void dockTopTask(boolean draggingInRecents) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask();
        if (topTask != null && !SystemServicesProxy.isHomeStack(topTask.stackId)) {
            ssp.startTaskInDockedMode(topTask.id,
                    ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT);
            showRecents(false /* triggeredFromAltTab */);
            showRecents(false /* triggeredFromAltTab */, draggingInRecents);
        }
    }

@@ -856,7 +870,8 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        launchState.launchedNumVisibleTasks = vr.numVisibleTasks;
        launchState.launchedNumVisibleThumbnails = vr.numVisibleThumbnails;
        launchState.launchedHasConfigurationChanged = false;
        launchState.startHidden = topTask != null && topTask.stackId == FREEFORM_WORKSPACE_STACK_ID;
        launchState.startHidden = topTask != null && topTask.stackId == FREEFORM_WORKSPACE_STACK_ID
                || mDraggingInRecents;

        Intent intent = new Intent();
        intent.setClassName(RECENTS_PACKAGE, RECENTS_ACTIVITY);
Loading