Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42eab1b7 authored by Craig Mautner's avatar Craig Mautner Committed by The Android Automerger
Browse files

Make ChooserActivity intents doccentric and transitory

Activities launched from the chooser activity will now appear in
their own tasks which will be automatically removed from recents
when they are finished.

Also qualified application of new flags with null check and
Action check. Must be either ACTION_SEND or ACTION_SEND_MULTIPLE.

Fixes bug 14463859.
Fixes bug 14633773.

Change-Id: I8832462163958f6a43bc4c6a020f78948ce70ac3
parent 1e24710c
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -276,8 +276,13 @@ public class ShareActionProvider extends ActionProvider {
     * @see Intent#ACTION_SEND_MULTIPLE
     */
    public void setShareIntent(Intent shareIntent) {
        if (shareIntent != null) {
            final String action = shareIntent.getAction();
            if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
                shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                        Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
            }
        }
        ActivityChooserModel dataModel = ActivityChooserModel.get(mContext,
            mShareHistoryFileName);
        dataModel.setIntent(shareIntent);
@@ -294,8 +299,12 @@ public class ShareActionProvider extends ActionProvider {
            final int itemId = item.getItemId();
            Intent launchIntent = dataModel.chooseActivity(itemId);
            if (launchIntent != null) {
                final String action = launchIntent.getAction();
                if (Intent.ACTION_SEND.equals(action) ||
                        Intent.ACTION_SEND_MULTIPLE.equals(action)) {
                    launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                            Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
                }
                mContext.startActivity(launchIntent);
            }
            return true;
+17 −3
Original line number Diff line number Diff line
@@ -33,6 +33,14 @@ public class ChooserActivity extends ResolverActivity {
            return;
        }
        Intent target = (Intent)targetParcelable;
        if (target != null) {
            final String action = target.getAction();
            if (Intent.ACTION_SEND.equals(action) ||
                    Intent.ACTION_SEND_MULTIPLE.equals(action)) {
                target.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                        Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
            }
        }
        CharSequence title = intent.getCharSequenceExtra(Intent.EXTRA_TITLE);
        if (title == null) {
            title = getResources().getText(com.android.internal.R.string.chooseActivity);
@@ -43,13 +51,19 @@ public class ChooserActivity extends ResolverActivity {
            initialIntents = new Intent[pa.length];
            for (int i=0; i<pa.length; i++) {
                if (!(pa[i] instanceof Intent)) {
                    Log.w("ChooserActivity", "Initial intent #" + i
                            + " not an Intent: " + pa[i]);
                    Log.w("ChooserActivity", "Initial intent #" + i + " not an Intent: " + pa[i]);
                    finish();
                    super.onCreate(null);
                    return;
                }
                initialIntents[i] = (Intent)pa[i];
                final Intent in = (Intent) pa[i];
                final String action = in.getAction();
                if (Intent.ACTION_SEND.equals(action) ||
                        Intent.ACTION_SEND_MULTIPLE.equals(action)) {
                    in.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                            Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS);
                }
                initialIntents[i] = in;
            }
        }
        super.onCreate(savedInstanceState, target, title, initialIntents, null, false);