导航菜单

页面标题

页面副标题

Tasker v6.6.3 - TaskerAppWidgetConfigure.java 源代码

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

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


package net.dinglisch.android.taskerm;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import cyanogenmod.alarmclock.ClockContract;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import net.dinglisch.android.taskerm.HTMLView;
import net.dinglisch.android.taskerm.MacroEditView;
import net.dinglisch.android.taskerm.fo;
import net.dinglisch.android.taskerm.on;

public class TaskerAppWidgetConfigure extends Activity implements View.OnClickListener {
    public static long w = -1;
    private Button i;
    private int q;
    private MacroEditView s;
    private SharedPreferences v;
    private on r = new on();
    private int t = 0;
    protected boolean u = false;

    class a implements MacroEditView.k {
        a() {
        }

        @Override
        public void a() {
        }

        @Override
        public void b() {
            TaskerAppWidgetConfigure.this.p();
        }

        @Override
        public void onCancel() {
            TaskerAppWidgetConfigure.this.p();
        }
    }

    class b extends Handler {
        b() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                TaskerAppWidgetConfigure.this.r = new on(new ii(message.getData().getBundle("timer")));
                TaskerAppWidgetConfigure.this.i.setText(TaskerAppWidgetConfigure.this.r.F());
            }
        }
    }

    class c extends Handler {
        c() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what != 0) {
                TaskerAppWidgetConfigure.this.p();
            }
        }
    }

    static class d {
        static final int[] a;

        static {
            int[] iArr = new int[on.b.values().length];
            a = iArr;
            try {
                iArr[on.b.Update.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                a[on.b.End.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                a[on.b.Pause.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                a[on.b.Resume.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                a[on.b.Reset.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[on.b.SetTime.ordinal()] = 6;
            } catch (NoSuchFieldError unused6) {
            }
        }
    }

    public static synchronized boolean e(Context context, String str, String str2, g gVar) {
        boolean z;
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                AppWidgetManager k = k(context);
                z = false;
                if (k != null) {
                    Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                    while (it.hasNext()) {
                        int intValue = new Integer(it.next()).intValue();
                        fn j = j(context, intValue);
                        if (j.x() && j.getName().equals(str)) {
                            if (str2 != null) {
                                j.y2(str2);
                                x(context, intValue, j);
                            }
                            if (gVar != null) {
                                j.u2(gVar);
                                x(context, intValue, j);
                            }
                            TaskerAppWidgetProvider.j(context, k, intValue, j);
                        }
                    }
                    z = true;
                }
            } finally {
            }
        }
        return z;
    }

    private void f() {
        this.i = null;
        this.r = null;
        MacroEditView macroEditView = this.s;
        if (macroEditView != null) {
            macroEditView.M0();
            this.s = null;
        }
        this.v = null;
    }

    private boolean g() {
        fn fnVar;
        Bitmap bitmap;
        int i;
        if (this.s.n1(false)) {
            fn selected = this.s.getSelected();
            g icon = selected.getIcon();
            if (this.s.getSelectedNoActions() == 0) {
                pp.a0(this, 2131888045, new Object[0]);
                return false;
            }
            if (icon.h0()) {
                pp.a0(this, 2131887710, new Object[0]);
                this.s.k0();
                return false;
            }
            boolean x = selected.x();
            if (this.s.t0()) {
                x = false;
            } else {
                this.s.f0(0);
            }
            w = -1L;
            Intent intent = new Intent();
            if (x) {
                net.dinglisch.android.taskerm.c cVar = new net.dinglisch.android.taskerm.c(130);
                cVar.o0(0, selected.getName());
                cVar.o1(5, true);
                cVar.u1(1, selected.m1());
                fnVar = fo.Z1();
                fnVar.Z(cVar);
                fnVar.u2(selected.getIcon());
                fnVar.G2(2);
                fnVar.C(selected.getName());
                fnVar.D2(selected.m1());
            } else {
                fnVar = selected;
            }
            if (this.q == 1) {
                intent.putExtra("appWidgetId", this.t);
                if (this.u) {
                    if (this.r.m() > 0) {
                        this.r.C();
                    }
                    fnVar.N2(this.r);
                    on.w(this, fnVar, on.a.Started);
                }
                x(this, this.t, fnVar);
                AppWidgetManager k = k(this);
                if (k != null) {
                    TaskerAppWidgetProvider.j(this, k, this.t, fnVar);
                }
            } else {
                intent.putExtra("android.intent.extra.shortcut.INTENT", new ph.b(this).i(selected, fnVar));
                intent.putExtra("android.intent.extra.shortcut.NAME", selected.x() ? selected.getName() : selected.A0(0).getName());
                if (icon.g0() && icon.U() == 0 && !icon.Z()) {
                    i = icon.I(this);
                } else {
                    int Y = fp.Y(48);
                    try {
                        bitmap = icon.A(this, Y, Y, "TaskerAppWidgetConfigure", true);
                    } catch (Exception e) {
                        o7.H("TaskerAppWidgetConfigure", "create shortcut", e);
                        bitmap = null;
                    }
                    if (bitmap == null) {
                        i = 2131230944;
                    } else {
                        intent.putExtra("android.intent.extra.shortcut.ICON", bitmap);
                        i = -1;
                    }
                }
                if (i != -1) {
                    intent.putExtra("android.intent.extra.shortcut.ICON_RESOURCE", Intent.ShortcutIconResource.fromContext(this, i));
                }
            }
            setResult(-1, intent);
            MonitorService.G8(this);
            p();
        }
        return true;
    }

    public static synchronized boolean h(Context context, on.b bVar, String str, int[] iArr) {
        boolean z;
        on.a aVar;
        boolean z2;
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                AppWidgetManager k = k(context);
                z = false;
                if (k != null) {
                    Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                    boolean z3 = false;
                    while (it.hasNext()) {
                        int intValue = new Integer(it.next()).intValue();
                        fn j = j(context, intValue);
                        if (str != null) {
                            if (j.x() && j.getName().equals(str)) {
                            }
                        }
                        on y1 = j.y1();
                        if (y1 != null) {
                            switch (d.a[bVar.ordinal()]) {
                                case 1:
                                    z2 = true;
                                    aVar = null;
                                    break;
                                case 2:
                                    boolean r = y1.r();
                                    y1.y();
                                    if (r) {
                                        TaskerAppWidgetProvider.f(context, j, intValue);
                                    }
                                    aVar = on.a.Stopped;
                                    z2 = true;
                                    break;
                                case 3:
                                    if (y1.r()) {
                                        y1.E();
                                        aVar = on.a.Paused;
                                        z2 = true;
                                        break;
                                    }
                                    z2 = false;
                                    aVar = null;
                                    break;
                                case 4:
                                    if (!y1.r() && y1.m() > 0) {
                                        aVar = y1.q() ? on.a.Restarted : on.a.Started;
                                        y1.C();
                                        z2 = true;
                                        break;
                                    }
                                    z2 = false;
                                    aVar = null;
                                    break;
                                case 5:
                                    y1.v();
                                    aVar = on.a.Reset;
                                    z2 = true;
                                    break;
                                case ClockContract.InstancesColumns.MISSED_STATE:
                                    y1.z(iArr[0], iArr[1], iArr[2], iArr[3]);
                                    y1.A(iArr[0], iArr[1], iArr[2], iArr[3]);
                                    z2 = true;
                                    aVar = null;
                                    break;
                                default:
                                    z2 = false;
                                    aVar = null;
                                    break;
                            }
                            if (z2) {
                                x(context, intValue, j);
                                TaskerAppWidgetProvider.j(context, k, intValue, j);
                            }
                            if (aVar != null) {
                                on.w(context, j, aVar);
                            }
                        }
                        z3 = true;
                    }
                    z = z3;
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
        return z;
    }

    public static int i(Context context) {
        return pp.R0(context).getInt("wtp", 7);
    }

    public static synchronized fn j(Context context, int i) {
        fn fnVar;
        synchronized (TaskerAppWidgetConfigure.class) {
            String string = context.getSharedPreferences(d6.p, 0).getString(Integer.toString(i), null);
            fnVar = string != null ? new fn(new ii(string)) : null;
        }
        return fnVar;
    }

    public static AppWidgetManager k(Context context) {
        try {
            return AppWidgetManager.getInstance(context);
        } catch (Exception e) {
            o7.l("TaskerAppWidgetConfigure", "getManagerSafe", e);
            return null;
        }
    }

    public static synchronized Set<String> l(Context context) {
        HashSet hashSet;
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                hashSet = new HashSet();
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    Integer num = new Integer(it.next());
                    fn j = j(context, num.intValue());
                    if (j == null) {
                        o7.G("TaskerAppWidgetConfigure", "scanForVars: ignoring null mac, ID " + num);
                    } else {
                        for (net.dinglisch.android.taskerm.c cVar : j.D0()) {
                            if (cVar.j() == 130) {
                                hashSet.add(cVar.N(0).w());
                            }
                        }
                    }
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
        return hashSet;
    }

    public static synchronized int m(Context context, String str) {
        int i;
        on y1;
        synchronized (TaskerAppWidgetConfigure.class) {
            if (k(context) != null) {
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    fn j = j(context, new Integer(it.next()).intValue());
                    if (j.x() && j.getName().equals(str) && (y1 = j.y1()) != null) {
                        i = y1.m();
                        break;
                    }
                }
            }
            i = -1;
        }
        return i;
    }

    public static synchronized List<String> n(Context context, boolean z) {
        ArrayList arrayList;
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                arrayList = new ArrayList();
                AppWidgetManager k = k(context);
                if (k != null) {
                    ArrayList arrayList2 = new ArrayList();
                    for (String str : context.getSharedPreferences(d6.p, 0).getAll().keySet()) {
                        Integer num = new Integer(str);
                        int intValue = num.intValue();
                        if (k.getAppWidgetInfo(intValue) == null) {
                            o7.f("TaskerAppWidgetConfigure", "getWidgetNameList: remove task for unknown widget ID " + str);
                            arrayList2.add(num);
                        } else {
                            fn j = j(context, intValue);
                            if (j.x() && (!z || j.D1())) {
                                arrayList.add(j.getName());
                            }
                        }
                    }
                    Iterator it = arrayList2.iterator();
                    while (it.hasNext()) {
                        r(context, ((Integer) it.next()).intValue());
                    }
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
        return arrayList;
    }

    public static synchronized boolean o(Context context, int i) {
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    Integer num = new Integer(it.next());
                    fn j = j(context, num.intValue());
                    if (j == null) {
                        o7.G("TaskerAppWidgetConfigure", "haveActionCode: ignoring null mac, ID " + num);
                    } else {
                        Iterator<net.dinglisch.android.taskerm.c> it2 = j.D0().iterator();
                        while (it2.hasNext()) {
                            if (it2.next().j() == i) {
                                return true;
                            }
                        }
                    }
                }
                return false;
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    public void p() {
        fo L2 = fo.L2(fo.g.Passive, this, false);
        if (L2 != null) {
            L2.G4(this, this.v, getResources(), w, false, true);
        }
        ep.o0("TaskerAppWidgetConfigure lockAndFinish");
        finish();
    }

    public static synchronized void q(Context context) {
        synchronized (TaskerAppWidgetConfigure.class) {
            AppWidgetManager k = k(context);
            if (k != null) {
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    int intValue = new Integer(it.next()).intValue();
                    fn j = j(context, intValue);
                    if (j.getIcon().d0()) {
                        TaskerAppWidgetProvider.j(context, k, intValue, j);
                    }
                }
            }
        }
    }

    public static synchronized void r(Context context, int i) {
        synchronized (TaskerAppWidgetConfigure.class) {
            String num = Integer.toString(i);
            SharedPreferences sharedPreferences = context.getSharedPreferences(d6.p, 0);
            if (sharedPreferences.contains(num)) {
                sharedPreferences.edit().remove(num).commit();
            }
        }
    }

    public static synchronized void s(Context context, Set<Integer> set) {
        synchronized (TaskerAppWidgetConfigure.class) {
            if (k(context) != null) {
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    fn j = j(context, new Integer(it.next()).intValue());
                    if (j != null) {
                        fo.M4(j, set);
                    }
                }
            }
        }
    }

    public static synchronized Set<String> t(Context context, boolean z) {
        HashSet hashSet;
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                hashSet = new HashSet();
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    Integer num = new Integer(it.next());
                    fn j = j(context, num.intValue());
                    if (j == null) {
                        o7.G("TaskerAppWidgetConfigure", "scanForVars: ignoring null mac, ID " + num);
                    } else {
                        for (net.dinglisch.android.taskerm.c cVar : j.D0()) {
                            if (z) {
                                wp.u(cVar, false);
                            } else {
                                wp.n(cVar, hashSet, false, false);
                            }
                            if (cVar.j() == 130) {
                                hashSet.add(cVar.N(0).w());
                            }
                            if (cVar.H()) {
                                Iterator<q1> it2 = cVar.T().iterator();
                                while (it2.hasNext()) {
                                    q1 next = it2.next();
                                    String f = next.f();
                                    if (z) {
                                        wp.s(f, false);
                                    } else {
                                        wp.k(f, hashSet, false, false);
                                    }
                                    if (Expr.e(next.g())) {
                                        String j2 = next.j();
                                        if (z) {
                                            wp.s(j2, false);
                                        } else {
                                            wp.k(j2, hashSet, false, false);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
        return hashSet;
    }

    private void u() {
        Button button = (Button) findViewById(2131296518);
        this.i = button;
        if (button == null) {
            o7.k("TaskerAppWidgetConfigure", "onCreate: no countdown button");
            return;
        }
        button.setOnClickListener(this);
        this.i.setText(this.r.F());
        this.i.setVisibility(0);
    }

    private void v() {
        s1.j(this, new b(), null, this.r, true).i(this);
    }

    private void w() {
        ep.t0(this, new c()).E(this);
    }

    public static synchronized void x(Context context, int i, fn fnVar) {
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                String num = Integer.toString(i);
                String e0 = fnVar.X(0).e0(0);
                if (e0 == null) {
                    pp.a0(context, 2131891105, new Object[0]);
                } else {
                    context.getSharedPreferences(d6.p, 0).edit().putString(num, e0).commit();
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    public static synchronized void y(Context context, String str, String str2) {
        String str3;
        String str4;
        synchronized (TaskerAppWidgetConfigure.class) {
            try {
                AppWidgetManager k = k(context);
                if (k == null) {
                    return;
                }
                PackageManager packageManager = context.getPackageManager();
                Iterator<String> it = context.getSharedPreferences(d6.p, 0).getAll().keySet().iterator();
                while (it.hasNext()) {
                    int intValue = new Integer(it.next()).intValue();
                    fn j = j(context, intValue);
                    g icon = j.getIcon();
                    File t0 = ImageSelect.t0();
                    File file = null;
                    File file2 = t0 == null ? null : new File(t0, str2);
                    if (icon.d0()) {
                        File file3 = new File(j.getIcon().H());
                        str4 = file3.getParentFile().getName();
                        str3 = file3.getName();
                    } else if (icon.f0()) {
                        str4 = t5.i(icon.N());
                        str3 = icon.getName();
                    } else {
                        str3 = null;
                        str4 = null;
                    }
                    if (str4 != null) {
                        if (file2 != null) {
                            file = new File(file2, str3);
                        }
                        if (!str4.equals("Samples") && (str.length() == 0 || str4.equals(str))) {
                            if (!str4.equals(str2)) {
                                if (pp.v3(str2, t5.f()) != -1 && t5.l(packageManager, t5.h(packageManager, str2), str3) != -1) {
                                    icon.w0(t5.h(packageManager, str2), str3);
                                } else if (file != null && file.exists() && file.isFile()) {
                                    o7.f("TaskerAppWidgetConfigure", "to " + str2 + " is file, new path " + file);
                                    icon.r0(file.toString());
                                } else {
                                    o7.G("TaskerAppWidgetConfigure", "icon " + str3 + " not found in new set " + str2);
                                }
                                x(context, intValue, j);
                                TaskerAppWidgetProvider.j(context, k, intValue, j);
                            }
                        }
                    }
                }
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    @Override
    protected void onActivityResult(int i, int i2, Intent intent) {
        this.s.L0(i, i2, intent);
    }

    @Override
    public void onBackPressed() {
        g();
    }

    @Override
    public void onClick(View view) {
        if (this.i.equals(view)) {
            v();
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setResult(0);
        StringBuilder sb = new StringBuilder();
        sb.append("oncreate: icicle ");
        sb.append(bundle != null);
        o7.f("TaskerAppWidgetConfigure", sb.toString());
        p5.v(this, "TaskerAppWidgetConfigure.onCreate");
        t5.j(this, false);
        ep.o0("TaskerAppWidgetConfigure onCreate");
        MyActivity.a0(this);
        try {
            t6.e(getBaseContext());
            if (bundle == null && fo.W2()) {
                pp.c0(this, 2131887840, new Object[0]);
                finish();
                return;
            }
            if (!pp.h(this)) {
                pp.a0(this, 2131887764, new Object[0]);
                p();
                return;
            }
            fp.b0(this);
            MacroEditView macroEditView = new MacroEditView(this);
            this.s = macroEditView;
            macroEditView.setId(2131297325);
            setContentView(this.s);
            net.dinglisch.android.taskerm.a.T(this, true);
            gp.t(this);
            gp.u(this);
            this.v = pp.R0(this);
            Intent intent = getIntent();
            fn fnVar = null;
            this.q = !"android.intent.action.CREATE_SHORTCUT".equals(intent == null ? null : intent.getAction()) ? 1 : 0;
            if (bundle != null) {
                this.t = bundle.getInt("sdataw", 0);
                if (bundle.containsKey("ssat")) {
                    Bundle bundle2 = bundle.getBundle("ssat");
                    if (bundle2 == null) {
                        o7.G("TaskerAppWidgetConfigure", "restore bundle null");
                    } else {
                        fnVar = new fn(new ii(bundle2));
                    }
                }
            } else if (intent == null) {
                o7.k("TaskerAppWidgetConfigure", "null icicle, no intent");
            } else {
                Bundle extras = intent.getExtras();
                if (extras != null) {
                    this.t = extras.getInt("appWidgetId", 0);
                }
            }
            if (this.q == 1 && this.t == 0) {
                pp.a0(this, 2131891124, new Object[0]);
                p();
            }
            if (this.u) {
                this.s.setDefaultIconResource(fp.J(this, 2130969295));
            }
            MacroEditView macroEditView2 = this.s;
            a aVar = new a();
            int i = this.q;
            macroEditView2.s0(this, aVar, i == 1 ? 2131886738 : 2131886734, (i == 1 ? 2 : 0) | 44, true);
            this.s.setTaskIconImageSelectFlags(479);
            this.s.setTask(fnVar, -1);
            if (this.u) {
                u();
            }
            Intent intent2 = new Intent();
            if (this.q == 1) {
                intent2.putExtra("appWidgetId", this.t);
            }
            setResult(0, intent2);
            if (ep.q0(this) || ep.s0(this)) {
                w();
            }
        } catch (NullPointerException unused) {
            pp.a0(this, 2131889325, new Object[0]);
            p();
        } catch (OutOfMemoryError unused2) {
            pp.a0(this, 2131889325, new Object[0]);
            p();
        }
    }

    @Override
    public void onDestroy() {
        o7.f("TaskerAppWidgetConfigure", "onDestroy");
        super.onDestroy();
        f();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == 1) {
            p();
        } else if (menuItem.getItemId() == 2) {
            HTMLView.H0(this, "activity_widget_configure.html", -1, HTMLView.g.Inform);
        } else {
            if (menuItem.getItemId() != 16908332) {
                return this.s.N0(menuItem, "activity_widget_configure.html");
            }
            g();
        }
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        this.s.P0(menu);
        net.dinglisch.android.taskerm.a.v(this, 2, menu);
        net.dinglisch.android.taskerm.a.d(this, 1, menu);
        return true;
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (w == -1) {
            w = System.currentTimeMillis();
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        o7.f("TaskerAppWidgetConfigure", "OSIS");
        bundle.putInt("sdataw", this.t);
        if (this.s.getSelected() == null) {
            o7.f("TaskerAppWidgetConfigure", "store null");
            bundle.putBundle("ssat", null);
        } else {
            o7.f("TaskerAppWidgetConfigure", "store non-null");
            bundle.putBundle("ssat", this.s.getSelected().X(0).c0());
        }
    }
}