CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 WebViewActivity.java 源代码,内容仅作参考
package ak.im.ui.activity;
import ak.application.AKApplication;
import ak.im.BuildConfig;
import ak.im.module.AKCDiscoverInstance;
import ak.im.module.AKChannel;
import ak.im.module.ChatMessage;
import ak.im.module.ChatMessageBuilder;
import ak.im.module.CookieData;
import ak.im.module.Group;
import ak.im.module.GroupUser;
import ak.im.module.IMMessage;
import ak.im.module.User;
import ak.im.sdk.manager.AKCDiscoverManager;
import ak.im.sdk.manager.BadgeManager;
import ak.im.sdk.manager.ChannelManager;
import ak.im.sdk.manager.MessageManager;
import ak.im.service.AKCoreService;
import ak.im.ui.activity.WebViewActivity;
import ak.im.ui.view.AdvancedWebView;
import ak.im.uitls.AKCAppConfiguration;
import ak.im.utils.AkeyChatUtils;
import ak.im.utils.HttpURLTools;
import ak.im.utils.Log;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.ConsoleMessage;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
import android.webkit.URLUtil;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.view.GravityCompat;
import cn.tee3.avd.User;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.asim.protobuf.Akeychat;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.net.HttpURLConnection;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import okhttp3.a0;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.http.HttpHost;
import org.jivesoftware.smack.sm.packet.StreamManagement;
import org.jivesoftware.smackx.amp.packet.AMPExtension;
import org.pjsip.pjsua2.app.SipCall;
import org.pjsip.pjsua2.app.VoIpManager;
public class WebViewActivity extends SwipeBackActivity implements AdvancedWebView.d {
private AdvancedWebView a;
private View f1942b;
private String i;
private View j;
private IMMessage.ArticleMsgInfo l;
private String m;
Akeychat.AKWebShare n;
private AdvancedWebView.f o;
private LinkedHashMap<String, String> q;
private AKChannel s;
ClipDrawable t;
String u;
String v;
String w;
private String x;
private TextView f1943c = null;
private ImageView f1944d = null;
private ImageView f1945e = null;
private boolean f = true;
private ImageView g = null;
private ImageView h = null;
private int k = 0;
public String p = ak.im.sdk.manager.ye.getInstance().getUsername() + "_cookie";
private String r = "";
public class CNOAJavascriptInterface {
public CNOAJavascriptInterface() {
}
public void b() {
WebViewActivity.this.a.loadUrl(WebViewActivity.this.i);
}
@JavascriptInterface
public void returnToMain() {
if (WebViewActivity.this.a != null) {
WebViewActivity.this.runOnUiThread(new Runnable() {
@Override
public final void run() {
WebViewActivity.CNOAJavascriptInterface.this.b();
}
});
}
}
}
class a extends ak.j.a<String> {
a() {
}
@Override
public void onError(Throwable th) {
super.onError(th);
WebViewActivity.this.getIBaseActivity().dismissPGDialog();
}
@Override
public void onNext(String str) {
WebViewActivity.this.getIBaseActivity().dismissPGDialog();
if (str.startsWith(HttpHost.DEFAULT_SCHEME_NAME)) {
AkeyChatUtils.startImageActivityOpenHttp(WebViewActivity.this, str);
} else {
AkeyChatUtils.startImageActivityOpenFile(WebViewActivity.this, str);
}
}
}
public class b extends WebViewClient {
b() {
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
String cookie = CookieManager.getInstance().getCookie(str);
Log.i("WebViewActivity", "check current cookie:" + cookie);
ak.im.sdk.manager.ye.getInstance().saveWebViewCookie(WebViewActivity.this.p, new com.google.gson.d().toJson(new CookieData(str, cookie, ak.im.sdk.manager.ye.getInstance().getUsername())));
WebViewActivity.this.r();
WebViewActivity.this.p();
WebViewActivity.this.K0();
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
super.onPageStarted(webView, str, bitmap);
WebViewActivity.this.q.put(str, str);
WebViewActivity.this.m = str;
WebViewActivity.this.f1942b.setVisibility(0);
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
WebViewActivity.this.r();
super.onReceivedError(webView, i, str, str2);
Log.w("WebViewActivity", "webview load error,error code:" + i + ",des:" + str);
if (!str2.contains("http:") || i != -8) {
WebViewActivity.this.a.setVisibility(8);
WebViewActivity.this.j.setVisibility(0);
return;
}
WebViewActivity.this.a.loadUrl(str2.replace("http:", "https:"));
}
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
Log.w("WebViewActivity", "check ssl error info:");
try {
Method declaredMethod = SslErrorHandler.class.getDeclaredMethod(new String(ak.comm.d.decode("cHJvY2VlZA==")), new Class[0]);
declaredMethod.setAccessible(true);
declaredMethod.invoke(sslErrorHandler, new Object[0]);
} catch (NoSuchMethodException e2) {
e2.printStackTrace();
} catch (Exception e3) {
e3.printStackTrace();
}
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
DataInputStream dataInputStream;
if (str == null) {
return super.shouldInterceptRequest(webView, str);
}
HttpURLTools.UrlType checkHttpUrlType = HttpURLTools.checkHttpUrlType(str);
if (checkHttpUrlType != HttpURLTools.UrlType.BoxNetNetworkInternalUrl && checkHttpUrlType != HttpURLTools.UrlType.PublicNetworkInternalUrl) {
Log.i("WebViewActivity", "external url via webview");
try {
if (str.startsWith("https://") && str.contains("/app/seaweedfsdownload?fid=")) {
String accessToken = ak.im.sdk.manager.ye.getInstance().getAccessToken();
HttpURLConnection httpURLConnection = (HttpURLConnection) URI.create(str).toURL().openConnection();
httpURLConnection.setRequestProperty("X-Access-Token", accessToken);
DataInputStream dataInputStream2 = null;
try {
try {
} catch (IOException unused) {
if (httpURLConnection.getErrorStream() != null) {
dataInputStream = new DataInputStream(httpURLConnection.getErrorStream());
} else {
return super.shouldInterceptRequest(webView, str);
}
}
} catch (Exception unused2) {
}
if (httpURLConnection.getInputStream() != null) {
dataInputStream = new DataInputStream(httpURLConnection.getInputStream());
dataInputStream2 = dataInputStream;
return new WebResourceResponse(httpURLConnection.getContentType(), "UTF-8", dataInputStream2);
}
return super.shouldInterceptRequest(webView, str);
}
} catch (Exception e2) {
e2.printStackTrace();
}
} else {
Log.i("WebViewActivity", "internal url via http client");
try {
okhttp3.c0 execute = HttpURLTools.getOkHttpClientBuilder(str, ak.im.sdk.manager.ye.getInstance().getAccessToken(), false).build().newCall(new a0.a().url(str).build()).execute();
String str2 = execute.body().contentType().type() + CookieSpec.PATH_DELIM + execute.body().contentType().subtype();
Log.e("WebViewActivity", "request url " + str + ", type " + str2);
return new WebResourceResponse(str2, execute.header("content-encoding", "utf-8"), execute.body().byteStream());
} catch (Exception e3) {
e3.printStackTrace();
}
}
return super.shouldInterceptRequest(webView, str);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
Log.i("WebViewActivity", "check url:" + str);
if (!str.startsWith(AKApplication.getAsimPackageName() + "://splash/openwith")) {
if (!WebViewActivity.this.x(str)) {
Log.w("WebViewActivity", "illegal url do not load it:" + str);
return true;
}
return super.shouldOverrideUrlLoading(webView, str);
}
Intent intent = new Intent("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
AkeyChatUtils.handleBrowserOpenEvent(intent, false, WebViewActivity.this);
return true;
}
}
public class c implements TextWatcher {
c() {
}
@Override
public void afterTextChanged(Editable editable) {
String charSequence = WebViewActivity.this.f1943c.getText().toString();
if ("netcheckpage.html".equals(charSequence) || "netcheckpage_boxtalk.html".equals(charSequence)) {
WebViewActivity.this.f1943c.setText(WebViewActivity.this.getString(ak.im.b2.net_check_title));
}
}
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
}
}
public class d extends AdvancedWebView.f {
d(AdvancedWebView advancedWebView, View view, ViewGroup viewGroup) {
super(view, viewGroup);
Objects.requireNonNull(advancedWebView);
}
public void b(DialogInterface dialogInterface) {
WebViewActivity.this.a.onActivityResult(51426, 0, null);
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
return false;
}
@Override
public void onProgressChanged(WebView webView, int i) {
super.onProgressChanged(webView, i);
WebViewActivity webViewActivity = WebViewActivity.this;
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) webViewActivity.f1942b.getLayoutParams();
layoutParams.width = (int) ((i / 100.0f) * webViewActivity.mScreenWidth);
WebViewActivity.this.f1942b.setLayoutParams(layoutParams);
}
@Override
public void onReceivedTitle(WebView webView, String str) {
super.onReceivedTitle(webView, str);
if (("ak-url".equals(WebViewActivity.this.u) || "ak-share-web".equals(WebViewActivity.this.u) || "work-space".equals(WebViewActivity.this.u) || "bot-menu".equals(WebViewActivity.this.u)) && TextUtils.isEmpty(WebViewActivity.this.r)) {
WebViewActivity.this.f1943c.setText(str);
}
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
if (Build.VERSION.SDK_INT >= 21 && fileChooserParams != null && fileChooserParams.getAcceptTypes()[0].startsWith(ChatMessage.CHAT_IMAGE)) {
WebViewActivity.this.a.selfDefineImageChoose(null, valueCallback);
AkeyChatUtils.showDialogChooseImage(WebViewActivity.this.getIBaseActivity(), new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
WebViewActivity.d.this.b(dialogInterface);
}
});
return true;
}
return super.onShowFileChooser(webView, valueCallback, fileChooserParams);
}
}
public class e implements AdvancedWebView.e {
e() {
}
@Override
public void toggledFullscreen(boolean z) {
if (z) {
WindowManager.LayoutParams attributes = WebViewActivity.this.getWindow().getAttributes();
int i = attributes.flags | 1024;
attributes.flags = i;
attributes.flags = i | 128;
WebViewActivity.this.getWindow().setAttributes(attributes);
WebViewActivity.this.setSwipeBackEnable(false);
WebViewActivity.this.getWindow().setBackgroundDrawableResource(ak.im.t1.black);
WebViewActivity.this.getWindow().getDecorView().setSystemUiVisibility(1);
return;
}
WebViewActivity.this.setSwipeBackEnable(true);
WebViewActivity.this.getWindow().setBackgroundDrawableResource(ak.im.t1.transparent_absolute);
WindowManager.LayoutParams attributes2 = WebViewActivity.this.getWindow().getAttributes();
int i2 = attributes2.flags & (-1025);
attributes2.flags = i2;
attributes2.flags = i2 & (-129);
WebViewActivity.this.getWindow().setAttributes(attributes2);
WebViewActivity.this.getWindow().getDecorView().setSystemUiVisibility(0);
}
}
class f extends ak.j.a<Long> {
f() {
}
@Override
public void onNext(Long l) {
WebViewActivity.this.a.loadUrl("javascript:getAndRenderStatus()");
}
}
public class g extends ak.j.a<ChatMessage> {
g() {
}
@Override
public void onNext(ChatMessage chatMessage) {
AkeyChatUtils.prepareTransmitMsg(chatMessage, WebViewActivity.this);
}
}
public class h extends ak.j.a<ChatMessage> {
h() {
}
@Override
public void onNext(ChatMessage chatMessage) {
AkeyChatUtils.transmitToAKCloud(chatMessage, WebViewActivity.this.getIBaseActivity());
}
}
public class i extends ak.j.a<String> {
i() {
}
@Override
public void onNext(String str) {
WebViewActivity.this.getIBaseActivity().showToast(str);
}
}
public class j extends ak.j.a<String> {
final View a;
j(View view) {
this.a = view;
}
@Override
public void onNext(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
WebViewActivity.this.x = str;
this.a.setVisibility(0);
}
}
public void B(PopupWindow popupWindow, String str, View view) {
popupWindow.dismiss();
u(str).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(new g());
}
public void B0(View view) {
getIBaseActivity().dismissFullWindowDialog();
AkeyChatUtils.prepareTransmitMsg(t(), this);
}
public static ak.im.module.ChatMessage C(ak.im.module.ChatMessage r1) throws java.lang.Exception {
throw new UnsupportedOperationException("Method not decompiled: ak.im.ui.activity.WebViewActivity.C(ak.im.module.ChatMessage):ak.im.module.ChatMessage");
}
public void D0(View view) {
getIBaseActivity().dismissFullWindowDialog();
AkeyChatUtils.transmitToAKCloud(t(), getIBaseActivity());
}
public void E(PopupWindow popupWindow, String str, View view) {
popupWindow.dismiss();
u(str).map(new io.reactivex.s0.o() {
@Override
public final java.lang.Object apply(java.lang.Object r1) {
throw new UnsupportedOperationException("Method not decompiled: ak.im.ui.activity.fe0.apply(java.lang.Object):java.lang.Object");
}
}).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(new h());
}
public void F0(View view) {
getIBaseActivity().dismissFullWindowDialog();
}
public void H0(View view) {
getIBaseActivity().dismissFullWindowDialog();
Intent intent = new Intent("android.intent.action.VIEW");
if (!URLUtil.isNetworkUrl(this.i)) {
Log.e("WebViewActivity", "the url is invalid: " + this.i);
return;
}
intent.setData(Uri.parse(this.i));
startActivity(intent);
}
public String I(String str) throws Exception {
return getString(ak.im.b2.image_save_hint, new Object[]{ak.im.utils.l4.getSaveAttachImagePath()});
}
private void I0() {
this.q = new LinkedHashMap<>(16);
this.a.canGoBackOrForward(10);
HashMap hashMap = new HashMap();
hashMap.put("X-Access-Token", ak.im.sdk.manager.ye.getInstance().getAccessToken());
if (!this.i.startsWith("https://") && !this.i.startsWith("http://")) {
if (ak.im.utils.l4.isVaultPath(this.i)) {
this.r = ak.im.utils.l4.getFileNameByPath(this.i);
File copyVaultFileToTemp = ak.im.utils.l4.copyVaultFileToTemp(this.i);
this.i = "file://" + Uri.parse(copyVaultFileToTemp.getPath());
this.f1945e.setVisibility(4);
} else if (!this.i.startsWith(ak.im.p1.f616d) && !this.i.startsWith(ak.im.o1.get().getCacheDir().getPath())) {
if (!this.i.startsWith("file://")) {
this.i = "http://" + this.i;
}
} else {
this.r = ak.im.utils.l4.getFileNameByPath(this.i);
this.i = "file://" + this.i;
this.f1945e.setVisibility(4);
}
}
String str = this.i;
if (str != null && str.contains("?")) {
String notifyCheck = AKCAppConfiguration.a.getNotifyCheck();
String str2 = this.i;
if (notifyCheck.startsWith(str2.substring(0, str2.lastIndexOf("?")))) {
this.f1945e.setVisibility(8);
}
}
Log.i("WebViewActivity", "current url is " + this.i);
if ((this.k & 1) == 1) {
this.a.loadUrl(this.i, hashMap);
} else {
this.a.loadUrl(this.i);
}
if ("ak-url".equals(this.u) || "work-space".equals(this.u) || "bot-menu".equals(this.u)) {
this.f1943c.setText(this.r);
}
if (this.i.contains("cnoa.cn")) {
this.a.addJavascriptInterface(new CNOAJavascriptInterface(), "javaInterface");
} else {
this.a.addJavascriptInterface(this, "androidWebViewClient");
}
this.a.setWebViewClient(new b());
if (Build.VERSION.SDK_INT >= 19) {
if (AKApplication.isEMUI()) {
this.a.setLayerType(2, null);
}
} else {
this.a.setLayerType(1, null);
}
try {
CookieData cookieData = (CookieData) new com.google.gson.d().fromJson(ak.im.sdk.manager.ye.getInstance().getWebViewCookie(this.p), (Class<Object>) CookieData.class);
if (cookieData != null && ak.im.sdk.manager.ye.getInstance().getUsername().equals(cookieData.getName()) && this.i.equals(cookieData.getUrl())) {
synCookies(this, this.i, cookieData.getcookie());
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
public void K(PopupWindow popupWindow, final String str, View view) {
popupWindow.dismiss();
AkeyChatUtils.getBitmapByBase64DataWithRX(str).flatMap(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
io.reactivex.e0 saveWebViewBitmap;
saveWebViewBitmap = AkeyChatUtils.saveWebViewBitmap((Bitmap) obj, AkeyChatUtils.getMimeTypeByBase64Data(str));
return saveWebViewBitmap;
}
}).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return WebViewActivity.this.I((String) obj);
}
}).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(new i());
}
public void J0() {
if (getIBaseActivity().useSecModeUI()) {
this.f1944d.setBackgroundResource(ak.im.v1.sec_title_selector);
} else {
this.f1944d.setBackgroundResource(ak.im.v1.unsec_title_selector);
}
}
public void K0() {
boolean canGoBack = this.a.canGoBack();
boolean canGoForward = this.a.canGoForward();
boolean z = canGoBack || canGoForward;
this.g.setEnabled(canGoBack);
this.h.setEnabled(canGoForward);
if (this.f && z) {
findViewById(ak.im.w1.bottom_bar).setVisibility(0);
} else {
findViewById(ak.im.w1.bottom_bar).setVisibility(8);
}
}
public void M(PopupWindow popupWindow, View view) {
popupWindow.dismiss();
AkeyChatUtils.handleQRCode(this.x, getIBaseActivity());
}
private void L0() {
this.a.reload();
this.a.clearHistory();
this.j.setVisibility(8);
this.a.setVisibility(0);
}
private void M0(WebSettings webSettings) {
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);
webSettings.setSupportZoom(true);
webSettings.setDomStorageEnabled(true);
webSettings.setBlockNetworkImage(false);
webSettings.setDatabaseEnabled(true);
webSettings.setSavePassword(false);
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(true);
if (Build.VERSION.SDK_INT >= 21) {
webSettings.setMixedContentMode(0);
}
webSettings.setAllowFileAccess(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
}
public void P(Boolean bool) throws Exception {
if (!bool.booleanValue()) {
getIBaseActivity().showToast(getString(ak.im.b2.permission_deny_location));
} else {
w("get_location", s(AKApplication.getLocation()));
}
}
public static io.reactivex.e0 R(String str) throws Exception {
ChatMessageBuilder chatMessageBuilder = new ChatMessageBuilder();
chatMessageBuilder.setSrcPath(str).setDestroy(IMMessage.NEVER_BURN);
return MessageManager.generateOneImageMessageByRX(chatMessageBuilder);
}
public void W(View view) {
L0();
}
public void Y(View view) {
this.a.goBack();
}
public void a0(View view) {
this.a.goForward();
}
public void c0(View view) {
popupWindow();
}
public void e0(View view) {
finish();
}
public boolean g0(View view) {
int type;
if (getIntent().getBooleanExtra("web_forbidden_copy", false)) {
return true;
}
WebView.HitTestResult hitTestResult = ((WebView) view).getHitTestResult();
if (hitTestResult == null || (type = hitTestResult.getType()) == 0) {
return false;
}
if (5 == type) {
q(hitTestResult.getExtra());
}
return true;
}
public void i0(String str, View view) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(Intent.createChooser(intent, ""));
} else {
Log.i("WebViewActivity", "url is wrong or no default web");
}
}
private void init() {
Intent intent = getIntent();
String stringExtra = intent.getStringExtra("purpose");
Log.i("WebViewActivity", "type is " + stringExtra);
this.v = intent.getStringExtra("name-key");
this.w = intent.getStringExtra("chat_type");
this.u = stringExtra;
AdvancedWebView advancedWebView = (AdvancedWebView) findViewById(ak.im.w1.webView);
this.a = advancedWebView;
advancedWebView.setListener(this, this);
View findViewById = findViewById(ak.im.w1.tv_error_view);
this.j = findViewById;
findViewById.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.W(view);
}
});
this.f1942b = findViewById(ak.im.w1.progress);
this.t = new ClipDrawable(new ColorDrawable(getResources().getColor(ak.im.t1.main_green)), GravityCompat.START, 1);
TextView textView = (TextView) findViewById(ak.im.w1.tv_title_back);
this.f1943c = textView;
textView.addTextChangedListener(new c());
this.f1944d = (ImageView) findViewById(ak.im.w1.iv_title_close);
this.f1945e = (ImageView) findViewById(ak.im.w1.iv_other_op);
ImageView imageView = (ImageView) findViewById(ak.im.w1.iv_nav_goback);
this.g = imageView;
imageView.setEnabled(false);
this.g.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.Y(view);
}
});
ImageView imageView2 = (ImageView) findViewById(ak.im.w1.iv_nav_goforward);
this.h = imageView2;
imageView2.setEnabled(false);
this.h.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.a0(view);
}
});
getIBaseActivity().registerSecurityChangedListener(new ak.im.listener.w() {
@Override
public final void callback() {
WebViewActivity.this.J0();
}
});
this.f1945e.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.c0(view);
}
});
this.f1944d.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.e0(view);
}
});
if ("0a9605c6e4f5d5b4".equals(stringExtra)) {
this.i = ak.im.g2.c.a.getDefaultProductIntroduction();
this.f1943c.setText(ak.im.b2.feature_introduction);
} else if ("62c151646774c20e".equals(stringExtra)) {
this.i = ak.im.g2.c.a.getDefaultUserAgreement();
this.f1943c.setText(String.format(getString(ak.im.b2.agreement_title), AKApplication.getAppName()));
} else if ("234fr56gce5gc5t5".equals(stringExtra)) {
this.i = ak.im.g2.c.a.getDefaultPrivacy();
this.f1943c.setText(getString(ak.im.b2.app_name).concat(getString(ak.im.b2.str_user_privacy)));
} else if ("5ededa3c69349f30".equals(stringExtra)) {
IMMessage.ArticleMsgInfo articleMsgInfo = (IMMessage.ArticleMsgInfo) getIntent().getParcelableExtra(IMMessage.ArticleMsgInfo.ARTICLE_MSG_KEY);
this.l = articleMsgInfo;
if (articleMsgInfo == null) {
Log.w("WebViewActivity", "got null article info");
finish();
return;
}
this.i = articleMsgInfo.articleId;
this.s = ChannelManager.getSingleton().getChannelAnyway(this.l.channelName);
this.f1945e.setVisibility(0);
String str = this.l.channelNick;
if (TextUtils.isEmpty(str)) {
AKChannel aKChannel = this.s;
if (aKChannel != null) {
str = aKChannel.nick;
}
if (TextUtils.isEmpty(str)) {
str = getString(ak.im.b2.news);
}
}
this.f1943c.setText(str);
this.i = AkeyChatUtils.getArticleUrl(this.i);
this.k = 17;
} else if (!"ak-url".equals(stringExtra) && !"work-space".equals(stringExtra) && !"bot-menu".equals(stringExtra)) {
if ("ak-share-web".equals(stringExtra)) {
Akeychat.AKWebShare aKWebShare = (Akeychat.AKWebShare) getIntent().getSerializableExtra("ak-s-w-k");
this.n = aKWebShare;
this.i = aKWebShare.getWebUrl();
this.k = 1;
this.f1945e.setVisibility(0);
} else if ("about-box".equals(stringExtra)) {
this.i = "http://akeypublichtml.akeychat.cn/what-is-akeybox.html";
this.f1943c.setText(AKApplication.getAppName());
} else if ("help-box".equals(stringExtra)) {
this.i = "http://akeypublichtml.akeychat.cn/how-to-connect-wifi-for-akeybox.html";
this.f1943c.setText(AKApplication.getAppName());
} else if ("Expansion-box".equals(stringExtra)) {
this.i = ak.im.sdk.manager.ye.getInstance().getM5MBase() + "/app/userLogin";
this.f1943c.setText(AKApplication.getAppName());
} else if ("buy-box".equals(stringExtra)) {
this.i = intent.getStringExtra("buy-box");
this.f1943c.setText(AKApplication.getAppName());
} else if ("about-enterprise".equals(stringExtra)) {
this.i = ak.im.g2.c.a.getDefaultEnterpriseIntroduction();
this.f1943c.setText(AKApplication.getAppName());
} else {
finish();
}
} else {
this.i = getIntent().getStringExtra("ak-url-k");
if ("work-space".equals(stringExtra)) {
this.k = 257;
} else if ("bot-menu".equals(stringExtra)) {
this.k = 4097;
}
this.f1945e.setVisibility(0);
}
this.a.removeJavascriptInterface("searchBoxJavaBridge_");
this.a.removeJavascriptInterface("accessibilityTraversal");
this.a.removeJavascriptInterface("accessibility");
AdvancedWebView advancedWebView2 = this.a;
Objects.requireNonNull(advancedWebView2);
d dVar = new d(advancedWebView2, findViewById(ak.im.w1.fl), (ViewGroup) findViewById(ak.im.w1.videoLayout));
this.o = dVar;
dVar.setOnToggledFullscreen(new e());
this.a.setWebChromeClient(this.o);
M0(this.a.getSettings());
this.a.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public final boolean onLongClick(View view) {
return WebViewActivity.this.g0(view);
}
});
Log.i("WebViewActivity", "url is " + this.i);
}
public void k0(View view) {
getIBaseActivity().dismissAlertDialog();
}
public static io.reactivex.e0 l0(String str, String str2, String str3) throws Exception {
if (str.startsWith("data:") && str.contains(str2)) {
return AkeyChatUtils.saveWebViewBitmap(AkeyChatUtils.getBitmapByBase64Data(str3), AkeyChatUtils.getMimeTypeByBase64Data(str3));
}
return io.reactivex.z.just(str3);
}
public void s0(View view) {
IMMessage.ArticleMsgInfo articleMsgInfo = this.l;
if (articleMsgInfo != null && !articleMsgInfo.allowForward) {
getIBaseActivity().showToast(ak.im.b2.prohibit_collect);
return;
}
getIBaseActivity().dismissFullWindowDialog();
ArrayList arrayList = new ArrayList();
arrayList.add(this.l);
AkeyChatUtils.transmitToAKCloud(MessageManager.generateOneArticleMessage(arrayList, "single", ak.im.utils.n5.getJidByName(ak.im.sdk.manager.ye.getInstance().getUsername())), getIBaseActivity());
}
public void v0(View view) {
getIBaseActivity().dismissFullWindowDialog();
L0();
}
public void w0(View view) {
getIBaseActivity().dismissFullWindowDialog();
}
public void x0(View view) {
getIBaseActivity().dismissFullWindowDialog();
AkeyChatUtils.startFileDownloadActivity(getIBaseActivity(), 0);
}
public void n0(View view) {
getIBaseActivity().dismissFullWindowDialog();
L0();
}
public void p0(View view) {
getIBaseActivity().dismissFullWindowDialog();
AkeyChatUtils.startFileDownloadActivity(getIBaseActivity(), 0);
}
public void p() {
if (((this.k & 16) != 0) && (true ^ this.i.contains("buy.akey.me"))) {
this.a.loadUrl("javascript:(function(){var objs = document.getElementsByTagName(\"img\"); for(var i=0;i<objs.length;i++) { objs[i].onclick=function() { androidWebViewClient.openImage(this.src); } }})()");
}
}
public void r0(View view) {
IMMessage.ArticleMsgInfo articleMsgInfo = this.l;
if (articleMsgInfo != null && !articleMsgInfo.allowForward) {
getIBaseActivity().showToast(ak.im.b2.prohibit_forward);
return;
}
getIBaseActivity().dismissFullWindowDialog();
AkeyChatUtils.prepareTransmitArticle(this.l, this);
}
public void r() {
this.f1942b.setVisibility(8);
}
private String s(String str) {
if (TextUtils.isEmpty(str)) {
return null;
}
return ak.im.utils.n5.getHexString(ak.comm.d.encodeBytes(str.getBytes()).getBytes());
}
private ChatMessage t() {
String str;
List<WeakReference<Activity>> activityList = AKApplication.getActivityList();
if (activityList != null) {
for (int size = activityList.size() - 1; size > 0; size--) {
Activity activity = activityList.get(size).get();
if (activity instanceof BaseChatActivity) {
str = ((BaseChatActivity) activity).getWith();
break;
}
}
}
str = null;
User userMe = ak.im.sdk.manager.nf.getInstance().getUserMe();
if (TextUtils.isEmpty(str)) {
str = userMe.getJID();
}
String str2 = str;
if (this.n != null) {
ChatMessageBuilder chatMessageBuilder = new ChatMessageBuilder();
chatMessageBuilder.setChatType("single").setWith(str2).setMessageContentType(ChatMessage.CHAT_SHARE_WEB).setAppId(this.n.getAppId()).setAppName(this.n.getAppName()).setAppIcon(this.n.getAppSmallIcon()).setWebUrl(this.n.getWebUrl()).setWebDes(this.n.getDescription()).setWebThumbUrl(this.n.getWebLogoUrl()).setWebTitle(this.n.getTitle());
return MessageManager.generateOneShareWebMessage(chatMessageBuilder);
}
return MessageManager.generateOneTextMessage(this.i, "single", str2, IMMessage.NEVER_BURN, null, ak.comm.a.getEmptyString());
}
public void u0(View view) {
getIBaseActivity().dismissFullWindowDialog();
IMMessage.ArticleMsgInfo articleMsgInfo = this.l;
if (articleMsgInfo == null) {
Log.w("WebViewActivity", "article is null");
} else {
AkeyChatUtils.startChannelInfoActivity(this, articleMsgInfo.channelName);
}
}
private io.reactivex.z<ChatMessage> u(final String str) {
return AkeyChatUtils.getBitmapByBase64DataWithRX(str).flatMap(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
io.reactivex.e0 cacheWebViewBitmap;
cacheWebViewBitmap = AkeyChatUtils.cacheWebViewBitmap((Bitmap) obj, AkeyChatUtils.getMimeTypeByBase64Data(str));
return cacheWebViewBitmap;
}
}).flatMap(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return WebViewActivity.R((String) obj);
}
});
}
public void T(ArrayList<String> arrayList) {
JSONObject jSONObject = new JSONObject();
JSONObject jSONObject2 = new JSONObject();
JSONObject jSONObject3 = new JSONObject();
Iterator<String> it = arrayList.iterator();
while (it.hasNext()) {
String next = it.next();
String userNameByJid = ak.im.sdk.manager.nf.getInstance().getUserNameByJid(next);
if (userNameByJid.contains("_") && next.contains(Group.GROUPNAMESPLIT)) {
Group groupBySimpleName = ak.im.sdk.manager.df.getInstance().getGroupBySimpleName(userNameByJid);
if (groupBySimpleName != null) {
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put(SipCall.VOIP_GROUP_NAME, (Object) groupBySimpleName.getNickName());
JSONObject jSONObject5 = new JSONObject();
for (Map.Entry<String, GroupUser> entry : groupBySimpleName.getMemberMap().entrySet()) {
GroupUser value = entry.getValue();
jSONObject5.put(value.getName(), (Object) value.getUserNickname());
}
jSONObject4.put("memberinfo", (Object) jSONObject5);
jSONObject3.put(userNameByJid, (Object) jSONObject4);
} else {
Log.w("WebViewActivity", "g is null:" + userNameByJid);
}
} else {
User userByName = ak.im.sdk.manager.nf.getInstance().getUserByName(userNameByJid, false);
if (userByName != null) {
jSONObject2.put(userByName.getName(), (Object) userByName.getNickName());
} else {
Log.w("WebViewActivity", "u is null:" + userNameByJid);
}
}
}
jSONObject.put("users", (Object) jSONObject2);
jSONObject.put("groups", (Object) jSONObject3);
w("ak_selected_u_g_list", s(jSONObject.toJSONString()));
}
private void w(String str, String str2) {
this.a.loadUrl(String.format("javascript: handleAction(\"%s\",\"%s\")", str, str2));
}
public boolean x(String str) {
if (str == null) {
return false;
}
StringBuilder sb = new StringBuilder();
sb.append(AKApplication.getAsimPackageName());
sb.append("://splash/openwith");
return str.startsWith(sb.toString()) || str.startsWith("http://") || str.startsWith("https://");
}
public void z0(View view) {
getIBaseActivity().dismissFullWindowDialog();
}
@JavascriptInterface
public String getAndroidSystemInfo(String str) {
return ak.im.sdk.manager.ye.getInstance().getPropValue(str);
}
@JavascriptInterface
public String getAndroidVersion() {
return Build.VERSION.RELEASE;
}
@JavascriptInterface
public String getAppProduct() {
return BuildConfig.FLAVOR_akProduct;
}
@JavascriptInterface
public String getAppVersion() {
return ak.im.sdk.manager.ye.getInstance().getBigVersion();
}
@JavascriptInterface
public int getButtonValue(int i2) {
int checkOpForHm;
String phoneType = getPhoneType();
if ("xiaomi".equals(phoneType)) {
if (i2 == 1) {
checkOpForHm = AkeyChatUtils.checkOp(this.context, 10008);
} else if (i2 == 2) {
checkOpForHm = AkeyChatUtils.checkOp(this.context, 10021);
} else {
if (i2 == 7) {
checkOpForHm = AkeyChatUtils.checkOp(this.context, 10020);
}
checkOpForHm = -1;
}
} else if (!BadgeManager.MANUFACTURER_OF_HARDWARE_VIVO.equals(phoneType)) {
if (getRom().startsWith("hw_sc.build.platform.version") && i2 == 2) {
checkOpForHm = AkeyChatUtils.checkOpForHm(this.context);
}
checkOpForHm = -1;
} else if (i2 == 1) {
checkOpForHm = AkeyChatUtils.getVivoBgStartPermissionStatus(this.context, "bg_start_up_apps");
} else if (i2 == 2) {
checkOpForHm = AkeyChatUtils.getVivoBgStartPermissionStatus(this.context, "start_bg_activity");
} else {
if (i2 == 7) {
checkOpForHm = AkeyChatUtils.getVivoBgStartPermissionStatus(this.context, "control_locked_screen_action");
}
checkOpForHm = -1;
}
if (3 == i2) {
checkOpForHm = !AkeyChatUtils.isIgnoringBatteryOptimizations() ? 1 : 0;
}
if (5 == i2) {
checkOpForHm = !getIBaseActivity().ownFloatWindowPermission();
}
if (6 == i2) {
checkOpForHm = !getIBaseActivity().isAllowSendNotification();
}
if (8 == i2) {
checkOpForHm = !ak.im.sdk.manager.ye.getInstance().isHadStartForeground();
}
if (9 == i2) {
checkOpForHm = !ak.im.sdk.manager.ye.getInstance().isIgnoreCanLeave();
}
Log.i("getButtonValue", "rule is " + i2 + ",value is " + checkOpForHm);
return checkOpForHm;
}
@JavascriptInterface
public String getCurrentUserInfo() {
User userMe = ak.im.sdk.manager.nf.getInstance().getUserMe();
JSONObject jSONObject = new JSONObject();
jSONObject.put("phonenumber", (Object) userMe.getPhone());
jSONObject.put("name", (Object) userMe.getNickName());
jSONObject.put("idcard", (Object) ak.im.sdk.manager.ye.getInstance().getIDNO());
jSONObject.put("sex", (Object) userMe.getGender().toLowerCase());
jSONObject.put("group", (Object) userMe.getmGroup());
jSONObject.put(IMMessage.CARD_AVATAR_KEY, (Object) userMe.getHeadImgOrignal());
jSONObject.put(GroupUser.USER_NAME, (Object) ak.im.sdk.manager.ye.getInstance().getUsername());
jSONObject.put("token", (Object) ak.im.sdk.manager.ye.getInstance().getAccessToken());
String headImgThumb = userMe.getHeadImgThumb();
if (!TextUtils.isEmpty(headImgThumb)) {
if (!headImgThumb.startsWith(HttpHost.DEFAULT_SCHEME_NAME)) {
jSONObject.put(IMMessage.CARD_AVATAR_KEY, (Object) ak.im.utils.l4.getDownloadUrlByKey(headImgThumb));
} else {
jSONObject.put(IMMessage.CARD_AVATAR_KEY, (Object) headImgThumb);
}
}
try {
return ak.comm.a.stringToHex(ak.comm.d.encodeBytes(jSONObject.toJSONString().getBytes("utf-8")));
} catch (Exception e2) {
e2.printStackTrace();
return "some error happened";
}
}
@JavascriptInterface
public String getDeviceInfo() {
JSONObject jSONObject = new JSONObject();
jSONObject.put(StreamManagement.AckRequest.ELEMENT, (Object) ak.im.sdk.manager.ye.getInstance().getResource());
jSONObject.put("d1", (Object) Build.MANUFACTURER);
jSONObject.put("d2", (Object) Build.MODEL);
jSONObject.put("d3", (Object) AkeyChatUtils.getRom());
AKCDiscoverInstance queryDiscoverInstanceBy = AKCDiscoverInstance.Companion.queryDiscoverInstanceBy(AKCDiscoverManager.a.getInstance().getLastServerSearchKey());
jSONObject.put("ip", (Object) (queryDiscoverInstanceBy == null ? "" : queryDiscoverInstanceBy.getDeviceIp()));
return jSONObject.toJSONString();
}
@JavascriptInterface
public String getLanguage() {
return ak.comm.b.getLanguage();
}
@JavascriptInterface
@SuppressLint({"CheckResult"})
public String getLocation() {
if (checkCallingOrSelfPermission("android.permission.ACCESS_FINE_LOCATION") == 0) {
return AKApplication.getLocation();
}
getIBaseActivity().requestPermission("android.permission.ACCESS_FINE_LOCATION", "android.permission.ACCESS_COARSE_LOCATION").subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
WebViewActivity.this.P((Boolean) obj);
}
});
return null;
}
@JavascriptInterface
public String getOem() {
return ak.im.o1.get().getPackageName();
}
@JavascriptInterface
public String getPhoneType() {
return AKApplication.getRealPushType();
}
@JavascriptInterface
public String getRom() {
return AkeyChatUtils.getRom();
}
@JavascriptInterface
public void getShareTargetsInfo() {
if (!TextUtils.isEmpty(this.v) && !TextUtils.isEmpty(this.w)) {
String str = null;
if ("group".equals(this.w)) {
str = ak.im.utils.n5.getGroupNameBySimpleName(this.v);
} else if ("single".equals(this.w)) {
str = ak.im.utils.n5.getJidByName(this.v);
}
if (TextUtils.isEmpty(str)) {
Log.w("WebViewActivity", "illegal jid");
return;
}
final ArrayList arrayList = new ArrayList();
arrayList.add(str);
this.a.post(new Runnable() {
@Override
public final void run() {
WebViewActivity.this.T(arrayList);
}
});
return;
}
Intent intent = new Intent(this, UserListActivity.class);
intent.putExtra("purpose", "broadcast");
startActivityForResult(intent, 6);
}
@JavascriptInterface
public void goToOpen(String str) {
ak.im.sdk.manager.ye yeVar = ak.im.sdk.manager.ye.getInstance();
yeVar.setHadGotoNotifyWebForSip(true);
yeVar.setHadGotoNotifyWebForNormal(true);
Log.i("WebViewActivity", "goToOpen json is " + str);
try {
JSONObject parseObject = JSON.parseObject(str);
Intent intent = new Intent();
if (parseObject.containsKey("ComponentName")) {
intent.setComponent(new ComponentName((String) parseObject.getJSONObject("ComponentName").get("ComponentName_pkg"), (String) parseObject.getJSONObject("ComponentName").get("ComponentName_cls")));
}
if (parseObject.containsKey(AMPExtension.Action.ATTRIBUTE_NAME)) {
intent.setAction(parseObject.getString(AMPExtension.Action.ATTRIBUTE_NAME));
}
if (parseObject.containsKey("extra_pkg")) {
intent.putExtra(parseObject.getString("extra_pkg"), getPackageName());
}
try {
if (parseObject.containsKey("extra_list")) {
JSONObject jSONObject = parseObject.getJSONObject("extra_list");
for (String str2 : jSONObject.keySet()) {
String str3 = (String) jSONObject.get(str2);
if (str2.equals("key_need_flags")) {
intent.addFlags(Integer.parseInt(str3));
} else {
if ("value_need_pg".equals(str3)) {
str3 = getPackageName();
} else if ("value_need_name".equals(str3)) {
str3 = getString(ak.im.b2.app_name);
} else if ("value_need_id".equals(str3)) {
str3 = getApplicationInfo().uid + "";
}
intent.putExtra(str2, str3);
}
}
}
} catch (Exception e2) {
e2.printStackTrace();
Log.e("WebViewActivity", "extra_list failed ,e is " + e2.getMessage());
}
if (parseObject.containsKey(AMPExtension.Rule.ELEMENT)) {
toSet(((Integer) parseObject.get(AMPExtension.Rule.ELEMENT)).intValue(), parseObject.containsKey("value") ? ((Integer) parseObject.get("value")).intValue() : -1);
} else {
startActivity(intent);
}
} catch (Exception unused) {
Intent intent2 = new Intent();
intent2.addFlags(User.UserStatus.camera_on);
intent2.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
intent2.setData(Uri.fromParts("package", getPackageName(), null));
startActivity(intent2);
}
}
@JavascriptInterface
public void handleJSClickEvent(String str) {
try {
JSONObject parseObject = JSON.parseObject(str);
String string = parseObject.getString(AMPExtension.Action.ATTRIBUTE_NAME);
String string2 = parseObject.getString("data");
if (TextUtils.isEmpty(string)) {
Log.w("WebViewActivity", "illegal json data:" + str);
return;
}
if ("go_to_channel_info".equals(string)) {
AkeyChatUtils.startChannelInfoActivity(this, string2);
} else if ("ak-cancel-title".equals(string)) {
final View findViewById = findViewById(ak.im.w1.main_head);
findViewById.post(new Runnable() {
@Override
public final void run() {
findViewById.setVisibility(8);
}
});
} else if ("ak-back".equals(string)) {
finish();
} else if ("ak-phone-call".equals(string)) {
AkeyChatUtils.startCallPhone(getIBaseActivity(), string2);
} else if ("ak-choose-picture".equals(string)) {
AkeyChatUtils.showDialogChooseImage(getIBaseActivity());
}
Log.i("WebViewActivity", "js invoke this method and we get action:" + parseObject.toJSONString());
} catch (Exception e2) {
e2.printStackTrace();
}
}
@JavascriptInterface
public void invokeAndroidMethodAsync(String str, String str2) {
}
@JavascriptInterface
public String invokeAndroidMethodSync(String str, String str2) {
JSONObject jSONObject;
if (!"myb-sign".equals(str) && "set_bottom_navigation_bar".equals(str)) {
try {
jSONObject = JSON.parseObject(str2);
} catch (Exception e2) {
Log.w("WebViewActivity", "set_bottom_navigation_bar JS API action data invalid: " + str2);
e2.printStackTrace();
jSONObject = null;
}
if (jSONObject != null) {
if (jSONObject.getInteger("switch").intValue() == 1) {
Log.i("WebViewActivity", "set_bottom_navigation_bar open the switch");
this.f = true;
} else {
Log.i("WebViewActivity", "set_bottom_navigation_bar close the switch");
this.f = false;
}
K0();
}
}
return null;
}
@Override
public void onActivityResult(int i2, int i3, Intent intent) {
super.onActivityResult(i2, i3, intent);
if (i2 == 3) {
this.a.onActivityResult(51426, i3, intent);
} else if (i2 == 4) {
try {
File file = new File(ak.im.sdk.manager.ye.getInstance().getUriForWeb());
if (intent == null) {
intent = new Intent();
}
intent.setData(AkeyChatUtils.getUriByFileProvider(this, file));
this.a.onActivityResult(51426, i3, intent);
} catch (Exception e2) {
Log.i("WebViewActivity", "REQCODE_MOD_IMAGE_BY_CAPTURE failed,error is " + e2.getMessage());
e2.printStackTrace();
}
} else {
this.a.onActivityResult(i2, i3, intent);
if (i3 == -1 && i2 == 6) {
S(intent.getStringArrayListExtra(ak.im.module.User.userListKey));
}
}
}
@Override
public void onCreate(Bundle bundle) {
requestWindowFeature(1);
super.onCreate(bundle);
if (!AKApplication.isAppDebug() && !AKCAppConfiguration.a.isSecure(ak.im.sdk.manager.ye.getInstance().getServerId())) {
getWindow().addFlags(8192);
}
setContentView(ak.im.x1.activity_webview_layout);
init();
if (this.i == null) {
finish();
} else {
I0();
}
}
@Override
public void onDestroy() {
super.onDestroy();
String str = this.i;
if (str != null && str.lastIndexOf("?") > 0) {
String notifyCheck = AKCAppConfiguration.a.getNotifyCheck();
String str2 = this.i;
if (notifyCheck.startsWith(str2.substring(0, str2.lastIndexOf("?")))) {
AkeyChatUtils.reportNotifySetting();
}
}
try {
AdvancedWebView advancedWebView = this.a;
if (advancedWebView != null) {
advancedWebView.destroy();
}
AdvancedWebView advancedWebView2 = this.a;
if (advancedWebView2 != null) {
advancedWebView2.clearHistory();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
@Override
public void onDownloadRequested(final String str, String str2, String str3, long j2, String str4, String str5) {
getIBaseActivity().showAlertDialog(getString(ak.im.b2.open_other_web), getString(ak.im.b2.open), getString(ak.im.b2.cancel), new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.i0(str, view);
}
}, new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.k0(view);
}
});
}
@Override
public void onExternalPageRequest(String str) {
}
@Override
public void onPageError(int i2, String str, String str2) {
}
@Override
public void onPageFinished(String str) {
}
@Override
public void onPageStarted(String str, Bitmap bitmap) {
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onResume() {
super.onResume();
J0();
this.a.onResume();
this.a.postDelayed(new Runnable() {
@Override
public final void run() {
WebViewActivity.this.p();
}
}, 200L);
io.reactivex.z.timer(1L, TimeUnit.SECONDS).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(new f());
}
@JavascriptInterface
public void openImage(final String str) {
getIBaseActivity().showPGDialog(ak.im.b2.please_wait);
io.reactivex.z.just(str).flatMap(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return WebViewActivity.l0(str, r2, (String) obj);
}
}).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(new a());
}
protected void popupWindow() {
View inflate;
if (!"ak-url".equals(this.u) && !"ak-share-web".equals(this.u) && !"work-space".equals(this.u) && !"bot-menu".equals(this.u)) {
inflate = getLayoutInflater().inflate(ak.im.x1.article_popup_layout, (ViewGroup) null);
View findViewById = inflate.findViewById(ak.im.w1.ll_transmit);
View findViewById2 = inflate.findViewById(ak.im.w1.ll_favorite);
View findViewById3 = inflate.findViewById(ak.im.w1.ll_check);
View findViewById4 = inflate.findViewById(ak.im.w1.ll_refresh);
findViewById.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.r0(view);
}
});
findViewById2.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.s0(view);
}
});
findViewById3.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.u0(view);
}
});
findViewById4.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.v0(view);
}
});
((TextView) inflate.findViewById(ak.im.w1.tv_cancel)).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.w0(view);
}
});
inflate.findViewById(ak.im.w1.ll_download_record).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.x0(view);
}
});
} else {
inflate = getLayoutInflater().inflate(ak.im.x1.open_with_other_browser_popup_layout, (ViewGroup) null);
View findViewById5 = inflate.findViewById(ak.im.w1.ll_open);
View findViewById6 = inflate.findViewById(ak.im.w1.tv_cancel);
View findViewById7 = inflate.findViewById(ak.im.w1.ll_refresh);
View findViewById8 = inflate.findViewById(ak.im.w1.ll_transmit);
View findViewById9 = inflate.findViewById(ak.im.w1.ll_favorite);
findViewById8.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.B0(view);
}
});
findViewById9.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.D0(view);
}
});
findViewById6.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.F0(view);
}
});
findViewById5.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.H0(view);
}
});
findViewById7.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.n0(view);
}
});
inflate.findViewById(ak.im.w1.ll_download_record).setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.p0(view);
}
});
}
inflate.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.z0(view);
}
});
getIBaseActivity().showFullWindowDialog(inflate);
}
protected void q(final String str) {
this.x = null;
int screenHeight = ak.im.utils.p5.screenHeight() - ak.im.utils.p5.getStatusBarHeight(this);
View inflate = getLayoutInflater().inflate(ak.im.x1.popup_image_long_click, (ViewGroup) null);
View findViewById = inflate.findViewById(ak.im.w1.btn_send);
View findViewById2 = inflate.findViewById(ak.im.w1.btn_favorite);
View findViewById3 = inflate.findViewById(ak.im.w1.btn_save);
View findViewById4 = inflate.findViewById(ak.im.w1.btn_recognise);
View findViewById5 = inflate.findViewById(ak.im.w1.btn_cancel);
final PopupWindow popupWindow = new PopupWindow(inflate, -1, screenHeight, true);
findViewById.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.B(popupWindow, str, view);
}
});
findViewById2.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.E(popupWindow, str, view);
}
});
findViewById5.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
popupWindow.dismiss();
}
});
findViewById3.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.K(popupWindow, str, view);
}
});
findViewById4.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
WebViewActivity.this.M(popupWindow, view);
}
});
findViewById4.setVisibility(8);
AkeyChatUtils.getBitmapByBase64DataWithRX(str).flatMap(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
return ak.im.utils.f5.readQRCodeInfoFromBitmapByRX((Bitmap) obj);
}
}).subscribeOn(io.reactivex.w0.a.io()).observeOn(io.reactivex.q0.c.a.mainThread()).subscribe(new j(findViewById4));
popupWindow.setTouchable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
inflate.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
popupWindow.dismiss();
}
});
popupWindow.setAnimationStyle(0);
ImageView imageView = this.f1945e;
popupWindow.showAsDropDown(imageView, 0, -imageView.getHeight());
}
public void synCookies(Context context, String str, String str2) {
CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.setCookie(str, str2);
CookieSyncManager.getInstance().sync();
}
public void toSet(int i2, int i3) {
Log.i("WebViewActivity", "toSet " + i2 + ",value " + i3);
if (i2 == 6) {
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("app_package", this.context.getPackageName());
intent.putExtra("app_uid", this.context.getApplicationInfo().uid);
intent.putExtra("android.provider.extra.APP_PACKAGE", this.context.getPackageName());
this.context.startActivity(intent);
}
if (i2 == 5) {
getIBaseActivity().gotoFloatingWindowSettings();
}
if (i2 == 3) {
if (Build.VERSION.SDK_INT < 23) {
getIBaseActivity().showToast(getString(ak.im.b2.android_m_can_use_only));
return;
}
try {
AkeyChatUtils.checkBatteryOptimizations(this);
} catch (Exception e2) {
getIBaseActivity().showToast(getString(ak.im.b2.sorry_device_cannot_support));
e2.printStackTrace();
}
}
if (i2 == 8 && Build.VERSION.SDK_INT >= 26) {
if (i3 == 0 && !ak.im.sdk.manager.ye.getInstance().isHadStartForeground()) {
ak.im.sdk.manager.ye.getInstance().setOpenForeground(true);
ak.im.sdk.manager.ye.getInstance().setHadStartForeground(true);
sendBroadcast(new Intent(AKCoreService.f1287b));
} else if (i3 == 1 && ak.im.sdk.manager.ye.getInstance().isHadStartForeground()) {
if (VoIpManager.getInstance().getmCurrentCall() != null) {
getIBaseActivity().showToast("您当前正在语音通话中,为避免影响通话稳定性,请通话结束后再设置");
} else {
ak.im.sdk.manager.ye.getInstance().setOpenForeground(false);
ak.im.sdk.manager.ye.getInstance().setHadStartForeground(false);
sendBroadcast(new Intent(AKCoreService.f1287b));
}
}
}
if (i2 == 9) {
ak.im.sdk.manager.ye.getInstance().setIgnoreCanLeave(i3 == 0);
}
}
}