[Partial screensharing] Handle clicking on recent apps

Adds launching recent activity with scale up animation
and a launch cookie that could be used to find
the activity and record the task.

Bug: 240924732
Test: manual + E2E tests will be implemented in b/240925102
Change-Id: I98dd6c8f0249efcf23a25924ebd3c9e248086aff
This commit is contained in:
Nick Chameyev
2022-09-27 12:17:29 +01:00
parent d639c8ee73
commit 9bd931c3be
2 changed files with 14 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
package com.android.systemui.media
import android.app.ActivityOptions
import android.app.IActivityTaskManager
import android.content.Intent
import android.media.projection.IMediaProjection
import android.media.projection.MediaProjectionManager.EXTRA_MEDIA_PROJECTION
@@ -46,6 +47,7 @@ import javax.inject.Inject
class MediaProjectionAppSelectorActivity(
private val activityLauncher: AsyncActivityLauncher,
private val activityTaskManager: IActivityTaskManager,
private val controller: MediaProjectionAppSelectorController,
private val recentTasksAdapterFactory: RecentTasksAdapter.Factory,
/** This is used to override the dependency in a screenshot test */
@@ -56,9 +58,10 @@ class MediaProjectionAppSelectorActivity(
@Inject
constructor(
activityLauncher: AsyncActivityLauncher,
activityTaskManager: IActivityTaskManager,
controller: MediaProjectionAppSelectorController,
recentTasksAdapterFactory: RecentTasksAdapter.Factory,
) : this(activityLauncher, controller, recentTasksAdapterFactory, null)
) : this(activityLauncher, activityTaskManager, controller, recentTasksAdapterFactory, null)
private var recentsRoot: ViewGroup? = null
private var recentsProgress: View? = null
@@ -176,8 +179,14 @@ class MediaProjectionAppSelectorActivity(
recycler.adapter = recentTasksAdapterFactory.create(recentTasks, this)
}
override fun onRecentClicked(task: RecentTask, view: View) {
// TODO(b/240924732) Handle clicking on a recent task
override fun onRecentAppClicked(task: RecentTask, view: View) {
val launchCookie = Binder()
val activityOptions = ActivityOptions.makeScaleUpAnimation(view, /* startX= */ 0,
/* startY= */ 0, view.width, view.height)
activityOptions.launchCookie = launchCookie
activityTaskManager.startActivityFromRecents(task.taskId, activityOptions.toBundle())
onTargetActivityLaunched(launchCookie)
}
private fun onTargetActivityLaunched(launchToken: IBinder) {

View File

@@ -43,7 +43,7 @@ class RecentTasksAdapter @AssistedInject constructor(
override fun onBindViewHolder(holder: RecentTaskViewHolder, position: Int) {
val task = items[position]
holder.bind(task, onClick = {
listener.onRecentClicked(task, holder.itemView)
listener.onRecentAppClicked(task, holder.itemView)
})
}
@@ -54,7 +54,7 @@ class RecentTasksAdapter @AssistedInject constructor(
}
interface RecentTaskClickListener {
fun onRecentClicked(task: RecentTask, view: View)
fun onRecentAppClicked(task: RecentTask, view: View)
}
@AssistedFactory