Loading core/java/com/android/internal/app/ChooserActivity.java +31 −16 Original line number Original line Diff line number Diff line Loading @@ -318,9 +318,7 @@ public class ChooserActivity extends ResolverActivity { // Do not allow the title to be changed when sharing content // Do not allow the title to be changed when sharing content CharSequence title = null; CharSequence title = null; if (target != null) { if (target != null) { String targetAction = target.getAction(); if (!isSendAction(target)) { if (!(Intent.ACTION_SEND.equals(targetAction) || Intent.ACTION_SEND_MULTIPLE.equals( targetAction))) { title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE); title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE); } else { } else { Log.w(TAG, "Ignoring intent's EXTRA_TITLE, deprecated in P. You may wish to set a" Log.w(TAG, "Ignoring intent's EXTRA_TITLE, deprecated in P. You may wish to set a" Loading Loading @@ -444,7 +442,7 @@ public class ChooserActivity extends ResolverActivity { .getDimensionPixelSize(R.dimen.chooser_service_spacing); .getDimensionPixelSize(R.dimen.chooser_service_spacing); // expand/shrink direct share 4 -> 8 viewgroup // expand/shrink direct share 4 -> 8 viewgroup if (mResolverDrawerLayout != null) { if (mResolverDrawerLayout != null && isSendAction(target)) { mResolverDrawerLayout.setOnScrollChangeListener(this::handleScroll); mResolverDrawerLayout.setOnScrollChangeListener(this::handleScroll); } } Loading @@ -470,13 +468,8 @@ public class ChooserActivity extends ResolverActivity { public void setHeader() { public void setHeader() { super.setHeader(); super.setHeader(); Intent targetIntent = getTargetIntent(); final Intent targetIntent = getTargetIntent(); if (targetIntent == null) { if (!isSendAction(targetIntent)) { return; } String action = targetIntent.getAction(); if (!(Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action))) { return; return; } } Loading Loading @@ -943,9 +936,7 @@ public class ChooserActivity extends ResolverActivity { } } private void modifyTargetIntent(Intent in) { private void modifyTargetIntent(Intent in) { final String action = in.getAction(); if (isSendAction(in)) { if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { in.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | in.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } } Loading Loading @@ -1939,9 +1930,13 @@ public class ChooserActivity extends ResolverActivity { } } public int getServiceTargetCount() { public int getServiceTargetCount() { if (isSendAction(getTargetIntent())) { return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); } } return 0; } public int getStandardTargetCount() { public int getStandardTargetCount() { return super.getCount(); return super.getCount(); } } Loading Loading @@ -2088,6 +2083,23 @@ public class ChooserActivity extends ResolverActivity { } } } } private boolean isSendAction(Intent targetIntent) { if (targetIntent == null) { return false; } String action = targetIntent.getAction(); if (action == null) { return false; } if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { return true; } return false; } class ChooserRowAdapter extends BaseAdapter { class ChooserRowAdapter extends BaseAdapter { private ChooserListAdapter mChooserListAdapter; private ChooserListAdapter mChooserListAdapter; private final LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater; Loading Loading @@ -2141,8 +2153,11 @@ public class ChooserActivity extends ResolverActivity { // There can be at most one row in the listview, that is internally // There can be at most one row in the listview, that is internally // a ViewGroup with 2 rows // a ViewGroup with 2 rows public int getServiceTargetRowCount() { public int getServiceTargetRowCount() { if (isSendAction(getTargetIntent())) { return 1; return 1; } } return 0; } @Override @Override public Object getItem(int position) { public Object getItem(int position) { Loading core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -97,9 +97,12 @@ public class ChooserActivityTest { when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(), when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); mActivityRule.launchActivity(Intent.createChooser(viewIntent, "chooser test")); final ChooserWrapperActivity activity = mActivityRule.launchActivity( Intent.createChooser(viewIntent, "chooser test")); waitForIdle(); waitForIdle(); assertThat(activity.getAdapter().getCount(), is(2)); assertThat(activity.getAdapter().getServiceTargetCount(), is(0)); onView(withId(R.id.title)).check(matches(withText("chooser test"))); onView(withId(R.id.title)).check(matches(withText("chooser test"))); } } Loading core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -39,8 +39,8 @@ public class ChooserWrapperActivity extends ChooserActivity { static final OverrideData sOverrides = new OverrideData(); static final OverrideData sOverrides = new OverrideData(); private UsageStatsManager mUsm; private UsageStatsManager mUsm; ResolveListAdapter getAdapter() { ChooserListAdapter getAdapter() { return mAdapter; return (ChooserListAdapter) mAdapter; } } boolean getIsSelected() { return mIsSuccessfullySelected; } boolean getIsSelected() { return mIsSuccessfullySelected; } Loading Loading
core/java/com/android/internal/app/ChooserActivity.java +31 −16 Original line number Original line Diff line number Diff line Loading @@ -318,9 +318,7 @@ public class ChooserActivity extends ResolverActivity { // Do not allow the title to be changed when sharing content // Do not allow the title to be changed when sharing content CharSequence title = null; CharSequence title = null; if (target != null) { if (target != null) { String targetAction = target.getAction(); if (!isSendAction(target)) { if (!(Intent.ACTION_SEND.equals(targetAction) || Intent.ACTION_SEND_MULTIPLE.equals( targetAction))) { title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE); title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE); } else { } else { Log.w(TAG, "Ignoring intent's EXTRA_TITLE, deprecated in P. You may wish to set a" Log.w(TAG, "Ignoring intent's EXTRA_TITLE, deprecated in P. You may wish to set a" Loading Loading @@ -444,7 +442,7 @@ public class ChooserActivity extends ResolverActivity { .getDimensionPixelSize(R.dimen.chooser_service_spacing); .getDimensionPixelSize(R.dimen.chooser_service_spacing); // expand/shrink direct share 4 -> 8 viewgroup // expand/shrink direct share 4 -> 8 viewgroup if (mResolverDrawerLayout != null) { if (mResolverDrawerLayout != null && isSendAction(target)) { mResolverDrawerLayout.setOnScrollChangeListener(this::handleScroll); mResolverDrawerLayout.setOnScrollChangeListener(this::handleScroll); } } Loading @@ -470,13 +468,8 @@ public class ChooserActivity extends ResolverActivity { public void setHeader() { public void setHeader() { super.setHeader(); super.setHeader(); Intent targetIntent = getTargetIntent(); final Intent targetIntent = getTargetIntent(); if (targetIntent == null) { if (!isSendAction(targetIntent)) { return; } String action = targetIntent.getAction(); if (!(Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action))) { return; return; } } Loading Loading @@ -943,9 +936,7 @@ public class ChooserActivity extends ResolverActivity { } } private void modifyTargetIntent(Intent in) { private void modifyTargetIntent(Intent in) { final String action = in.getAction(); if (isSendAction(in)) { if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { in.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | in.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); Intent.FLAG_ACTIVITY_MULTIPLE_TASK); } } Loading Loading @@ -1939,9 +1930,13 @@ public class ChooserActivity extends ResolverActivity { } } public int getServiceTargetCount() { public int getServiceTargetCount() { if (isSendAction(getTargetIntent())) { return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); return Math.min(mServiceTargets.size(), MAX_SERVICE_TARGETS); } } return 0; } public int getStandardTargetCount() { public int getStandardTargetCount() { return super.getCount(); return super.getCount(); } } Loading Loading @@ -2088,6 +2083,23 @@ public class ChooserActivity extends ResolverActivity { } } } } private boolean isSendAction(Intent targetIntent) { if (targetIntent == null) { return false; } String action = targetIntent.getAction(); if (action == null) { return false; } if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) { return true; } return false; } class ChooserRowAdapter extends BaseAdapter { class ChooserRowAdapter extends BaseAdapter { private ChooserListAdapter mChooserListAdapter; private ChooserListAdapter mChooserListAdapter; private final LayoutInflater mLayoutInflater; private final LayoutInflater mLayoutInflater; Loading Loading @@ -2141,8 +2153,11 @@ public class ChooserActivity extends ResolverActivity { // There can be at most one row in the listview, that is internally // There can be at most one row in the listview, that is internally // a ViewGroup with 2 rows // a ViewGroup with 2 rows public int getServiceTargetRowCount() { public int getServiceTargetRowCount() { if (isSendAction(getTargetIntent())) { return 1; return 1; } } return 0; } @Override @Override public Object getItem(int position) { public Object getItem(int position) { Loading
core/tests/coretests/src/com/android/internal/app/ChooserActivityTest.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -97,9 +97,12 @@ public class ChooserActivityTest { when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(), when(sOverrides.resolverListController.getResolversForIntent(Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); Mockito.isA(List.class))).thenReturn(resolvedComponentInfos); mActivityRule.launchActivity(Intent.createChooser(viewIntent, "chooser test")); final ChooserWrapperActivity activity = mActivityRule.launchActivity( Intent.createChooser(viewIntent, "chooser test")); waitForIdle(); waitForIdle(); assertThat(activity.getAdapter().getCount(), is(2)); assertThat(activity.getAdapter().getServiceTargetCount(), is(0)); onView(withId(R.id.title)).check(matches(withText("chooser test"))); onView(withId(R.id.title)).check(matches(withText("chooser test"))); } } Loading
core/tests/coretests/src/com/android/internal/app/ChooserWrapperActivity.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -39,8 +39,8 @@ public class ChooserWrapperActivity extends ChooserActivity { static final OverrideData sOverrides = new OverrideData(); static final OverrideData sOverrides = new OverrideData(); private UsageStatsManager mUsm; private UsageStatsManager mUsm; ResolveListAdapter getAdapter() { ChooserListAdapter getAdapter() { return mAdapter; return (ChooserListAdapter) mAdapter; } } boolean getIsSelected() { return mIsSuccessfullySelected; } boolean getIsSelected() { return mIsSuccessfullySelected; } Loading