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

Commit be282e9b authored by Tony Wickham's avatar Tony Wickham
Browse files

Update taskbar to add extra hotseat items instead of recent apps

Removes recents-related code including the divider between it and
hotseat.

Test: manually on device

Fixes: 184366189
Bug: 184789479
Bug: 171917176
Change-Id: I7776c98659ded70f53a49befddcd23c8353c6440
parent b87f3cdc
Loading
Loading
Loading
Loading
+0 −21
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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.
-->

<View
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="@dimen/taskbar_divider_thickness"
    android:layout_height="@dimen/taskbar_divider_height"
    android:background="@color/taskbar_divider" />
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
@@ -27,5 +27,4 @@

    <!-- Taskbar -->
    <color name="taskbar_background">#101010</color>
    <color name="taskbar_divider">#C0C0C0</color>
</resources>
 No newline at end of file
+0 −2
Original line number Diff line number Diff line
@@ -134,7 +134,5 @@
    <dimen name="taskbar_icon_drag_icon_size">54dp</dimen>
    <!-- Note that this applies to both sides of all icons, so visible space is double this. -->
    <dimen name="taskbar_icon_spacing">8dp</dimen>
    <dimen name="taskbar_divider_thickness">1dp</dimen>
    <dimen name="taskbar_divider_height">32dp</dimen>
    <dimen name="taskbar_folder_margin">16dp</dimen>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public abstract class BaseQuickstepLauncher extends Launcher
        SysUINavigationMode.INSTANCE.get(this).removeModeChangeListener(this);
        if (mTaskbarController != null) {
            mTaskbarController.cleanup();
            mTaskbarController = null;
        }

        super.onDestroy();
+2 −91
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTR
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.ActivityOptions;
import android.content.ComponentName;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
@@ -56,9 +55,6 @@ import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.WindowManagerWrapper;

import java.util.ArrayList;
import java.util.List;

/**
 * Interfaces with Launcher/WindowManager/SystemUI to determine what to show in TaskbarView.
 */
@@ -76,17 +72,11 @@ public class TaskbarController {
    private final TaskbarStateHandler mTaskbarStateHandler;
    private final TaskbarAnimationController mTaskbarAnimationController;
    private final TaskbarHotseatController mHotseatController;
    private final TaskbarRecentsController mRecentsController;
    private final TaskbarDragController mDragController;

    // Initialized in init().
    private WindowManager.LayoutParams mWindowLayoutParams;

    // Contains all loaded Tasks, not yet deduped from Hotseat items.
    private List<Task> mLatestLoadedRecentTasks;
    // Contains all loaded Hotseat items.
    private ItemInfo[] mLatestLoadedHotseatItems;

    private @Nullable Animator mAnimator;
    private boolean mIsAnimatingToLauncher;

@@ -106,8 +96,6 @@ public class TaskbarController {
                createTaskbarAnimationControllerCallbacks());
        mHotseatController = new TaskbarHotseatController(mLauncher,
                createTaskbarHotseatControllerCallbacks());
        mRecentsController = new TaskbarRecentsController(mLauncher,
                createTaskbarRecentsControllerCallbacks());
        mDragController = new TaskbarDragController(mLauncher);
    }

@@ -220,24 +208,6 @@ public class TaskbarController {
            @Override
            public void updateHotseatItems(ItemInfo[] hotseatItemInfos) {
                mTaskbarViewInApp.updateHotseatItems(hotseatItemInfos);
                mLatestLoadedHotseatItems = hotseatItemInfos;
                dedupeAndUpdateRecentItems();
            }
        };
    }

    private TaskbarRecentsControllerCallbacks createTaskbarRecentsControllerCallbacks() {
        return new TaskbarRecentsControllerCallbacks() {
            @Override
            public void updateRecentItems(ArrayList<Task> recentTasks) {
                mLatestLoadedRecentTasks = recentTasks;
                dedupeAndUpdateRecentItems();
            }

            @Override
            public void updateRecentTaskAtIndex(int taskIndex, Task task) {
                mTaskbarViewInApp.updateRecentTaskAtIndex(taskIndex, task);
                mTaskbarViewOnHome.updateRecentTaskAtIndex(taskIndex, task);
            }
        };
    }
