diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java index 970bab9bc53b4..2fc75a7aa1a2e 100644 --- a/core/java/com/android/internal/app/ChooserActivity.java +++ b/core/java/com/android/internal/app/ChooserActivity.java @@ -2885,6 +2885,13 @@ public class ChooserActivity extends ResolverActivity implements return METRICS_CATEGORY_CHOOSER; } + @Override + protected void onProfileTabSelected() { + ChooserGridAdapter currentRootAdapter = + mChooserMultiProfilePagerAdapter.getCurrentRootAdapter(); + currentRootAdapter.updateDirectShareExpansion(); + } + /** * Adapter for all types of items and targets in ShareSheet. * Note that ranked sections like Direct Share - while appearing grid-like - are handled on the @@ -3357,15 +3364,7 @@ public class ChooserActivity extends ResolverActivity implements } public void handleScroll(View v, int y, int oldy) { - // Only expand direct share area if there is a minimum number of shortcuts, - // which will help reduce the amount of visible shuffling due to older-style - // direct share targets. - int orientation = getResources().getConfiguration().orientation; - boolean canExpandDirectShare = - mChooserListAdapter.getNumShortcutResults() > getMaxTargetsPerRow() - && orientation == Configuration.ORIENTATION_PORTRAIT - && !isInMultiWindowMode(); - + boolean canExpandDirectShare = canExpandDirectShare(); if (mDirectShareViewHolder != null && canExpandDirectShare) { mDirectShareViewHolder.handleScroll( mChooserMultiProfilePagerAdapter.getActiveAdapterView(), y, oldy, @@ -3373,6 +3372,18 @@ public class ChooserActivity extends ResolverActivity implements } } + /** + * Only expand direct share area if there is a minimum number of shortcuts, + * which will help reduce the amount of visible shuffling due to older-style + * direct share targets. + */ + private boolean canExpandDirectShare() { + int orientation = getResources().getConfiguration().orientation; + return mChooserListAdapter.getNumShortcutResults() > getMaxTargetsPerRow() + && orientation == Configuration.ORIENTATION_PORTRAIT + && !isInMultiWindowMode(); + } + public ChooserListAdapter getListAdapter() { return mChooserListAdapter; } @@ -3380,6 +3391,19 @@ public class ChooserActivity extends ResolverActivity implements boolean shouldCellSpan(int position) { return getItemViewType(position) == VIEW_TYPE_NORMAL; } + + void updateDirectShareExpansion() { + if (mDirectShareViewHolder == null || !canExpandDirectShare()) { + return; + } + RecyclerView activeAdapterView = + mChooserMultiProfilePagerAdapter.getActiveAdapterView(); + if (mResolverDrawerLayout.isCollapsed()) { + mDirectShareViewHolder.collapse(activeAdapterView); + } else { + mDirectShareViewHolder.expand(activeAdapterView); + } + } } /** @@ -3577,6 +3601,20 @@ public class ChooserActivity extends ResolverActivity implements newHeight = Math.max(newHeight, mDirectShareMinHeight); yDiff = newHeight - prevHeight; + updateDirectShareRowHeight(view, yDiff, newHeight); + } + + void expand(RecyclerView view) { + updateDirectShareRowHeight(view, mDirectShareMaxHeight - mDirectShareCurrHeight, + mDirectShareMaxHeight); + } + + void collapse(RecyclerView view) { + updateDirectShareRowHeight(view, mDirectShareMinHeight - mDirectShareCurrHeight, + mDirectShareMinHeight); + } + + private void updateDirectShareRowHeight(RecyclerView view, int yDiff, int newHeight) { if (view == null || view.getChildCount() == 0 || yDiff == 0) { return; } diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java index e20e99bd6245b..00faa3b3d21eb 100644 --- a/core/java/com/android/internal/app/ResolverActivity.java +++ b/core/java/com/android/internal/app/ResolverActivity.java @@ -1622,6 +1622,7 @@ public class ResolverActivity extends Activity implements } setupViewVisibilities(); maybeLogProfileChange(); + onProfileTabSelected(); DevicePolicyEventLogger .createEvent(DevicePolicyEnums.RESOLVER_SWITCH_TABS) .setInt(viewPager.getCurrentItem()) @@ -1640,6 +1641,12 @@ public class ResolverActivity extends Activity implements findViewById(R.id.resolver_tab_divider).setVisibility(View.VISIBLE); } + /** + * Callback called when user changes the profile tab. + *
This method is intended to be overridden by subclasses. + */ + protected void onProfileTabSelected() { } + private void resetCheckedItem() { if (!isIntentPicker()) { return;