Disable tabbed view support for UsbResolverActivity.

UsbResolverActivity extends ResolverActivity, but it should never
show a tabbed view if there is a work profile on the device.

Test: none
Fixes: 149749166
Change-Id: I4ea713a32d4b85820e42b4e3ab60c9da54814fdc
This commit is contained in:
arangelov
2020-02-18 17:18:47 +00:00
parent b55d7214b0
commit f163a88595
3 changed files with 24 additions and 16 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -190,4 +190,9 @@ public class UsbResolverActivity extends ResolverActivity {
}
return true;
}
@Override
protected boolean shouldShowTabs() {
return false;
}
}