2021-06-27 20:44:35 +00:00
|
|
|
package androidx.core.app;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2021-09-29 00:45:08 +00:00
|
|
|
import android.content.ClipData;
|
2021-06-27 20:44:35 +00:00
|
|
|
import android.content.ComponentName;
|
|
|
|
import android.content.Context;
|
2021-09-29 00:45:08 +00:00
|
|
|
import android.content.ContextWrapper;
|
2021-06-27 20:44:35 +00:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.ActionProvider;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.widget.ShareActionProvider;
|
|
|
|
import androidx.annotation.IdRes;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
2021-09-29 00:45:08 +00:00
|
|
|
import androidx.annotation.RequiresApi;
|
2021-06-27 20:44:35 +00:00
|
|
|
import androidx.annotation.StringRes;
|
2021-08-09 22:50:01 +00:00
|
|
|
import androidx.core.content.IntentCompat;
|
2021-06-27 20:44:35 +00:00
|
|
|
import androidx.core.util.Preconditions;
|
2021-12-21 23:37:30 +00:00
|
|
|
import b.d.b.a.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
import java.util.ArrayList;
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public final class ShareCompat {
|
|
|
|
public static final String EXTRA_CALLING_ACTIVITY = "androidx.core.app.EXTRA_CALLING_ACTIVITY";
|
|
|
|
public static final String EXTRA_CALLING_ACTIVITY_INTEROP = "android.support.v4.app.EXTRA_CALLING_ACTIVITY";
|
|
|
|
public static final String EXTRA_CALLING_PACKAGE = "androidx.core.app.EXTRA_CALLING_PACKAGE";
|
|
|
|
public static final String EXTRA_CALLING_PACKAGE_INTEROP = "android.support.v4.app.EXTRA_CALLING_PACKAGE";
|
|
|
|
private static final String HISTORY_FILENAME_PREFIX = ".sharecompat_";
|
|
|
|
|
2021-09-29 00:45:08 +00:00
|
|
|
@RequiresApi(16)
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-09-29 00:45:08 +00:00
|
|
|
public static class Api16Impl {
|
|
|
|
private Api16Impl() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void migrateExtraStreamToClipData(@NonNull Intent intent, @NonNull ArrayList<Uri> arrayList) {
|
|
|
|
ClipData clipData = new ClipData(null, new String[]{intent.getType()}, new ClipData.Item(intent.getCharSequenceExtra("android.intent.extra.TEXT"), intent.getStringExtra(IntentCompat.EXTRA_HTML_TEXT), null, arrayList.get(0)));
|
|
|
|
int size = arrayList.size();
|
|
|
|
for (int i = 1; i < size; i++) {
|
|
|
|
clipData.addItem(new ClipData.Item(arrayList.get(i)));
|
|
|
|
}
|
|
|
|
intent.setClipData(clipData);
|
|
|
|
intent.addFlags(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void removeClipData(@NonNull Intent intent) {
|
|
|
|
intent.setClipData(null);
|
2022-03-02 20:59:20 +00:00
|
|
|
intent.setFlags(intent.getFlags() & (-2));
|
2021-09-29 00:45:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public static class IntentBuilder {
|
|
|
|
@Nullable
|
|
|
|
private ArrayList<String> mBccAddresses;
|
|
|
|
@Nullable
|
|
|
|
private ArrayList<String> mCcAddresses;
|
|
|
|
@Nullable
|
|
|
|
private CharSequence mChooserTitle;
|
|
|
|
@NonNull
|
|
|
|
private final Context mContext;
|
|
|
|
@NonNull
|
|
|
|
private final Intent mIntent;
|
|
|
|
@Nullable
|
|
|
|
private ArrayList<Uri> mStreams;
|
|
|
|
@Nullable
|
|
|
|
private ArrayList<String> mToAddresses;
|
|
|
|
|
2021-09-29 00:45:08 +00:00
|
|
|
public IntentBuilder(@NonNull Context context) {
|
|
|
|
Activity activity;
|
2021-06-27 20:44:35 +00:00
|
|
|
this.mContext = (Context) Preconditions.checkNotNull(context);
|
|
|
|
Intent action = new Intent().setAction("android.intent.action.SEND");
|
|
|
|
this.mIntent = action;
|
2021-08-09 22:50:01 +00:00
|
|
|
action.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, context.getPackageName());
|
|
|
|
action.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE_INTEROP, context.getPackageName());
|
2021-06-27 20:44:35 +00:00
|
|
|
action.addFlags(524288);
|
2021-09-29 00:45:08 +00:00
|
|
|
while (true) {
|
|
|
|
if (!(context instanceof ContextWrapper)) {
|
|
|
|
activity = null;
|
|
|
|
break;
|
|
|
|
} else if (context instanceof Activity) {
|
|
|
|
activity = (Activity) context;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
context = ((ContextWrapper) context).getBaseContext();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (activity != null) {
|
|
|
|
ComponentName componentName = activity.getComponentName();
|
|
|
|
this.mIntent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, componentName);
|
|
|
|
this.mIntent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY_INTEROP, componentName);
|
|
|
|
}
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void combineArrayExtra(String str, ArrayList<String> arrayList) {
|
|
|
|
String[] stringArrayExtra = this.mIntent.getStringArrayExtra(str);
|
|
|
|
int length = stringArrayExtra != null ? stringArrayExtra.length : 0;
|
2022-03-02 20:59:20 +00:00
|
|
|
String[] strArr = new String[arrayList.size() + length];
|
2021-06-27 20:44:35 +00:00
|
|
|
arrayList.toArray(strArr);
|
|
|
|
if (stringArrayExtra != null) {
|
|
|
|
System.arraycopy(stringArrayExtra, 0, strArr, arrayList.size(), length);
|
|
|
|
}
|
|
|
|
this.mIntent.putExtra(str, strArr);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void combineArrayExtra(@Nullable String str, @NonNull String[] strArr) {
|
|
|
|
Intent intent = getIntent();
|
|
|
|
String[] stringArrayExtra = intent.getStringArrayExtra(str);
|
|
|
|
int length = stringArrayExtra != null ? stringArrayExtra.length : 0;
|
2022-03-02 20:59:20 +00:00
|
|
|
String[] strArr2 = new String[strArr.length + length];
|
2021-06-27 20:44:35 +00:00
|
|
|
if (stringArrayExtra != null) {
|
|
|
|
System.arraycopy(stringArrayExtra, 0, strArr2, 0, length);
|
|
|
|
}
|
|
|
|
System.arraycopy(strArr, 0, strArr2, length, strArr.length);
|
|
|
|
intent.putExtra(str, strArr2);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
2021-09-29 00:45:08 +00:00
|
|
|
@Deprecated
|
2021-06-27 20:44:35 +00:00
|
|
|
public static IntentBuilder from(@NonNull Activity activity) {
|
2021-09-29 00:45:08 +00:00
|
|
|
return new IntentBuilder(activity);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addEmailBcc(@NonNull String str) {
|
|
|
|
if (this.mBccAddresses == null) {
|
|
|
|
this.mBccAddresses = new ArrayList<>();
|
|
|
|
}
|
|
|
|
this.mBccAddresses.add(str);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addEmailBcc(@NonNull String[] strArr) {
|
|
|
|
combineArrayExtra("android.intent.extra.BCC", strArr);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addEmailCc(@NonNull String str) {
|
|
|
|
if (this.mCcAddresses == null) {
|
|
|
|
this.mCcAddresses = new ArrayList<>();
|
|
|
|
}
|
|
|
|
this.mCcAddresses.add(str);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addEmailCc(@NonNull String[] strArr) {
|
|
|
|
combineArrayExtra("android.intent.extra.CC", strArr);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addEmailTo(@NonNull String str) {
|
|
|
|
if (this.mToAddresses == null) {
|
|
|
|
this.mToAddresses = new ArrayList<>();
|
|
|
|
}
|
|
|
|
this.mToAddresses.add(str);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addEmailTo(@NonNull String[] strArr) {
|
|
|
|
combineArrayExtra("android.intent.extra.EMAIL", strArr);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder addStream(@NonNull Uri uri) {
|
2021-09-29 00:45:08 +00:00
|
|
|
if (this.mStreams == null) {
|
2021-06-27 20:44:35 +00:00
|
|
|
this.mStreams = new ArrayList<>();
|
|
|
|
}
|
|
|
|
this.mStreams.add(uri);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public Intent createChooserIntent() {
|
|
|
|
return Intent.createChooser(getIntent(), this.mChooserTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public Context getContext() {
|
|
|
|
return this.mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public Intent getIntent() {
|
|
|
|
ArrayList<String> arrayList = this.mToAddresses;
|
|
|
|
if (arrayList != null) {
|
|
|
|
combineArrayExtra("android.intent.extra.EMAIL", arrayList);
|
|
|
|
this.mToAddresses = null;
|
|
|
|
}
|
|
|
|
ArrayList<String> arrayList2 = this.mCcAddresses;
|
|
|
|
if (arrayList2 != null) {
|
|
|
|
combineArrayExtra("android.intent.extra.CC", arrayList2);
|
|
|
|
this.mCcAddresses = null;
|
|
|
|
}
|
|
|
|
ArrayList<String> arrayList3 = this.mBccAddresses;
|
|
|
|
if (arrayList3 != null) {
|
|
|
|
combineArrayExtra("android.intent.extra.BCC", arrayList3);
|
|
|
|
this.mBccAddresses = null;
|
|
|
|
}
|
|
|
|
ArrayList<Uri> arrayList4 = this.mStreams;
|
|
|
|
boolean z2 = true;
|
|
|
|
if (arrayList4 == null || arrayList4.size() <= 1) {
|
|
|
|
z2 = false;
|
|
|
|
}
|
2021-09-29 00:45:08 +00:00
|
|
|
if (!z2) {
|
2021-06-27 20:44:35 +00:00
|
|
|
this.mIntent.setAction("android.intent.action.SEND");
|
|
|
|
ArrayList<Uri> arrayList5 = this.mStreams;
|
|
|
|
if (arrayList5 == null || arrayList5.isEmpty()) {
|
|
|
|
this.mIntent.removeExtra("android.intent.extra.STREAM");
|
2021-09-29 00:45:08 +00:00
|
|
|
Api16Impl.removeClipData(this.mIntent);
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
|
|
|
this.mIntent.putExtra("android.intent.extra.STREAM", this.mStreams.get(0));
|
2021-09-29 00:45:08 +00:00
|
|
|
Api16Impl.migrateExtraStreamToClipData(this.mIntent, this.mStreams);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-09-29 00:45:08 +00:00
|
|
|
} else {
|
2021-06-27 20:44:35 +00:00
|
|
|
this.mIntent.setAction("android.intent.action.SEND_MULTIPLE");
|
2021-09-29 00:45:08 +00:00
|
|
|
this.mIntent.putParcelableArrayListExtra("android.intent.extra.STREAM", this.mStreams);
|
|
|
|
Api16Impl.migrateExtraStreamToClipData(this.mIntent, this.mStreams);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return this.mIntent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setChooserTitle(@StringRes int i) {
|
|
|
|
return setChooserTitle(this.mContext.getText(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setChooserTitle(@Nullable CharSequence charSequence) {
|
|
|
|
this.mChooserTitle = charSequence;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setEmailBcc(@Nullable String[] strArr) {
|
|
|
|
this.mIntent.putExtra("android.intent.extra.BCC", strArr);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setEmailCc(@Nullable String[] strArr) {
|
|
|
|
this.mIntent.putExtra("android.intent.extra.CC", strArr);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setEmailTo(@Nullable String[] strArr) {
|
|
|
|
if (this.mToAddresses != null) {
|
|
|
|
this.mToAddresses = null;
|
|
|
|
}
|
|
|
|
this.mIntent.putExtra("android.intent.extra.EMAIL", strArr);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setHtmlText(@Nullable String str) {
|
2021-08-09 22:50:01 +00:00
|
|
|
this.mIntent.putExtra(IntentCompat.EXTRA_HTML_TEXT, str);
|
2021-06-27 20:44:35 +00:00
|
|
|
if (!this.mIntent.hasExtra("android.intent.extra.TEXT")) {
|
|
|
|
setText(Html.fromHtml(str));
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setStream(@Nullable Uri uri) {
|
2021-09-28 19:28:19 +00:00
|
|
|
this.mStreams = null;
|
2021-09-29 00:45:08 +00:00
|
|
|
if (uri != null) {
|
|
|
|
addStream(uri);
|
|
|
|
}
|
2021-06-27 20:44:35 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setSubject(@Nullable String str) {
|
|
|
|
this.mIntent.putExtra("android.intent.extra.SUBJECT", str);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setText(@Nullable CharSequence charSequence) {
|
|
|
|
this.mIntent.putExtra("android.intent.extra.TEXT", charSequence);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
public IntentBuilder setType(@Nullable String str) {
|
|
|
|
this.mIntent.setType(str);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void startChooser() {
|
|
|
|
this.mContext.startActivity(createChooserIntent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-02 20:59:20 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-06-27 20:44:35 +00:00
|
|
|
public static class IntentReader {
|
|
|
|
private static final String TAG = "IntentReader";
|
|
|
|
@Nullable
|
|
|
|
private final ComponentName mCallingActivity;
|
|
|
|
@Nullable
|
|
|
|
private final String mCallingPackage;
|
|
|
|
@NonNull
|
|
|
|
private final Context mContext;
|
|
|
|
@NonNull
|
|
|
|
private final Intent mIntent;
|
|
|
|
@Nullable
|
|
|
|
private ArrayList<Uri> mStreams;
|
|
|
|
|
2021-09-29 00:45:08 +00:00
|
|
|
public IntentReader(@NonNull Activity activity) {
|
|
|
|
this((Context) Preconditions.checkNotNull(activity), activity.getIntent());
|
|
|
|
}
|
|
|
|
|
|
|
|
public IntentReader(@NonNull Context context, @NonNull Intent intent) {
|
2021-06-27 20:44:35 +00:00
|
|
|
this.mContext = (Context) Preconditions.checkNotNull(context);
|
|
|
|
this.mIntent = (Intent) Preconditions.checkNotNull(intent);
|
|
|
|
this.mCallingPackage = ShareCompat.getCallingPackage(intent);
|
|
|
|
this.mCallingActivity = ShareCompat.getCallingActivity(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
2021-09-29 00:45:08 +00:00
|
|
|
@Deprecated
|
2021-06-27 20:44:35 +00:00
|
|
|
public static IntentReader from(@NonNull Activity activity) {
|
2021-09-29 00:45:08 +00:00
|
|
|
return new IntentReader(activity);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void withinStyle(StringBuilder sb, CharSequence charSequence, int i, int i2) {
|
|
|
|
while (i < i2) {
|
|
|
|
char charAt = charSequence.charAt(i);
|
|
|
|
if (charAt == '<') {
|
|
|
|
sb.append("<");
|
|
|
|
} else if (charAt == '>') {
|
|
|
|
sb.append(">");
|
|
|
|
} else if (charAt == '&') {
|
|
|
|
sb.append("&");
|
|
|
|
} else if (charAt > '~' || charAt < ' ') {
|
|
|
|
sb.append("&#");
|
|
|
|
sb.append((int) charAt);
|
|
|
|
sb.append(";");
|
|
|
|
} else if (charAt == ' ') {
|
|
|
|
while (true) {
|
|
|
|
int i3 = i + 1;
|
|
|
|
if (i3 >= i2 || charSequence.charAt(i3) != ' ') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sb.append(" ");
|
|
|
|
i = i3;
|
|
|
|
}
|
|
|
|
sb.append(' ');
|
|
|
|
} else {
|
|
|
|
sb.append(charAt);
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public ComponentName getCallingActivity() {
|
|
|
|
return this.mCallingActivity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Drawable getCallingActivityIcon() {
|
|
|
|
if (this.mCallingActivity == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return this.mContext.getPackageManager().getActivityIcon(this.mCallingActivity);
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
2021-08-09 22:50:01 +00:00
|
|
|
Log.e(TAG, "Could not retrieve icon for calling activity", e);
|
2021-06-27 20:44:35 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Drawable getCallingApplicationIcon() {
|
|
|
|
if (this.mCallingPackage == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return this.mContext.getPackageManager().getApplicationIcon(this.mCallingPackage);
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
2021-08-09 22:50:01 +00:00
|
|
|
Log.e(TAG, "Could not retrieve icon for calling application", e);
|
2021-06-27 20:44:35 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public CharSequence getCallingApplicationLabel() {
|
|
|
|
if (this.mCallingPackage == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
PackageManager packageManager = this.mContext.getPackageManager();
|
|
|
|
try {
|
|
|
|
return packageManager.getApplicationLabel(packageManager.getApplicationInfo(this.mCallingPackage, 0));
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
2021-08-09 22:50:01 +00:00
|
|
|
Log.e(TAG, "Could not retrieve label for calling application", e);
|
2021-06-27 20:44:35 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getCallingPackage() {
|
|
|
|
return this.mCallingPackage;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String[] getEmailBcc() {
|
|
|
|
return this.mIntent.getStringArrayExtra("android.intent.extra.BCC");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String[] getEmailCc() {
|
|
|
|
return this.mIntent.getStringArrayExtra("android.intent.extra.CC");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String[] getEmailTo() {
|
|
|
|
return this.mIntent.getStringArrayExtra("android.intent.extra.EMAIL");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getHtmlText() {
|
2021-08-09 22:50:01 +00:00
|
|
|
String stringExtra = this.mIntent.getStringExtra(IntentCompat.EXTRA_HTML_TEXT);
|
2021-06-27 20:44:35 +00:00
|
|
|
if (stringExtra != null) {
|
|
|
|
return stringExtra;
|
|
|
|
}
|
|
|
|
CharSequence text = getText();
|
|
|
|
return text instanceof Spanned ? Html.toHtml((Spanned) text) : text != null ? Html.escapeHtml(text) : stringExtra;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Uri getStream() {
|
|
|
|
return (Uri) this.mIntent.getParcelableExtra("android.intent.extra.STREAM");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Uri getStream(int i) {
|
|
|
|
if (this.mStreams == null && isMultipleShare()) {
|
|
|
|
this.mStreams = this.mIntent.getParcelableArrayListExtra("android.intent.extra.STREAM");
|
|
|
|
}
|
|
|
|
ArrayList<Uri> arrayList = this.mStreams;
|
|
|
|
if (arrayList != null) {
|
|
|
|
return arrayList.get(i);
|
|
|
|
}
|
|
|
|
if (i == 0) {
|
|
|
|
return (Uri) this.mIntent.getParcelableExtra("android.intent.extra.STREAM");
|
|
|
|
}
|
2022-03-22 15:40:06 +00:00
|
|
|
StringBuilder S = a.S("Stream items available: ");
|
|
|
|
S.append(getStreamCount());
|
|
|
|
S.append(" index requested: ");
|
|
|
|
S.append(i);
|
|
|
|
throw new IndexOutOfBoundsException(S.toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getStreamCount() {
|
|
|
|
if (this.mStreams == null && isMultipleShare()) {
|
|
|
|
this.mStreams = this.mIntent.getParcelableArrayListExtra("android.intent.extra.STREAM");
|
|
|
|
}
|
|
|
|
ArrayList<Uri> arrayList = this.mStreams;
|
|
|
|
return arrayList != null ? arrayList.size() : this.mIntent.hasExtra("android.intent.extra.STREAM") ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getSubject() {
|
|
|
|
return this.mIntent.getStringExtra("android.intent.extra.SUBJECT");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public CharSequence getText() {
|
|
|
|
return this.mIntent.getCharSequenceExtra("android.intent.extra.TEXT");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public String getType() {
|
|
|
|
return this.mIntent.getType();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isMultipleShare() {
|
|
|
|
return "android.intent.action.SEND_MULTIPLE".equals(this.mIntent.getAction());
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isShareIntent() {
|
|
|
|
String action = this.mIntent.getAction();
|
|
|
|
return "android.intent.action.SEND".equals(action) || "android.intent.action.SEND_MULTIPLE".equals(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSingleShare() {
|
|
|
|
return "android.intent.action.SEND".equals(this.mIntent.getAction());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private ShareCompat() {
|
|
|
|
}
|
|
|
|
|
2021-09-29 00:45:08 +00:00
|
|
|
@Deprecated
|
2021-06-27 20:44:35 +00:00
|
|
|
public static void configureMenuItem(@NonNull Menu menu, @IdRes int i, @NonNull IntentBuilder intentBuilder) {
|
|
|
|
MenuItem findItem = menu.findItem(i);
|
|
|
|
if (findItem != null) {
|
|
|
|
configureMenuItem(findItem, intentBuilder);
|
|
|
|
return;
|
|
|
|
}
|
2021-11-08 18:25:28 +00:00
|
|
|
throw new IllegalArgumentException(a.q("Could not find menu item with id ", i, " in the supplied menu"));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-09-29 00:45:08 +00:00
|
|
|
@Deprecated
|
2021-06-27 20:44:35 +00:00
|
|
|
public static void configureMenuItem(@NonNull MenuItem menuItem, @NonNull IntentBuilder intentBuilder) {
|
|
|
|
ActionProvider actionProvider = menuItem.getActionProvider();
|
|
|
|
ShareActionProvider shareActionProvider = !(actionProvider instanceof ShareActionProvider) ? new ShareActionProvider(intentBuilder.getContext()) : (ShareActionProvider) actionProvider;
|
2022-03-22 15:40:06 +00:00
|
|
|
StringBuilder S = a.S(HISTORY_FILENAME_PREFIX);
|
|
|
|
S.append(intentBuilder.getContext().getClass().getName());
|
|
|
|
shareActionProvider.setShareHistoryFileName(S.toString());
|
2021-06-27 20:44:35 +00:00
|
|
|
shareActionProvider.setShareIntent(intentBuilder.getIntent());
|
|
|
|
menuItem.setActionProvider(shareActionProvider);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static ComponentName getCallingActivity(@NonNull Activity activity) {
|
|
|
|
Intent intent = activity.getIntent();
|
|
|
|
ComponentName callingActivity = activity.getCallingActivity();
|
|
|
|
return callingActivity == null ? getCallingActivity(intent) : callingActivity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static ComponentName getCallingActivity(@NonNull Intent intent) {
|
2021-08-09 22:50:01 +00:00
|
|
|
ComponentName componentName = (ComponentName) intent.getParcelableExtra(EXTRA_CALLING_ACTIVITY);
|
|
|
|
return componentName == null ? (ComponentName) intent.getParcelableExtra(EXTRA_CALLING_ACTIVITY_INTEROP) : componentName;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static String getCallingPackage(@NonNull Activity activity) {
|
|
|
|
Intent intent = activity.getIntent();
|
|
|
|
String callingPackage = activity.getCallingPackage();
|
|
|
|
return (callingPackage != null || intent == null) ? callingPackage : getCallingPackage(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public static String getCallingPackage(@NonNull Intent intent) {
|
2021-08-09 22:50:01 +00:00
|
|
|
String stringExtra = intent.getStringExtra(EXTRA_CALLING_PACKAGE);
|
|
|
|
return stringExtra == null ? intent.getStringExtra(EXTRA_CALLING_PACKAGE_INTEROP) : stringExtra;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|