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

Commit a0e88b50 authored by Winson Chung's avatar Winson Chung
Browse files

Implementing Recents focus states. (Bug 16950262)

- Fixed issue with focus going to send front most task when coming from Home
- Adding shortcut to dismiss a task
- Refactoring code to get secondary overlay and affiliation color
- Throttling alt-tab key presses
- Fixing issue with slivers of the task thumbnail being visible for affiliated tasks

Change-Id: Iaafe408318646a423fd58b51bbe93dbe0f2eed99
parent 3e190250
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 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.
-->

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:attr/colorControlHighlight">
    <item android:drawable="@android:color/transparent" />
</ripple>
 No newline at end of file
+1 −3
Original line number Original line Diff line number Diff line
@@ -26,8 +26,7 @@
        android:id="@+id/task_view_bar"
        android:id="@+id/task_view_bar"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
        android:layout_height="@dimen/recents_task_bar_height"
        android:layout_height="@dimen/recents_task_bar_height"
        android:layout_gravity="top|center_horizontal"
        android:layout_gravity="top|center_horizontal">
        android:background="@color/recents_task_bar_default_background_color">
        <com.android.systemui.recents.views.FixedSizeImageView
        <com.android.systemui.recents.views.FixedSizeImageView
            android:id="@+id/application_icon"
            android:id="@+id/application_icon"
            android:layout_width="@dimen/recents_task_view_application_icon_size"
            android:layout_width="@dimen/recents_task_view_application_icon_size"
@@ -69,7 +68,6 @@
        android:layout_gravity="bottom|right"
        android:layout_gravity="bottom|right"
        android:layout_marginRight="15dp"
        android:layout_marginRight="15dp"
        android:layout_marginBottom="15dp"
        android:layout_marginBottom="15dp"
        android:translationZ="50dp"
        android:contentDescription="@string/recents_lock_to_app_button_label"
        android:contentDescription="@string/recents_lock_to_app_button_label"
        android:background="@drawable/recents_lock_to_task_button_bg">
        android:background="@drawable/recents_lock_to_task_button_bg">
        <ImageView
        <ImageView
+2 −0
Original line number Original line Diff line number Diff line
@@ -147,6 +147,8 @@
    <integer name="recents_max_task_stack_view_dim">96</integer>
    <integer name="recents_max_task_stack_view_dim">96</integer>
    <!-- The number of tasks that RecentsTaskLoader should load. -->
    <!-- The number of tasks that RecentsTaskLoader should load. -->
    <integer name="recents_max_num_tasks_to_load">50</integer>
    <integer name="recents_max_num_tasks_to_load">50</integer>
    <!-- The delay to enforce between each alt-tab key press. -->
    <integer name="recents_alt_tab_key_delay">200</integer>
    <!-- Transposes the recents layout in landscape. -->
    <!-- Transposes the recents layout in landscape. -->
    <bool name="recents_transpose_layout_with_orientation">true</bool>
    <bool name="recents_transpose_layout_with_orientation">true</bool>


