- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
243 lines
10 KiB
Java
243 lines
10 KiB
Java
package com.ea.nimble;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.app.Activity;
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.res.Configuration;
|
|
import android.graphics.Bitmap;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.webkit.WebResourceRequest;
|
|
import android.webkit.WebViewClient;
|
|
import android.widget.RelativeLayout;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.browser.customtabs.CustomTabsCallback;
|
|
import androidx.browser.customtabs.CustomTabsClient;
|
|
import androidx.browser.customtabs.CustomTabsServiceConnection;
|
|
import androidx.browser.customtabs.CustomTabsSession;
|
|
import com.ea.nimble.Log;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class WebView extends Activity {
|
|
private static CustomTabsSession mSession;
|
|
private static WebViewCallback s_callback;
|
|
private CustomTabsClient mClient;
|
|
private CustomTabsServiceConnection mConnection;
|
|
private String m_redirectUrl;
|
|
android.webkit.WebView m_webView = null;
|
|
|
|
public static CustomTabsSession getCustomTabServiceSession() {
|
|
return mSession;
|
|
}
|
|
|
|
private void createCustomTabsServiceConnection() {
|
|
if (this.mConnection == null) {
|
|
this.mConnection = new CustomTabsServiceConnection() { // from class: com.ea.nimble.WebView.1
|
|
@Override // androidx.browser.customtabs.CustomTabsServiceConnection
|
|
public void onCustomTabsServiceConnected(@NonNull ComponentName componentName, @NonNull CustomTabsClient customTabsClient) {
|
|
WebView.this.mClient = customTabsClient;
|
|
WebView.this.mClient.warmup(0L);
|
|
CustomTabsSession unused = WebView.mSession = WebView.this.mClient.newSession(new CustomTabsCallback());
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceDisconnected(ComponentName componentName) {
|
|
WebView.this.mClient = null;
|
|
CustomTabsSession unused = WebView.mSession = null;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
private void bindCustomTabService(Context context) {
|
|
createCustomTabsServiceConnection();
|
|
if (this.mClient != null || CustomTabActivity.getCustomTabsPackageToUse(getApplicationContext()) == null || this.mConnection == null) {
|
|
return;
|
|
}
|
|
CustomTabsClient.bindCustomTabsService(context, CustomTabActivity.getCustomTabsPackageToUse(getApplicationContext()), this.mConnection);
|
|
}
|
|
|
|
@Override // android.app.Activity, android.content.ComponentCallbacks
|
|
@SuppressLint({"SourceLockedOrientationActivity"})
|
|
public void onConfigurationChanged(Configuration configuration) {
|
|
super.onConfigurationChanged(configuration);
|
|
int i = configuration.orientation;
|
|
if (i == 2) {
|
|
setRequestedOrientation(0);
|
|
} else if (i == 1) {
|
|
setRequestedOrientation(1);
|
|
}
|
|
}
|
|
|
|
@Override // android.app.Activity
|
|
public void onBackPressed() {
|
|
if (s_callback != null) {
|
|
invokeCallback("");
|
|
}
|
|
super.onBackPressed();
|
|
}
|
|
|
|
@Override // android.app.Activity
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
Bundle extras = getIntent().getExtras();
|
|
String string = extras.getString("Redirect_URL");
|
|
if (string == null || string.isEmpty()) {
|
|
string = "";
|
|
}
|
|
this.m_redirectUrl = string;
|
|
String string2 = extras.getString("Oauth_URL");
|
|
if (string2.isEmpty()) {
|
|
Log.Helper.LOGE(this, "[onCreate] Error: Url is missing", new Object[0]);
|
|
invokeCallback("");
|
|
finish();
|
|
return;
|
|
}
|
|
if (this.m_redirectUrl.isEmpty()) {
|
|
Log.Helper.LOGE(this, "[onCreate] Error: Redirect Url is missing", new Object[0]);
|
|
invokeCallback("");
|
|
finish();
|
|
return;
|
|
}
|
|
if (CustomTabActivity.isCustomTabSupported(getApplicationContext()) && !this.m_redirectUrl.startsWith("http") && Build.VERSION.SDK_INT > 28) {
|
|
bindCustomTabService(this);
|
|
Intent intent = new Intent(this, (Class<?>) CustomTabActivity.class);
|
|
intent.putExtra(Constants.EXTRA_URL, string2);
|
|
intent.putExtra(Constants.EXTRA_REDIRECT_URL, this.m_redirectUrl);
|
|
intent.addFlags(603979776);
|
|
try {
|
|
Log.Helper.LOGD(this, "[onCreate] Using CustomTab", new Object[0]);
|
|
startActivityForResult(intent, 100);
|
|
return;
|
|
} catch (Exception e) {
|
|
System.out.println(e);
|
|
invokeCallback("");
|
|
finish();
|
|
return;
|
|
}
|
|
}
|
|
Log.Helper.LOGD(this, "[onCreate] Using WebView", new Object[0]);
|
|
this.m_webView = new android.webkit.WebView(this);
|
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
|
|
layoutParams.addRule(14);
|
|
layoutParams.addRule(15);
|
|
this.m_webView.setLayoutParams(layoutParams);
|
|
this.m_webView.getSettings().setJavaScriptEnabled(true);
|
|
this.m_webView.getSettings().setDomStorageEnabled(true);
|
|
if (extras.containsKey("Oauth_URL")) {
|
|
Log.Helper.LOGD(this, "[onCreate] Using WebView URL: " + string2, new Object[0]);
|
|
this.m_webView.loadUrl(string2);
|
|
this.m_webView.setWebViewClient(new WebViewClient() { // from class: com.ea.nimble.WebView.2
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageStarted(android.webkit.WebView webView, String str, Bitmap bitmap) {
|
|
if (str.contains(WebView.this.m_redirectUrl)) {
|
|
WebView.this.finish();
|
|
WebView.this.invokeCallback(str);
|
|
} else {
|
|
super.onPageStarted(webView, str, bitmap);
|
|
}
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public boolean shouldOverrideUrlLoading(android.webkit.WebView webView, String str) {
|
|
if (str.contains(WebView.this.m_redirectUrl)) {
|
|
WebView.this.finish();
|
|
WebView.this.invokeCallback(str);
|
|
return true;
|
|
}
|
|
return super.shouldOverrideUrlLoading(webView, str);
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public boolean shouldOverrideUrlLoading(android.webkit.WebView webView, WebResourceRequest webResourceRequest) {
|
|
String uri = webResourceRequest.getUrl().toString();
|
|
if (uri.contains(WebView.this.m_redirectUrl)) {
|
|
WebView.this.finish();
|
|
WebView.this.invokeCallback(uri);
|
|
return true;
|
|
}
|
|
return super.shouldOverrideUrlLoading(webView, webResourceRequest);
|
|
}
|
|
});
|
|
}
|
|
RelativeLayout relativeLayout = new RelativeLayout(this);
|
|
relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
|
|
relativeLayout.addView(this.m_webView);
|
|
setContentView(relativeLayout);
|
|
}
|
|
|
|
@Override // android.app.Activity
|
|
public void onNewIntent(Intent intent) {
|
|
super.onNewIntent(intent);
|
|
setResult(-1, intent);
|
|
finish();
|
|
}
|
|
|
|
@Override // android.app.Activity
|
|
public void onDestroy() {
|
|
Log.Helper.LOGD(this, "[onDestroy] Browser will be disposed", new Object[0]);
|
|
this.m_webView = null;
|
|
CustomTabsServiceConnection customTabsServiceConnection = this.mConnection;
|
|
if (customTabsServiceConnection != null) {
|
|
unbindService(customTabsServiceConnection);
|
|
this.mConnection = null;
|
|
}
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override // android.app.Activity
|
|
public void onActivityResult(int i, int i2, Intent intent) {
|
|
super.onActivityResult(i, i2, intent);
|
|
Bundle extras = intent != null ? intent.getExtras() : new Bundle();
|
|
String string = extras.getString(Constants.EXTRA_URL, "");
|
|
if (i == 100) {
|
|
if (i2 == -1) {
|
|
if (string.contains(this.m_redirectUrl)) {
|
|
invokeCallback(string);
|
|
}
|
|
Log.Helper.LOGD(this, "[onActivityResult] Succeeded with callback url: " + string, new Object[0]);
|
|
} else if (i2 == 0) {
|
|
Log.Helper.LOGE(this, "[onActivityResult] Browser canceled.", new Object[0]);
|
|
invokeCallback("");
|
|
} else if (i2 == 10) {
|
|
Log.Helper.LOGE(this, "[onActivityResult] Error: " + extras.getString(Constants.EXTRA_ERROR, ""), new Object[0]);
|
|
invokeCallback("");
|
|
}
|
|
finish();
|
|
}
|
|
Log.Helper.LOGE(this, "[onActivityResult] Error: Unknown activity result. requestCode=" + i + " | resultCode=" + i2, new Object[0]);
|
|
invokeCallback("");
|
|
finish();
|
|
}
|
|
|
|
public static void showAuthView(String str, String str2, WebViewCallback webViewCallback) {
|
|
Activity currentActivity = ApplicationEnvironment.getCurrentActivity();
|
|
Intent intent = new Intent(currentActivity, (Class<?>) WebView.class);
|
|
intent.putExtra("Oauth_URL", str);
|
|
intent.putExtra("Redirect_URL", str2);
|
|
s_callback = webViewCallback;
|
|
currentActivity.startActivity(intent);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void invokeCallback(String str) {
|
|
if (s_callback != null) {
|
|
Log.Helper.LOGD(this, "invokeCallback s_callback with URL: " + str, new Object[0]);
|
|
s_callback.callback(str, new Runnable() { // from class: com.ea.nimble.WebView$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
WebView.this.lambda$invokeCallback$0();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public /* synthetic */ void lambda$invokeCallback$0() {
|
|
s_callback = null;
|
|
Log.Helper.LOGD(this, "s_callback marked as null ", new Object[0]);
|
|
}
|
|
}
|