Active IQ v6.7.1版本的 MD5 值为:5082594ca2b69fbfbe64e6d6ee2159a7
以下内容为反编译后的 WhatsNewDialog.java 源代码,内容仅作参考
package com.netapp.myautosupport.presentation.whatsnew;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.ColorDrawable;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
import com.flurry.android.FlurryAgent;
import com.netapp.myautosupport.MyAsupApplication;
import com.netapp.myautosupport.R;
import com.netapp.myautosupport.common.AppConstants;
import com.netapp.myautosupport.common.SharedPreferenceHandle;
import com.netapp.myautosupport.common.Utils;
import com.netapp.myautosupport.presentation.newsletter.NewsLetterDialog;
import com.netapp.myautosupport.presentation.whatsnew.WhatsNewContract;
import java.util.HashMap;
import java.util.Map;
public class WhatsNewDialog extends Dialog implements View.OnClickListener, WhatsNewContract.View {
public String TAG;
public Context activity;
public Dialog dialog;
public String mHTMLContent;
public SharedPreferenceHandle sharedPreferenceHandle;
public boolean showNewsLetterDialog;
public String url;
private WebView webView;
@Override
public void hideLoading() {
}
@Override
public void showError(String str) {
}
@Override
public void showLoading() {
}
@Override
public void showUpgrade(String str) {
}
@Override
public void timeoutError() {
}
public WhatsNewDialog(Context context, String str, boolean z) {
super(context, 16973841);
this.TAG = WhatsNewDialog.class.getSimpleName();
this.activity = context;
this.mHTMLContent = str;
this.showNewsLetterDialog = z;
}
@Override
protected void onCreate(Bundle bundle) {
requestWindowFeature(1);
getWindow().setFlags(1024, 1024);
getWindow().setBackgroundDrawable(new ColorDrawable(0));
super.onCreate(bundle);
this.sharedPreferenceHandle = SharedPreferenceHandle.getSharedPreferenceHandle(this.activity);
setContentView(R.layout.dialog_whats_new);
((TextView) findViewById(R.id.dialog_whats_new_okay)).setOnClickListener(this);
this.webView = (WebView) findViewById(R.id.dialog_whats_new_webview);
this.webView.setInitialScale(1);
WebSettings settings = this.webView.getSettings();
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
settings.setSupportZoom(false);
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setPluginState(WebSettings.PluginState.ON);
settings.setDomStorageEnabled(true);
settings.setDefaultFontSize((int) this.activity.getResources().getDimension(R.dimen.detail_screen_textsize14));
this.webView.setVisibility(0);
CookieSyncManager.createInstance(this.webView.getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeAllCookie();
String str = MyAsupApplication.SSO_COOKIE + "; domain=netapp.com; path=/; secure=true; httponly";
cookieManager.setCookie("netapp.com", str);
if (Build.VERSION.SDK_INT >= 21) {
cookieManager.setAcceptThirdPartyCookies(this.webView, true);
} else {
cookieManager.acceptCookie();
}
CookieSyncManager.getInstance().sync();
HashMap hashMap = new HashMap();
hashMap.put("Cookie", str);
loadContent(this.mHTMLContent);
this.webView.setWebViewClient(new AnonymousClass1(hashMap));
}
class AnonymousClass1 extends WebViewClient {
final Map val$cookies;
AnonymousClass1(Map map) {
this.val$cookies = map;
}
@Override
@RequiresApi(api = 21)
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
webView.loadUrl(webResourceRequest.getUrl().toString(), this.val$cookies);
webView.setBackgroundResource(R.color.white);
return true;
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
Log.e(WhatsNewDialog.this.TAG, "onPageFinished: ");
WebView webView2 = WhatsNewDialog.this.webView;
webView2.loadUrl("javascript:document.getElementById('navigationText')style.fontFamily =src:url('file:///android_asset/fonts/Montserrat-Regular.ttf');");
}
@Override
@RequiresApi(api = 23)
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
super.onReceivedError(webView, webResourceRequest, webResourceError);
Log.e(WhatsNewDialog.this.TAG, "onReceivedError: ");
Utils.getInstance().showDialogWithOneButton(WhatsNewDialog.this.activity, webResourceError.getDescription().toString());
}
@Override
public void onReceivedSslError(WebView webView, final SslErrorHandler sslErrorHandler, SslError sslError) {
AlertDialog.Builder builder = new AlertDialog.Builder(WhatsNewDialog.this.activity);
builder.setMessage(R.string.notification_error_ssl_cert_invalid);
builder.setPositiveButton("continue", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
sslErrorHandler.proceed();
}
});
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i) {
sslErrorHandler.cancel();
}
});
builder.create().show();
}
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.dialog_whats_new_okay) {
FlurryAgent.logEvent("What's New");
dismiss();
if (this.showNewsLetterDialog) {
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_NEWSLETTER, false);
new NewsLetterDialog(this.activity).show();
}
}
}
@Override
public void success(String str) {
loadContent(str);
}
private void loadContent(String str) {
if (str.contains("<html")) {
showData(String.format("<html>\n<title>Active IQ What's New</title>\n<head>\n<style type=\"text/css\">\n @font-face {\n font-family: MyFont;\n src: url(\"file:///android_asset/fonts/Montserrat-Regular.ttf\");\n }\n body {\n font-family: MyFont;\n color: #000000;\n font-style: normal;\n }\n</style>\n</head>\n\n%s\n</body>\n</html>", str.substring(str.indexOf("<body"), str.indexOf("</body>"))));
}
}
@JavascriptInterface
public void showData(String str) {
hideLoading();
this.webView.loadDataWithBaseURL("file:///android_asset/", str.toString(), AppConstants.TEXT_OR_HTML, "utf-8", null);
}
}