Merge "Provide startIntentSenderForResult for fragments" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6e58549740
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentSender;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.ArrayMap;
|
||||
@@ -130,6 +131,21 @@ public abstract class FragmentHostCallback<E> extends FragmentContainer {
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new {@link IntentSender} from the given fragment.
|
||||
* See {@link Activity#startIntentSender(IntentSender, Intent, int, int, int, Bundle)}.
|
||||
*/
|
||||
public void onStartIntentSenderFromFragment(Fragment fragment, IntentSender intent,
|
||||
int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues,
|
||||
int extraFlags, Bundle options) throws IntentSender.SendIntentException {
|
||||
if (requestCode != -1) {
|
||||
throw new IllegalStateException(
|
||||
"Starting intent sender with a requestCode requires a FragmentActivity host");
|
||||
}
|
||||
mContext.startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags,
|
||||
options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests permissions from the given fragment.
|
||||
* See {@link Activity#requestPermissions(String[], int)}
|
||||
|
||||
Reference in New Issue
Block a user