486 lines
19 KiB
Java
486 lines
19 KiB
Java
package com.ubt.jimu.user.setting.view;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.graphics.Bitmap;
|
|
import android.net.MailTo;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewParent;
|
|
import android.webkit.ValueCallback;
|
|
import android.webkit.WebChromeClient;
|
|
import android.webkit.WebResourceRequest;
|
|
import android.webkit.WebResourceResponse;
|
|
import android.webkit.WebSettings;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebViewClient;
|
|
import android.widget.ImageView;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.Toast;
|
|
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
|
import com.ubt.jimu.JimuApplication;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.cache.Constants;
|
|
import com.ubt.jimu.base.db.user.UserDbHandler;
|
|
import com.ubt.jimu.base.dialog.JimuSimpleDialog;
|
|
import com.ubt.jimu.base.entities.ApiStatus;
|
|
import com.ubt.jimu.base.entities.User;
|
|
import com.ubt.jimu.base.event.MessageEvent;
|
|
import com.ubt.jimu.base.mvp.BaseMvpFragment;
|
|
import com.ubt.jimu.base.mvp.SingleClickListener;
|
|
import com.ubt.jimu.course.repository.CourseResult;
|
|
import com.ubt.jimu.unity.ModelType;
|
|
import com.ubt.jimu.user.Constant;
|
|
import com.ubt.jimu.user.setting.presenter.CommonWebPresenter;
|
|
import com.ubt.jimu.utils.ExternalOverFroyoUtils;
|
|
import com.ubt.jimu.utils.LogUtils;
|
|
import com.ubt.jimu.utils.NetWorkUtil;
|
|
import com.ubt.jimu.utils.ShortcutHelper;
|
|
import com.ubt.jimu.widgets.choosePhotos.AlbumActivity;
|
|
import com.ubt.jimu.widgets.choosePhotos.media.HPMedia;
|
|
import com.ubtech.utils.FileHelper;
|
|
import com.ubtech.utils.XLog;
|
|
import com.ubtech.view.widget.UButton;
|
|
import java.io.File;
|
|
import java.util.List;
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class CommonWebFragment extends BaseMvpFragment<CommonWebPresenter> implements CommonWebPresenter.CommonWebView {
|
|
private ProgressBar a;
|
|
private WebView b;
|
|
private RelativeLayout c;
|
|
private ImageView d;
|
|
private UButton e;
|
|
private String f;
|
|
private String g;
|
|
private int h;
|
|
private int i;
|
|
private byte[] j;
|
|
private RelativeLayout k;
|
|
private ValueCallback<Uri[]> m;
|
|
private boolean l = false;
|
|
private boolean n = false;
|
|
|
|
private void A() {
|
|
this.l = true;
|
|
this.g = getArguments().getString("url");
|
|
this.f = this.g;
|
|
getArguments().getString("title");
|
|
this.h = getArguments().getInt("type");
|
|
String string = getArguments().getString("data");
|
|
if (string == null) {
|
|
string = "";
|
|
}
|
|
this.j = string.getBytes();
|
|
this.i = getArguments().getInt("zoom", 100);
|
|
getArguments().getBoolean("show_title");
|
|
this.b.getSettings().setTextZoom(this.i);
|
|
LogUtils.c("initData:" + this.g);
|
|
c(this.g);
|
|
if (this.g.contains("https://support.qq.com/product/33918?")) {
|
|
this.k.setVisibility(0);
|
|
} else {
|
|
this.k.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void B() {
|
|
new JimuSimpleDialog.Builder(getActivity()).cancel(R.string.cancel).ok(R.string.ok).content(R.string.tips_close_account).onCancel(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.j
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
dialogInterface.dismiss();
|
|
}
|
|
}).onOk(new DialogInterface.OnClickListener() { // from class: com.ubt.jimu.user.setting.view.i
|
|
@Override // android.content.DialogInterface.OnClickListener
|
|
public final void onClick(DialogInterface dialogInterface, int i) {
|
|
CommonWebFragment.this.a(dialogInterface, i);
|
|
}
|
|
}).cancleBtnBg(R.drawable.shape_cor50_bg92a7b6).build().show();
|
|
}
|
|
|
|
private void initView(View view) {
|
|
this.k = (RelativeLayout) view.findViewById(R.id.rl_left_back);
|
|
this.d = (ImageView) view.findViewById(R.id.iv_web_back);
|
|
this.e = (UButton) view.findViewById(R.id.btnLogout);
|
|
this.a = (ProgressBar) view.findViewById(R.id.pb_web);
|
|
this.b = (WebView) view.findViewById(R.id.web_view);
|
|
this.c = (RelativeLayout) view.findViewById(R.id.rl_web_error);
|
|
}
|
|
|
|
private void q() {
|
|
if (this.g.equals("https://support.qq.com/product/33918?")) {
|
|
this.j = null;
|
|
this.b.loadUrl(this.g);
|
|
}
|
|
}
|
|
|
|
private void v() {
|
|
if (Build.VERSION.SDK_INT >= 11) {
|
|
this.b.removeJavascriptInterface("searchBoxJavaBridge_");
|
|
this.b.removeJavascriptInterface("accessibility");
|
|
this.b.removeJavascriptInterface("accessibilityTraversal");
|
|
}
|
|
WebSettings settings = this.b.getSettings();
|
|
settings.setJavaScriptEnabled(true);
|
|
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
|
settings.setAllowFileAccess(true);
|
|
settings.setSupportZoom(true);
|
|
settings.setCacheMode(2);
|
|
settings.setBuiltInZoomControls(false);
|
|
settings.setLoadsImagesAutomatically(true);
|
|
settings.setDefaultTextEncodingName("UTF-8");
|
|
settings.setLoadWithOverviewMode(true);
|
|
settings.setDomStorageEnabled(true);
|
|
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
|
settings.setBlockNetworkLoads(false);
|
|
settings.setBlockNetworkImage(false);
|
|
this.b.setWebChromeClient(new WebChromeClient() { // from class: com.ubt.jimu.user.setting.view.CommonWebFragment.4
|
|
@Override // android.webkit.WebChromeClient
|
|
public void onProgressChanged(WebView webView, int i) {
|
|
if (i == 100) {
|
|
CommonWebFragment.this.a.setVisibility(8);
|
|
CommonWebFragment.this.b();
|
|
} else {
|
|
if (CommonWebFragment.this.a.getVisibility() == 8) {
|
|
CommonWebFragment.this.a.setVisibility(0);
|
|
}
|
|
CommonWebFragment.this.a.setProgress(i);
|
|
}
|
|
super.onProgressChanged(webView, i);
|
|
}
|
|
|
|
@Override // android.webkit.WebChromeClient
|
|
public void onReceivedTitle(WebView webView, String str) {
|
|
super.onReceivedTitle(webView, str);
|
|
Log.e("webviewtitle", str);
|
|
if (CommonWebFragment.this.g.equals("https://support.qq.com/product/33918?")) {
|
|
CommonWebFragment.this.n = true;
|
|
CommonWebFragment.this.c.setVisibility(8);
|
|
} else if (str.contains("404") || str.contains("500") || str.contains("Error") || str.contains("找不到网页") || str.contains("网页无法打开")) {
|
|
CommonWebFragment.this.n = false;
|
|
CommonWebFragment.this.c.setVisibility(0);
|
|
} else {
|
|
CommonWebFragment.this.n = true;
|
|
CommonWebFragment.this.c.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
@Override // android.webkit.WebChromeClient
|
|
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
|
|
CommonWebFragment.this.m = valueCallback;
|
|
Intent intent = new Intent(CommonWebFragment.this.getActivity(), (Class<?>) AlbumActivity.class);
|
|
intent.putExtra("type", "MULTITERM_IMAGE");
|
|
intent.putExtra(FileDownloadModel.TOTAL, 6);
|
|
CommonWebFragment.this.startActivityForResult(intent, 1);
|
|
return true;
|
|
}
|
|
});
|
|
this.b.setWebViewClient(new WebViewClient() { // from class: com.ubt.jimu.user.setting.view.CommonWebFragment.5
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageFinished(WebView webView, String str) {
|
|
super.onPageFinished(webView, str);
|
|
CommonWebFragment.this.f = str;
|
|
CommonWebFragment.this.b();
|
|
LogUtils.c("onPageFinished:" + str);
|
|
if (CommonWebFragment.this.c.getVisibility() == 0 && NetWorkUtil.b(JimuApplication.l()) && CommonWebFragment.this.n) {
|
|
CommonWebFragment.this.c.setVisibility(8);
|
|
}
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
|
|
super.onPageStarted(webView, str, bitmap);
|
|
CommonWebFragment.this.f = str;
|
|
LogUtils.c("onPageStarted:" + str);
|
|
if (NetWorkUtil.b(JimuApplication.l())) {
|
|
return;
|
|
}
|
|
CommonWebFragment.this.c.setVisibility(0);
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onReceivedError(WebView webView, int i, String str, String str2) {
|
|
super.onReceivedError(webView, i, str, str2);
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
|
|
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
|
|
}
|
|
|
|
@Override // android.webkit.WebViewClient
|
|
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
|
|
if (str.startsWith("tel:")) {
|
|
CommonWebFragment.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
|
|
return true;
|
|
}
|
|
if (str.startsWith("mailto:")) {
|
|
MailTo parse = MailTo.parse(str);
|
|
CommonWebFragment.this.startActivity(CommonWebFragment.this.a(parse.getTo(), parse.getSubject(), parse.getBody(), parse.getCc()));
|
|
webView.reload();
|
|
return true;
|
|
}
|
|
if (TextUtils.isEmpty(str) || str.startsWith("http")) {
|
|
webView.loadUrl(str);
|
|
LogUtils.c("url:" + str);
|
|
return true;
|
|
}
|
|
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
|
|
if (intent.resolveActivity(CommonWebFragment.this.getActivity().getPackageManager()) != null) {
|
|
intent.setFlags(270532608);
|
|
CommonWebFragment.this.getActivity().startActivity(intent);
|
|
} else {
|
|
Toast.makeText(CommonWebFragment.this.getActivity(), "App not installed", 0).show();
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
|
|
private void x() {
|
|
this.c.setOnClickListener(new SingleClickListener() { // from class: com.ubt.jimu.user.setting.view.CommonWebFragment.1
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener, android.view.View.OnClickListener
|
|
public /* synthetic */ void onClick(View view) {
|
|
com.ubt.jimu.base.mvp.b.$default$onClick(this, view);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener
|
|
public void onSingleClick(View view) {
|
|
CommonWebFragment commonWebFragment = CommonWebFragment.this;
|
|
commonWebFragment.c(commonWebFragment.f);
|
|
}
|
|
});
|
|
this.d.setOnClickListener(new SingleClickListener() { // from class: com.ubt.jimu.user.setting.view.CommonWebFragment.2
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener, android.view.View.OnClickListener
|
|
public /* synthetic */ void onClick(View view) {
|
|
com.ubt.jimu.base.mvp.b.$default$onClick(this, view);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener
|
|
public void onSingleClick(View view) {
|
|
if (CommonWebFragment.this.b.canGoBack()) {
|
|
CommonWebFragment.this.b.goBack();
|
|
}
|
|
}
|
|
});
|
|
this.e.setOnClickListener(new SingleClickListener() { // from class: com.ubt.jimu.user.setting.view.CommonWebFragment.3
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener, android.view.View.OnClickListener
|
|
public /* synthetic */ void onClick(View view) {
|
|
com.ubt.jimu.base.mvp.b.$default$onClick(this, view);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.SingleClickListener
|
|
public void onSingleClick(View view) {
|
|
CommonWebFragment.this.B();
|
|
}
|
|
});
|
|
}
|
|
|
|
private void y() {
|
|
User user;
|
|
if (!this.g.equals("https://support.qq.com/product/33918?") || (user = UserDbHandler.getUser()) == null) {
|
|
return;
|
|
}
|
|
this.j = ("nickname=" + user.getNickName() + "&avatar=" + com.ubt.jimu.utils.TextUtils.e(user.getUserImage()) + "&openid=" + user.getUserId()).getBytes();
|
|
this.b.postUrl("https://support.qq.com/product/33918?", this.j);
|
|
}
|
|
|
|
public void b() {
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public int getLayoutID() {
|
|
return R.layout.fragment_commonwebview;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.setting.presenter.CommonWebPresenter.CommonWebView
|
|
public void h() {
|
|
hideLoading();
|
|
toast(getString(R.string.tips_delete_account_failed));
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public boolean isRegistEventBus() {
|
|
return true;
|
|
}
|
|
|
|
public void l() {
|
|
Cache.getInstance().clearCacheUser();
|
|
UserDbHandler.clearUser();
|
|
ShortcutHelper.a(getActivity());
|
|
EventBus.b().b(new MessageEvent(5));
|
|
}
|
|
|
|
public void o() {
|
|
User user = UserDbHandler.getUser();
|
|
if (user == null || user.getUserId() <= 0 || !this.f.contains(Constant.a)) {
|
|
this.e.setVisibility(8);
|
|
} else {
|
|
this.e.setVisibility(0);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onActivityResult(int i, int i2, Intent intent) {
|
|
List list;
|
|
super.onActivityResult(i, i2, intent);
|
|
if (-1 != i2 || intent == null || (list = (List) intent.getSerializableExtra("result_data")) == null) {
|
|
return;
|
|
}
|
|
Uri[] uriArr = new Uri[list.size()];
|
|
for (int i3 = 0; i3 < list.size(); i3++) {
|
|
HPMedia hPMedia = (HPMedia) list.get(i3);
|
|
if (hPMedia != null) {
|
|
XLog.a("web", "media %s", hPMedia.getPath());
|
|
uriArr[i3] = Uri.fromFile(new File(hPMedia.getPath()));
|
|
}
|
|
}
|
|
ValueCallback<Uri[]> valueCallback = this.m;
|
|
if (valueCallback != null) {
|
|
valueCallback.onReceiveValue(uriArr);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
|
return super.onCreateView(layoutInflater, viewGroup, bundle);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onDestroy() {
|
|
WebView webView = this.b;
|
|
if (webView != null) {
|
|
ViewParent parent = webView.getParent();
|
|
if (parent != null) {
|
|
((ViewGroup) parent).removeView(this.b);
|
|
}
|
|
this.b.stopLoading();
|
|
this.b.clearHistory();
|
|
this.b.removeAllViews();
|
|
this.b.destroy();
|
|
this.b.clearCache(true);
|
|
this.b = null;
|
|
}
|
|
super.onDestroy();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onHiddenChanged(boolean z) {
|
|
super.onHiddenChanged(z);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onPause() {
|
|
super.onPause();
|
|
this.b.onPause();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public void onReceiveMessage(MessageEvent messageEvent) {
|
|
super.onReceiveMessage(messageEvent);
|
|
if (messageEvent.getType() == 1) {
|
|
o();
|
|
q();
|
|
} else if (messageEvent.getType() == 0) {
|
|
o();
|
|
y();
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
super.onResume();
|
|
o();
|
|
this.b.onResume();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onStart() {
|
|
super.onStart();
|
|
if (this.l) {
|
|
return;
|
|
}
|
|
A();
|
|
v();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment, androidx.fragment.app.Fragment
|
|
public void onViewCreated(View view, Bundle bundle) {
|
|
super.onViewCreated(view, bundle);
|
|
initView(view);
|
|
x();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void c(String str) {
|
|
if (this.h == 0) {
|
|
this.b.loadUrl(str);
|
|
return;
|
|
}
|
|
byte[] bArr = this.j;
|
|
if (bArr != null) {
|
|
this.b.postUrl(str, bArr);
|
|
} else {
|
|
this.b.loadUrl(str);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpFragment
|
|
public CommonWebPresenter createPresenter() {
|
|
return new CommonWebPresenter();
|
|
}
|
|
|
|
public /* synthetic */ void a(DialogInterface dialogInterface, int i) {
|
|
if (!NetWorkUtil.b(JimuApplication.l())) {
|
|
toast(getString(R.string.network_error));
|
|
return;
|
|
}
|
|
((CommonWebPresenter) this.mPresenter).a();
|
|
dialogInterface.dismiss();
|
|
showLoading(getString(R.string.logoff) + "...");
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.setting.presenter.CommonWebPresenter.CommonWebView
|
|
public void a(ApiStatus apiStatus) {
|
|
hideLoading();
|
|
if (apiStatus.getCode() != 0 && !CourseResult.SUCCESS.equals(apiStatus.getMessage())) {
|
|
toast(getString(R.string.tips_delete_account_failed));
|
|
return;
|
|
}
|
|
File file = new File(ExternalOverFroyoUtils.a(JimuApplication.l(), (ModelType) null) + String.format(Constants.USER_HOME, Cache.getInstance().getUserId()));
|
|
if (file.exists()) {
|
|
FileHelper.a(file);
|
|
}
|
|
l();
|
|
toast(getString(R.string.tips_delete_account));
|
|
this.e.setVisibility(8);
|
|
EventBus.b().b(new MessageEvent(5));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Intent a(String str, String str2, String str3, String str4) {
|
|
Intent intent = new Intent("android.intent.action.SEND");
|
|
intent.putExtra("android.intent.extra.EMAIL", new String[]{str});
|
|
intent.putExtra("android.intent.extra.TEXT", str3);
|
|
intent.putExtra("android.intent.extra.SUBJECT", str2);
|
|
intent.putExtra("android.intent.extra.CC", str4);
|
|
intent.setType("message/rfc822");
|
|
return intent;
|
|
}
|
|
}
|