正在查看: Vi App v10.18.0 应用的 NPDWebActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Vi App v10.18.0 应用的 NPDWebActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.viapps.viappwebview;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import com.viapps.elk.KibanaUtility;
import in.juspay.hyper.constants.LogSubCategory;
import in.juspay.hypersdk.core.PaymentConstants;
import kotlin.Deprecated;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.text.StringsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
public class NPDWebActivity extends AppCompatActivity {
@NotNull
public static final Companion Companion = new Companion(null);
@Nullable
private View errorView;
private boolean isWebViewDestroyed;
@Nullable
private NetworkUtil networkUtil;
@Nullable
private ProgressBar progressBar;
@Nullable
private ValueCallback<Uri[]> uploadMessage;
@Nullable
private String url;
@Nullable
private WebView webViewNPD;
public static final class Companion {
private Companion() {
}
public Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
public final void handleBackPressed() {
WebView webView = this.webViewNPD;
if (Intrinsics.areEqual(webView != null ? webView.getUrl() : null, "https://games.myvi.in/cavil/home")) {
finish();
return;
}
WebView webView2 = this.webViewNPD;
if (webView2 != null && webView2.isFocused()) {
WebView webView3 = this.webViewNPD;
if (webView3 != null && webView3.canGoBack()) {
WebView webView4 = this.webViewNPD;
if (webView4 != null) {
webView4.goBack();
return;
}
return;
}
}
super/*androidx.activity.ComponentActivity*/.onBackPressed();
finish();
}
private final JSONObject modifyJsonObject(String str, String str2) {
try {
JSONObject jSONObject = new JSONObject(String.valueOf(str));
jSONObject.getJSONObject("NativeMap").put("msisdn", str2);
return jSONObject;
} catch (Exception e2) {
e2.printStackTrace();
return null;
}
}
public static final void onCreate$lambda$0(NPDWebActivity nPDWebActivity, String str, String str2, String str3, String str4, long j) {
Intrinsics.checkNotNullParameter(nPDWebActivity, "this$0");
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str));
request.setMimeType(str4);
request.addRequestHeader("cookie", CookieManager.getInstance().getCookie(str));
request.addRequestHeader("User-Agent", str2);
request.setDescription("Downloading File...");
request.setTitle(URLUtil.guessFileName(str, str3, str4));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(1);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(str, str3, str4));
Object systemService = nPDWebActivity.getApplicationContext().getSystemService("download");
Intrinsics.checkNotNull(systemService, "null cannot be cast to non-null type android.app.DownloadManager");
((DownloadManager) systemService).enqueue(request);
Toast.makeText(nPDWebActivity.getApplicationContext(), "Downloading File", 1).show();
}
private final void safelyDestroyWebView(final WebView webView) {
if (this.isWebViewDestroyed) {
return;
}
if (webView != null) {
webView.loadUrl("about:blank");
}
ViewParent parent = webView != null ? webView.getParent() : null;
ViewGroup viewGroup = parent instanceof ViewGroup ? (ViewGroup) parent : null;
if (viewGroup != null) {
viewGroup.removeView(webView);
}
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public final void run() {
NPDWebActivity.safelyDestroyWebView$lambda$3(webView, this);
}
}, 300L);
}
public static final void safelyDestroyWebView$lambda$3(WebView webView, NPDWebActivity nPDWebActivity) {
Intrinsics.checkNotNullParameter(nPDWebActivity, "this$0");
if (webView != null) {
try {
webView.removeAllViews();
} catch (Exception unused) {
return;
}
}
if (webView != null) {
webView.clearHistory();
}
if (webView != null) {
webView.clearCache(true);
}
if (webView != null) {
webView.destroy();
}
nPDWebActivity.isWebViewDestroyed = true;
}
@Nullable
public final ProgressBar getProgressBar() {
return this.progressBar;
}
@Nullable
public final ValueCallback<Uri[]> getUploadMessage() {
return this.uploadMessage;
}
@Nullable
public final WebView getWebViewNPD() {
return this.webViewNPD;
}
@Deprecated(message = "Deprecated in Java")
public void onActivityResult(int i2, int i3, @Nullable Intent intent) {
ValueCallback<Uri[]> valueCallback;
super/*androidx.fragment.app.FragmentActivity*/.onActivityResult(i2, i3, intent);
if (i2 != 101 || (valueCallback = this.uploadMessage) == null) {
return;
}
Intrinsics.checkNotNull(valueCallback);
valueCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(i3, intent));
this.uploadMessage = null;
}
@Deprecated(message = "Deprecated in Java")
@SuppressLint({"MissingSuperCall"})
public void onBackPressed() {
handleBackPressed();
}
@SuppressLint({"SetJavaScriptEnabled"})
public void onCreate(@Nullable Bundle bundle) {
String str;
super/*androidx.fragment.app.FragmentActivity*/.onCreate(bundle);
setContentView(R.layout.activity_vi_npd);
View findViewById = findViewById(R.id.vi_npd_native_webview_sdk);
Intrinsics.checkNotNull(findViewById, "null cannot be cast to non-null type android.webkit.WebView");
this.webViewNPD = (WebView) findViewById;
this.errorView = findViewById(R.id.vi_npd_errorView_sdk);
NetworkUtil networkUtil = new NetworkUtil(this);
this.networkUtil = networkUtil;
Intrinsics.checkNotNull(networkUtil);
WebView webView = this.webViewNPD;
Intrinsics.checkNotNull(webView);
View view = this.errorView;
Intrinsics.checkNotNull(view);
networkUtil.checkNetworkAndShowError(this, webView, view);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
if ((getIntent().getStringExtra("title") != null || getIntent().getStringExtra("title") != "") && supportActionBar != null) {
supportActionBar.setTitle(getIntent().getStringExtra("title"));
}
if (checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == -1) {
requestPermissions(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
}
View findViewById2 = findViewById(R.id.vi_npd_native_progressBar_sdk);
Intrinsics.checkNotNull(findViewById2, "null cannot be cast to non-null type android.widget.ProgressBar");
this.progressBar = (ProgressBar) findViewById2;
String stringExtra = getIntent().getStringExtra(PaymentConstants.URL);
this.url = stringExtra;
boolean z = false;
if (stringExtra != null) {
if (stringExtra.length() == 0) {
z = true;
}
}
if (z) {
finish();
}
WebView webView2 = this.webViewNPD;
WebSettings settings = webView2 != null ? webView2.getSettings() : null;
if (settings != null) {
settings.setDomStorageEnabled(true);
}
if (settings != null) {
settings.setCacheMode(1);
}
if (settings != null) {
settings.setLoadWithOverviewMode(true);
}
if (settings != null) {
settings.setUseWideViewPort(true);
}
if (settings != null) {
settings.setAllowFileAccessFromFileURLs(true);
}
if (settings != null) {
settings.setAllowUniversalAccessFromFileURLs(true);
}
if (settings != null) {
settings.setJavaScriptEnabled(true);
}
WebView webView3 = this.webViewNPD;
if (webView3 != null) {
webView3.setInitialScale(1);
}
WebView webView4 = this.webViewNPD;
if (webView4 != null) {
webView4.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onShowFileChooser(@NotNull WebView webView5, @NotNull ValueCallback<Uri[]> valueCallback, @NotNull WebChromeClient.FileChooserParams fileChooserParams) {
Intrinsics.checkNotNullParameter(webView5, "mWebView");
Intrinsics.checkNotNullParameter(valueCallback, "filePathCallback");
Intrinsics.checkNotNullParameter(fileChooserParams, "fileChooserParams");
if (NPDWebActivity.this.getUploadMessage() != null) {
ValueCallback<Uri[]> uploadMessage = NPDWebActivity.this.getUploadMessage();
Intrinsics.checkNotNull(uploadMessage);
uploadMessage.onReceiveValue(null);
NPDWebActivity.this.setUploadMessage(null);
}
NPDWebActivity.this.setUploadMessage(valueCallback);
Intent createIntent = fileChooserParams.createIntent();
try {
Context context = webView5.getContext();
Intrinsics.checkNotNull(context, "null cannot be cast to non-null type android.app.Activity");
((Activity) context).startActivityForResult(createIntent, 101);
return true;
} catch (Exception unused) {
valueCallback.onReceiveValue(null);
return true;
}
}
});
}
WebView webView5 = this.webViewNPD;
if (webView5 != null) {
webView5.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(@NotNull WebView webView6, @NotNull String str2) {
View view2;
Intrinsics.checkNotNullParameter(webView6, "view");
Intrinsics.checkNotNullParameter(str2, PaymentConstants.URL);
ProgressBar progressBar = NPDWebActivity.this.getProgressBar();
Intrinsics.checkNotNull(progressBar);
progressBar.setVisibility(8);
WebView webViewNPD = NPDWebActivity.this.getWebViewNPD();
if (webViewNPD != null) {
webViewNPD.setVisibility(0);
}
view2 = NPDWebActivity.this.errorView;
if (view2 == null) {
return;
}
view2.setVisibility(8);
}
@Override
public void onPageStarted(@NotNull WebView webView6, @NotNull String str2, @Nullable Bitmap bitmap) {
View view2;
Intrinsics.checkNotNullParameter(webView6, "view");
Intrinsics.checkNotNullParameter(str2, PaymentConstants.URL);
ProgressBar progressBar = NPDWebActivity.this.getProgressBar();
Intrinsics.checkNotNull(progressBar);
progressBar.setVisibility(8);
WebView webViewNPD = NPDWebActivity.this.getWebViewNPD();
if (webViewNPD != null) {
webViewNPD.setVisibility(0);
}
view2 = NPDWebActivity.this.errorView;
if (view2 == null) {
return;
}
view2.setVisibility(8);
}
@Override
@Deprecated(message = "Deprecated in Java")
public void onReceivedError(@NotNull WebView webView6, int i2, @NotNull String str2, @NotNull String str3) {
Intrinsics.checkNotNullParameter(webView6, "view");
Intrinsics.checkNotNullParameter(str2, "description");
Intrinsics.checkNotNullParameter(str3, "failingUrl");
ProgressBar progressBar = NPDWebActivity.this.getProgressBar();
Intrinsics.checkNotNull(progressBar);
progressBar.setVisibility(8);
NPDWebActivity.this.setUrl(str3);
super.onReceivedError(webView6, i2, str2, str3);
if (StringsKt.startsWith$default(str3, "tel:", false, 2, (Object) null)) {
NPDWebActivity.this.handleBackPressed();
}
NPDWebActivity.this.sendData(i2, str2);
Toast.makeText(NPDWebActivity.this.getApplicationContext(), "Sorry, something went wrong. Please try again", 1).show();
}
@Override
public boolean onRenderProcessGone(@Nullable WebView webView6, @Nullable RenderProcessGoneDetail renderProcessGoneDetail) {
return true;
}
@Override
@Deprecated(message = "Deprecated in Java")
public boolean shouldOverrideUrlLoading(@NotNull WebView webView6, @NotNull String str2) {
WebView webViewNPD;
Intrinsics.checkNotNullParameter(webView6, "wv");
Intrinsics.checkNotNullParameter(str2, PaymentConstants.URL);
if (!StringsKt.contains$default(str2, "vi.app.link", false, 2, (Object) null) && !StringsKt.contains$default(str2, "mva.page.link", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "intent:", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "mailto:", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "maps:", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "geo:", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "sms:", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "whatsapp", false, 2, (Object) null) && !StringsKt.startsWith$default(str2, "tel:", false, 2, (Object) null)) {
return false;
}
try {
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str2));
NPDWebActivity.this.startActivity(intent);
if (!StringsKt.startsWith$default(str2, "tel:", false, 2, (Object) null) && (webViewNPD = NPDWebActivity.this.getWebViewNPD()) != null) {
webViewNPD.goBack();
}
} catch (ActivityNotFoundException unused) {
Toast.makeText(NPDWebActivity.this.getApplicationContext(), "Sorry, something went wrong. Please try again", 1).show();
}
return true;
}
@Override
public void onReceivedError(@NotNull WebView webView6, @NotNull WebResourceRequest webResourceRequest, @NotNull WebResourceError webResourceError) {
Intrinsics.checkNotNullParameter(webView6, "view");
Intrinsics.checkNotNullParameter(webResourceRequest, "request");
Intrinsics.checkNotNullParameter(webResourceError, "error");
super.onReceivedError(webView6, webResourceRequest, webResourceError);
}
});
}
WebView webView6 = this.webViewNPD;
if (webView6 != null) {
webView6.addJavascriptInterface(new NPDWebActivity$onCreate$3(this), "ReactNativeWebView");
}
WebView webView7 = this.webViewNPD;
if (webView7 != null) {
webView7.setDownloadListener(new DownloadListener() {
@Override
public final void onDownloadStart(String str2, String str3, String str4, String str5, long j) {
NPDWebActivity.onCreate$lambda$0(NPDWebActivity.this, str2, str3, str4, str5, j);
}
});
}
WebView webView8 = this.webViewNPD;
if (webView8 == null || (str = this.url) == null) {
return;
}
webView8.getSettings().setJavaScriptEnabled(true);
webView8.loadUrl(str);
}
public void onDestroy() {
super.onDestroy();
safelyDestroyWebView(this.webViewNPD);
}
public boolean onOptionsItemSelected(@NotNull MenuItem menuItem) {
Intrinsics.checkNotNullParameter(menuItem, "item");
if (menuItem.getItemId() != 16908332) {
return super/*android.app.Activity*/.onOptionsItemSelected(menuItem);
}
onBackPressed();
return true;
}
public void onResume() {
super/*androidx.fragment.app.FragmentActivity*/.onResume();
}
public final void sendData(int i2, @Nullable String str) {
try {
Object obj = getApplication().getPackageManager().getPackageInfo(getApplication().getPackageName(), 0).versionName;
try {
JSONObject jSONObject = new JSONObject();
jSONObject.put("module", getIntent().getStringExtra("title"));
jSONObject.put(PaymentConstants.PAYLOAD, modifyJsonObject(getIntent().getStringExtra("userObj"), getIntent().getStringExtra("encryptedMsisdn")));
jSONObject.put("APIName", this.url);
jSONObject.put("deviceModel", Build.MODEL);
jSONObject.put("deviceOSVersion", LogSubCategory.LifeCycle.ANDROID);
jSONObject.put("deviceManufacturer", Build.MANUFACTURER);
jSONObject.put("appVersion", obj);
jSONObject.put("MSISDN", getIntent().getStringExtra("msisdn"));
JSONObject jSONObject2 = new JSONObject();
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("errorCode", i2);
jSONObject3.put("errorMessage", str);
jSONObject2.put("data", jSONObject3);
jSONObject.put("APIResponse", jSONObject2);
KibanaUtility kibanaUtility = KibanaUtility.INSTANCE;
new KibanaUtility.CallBack() {
@Override
public void onFailure(@Nullable String str2) {
}
@Override
public void onSuccess(@Nullable String str2) {
}
};
c.a();
} catch (Exception e2) {
e2.printStackTrace();
}
} catch (PackageManager.NameNotFoundException e3) {
throw new RuntimeException(e3);
}
}
public final void setUploadMessage(@Nullable ValueCallback<Uri[]> valueCallback) {
this.uploadMessage = valueCallback;
}
public final void setUrl(@Nullable String str) {
this.url = str;
}
}