diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/app/ChooserActivity.java | 15 | ||||
| -rw-r--r-- | core/java/com/android/internal/app/ResolverActivity.java | 20 |
2 files changed, 19 insertions, 16 deletions
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index dc801a996dbb..8618bcfc3932 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -373,7 +373,7 @@ public class ChooserActivity extends ResolverActivity implements Log.i(TAG, "Hiding image preview area. Timed out waiting for preview to load" + " within " + mImageLoadTimeoutMillis + "ms."); collapseParentView(); - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { hideStickyContentPreview(); } else if (mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() != null) { mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().hideContentPreview(); @@ -773,7 +773,7 @@ public class ChooserActivity extends ResolverActivity implements Intent[] initialIntents, List<ResolveInfo> rList, boolean filterLastUsed) { - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { mChooserMultiProfilePagerAdapter = createChooserMultiProfilePagerAdapterForTwoProfiles( initialIntents, rList, filterLastUsed); } else { @@ -2434,7 +2434,7 @@ public class ChooserActivity extends ResolverActivity implements offset += findViewById(R.id.content_preview_container).getHeight(); } - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { offset += findViewById(R.id.tabs).getHeight(); } @@ -2562,7 +2562,7 @@ public class ChooserActivity extends ResolverActivity implements } private void setupScrollListener() { - if (mResolverDrawerLayout == null || (hasWorkProfile() && ENABLE_TABBED_VIEW)) { + if (mResolverDrawerLayout == null || shouldShowTabs()) { return; } final View chooserHeader = mResolverDrawerLayout.findViewById(R.id.chooser_header); @@ -2613,8 +2613,7 @@ public class ChooserActivity extends ResolverActivity implements * we instead show the content preview as a regular list item. */ private boolean shouldShowStickyContentPreview() { - return hasWorkProfile() - && ENABLE_TABBED_VIEW + return shouldShowTabs() && mMultiProfilePagerAdapter.getListAdapterForUserHandle( UserHandle.of(UserHandle.myUserId())).getCount() > 0 && isSendAction(getTargetIntent()) @@ -2824,7 +2823,7 @@ public class ChooserActivity extends ResolverActivity implements public int getContentPreviewRowCount() { // For the tabbed case we show the sticky content preview above the tabs, // please refer to shouldShowStickyContentPreview - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { return 0; } if (!isSendAction(getTargetIntent())) { @@ -2840,7 +2839,7 @@ public class ChooserActivity extends ResolverActivity implements } public int getProfileRowCount() { - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { return 0; } return mChooserListAdapter.getOtherProfile() == null ? 0 : 1; diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index 5dc8b0b2b21d..f07377b41002 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -362,7 +362,7 @@ public class ResolverActivity extends Activity implements mMultiProfilePagerAdapter.getPersonalListAdapter()); mPersonalPackageMonitor.register( this, getMainLooper(), getPersonalProfileUserHandle(), false); - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { mWorkPackageMonitor = createPackageMonitor( mMultiProfilePagerAdapter.getWorkListAdapter()); mWorkPackageMonitor.register(this, getMainLooper(), getWorkProfileUserHandle(), false); @@ -390,7 +390,7 @@ public class ResolverActivity extends Activity implements | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); rdl.setOnApplyWindowInsetsListener(this::onApplyWindowInsets); - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { rdl.setMaxCollapsedHeight(getResources().getDimensionPixelSize( R.dimen.resolver_empty_state_height_with_tabs)); findViewById(R.id.profile_pager).setMinimumHeight( @@ -419,7 +419,7 @@ public class ResolverActivity extends Activity implements List<ResolveInfo> rList, boolean filterLastUsed) { AbstractMultiProfilePagerAdapter resolverMultiProfilePagerAdapter = null; - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { resolverMultiProfilePagerAdapter = createResolverMultiProfilePagerAdapterForTwoProfiles( initialIntents, rList, filterLastUsed); @@ -500,10 +500,14 @@ public class ResolverActivity extends Activity implements return null; } - protected boolean hasWorkProfile() { + private boolean hasWorkProfile() { return getWorkProfileUserHandle() != null; } + protected boolean shouldShowTabs() { + return hasWorkProfile() && ENABLE_TABBED_VIEW; + } + protected void onProfileClick(View v) { final DisplayResolveInfo dri = mMultiProfilePagerAdapter.getActiveListAdapter().getOtherProfile(); @@ -728,7 +732,7 @@ public class ResolverActivity extends Activity implements if (!mRegistered) { mPersonalPackageMonitor.register(this, getMainLooper(), getPersonalProfileUserHandle(), false); - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { if (mWorkPackageMonitor == null) { mWorkPackageMonitor = createPackageMonitor( mMultiProfilePagerAdapter.getWorkListAdapter()); @@ -745,7 +749,7 @@ public class ResolverActivity extends Activity implements @Override protected void onStart() { super.onStart(); - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { mWorkProfileStateReceiver = createWorkProfileStateReceiver(); registerWorkProfileStateReceiver(); } @@ -1343,7 +1347,7 @@ public class ResolverActivity extends Activity implements setupViewVisibilities(); - if (hasWorkProfile() && ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { setupProfileTabs(); } @@ -1562,7 +1566,7 @@ public class ResolverActivity extends Activity implements stub.setVisibility(View.VISIBLE); TextView textView = (TextView) LayoutInflater.from(this).inflate( R.layout.resolver_different_item_header, null, false); - if (ENABLE_TABBED_VIEW) { + if (shouldShowTabs()) { textView.setGravity(Gravity.CENTER); } stub.addView(textView); |
