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

Commit e8482312 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12748980 from 2909e72d to 25Q1-release

Change-Id: I2ed1a23c847ed954b52002d13d9bd5e62298d8ed
parents af79b552 2909e72d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@
            android:stateNotNeeded="true"
            android:windowSoftInputMode="adjustPan"
            android:screenOrientation="unspecified"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize"
            android:configChanges="keyboard|keyboardHidden|mcc|mnc|navigation|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
            android:resizeableActivity="true"
            android:resumeWhilePausing="true"
            android:taskAffinity=""
+24 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     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.
-->
<com.android.quickstep.views.AddDesktopButton
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apgk/res-auto"
    android:id="@+id/add_desktop_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_desktop_add"
    android:padding="10dp" />
 No newline at end of file
+38 −33
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ import com.android.launcher3.util.TouchController
import com.android.launcher3.views.ActivityContext
import com.android.quickstep.RecentsModel
import com.android.quickstep.SystemUiProxy
import com.android.quickstep.util.GroupTask
import com.android.quickstep.util.DesktopTask
import com.android.systemui.shared.recents.model.Task
import com.android.systemui.shared.recents.model.ThumbnailData
import com.android.wm.shell.shared.multiinstance.ManageWindowsViewContainer
import java.util.Collections
@@ -60,20 +61,29 @@ class ManageWindowsTaskbarShortcut<T>(
    private val recentsModel = RecentsModel.INSTANCE[controllers.taskbarActivityContext]

    override fun onClick(v: View?) {
        val filter =
            Predicate<GroupTask> { task: GroupTask? ->
                task != null && task.task1.key.packageName == itemInfo?.getTargetPackage()
            }
        recentsModel.getTasks(
            { tasks: List<GroupTask> ->
                // Since fetching thumbnails is asynchronous, use this set to gate until the tasks
                // are ready to display
                val pendingTaskIds =
                    Collections.synchronizedSet(tasks.map { it.task1.key.id }.toMutableSet())
                createAndShowTaskShortcutView(tasks, pendingTaskIds)
            },
            filter,
        )
        val targetPackage = itemInfo?.getTargetPackage()
        val targetUserId = itemInfo?.user?.identifier
        val isTargetPackageTask: (Task) -> Boolean = { task ->
            task.key?.packageName == targetPackage && task.key.userId == targetUserId
        }

        recentsModel.getTasks { tasks ->
            val desktopTask = tasks.filterIsInstance<DesktopTask>().firstOrNull()
            val packageDesktopTasks =
                (desktopTask?.tasks ?: emptyList()).filter(isTargetPackageTask)
            val nonDesktopPackageTasks =
                tasks.filter { isTargetPackageTask(it.task1) }.map { it.task1 }

            // Add tasks from the fetched tasks, deduplicating by task ID
            val packageTasks =
                (packageDesktopTasks + nonDesktopPackageTasks).distinctBy { it.key.id }

            // Since fetching thumbnails is asynchronous, use `awaitedTaskIds` to gate until the
            // tasks are ready to display
            val awaitedTaskIds = packageTasks.map { it.key.id }.toMutableSet()

            createAndShowTaskShortcutView(packageTasks, awaitedTaskIds)
        }
    }

    /**
@@ -83,13 +93,10 @@ class ManageWindowsTaskbarShortcut<T>(
     * thumbnails are processed, it creates a [TaskbarShortcutManageWindowsView] with the collected
     * thumbnails and positions it appropriately.
     */
    private fun createAndShowTaskShortcutView(
        tasks: List<GroupTask?>,
        pendingTaskIds: MutableSet<Int>,
    ) {
    private fun createAndShowTaskShortcutView(tasks: List<Task>, pendingTaskIds: MutableSet<Int>) {
        val taskList = arrayListOf<Pair<Int, Bitmap?>>()
        tasks.forEach { groupTask ->
            groupTask?.task1?.let { task ->

        tasks.forEach { task ->
            recentsModel.thumbnailCache.getThumbnailInBackground(task) {
                thumbnailData: ThumbnailData ->
                pendingTaskIds.remove(task.key.id)
@@ -97,7 +104,6 @@ class ManageWindowsTaskbarShortcut<T>(
                if (thumbnailData.thumbnail != null) {
                    taskList.add(task.key.id to thumbnailData.thumbnail)
                }

                // If the set is empty, all thumbnails have been fetched
                if (pendingTaskIds.isEmpty() && taskList.isNotEmpty()) {
                    createAndPositionTaskbarShortcut(taskList)
@@ -105,7 +111,6 @@ class ManageWindowsTaskbarShortcut<T>(
            }
        }
    }
    }

    /**
     * Creates and positions the [TaskbarShortcutManageWindowsView] with the provided thumbnails.
+6 −4
Original line number Diff line number Diff line
@@ -326,8 +326,8 @@ class TaskbarRecentAppsController(context: Context, private val recentsModel: Re
    }

    /**
     * Returns the hotseat items updated so that any item that points to a package with a running
     * task also references that task.
     * Returns the hotseat items updated so that any item that points to a package+user with a
     * running task also references that task.
     */
    private fun updateHotseatItemsFromRunningTasks(
        groupTasks: List<GroupTask>,
@@ -338,8 +338,10 @@ class TaskbarRecentAppsController(context: Context, private val recentsModel: Re
                itemInfo
            } else {
                val foundTask =
                    groupTasks.find { task -> task.task1.key.packageName == itemInfo.targetPackage }
                        ?: return@map itemInfo
                    groupTasks.find { task ->
                        task.task1.key.packageName == itemInfo.targetPackage &&
                            task.task1.key.userId == itemInfo.user.identifier
                    } ?: return@map itemInfo
                TaskItemInfo(foundTask.task1.key.id, itemInfo as WorkspaceItemInfo)
            }
        }
+30 −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.views

import android.content.Context
import android.util.AttributeSet
import android.widget.ImageButton

/**
 * Button for supporting multiple desktop sessions. The button will be next to the first TaskView
 * inside overview, while clicking this button will create a new desktop session.
 */
class AddDesktopButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
    ImageButton(context, attrs) {
    // TODO(b/382057498): add this button the overview.
}
Loading