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

Commit 211f2309 authored by Michael Jurka's avatar Michael Jurka Committed by Android (Google) Code Review
Browse files

Merge "Fix Recents dismiss/back button behavior" into jb-mr1-dev

parents c2a28163 e5923631
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.recent;

import android.app.Activity;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -30,6 +31,8 @@ import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.statusbar.tablet.StatusBarPanel;

import java.util.List;

public class RecentsActivity extends Activity {
    public static final String TOGGLE_RECENTS_INTENT = "com.android.systemui.TOGGLE_RECENTS";
    public static final String CLOSE_RECENTS_INTENT = "com.android.systemui.CLOSE_RECENTS";
@@ -122,11 +125,15 @@ public class RecentsActivity extends Activity {

    public void dismissAndGoBack() {
        if (mRecentsPanel != null) {
            final SystemUIApplication app = (SystemUIApplication) getApplication();
            final RecentTasksLoader recentTasksLoader = app.getRecentTasksLoader();
            TaskDescription firstTask = mRecentsPanel.getBottomTask();
            if (firstTask != null && mRecentsPanel.simulateClick(firstTask)) {
                // recents panel will take care of calling show(false);
            final ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);

            final List<ActivityManager.RecentTaskInfo> recentTasks =
                    am.getRecentTasks(2,
                            ActivityManager.RECENT_WITH_EXCLUDED |
                            ActivityManager.RECENT_IGNORE_UNAVAILABLE);
            if (recentTasks.size() > 1 &&
                    mRecentsPanel.simulateClick(recentTasks.get(1).persistentId)) {
                // recents panel will take care of calling show(false) through simulateClick
                return;
            }
            mRecentsPanel.show(false);
+2 −2
Original line number Diff line number Diff line
@@ -76,11 +76,11 @@ public class RecentsHorizontalScrollView extends HorizontalScrollView
        }
    }

    public View findViewForTask(TaskDescription task) {
    public View findViewForTask(int persistentTaskId) {
        for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
            View v = mLinearLayout.getChildAt(i);
            RecentsPanelView.ViewHolder holder = (RecentsPanelView.ViewHolder) v.getTag();
            if (holder.taskDescription == task) {
            if (holder.taskDescription.persistentTaskId == persistentTaskId) {
                return v;
            }
        }
+4 −22
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        public void setAdapter(TaskDescriptionAdapter adapter);
        public void setCallback(RecentsCallback callback);
        public void setMinSwipeAlpha(float minAlpha);
        public View findViewForTask(TaskDescription task);
        public View findViewForTask(int persistentTaskId);
    }

    private final class OnLongClickDelegate implements View.OnLongClickListener {
@@ -518,24 +518,6 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        showIfReady();
    }

    public TaskDescription getBottomTask() {
        if (mRecentsContainer != null) {
            ViewGroup container = mRecentsContainer;
            if (container instanceof RecentsScrollView) {
                container = (ViewGroup) container.findViewById(
                        R.id.recents_linear_layout);
            }
            if (container.getChildCount() > 0) {
                View v = container.getChildAt(container.getChildCount() - 1);
                if (v.getTag() instanceof ViewHolder) {
                    ViewHolder h = (ViewHolder)v.getTag();
                    return h.taskDescription;
                }
            }
        }
        return null;
    }

    public void onWindowAnimationStart() {
        if (mItemToAnimateInWhenWindowAnimationIsFinished != null) {
            final int startDelay = 100;
@@ -622,11 +604,11 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
        setContentDescription(recentAppsAccessibilityDescription);
    }

    public boolean simulateClick(TaskDescription task) {
    public boolean simulateClick(int persistentTaskId) {
        if (mRecentsContainer instanceof RecentsScrollView){
            RecentsScrollView scrollView
                = (RecentsScrollView) mRecentsContainer;
            View v = scrollView.findViewForTask(task);
            View v = scrollView.findViewForTask(persistentTaskId);
            if (v != null) {
                handleOnClick(v);
                return true;
+2 −2
Original line number Diff line number Diff line
@@ -77,11 +77,11 @@ public class RecentsVerticalScrollView extends ScrollView
        }
    }

    public View findViewForTask(TaskDescription task) {
    public View findViewForTask(int persistentTaskId) {
        for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
            View v = mLinearLayout.getChildAt(i);
            RecentsPanelView.ViewHolder holder = (RecentsPanelView.ViewHolder) v.getTag();
            if (holder.taskDescription == task) {
            if (holder.taskDescription.persistentTaskId == persistentTaskId) {
                return v;
            }
        }