导航菜单

页面标题

页面副标题

Tasker v6.5.11 - HTMLView.java 源代码

正在查看: Tasker v6.5.11 应用的 HTMLView.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package net.dinglisch.android.taskerm;

import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import com.joaomgcd.taskerm.spawn.RFactory;
import com.joaomgcd.taskerm.util.ExtensionsContextKt;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import net.dinglisch.android.taskerm.HTMLView;

public class HTMLView extends MyActivity implements pf.a {
    private static String C = "<(?:TITLE|H\\d)>(?:Tasker:\\s*)?(.*)</(?:TITLE|H\\d)>";
    private String A;
    private g v;
    private WebView x;
    private String z;
    private BroadcastReceiver w = null;
    private qf.o y = new qf.o(this);
    private ProgressDialog B = null;

    class a implements FileFilter {
        a() {
        }

        @Override
        public boolean accept(File file) {
            String name = file.getName();
            return name.endsWith(".html") && !name.endsWith("index.html");
        }
    }

    class b extends Handler {
        b() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what != 1) {
                HTMLView.this.finish();
            } else {
                HTMLView.this.y0(message.getData().getInt("index"));
            }
        }
    }

    class c extends BroadcastReceiver {
        final File a;
        final String b;

        c(File file, String str) {
            this.a = file;
            this.b = str;
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            com.joaomgcd.taskerm.util.f1.e(intent);
            HTMLView.this.q0();
            if (intent.getBooleanExtra("success", false)) {
                File file = new File(this.a, HTMLView.this.A);
                HTMLView.this.z = "file:///" + file.toString();
            } else {
                HTMLView hTMLView = HTMLView.this;
                hTMLView.z = hTMLView.D0(this.b, hTMLView.A);
            }
            HTMLView hTMLView2 = HTMLView.this;
            hTMLView2.C0(hTMLView2.z);
        }
    }

    class d implements DialogInterface.OnCancelListener {
        d() {
        }

        @Override
        public void onCancel(DialogInterface dialogInterface) {
            HTMLView.this.finish();
        }
    }

    class e extends f {
        public e(HTMLView hTMLView) {
            super(hTMLView);
        }

        public Boolean e(WebResourceError webResourceError) {
            return Boolean.valueOf(HTMLView.this.y.h0(webResourceError));
        }

        public Boolean f(WebResourceError webResourceError) {
            return Boolean.valueOf(!HTMLView.this.y.g0(webResourceError));
        }

        public static Boolean g(WebResourceResponse webResourceResponse) {
            return Boolean.valueOf(webResourceResponse.getStatusCode() == 404);
        }

        public static Boolean h(WebResourceResponse webResourceResponse) {
            return Boolean.valueOf(webResourceResponse.getStatusCode() == 404);
        }

        @Override
        public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
            super.onReceivedError(webView, webResourceRequest, webResourceError);
            HTMLView.this.y.f0(HTMLView.this.x, webResourceRequest, webResourceError, new xj.l() {
                @Override
                public final Object invoke(Object obj) {
                    Boolean e;
                    e = HTMLView.e.this.e((WebResourceError) obj);
                    return e;
                }
            }, new xj.l() {
                @Override
                public final Object invoke(Object obj) {
                    Boolean f;
                    f = HTMLView.e.this.f((WebResourceError) obj);
                    return f;
                }
            });
        }

        @Override
        public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
            super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
            HTMLView.this.y.f0(HTMLView.this.x, webResourceRequest, webResourceResponse, new xj.l() {
                @Override
                public final Object invoke(Object obj) {
                    Boolean g;
                    g = HTMLView.e.g((WebResourceResponse) obj);
                    return g;
                }
            }, new xj.l() {
                @Override
                public final Object invoke(Object obj) {
                    Boolean h;
                    h = HTMLView.e.h((WebResourceResponse) obj);
                    return h;
                }
            });
        }
    }

    private class f extends WebViewClient {
        HTMLView a;

        public f(HTMLView hTMLView) {
            this.a = hTMLView;
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            if (!tp.l(HTMLView.this)) {
                String substring = dh.e(tp.L(HTMLView.this), false).substring(2);
                String e = dh.e(up.n(HTMLView.this), false);
                if (e.length() > 6) {
                    e = e.substring(e.length() - 6);
                }
                webView.evaluateJavascript("document.body.style.setProperty(\"color\", \"#" + substring + "\");\nvar links = document.getElementsByTagName(\"a\");\nfor(var i=0;i<links.length;i++)\n{\n        if(links[i].href)\n        {\n            links[i].style.color = \"#" + e + "\";  \n        }\n}  ", null);
            }
            HTMLView.this.invalidateOptionsMenu();
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView webView, String str) {
            if (str.startsWith("file://") || str.startsWith("https://tasker.joaoapps.com/userguide")) {
                return false;
            }
            this.a.s0(str);
            return true;
        }
    }

    public enum g {
        Confirm,
        Inform,
        InformWithAccept
    }

    public static String A0(Resources resources, int i) {
        return vh.j(resources, RFactory.layout.runlog_item)[i];
    }

    public static int B0(Resources resources, String str) {
        return dq.v3(str, vh.j(resources, RFactory.layout.runlog_item));
    }

    public void C0(String str) {
        if (str != null) {
            WebSettings settings = this.x.getSettings();
            settings.setDefaultTextEncodingName("utf-8");
            settings.setJavaScriptEnabled(true);
            this.x.loadUrl(str);
        }
    }

    public static void E0(android.content.Context r23, net.dinglisch.android.taskerm.bm r24, java.lang.String r25, net.dinglisch.android.taskerm.cm.a r26, java.util.List<net.dinglisch.android.taskerm.cm> r27) {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.HTMLView.E0(android.content.Context, net.dinglisch.android.taskerm.bm, java.lang.String, net.dinglisch.android.taskerm.cm$a, java.util.List):void");
    }

    public static ProgressDialog F0(Activity activity) {
        ProgressDialog show = ProgressDialog.show(activity, vh.g(activity, 2131887474, new Object[0]), vh.g(activity, 2131887299, new Object[0]), true);
        show.setCancelable(true);
        return show;
    }

    public static void G0(Activity activity, String str) {
        H0(activity, str, -1, g.Inform);
    }

    public static void H0(Activity activity, String str, int i, g gVar) {
        activity.startActivityForResult(w0(activity, str, gVar), i);
    }

    private void I0(String str, String str2) {
        String D0 = D0(str, str2);
        this.z = D0;
        C0(D0);
    }

    private void J0() {
        wj.D(this, new b(), 2131887473).I(vh.i(this, RFactory.layout.lock_icon)).C(this);
    }

    public void q0() {
        BroadcastReceiver broadcastReceiver = this.w;
        if (broadcastReceiver != null) {
            unregisterReceiver(broadcastReceiver);
            this.w = null;
        }
        ProgressDialog progressDialog = this.B;
        if (progressDialog != null) {
            progressDialog.dismiss();
            this.B = null;
        }
    }

    public static boolean r0(Activity activity, String str) {
        File v0 = v0(str);
        if (v0 == null) {
            dq.a0(activity, 2131887724, v0);
        } else {
            if (dq.o2(v0)) {
                String str2 = str + "." + u0(activity.getResources(), str) + ".zip";
                dq.Q(activity, vh.g(activity, 2131887474, new Object[0]), Uri.parse("https://tasker.joaoapps.com/userguide/" + str + "/zip/" + str2), new File(v0, str2), "application/zip", null);
                return true;
            }
            dq.a0(activity, 2131887828, v0);
        }
        return false;
    }

    public void s0(String str) {
        dq.l3(this, new Intent("android.intent.action.VIEW", Uri.parse(str)));
    }

    private String t0(String str, String str2) {
        AssetManager assets = getResources().getAssets();
        String str3 = null;
        try {
            if (dq.v3(str2, assets.list(str)) != -1) {
                str3 = "file:///android_asset/" + str + "/" + str2;
            } else if (dq.v3(str2, assets.list("")) != -1) {
                str3 = "file:///android_asset/" + str2;
            }
        } catch (IOException e2) {
            r7.l("HV", "checkShowDoc", e2);
        }
        return str3;
    }

    public static String u0(Resources resources, String str) {
        return vh.j(resources, RFactory.layout.runlog)[B0(resources, str)];
    }

    public static File v0(String str) {
        if (dq.c1() != null) {
            return new File(new File(dq.k1(), "userguide"), str);
        }
        r7.f("HV", "no SD card");
        return null;
    }

    public static Intent w0(Activity activity, String str, g gVar) {
        return new Intent(activity, (Class<?>) HTMLView.class).putExtra("url", str).putExtra("sty", gVar.ordinal());
    }

    private String x0(String str) {
        SharedPreferences sharedPreferences = getSharedPreferences(g6.g, 0);
        String b2 = w6.b(sharedPreferences);
        String t0 = t0(b2, str);
        this.z = t0;
        if (t0 == null) {
            File v0 = v0(b2);
            if (v0 == null) {
                this.z = D0(b2, str);
            } else {
                dq.o2(v0);
                File file = new File(v0, str);
                File file2 = new File(v0, u0(getResources(), b2));
                r7.f("HV", "docfile: " + file.toString());
                r7.f("HV", "versionfile: " + file2.toString());
                if (sharedPreferences.getBoolean("avo", false)) {
                    this.z = D0(b2, str);
                } else if ((file2.exists() || dq.N1()) && file.exists()) {
                    this.z = "file:///" + file.toString();
                } else {
                    this.A = str;
                    J0();
                }
            }
        }
        return this.z;
    }

    public void y0(int i) {
        SharedPreferences sharedPreferences = getSharedPreferences(g6.g, 0);
        String b2 = w6.b(sharedPreferences);
        if (i != 2) {
            if (i == 1) {
                sharedPreferences.edit().putBoolean("avo", true).commit();
            }
            I0(b2, this.A);
            return;
        }
        File v0 = v0(b2);
        q0();
        c cVar = new c(v0, b2);
        this.w = cVar;
        ExtensionsContextKt.V2(this, cVar, TaskerIntent.c(vh.g(this, 2131887474, new Object[0])));
        if (!r0(this, b2)) {
            I0(b2, this.A);
        } else if (this.B == null) {
            ProgressDialog F0 = F0(this);
            this.B = F0;
            F0.setOnCancelListener(new d());
        }
    }

    public static synchronized boolean z0(android.content.Context r4) {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.HTMLView.z0(android.content.Context):boolean");
    }

    public String D0(String str, String str2) {
        return "https://tasker.joaoapps.com/userguide/" + str + "/" + str2;
    }

    @Override
    public void g(com.joaomgcd.taskerm.util.e5 e5Var, com.joaomgcd.taskerm.util.t6 t6Var) {
    }

    @Override
    @TargetApi(23)
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setResult(0, null);
        Intent intent = getIntent();
        this.v = g.values()[intent.getIntExtra("sty", g.Inform.ordinal())];
        try {
            WebView webView = new WebView(this);
            this.x = webView;
            webView.getSettings().setAllowFileAccess(true);
            this.x.getSettings().setBuiltInZoomControls(true);
            this.x.setWebViewClient(com.joaomgcd.taskerm.util.k.f() ? new f(this) : new e(this));
        } catch (Throwable th2) {
            r7.l("HV", "onCreate", th2);
            dq.b0(this, "Android internal error, try updating Android WebView", new Object[0]);
            this.x = null;
        }
        if (this.x == null) {
            finish();
        } else {
            LinearLayout linearLayout = new LinearLayout(this);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
            linearLayout.setPadding(0, 0, 0, 0);
            linearLayout.setLayoutParams(layoutParams);
            linearLayout.addView(this.x);
            this.x.setScrollBarStyle(16777216);
            setContentView(linearLayout);
            if (this.v == g.InformWithAccept) {
                ActionBar actionBar = getActionBar();
                actionBar.setHomeButtonEnabled(false);
                if (tp.e0()) {
                    actionBar.setDisplayOptions(8);
                } else {
                    actionBar.setDisplayOptions(10);
                }
            } else {
                net.dinglisch.android.taskerm.a.T(this, false);
            }
            this.x.setBackgroundColor(0);
            String stringExtra = intent.getStringExtra("url");
            if (bundle != null) {
                this.z = bundle.getString("url");
            } else {
                this.z = x0(stringExtra);
            }
            C0(this.z);
        }
        this.y.I();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.B = null;
        this.w = null;
        System.gc();
        this.y.J();
    }

    @Override
    public void onDetachedFromWindow() {
        WebView webView = this.x;
        if (webView != null) {
            MyActivity.unbindAllReferences(webView);
            this.x = null;
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 0) {
            finish();
        } else if (itemId == 1) {
            this.x.goBack();
        } else if (itemId == 2) {
            this.x.goForward();
        } else if (itemId == 3 || itemId == 16908332) {
            setResult(-1);
            finish();
        }
        return true;
    }

    @Override
    public void onPause() {
        super.onPause();
        q0();
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        if (this.v != g.Inform) {
            net.dinglisch.android.taskerm.a.a(this, 3, 2131886891, menu);
        }
        if (this.v == g.Confirm) {
            net.dinglisch.android.taskerm.a.d(this, 0, menu);
        } else {
            WebView webView = this.x;
            if (webView == null) {
                return true;
            }
            if (webView.canGoBack()) {
                net.dinglisch.android.taskerm.a.b(this, 1, menu);
            }
            if (webView.canGoForward()) {
                net.dinglisch.android.taskerm.a.s(this, 2, menu);
            }
        }
        return true;
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putString("url", this.z);
    }
}