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

Commit e05582c4 authored by Chris Göllner's avatar Chris Göllner Committed by Chris Göllner
Browse files

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

When there is no work profile and no recent apps, and the app selector
is collapsed, the recents view is visible, but with no recent app
shown, making the chooser look empty.

Fixes: 285109109
Test: atest SystemUIGoogleScreenshotTests:MediaProjectionAppSelectorScreenshotTest
Change-Id: If9c0707e5a95153c72eb45cc935c9277e12ca27f
parent 8ecd6992
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)