VMOS Pro v2.9.9版本的 MD5 值为:dceadad381c71b757ecb2d1f07ea613a
以下内容为反编译后的 WebViewActivity.java 源代码,内容仅作参考
package com.vmos.pro.ui.protocol;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import com.alipay.sdk.cons.b;
import com.luck.picture.lib.basic.PictureSelector;
import com.luck.picture.lib.config.SelectMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.interfaces.OnResultCallbackListener;
import com.tencent.mars.xlog.Log;
import com.vmos.pro.R;
import com.vmos.pro.vmsupport.TopNotificationPopup;
import java.io.File;
import java.util.ArrayList;
public class WebViewActivity extends AppCompatActivity {
public static final int f12155 = 101;
public View f12156;
public View f12157;
public boolean f12158;
public String f12159;
public String f12160;
public View f12161;
public ValueCallback<Uri[]> f12162;
public File f12163;
public WebView f12164;
public int f12165 = 100;
public Uri f12166;
public class View$OnClickListenerC2089 implements View.OnClickListener {
public View$OnClickListenerC2089() {
}
@Override
public void onClick(View view) {
WebViewActivity.this.finish();
}
}
public class View$OnClickListenerC2090 implements View.OnClickListener {
public View$OnClickListenerC2090() {
}
@Override
public void onClick(View view) {
WebViewActivity webViewActivity = WebViewActivity.this;
webViewActivity.f12158 = false;
webViewActivity.f12156.setVisibility(8);
WebViewActivity.this.f12164.reload();
}
}
public class C2091 extends WebChromeClient {
public final ProgressBar f12170;
public class C2092 implements OnResultCallbackListener<LocalMedia> {
public C2092() {
}
@Override
public void onCancel() {
}
@Override
public void onResult(ArrayList<LocalMedia> arrayList) {
String str;
if (C7397.m55533(arrayList)) {
str = "";
} else {
str = arrayList.get(0).getCompressPath();
if (TextUtils.isEmpty(str)) {
str = arrayList.get(0).getPath();
}
}
Uri[] uriArr = {Uri.parse("file:" + str)};
ValueCallback<Uri[]> valueCallback = WebViewActivity.this.f12162;
if (valueCallback != null) {
valueCallback.onReceiveValue(uriArr);
WebViewActivity.this.f12162 = null;
}
}
}
public C2091(ProgressBar progressBar) {
this.f12170 = progressBar;
}
@Override
public void onProgressChanged(WebView webView, int i) {
this.f12170.setProgress(i);
if (i == 100) {
this.f12170.setVisibility(8);
}
}
@Override
public void onReceivedTitle(WebView webView, String str) {
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
WebViewActivity.this.log("onShowFileChooser");
String[] acceptTypes = fileChooserParams.getAcceptTypes();
r8 = "";
if (acceptTypes != null) {
for (String str : acceptTypes) {
WebViewActivity.this.log("type:" + str);
}
}
WebViewActivity.this.f12162 = valueCallback;
if (TextUtils.isEmpty(str)) {
PictureSelector.create((AppCompatActivity) WebViewActivity.this).openGallery(SelectMimeType.ofImage()).setSelectionMode(1).setImageSpanCount(4).setImageEngine(wn1.m49076()).setCropEngine(new i42()).setCompressEngine(new h42()).forResult(new C2092());
} else if (Build.VERSION.SDK_INT < 23) {
WebViewActivity.this.takePhoto();
} else if (ContextCompat.checkSelfPermission(WebViewActivity.this.getBaseContext(), "android.permission.CAMERA") == 0) {
WebViewActivity.this.takePhoto();
} else {
TopNotificationPopup.m15056(WebViewActivity.this, R.string.permission_camera, R.string.permission_camera_tip);
WebViewActivity webViewActivity = WebViewActivity.this;
ActivityCompat.requestPermissions(webViewActivity, new String[]{"android.permission.CAMERA"}, webViewActivity.f12165);
}
return true;
}
}
public static void m14839(Context context, String str, String str2) {
Intent intent = new Intent(context, WebViewActivity.class);
intent.putExtra("title", str);
intent.putExtra("url", str2);
C7580.m56052(context, intent);
}
public final void log(String str) {
Log.d("vmos-test", str);
}
@Override
public void onActivityResult(int i, int i2, @Nullable Intent intent) {
super.onActivityResult(i, i2, intent);
if (i2 == -1 && i == 101) {
Uri[] uriArr = {this.f12166};
ValueCallback<Uri[]> valueCallback = this.f12162;
if (valueCallback != null) {
valueCallback.onReceiveValue(uriArr);
this.f12162 = null;
}
}
ValueCallback<Uri[]> valueCallback2 = this.f12162;
if (valueCallback2 != null) {
valueCallback2.onReceiveValue(null);
this.f12162 = null;
}
log("onActivityResult photoPath:");
}
@Override
public void onCreate(@Nullable Bundle bundle) {
super.onCreate(bundle);
bw5.m4156(this);
getWindow().setStatusBarColor(bm4.m3643(R.color.dialogcolor));
setContentView(R.layout.activity_web);
this.f12156 = findViewById(R.id.rl_error);
this.f12157 = findViewById(R.id.tv_restart);
this.f12161 = findViewById(R.id.ll_content);
TextView textView = (TextView) findViewById(R.id.tv_wv_title);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.pb_progress);
this.f12164 = (WebView) findViewById(R.id.wv_commonWebView);
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll_back);
this.f12159 = getIntent().getStringExtra("title");
this.f12160 = getIntent().getStringExtra("url");
WebSettings settings = this.f12164.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setJavaScriptEnabled(true);
settings.setSaveFormData(true);
settings.setDomStorageEnabled(true);
settings.setSaveFormData(true);
settings.setSupportZoom(false);
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(true);
this.f12157.setOnClickListener(new View$OnClickListenerC2090());
if (Build.VERSION.SDK_INT >= 21) {
settings.setMixedContentMode(0);
}
this.f12164.setWebChromeClient(new C2091(progressBar));
this.f12164.setWebViewClient(new C2093());
progressBar.setVisibility(0);
this.f12164.loadUrl(this.f12160);
textView.setText(this.f12159);
linearLayout.setOnClickListener(new View$OnClickListenerC2089());
}
@Override
public void onDestroy() {
WebView webView = this.f12164;
if (webView != null) {
ViewParent parent = webView.getParent();
if (parent != null) {
((ViewGroup) parent).removeView(this.f12164);
}
this.f12164.stopLoading();
this.f12164.getSettings().setJavaScriptEnabled(false);
this.f12164.clearHistory();
this.f12164.removeAllViews();
this.f12164.destroy();
}
super.onDestroy();
}
@Override
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (i == 4 && this.f12164.canGoBack()) {
this.f12164.goBack();
return true;
}
return super.onKeyDown(i, keyEvent);
}
@Override
public void onPause() {
super.onPause();
Intent intent = getIntent();
if (intent == null || !intent.getBooleanExtra("rom_tutorial", false)) {
return;
}
moveTaskToBack(true);
}
@Override
public void onRequestPermissionsResult(int i, @NonNull String[] strArr, @NonNull int[] iArr) {
super.onRequestPermissionsResult(i, strArr, iArr);
if (i == this.f12165) {
if (iArr != null && iArr.length > 0 && iArr[0] == 0) {
takePhoto();
} else {
oz5.m35335(this, getString(R.string.update_userinfo_2));
}
}
}
public final void takePhoto() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
if (intent.resolveActivity(getPackageManager()) != null) {
File m50902 = xt5.m50902(this);
this.f12163 = m50902;
if (m50902 != null) {
if (Build.VERSION.SDK_INT >= 24) {
this.f12166 = FileProvider.getUriForFile(this, xy.f41615 + ".fileProvider", this.f12163);
} else {
this.f12166 = Uri.fromFile(m50902);
}
intent.putExtra("output", this.f12166);
startActivityForResult(intent, 101);
}
}
}
public class C2093 extends WebViewClient {
public C2093() {
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
WebViewActivity webViewActivity = WebViewActivity.this;
if (!webViewActivity.f12158) {
webViewActivity.f12164.setVisibility(0);
webView.loadUrl("javascript:(function() {var body = document.getElementsByTagName('body');\nvar footer = document.getElementById('footer');\n\nvar navbar = document.getElementsByClassName('navbar');\n\n\ntry{\nbody[0].removeChild(footer);\n}catch(err){\n\n}\n\ntry{\nbody[0].removeChild(navbar[0]);\n}catch(err){\n\n} })()");
return;
}
webViewActivity.f12156.setVisibility(0);
WebViewActivity.this.f12164.setVisibility(4);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
if (str.startsWith(ku.f23765)) {
webView.stopLoading();
C7580.m56052(WebViewActivity.this, new Intent("android.intent.action.VIEW", Uri.parse(str)));
WebViewActivity.this.finish();
return;
}
super.onPageStarted(webView, str, bitmap);
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
try {
if (TextUtils.equals(str, WebViewActivity.this.f12160) || TextUtils.equals(WebViewActivity.this.f12160, str2)) {
WebViewActivity.this.f12158 = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
try {
if (TextUtils.equals(webResourceRequest.getUrl().toString(), WebViewActivity.this.f12160)) {
WebViewActivity.this.f12158 = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
@Nullable
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
if (!WebViewActivity.this.f12160.startsWith(wy1.f40130) && !WebViewActivity.this.f12160.startsWith(b.f48843a)) {
WebViewActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(WebViewActivity.this.f12160)));
return null;
}
return super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
if (!str.contains(ku.f23789) && !str.contains("alipays://")) {
webView.loadUrl(str);
return true;
}
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
WebViewActivity.this.startActivity(intent);
return true;
}
@Override
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
super.onReceivedError(webView, webResourceRequest, webResourceError);
try {
if (TextUtils.equals(webResourceRequest.getUrl().toString(), WebViewActivity.this.f12160)) {
WebViewActivity.this.f12158 = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}