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

Commit b1f74990 authored by Winson Chung's avatar Winson Chung Committed by Dan Sandler
Browse files

Initial changes to support swiping on the nav bar to switch affiliated tasks.

- Actual sideways animations to come once they've been finalized

Bug: 16846966
Change-Id: If6d40495498197a86a98f9b03f54ced3d2baf64a
parent 7036cb6b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -145,6 +145,8 @@
    <integer name="recents_animate_task_view_remove_duration">250</integer>
    <!-- The minimum alpha for the dim applied to cards that go deeper into the stack. -->
    <integer name="recents_max_task_stack_view_dim">96</integer>
    <!-- The number of tasks that RecentsTaskLoader should load. -->
    <integer name="recents_max_num_tasks_to_load">50</integer>
    <!-- Transposes the recents layout in landscape. -->
    <bool name="recents_transpose_layout_with_orientation">true</bool>

+2 −0
Original line number Diff line number Diff line
@@ -29,5 +29,7 @@ public interface RecentsComponent {
    void toggleRecents(Display display, int layoutDirection, View statusBarView);
    void preloadRecents();
    void cancelPreloadingRecents();
    void showNextAffiliatedTask();
    void showPrevAffiliatedTask();
    void setCallback(Callbacks cb);
}
+14 −0
Original line number Diff line number Diff line
@@ -273,6 +273,20 @@ public class Recents extends SystemUI implements RecentsComponent {
        }
    }

    @Override
    public void showNextAffiliatedTask() {
        if (mUseAlternateRecents) {
            mAlternateRecents.onShowNextAffiliatedTask();
        }
    }

    @Override
    public void showPrevAffiliatedTask() {
        if (mUseAlternateRecents) {
            mAlternateRecents.onShowPrevAffiliatedTask();
        }
    }

    @Override
    public void setCallback(Callbacks cb) {
        if (mUseAlternateRecents) {
+74 −1
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@ import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskGrouping;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.TaskStackView;
import com.android.systemui.recents.views.TaskStackViewLayoutAlgorithm;
@@ -165,6 +167,77 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        // Do nothing
    }

    void showRelativeAffiliatedTask(boolean showNextTask) {
        TaskStack stack = RecentsTaskLoader.getShallowTaskStack(mSystemServicesProxy,
                Integer.MAX_VALUE);
        // Return early if there are no tasks
        if (stack.getTaskCount() == 0) return;

        ActivityManager.RunningTaskInfo runningTask = getTopMostTask();
        // Return early if the running task is in the home stack (optimization)
        if (mSystemServicesProxy.isInHomeStack(runningTask.id)) return;

        // Find the task in the recents list
        ArrayList<Task> tasks = stack.getTasks();
        Task toTask = null;
        ActivityOptions launchOpts = null;
        int taskCount = tasks.size();
        for (int i = 0; i < taskCount; i++) {
            Task task = tasks.get(i);
            if (task.key.id == runningTask.id) {
                TaskGrouping group = task.group;
                Task.TaskKey toTaskKey;
                if (showNextTask) {
                    toTaskKey = group.getNextTaskInGroup(task);
                    // XXX: We will actually set the appropriate launch animations here
                } else {
                    toTaskKey = group.getPrevTaskInGroup(task);
                    // XXX: We will actually set the appropriate launch animations here
                }
                if (toTaskKey != null) {
                    toTask = stack.findTaskWithId(toTaskKey.id);
                }
                break;
            }
        }

        // Return early if there is no next task
        if (toTask == null) {
            // XXX: We will actually show a bounce animation here
            return;
        }

        // Launch the task
        if (toTask.isActive) {
            // Bring an active task to the foreground
            mSystemServicesProxy.moveTaskToFront(toTask.key.id, launchOpts);
        } else {
            // Launch the activity anew with the desired animation
            boolean isDocument = Utilities.isDocument(toTask.key.baseIntent);
            Intent intent = new Intent(toTask.key.baseIntent);
            intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
                    | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
            if (!isDocument) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            }
            try {
                mSystemServicesProxy.startActivityFromRecents(toTask.key.id, launchOpts);
            } catch (ActivityNotFoundException anfe) {}

            // Remove the old task from activity manager
            RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(toTask.key.id,
                    isDocument);
        }
    }

    public void onShowNextAffiliatedTask() {
        showRelativeAffiliatedTask(true);
    }

    public void onShowPrevAffiliatedTask() {
        showRelativeAffiliatedTask(false);
    }

    public void onConfigurationChanged(Configuration newConfig) {
        mConfig = RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy);
        mConfig.updateOnConfigurationChange();
@@ -318,7 +391,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    /** Returns the transition rect for the given task id. */
    Rect getThumbnailTransitionRect(int runningTaskId) {
        // Get the stack of tasks that we are animating into
        TaskStack stack = RecentsTaskLoader.getShallowTaskStack(mSystemServicesProxy);
        TaskStack stack = RecentsTaskLoader.getShallowTaskStack(mSystemServicesProxy, -1);
        if (stack.getTaskCount() == 0) {
            return new Rect();
        }
+7 −2
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ public class RecentsConfiguration {
    boolean isLandscape;
    boolean transposeRecentsLayoutWithOrientation;

    /** Loading */
    public int maxNumTasksToLoad;

    /** Search bar */
    int searchBarAppWidgetId = -1;
    public int searchBarSpaceHeightPx;
@@ -162,8 +165,7 @@ public class RecentsConfiguration {
        }

        // Layout
        isLandscape = res.getConfiguration().orientation ==
                Configuration.ORIENTATION_LANDSCAPE;
        isLandscape = res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
        transposeRecentsLayoutWithOrientation =
                res.getBoolean(R.bool.recents_transpose_layout_with_orientation);

@@ -180,6 +182,9 @@ public class RecentsConfiguration {
        filteringNewViewsAnimDuration =
                res.getInteger(R.integer.recents_filter_animate_new_views_duration);

        // Loading
        maxNumTasksToLoad = res.getInteger(R.integer.recents_max_num_tasks_to_load);

        // Search Bar
        searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height);
        searchBarAppWidgetId = settings.getInt(Constants.Values.App.Key_SearchAppWidgetId, -1);
Loading