package cn.jpush.android.ui; import android.app.Activity; import android.app.ActivityManager; import android.content.ComponentName; import android.content.Intent; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.KeyEvent; import android.view.Menu; import android.view.View; import android.view.WindowManager; import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.ImageButton; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; import cn.jpush.android.helper.Logger; import cn.jpush.android.local.ProxyActivityAction; import cn.jpush.android.p.b; import cn.jpush.android.u.a; import cn.jpush.android.u.e; import cn.jpush.android.u.g; import cn.jpush.android.webview.bridge.HostJsScope; import cn.jpush.android.webview.bridge.d; import java.io.File; public class c extends ProxyActivityAction { public static d a; private int b = 0; private boolean c = false; private String d; private WebView e; private RelativeLayout f; private TextView g; private ImageButton h; private ProgressBar i; private View.OnClickListener j = new View.OnClickListener() { /* class cn.jpush.android.ui.c.AnonymousClass2 */ public void onClick(View view) { if (view != null) { try { if (view.getContext() != null && (view.getContext() instanceof Activity)) { ((Activity) view.getContext()).onBackPressed(); } } catch (Throwable unused) { } } } }; private cn.jpush.android.d.d a(Activity activity, Intent intent) { cn.jpush.android.d.d a2 = b.a(activity, activity.getIntent()); if (a2 != null) { return a2; } Logger.dd("PushActivityImpl", "parse entity form plugin plateform"); String str = null; if (intent.getData() != null) { str = intent.getData().toString(); } if (TextUtils.isEmpty(str) && intent.getExtras() != null) { str = intent.getExtras().getString("JMessageExtra"); } Logger.d("PushActivityImpl", "content:" + str); return cn.jpush.android.t.b.a(activity, str, ""); } private void a(Activity activity, cn.jpush.android.d.d dVar) { if (dVar == null) { Logger.ww("PushActivityImpl", "Null message entity! Close PushActivity!"); } else if (dVar.p != 0) { Logger.w("PushActivityImpl", "Invalid msg type to show - " + dVar.p); b.b(activity, dVar); } else { activity.setRequestedOrientation(1); b(activity, dVar); return; } activity.finish(); } private void b() { try { g.a(this.e, "addJavascriptInterface", new Class[]{Object.class, String.class}, new Object[]{a, "JPushWeb"}); } catch (Exception e2) { e2.printStackTrace(); Logger.e("PushActivityImpl", "addJavascriptInterface failed:" + e2.toString()); } } private void b(Activity activity) { if (activity.getIntent() != null) { try { this.c = activity.getIntent().getBooleanExtra(PushActivity.FROM_OTHER_WAY, false); cn.jpush.android.d.d a2 = a(activity, activity.getIntent()); if (a2 != null) { this.d = a2.c; a(activity, a2); return; } Logger.ww("PushActivityImpl", "Warning,null message entity! Close PushActivity!"); activity.finish(); } catch (Exception e2) { Logger.ee("PushActivityImpl", "Extra data is not serializable!"); e2.printStackTrace(); } } else { Logger.ww("PushActivityImpl", "PushActivity get NULL intent!"); activity.finish(); } } private void b(Activity activity, cn.jpush.android.d.d dVar) { String str; String str2; Logger.i("PushActivityImpl", "Action: processShow"); if (dVar == null) { Logger.ww("PushActivityImpl", "Null message entity! Close PushActivity!"); } else { if (dVar.X == 0) { this.b = dVar.V; int identifier = activity.getResources().getIdentifier("jpush_webview_layout", "layout", activity.getPackageName()); if (identifier == 0) { str = "PushActivityImpl"; str2 = "Please add layout resource jpush_webview_layout.xml to res/layout !"; } else { activity.setContentView(identifier); String str3 = dVar.S; if (!a.a(str3)) { b.b(activity, dVar); } else { String str4 = dVar.U; if (dVar.q) { int identifier2 = activity.getResources().getIdentifier("actionbarLayoutId", "id", activity.getPackageName()); if (identifier2 == 0) { str = "PushActivityImpl"; str2 = "Please use default code in jpush_webview_layout.xml!"; } else { a(activity, activity.findViewById(identifier2), dVar); if (TextUtils.isEmpty(str4) || !new File(str4.replace("file://", "")).exists() || this.c) { this.e.loadUrl(str3); } else { this.e.loadUrl(str4); } } } if (!this.c) { cn.jpush.android.helper.c.a(this.d, 1000, activity.getApplicationContext()); } } } Logger.ee(str, str2); } int i2 = dVar.W; return; } activity.finish(); } private void c(Activity activity) { try { WindowManager.LayoutParams attributes = activity.getWindow().getAttributes(); attributes.flags &= -1025; activity.getWindow().setAttributes(attributes); activity.getWindow().clearFlags(512); } catch (Throwable unused) { Logger.w("PushActivityImpl", "quitFullScreen errno"); } } public void a() { try { if (this.f != null && this.f.getVisibility() == 8) { this.f.setVisibility(0); c((Activity) this.f.getContext()); this.h.setOnClickListener(this.j); if (this.e != null) { this.e.postDelayed(new e("PushActivityImpl#showTitleBar") { /* class cn.jpush.android.ui.c.AnonymousClass3 */ @Override // cn.jpush.android.u.e public void a() { try { if (c.this.e != null) { c.this.e.clearHistory(); } } catch (Throwable unused) { } } }, 1000); } } } catch (Throwable unused) { } } public void a(Activity activity) { activity.finish(); if (1 == this.b) { try { ActivityManager activityManager = (ActivityManager) activity.getSystemService("activity"); ComponentName componentName = activityManager.getRunningTasks(1).get(0).baseActivity; ComponentName componentName2 = activityManager.getRunningTasks(1).get(0).topActivity; Logger.d("PushActivityImpl", "baseActivity = " + componentName.toString()); Logger.d("PushActivityImpl", "topActivity = " + componentName2.toString()); if (componentName != null && componentName2 != null && componentName2.toString().equals(componentName.toString())) { a.e(activity); } } catch (Exception unused) { Logger.ww("PushActivityImpl", "Get running tasks failed."); a.e(activity); } } } public void a(Activity activity, View view, cn.jpush.android.d.d dVar) { String str = dVar.T; view.setFocusable(true); this.e = (WebView) activity.findViewById(activity.getResources().getIdentifier("fullWebView", "id", activity.getPackageName())); this.f = (RelativeLayout) activity.findViewById(activity.getResources().getIdentifier("rlRichpushTitleBar", "id", activity.getPackageName())); this.g = (TextView) activity.findViewById(activity.getResources().getIdentifier("tvRichpushTitle", "id", activity.getPackageName())); this.h = (ImageButton) activity.findViewById(activity.getResources().getIdentifier("imgRichpushBtnBack", "id", activity.getPackageName())); this.i = (ProgressBar) activity.findViewById(activity.getResources().getIdentifier("pushPrograssBar", "id", activity.getPackageName())); if (this.e == null || this.f == null || this.g == null || this.h == null) { Logger.ee("PushActivityImpl", "Please use default code in jpush_webview_layout.xml!"); activity.finish(); } if (1 == dVar.W) { this.f.setVisibility(8); activity.getWindow().setFlags(1024, 1024); } else { this.g.setText(str); this.h.setOnClickListener(this.j); } this.e.setScrollbarFadingEnabled(true); this.e.setScrollBarStyle(33554432); WebSettings settings = this.e.getSettings(); a.a(settings); a.a(this.e); settings.setSavePassword(false); a = new d(activity, dVar); if (Build.VERSION.SDK_INT >= 17) { Logger.dd("PushActivityImpl", "Android sdk version greater than or equal to 17, Java—Js interact by annotation!"); b(); } this.e.setWebChromeClient(new cn.jpush.android.webview.bridge.a("JPushWeb", HostJsScope.class, this.i, this.g)); this.e.setWebViewClient(new a(dVar, activity)); HostJsScope.setWebViewHelper(a); } @Override // cn.jpush.android.local.ProxyActivityAction public void onBackPressed(Activity activity) { WebView webView = this.e; if (webView == null || !webView.canGoBack()) { cn.jpush.android.helper.c.a(this.d, 1006, activity); a(activity); return; } this.e.goBack(); } @Override // cn.jpush.android.local.ProxyActivityAction public void onConfigurationChanged(Activity activity, Configuration configuration) { } @Override // cn.jpush.android.local.ProxyActivityAction public void onCreate(Activity activity, Bundle bundle) { a.d(activity); b(activity); } @Override // cn.jpush.android.local.ProxyActivityAction public boolean onCreateOptionsMenu(Activity activity, Menu menu) { return false; } @Override // cn.jpush.android.local.ProxyActivityAction public void onDestroy(Activity activity) { WebView webView = this.e; if (webView != null) { webView.removeAllViews(); this.e.clearSslPreferences(); this.e.destroy(); this.e = null; } } @Override // cn.jpush.android.local.ProxyActivityAction public void onEvent(Activity activity, String str, Bundle bundle) { if (!TextUtils.isEmpty(str) && str.equals("push_show_titlebar")) { activity.runOnUiThread(new e("PushActivityImpl#onEvent") { /* class cn.jpush.android.ui.c.AnonymousClass1 */ @Override // cn.jpush.android.u.e public void a() { c.this.a(); } }); } } @Override // cn.jpush.android.local.ProxyActivityAction public boolean onKeyDown(Activity activity, int i2, KeyEvent keyEvent) { return false; } @Override // cn.jpush.android.local.ProxyActivityAction public void onNewIntent(Activity activity, Intent intent) { activity.setIntent(intent); b(activity); } @Override // cn.jpush.android.local.ProxyActivityAction public void onPause(Activity activity) { if (this.e != null && Build.VERSION.SDK_INT >= 11) { this.e.onPause(); } } @Override // cn.jpush.android.local.ProxyActivityAction public void onRestart(Activity activity) { } @Override // cn.jpush.android.local.ProxyActivityAction public void onResume(Activity activity) { if (this.e != null) { if (Build.VERSION.SDK_INT >= 11) { this.e.onResume(); } HostJsScope.setWebViewHelper(a); } } @Override // cn.jpush.android.local.ProxyActivityAction public void onStart(Activity activity, Intent intent) { } @Override // cn.jpush.android.local.ProxyActivityAction public void onStop(Activity activity) { } }