From 8edfdb2a8ea1b1a92bd002ed7aa758b53113465d Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Fri, 6 Jan 2023 11:29:32 +0000 Subject: [Chooser/ResolverActivity] Add option to show preview area even if there are no apps in the tab Add a protected method that could be overriden to change the default behavior that hides the content preview area when there are not items for the current user. This is needed for the partial screen sharing feature as we want to show the recents app selector no matter if we have apps available for the current profile or not. Recent app selector is displayed in content preview area. Test: atest com.android.intentresolver.UnbundledChooserActivityWorkProfileTest Bug: 233348916 Change-Id: I0fa8da2dd4a690f5be1741d0936f776a3374aee7 --- java/src/com/android/intentresolver/ChooserActivity.java | 14 +++++++++++++- java/src/com/android/intentresolver/ResolverActivity.java | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'java') diff --git a/java/src/com/android/intentresolver/ChooserActivity.java b/java/src/com/android/intentresolver/ChooserActivity.java index ceab62b2..a3de9d31 100644 --- a/java/src/com/android/intentresolver/ChooserActivity.java +++ b/java/src/com/android/intentresolver/ChooserActivity.java @@ -1946,11 +1946,23 @@ public class ChooserActivity extends ResolverActivity implements private boolean shouldShowStickyContentPreviewNoOrientationCheck() { return shouldShowTabs() - && mMultiProfilePagerAdapter.getListAdapterForUserHandle( + && (mMultiProfilePagerAdapter.getListAdapterForUserHandle( UserHandle.of(UserHandle.myUserId())).getCount() > 0 + || shouldShowContentPreviewWhenEmpty()) && shouldShowContentPreview(); } + /** + * This method could be used to override the default behavior when we hide the preview area + * when the current tab doesn't have any items. + * + * @return true if we want to show the content preview area even if the tab for the current + * user is empty + */ + protected boolean shouldShowContentPreviewWhenEmpty() { + return false; + } + /** * @return true if we want to show the content preview area */ diff --git a/java/src/com/android/intentresolver/ResolverActivity.java b/java/src/com/android/intentresolver/ResolverActivity.java index 5573e18a..5f8f3da8 100644 --- a/java/src/com/android/intentresolver/ResolverActivity.java +++ b/java/src/com/android/intentresolver/ResolverActivity.java @@ -202,7 +202,7 @@ public class ResolverActivity extends FragmentActivity implements *

Can only be used if there is a work profile. *

Possible values can be either {@link #PROFILE_PERSONAL} or {@link #PROFILE_WORK}. */ - static final String EXTRA_SELECTED_PROFILE = + protected static final String EXTRA_SELECTED_PROFILE = "com.android.internal.app.ResolverActivity.EXTRA_SELECTED_PROFILE"; /** @@ -217,8 +217,8 @@ public class ResolverActivity extends FragmentActivity implements static final String EXTRA_CALLING_USER = "com.android.internal.app.ResolverActivity.EXTRA_CALLING_USER"; - static final int PROFILE_PERSONAL = AbstractMultiProfilePagerAdapter.PROFILE_PERSONAL; - static final int PROFILE_WORK = AbstractMultiProfilePagerAdapter.PROFILE_WORK; + protected static final int PROFILE_PERSONAL = AbstractMultiProfilePagerAdapter.PROFILE_PERSONAL; + protected static final int PROFILE_WORK = AbstractMultiProfilePagerAdapter.PROFILE_WORK; private BroadcastReceiver mWorkProfileStateReceiver; private UserHandle mHeaderCreatorUser; -- cgit v1.2.3-59-g8ed1b