i自然 v1.5.2版本的 MD5 值为:4186de3133535afd3ad8a76e7e4d0eff
以下内容为反编译后的 CmsMainActivity.java 源代码,内容仅作参考
package com.mnr.app.cms.view;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.ValueCallback;
import android.widget.ImageView;
import androidx.core.app.ActivityCompat;
import com.mnr.app.R;
import com.mnr.app.app.AppCache;
import com.mnr.app.cms.CommonWebViewListener;
import com.mnr.app.cms.SuperBaseActivity;
import com.mnr.app.cms.X5CommonWebViewClient;
import com.mnr.app.cms.X5WebCreate;
import com.mnr.app.cms.util.Constant;
import com.mnr.app.cms.util.SharedPreferencesUtil;
import com.mnr.app.cms.util.UtilsNet;
import com.tencent.smtt.export.external.interfaces.GeolocationPermissionsCallback;
import com.tencent.smtt.export.external.interfaces.JsResult;
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebView;
public class CmsMainActivity extends SuperBaseActivity implements View.OnTouchListener {
private static final int FILE_CHOOSER_REQUEST = 100;
private static final int FLING_MIN_DISTANCE = 50;
private static final int FLING_MIN_VELOCITY = 0;
public static final String[] PERMISSIONS_LOCATION = {"android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION"};
public static final int REQUEST_EXTERNAL_STORAGE = 1;
public static final int REQUEST_GEOLOCATION = 2;
private X5CommonWebViewClient commonWebViewClient;
private boolean isShowTitleBar;
private ImageView iv_btn_back;
private String locationPermissionUrl;
private View mButtonClose;
private View mErrorView;
private long mExitTime;
private ValueCallback<Uri[]> mFilePathCallback;
private GeolocationPermissionsCallback mGeolocationCallback;
private GestureDetector mGestureDetector;
private long mLastBackTimeMill;
private View mSettingView;
private WebView mWebView;
private String title;
private ViewGroup webview_view;
private String webViewUrl = "http://cms.iziran.net/";
private String urls = "";
private String TAG = "MainActivity";
public final String[] mRoomPermission = {"android.permission.CAMERA", "android.permission.BLUETOOTH", "android.permission.RECORD_AUDIO", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"};
private boolean isError = false;
private boolean showMainFrameError = false;
GestureDetector.SimpleOnGestureListener myGestureListener = new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
Log.e("<--滑动测试-->", "开始滑动");
float x = e1.getX() - e2.getX();
float x2 = e2.getX() - e1.getX();
if ((x > 50.0f && Math.abs(velocityX) > 0.0f) || x2 <= 50.0f) {
return true;
}
Math.abs(velocityX);
return true;
}
};
public void forwardToLiveRoom(int cRole) {
}
@Override
protected int getResLayoutId() {
return R.layout.activity_cms_main;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SharedPreferencesUtil.newInstance(this, Constant.SP_KEY_SERVERCONFIG);
SharedPreferencesUtil.saveBoolean(Constant.IS_FIRST_LOGIN, false);
initWebView();
setSwipeBackEnable(false);
if (Build.VERSION.SDK_INT >= 23) {
ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.READ_LOGS", "android.permission.READ_PHONE_STATE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.SET_DEBUG_APP", "android.permission.SYSTEM_ALERT_WINDOW", "android.permission.GET_ACCOUNTS", "android.permission.WRITE_APN_SETTINGS", "android.permission.CAMERA", "android.permission.BLUETOOTH", "android.permission.RECORD_AUDIO"}, 123);
}
this.mGestureDetector = new GestureDetector(this, this.myGestureListener);
}
@Override
public void initView() {
super.initView();
this.mButtonClose = findViewById(R.id.button_close);
this.mErrorView = findViewById(R.id.error_layout);
this.mSettingView = findViewById(R.id.image_setting);
this.webview_view = (ViewGroup) findViewById(R.id.parent_view);
this.mErrorView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
CmsMainActivity.this.lambda$initView$0$CmsMainActivity(view);
}
});
this.mButtonClose.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
CmsMainActivity.this.lambda$initView$1$CmsMainActivity(view);
}
});
}
public void lambda$initView$0$CmsMainActivity(View view) {
this.mWebView.loadUrl(this.webViewUrl);
}
public void lambda$initView$1$CmsMainActivity(View view) {
finish();
}
private void initWebView() {
X5CommonWebViewClient x5CommonWebViewClient = new X5CommonWebViewClient(this) {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return CmsMainActivity.this.shouldOverrideDO(url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
return CmsMainActivity.this.shouldOverrideDO(webResourceRequest.getUrl().toString());
}
};
this.commonWebViewClient = x5CommonWebViewClient;
x5CommonWebViewClient.setCommonWebViewListener(new CommonWebViewListener() {
@Override
public void onPageStarted() {
CmsMainActivity.this.mErrorView.setVisibility(8);
CmsMainActivity.this.isError = false;
}
@Override
public void onPageFinished() {
if (!CmsMainActivity.this.showMainFrameError || UtilsNet.checkNet(CmsMainActivity.this)) {
if (CmsMainActivity.this.isError || CmsMainActivity.this.urls.contains("login-index.html")) {
CmsMainActivity.this.mSettingView.setVisibility(0);
return;
} else {
CmsMainActivity.this.mSettingView.setVisibility(8);
return;
}
}
CmsMainActivity.this.mErrorView.setVisibility(0);
CmsMainActivity.this.mSettingView.setVisibility(0);
CmsMainActivity.this.showMainFrameError = false;
}
@Override
public void OnPageError() {
Log.e("123", "============OnPageError=============");
CmsMainActivity.this.isError = true;
CmsMainActivity.this.mErrorView.setVisibility(0);
CmsMainActivity.this.mSettingView.setVisibility(0);
}
});
WebView webView = new X5WebCreate().initWebView(this, this.webview_view).setConfig().get();
this.mWebView = webView;
webView.setWebViewClient(this.commonWebViewClient);
this.mWebView.setWebChromeClient(new AnonymousClass3());
AppCache.INSTANCE.getAndSetX5Cookie(this.webViewUrl + Constant.loginUrl);
this.mWebView.loadUrl(this.webViewUrl + Constant.loginUrl);
}
public class AnonymousClass3 extends WebChromeClient {
AnonymousClass3() {
}
@Override
public boolean onJsAlert(WebView webView, String s, String message, final JsResult jsResult) {
new AlertDialog.Builder(CmsMainActivity.this).setTitle("JS弹窗Override").setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
JsResult.this.confirm();
}
}).setCancelable(false).show();
return true;
}
@Override
public boolean onJsConfirm(WebView webView, String s, String message, final JsResult result) {
new AlertDialog.Builder(CmsMainActivity.this).setTitle("JS弹窗Override").setMessage(message).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
JsResult.this.confirm();
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
JsResult.this.cancel();
}
}).setCancelable(false).show();
return true;
}
@Override
public boolean onJsBeforeUnload(WebView webView, String s, String s1, final JsResult jsResult) {
new AlertDialog.Builder(CmsMainActivity.this).setTitle("页面即将跳转").setMessage(s1).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
JsResult.this.confirm();
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
JsResult.this.cancel();
}
}).setCancelable(false).show();
return true;
}
@Override
public boolean onShowFileChooser(WebView webView, com.tencent.smtt.sdk.ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
CmsMainActivity.this.mFilePathCallback = filePathCallback;
CmsMainActivity.this.openFileChooseProcess(fileChooserParams.getMode() == 1);
return true;
}
@Override
public void onGeolocationPermissionsHidePrompt() {
super.onGeolocationPermissionsHidePrompt();
}
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback callback) {
super.onGeolocationPermissionsShowPrompt(origin, callback);
if (!CmsMainActivity.verifyLocationPermissions(CmsMainActivity.this)) {
CmsMainActivity.this.locationPermissionUrl = origin;
CmsMainActivity.this.mGeolocationCallback = callback;
} else {
callback.invoke(origin, true, false);
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1) {
initWebView();
}
GeolocationPermissionsCallback geolocationPermissionsCallback = this.mGeolocationCallback;
if (geolocationPermissionsCallback == null || requestCode != 2) {
return;
}
geolocationPermissionsCallback.invoke(this.locationPermissionUrl, grantResults[0] == 0, false);
this.mGeolocationCallback = null;
this.locationPermissionUrl = "";
}
@Override
public void getIntentData(Intent intent) {
super.getIntentData(intent);
this.title = intent.getStringExtra("title");
boolean booleanExtra = intent.getBooleanExtra("isShowTitleBar", false);
this.isShowTitleBar = booleanExtra;
isShowTitle(booleanExtra);
setTitle(this.title);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.e("123", "onTouch===============" + this.urls);
if (this.urls.contains("login-index.html")) {
return this.mGestureDetector.onTouchEvent(event);
}
return super.onTouchEvent(event);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == 4) {
if (this.mWebView.canGoBack()) {
this.mWebView.goBack();
return true;
}
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}
public boolean shouldOverrideDO(String url) {
this.urls = url;
if (url.contains("userinfo://userID=")) {
String str = url.substring(18, url.length()).split("&")[0];
this.mSettingView.postDelayed(new Runnable() {
@Override
public final void run() {
CmsMainActivity.this.lambda$shouldOverrideDO$2$CmsMainActivity();
}
}, 2000L);
}
if (url.contains("login-index.html")) {
this.mSettingView.setVisibility(0);
} else {
this.mSettingView.setVisibility(8);
}
if (url.contains("livemanager://userID")) {
return true;
}
if (!url.contains("videoconnect://")) {
return false;
}
String[] split = url.substring(15).split("&");
String str2 = split[0];
String str3 = split[1];
String str4 = split[2];
String str5 = split[3];
String str6 = split[4];
String str7 = split[5];
str2.substring(6);
str3.substring(6);
str4.substring(7);
str5.substring(7);
str6.substring(9);
str7.substring(9);
return true;
}
public void lambda$shouldOverrideDO$2$CmsMainActivity() {
Log.e("123", "-----------" + CookieManager.getInstance().getCookie(this.urls));
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode != 100) {
if (requestCode == 1000) {
initWebView();
return;
}
return;
}
if (resultCode != -1 || this.mFilePathCallback == null) {
return;
}
if (data != null && data.getClipData() != null) {
int itemCount = data.getClipData().getItemCount();
Log.i(this.TAG, "url count : " + itemCount);
Uri[] uriArr = new Uri[itemCount];
for (int i = 0; i < itemCount; i++) {
uriArr[i] = data.getClipData().getItemAt(i).getUri();
}
this.mFilePathCallback.onReceiveValue(uriArr);
} else {
Uri data2 = data == null ? null : data.getData();
Log.e(this.TAG, "" + data2);
this.mFilePathCallback.onReceiveValue(new Uri[]{data2});
}
this.mFilePathCallback = null;
}
public void openFileChooseProcess(boolean isMulti) {
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.DEFAULT");
intent.setType("*/*");
if (isMulti) {
Log.e(this.TAG, "putExtra");
intent.putExtra("android.intent.extra.ALLOW_MULTIPLE", true);
}
startActivityForResult(Intent.createChooser(intent, "FileChooser"), 100);
}
public static boolean verifyLocationPermissions(Activity activity) {
if (ActivityCompat.checkSelfPermission(activity, "android.permission.ACCESS_FINE_LOCATION") == 0) {
return true;
}
ActivityCompat.requestPermissions(activity, PERMISSIONS_LOCATION, 2);
return false;
}
@Override
public void onResume() {
super.onResume();
this.mWebView.onResume();
}
@Override
public void onPause() {
this.mWebView.onPause();
AppCache.INSTANCE.saveX5Cookie(this.mWebView.getUrl());
super.onPause();
}
@Override
public void onDestroy() {
this.mWebView.destroy();
super.onDestroy();
}
@Override
public void onStop() {
super.onStop();
}
}