- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1019 lines
43 KiB
Java
1019 lines
43 KiB
Java
package com.facebook.internal;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.Activity;
|
|
import android.app.Dialog;
|
|
import android.app.ProgressDialog;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.pm.ApplicationInfo;
|
|
import android.content.pm.PackageManager;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.net.Uri;
|
|
import android.net.http.SslError;
|
|
import android.os.AsyncTask;
|
|
import android.os.Bundle;
|
|
import android.util.DisplayMetrics;
|
|
import android.view.Display;
|
|
import android.view.KeyEvent;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import android.webkit.SslErrorHandler;
|
|
import android.webkit.WebSettings;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebViewClient;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import androidx.annotation.VisibleForTesting;
|
|
import com.facebook.AccessToken;
|
|
import com.facebook.FacebookDialogException;
|
|
import com.facebook.FacebookException;
|
|
import com.facebook.FacebookGraphResponseException;
|
|
import com.facebook.FacebookOperationCanceledException;
|
|
import com.facebook.FacebookRequestError;
|
|
import com.facebook.FacebookSdk;
|
|
import com.facebook.GraphRequest;
|
|
import com.facebook.GraphRequestAsyncTask;
|
|
import com.facebook.GraphResponse;
|
|
import com.facebook.common.R;
|
|
import com.facebook.internal.WebDialog;
|
|
import com.facebook.internal.instrument.crashshield.CrashShieldHandler;
|
|
import com.facebook.login.LoginTargetApp;
|
|
import com.facebook.share.internal.ShareConstants;
|
|
import com.facebook.share.internal.ShareInternalUtility;
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import kotlin.collections.ArraysKt___ArraysJvmKt;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.StringCompanionObject;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class WebDialog extends Dialog {
|
|
private static final int API_EC_DIALOG_CANCEL = 4201;
|
|
private static final int BACKGROUND_GRAY = -872415232;
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int DEFAULT_THEME = R.style.com_facebook_activity_theme;
|
|
public static final boolean DISABLE_SSL_CHECK_FOR_TESTING = false;
|
|
private static final String DISPLAY_TOUCH = "touch";
|
|
private static final String LOG_TAG = "FacebookSDK.WebDialog";
|
|
private static final int MAX_PADDING_SCREEN_HEIGHT = 1280;
|
|
private static final int MAX_PADDING_SCREEN_WIDTH = 800;
|
|
private static final double MIN_SCALE_FACTOR = 0.5d;
|
|
private static final int NO_PADDING_SCREEN_HEIGHT = 800;
|
|
private static final int NO_PADDING_SCREEN_WIDTH = 480;
|
|
private static final String PLATFORM_DIALOG_PATH_REGEX = "^/(v\\d+\\.\\d+/)??dialog/.*";
|
|
private static InitCallback initCallback;
|
|
private static volatile int webDialogTheme;
|
|
private FrameLayout contentFrameLayout;
|
|
private ImageView crossImageView;
|
|
private String expectedRedirectUrl;
|
|
private boolean isDetached;
|
|
private boolean isListenerCalled;
|
|
private boolean isPageFinished;
|
|
private OnCompleteListener onCompleteListener;
|
|
private ProgressDialog spinner;
|
|
private UploadStagingResourcesTask uploadTask;
|
|
private String url;
|
|
private WebView webView;
|
|
private WindowManager.LayoutParams windowParams;
|
|
|
|
public interface InitCallback {
|
|
void onInit(WebView webView);
|
|
}
|
|
|
|
public interface OnCompleteListener {
|
|
void onComplete(Bundle bundle, FacebookException facebookException);
|
|
}
|
|
|
|
public /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
int[] iArr = new int[LoginTargetApp.valuesCustom().length];
|
|
iArr[LoginTargetApp.INSTAGRAM.ordinal()] = 1;
|
|
$EnumSwitchMapping$0 = iArr;
|
|
}
|
|
}
|
|
|
|
public /* synthetic */ WebDialog(Context context, String str, Bundle bundle, int i, LoginTargetApp loginTargetApp, OnCompleteListener onCompleteListener, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, str, bundle, i, loginTargetApp, onCompleteListener);
|
|
}
|
|
|
|
private final int getScaledSize(int i, float f, int i2, int i3) {
|
|
int i4 = (int) (i / f);
|
|
return (int) (i * (i4 <= i2 ? 1.0d : i4 >= i3 ? 0.5d : (((i3 - i4) / (i3 - i2)) * MIN_SCALE_FACTOR) + MIN_SCALE_FACTOR));
|
|
}
|
|
|
|
public static final int getWebDialogTheme() {
|
|
return Companion.getWebDialogTheme();
|
|
}
|
|
|
|
public static final void initDefaultTheme(Context context) {
|
|
Companion.initDefaultTheme(context);
|
|
}
|
|
|
|
public static final WebDialog newInstance(Context context, String str, Bundle bundle, int i, OnCompleteListener onCompleteListener) {
|
|
return Companion.newInstance(context, str, bundle, i, onCompleteListener);
|
|
}
|
|
|
|
public static final WebDialog newInstance(Context context, String str, Bundle bundle, int i, LoginTargetApp loginTargetApp, OnCompleteListener onCompleteListener) {
|
|
return Companion.newInstance(context, str, bundle, i, loginTargetApp, onCompleteListener);
|
|
}
|
|
|
|
public static final void setInitCallback(InitCallback initCallback2) {
|
|
Companion.setInitCallback(initCallback2);
|
|
}
|
|
|
|
public static final void setWebDialogTheme(int i) {
|
|
Companion.setWebDialogTheme(i);
|
|
}
|
|
|
|
public final OnCompleteListener getOnCompleteListener() {
|
|
return this.onCompleteListener;
|
|
}
|
|
|
|
public final WebView getWebView() {
|
|
return this.webView;
|
|
}
|
|
|
|
public final boolean isListenerCalled() {
|
|
return this.isListenerCalled;
|
|
}
|
|
|
|
public final boolean isPageFinished() {
|
|
return this.isPageFinished;
|
|
}
|
|
|
|
public final void setExpectedRedirectUrl(String expectedRedirectUrl) {
|
|
Intrinsics.checkNotNullParameter(expectedRedirectUrl, "expectedRedirectUrl");
|
|
this.expectedRedirectUrl = expectedRedirectUrl;
|
|
}
|
|
|
|
public final void setOnCompleteListener(OnCompleteListener onCompleteListener) {
|
|
this.onCompleteListener = onCompleteListener;
|
|
}
|
|
|
|
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
|
public WebDialog(Context context, String url) {
|
|
this(context, url, Companion.getWebDialogTheme());
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(url, "url");
|
|
}
|
|
|
|
private WebDialog(Context context, String str, int i) {
|
|
super(context, i == 0 ? Companion.getWebDialogTheme() : i);
|
|
this.expectedRedirectUrl = ServerProtocol.DIALOG_REDIRECT_URI;
|
|
this.url = str;
|
|
}
|
|
|
|
private WebDialog(Context context, String str, Bundle bundle, int i, LoginTargetApp loginTargetApp, OnCompleteListener onCompleteListener) {
|
|
super(context, i == 0 ? Companion.getWebDialogTheme() : i);
|
|
Uri buildUri;
|
|
String str2 = ServerProtocol.DIALOG_REDIRECT_URI;
|
|
this.expectedRedirectUrl = ServerProtocol.DIALOG_REDIRECT_URI;
|
|
bundle = bundle == null ? new Bundle() : bundle;
|
|
str2 = Utility.isChromeOS(context) ? ServerProtocol.DIALOG_REDIRECT_CHROME_OS_URI : str2;
|
|
this.expectedRedirectUrl = str2;
|
|
bundle.putString(ServerProtocol.DIALOG_PARAM_REDIRECT_URI, str2);
|
|
bundle.putString("display", "touch");
|
|
bundle.putString("client_id", FacebookSdk.getApplicationId());
|
|
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
|
|
String format = String.format(Locale.ROOT, "android-%s", Arrays.copyOf(new Object[]{FacebookSdk.getSdkVersion()}, 1));
|
|
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(locale, format, *args)");
|
|
bundle.putString("sdk", format);
|
|
this.onCompleteListener = onCompleteListener;
|
|
if (Intrinsics.areEqual(str, "share") && bundle.containsKey("media")) {
|
|
this.uploadTask = new UploadStagingResourcesTask(this, str, bundle);
|
|
return;
|
|
}
|
|
if (WhenMappings.$EnumSwitchMapping$0[loginTargetApp.ordinal()] == 1) {
|
|
buildUri = Utility.buildUri(ServerProtocol.getInstagramDialogAuthority(), ServerProtocol.INSTAGRAM_OAUTH_PATH, bundle);
|
|
} else {
|
|
buildUri = Utility.buildUri(ServerProtocol.getDialogAuthority(), FacebookSdk.getGraphApiVersion() + "/dialog/" + ((Object) str), bundle);
|
|
}
|
|
this.url = buildUri.toString();
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.view.KeyEvent.Callback
|
|
public boolean onKeyDown(int i, KeyEvent event) {
|
|
Intrinsics.checkNotNullParameter(event, "event");
|
|
if (i == 4) {
|
|
WebView webView = this.webView;
|
|
if (webView != null) {
|
|
if (Intrinsics.areEqual(webView == null ? null : Boolean.valueOf(webView.canGoBack()), Boolean.TRUE)) {
|
|
WebView webView2 = this.webView;
|
|
if (webView2 == null) {
|
|
return true;
|
|
}
|
|
webView2.goBack();
|
|
return true;
|
|
}
|
|
}
|
|
cancel();
|
|
}
|
|
return super.onKeyDown(i, event);
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.content.DialogInterface
|
|
public void dismiss() {
|
|
ProgressDialog progressDialog;
|
|
WebView webView = this.webView;
|
|
if (webView != null) {
|
|
webView.stopLoading();
|
|
}
|
|
if (!this.isDetached && (progressDialog = this.spinner) != null && progressDialog.isShowing()) {
|
|
progressDialog.dismiss();
|
|
}
|
|
super.dismiss();
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void onStart() {
|
|
super.onStart();
|
|
UploadStagingResourcesTask uploadStagingResourcesTask = this.uploadTask;
|
|
if (uploadStagingResourcesTask != null) {
|
|
if ((uploadStagingResourcesTask == null ? null : uploadStagingResourcesTask.getStatus()) == AsyncTask.Status.PENDING) {
|
|
UploadStagingResourcesTask uploadStagingResourcesTask2 = this.uploadTask;
|
|
if (uploadStagingResourcesTask2 != null) {
|
|
uploadStagingResourcesTask2.execute(new Void[0]);
|
|
}
|
|
ProgressDialog progressDialog = this.spinner;
|
|
if (progressDialog == null) {
|
|
return;
|
|
}
|
|
progressDialog.show();
|
|
return;
|
|
}
|
|
}
|
|
resize();
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void onStop() {
|
|
UploadStagingResourcesTask uploadStagingResourcesTask = this.uploadTask;
|
|
if (uploadStagingResourcesTask != null) {
|
|
uploadStagingResourcesTask.cancel(true);
|
|
ProgressDialog progressDialog = this.spinner;
|
|
if (progressDialog != null) {
|
|
progressDialog.dismiss();
|
|
}
|
|
}
|
|
super.onStop();
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.view.Window.Callback
|
|
public void onDetachedFromWindow() {
|
|
this.isDetached = true;
|
|
super.onDetachedFromWindow();
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.view.Window.Callback
|
|
public void onAttachedToWindow() {
|
|
WindowManager.LayoutParams layoutParams;
|
|
WindowManager.LayoutParams attributes;
|
|
this.isDetached = false;
|
|
Utility utility = Utility.INSTANCE;
|
|
Context context = getContext();
|
|
Intrinsics.checkNotNullExpressionValue(context, "context");
|
|
if (Utility.mustFixWindowParamsForAutofill(context) && (layoutParams = this.windowParams) != null) {
|
|
if ((layoutParams == null ? null : layoutParams.token) == null) {
|
|
if (layoutParams != null) {
|
|
Activity ownerActivity = getOwnerActivity();
|
|
Window window = ownerActivity == null ? null : ownerActivity.getWindow();
|
|
layoutParams.token = (window == null || (attributes = window.getAttributes()) == null) ? null : attributes.token;
|
|
}
|
|
WindowManager.LayoutParams layoutParams2 = this.windowParams;
|
|
Utility.logd(LOG_TAG, Intrinsics.stringPlus("Set token on onAttachedToWindow(): ", layoutParams2 != null ? layoutParams2.token : null));
|
|
}
|
|
}
|
|
super.onAttachedToWindow();
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.view.Window.Callback
|
|
public void onWindowAttributesChanged(WindowManager.LayoutParams params) {
|
|
Intrinsics.checkNotNullParameter(params, "params");
|
|
if (params.token == null) {
|
|
this.windowParams = params;
|
|
}
|
|
super.onWindowAttributesChanged(params);
|
|
}
|
|
|
|
@Override // android.app.Dialog
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
ProgressDialog progressDialog = new ProgressDialog(getContext());
|
|
this.spinner = progressDialog;
|
|
progressDialog.requestWindowFeature(1);
|
|
ProgressDialog progressDialog2 = this.spinner;
|
|
if (progressDialog2 != null) {
|
|
progressDialog2.setMessage(getContext().getString(R.string.com_facebook_loading));
|
|
}
|
|
ProgressDialog progressDialog3 = this.spinner;
|
|
if (progressDialog3 != null) {
|
|
progressDialog3.setCanceledOnTouchOutside(false);
|
|
}
|
|
ProgressDialog progressDialog4 = this.spinner;
|
|
if (progressDialog4 != null) {
|
|
progressDialog4.setOnCancelListener(new DialogInterface.OnCancelListener() { // from class: com.facebook.internal.WebDialog$$ExternalSyntheticLambda0
|
|
@Override // android.content.DialogInterface.OnCancelListener
|
|
public final void onCancel(DialogInterface dialogInterface) {
|
|
WebDialog.m584onCreate$lambda4(WebDialog.this, dialogInterface);
|
|
}
|
|
});
|
|
}
|
|
requestWindowFeature(1);
|
|
this.contentFrameLayout = new FrameLayout(getContext());
|
|
resize();
|
|
Window window = getWindow();
|
|
if (window != null) {
|
|
window.setGravity(17);
|
|
}
|
|
Window window2 = getWindow();
|
|
if (window2 != null) {
|
|
window2.setSoftInputMode(16);
|
|
}
|
|
createCrossImage();
|
|
if (this.url != null) {
|
|
ImageView imageView = this.crossImageView;
|
|
if (imageView == null) {
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
}
|
|
setUpWebView((imageView.getDrawable().getIntrinsicWidth() / 2) + 1);
|
|
}
|
|
FrameLayout frameLayout = this.contentFrameLayout;
|
|
if (frameLayout != null) {
|
|
frameLayout.addView(this.crossImageView, new ViewGroup.LayoutParams(-2, -2));
|
|
}
|
|
FrameLayout frameLayout2 = this.contentFrameLayout;
|
|
if (frameLayout2 == null) {
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
}
|
|
setContentView(frameLayout2);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: onCreate$lambda-4, reason: not valid java name */
|
|
public static final void m584onCreate$lambda4(WebDialog this$0, DialogInterface dialogInterface) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
this$0.cancel();
|
|
}
|
|
|
|
@VisibleForTesting(otherwise = 4)
|
|
public Bundle parseResponseUri(String str) {
|
|
Uri parse = Uri.parse(str);
|
|
Utility utility = Utility.INSTANCE;
|
|
Bundle parseUrlQueryString = Utility.parseUrlQueryString(parse.getQuery());
|
|
parseUrlQueryString.putAll(Utility.parseUrlQueryString(parse.getFragment()));
|
|
return parseUrlQueryString;
|
|
}
|
|
|
|
public final void resize() {
|
|
Object systemService = getContext().getSystemService("window");
|
|
if (systemService == null) {
|
|
throw new NullPointerException("null cannot be cast to non-null type android.view.WindowManager");
|
|
}
|
|
Display defaultDisplay = ((WindowManager) systemService).getDefaultDisplay();
|
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
|
defaultDisplay.getMetrics(displayMetrics);
|
|
int i = displayMetrics.widthPixels;
|
|
int i2 = displayMetrics.heightPixels;
|
|
int i3 = i < i2 ? i : i2;
|
|
if (i < i2) {
|
|
i = i2;
|
|
}
|
|
int min = Math.min(getScaledSize(i3, displayMetrics.density, NO_PADDING_SCREEN_WIDTH, 800), displayMetrics.widthPixels);
|
|
int min2 = Math.min(getScaledSize(i, displayMetrics.density, 800, MAX_PADDING_SCREEN_HEIGHT), displayMetrics.heightPixels);
|
|
Window window = getWindow();
|
|
if (window == null) {
|
|
return;
|
|
}
|
|
window.setLayout(min, min2);
|
|
}
|
|
|
|
public final void sendSuccessToListener(Bundle bundle) {
|
|
OnCompleteListener onCompleteListener = this.onCompleteListener;
|
|
if (onCompleteListener == null || this.isListenerCalled) {
|
|
return;
|
|
}
|
|
this.isListenerCalled = true;
|
|
if (onCompleteListener != null) {
|
|
onCompleteListener.onComplete(bundle, null);
|
|
}
|
|
dismiss();
|
|
}
|
|
|
|
public final void sendErrorToListener(Throwable th) {
|
|
FacebookException facebookException;
|
|
if (this.onCompleteListener == null || this.isListenerCalled) {
|
|
return;
|
|
}
|
|
this.isListenerCalled = true;
|
|
if (th instanceof FacebookException) {
|
|
facebookException = (FacebookException) th;
|
|
} else {
|
|
facebookException = new FacebookException(th);
|
|
}
|
|
OnCompleteListener onCompleteListener = this.onCompleteListener;
|
|
if (onCompleteListener != null) {
|
|
onCompleteListener.onComplete(null, facebookException);
|
|
}
|
|
dismiss();
|
|
}
|
|
|
|
@Override // android.app.Dialog, android.content.DialogInterface
|
|
public void cancel() {
|
|
if (this.onCompleteListener == null || this.isListenerCalled) {
|
|
return;
|
|
}
|
|
sendErrorToListener(new FacebookOperationCanceledException());
|
|
}
|
|
|
|
private final void createCrossImage() {
|
|
ImageView imageView = new ImageView(getContext());
|
|
this.crossImageView = imageView;
|
|
imageView.setOnClickListener(new View.OnClickListener() { // from class: com.facebook.internal.WebDialog$$ExternalSyntheticLambda1
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
WebDialog.m583createCrossImage$lambda5(WebDialog.this, view);
|
|
}
|
|
});
|
|
Drawable drawable = getContext().getResources().getDrawable(R.drawable.com_facebook_close);
|
|
ImageView imageView2 = this.crossImageView;
|
|
if (imageView2 != null) {
|
|
imageView2.setImageDrawable(drawable);
|
|
}
|
|
ImageView imageView3 = this.crossImageView;
|
|
if (imageView3 == null) {
|
|
return;
|
|
}
|
|
imageView3.setVisibility(4);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: createCrossImage$lambda-5, reason: not valid java name */
|
|
public static final void m583createCrossImage$lambda5(WebDialog this$0, View view) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
this$0.cancel();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
@SuppressLint({"SetJavaScriptEnabled"})
|
|
public final void setUpWebView(int i) {
|
|
LinearLayout linearLayout = new LinearLayout(getContext());
|
|
final Context context = getContext();
|
|
this.webView = new WebView(context) { // from class: com.facebook.internal.WebDialog$setUpWebView$1
|
|
@Override // android.webkit.WebView, android.view.View
|
|
public void onWindowFocusChanged(boolean z) {
|
|
try {
|
|
super.onWindowFocusChanged(z);
|
|
} catch (NullPointerException unused) {
|
|
}
|
|
}
|
|
};
|
|
InitCallback initCallback2 = initCallback;
|
|
if (initCallback2 != null) {
|
|
initCallback2.onInit(getWebView());
|
|
}
|
|
WebView webView = this.webView;
|
|
if (webView != null) {
|
|
webView.setVerticalScrollBarEnabled(false);
|
|
}
|
|
WebView webView2 = this.webView;
|
|
if (webView2 != null) {
|
|
webView2.setHorizontalScrollBarEnabled(false);
|
|
}
|
|
WebView webView3 = this.webView;
|
|
if (webView3 != null) {
|
|
webView3.setWebViewClient(new DialogWebViewClient(this));
|
|
}
|
|
WebView webView4 = this.webView;
|
|
WebSettings settings = webView4 == null ? null : webView4.getSettings();
|
|
if (settings != null) {
|
|
settings.setJavaScriptEnabled(true);
|
|
}
|
|
WebView webView5 = this.webView;
|
|
if (webView5 != null) {
|
|
String str = this.url;
|
|
if (str != null) {
|
|
webView5.loadUrl(str);
|
|
} else {
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
}
|
|
}
|
|
WebView webView6 = this.webView;
|
|
if (webView6 != null) {
|
|
webView6.setLayoutParams(new FrameLayout.LayoutParams(-1, -1));
|
|
}
|
|
WebView webView7 = this.webView;
|
|
if (webView7 != null) {
|
|
webView7.setVisibility(4);
|
|
}
|
|
WebView webView8 = this.webView;
|
|
WebSettings settings2 = webView8 == null ? null : webView8.getSettings();
|
|
if (settings2 != null) {
|
|
settings2.setSavePassword(false);
|
|
}
|
|
WebView webView9 = this.webView;
|
|
WebSettings settings3 = webView9 != null ? webView9.getSettings() : null;
|
|
if (settings3 != null) {
|
|
settings3.setSaveFormData(false);
|
|
}
|
|
WebView webView10 = this.webView;
|
|
if (webView10 != null) {
|
|
webView10.setFocusable(true);
|
|
}
|
|
WebView webView11 = this.webView;
|
|
if (webView11 != null) {
|
|
webView11.setFocusableInTouchMode(true);
|
|
}
|
|
WebView webView12 = this.webView;
|
|
if (webView12 != null) {
|
|
webView12.setOnTouchListener(new View.OnTouchListener() { // from class: com.facebook.internal.WebDialog$$ExternalSyntheticLambda2
|
|
@Override // android.view.View.OnTouchListener
|
|
public final boolean onTouch(View view, MotionEvent motionEvent) {
|
|
boolean m585setUpWebView$lambda7;
|
|
m585setUpWebView$lambda7 = WebDialog.m585setUpWebView$lambda7(view, motionEvent);
|
|
return m585setUpWebView$lambda7;
|
|
}
|
|
});
|
|
}
|
|
linearLayout.setPadding(i, i, i, i);
|
|
linearLayout.addView(this.webView);
|
|
linearLayout.setBackgroundColor(BACKGROUND_GRAY);
|
|
FrameLayout frameLayout = this.contentFrameLayout;
|
|
if (frameLayout == null) {
|
|
return;
|
|
}
|
|
frameLayout.addView(linearLayout);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: setUpWebView$lambda-7, reason: not valid java name */
|
|
public static final boolean m585setUpWebView$lambda7(View view, MotionEvent motionEvent) {
|
|
if (view.hasFocus()) {
|
|
return false;
|
|
}
|
|
view.requestFocus();
|
|
return false;
|
|
}
|
|
|
|
public final class DialogWebViewClient extends WebViewClient {
|
|
final /* synthetic */ WebDialog this$0;
|
|
|
|
public DialogWebViewClient(WebDialog this$0) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
this.this$0 = this$0;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:38:0x00af */
|
|
/* JADX WARN: Removed duplicated region for block: B:39:0x00b5 */
|
|
@Override // android.webkit.WebViewClient
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public boolean shouldOverrideUrlLoading(android.webkit.WebView r6, java.lang.String r7) {
|
|
/*
|
|
Method dump skipped, instructions count: 246
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.facebook.internal.WebDialog.DialogWebViewClient.shouldOverrideUrlLoading(android.webkit.WebView, java.lang.String):boolean");
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onReceivedError(WebView view, int i, String description, String failingUrl) {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(description, "description");
|
|
Intrinsics.checkNotNullParameter(failingUrl, "failingUrl");
|
|
super.onReceivedError(view, i, description, failingUrl);
|
|
this.this$0.sendErrorToListener(new FacebookDialogException(description, i, failingUrl));
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(handler, "handler");
|
|
Intrinsics.checkNotNullParameter(error, "error");
|
|
super.onReceivedSslError(view, handler, error);
|
|
handler.cancel();
|
|
this.this$0.sendErrorToListener(new FacebookDialogException(null, -11, null));
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageStarted(WebView view, String url, Bitmap bitmap) {
|
|
ProgressDialog progressDialog;
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(url, "url");
|
|
Utility utility = Utility.INSTANCE;
|
|
Utility.logd(WebDialog.LOG_TAG, Intrinsics.stringPlus("Webview loading URL: ", url));
|
|
super.onPageStarted(view, url, bitmap);
|
|
if (this.this$0.isDetached || (progressDialog = this.this$0.spinner) == null) {
|
|
return;
|
|
}
|
|
progressDialog.show();
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageFinished(WebView view, String url) {
|
|
ProgressDialog progressDialog;
|
|
Intrinsics.checkNotNullParameter(view, "view");
|
|
Intrinsics.checkNotNullParameter(url, "url");
|
|
super.onPageFinished(view, url);
|
|
if (!this.this$0.isDetached && (progressDialog = this.this$0.spinner) != null) {
|
|
progressDialog.dismiss();
|
|
}
|
|
FrameLayout frameLayout = this.this$0.contentFrameLayout;
|
|
if (frameLayout != null) {
|
|
frameLayout.setBackgroundColor(0);
|
|
}
|
|
WebView webView = this.this$0.getWebView();
|
|
if (webView != null) {
|
|
webView.setVisibility(0);
|
|
}
|
|
ImageView imageView = this.this$0.crossImageView;
|
|
if (imageView != null) {
|
|
imageView.setVisibility(0);
|
|
}
|
|
this.this$0.isPageFinished = true;
|
|
}
|
|
}
|
|
|
|
public static class Builder {
|
|
private AccessToken accessToken;
|
|
private String action;
|
|
private String applicationId;
|
|
private Context context;
|
|
private OnCompleteListener listener;
|
|
private Bundle parameters;
|
|
private int theme;
|
|
|
|
public final String getApplicationId() {
|
|
return this.applicationId;
|
|
}
|
|
|
|
public final Context getContext() {
|
|
return this.context;
|
|
}
|
|
|
|
public final OnCompleteListener getListener() {
|
|
return this.listener;
|
|
}
|
|
|
|
public final Bundle getParameters() {
|
|
return this.parameters;
|
|
}
|
|
|
|
public final int getTheme() {
|
|
return this.theme;
|
|
}
|
|
|
|
public final Builder setOnCompleteListener(OnCompleteListener onCompleteListener) {
|
|
this.listener = onCompleteListener;
|
|
return this;
|
|
}
|
|
|
|
public final Builder setTheme(int i) {
|
|
this.theme = i;
|
|
return this;
|
|
}
|
|
|
|
public Builder(Context context, String action, Bundle bundle) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(action, "action");
|
|
AccessToken.Companion companion = AccessToken.Companion;
|
|
this.accessToken = companion.getCurrentAccessToken();
|
|
if (!companion.isCurrentAccessTokenActive()) {
|
|
String metadataApplicationId = Utility.getMetadataApplicationId(context);
|
|
if (metadataApplicationId == null) {
|
|
throw new FacebookException("Attempted to create a builder without a valid access token or a valid default Application ID.");
|
|
}
|
|
this.applicationId = metadataApplicationId;
|
|
}
|
|
finishInit(context, action, bundle);
|
|
}
|
|
|
|
public Builder(Context context, String str, String action, Bundle bundle) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(action, "action");
|
|
this.applicationId = Validate.notNullOrEmpty(str == null ? Utility.getMetadataApplicationId(context) : str, "applicationId");
|
|
finishInit(context, action, bundle);
|
|
}
|
|
|
|
public WebDialog build() {
|
|
AccessToken accessToken = this.accessToken;
|
|
if (accessToken != null) {
|
|
Bundle bundle = this.parameters;
|
|
if (bundle != null) {
|
|
bundle.putString("app_id", accessToken == null ? null : accessToken.getApplicationId());
|
|
}
|
|
Bundle bundle2 = this.parameters;
|
|
if (bundle2 != null) {
|
|
AccessToken accessToken2 = this.accessToken;
|
|
bundle2.putString("access_token", accessToken2 != null ? accessToken2.getToken() : null);
|
|
}
|
|
} else {
|
|
Bundle bundle3 = this.parameters;
|
|
if (bundle3 != null) {
|
|
bundle3.putString("app_id", this.applicationId);
|
|
}
|
|
}
|
|
Companion companion = WebDialog.Companion;
|
|
Context context = this.context;
|
|
if (context != null) {
|
|
return companion.newInstance(context, this.action, this.parameters, this.theme, this.listener);
|
|
}
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
}
|
|
|
|
private final void finishInit(Context context, String str, Bundle bundle) {
|
|
this.context = context;
|
|
this.action = str;
|
|
if (bundle != null) {
|
|
this.parameters = bundle;
|
|
} else {
|
|
this.parameters = new Bundle();
|
|
}
|
|
}
|
|
}
|
|
|
|
public final class UploadStagingResourcesTask extends AsyncTask<Void, Void, String[]> {
|
|
private final String action;
|
|
private Exception[] exceptions;
|
|
private final Bundle parameters;
|
|
final /* synthetic */ WebDialog this$0;
|
|
|
|
@Override // android.os.AsyncTask
|
|
public /* bridge */ /* synthetic */ String[] doInBackground(Void[] voidArr) {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return null;
|
|
}
|
|
try {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return null;
|
|
}
|
|
try {
|
|
return doInBackground2(voidArr);
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
return null;
|
|
}
|
|
} catch (Throwable th2) {
|
|
CrashShieldHandler.handleThrowable(th2, this);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override // android.os.AsyncTask
|
|
public /* bridge */ /* synthetic */ void onPostExecute(String[] strArr) {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return;
|
|
}
|
|
try {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return;
|
|
}
|
|
try {
|
|
onPostExecute2(strArr);
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
}
|
|
} catch (Throwable th2) {
|
|
CrashShieldHandler.handleThrowable(th2, this);
|
|
}
|
|
}
|
|
|
|
public UploadStagingResourcesTask(WebDialog this$0, String action, Bundle parameters) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
Intrinsics.checkNotNullParameter(action, "action");
|
|
Intrinsics.checkNotNullParameter(parameters, "parameters");
|
|
this.this$0 = this$0;
|
|
this.action = action;
|
|
this.parameters = parameters;
|
|
this.exceptions = new Exception[0];
|
|
}
|
|
|
|
/* renamed from: doInBackground, reason: avoid collision after fix types in other method */
|
|
public String[] doInBackground2(Void... p0) {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return null;
|
|
}
|
|
try {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return null;
|
|
}
|
|
try {
|
|
Intrinsics.checkNotNullParameter(p0, "p0");
|
|
String[] stringArray = this.parameters.getStringArray("media");
|
|
if (stringArray == null) {
|
|
return null;
|
|
}
|
|
final String[] strArr = new String[stringArray.length];
|
|
this.exceptions = new Exception[stringArray.length];
|
|
final CountDownLatch countDownLatch = new CountDownLatch(stringArray.length);
|
|
ConcurrentLinkedQueue concurrentLinkedQueue = new ConcurrentLinkedQueue();
|
|
AccessToken currentAccessToken = AccessToken.Companion.getCurrentAccessToken();
|
|
try {
|
|
int length = stringArray.length - 1;
|
|
if (length >= 0) {
|
|
final int i = 0;
|
|
while (true) {
|
|
int i2 = i + 1;
|
|
if (isCancelled()) {
|
|
Iterator it = concurrentLinkedQueue.iterator();
|
|
while (it.hasNext()) {
|
|
((GraphRequestAsyncTask) it.next()).cancel(true);
|
|
}
|
|
return null;
|
|
}
|
|
Uri uri = Uri.parse(stringArray[i]);
|
|
if (Utility.isWebUri(uri)) {
|
|
strArr[i] = uri.toString();
|
|
countDownLatch.countDown();
|
|
} else {
|
|
GraphRequest.Callback callback = new GraphRequest.Callback() { // from class: com.facebook.internal.WebDialog$UploadStagingResourcesTask$$ExternalSyntheticLambda0
|
|
@Override // com.facebook.GraphRequest.Callback
|
|
public final void onCompleted(GraphResponse graphResponse) {
|
|
WebDialog.UploadStagingResourcesTask.m586doInBackground$lambda0(strArr, i, this, countDownLatch, graphResponse);
|
|
}
|
|
};
|
|
ShareInternalUtility shareInternalUtility = ShareInternalUtility.INSTANCE;
|
|
Intrinsics.checkNotNullExpressionValue(uri, "uri");
|
|
concurrentLinkedQueue.add(ShareInternalUtility.newUploadStagingResourceWithImageRequest(currentAccessToken, uri, callback).executeAsync());
|
|
}
|
|
if (i2 > length) {
|
|
break;
|
|
}
|
|
i = i2;
|
|
}
|
|
}
|
|
countDownLatch.await();
|
|
return strArr;
|
|
} catch (Exception unused) {
|
|
Iterator it2 = concurrentLinkedQueue.iterator();
|
|
while (it2.hasNext()) {
|
|
((GraphRequestAsyncTask) it2.next()).cancel(true);
|
|
}
|
|
return null;
|
|
}
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
return null;
|
|
}
|
|
} catch (Throwable th2) {
|
|
CrashShieldHandler.handleThrowable(th2, this);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
/* renamed from: doInBackground$lambda-0, reason: not valid java name */
|
|
public static final void m586doInBackground$lambda0(String[] results, int i, UploadStagingResourcesTask this$0, CountDownLatch latch, GraphResponse response) {
|
|
FacebookRequestError error;
|
|
String str;
|
|
Intrinsics.checkNotNullParameter(results, "$results");
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
Intrinsics.checkNotNullParameter(latch, "$latch");
|
|
Intrinsics.checkNotNullParameter(response, "response");
|
|
try {
|
|
error = response.getError();
|
|
str = "Error staging photo.";
|
|
} catch (Exception e) {
|
|
this$0.exceptions[i] = e;
|
|
}
|
|
if (error != null) {
|
|
String errorMessage = error.getErrorMessage();
|
|
if (errorMessage != null) {
|
|
str = errorMessage;
|
|
}
|
|
throw new FacebookGraphResponseException(response, str);
|
|
}
|
|
JSONObject jSONObject = response.getJSONObject();
|
|
if (jSONObject == null) {
|
|
throw new FacebookException("Error staging photo.");
|
|
}
|
|
String optString = jSONObject.optString(ShareConstants.MEDIA_URI);
|
|
if (optString == null) {
|
|
throw new FacebookException("Error staging photo.");
|
|
}
|
|
results[i] = optString;
|
|
latch.countDown();
|
|
}
|
|
|
|
/* renamed from: onPostExecute, reason: avoid collision after fix types in other method */
|
|
public void onPostExecute2(String[] strArr) {
|
|
List asList;
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return;
|
|
}
|
|
try {
|
|
if (CrashShieldHandler.isObjectCrashing(this)) {
|
|
return;
|
|
}
|
|
try {
|
|
ProgressDialog progressDialog = this.this$0.spinner;
|
|
if (progressDialog != null) {
|
|
progressDialog.dismiss();
|
|
}
|
|
Exception[] excArr = this.exceptions;
|
|
int length = excArr.length;
|
|
int i = 0;
|
|
while (i < length) {
|
|
Exception exc = excArr[i];
|
|
i++;
|
|
if (exc != null) {
|
|
this.this$0.sendErrorToListener(exc);
|
|
return;
|
|
}
|
|
}
|
|
if (strArr == null) {
|
|
this.this$0.sendErrorToListener(new FacebookException("Failed to stage photos for web dialog"));
|
|
return;
|
|
}
|
|
asList = ArraysKt___ArraysJvmKt.asList(strArr);
|
|
if (asList.contains(null)) {
|
|
this.this$0.sendErrorToListener(new FacebookException("Failed to stage photos for web dialog"));
|
|
return;
|
|
}
|
|
Utility utility = Utility.INSTANCE;
|
|
Utility.putJSONValueInBundle(this.parameters, "media", new JSONArray((Collection) asList));
|
|
this.this$0.url = Utility.buildUri(ServerProtocol.getDialogAuthority(), FacebookSdk.getGraphApiVersion() + "/dialog/" + this.action, this.parameters).toString();
|
|
ImageView imageView = this.this$0.crossImageView;
|
|
if (imageView != null) {
|
|
this.this$0.setUpWebView((imageView.getDrawable().getIntrinsicWidth() / 2) + 1);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("Required value was null.".toString());
|
|
} catch (Throwable th) {
|
|
CrashShieldHandler.handleThrowable(th, this);
|
|
}
|
|
} catch (Throwable th2) {
|
|
CrashShieldHandler.handleThrowable(th2, this);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final class Companion {
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private Companion() {
|
|
}
|
|
|
|
public final void initDefaultTheme(Context context) {
|
|
if (context == null) {
|
|
return;
|
|
}
|
|
try {
|
|
ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128);
|
|
if ((applicationInfo == null ? null : applicationInfo.metaData) != null && WebDialog.webDialogTheme == 0) {
|
|
setWebDialogTheme(applicationInfo.metaData.getInt(FacebookSdk.WEB_DIALOG_THEME));
|
|
}
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
}
|
|
}
|
|
|
|
public final WebDialog newInstance(Context context, String str, Bundle bundle, int i, OnCompleteListener onCompleteListener) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
WebDialog.initDefaultTheme(context);
|
|
return new WebDialog(context, str, bundle, i, LoginTargetApp.FACEBOOK, onCompleteListener, null);
|
|
}
|
|
|
|
public final WebDialog newInstance(Context context, String str, Bundle bundle, int i, LoginTargetApp targetApp, OnCompleteListener onCompleteListener) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(targetApp, "targetApp");
|
|
WebDialog.initDefaultTheme(context);
|
|
return new WebDialog(context, str, bundle, i, targetApp, onCompleteListener, null);
|
|
}
|
|
|
|
public final int getWebDialogTheme() {
|
|
Validate.sdkInitialized();
|
|
return WebDialog.webDialogTheme;
|
|
}
|
|
|
|
public final void setWebDialogTheme(int i) {
|
|
if (i == 0) {
|
|
i = WebDialog.DEFAULT_THEME;
|
|
}
|
|
WebDialog.webDialogTheme = i;
|
|
}
|
|
|
|
public final void setInitCallback(InitCallback initCallback) {
|
|
WebDialog.initCallback = initCallback;
|
|
}
|
|
}
|
|
}
|