diff --git a/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java b/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java index d50826f815a0b..fa567f235c945 100644 --- a/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java +++ b/core/java/com/android/internal/app/AbstractMultiProfilePagerAdapter.java @@ -452,7 +452,7 @@ public abstract class AbstractMultiProfilePagerAdapter extends PagerAdapter { mEmptyStateView = rootView.findViewById(R.id.resolver_empty_state); } - private ViewGroup getEmptyStateView() { + protected ViewGroup getEmptyStateView() { return mEmptyStateView; } } diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index c099301d20432..5620bff5142bc 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -2411,6 +2411,8 @@ public class ChooserActivity extends ResolverActivity implements mChooserMultiProfilePagerAdapter.getActiveAdapterView() .setAdapter(mChooserMultiProfilePagerAdapter.getCurrentRootAdapter()); return; + } else if (mChooserMultiProfilePagerAdapter.getCurrentUserHandle() != getUser()) { + return; } getMainThreadHandler().post(() -> { @@ -2455,39 +2457,46 @@ public class ChooserActivity extends ResolverActivity implements offset += tabDivider.getHeight(); } - int directShareHeight = 0; - rowsToShow = Math.min(4, rowsToShow); - mLastNumberOfChildren = recyclerView.getChildCount(); - for (int i = 0, childCount = recyclerView.getChildCount(); - i < childCount && rowsToShow > 0; i++) { - View child = recyclerView.getChildAt(i); - if (((GridLayoutManager.LayoutParams) - child.getLayoutParams()).getSpanIndex() != 0) { - continue; + if (recyclerView.getVisibility() == View.VISIBLE) { + int directShareHeight = 0; + rowsToShow = Math.min(4, rowsToShow); + mLastNumberOfChildren = recyclerView.getChildCount(); + for (int i = 0, childCount = recyclerView.getChildCount(); + i < childCount && rowsToShow > 0; i++) { + View child = recyclerView.getChildAt(i); + if (((GridLayoutManager.LayoutParams) + child.getLayoutParams()).getSpanIndex() != 0) { + continue; + } + int height = child.getHeight(); + offset += height; + + if (gridAdapter.getTargetType( + recyclerView.getChildAdapterPosition(child)) + == ChooserListAdapter.TARGET_SERVICE) { + directShareHeight = height; + } + rowsToShow--; } - int height = child.getHeight(); - offset += height; - if (gridAdapter.getTargetType( - recyclerView.getChildAdapterPosition(child)) - == ChooserListAdapter.TARGET_SERVICE) { - directShareHeight = height; + boolean isExpandable = getResources().getConfiguration().orientation + == Configuration.ORIENTATION_PORTRAIT && !isInMultiWindowMode(); + if (directShareHeight != 0 && isSendAction(getTargetIntent()) + && isExpandable) { + // make sure to leave room for direct share 4->8 expansion + int requiredExpansionHeight = + (int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE); + int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0; + int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight() + - requiredExpansionHeight - topInset - bottomInset; + + offset = Math.min(offset, minHeight); + } + } else { + ViewGroup currentEmptyStateView = getCurrentEmptyStateView(); + if (currentEmptyStateView.getVisibility() == View.VISIBLE) { + offset += currentEmptyStateView.getHeight(); } - rowsToShow--; - } - - boolean isExpandable = getResources().getConfiguration().orientation - == Configuration.ORIENTATION_PORTRAIT && !isInMultiWindowMode(); - if (directShareHeight != 0 && isSendAction(getTargetIntent()) - && isExpandable) { - // make sure to leave room for direct share 4->8 expansion - int requiredExpansionHeight = - (int) (directShareHeight / DIRECT_SHARE_EXPANSION_RATE); - int topInset = mSystemWindowInsets != null ? mSystemWindowInsets.top : 0; - int minHeight = bottom - top - mResolverDrawerLayout.getAlwaysShowHeight() - - requiredExpansionHeight - topInset - bottomInset; - - offset = Math.min(offset, minHeight); } mResolverDrawerLayout.setCollapsibleHeightReserved(Math.min(offset, bottom - top)); @@ -2495,6 +2504,11 @@ public class ChooserActivity extends ResolverActivity implements } } + private ViewGroup getCurrentEmptyStateView() { + int currentPage = mChooserMultiProfilePagerAdapter.getCurrentPage(); + return mChooserMultiProfilePagerAdapter.getItem(currentPage).getEmptyStateView(); + } + static class BaseChooserTargetComparator implements Comparator { @Override public int compare(ChooserTarget lhs, ChooserTarget rhs) {