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

Commit 2c1cac12 authored by Winson Chung's avatar Winson Chung
Browse files

Revert "Removing historical tasks when packages are uninstalled."

This reverts commit 5d1413e7.

Change-Id: I6ca79949b4c92a5825554b91f4350685fa605c8f
parent 5d1413e7
Loading
Loading
Loading
Loading
+0 −24
Original line number Original line Diff line number Diff line
@@ -110,9 +110,7 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
        }
        }
    }
    }


    private Context mContext;
    private LayoutInflater mLayoutInflater;
    private LayoutInflater mLayoutInflater;
    private final List<Task> mTasks = new ArrayList<>();
    private final List<Row> mRows = new ArrayList<>();
    private final List<Row> mRows = new ArrayList<>();


    public RecentsHistoryAdapter(Context context) {
    public RecentsHistoryAdapter(Context context) {
@@ -123,10 +121,6 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
     * Updates this adapter with the given tasks.
     * Updates this adapter with the given tasks.
     */
     */
    public void updateTasks(Context context, List<Task> tasks) {
    public void updateTasks(Context context, List<Task> tasks) {
        mContext = context;
        mTasks.clear();
        mTasks.addAll(tasks);

        final Locale l = context.getResources().getConfiguration().locale;
        final Locale l = context.getResources().getConfiguration().locale;
        final String dateFormatStr = DateFormat.getBestDateTimePattern(l, "EEEEMMMMd");
        final String dateFormatStr = DateFormat.getBestDateTimePattern(l, "EEEEMMMMd");
        final List<Task> tasksMostRecent = new ArrayList<>(tasks);
        final List<Task> tasksMostRecent = new ArrayList<>(tasks);
@@ -150,24 +144,6 @@ public class RecentsHistoryAdapter extends RecyclerView.Adapter<RecentsHistoryAd
        notifyDataSetChanged();
        notifyDataSetChanged();
    }
    }


    /**
     * Removes historical tasks beloning to the specified package and user.
     */
    public void removeTasks(String packageName, int userId) {
        boolean packagesRemoved = false;
        for (int i = mTasks.size() - 1; i >= 0; i--) {
            Task task = mTasks.get(i);
            String taskPackage = task.key.getComponent().getPackageName();
            if (task.key.userId == userId && taskPackage.equals(packageName)) {
                mTasks.remove(i);
                packagesRemoved = true;
            }
        }
        if (packagesRemoved) {
            updateTasks(mContext, new ArrayList<Task>(mTasks));
        }
    }

    @Override
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
        switch (viewType) {
+0 −29
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.systemui.recents.history;
package com.android.systemui.recents.history;


import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -30,18 +29,9 @@ import android.view.animation.Interpolator;
import android.widget.LinearLayout;
import android.widget.LinearLayout;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivity;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.PackagesChangedEvent;
import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.misc.ReferenceCountedTrigger;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.TaskView;

import java.util.ArrayList;
import java.util.HashSet;


/**
/**
 * A list of the recent tasks that are not in the stack.
 * A list of the recent tasks that are not in the stack.
@@ -174,28 +164,9 @@ public class RecentsHistoryView extends LinearLayout {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
    }


    @Override
    protected void onAttachedToWindow() {
        SystemServicesProxy ssp = Recents.getSystemServices();
        EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1);
        super.onAttachedToWindow();
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        EventBus.getDefault().unregister(this);
    }

    @Override
    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        setSystemInsets(insets.getSystemWindowInsets());
        setSystemInsets(insets.getSystemWindowInsets());
        return insets;
        return insets;
    }
    }

    /**** EventBus Events ****/

    public final void onBusEvent(PackagesChangedEvent event) {
        mAdapter.removeTasks(event.packageName, event.userId);
    }
}
}