+7 −6
Original line number Original line Diff line number Diff line
@@ -345,8 +345,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
     * Creates the activity options for an app->recents transition.  If this method sets the static
     * Creates the activity options for an app->recents transition.  If this method sets the static
     * screenshot, then we will use that for the transition.
     * screenshot, then we will use that for the transition.
     */
     */
    ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask) {
    ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo topTask,

            boolean isTopTaskHome) {
        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
        if (Constants.DebugFlags.App.EnableScreenshotAppTransition) {
            // Recycle the last screenshot
            // Recycle the last screenshot
            consumeLastScreenshot();
            consumeLastScreenshot();
@@ -365,7 +365,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        Bitmap firstThumbnail = mSystemServicesProxy.getTaskThumbnail(topTask.id);
        Bitmap firstThumbnail = mSystemServicesProxy.getTaskThumbnail(topTask.id);
        if (firstThumbnail != null) {
        if (firstThumbnail != null) {
            // Update the destination rect
            // Update the destination rect
            Rect toTaskRect = getThumbnailTransitionRect(topTask.id);
            Rect toTaskRect = getThumbnailTransitionRect(topTask.id, isTopTaskHome);
            if (toTaskRect.width() > 0 && toTaskRect.height() > 0) {
            if (toTaskRect.width() > 0 && toTaskRect.height() > 0) {
                // Create the new thumbnail for the animation down
                // Create the new thumbnail for the animation down
                // XXX: We should find a way to optimize this so we don't need to create a new bitmap
                // XXX: We should find a way to optimize this so we don't need to create a new bitmap
@@ -389,7 +389,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    }
    }


    /** Returns the transition rect for the given task id. */
    /** Returns the transition rect for the given task id. */
    Rect getThumbnailTransitionRect(int runningTaskId) {
    Rect getThumbnailTransitionRect(int runningTaskId, boolean isTopTaskHome) {
        // Get the stack of tasks that we are animating into
        // Get the stack of tasks that we are animating into
        TaskStack stack = RecentsTaskLoader.getShallowTaskStack(mSystemServicesProxy, -1);
        TaskStack stack = RecentsTaskLoader.getShallowTaskStack(mSystemServicesProxy, -1);
        if (stack.getTaskCount() == 0) {
        if (stack.getTaskCount() == 0) {
@@ -401,7 +401,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        TaskStackViewLayoutAlgorithm algo = tsv.getStackAlgorithm();
        TaskStackViewLayoutAlgorithm algo = tsv.getStackAlgorithm();
        Rect taskStackBounds = new Rect(mTaskStackBounds);
        Rect taskStackBounds = new Rect(mTaskStackBounds);
        taskStackBounds.bottom -= mSystemInsets.bottom;
        taskStackBounds.bottom -= mSystemInsets.bottom;
        tsv.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds, mTriggeredFromAltTab);
        tsv.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds,
                mTriggeredFromAltTab, isTopTaskHome);
        tsv.getScroller().setStackScrollToInitialState();
        tsv.getScroller().setStackScrollToInitialState();


        // Find the running task in the TaskStack
        // Find the running task in the TaskStack
@@ -442,7 +443,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta


        if (useThumbnailTransition) {
        if (useThumbnailTransition) {
            // Try starting with a thumbnail transition
            // Try starting with a thumbnail transition
            ActivityOptions opts = getThumbnailTransitionActivityOptions(topTask);
            ActivityOptions opts = getThumbnailTransitionActivityOptions(topTask, isTopTaskHome);
            if (opts != null) {
            if (opts != null) {
                if (sLastScreenshot != null) {
                if (sLastScreenshot != null) {
                    startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_APP_FULL_SCREENSHOT);
                    startAlternateRecentsActivity(topTask, opts, EXTRA_FROM_APP_FULL_SCREENSHOT);
+28 −11
Original line number Original line Diff line number Diff line
@@ -61,6 +61,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView


    RecentsConfiguration mConfig;
    RecentsConfiguration mConfig;
    boolean mVisible;
    boolean mVisible;
    long mLastTabKeyEventTime;


    // Top level views
    // Top level views
    RecentsView mRecentsView;
    RecentsView mRecentsView;
@@ -512,18 +513,34 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView


    @Override
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_TAB) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_TAB: {
                boolean hasRepKeyTimeElapsed = (System.currentTimeMillis() -
                        mLastTabKeyEventTime) > mConfig.altTabKeyDelay;
                if (event.getRepeatCount() <= 0 || hasRepKeyTimeElapsed) {
                    // Focus the next task in the stack
                    // Focus the next task in the stack
                    final boolean backward = event.isShiftPressed();
                    final boolean backward = event.isShiftPressed();
                    mRecentsView.focusNextTask(!backward);
                    mRecentsView.focusNextTask(!backward);
                    mLastTabKeyEventTime = System.currentTimeMillis();
                }
                return true;
                return true;
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
            }
            case KeyEvent.KEYCODE_DPAD_UP: {
                mRecentsView.focusNextTask(true);
                mRecentsView.focusNextTask(true);
                return true;
                return true;
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
            }
            case KeyEvent.KEYCODE_DPAD_DOWN: {
                mRecentsView.focusNextTask(false);
                mRecentsView.focusNextTask(false);
                return true;
                return true;
            }
            }
            case KeyEvent.KEYCODE_DEL:
            case KeyEvent.KEYCODE_FORWARD_DEL: {
                mRecentsView.dismissFocusedTask();
                return true;
            }
            default:
                break;
        }
        // Pass through the debug trigger
        // Pass through the debug trigger
        mDebugTrigger.onKeyEvent(keyCode);
        mDebugTrigger.onKeyEvent(keyCode);
        return super.onKeyDown(keyCode, event);
        return super.onKeyDown(keyCode, event);
Loading