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

Commit 6e585497 authored by Clara Bayarri's avatar Clara Bayarri Committed by Android (Google) Code Review
Browse files

Merge "Provide startIntentSenderForResult for fragments" into nyc-dev

parents 25c43b78 a0c2dc3c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4480,6 +4480,7 @@ package android.app {
    method public void startActivity(android.content.Intent, android.os.Bundle);
    method public void startActivityForResult(android.content.Intent, int);
    method public void startActivityForResult(android.content.Intent, int, android.os.Bundle);
    method public void startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
    method public void unregisterForContextMenu(android.view.View);
  }
@@ -4571,6 +4572,7 @@ package android.app {
    method public void onRequestPermissionsFromFragment(android.app.Fragment, java.lang.String[], int);
    method public boolean onShouldSaveFragmentState(android.app.Fragment);
    method public void onStartActivityFromFragment(android.app.Fragment, android.content.Intent, int, android.os.Bundle);
    method public void onStartIntentSenderFromFragment(android.app.Fragment, android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
    method public boolean onUseFragmentManagerInflaterFactory();
  }
+2 −0
Original line number Diff line number Diff line
@@ -4613,6 +4613,7 @@ package android.app {
    method public void startActivity(android.content.Intent, android.os.Bundle);
    method public void startActivityForResult(android.content.Intent, int);
    method public void startActivityForResult(android.content.Intent, int, android.os.Bundle);
    method public void startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
    method public void unregisterForContextMenu(android.view.View);
  }
@@ -4704,6 +4705,7 @@ package android.app {
    method public void onRequestPermissionsFromFragment(android.app.Fragment, java.lang.String[], int);
    method public boolean onShouldSaveFragmentState(android.app.Fragment);
    method public void onStartActivityFromFragment(android.app.Fragment, android.content.Intent, int, android.os.Bundle);
    method public void onStartIntentSenderFromFragment(android.app.Fragment, android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
    method public boolean onUseFragmentManagerInflaterFactory();
  }
+2 −0
Original line number Diff line number Diff line
@@ -4480,6 +4480,7 @@ package android.app {
    method public void startActivity(android.content.Intent, android.os.Bundle);
    method public void startActivityForResult(android.content.Intent, int);
    method public void startActivityForResult(android.content.Intent, int, android.os.Bundle);
    method public void startIntentSenderForResult(android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
    method public void unregisterForContextMenu(android.view.View);
  }
@@ -4571,6 +4572,7 @@ package android.app {
    method public void onRequestPermissionsFromFragment(android.app.Fragment, java.lang.String[], int);
    method public boolean onShouldSaveFragmentState(android.app.Fragment);
    method public void onStartActivityFromFragment(android.app.Fragment, android.content.Intent, int, android.os.Bundle);
    method public void onStartIntentSenderFromFragment(android.app.Fragment, android.content.IntentSender, int, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
    method public boolean onUseFragmentManagerInflaterFactory();
  }
+35 −7
Original line number Diff line number Diff line
@@ -4405,8 +4405,8 @@ public class Activity extends ContextThemeWrapper
            @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
            Bundle options) throws IntentSender.SendIntentException {
        if (mParent == null) {
            startIntentSenderForResultInner(intent, requestCode, fillInIntent,
                    flagsMask, flagsValues, this, options);
            startIntentSenderForResultInner(intent, mEmbeddedID, requestCode, fillInIntent,
                    flagsMask, flagsValues, options);
        } else if (options != null) {
            mParent.startIntentSenderFromChild(this, intent, requestCode,
                    fillInIntent, flagsMask, flagsValues, extraFlags, options);
@@ -4418,8 +4418,8 @@ public class Activity extends ContextThemeWrapper
        }
    }

    private void startIntentSenderForResultInner(IntentSender intent, int requestCode,
            Intent fillInIntent, int flagsMask, int flagsValues, Activity activity,
    private void startIntentSenderForResultInner(IntentSender intent, String who, int requestCode,
            Intent fillInIntent, int flagsMask, int flagsValues,
            Bundle options)
            throws IntentSender.SendIntentException {
        try {
@@ -4431,7 +4431,7 @@ public class Activity extends ContextThemeWrapper
            }
            int result = ActivityManagerNative.getDefault()
                .startActivityIntentSender(mMainThread.getApplicationThread(), intent,
                        fillInIntent, resolvedType, mToken, activity.mEmbeddedID,
                        fillInIntent, resolvedType, mToken, who,
                        requestCode, flagsMask, flagsValues, options);
            if (result == ActivityManager.START_CANCELED) {
                throw new IntentSender.SendIntentException();
@@ -4888,8 +4888,23 @@ public class Activity extends ContextThemeWrapper
            int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
            int extraFlags, @Nullable Bundle options)
            throws IntentSender.SendIntentException {
        startIntentSenderForResultInner(intent, requestCode, fillInIntent,
                flagsMask, flagsValues, child, options);
        startIntentSenderForResultInner(intent, child.mEmbeddedID, requestCode, fillInIntent,
                flagsMask, flagsValues, options);
    }

    /**
     * Like {@link #startIntentSenderFromChild}, but taking a Fragment; see
     * {@link #startIntentSenderForResult(IntentSender, int, Intent, int, int, int)}
     * for more information.
     *
     * @hide
     */
    public void startIntentSenderFromChildFragment(Fragment child, IntentSender intent,
            int requestCode, Intent fillInIntent, int flagsMask, int flagsValues,
            int extraFlags, @Nullable Bundle options)
            throws IntentSender.SendIntentException {
        startIntentSenderForResultInner(intent, child.mWho, requestCode, fillInIntent,
                flagsMask, flagsValues, options);
    }

    /**
@@ -7034,6 +7049,19 @@ public class Activity extends ContextThemeWrapper
            Activity.this.startActivityFromFragment(fragment, intent, requestCode, options);
        }

        @Override
        public void onStartIntentSenderFromFragment(Fragment fragment, IntentSender intent,
                int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues,
                int extraFlags, Bundle options) throws IntentSender.SendIntentException {
            if (mParent == null) {
                startIntentSenderForResultInner(intent, fragment.mWho, requestCode, fillInIntent,
                        flagsMask, flagsValues, options);
            } else if (options != null) {
                mParent.startIntentSenderFromChildFragment(fragment, intent, requestCode,
                        fillInIntent, flagsMask, flagsValues, extraFlags, options);
            }
        }

        @Override
        public void onRequestPermissionsFromFragment(Fragment fragment, String[] permissions,
                int requestCode) {
+15 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.StringRes;
import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -1115,6 +1116,20 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
        mHost.onStartActivityFromFragment(this, intent, requestCode, options);
    }

    /**
     * Call {@link Activity#startIntentSenderForResult(IntentSender, int, Intent, int, int, int,
     * Bundle)} from the fragment's containing Activity.
     */
    public void startIntentSenderForResult(IntentSender intent, int requestCode,
            @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags,
            Bundle options) throws IntentSender.SendIntentException {
        if (mHost == null) {
            throw new IllegalStateException("Fragment " + this + " not attached to Activity");
        }
        mHost.onStartIntentSenderFromFragment(this, intent, requestCode, fillInIntent, flagsMask,
                flagsValues, extraFlags, options);
    }

    /**
     * Receive the result from a previous call to
     * {@link #startActivityForResult(Intent, int)}.  This follows the
Loading