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

Commit f73bca7a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Make TasksRepository listen to changes in task visuals and update" into main

parents cf4666fb 7640d974
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.launcher3.util.Executors.SimpleThreadFactory;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.SafeCloseable;
import com.android.quickstep.recents.data.RecentTasksDataSource;
import com.android.quickstep.recents.data.TaskVisualsChangeNotifier;
import com.android.quickstep.util.DesktopTask;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.TaskVisualsChangeListener;
@@ -65,7 +66,8 @@ import java.util.function.Predicate;
 */
@TargetApi(Build.VERSION_CODES.O)
public class RecentsModel implements RecentTasksDataSource, IconChangeListener,
        TaskStackChangeListener, TaskVisualsChangeListener, SafeCloseable {
        TaskStackChangeListener, TaskVisualsChangeListener, TaskVisualsChangeNotifier,
        SafeCloseable {

    // We do not need any synchronization for this variable as its only written on UI thread.
    public static final MainThreadInitializedObject<RecentsModel> INSTANCE =
@@ -287,6 +289,7 @@ public class RecentsModel implements RecentTasksDataSource, IconChangeListener,
    /**
     * Adds a listener for visuals changes
     */
    @Override
    public void addThumbnailChangeListener(TaskVisualsChangeListener listener) {
        mThumbnailChangeListeners.add(listener);
    }
@@ -294,6 +297,7 @@ public class RecentsModel implements RecentTasksDataSource, IconChangeListener,
    /**
     * Removes a previously added listener
     */
    @Override
    public void removeThumbnailChangeListener(TaskVisualsChangeListener listener) {
        mThumbnailChangeListeners.remove(listener);
    }
+6 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.launcher3.R;
import com.android.launcher3.util.CancellableTask;
import com.android.launcher3.util.Preconditions;
import com.android.quickstep.recents.data.HighResLoadingStateNotifier;
import com.android.quickstep.task.thumbnail.data.TaskThumbnailDataSource;
import com.android.quickstep.util.TaskKeyByLastActiveTimeCache;
import com.android.quickstep.util.TaskKeyCache;
@@ -48,7 +49,7 @@ public class TaskThumbnailCache implements TaskThumbnailDataSource {
    private final boolean mEnableTaskSnapshotPreloading;
    private final Context mContext;

    public static class HighResLoadingState {
    public static class HighResLoadingState implements HighResLoadingStateNotifier {
        private boolean mForceHighResThumbnails;
        private boolean mVisible;
        private boolean mFlingingFast;
@@ -65,11 +66,13 @@ public class TaskThumbnailCache implements TaskThumbnailDataSource {
            mForceHighResThumbnails = !supportsLowResThumbnails();
        }

        public void addCallback(HighResLoadingStateChangedCallback callback) {
        @Override
        public void addCallback(@NonNull HighResLoadingStateChangedCallback callback) {
            mCallbacks.add(callback);
        }

        public void removeCallback(HighResLoadingStateChangedCallback callback) {
        @Override
        public void removeCallback(@NonNull HighResLoadingStateChangedCallback callback) {
            mCallbacks.remove(callback);
        }

+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

package com.android.quickstep.recents.data

import com.android.quickstep.TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback

/** Notifies added callbacks that high res state has changed */
interface HighResLoadingStateNotifier {
    /** Adds a callback for high res loading state */
    fun addCallback(callback: HighResLoadingStateChangedCallback)

    /** Removes a callback for high res loading state */
    fun removeCallback(callback: HighResLoadingStateChangedCallback)
}
+0 −6
Original line number Diff line number Diff line
@@ -41,10 +41,4 @@ interface RecentTasksRepository {
     * populated e.g. icons/thumbnails etc.
     */
    fun setVisibleTasks(visibleTaskIdList: List<Int>)

    /**
     * Override [ThumbnailData] with a map of taskId to [ThumbnailData]. The override only applies
     * if the tasks are already visible, and will be invalidated when tasks become invisible.
     */
    fun addOrUpdateThumbnailOverride(thumbnailOverride: Map<Int, ThumbnailData>)
}
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.
 */

package com.android.quickstep.recents.data

import com.android.quickstep.util.TaskVisualsChangeListener

/** Notifies added listeners that task visuals have changed */
interface TaskVisualsChangeNotifier {
    /** Adds a listener for visuals changes */
    fun addThumbnailChangeListener(listener: TaskVisualsChangeListener)

    /** Removes a listener for visuals changes */
    fun removeThumbnailChangeListener(listener: TaskVisualsChangeListener)
}
Loading