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

Commit 9bd931c3 authored by Nick Chameyev's avatar Nick Chameyev
Browse files

[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
parent d639c8ee
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -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) {
+2 −2
Original line number Diff line number Diff line
@@ -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