Loading core/java/com/android/internal/app/ChooserActivity.java +15 −19 Original line number Diff line number Diff line Loading @@ -162,6 +162,9 @@ public class ChooserActivity extends ResolverActivity implements private AppPredictor mWorkAppPredictor; private boolean mShouldDisplayLandscape; private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4; private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8; @UnsupportedAppUsage public ChooserActivity() { } Loading Loading @@ -905,7 +908,7 @@ public class ChooserActivity extends ResolverActivity implements adapter, getPersonalProfileUserHandle(), /* workProfileUserHandle= */ null, isSendAction(getTargetIntent())); isSendAction(getTargetIntent()), getMaxTargetsPerRow()); } private ChooserMultiProfilePagerAdapter createChooserMultiProfilePagerAdapterForTwoProfiles( Loading Loading @@ -934,7 +937,7 @@ public class ChooserActivity extends ResolverActivity implements selectedProfile, getPersonalProfileUserHandle(), getWorkProfileUserHandle(), isSendAction(getTargetIntent())); isSendAction(getTargetIntent()), getMaxTargetsPerRow()); } private int findSelectedProfile() { Loading Loading @@ -2683,7 +2686,7 @@ public class ChooserActivity extends ResolverActivity implements // and b/150936654 recyclerView.setAdapter(gridAdapter); ((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount( gridAdapter.getMaxTargetsPerRow()); getMaxTargetsPerRow()); } UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle(); Loading Loading @@ -2848,9 +2851,7 @@ public class ChooserActivity extends ResolverActivity implements @Override // ChooserListCommunicator public int getMaxRankedTargets() { return mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() == null ? ChooserGridAdapter.MAX_TARGETS_PER_ROW_PORTRAIT : mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().getMaxTargetsPerRow(); return getMaxTargetsPerRow(); } @Override // ChooserListCommunicator Loading Loading @@ -3198,6 +3199,13 @@ public class ChooserActivity extends ResolverActivity implements } } int getMaxTargetsPerRow() { int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT; if (mShouldDisplayLandscape) { maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE; } return maxTargets; } /** * 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 Loading Loading @@ -3226,9 +3234,6 @@ public class ChooserActivity extends ResolverActivity implements private static final int VIEW_TYPE_CALLER_AND_RANK = 5; private static final int VIEW_TYPE_FOOTER = 6; private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4; private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8; private static final int NUM_EXPANSIONS_TO_HIDE_AZ_LABEL = 20; ChooserGridAdapter(ChooserListAdapter wrappedAdapter) { Loading Loading @@ -3277,14 +3282,6 @@ public class ChooserActivity extends ResolverActivity implements return false; } int getMaxTargetsPerRow() { int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT; if (mShouldDisplayLandscape) { maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE; } return maxTargets; } /** * Hides the list item content preview. * <p>Not to be confused with the sticky content preview which is above the Loading Loading @@ -3654,8 +3651,7 @@ public class ChooserActivity extends ResolverActivity implements position -= getSystemRowCount() + getProfileRowCount(); final int serviceCount = mChooserListAdapter.getServiceTargetCount(); final int serviceRows = (int) Math.ceil((float) serviceCount / ChooserListAdapter.MAX_SERVICE_TARGETS); final int serviceRows = (int) Math.ceil((float) serviceCount / getMaxRankedTargets()); if (position < serviceRows) { return position * getMaxTargetsPerRow(); } Loading core/java/com/android/internal/app/ChooserListAdapter.java +6 −7 Original line number Diff line number Diff line Loading @@ -82,8 +82,6 @@ public class ChooserListAdapter extends ResolverListAdapter { private static final int MAX_SERVICE_TARGET_APP = 8; private static final int DEFAULT_DIRECT_SHARE_RANKING_SCORE = 1000; static final int MAX_SERVICE_TARGETS = 8; /** {@link #getBaseScore} */ public static final float CALLER_TARGET_SCORE_BOOST = 900.f; /** {@link #getBaseScore} */ Loading Loading @@ -130,10 +128,10 @@ public class ChooserListAdapter extends ResolverListAdapter { super(context, payloadIntents, null, rList, filterLastUsed, resolverListController, chooserListCommunicator, false); createPlaceHolders(); mMaxShortcutTargetsPerApp = context.getResources().getInteger(R.integer.config_maxShortcutTargetsPerApp); mChooserListCommunicator = chooserListCommunicator; createPlaceHolders(); mSelectableTargetInfoCommunicator = selectableTargetInfoCommunicator; if (initialIntents != null) { Loading Loading @@ -227,7 +225,7 @@ public class ChooserListAdapter extends ResolverListAdapter { mParkingDirectShareTargets.clear(); mPendingChooserTargetService.clear(); mShortcutComponents.clear(); for (int i = 0; i < MAX_SERVICE_TARGETS; i++) { for (int i = 0; i < mChooserListCommunicator.getMaxRankedTargets(); i++) { mServiceTargets.add(mPlaceHolderTargetInfo); } } Loading Loading @@ -382,7 +380,7 @@ public class ChooserListAdapter extends ResolverListAdapter { public int getServiceTargetCount() { if (mChooserListCommunicator.isSendAction(mChooserListCommunicator.getTargetIntent()) && !ActivityManager.isLowRamDeviceStatic()) { return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); return Math.min(mServiceTargets.size(), mChooserListCommunicator.getMaxRankedTargets()); } return 0; Loading Loading @@ -847,7 +845,8 @@ public class ChooserListAdapter extends ResolverListAdapter { int currentSize = mServiceTargets.size(); final float newScore = chooserTargetInfo.getModifiedScore(); for (int i = 0; i < Math.min(currentSize, MAX_SERVICE_TARGETS); i++) { for (int i = 0; i < Math.min(currentSize, mChooserListCommunicator.getMaxRankedTargets()); i++) { final ChooserTargetInfo serviceTarget = mServiceTargets.get(i); if (serviceTarget == null) { mServiceTargets.set(i, chooserTargetInfo); Loading @@ -858,7 +857,7 @@ public class ChooserListAdapter extends ResolverListAdapter { } } if (currentSize < MAX_SERVICE_TARGETS) { if (currentSize < mChooserListCommunicator.getMaxRankedTargets()) { mServiceTargets.add(chooserTargetInfo); return true; } Loading core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +6 −3 Original line number Diff line number Diff line Loading @@ -39,17 +39,19 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd private final ChooserProfileDescriptor[] mItems; private final boolean mIsSendAction; private int mBottomOffset; private int mMaxTargetsPerRow; ChooserMultiProfilePagerAdapter(Context context, ChooserActivity.ChooserGridAdapter adapter, UserHandle personalProfileUserHandle, UserHandle workProfileUserHandle, boolean isSendAction) { boolean isSendAction, int maxTargetsPerRow) { super(context, /* currentPage */ 0, personalProfileUserHandle, workProfileUserHandle); mItems = new ChooserProfileDescriptor[] { createProfileDescriptor(adapter) }; mIsSendAction = isSendAction; mMaxTargetsPerRow = maxTargetsPerRow; } ChooserMultiProfilePagerAdapter(Context context, Loading @@ -58,7 +60,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd @Profile int defaultProfile, UserHandle personalProfileUserHandle, UserHandle workProfileUserHandle, boolean isSendAction) { boolean isSendAction, int maxTargetsPerRow) { super(context, /* currentPage */ defaultProfile, personalProfileUserHandle, workProfileUserHandle); mItems = new ChooserProfileDescriptor[] { Loading @@ -66,6 +68,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd createProfileDescriptor(workAdapter) }; mIsSendAction = isSendAction; mMaxTargetsPerRow = maxTargetsPerRow; } private ChooserProfileDescriptor createProfileDescriptor( Loading Loading @@ -114,7 +117,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd ChooserActivity.ChooserGridAdapter chooserGridAdapter = getItem(pageIndex).chooserGridAdapter; GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager(); glm.setSpanCount(chooserGridAdapter.getMaxTargetsPerRow()); glm.setSpanCount(mMaxTargetsPerRow); glm.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup() { @Override Loading Loading
core/java/com/android/internal/app/ChooserActivity.java +15 −19 Original line number Diff line number Diff line Loading @@ -162,6 +162,9 @@ public class ChooserActivity extends ResolverActivity implements private AppPredictor mWorkAppPredictor; private boolean mShouldDisplayLandscape; private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4; private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8; @UnsupportedAppUsage public ChooserActivity() { } Loading Loading @@ -905,7 +908,7 @@ public class ChooserActivity extends ResolverActivity implements adapter, getPersonalProfileUserHandle(), /* workProfileUserHandle= */ null, isSendAction(getTargetIntent())); isSendAction(getTargetIntent()), getMaxTargetsPerRow()); } private ChooserMultiProfilePagerAdapter createChooserMultiProfilePagerAdapterForTwoProfiles( Loading Loading @@ -934,7 +937,7 @@ public class ChooserActivity extends ResolverActivity implements selectedProfile, getPersonalProfileUserHandle(), getWorkProfileUserHandle(), isSendAction(getTargetIntent())); isSendAction(getTargetIntent()), getMaxTargetsPerRow()); } private int findSelectedProfile() { Loading Loading @@ -2683,7 +2686,7 @@ public class ChooserActivity extends ResolverActivity implements // and b/150936654 recyclerView.setAdapter(gridAdapter); ((GridLayoutManager) recyclerView.getLayoutManager()).setSpanCount( gridAdapter.getMaxTargetsPerRow()); getMaxTargetsPerRow()); } UserHandle currentUserHandle = mChooserMultiProfilePagerAdapter.getCurrentUserHandle(); Loading Loading @@ -2848,9 +2851,7 @@ public class ChooserActivity extends ResolverActivity implements @Override // ChooserListCommunicator public int getMaxRankedTargets() { return mChooserMultiProfilePagerAdapter.getCurrentRootAdapter() == null ? ChooserGridAdapter.MAX_TARGETS_PER_ROW_PORTRAIT : mChooserMultiProfilePagerAdapter.getCurrentRootAdapter().getMaxTargetsPerRow(); return getMaxTargetsPerRow(); } @Override // ChooserListCommunicator Loading Loading @@ -3198,6 +3199,13 @@ public class ChooserActivity extends ResolverActivity implements } } int getMaxTargetsPerRow() { int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT; if (mShouldDisplayLandscape) { maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE; } return maxTargets; } /** * 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 Loading Loading @@ -3226,9 +3234,6 @@ public class ChooserActivity extends ResolverActivity implements private static final int VIEW_TYPE_CALLER_AND_RANK = 5; private static final int VIEW_TYPE_FOOTER = 6; private static final int MAX_TARGETS_PER_ROW_PORTRAIT = 4; private static final int MAX_TARGETS_PER_ROW_LANDSCAPE = 8; private static final int NUM_EXPANSIONS_TO_HIDE_AZ_LABEL = 20; ChooserGridAdapter(ChooserListAdapter wrappedAdapter) { Loading Loading @@ -3277,14 +3282,6 @@ public class ChooserActivity extends ResolverActivity implements return false; } int getMaxTargetsPerRow() { int maxTargets = MAX_TARGETS_PER_ROW_PORTRAIT; if (mShouldDisplayLandscape) { maxTargets = MAX_TARGETS_PER_ROW_LANDSCAPE; } return maxTargets; } /** * Hides the list item content preview. * <p>Not to be confused with the sticky content preview which is above the Loading Loading @@ -3654,8 +3651,7 @@ public class ChooserActivity extends ResolverActivity implements position -= getSystemRowCount() + getProfileRowCount(); final int serviceCount = mChooserListAdapter.getServiceTargetCount(); final int serviceRows = (int) Math.ceil((float) serviceCount / ChooserListAdapter.MAX_SERVICE_TARGETS); final int serviceRows = (int) Math.ceil((float) serviceCount / getMaxRankedTargets()); if (position < serviceRows) { return position * getMaxTargetsPerRow(); } Loading
core/java/com/android/internal/app/ChooserListAdapter.java +6 −7 Original line number Diff line number Diff line Loading @@ -82,8 +82,6 @@ public class ChooserListAdapter extends ResolverListAdapter { private static final int MAX_SERVICE_TARGET_APP = 8; private static final int DEFAULT_DIRECT_SHARE_RANKING_SCORE = 1000; static final int MAX_SERVICE_TARGETS = 8; /** {@link #getBaseScore} */ public static final float CALLER_TARGET_SCORE_BOOST = 900.f; /** {@link #getBaseScore} */ Loading Loading @@ -130,10 +128,10 @@ public class ChooserListAdapter extends ResolverListAdapter { super(context, payloadIntents, null, rList, filterLastUsed, resolverListController, chooserListCommunicator, false); createPlaceHolders(); mMaxShortcutTargetsPerApp = context.getResources().getInteger(R.integer.config_maxShortcutTargetsPerApp); mChooserListCommunicator = chooserListCommunicator; createPlaceHolders(); mSelectableTargetInfoCommunicator = selectableTargetInfoCommunicator; if (initialIntents != null) { Loading Loading @@ -227,7 +225,7 @@ public class ChooserListAdapter extends ResolverListAdapter { mParkingDirectShareTargets.clear(); mPendingChooserTargetService.clear(); mShortcutComponents.clear(); for (int i = 0; i < MAX_SERVICE_TARGETS; i++) { for (int i = 0; i < mChooserListCommunicator.getMaxRankedTargets(); i++) { mServiceTargets.add(mPlaceHolderTargetInfo); } } Loading Loading @@ -382,7 +380,7 @@ public class ChooserListAdapter extends ResolverListAdapter { public int getServiceTargetCount() { if (mChooserListCommunicator.isSendAction(mChooserListCommunicator.getTargetIntent()) && !ActivityManager.isLowRamDeviceStatic()) { return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); return Math.min(mServiceTargets.size(), mChooserListCommunicator.getMaxRankedTargets()); } return 0; Loading Loading @@ -847,7 +845,8 @@ public class ChooserListAdapter extends ResolverListAdapter { int currentSize = mServiceTargets.size(); final float newScore = chooserTargetInfo.getModifiedScore(); for (int i = 0; i < Math.min(currentSize, MAX_SERVICE_TARGETS); i++) { for (int i = 0; i < Math.min(currentSize, mChooserListCommunicator.getMaxRankedTargets()); i++) { final ChooserTargetInfo serviceTarget = mServiceTargets.get(i); if (serviceTarget == null) { mServiceTargets.set(i, chooserTargetInfo); Loading @@ -858,7 +857,7 @@ public class ChooserListAdapter extends ResolverListAdapter { } } if (currentSize < MAX_SERVICE_TARGETS) { if (currentSize < mChooserListCommunicator.getMaxRankedTargets()) { mServiceTargets.add(chooserTargetInfo); return true; } Loading
core/java/com/android/internal/app/ChooserMultiProfilePagerAdapter.java +6 −3 Original line number Diff line number Diff line Loading @@ -39,17 +39,19 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd private final ChooserProfileDescriptor[] mItems; private final boolean mIsSendAction; private int mBottomOffset; private int mMaxTargetsPerRow; ChooserMultiProfilePagerAdapter(Context context, ChooserActivity.ChooserGridAdapter adapter, UserHandle personalProfileUserHandle, UserHandle workProfileUserHandle, boolean isSendAction) { boolean isSendAction, int maxTargetsPerRow) { super(context, /* currentPage */ 0, personalProfileUserHandle, workProfileUserHandle); mItems = new ChooserProfileDescriptor[] { createProfileDescriptor(adapter) }; mIsSendAction = isSendAction; mMaxTargetsPerRow = maxTargetsPerRow; } ChooserMultiProfilePagerAdapter(Context context, Loading @@ -58,7 +60,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd @Profile int defaultProfile, UserHandle personalProfileUserHandle, UserHandle workProfileUserHandle, boolean isSendAction) { boolean isSendAction, int maxTargetsPerRow) { super(context, /* currentPage */ defaultProfile, personalProfileUserHandle, workProfileUserHandle); mItems = new ChooserProfileDescriptor[] { Loading @@ -66,6 +68,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd createProfileDescriptor(workAdapter) }; mIsSendAction = isSendAction; mMaxTargetsPerRow = maxTargetsPerRow; } private ChooserProfileDescriptor createProfileDescriptor( Loading Loading @@ -114,7 +117,7 @@ public class ChooserMultiProfilePagerAdapter extends AbstractMultiProfilePagerAd ChooserActivity.ChooserGridAdapter chooserGridAdapter = getItem(pageIndex).chooserGridAdapter; GridLayoutManager glm = (GridLayoutManager) recyclerView.getLayoutManager(); glm.setSpanCount(chooserGridAdapter.getMaxTargetsPerRow()); glm.setSpanCount(mMaxTargetsPerRow); glm.setSpanSizeLookup( new GridLayoutManager.SpanSizeLookup() { @Override Loading