Loading core/java/com/android/internal/app/ChooserListAdapter.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -181,6 +181,7 @@ public class ChooserListAdapter extends ResolverListAdapter { ri.icon = 0; ri.icon = 0; } } mCallerTargets.add(new DisplayResolveInfo(ii, ri, ii, makePresentationGetter(ri))); mCallerTargets.add(new DisplayResolveInfo(ii, ri, ii, makePresentationGetter(ri))); if (mCallerTargets.size() == MAX_SUGGESTED_APP_TARGETS) break; } } } } } } Loading Loading @@ -320,7 +321,7 @@ public class ChooserListAdapter extends ResolverListAdapter { public int getCallerTargetCount() { public int getCallerTargetCount() { return Math.min(mCallerTargets.size(), MAX_SUGGESTED_APP_TARGETS); return mCallerTargets.size(); } } /** /** Loading @@ -346,8 +347,9 @@ public class ChooserListAdapter extends ResolverListAdapter { } } int getAlphaTargetCount() { int getAlphaTargetCount() { int standardCount = mSortedList.size(); int groupedCount = mSortedList.size(); return standardCount > mChooserListCommunicator.getMaxRankedTargets() ? standardCount : 0; int ungroupedCount = mCallerTargets.size() + mDisplayList.size(); return ungroupedCount > mChooserListCommunicator.getMaxRankedTargets() ? groupedCount : 0; } } /** /** Loading core/java/com/android/internal/app/ResolverListAdapter.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -617,7 +617,8 @@ public class ResolverListAdapter extends BaseAdapter { } } } } UserHandle getUserHandle() { @VisibleForTesting public UserHandle getUserHandle() { return mResolverListController.getUserHandle(); return mResolverListController.getUserHandle(); } } Loading core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.swipeUp; import static androidx.test.espresso.action.ViewActions.swipeUp; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.hasSibling; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static androidx.test.espresso.matcher.ViewMatchers.withText; Loading Loading @@ -299,9 +300,8 @@ public class ChooserActivityTest { public void fourOptionsStackedIntoOneTarget() throws InterruptedException { public void fourOptionsStackedIntoOneTarget() throws InterruptedException { Intent sendIntent = createSendTextIntent(); Intent sendIntent = createSendTextIntent(); // create 12 unique app targets to ensure the app ranking row can be filled, otherwise // create just enough targets to ensure the a-z list should be shown // targets will not stack List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(1); List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(12); // next create 4 targets in a single app that should be stacked into a single target // next create 4 targets in a single app that should be stacked into a single target String packageName = "xxx.yyy"; String packageName = "xxx.yyy"; Loading @@ -328,8 +328,8 @@ public class ChooserActivityTest { .launchActivity(Intent.createChooser(sendIntent, null)); .launchActivity(Intent.createChooser(sendIntent, null)); waitForIdle(); waitForIdle(); // expect 12 unique targets + 1 group + 4 ranked app targets // expect 1 unique targets + 1 group + 4 ranked app targets assertThat(activity.getAdapter().getCount(), is(17)); assertThat(activity.getAdapter().getCount(), is(6)); ResolveInfo[] chosen = new ResolveInfo[1]; ResolveInfo[] chosen = new ResolveInfo[1]; sOverrides.onSafelyStartCallback = targetInfo -> { sOverrides.onSafelyStartCallback = targetInfo -> { Loading @@ -337,7 +337,7 @@ public class ChooserActivityTest { return true; return true; }; }; onView(withText(appName)).perform(click()); onView(allOf(withText(appName), hasSibling(withText("")))).perform(click()); waitForIdle(); waitForIdle(); // clicking will launch a dialog to choose the activity within the app // clicking will launch a dialog to choose the activity within the app Loading Loading
core/java/com/android/internal/app/ChooserListAdapter.java +5 −3 Original line number Original line Diff line number Diff line Loading @@ -181,6 +181,7 @@ public class ChooserListAdapter extends ResolverListAdapter { ri.icon = 0; ri.icon = 0; } } mCallerTargets.add(new DisplayResolveInfo(ii, ri, ii, makePresentationGetter(ri))); mCallerTargets.add(new DisplayResolveInfo(ii, ri, ii, makePresentationGetter(ri))); if (mCallerTargets.size() == MAX_SUGGESTED_APP_TARGETS) break; } } } } } } Loading Loading @@ -320,7 +321,7 @@ public class ChooserListAdapter extends ResolverListAdapter { public int getCallerTargetCount() { public int getCallerTargetCount() { return Math.min(mCallerTargets.size(), MAX_SUGGESTED_APP_TARGETS); return mCallerTargets.size(); } } /** /** Loading @@ -346,8 +347,9 @@ public class ChooserListAdapter extends ResolverListAdapter { } } int getAlphaTargetCount() { int getAlphaTargetCount() { int standardCount = mSortedList.size(); int groupedCount = mSortedList.size(); return standardCount > mChooserListCommunicator.getMaxRankedTargets() ? standardCount : 0; int ungroupedCount = mCallerTargets.size() + mDisplayList.size(); return ungroupedCount > mChooserListCommunicator.getMaxRankedTargets() ? groupedCount : 0; } } /** /** Loading
core/java/com/android/internal/app/ResolverListAdapter.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -617,7 +617,8 @@ public class ResolverListAdapter extends BaseAdapter { } } } } UserHandle getUserHandle() { @VisibleForTesting public UserHandle getUserHandle() { return mResolverListController.getUserHandle(); return mResolverListController.getUserHandle(); } } Loading
core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.swipeUp; import static androidx.test.espresso.action.ViewActions.swipeUp; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.ViewMatchers.hasSibling; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.espresso.matcher.ViewMatchers.withText; import static androidx.test.espresso.matcher.ViewMatchers.withText; Loading Loading @@ -299,9 +300,8 @@ public class ChooserActivityTest { public void fourOptionsStackedIntoOneTarget() throws InterruptedException { public void fourOptionsStackedIntoOneTarget() throws InterruptedException { Intent sendIntent = createSendTextIntent(); Intent sendIntent = createSendTextIntent(); // create 12 unique app targets to ensure the app ranking row can be filled, otherwise // create just enough targets to ensure the a-z list should be shown // targets will not stack List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(1); List<ResolvedComponentInfo> resolvedComponentInfos = createResolvedComponentsForTest(12); // next create 4 targets in a single app that should be stacked into a single target // next create 4 targets in a single app that should be stacked into a single target String packageName = "xxx.yyy"; String packageName = "xxx.yyy"; Loading @@ -328,8 +328,8 @@ public class ChooserActivityTest { .launchActivity(Intent.createChooser(sendIntent, null)); .launchActivity(Intent.createChooser(sendIntent, null)); waitForIdle(); waitForIdle(); // expect 12 unique targets + 1 group + 4 ranked app targets // expect 1 unique targets + 1 group + 4 ranked app targets assertThat(activity.getAdapter().getCount(), is(17)); assertThat(activity.getAdapter().getCount(), is(6)); ResolveInfo[] chosen = new ResolveInfo[1]; ResolveInfo[] chosen = new ResolveInfo[1]; sOverrides.onSafelyStartCallback = targetInfo -> { sOverrides.onSafelyStartCallback = targetInfo -> { Loading @@ -337,7 +337,7 @@ public class ChooserActivityTest { return true; return true; }; }; onView(withText(appName)).perform(click()); onView(allOf(withText(appName), hasSibling(withText("")))).perform(click()); waitForIdle(); waitForIdle(); // clicking will launch a dialog to choose the activity within the app // clicking will launch a dialog to choose the activity within the app Loading