@@ -246,16 +216,13 @@ public class TaskbarController {
     * Initializes the Taskbar, including adding it to the screen.
     */
    public void init() {
        mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons(),
                mRecentsController.getNumRecentIcons());
        mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons(),
                mRecentsController.getNumRecentIcons());
        mTaskbarViewInApp.init(mHotseatController.getNumHotseatIcons());
        mTaskbarViewOnHome.init(mHotseatController.getNumHotseatIcons());
        mTaskbarContainerView.init(mTaskbarViewInApp);
        addToWindowManager();
        mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
        mTaskbarAnimationController.init();
        mHotseatController.init();
        mRecentsController.init();

        setWhichTaskbarViewIsVisible(mLauncher.hasBeenResumed()
                ? mTaskbarViewOnHome
@@ -292,7 +259,6 @@ public class TaskbarController {
        mTaskbarStateHandler.setTaskbarCallbacks(null);
        mTaskbarAnimationController.cleanup();
        mHotseatController.cleanup();
        mRecentsController.cleanup();

        setWhichTaskbarViewIsVisible(null);
    }
@@ -425,53 +391,6 @@ public class TaskbarController {
        return mTaskbarViewInApp.isDraggingItem() || mTaskbarViewOnHome.isDraggingItem();
    }

    private void dedupeAndUpdateRecentItems() {
        if (mLatestLoadedRecentTasks == null || mLatestLoadedHotseatItems == null) {
            return;
        }

        final int numRecentIcons = mRecentsController.getNumRecentIcons();

        // From most recent to least recently opened.
        List<Task> dedupedTasksInDescendingOrder = new ArrayList<>();
        for (int i = mLatestLoadedRecentTasks.size() - 1; i >= 0; i--) {
            Task task = mLatestLoadedRecentTasks.get(i);
            boolean isTaskInHotseat = false;
            for (ItemInfo hotseatItem : mLatestLoadedHotseatItems) {
                if (hotseatItem == null) {
                    continue;
                }
                ComponentName hotseatActivity = hotseatItem.getTargetComponent();
                if (hotseatActivity != null && task.key.sourceComponent.getPackageName()
                        .equals(hotseatActivity.getPackageName())) {
                    isTaskInHotseat = true;
                    break;
                }
            }
            if (!isTaskInHotseat) {
                dedupedTasksInDescendingOrder.add(task);
                if (dedupedTasksInDescendingOrder.size() == numRecentIcons) {
                    break;
                }
            }
        }

        // TaskbarView expects an array of all the recent tasks to show, in the order to show them.
        // So we create an array of the proper size, then fill it in such that the most recent items
        // are at the end. If there aren't enough elements to fill the array, leave them null.
        Task[] tasksArray = new Task[numRecentIcons];
        for (int i = 0; i < tasksArray.length; i++) {
            Task task = i >= dedupedTasksInDescendingOrder.size()
                    ? null
                    : dedupedTasksInDescendingOrder.get(i);
            tasksArray[tasksArray.length - 1 - i] = task;
        }

        mTaskbarViewInApp.updateRecentTasks(tasksArray);
        mTaskbarViewOnHome.updateRecentTasks(tasksArray);
        mRecentsController.loadIconsForTasks(tasksArray);
    }

    /**
     * @return Whether the given View is in the same window as Taskbar.
     */
@@ -573,12 +492,4 @@ public class TaskbarController {
    protected interface TaskbarHotseatControllerCallbacks {
        void updateHotseatItems(ItemInfo[] hotseatItemInfos);
    }

    /**
     * Contains methods that TaskbarRecentsController can call to interface with TaskbarController.
     */
    protected interface TaskbarRecentsControllerCallbacks {
        void updateRecentItems(ArrayList<Task> recentTasks);
        void updateRecentTaskAtIndex(int taskIndex, Task task);
    }
}
Loading