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

Commit 60c56f40 authored by Chris Göllner's avatar Chris Göllner Committed by Automerger Merge Worker
Browse files

Merge "Fix PSS app chooser looking empty with no recent apps and work profile"...

Merge "Fix PSS app chooser looking empty with no recent apps and work profile" into udc-qpr-dev am: a41d6096

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24526908



Change-Id: I30ac39bcd8112e331ec650a04a9061dd8dab8446
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents b79e3662 a41d6096
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -206,6 +206,11 @@ class MediaProjectionAppSelectorActivity(

    override fun bind(recentTasks: List<RecentTask>) {
        recentsViewController.bind(recentTasks)
        if (!hasWorkProfile()) {
            // Make sure to refresh the adapter, to show/hide the recents view depending on whether
            // there are recents or not.
            mMultiProfilePagerAdapter.personalListAdapter.notifyDataSetChanged()
        }
    }

    override fun returnSelectedApp(launchCookie: IBinder) {
@@ -248,9 +253,20 @@ class MediaProjectionAppSelectorActivity(

    override fun shouldGetOnlyDefaultActivities() = false

    override fun shouldShowContentPreview() = true
    override fun shouldShowContentPreview() =
        if (hasWorkProfile()) {
            // When the user has a work profile, we can always set this to true, and the layout is
            // adjusted automatically, and hide the recents view.
            true
        } else {
            // When there is no work profile, we should only show the content preview if there are
            // recents, otherwise the collapsed app selector will look empty.
            recentsViewController.hasRecentTasks
        }

    override fun shouldShowContentPreviewWhenEmpty() = shouldShowContentPreview()

    override fun shouldShowContentPreviewWhenEmpty(): Boolean = true
    private fun hasWorkProfile() = mMultiProfilePagerAdapter.count > 1

    override fun createMyUserIdProvider(): MyUserIdProvider =
        object : MyUserIdProvider() {
+14 −7
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@ import com.android.systemui.util.recycler.HorizontalSpacerItemDecoration
import javax.inject.Inject

/**
 * Controller that handles view of the recent apps selector in the media projection activity.
 * It is responsible for creating and updating recent apps view.
 * Controller that handles view of the recent apps selector in the media projection activity. It is
 * responsible for creating and updating recent apps view.
 */
@MediaProjectionAppSelectorScope
class MediaProjectionRecentsViewController
@@ -51,15 +51,21 @@ constructor(
    private var views: Views? = null
    private var lastBoundData: List<RecentTask>? = null

    val hasRecentTasks: Boolean
        get() = lastBoundData?.isNotEmpty() ?: false

    init {
        taskViewSizeProvider.addCallback(this)
    }

    fun createView(parent: ViewGroup): ViewGroup =
        views?.root ?: createRecentViews(parent).also {
        views?.root
            ?: createRecentViews(parent)
                .also {
                    views = it
                    lastBoundData?.let { recents -> bind(recents) }
        }.root
                }
                .root

    fun bind(recentTasks: List<RecentTask>) {
        views?.apply {
@@ -88,7 +94,8 @@ constructor(
                .inflate(R.layout.media_projection_recent_tasks, parent, /* attachToRoot= */ false)
                as ViewGroup

        val container = recentsRoot.requireViewById<View>(R.id.media_projection_recent_tasks_container)
        val container =
            recentsRoot.requireViewById<View>(R.id.media_projection_recent_tasks_container)
        container.setTaskHeightSize()

        val progress = recentsRoot.requireViewById<View>(R.id.media_projection_recent_tasks_loader)