导航菜单

页面标题

页面副标题

Tasker v6.5.11 - Main.java 源代码

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

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


package net.dinglisch.android.taskerm;

import android.R;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.app.ListFragment;
import android.app.backup.RestoreObserver;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.text.Editable;
import android.text.Html;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.view.ActionMode;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.ToggleButton;
import androidx.annotation.Keep;
import androidx.legacy.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.joaomgcd.taskerm.backup.GenericActionBackupToGoogleDrive;
import com.joaomgcd.taskerm.genericaction.GenericActionActivityConfigureNotificationChannel;
import com.joaomgcd.taskerm.genericaction.GenericActionActivityDisableBatteryOptimizations;
import com.joaomgcd.taskerm.genericaction.GenericActionActivityRequestCallScreeningAccess;
import com.joaomgcd.taskerm.genericaction.GenericActionActivityRequestManageExternalStorageAccess;
import com.joaomgcd.taskerm.genericaction.GenericActionActivityRequestMissingPermissions;
import com.joaomgcd.taskerm.genericaction.GenericActionSendEmailToSupport;
import com.joaomgcd.taskerm.helper.q;
import com.joaomgcd.taskerm.rx.EventBusRxSubscription;
import com.joaomgcd.taskerm.spawn.RFactory;
import com.joaomgcd.taskerm.util.ExtensionsContextKt;
import com.joaomgcd.taskerm.util.TaskerApp;
import cyanogenmod.alarmclock.ClockContract;
import cyanogenmod.app.ProfileManager;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import net.dinglisch.android.taskerm.ActionEdit;
import net.dinglisch.android.taskerm.FileSelect;
import net.dinglisch.android.taskerm.HTMLView;
import net.dinglisch.android.taskerm.Main;
import net.dinglisch.android.taskerm.MonitorService;
import net.dinglisch.android.taskerm.RunLog;
import net.dinglisch.android.taskerm.am;
import net.dinglisch.android.taskerm.c2;
import net.dinglisch.android.taskerm.ch;
import net.dinglisch.android.taskerm.dk;
import net.dinglisch.android.taskerm.g6;
import net.dinglisch.android.taskerm.iq;
import net.dinglisch.android.taskerm.mh;
import net.dinglisch.android.taskerm.ri;
import net.dinglisch.android.taskerm.si;
import net.dinglisch.android.taskerm.tn;
import net.dinglisch.android.taskerm.to;
import net.dinglisch.android.taskerm.tp;
import net.dinglisch.android.taskerm.vi;
import net.dinglisch.android.taskerm.wo;
import net.dinglisch.android.taskerm.yd;
import net.dinglisch.android.taskerm.yj;
import net.dinglisch.android.taskerm.zh;
import o3.q0;

public class Main extends MyActivity implements View.OnClickListener, vi.m, vi.n, vi.l, vi.o, pf.a {
    private static final String[] h0 = {"tsIndexed", "tsEmpty", "tsRef"};
    private static final boolean[] i0 = {true, true, true};
    private static final int[] j0 = {2131886800, 2131886794, 2131886811};
    private static final int[] k0 = {2131297647, 2131297649, 2131297648};
    public static String l0 = "startWithTaskName";
    public static String m0 = "startWithTaskId";
    public static String n0 = "startWithSceneName";
    public static String o0 = "startWithSubspec";
    public static String p0 = "forego_unlock";
    private static boolean q0 = false;
    private static long r0 = -1;
    private static boolean s0 = false;
    private static long t0 = -1;
    private static boolean u0 = false;
    private static boolean v0 = false;
    public EditText B;
    private ViewGroup E;
    private RelativeLayout F;
    private RelativeLayout G;
    private View H;
    private zh I;
    private zh J;
    public ImageView K;
    public ImageView L;
    private SharedPreferences M;
    private SharedPreferences N;
    private Resources O;
    private ViewPager P;
    private v1 Q;
    private int W;
    private int X;
    private c2.a a0;
    public am v;
    com.joaomgcd.taskerm.util.e5 w = null;
    public vi x = null;
    private ql y = null;
    private vn z = null;
    private iq A = null;
    private ToggleButton[] C = new ToggleButton[iq.b.values().length];
    private Handler D = null;
    private boolean R = false;
    public to S = new to();
    private int T = 0;
    private wo U = null;
    private String V = null;
    private pi Y = null;
    private to Z = null;
    private int b0 = -2;
    private String c0 = "";
    private wh d0 = null;
    private MonitorService.z e0 = null;
    public com.joaomgcd.taskerm.helper.q f0 = new com.joaomgcd.taskerm.helper.q(this);
    private boolean g0 = true;

    class a extends Handler {
        a() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main main = Main.this;
                main.Ic(MyDeviceAdminReceiver.d(main), 26);
            }
        }
    }

    class a0 implements AdapterView.OnItemClickListener {
        a0() {
        }

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            Main.this.U = null;
            if (Main.this.y()) {
                return;
            }
            Main.this.r7(i);
        }
    }

    class a1 extends qh {
        final ListView i;

        a1(Context context, yg ygVar, ImageView imageView, ImageView imageView2, ImageView imageView3, ListView listView) {
            super(context, ygVar, imageView, imageView2, imageView3);
            this.i = listView;
        }

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case 1:
                    Main main = Main.this;
                    main.tc(main.findViewById(1), (tn) d().d());
                    return true;
                case 2:
                    Main main2 = Main.this;
                    main2.t5(main2.hd(main2.z.g()));
                    return true;
                case 3:
                    Main main3 = Main.this;
                    main3.Qb(main3.findViewById(2), d().g());
                    return true;
                case 4:
                case 5:
                    Iterator<Object> it = d().g().iterator();
                    while (it.hasNext()) {
                        ((tn) it.next()).E(menuItem.getItemId() == 4);
                    }
                    Main.this.K6(false, c2.a.Task);
                    Main.this.K6(false, c2.a.Profile);
                    Main.this.K6(false, c2.a.Scene);
                    Main.this.v();
                    return true;
                case ClockContract.InstancesColumns.MISSED_STATE:
                case 7:
                default:
                    return false;
                case 8:
                    Main main4 = Main.this;
                    main4.Ob(main4.findViewById(8), (tn) d().d(), true, -1);
                    return true;
                case 9:
                    Main.this.b0();
                    return true;
                case 10:
                    Main main5 = Main.this;
                    main5.na(main5.hd(main5.z.g()));
                    Main.this.K6(false, c2.a.Task);
                    Main.this.v();
                    return true;
                case 11:
                    g(this.i);
                    return true;
                case 12:
                    tn tnVar = (tn) d().d();
                    tnVar.D2(100);
                    ExecuteService.d6(Main.this, tnVar, 9, -1, -1, -1, null, null, "ui", null);
                    Main.this.v();
                    return true;
                case 13:
                    Main.this.f0.w2((tn) d().d());
                    return true;
                case 14:
                    Main.this.f0.q2(d().g());
                    return true;
            }
        }

        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            super.onCreateActionMode(actionMode, menu);
            Main.this.wa();
            return Main.this.U(actionMode);
        }

        @Override
        public void onDestroyActionMode(ActionMode actionMode) {
            super.onDestroyActionMode(actionMode);
            Main.this.U(null);
        }

        @Override
        public void onItemCheckedStateChanged(ActionMode actionMode, int i, long j, boolean z) {
            if (Main.this.a5(c2.a.Task, i)) {
                return;
            }
            super.onItemCheckedStateChanged(actionMode, i, j, z);
        }

        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            super.e(actionMode, menu, false);
            if (Main.this.u()) {
                Main.this.R4(menu, 9);
                return true;
            }
            if (this.g == -1) {
                return false;
            }
            tn tnVar = (tn) Main.this.z.getItem(this.g);
            boolean j1 = Settings.j1(Main.this.M);
            if (f()) {
                net.dinglisch.android.taskerm.a.E(Main.this, 8, menu);
                net.dinglisch.android.taskerm.a.I(Main.this, 12, menu);
            }
            Main.this.R4(menu, 9);
            if (!j1 && f()) {
                net.dinglisch.android.taskerm.a.f(Main.this, 1, menu, false);
            }
            net.dinglisch.android.taskerm.a.k(Main.this, 2, menu);
            net.dinglisch.android.taskerm.a.r(Main.this, 3, false, menu);
            if (tnVar != null && tnVar.q()) {
                net.dinglisch.android.taskerm.a.R(Main.this, 5, false, menu);
            } else if (!j1) {
                net.dinglisch.android.taskerm.a.w(Main.this, 4, false, menu);
            }
            if (Main.this.B6() == tn.f.User && (!f() || this.g > 0)) {
                net.dinglisch.android.taskerm.a.D(Main.this, 10, menu);
            }
            if (!d().b()) {
                net.dinglisch.android.taskerm.a.P(Main.this, 11, menu);
            }
            Iterator<Object> it = Main.this.z.g().iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                tn tnVar2 = (tn) it.next();
                if (tnVar2 != null && tnVar2.r()) {
                    Main.this.m5(13, null);
                    break;
                }
            }
            if (f()) {
                net.dinglisch.android.taskerm.a.y(Main.this, 13, menu, 2131890587, 2130969223);
            }
            net.dinglisch.android.taskerm.a.C(Main.this, 14, false, menu);
            return true;
        }
    }

    class b extends Handler {
        final wo a;
        final int b;

        b(wo woVar, int i) {
            this.a = woVar;
            this.b = i;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.R6(this.a, this.b);
            }
        }
    }

    class b0 implements AdapterView.OnItemClickListener {
        b0() {
        }

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            Main.this.U = null;
            if (Main.this.y()) {
                return;
            }
            View v = Main.this.oa() ? Main.this.J.v(c2.a.Variable.ordinal()) : view.findViewById(2131297681);
            Main main = Main.this;
            main.Fc((fq) main.A.getItem(i), v, (ListView) adapterView, i);
        }
    }

    class b1 extends qh {
        final ListView i;

        b1(Context context, yg ygVar, ImageView imageView, ImageView imageView2, ImageView imageView3, ListView listView) {
            super(context, ygVar, imageView, imageView2, imageView3);
            this.i = listView;
        }

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            dk dkVar = (dk) d().d();
            switch (menuItem.getItemId()) {
                case 1:
                    Main main = Main.this;
                    main.sc(main.findViewById(1), dkVar);
                    return true;
                case 2:
                    Main main2 = Main.this;
                    main2.h5(main2.Oa(d().g()));
                    return true;
                case 3:
                    Main main3 = Main.this;
                    main3.Qb(main3.findViewById(2), d().g());
                    return true;
                case 4:
                case 5:
                    Iterator<Object> it = d().g().iterator();
                    while (it.hasNext()) {
                        ((dk) it.next()).E(menuItem.getItemId() == 4);
                    }
                    Main.this.K6(false, c2.a.Scene);
                    Main.this.v();
                    if (dkVar.q()) {
                        Main.this.id();
                    }
                    return true;
                case ClockContract.InstancesColumns.MISSED_STATE:
                default:
                    return false;
                case 7:
                    Iterator<Object> it2 = d().g().iterator();
                    while (it2.hasNext()) {
                        dk dkVar2 = (dk) it2.next();
                        if (wl.N(dkVar2.getName())) {
                            wl.v(Main.this, dkVar2.getName(), true);
                        }
                    }
                    Main.this.L6(c2.a.Scene);
                    Main.this.v();
                    return true;
                case 8:
                    Main main4 = Main.this;
                    main4.Ob(main4.findViewById(8), (dk) d().d(), true, -1);
                    return true;
                case 9:
                    Main.this.b0();
                    return true;
                case 10:
                    Main main5 = Main.this;
                    main5.ia(main5.Oa(d().g()));
                    Main.this.K6(false, c2.a.Scene);
                    Main.this.v();
                    return true;
                case 11:
                    g(this.i);
                    return true;
                case 12:
                    Main main6 = Main.this;
                    main6.Nb(dkVar, main6.findViewById(8));
                    return true;
                case 13:
                    Main.this.f0.p2(d().g());
                    return true;
            }
        }

        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            super.onCreateActionMode(actionMode, menu);
            Main.this.wa();
            return Main.this.U(actionMode);
        }

        @Override
        public void onDestroyActionMode(ActionMode actionMode) {
            super.onDestroyActionMode(actionMode);
            Main.this.U(null);
        }

        @Override
        public void onItemCheckedStateChanged(ActionMode actionMode, int i, long j, boolean z) {
            if (Main.this.a5(c2.a.Scene, i)) {
                return;
            }
            super.onItemCheckedStateChanged(actionMode, i, j, z);
        }

        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            super.e(actionMode, menu, false);
            if (Main.this.u()) {
                Main.this.R4(menu, 9);
                return true;
            }
            if (this.g == -1) {
                return false;
            }
            dk dkVar = (dk) Main.this.y.getItem(this.g);
            boolean j1 = Settings.j1(Main.this.M);
            if (f() && !xl.P(dkVar.getName())) {
                net.dinglisch.android.taskerm.a.E(Main.this, 8, menu);
            }
            Main.this.R4(menu, 9);
            if (!j1 && f()) {
                net.dinglisch.android.taskerm.a.f(Main.this, 1, menu, false);
            }
            net.dinglisch.android.taskerm.a.k(Main.this, 2, menu);
            if (wl.N(dkVar.getName())) {
                net.dinglisch.android.taskerm.a.l(Main.this, 7, menu);
            }
            net.dinglisch.android.taskerm.a.r(Main.this, 3, false, menu);
            if (!j1 && f() && dkVar.t1() > 0) {
                net.dinglisch.android.taskerm.a.o(Main.this, 12, menu);
            }
            if (dkVar.q()) {
                net.dinglisch.android.taskerm.a.R(Main.this, 5, false, menu);
            } else if (!j1) {
                net.dinglisch.android.taskerm.a.w(Main.this, 4, false, menu);
            }
            if (Main.this.z6() == dk.i.User && (!f() || this.g > 0)) {
                net.dinglisch.android.taskerm.a.D(Main.this, 10, menu);
            }
            if (!d().b()) {
                net.dinglisch.android.taskerm.a.P(Main.this, 11, menu);
            }
            net.dinglisch.android.taskerm.a.C(Main.this, 13, false, menu);
            Iterator<Object> it = Main.this.y.g().iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                if (((dk) it.next()).r()) {
                    Main.this.m5(14, null);
                    break;
                }
            }
            return true;
        }
    }

    class c extends Handler {
        final int[] a;

        c(int[] iArr) {
            this.a = iArr;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.P6(this.a);
            }
        }
    }

    class c0 implements Runnable {
        final int i;

        c0(int i) {
            this.i = i;
        }

        @Override
        public void run() {
            if (Main.this.I != null) {
                Main.this.I.Z(Main.this.t6());
                Main.this.I.o(this.i);
            }
        }
    }

    class c1 implements am.l {
        c1() {
        }

        @Override
        public void e(am.k kVar, int i) {
            Main.this.U6();
        }
    }

    class d extends Handler {
        final int[] a;

        d(int[] iArr) {
            this.a = iArr;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.x7(this.a);
            }
        }
    }

    class d0 extends Handler {
        d0() {
        }

        public void b() {
            Main.this.w5("initkey");
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main main = Main.this;
                main.f0.Z(main.Y9("keystore.user", "bl^!)*(!*{a", message.getData().getString("text")), new Runnable() {
                    @Override
                    public final void run() {
                        Main.d0.this.b();
                    }
                });
            }
        }
    }

    class d1 extends qh {
        final ListView i;

        d1(Context context, yg ygVar, ImageView imageView, ImageView imageView2, ImageView imageView3, ListView listView) {
            super(context, ygVar, imageView, imageView2, imageView3);
            this.i = listView;
        }

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            int itemId = menuItem.getItemId();
            if (itemId == 3) {
                StringBuilder sb = new StringBuilder();
                for (Object obj : d().g()) {
                    if (sb.length() > 0) {
                        sb.append(',');
                    }
                    sb.append(kq.B0(Main.this, ((fq) obj).getName()));
                }
                if (ch.c(Main.this, sb.toString(), ch.a.None)) {
                    dq.j0(Main.this, 2131888716, new Object[0]);
                } else {
                    dq.a0(Main.this, 2131887707, new Object[0]);
                }
                Main.this.v();
            } else if (itemId == 11) {
                g(this.i);
            } else if (itemId == 8) {
                Main main = Main.this;
                main.Ob(main.findViewById(8), (fq) d().d(), true, -1);
            } else {
                if (itemId != 9) {
                    return false;
                }
                Main.this.Ec(d().g());
            }
            return true;
        }

        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            super.onCreateActionMode(actionMode, menu);
            Main.this.wa();
            return Main.this.U(actionMode);
        }

        @Override
        public void onDestroyActionMode(ActionMode actionMode) {
            super.onDestroyActionMode(actionMode);
            Main.this.U(null);
        }

        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            super.e(actionMode, menu, false);
            if (this.g == -1) {
                return false;
            }
            fq fqVar = (fq) Main.this.A.getItem(this.g);
            boolean L0 = kq.L0(Main.this, fqVar.getName());
            if (f()) {
                Main main = Main.this;
                if (!main.S.D4(main, main.getPackageManager(), -2, false).contains(fqVar.getName())) {
                    net.dinglisch.android.taskerm.a.E(Main.this, 8, menu);
                }
            }
            if (L0) {
                net.dinglisch.android.taskerm.a.e(Main.this, 9, menu);
                net.dinglisch.android.taskerm.a.i(Main.this, 3, menu);
            }
            if (d().b()) {
                return true;
            }
            net.dinglisch.android.taskerm.a.P(Main.this, 11, menu);
            return true;
        }
    }

    class e extends Handler {
        final String[] a;

        e(String[] strArr) {
            this.a = strArr;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.Q6(this.a);
            }
        }
    }

    class e0 implements Runnable {
        e0() {
        }

        @Override
        public void run() {
            Main.this.Sc();
        }
    }

    class e1 extends Handler {
        e1() {
        }

        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i == 0) {
                r7.f("T", "connected to monitor service");
                Main.this.tb();
                MonitorService u6 = Main.this.u6("bind:handleMessage");
                if (u6 != null) {
                    u6.o7();
                    return;
                } else {
                    r7.G("T", "no monitor service after bind, unbind");
                    Main.this.kd();
                    return;
                }
            }
            if (i == 2) {
                r7.G("T", "monitor service connection error");
                Main.this.d0 = null;
            } else if (i == 1) {
                r7.f("T", "disconnected from monitor service");
                to toVar = Main.this.S;
                if (toVar != null) {
                    toVar.R0();
                }
            }
        }
    }

    class f extends xg {
        final int b;
        final boolean c;

        class a implements Runnable {
            a() {
            }

            @Override
            public void run() {
                f fVar = f.this;
                Main.this.H5(fVar.b, fVar.c);
            }
        }

        f(int i, boolean z) {
            this.b = i;
            this.c = z;
        }

        @Override
        public void e() {
            Main.this.F.postDelayed(new a(), 100L);
        }
    }

    class f0 implements mh.f {
        final View a;

        f0(View view) {
            this.a = view;
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            Main.this.W = mhVar.A();
            if (Main.this.W == 3 && Main.this.S.J1(3).size() > 0) {
                Main.this.Zb(this.a);
                return;
            }
            if (Main.this.U != null && ho.I0(Main.this.W)) {
                int i = 4;
                while (true) {
                    if (i > 6) {
                        break;
                    }
                    if (!Main.this.U.Z0(i)) {
                        Main.this.W = i;
                        break;
                    }
                    i++;
                }
            }
            Main main = Main.this;
            main.Kc(main.U, Main.this.W, true);
        }
    }

    class f1 implements MonitorService.z {
        f1() {
        }

        public void d(boolean z, int i) {
            to toVar = Main.this.S;
            if (toVar != null) {
                wo c = toVar.c(i);
                if (c != null) {
                    c.e1();
                    Main main = Main.this;
                    if (main.x != null) {
                        wo.b y6 = main.y6();
                        if (y6 == wo.b.ActiveAlpha || y6 == wo.b.ActiveContext) {
                            z = true;
                        } else {
                            Main.this.f0.v2();
                        }
                    }
                }
                if (z) {
                    Main.this.J6(false, false, false, c2.a.Profile);
                }
            }
        }

        @Override
        public void a(int i, int i2, boolean z, boolean z2) {
            wo c;
            to toVar = Main.this.S;
            if (toVar == null || (c = toVar.c(i)) == null || !c.Z0(i2)) {
                return;
            }
            ho T0 = c.T0(i2);
            r7.f("T", "Setting profile " + c.C0() + " context " + i2 + " to active " + z2);
            T0.M0(z2);
            Main.this.f0.v2();
        }

        @Override
        public void b(final int i, boolean z, boolean z2, final boolean z3) {
            pg.w0.p0(new Runnable() {
                @Override
                public final void run() {
                    Main.f1.this.d(z3, i);
                }
            });
        }
    }

    class g extends Handler {
        g() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main main = Main.this;
                main.E5(main.U, Main.this.W);
                Main.this.L6(c2.a.Profile);
                Main main2 = Main.this;
                main2.O7(main2.U.C0());
            }
        }
    }

    class g0 implements mh.f {
        g0() {
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            Main.this.u5();
            lp.c(Main.this, 2131890962);
        }
    }

    class g1 extends Handler {
        g1() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.T6();
            } else {
                Main.this.V5(false, "discdialogfalse");
            }
        }
    }

    class h implements Runnable {
        final ImageView i;
        final wo q;
        final ho r;

        h(ImageView imageView, wo woVar, ho hoVar) {
            this.i = imageView;
            this.q = woVar;
            this.r = hoVar;
        }

        @Override
        public void run() {
            ?? findViewById;
            ImageView imageView = this.i;
            View x6 = Main.this.x6(this.q.C0());
            if (x6 != null && (findViewById = x6.findViewById(2131296769)) != 0) {
                imageView = findViewById;
            }
            Main.this.Hb(this.q, this.r, imageView);
        }
    }

    class h0 implements mh.f {
        final List a;

        h0(List list) {
            this.a = list;
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            int A = mhVar.A();
            if (A == 9535435) {
                Main main = Main.this;
                main.Kc(main.U, 3, true);
            } else {
                Main.this.Y6(Main.this.S.I1((String) this.a.get(A), 3));
            }
        }
    }

    class h1 implements mh.f {
        final dk a;

        h1(dk dkVar) {
            this.a = dkVar;
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            Main.this.Rc(this.a.getName(), mhVar.B(), 11);
            Main.this.v();
        }
    }

    class i extends Handler {

        class a implements Runnable {
            a() {
            }

            @Override
            public void run() {
                Main.this.md(c2.a.Scene);
            }
        }

        i() {
        }

        @Override
        public void handleMessage(Message message) {
            Main.this.runOnUiThread(new a());
        }
    }

    class i0 extends Handler {
        i0() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.Lc();
            }
        }
    }

    static class i1 {
        static final int[] a;
        static final int[] b;

        static {
            int[] iArr = new int[c2.a.values().length];
            b = iArr;
            try {
                iArr[c2.a.Profile.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                b[c2.a.Task.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                b[c2.a.Scene.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                b[c2.a.Variable.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            int[] iArr2 = new int[RunLog.h.values().length];
            a = iArr2;
            try {
                iArr2[RunLog.h.Profile.ordinal()] = 1;
            } catch (NoSuchFieldError unused5) {
            }
            try {
                a[RunLog.h.Task.ordinal()] = 2;
            } catch (NoSuchFieldError unused6) {
            }
            try {
                a[RunLog.h.Action.ordinal()] = 3;
            } catch (NoSuchFieldError unused7) {
            }
            try {
                a[RunLog.h.MonitorStatus.ordinal()] = 4;
            } catch (NoSuchFieldError unused8) {
            }
            try {
                a[RunLog.h.ExeStatus.ordinal()] = 5;
            } catch (NoSuchFieldError unused9) {
            }
        }
    }

    class j extends Handler {

        class a extends Handler {
            a() {
            }

            @Override
            public void handleMessage(Message message) {
                Main.this.V5(true, "menu2");
            }
        }

        j() {
        }

        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i == 0) {
                Main.this.V5(false, "anyway");
                return;
            }
            if (i == 99 || i == 1) {
                return;
            }
            if (lp.g(Main.this, 2131890930)) {
                Main.this.V5(true, "menu1");
            } else {
                lp.c(Main.this, 2131890930);
                TextBoxDialogFragment.F(Main.this, new a(), 2131890864, vh.g(Main.this, 2131890930, new Object[0]), 2131886891, -1, -1, 4).E(Main.this);
            }
        }
    }

    class j0 extends Handler {
        j0() {
        }

        @Override
        public void handleMessage(Message message) {
            String l = jh.l(Main.this, message.getData().getString("text"));
            if (l != null) {
                TextBoxDialogFragment.F(Main.this, null, 2131888783, l, 2131886891, -1, -1, 521).E(Main.this);
            } else {
                Main main = Main.this;
                dq.a0(main, 2131887966, vh.g(main, 2131888783, new Object[0]));
            }
        }
    }

    class j1 implements View.OnTouchListener {
        final ListView i;

        j1(ListView listView) {
            this.i = listView;
        }

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            int Q;
            int action = motionEvent.getAction();
            if (Main.this.v.n0() || Main.this.A5() == c2.a.Variable) {
                return false;
            }
            int x = (int) motionEvent.getX();
            int y = (int) motionEvent.getY();
            if (action != 2 || !Main.this.v.g0(y, "listViewTouchListener")) {
                if (action == 1) {
                    Main.this.x5(this.i);
                    return false;
                }
                if (action != 0) {
                    return false;
                }
                Main.this.v.m0(this.i, x, y);
                Main.this.v.l0(x, y);
                return false;
            }
            Main main = Main.this;
            if (!am.X(main, main.y(), x, this.i.getWidth()) || am.d0(this.i, x, y) == -1 || (Q = Main.this.v.Q()) == -1) {
                return false;
            }
            Main main2 = Main.this;
            if (!main2.v.y(this.i, main2.y(), Q)) {
                return false;
            }
            Main.this.Mc(this.i, Q, "listViewTouch");
            return true;
        }
    }

    class k extends Handler {
        k() {
        }

        @Override
        public void handleMessage(Message message) {
            Main.this.Jc("getFactoryGooglePlay", new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=net.dinglisch.android.appfactory")));
        }
    }

    class k0 extends Handler {
        k0() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                File k = jh.k(Main.this);
                if (k == null || !k.delete()) {
                    dq.a0(Main.this, 2131887955, k.getName());
                } else {
                    dq.j0(Main.this, 2131886891, new Object[0]);
                }
            }
        }
    }

    class k1 extends Handler {
        final wo a;
        final w1 b;
        final View c;
        final int d;

        k1(wo woVar, w1 w1Var, View view, int i) {
            this.a = woVar;
            this.b = w1Var;
            this.c = view;
            this.d = i;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.P6(new int[]{this.a.C0()});
            } else {
                Main.this.Bc(this.b, this.c, this.a, this.d);
            }
        }
    }

    class l extends Handler {
        l() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main main = Main.this;
                main.P6(new int[]{main.U.C0()});
            } else {
                Main main2 = Main.this;
                main2.Rb(main2.U, true);
            }
        }
    }

    class l0 extends Handler {
        l0() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main.this.deleteFile("autobackup.xml");
                Main.this.S.P0("ui");
                Main.this.J7();
                Main.this.I7();
                Main.this.I.S(0);
                Main main = Main.this;
                main.x.E(0, main.y6(), false);
                Main.this.Ya(64);
                Main.this.Ya(8);
                Main.this.J6(false, true, false, c2.a.values());
                Main.this.Qa(c2.a.Profile, "showConfirmClearData");
                Main.this.invalidateOptionsMenu();
            }
        }
    }

    class l1 implements si.i {
        final View a;

        l1(View view) {
            this.a = view;
        }

        @Override
        public void a(si siVar) {
            if (siVar.f() || !siVar.g()) {
                return;
            }
            String i = siVar.i();
            Main main = Main.this;
            if (!main.n5(i, main.S.W2(i), null)) {
                Main.this.gc(this.a, i);
                return;
            }
            xi xiVar = new xi(i);
            xiVar.r0(Main.this.S.s2(0, "snpnp").x());
            Main.this.S.x0(xiVar);
            if (Main.this.od()) {
                Main.this.I.n(Main.this);
            } else {
                Main.this.I.m(Main.this, false);
            }
            Main.this.Ia();
            Main.this.q7(r4.I.x() - 1);
            Main main2 = Main.this;
            main2.Z4(main2.D5());
            Main.this.Ta();
        }
    }

    class m extends Handler {
        final jf.d a;

        m(jf.d dVar) {
            this.a = dVar;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Main main = Main.this;
                main.Ma(main, this.a.a0(), this.a.getName(), true);
            }
        }
    }

    class m0 implements mh.f {
        final View a;
        final wo b;
        final int c;

        m0(View view, wo woVar, int i) {
            this.a = view;
            this.b = woVar;
            this.c = i;
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            int ordinal = n1.values()[mhVar.A()].ordinal();
            if (ordinal == 0) {
                Main.this.Jb(this.a);
                return;
            }
            if (ordinal == 1) {
                if (Main.this.e5()) {
                    Main.this.L6(c2.a.Profile);
                    return;
                }
                return;
            }
            if (ordinal == 2) {
                Main main = Main.this;
                wo woVar = this.b;
                main.Hb(woVar, woVar.T0(this.c), this.a);
            } else {
                if (ordinal != 3) {
                    return;
                }
                Main main2 = Main.this;
                wo W0 = main2.S.W0(this.b, main2.W);
                W0.G(null);
                Main.this.L6(c2.a.Profile);
                Main.this.U = W0;
                Main main3 = Main.this;
                main3.W4(main3.q6(), Main.this.U.C0());
                Main.this.Rb(W0, true);
            }
        }
    }

    class m1 extends Handler {
        final int a;

        m1(int i) {
            this.a = i;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                lp.c(Main.this, 2131887134);
                Main.this.O6(this.a);
            }
        }
    }

    class n implements Runnable {
        final String i;

        n(String str) {
            this.i = str;
        }

        public g5 c(String str) {
            Main main = Main.this;
            return main.Z6(main.a0, str);
        }

        public ji.r d(final String str) {
            return pg.w0.M0(new xj.a() {
                @Override
                public final Object invoke() {
                    g5 c;
                    c = Main.n.this.c(str);
                    return c;
                }
            });
        }

        @Override
        public void run() {
            Main main = Main.this;
            final String str = this.i;
            com.joaomgcd.taskerm.datashare.export.d.i(main, new xj.a() {
                @Override
                public final Object invoke() {
                    ji.r d;
                    d = Main.n.this.d(str);
                    return d;
                }
            });
        }
    }

    class n0 implements mh.f {
        final View a;
        final wo b;
        final int c;
        final int d;

        n0(View view, wo woVar, int i, int i2) {
            this.a = view;
            this.b = woVar;
            this.c = i;
            this.d = i2;
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            switch (x1.values()[mhVar.A()].ordinal()) {
                case 0:
                    Main main = Main.this;
                    main.Bc(w1.ProfileAddOfType, this.a, main.U, 0);
                    break;
                case 1:
                    Main main2 = Main.this;
                    main2.Bc(w1.ProfileAddOfType, this.a, main2.U, 1);
                    break;
                case 2:
                    if (Main.this.W == 0) {
                        Main.this.W = 1;
                    } else {
                        Main.this.W = 0;
                    }
                    Main main3 = Main.this;
                    main3.Bc(w1.ProfileAddOfType, this.a, main3.U, Main.this.W);
                    break;
                case 3:
                    Main main4 = Main.this;
                    main4.Ob(this.a, main4.S.K2(this.b, this.c), false, this.d);
                    break;
                case 4:
                    Main main5 = Main.this;
                    main5.s5(main5.U, Main.this.W);
                    break;
                case 5:
                    Main main6 = Main.this;
                    main6.Bc(w1.ProfileReselect, this.a, main6.U, Main.this.W);
                    break;
                case ClockContract.InstancesColumns.MISSED_STATE:
                case 7:
                    int i = Main.this.W == 0 ? 1 : 0;
                    int Q0 = Main.this.U.Q0(Main.this.W);
                    Main.this.U.F1(Main.this.W, -1);
                    Main.this.U.F1(i, Q0);
                    Main main7 = Main.this;
                    main7.S.A4(main7.U);
                    Main.this.K6(false, c2.a.Profile);
                    break;
            }
        }
    }

    private enum n1 {
        Add,
        Delete,
        Name,
        Clone
    }

    class o implements Runnable {
        final int i;

        o(int i) {
            this.i = i;
        }

        @Override
        public void run() {
            Main.this.Y4(this.i);
        }
    }

    class o0 extends Handler {

        class a extends RestoreObserver {
            a() {
            }

            @Override
            public void onUpdate(int i, String str) {
                r7.f("T", "now restoring package: " + i + " (" + str + ")");
            }

            @Override
            public void restoreFinished(int i) {
                Main main = Main.this;
                to toVar = main.S;
                if (toVar != null) {
                    if (i != 0) {
                        dq.b0(main, String.valueOf(i), new Object[0]);
                        return;
                    }
                    if (toVar.m4(main, "autobackup.xml")) {
                        Main.this.i6();
                        dq.j0(Main.this, 2131890221, new Object[0]);
                    } else {
                        dq.a0(Main.this, 2131891078, new Object[0]);
                    }
                    Main.this.Ta();
                }
            }

            @Override
            public void restoreStarting(int i) {
                r7.f("T", "starting restore of " + i + " packages ");
            }
        }

        o0() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                try {
                    int b = MyBackupAgent.b(Main.this, new a());
                    if (b != 0) {
                        dq.b0(Main.this, String.valueOf(b), new Object[0]);
                    }
                } catch (SecurityException e) {
                    dq.b0(Main.this, "security exception: " + e.getMessage(), new Object[0]);
                }
            }
        }
    }

    private enum o1 {
        Disable,
        Enable
    }

    class p implements Runnable {
        final ListView i;
        final int q;
        final boolean r;

        p(ListView listView, int i, boolean z) {
            this.i = listView;
            this.q = i;
            this.r = z;
        }

        @Override
        public void run() {
            Main.this.W4(this.i, this.q);
            Main.this.W5(this.q);
            if (this.r) {
                Main.this.K6(false, c2.a.Profile);
            }
        }
    }

    class p0 extends Handler {

        class a extends Handler {
            final File a;

            a(File file) {
                this.a = file;
            }

            @Override
            public void handleMessage(Message message) {
                if (message.what == 0) {
                    Main main = Main.this;
                    main.Ma(main, this.a, "userbackup.xml", true);
                }
            }
        }

        p0() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 1) {
                int i = message.getData().getInt("index");
                Map<Long, File> E1 = to.E1();
                Long l = dq.i3(E1.keySet(), true)[i];
                l.longValue();
                TextBoxDialogFragment.Y(Main.this, new a(E1.get(l)), 2131887312);
            }
        }
    }

    private enum p1 {
        ClearAll,
        SetSort,
        Import,
        ToggleTools
    }

    class q implements Runnable {
        final boolean i;
        final c2.a[] q;
        final boolean r;
        final boolean s;

        q(boolean z, c2.a[] aVarArr, boolean z2, boolean z3) {
            this.i = z;
            this.q = aVarArr;
            this.r = z2;
            this.s = z3;
        }

        public void b(to toVar) {
            toVar.O0(Main.this.getPackageManager(), c2.a.values());
        }

        @Override
        public void run() {
            if (this.i) {
                Main.this.Ta();
            }
            Main main = Main.this;
            final to toVar = main.S;
            if (toVar == null) {
                MyActivity.L(main, "handleDataChanged data null");
                return;
            }
            for (c2.a aVar : this.q) {
                int i = i1.b[aVar.ordinal()];
                if (i == 1) {
                    Main main2 = Main.this;
                    vi viVar = main2.x;
                    if (viVar != null) {
                        viVar.z("dataChanged", main2.y6(), toVar);
                    }
                } else if (i != 2) {
                    if (i != 3) {
                        if (i == 4 && Main.this.A != null) {
                            Main.this.A.w(toVar, Main.this.C5());
                            Main.this.A.x();
                        }
                    } else if (Main.this.y != null) {
                        Main.this.y.s(toVar, Main.this.C5(), Main.this.z6());
                    }
                } else if (Main.this.z != null) {
                    Main.this.z.s(toVar, Main.this.C5(), Main.this.B6());
                }
            }
            if (this.r) {
                if (this.s) {
                    pg.w0.l0(new Runnable() {
                        @Override
                        public final void run() {
                            Main.q.this.b(toVar);
                        }
                    });
                } else {
                    toVar.O0(Main.this.getPackageManager(), c2.a.values());
                }
            }
            Main.this.Ha();
        }
    }

    class q0 extends Handler {
        final boolean a;
        final int b;
        final Object[] c;
        final Runnable d;

        q0(boolean z, int i, Object[] objArr, Runnable runnable) {
            this.a = z;
            this.b = i;
            this.c = objArr;
            this.d = runnable;
        }

        @Override
        public void handleMessage(Message message) {
            Main.v0 = false;
            if (message.what == 0) {
                Main.this.c7(this.a, this.b, this.c);
                Runnable runnable = this.d;
                if (runnable != null) {
                    runnable.run();
                    return;
                }
                return;
            }
            if (this.a) {
                Main.this.V5(false, "lockfail");
                return;
            }
            int i = this.b;
            if (i == 13 || i == 14) {
                Main.this.v();
            }
        }
    }

    public enum q1 {
        AsApp,
        DescrToClip,
        DescrToEmail,
        XmlToEmail,
        XmlToClip,
        XmlToSD,
        ToLink,
        ToUri
    }

    class r implements zh.j {
        r() {
        }

        @Override
        public void a(int i, int i2, boolean z) {
        }

        @Override
        public void b(boolean z) {
        }

        @Override
        public void c(int i) {
            Main.this.v();
            if (i != -1 && Main.this.m5(11, new Object[]{new Integer(i)})) {
                Main.this.qc(i);
            }
        }

        @Override
        public void d(int i) {
            Main.this.v();
            if (Main.this.m5(11, new Object[]{new Integer(i)})) {
                Main.this.qc(i);
            }
        }

        @Override
        public void e(int i, int i2, int i3, int i4) {
        }

        @Override
        public boolean f(int i, int i2, boolean z) {
            Main.this.v();
            return Main.this.q7(i2);
        }

        @Override
        public boolean g(int i) {
            int ka;
            if (!Main.this.u()) {
                return false;
            }
            int Da = Main.this.Da(i);
            c2.a A5 = Main.this.A5();
            int i2 = i1.b[A5.ordinal()];
            if (i2 == 1) {
                Main main = Main.this;
                ka = main.ka(main.C5(), Da);
            } else if (i2 == 2) {
                Main main2 = Main.this;
                ka = main2.ma(main2.C5(), Da);
            } else if (i2 != 3) {
                ka = 0;
            } else {
                Main main3 = Main.this;
                ka = main3.la(main3.C5(), Da);
            }
            if (ka > 0) {
                Main.this.K6(false, A5);
                Main.this.K6(false, c2.a.Variable);
            }
            Main.this.v();
            return true;
        }
    }

    class r0 implements View.OnLongClickListener {
        r0() {
        }

        @Override
        public boolean onLongClick(View view) {
            Main.this.Lb(view);
            return true;
        }
    }

    private static class r1 extends Handler {
        WeakReference<Main> a;

        r1(Main main) {
            this.a = new WeakReference<>(main);
        }

        @Override
        public void handleMessage(Message message) {
            Main main = this.a.get();
            if (main == null) {
                return;
            }
            main.l5();
        }
    }

    class s implements mh.f {
        final int a;

        s(int i) {
            this.a = i;
        }

        public void c(we.l0 l0Var) throws Exception {
            if (l0Var.o()) {
                kq.E(Main.this, "", false, true, null);
                Main.this.md(c2.a.Variable);
            }
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            int ordinal = p1.values()[mhVar.A()].ordinal();
            if (ordinal == 0) {
                if (Main.this.a0 == c2.a.Scene) {
                    wl.r(Main.this);
                    return;
                } else if (Main.this.a0 == c2.a.Task) {
                    dq.o3(Main.this, ExecuteService.class);
                    ExecuteService.o8(Main.this);
                    return;
                } else {
                    Main main = Main.this;
                    main.f0.R(com.joaomgcd.taskerm.dialog.a.o3(main, 2131888786, 2131890185), new oi.d() {
                        @Override
                        public final void accept(Object obj) {
                            Main.s.this.c((we.l0) obj);
                        }
                    });
                    return;
                }
            }
            if (ordinal == 1) {
                Main.this.Pb(this.a);
                return;
            }
            if (ordinal == 2) {
                Main main2 = Main.this;
                main2.Wb(main2.a0);
            } else {
                if (ordinal != 3) {
                    return;
                }
                Main.this.qb(!r4.qd());
                Main main3 = Main.this;
                main3.Ub(main3.qd(), true, true, false);
                Main.this.B.setText("");
            }
        }
    }

    class s0 implements View.OnDragListener {
        final c2.a a;
        final ListView b;

        s0(c2.a aVar, ListView listView) {
            this.a = aVar;
            this.b = listView;
        }

        @Override
        public boolean onDrag(View view, DragEvent dragEvent) {
            if (Main.this.v.n0()) {
                return false;
            }
            try {
                return Main.this.a7(this.a, this.b, view, dragEvent);
            } catch (Exception e) {
                r7.l("T", "onDrag/list", e);
                return false;
            }
        }
    }

    public static class s1 extends ListFragment {
        c2.a i;

        private void b(Main main, int i, int i2) {
            setEmptyText(Html.fromHtml("<I><SMALL>" + vh.g(main, i, new Object[0]) + "</SMALL></I>"));
        }

        public Main a() {
            return (Main) getActivity();
        }

        public void c() {
            Main main = (Main) getActivity();
            int i = i1.b[this.i.ordinal()];
            if (i == 1) {
                setListAdapter(main.x);
                return;
            }
            if (i == 2) {
                setListAdapter(main.z);
            } else if (i == 3) {
                setListAdapter(main.y);
            } else {
                if (i != 4) {
                    return;
                }
                setListAdapter(main.A);
            }
        }

        @Override
        public void onActivityCreated(Bundle bundle) {
            super.onActivityCreated(bundle);
            c();
        }

        @Override
        public void onCreate(Bundle bundle) {
            super.onCreate(bundle);
            this.i = c2.a.valueOf(getArguments().getString("type"));
        }

        @Override
        public void onDestroyView() {
            super.onDestroyView();
            v1 A6 = a().A6();
            if (A6 != null) {
                A6.e(this.i, null);
            }
        }

        @Override
        public void onSaveInstanceState(Bundle bundle) {
            bundle.putString("type", this.i.toString());
        }

        @Override
        public void onViewCreated(View view, Bundle bundle) {
            int i;
            int i2;
            if (bundle != null) {
                this.i = c2.a.valueOf(bundle.getString("type"));
            }
            Main a = a();
            am amVar = a.v;
            ListView listView = getListView();
            a.eb(this.i, listView);
            if (amVar != null) {
                amVar.t0(listView, Main.pd(a), this.i == c2.a.Profile);
            }
            if (this.i == c2.a.Variable) {
                a.gb(listView, a.qd());
            }
            a.sb(this.i, listView);
            a.ib(listView);
            a.hb(this.i, listView);
            listView.setScrollBarStyle(33554432);
            oi.r(listView, tp.w(a, 2131165290));
            oi.q(listView, tp.w(a, 2131165289));
            listView.setChoiceMode(3);
            listView.setItemsCanFocus(true);
            listView.setDividerHeight(tp.w(a, 2131165379));
            a.ab(listView);
            int i3 = i1.b[this.i.ordinal()];
            if (i3 == 1) {
                a.jb(listView);
                i = 2131889254;
                i2 = 2131890867;
            } else if (i3 == 2) {
                a.nb(listView);
                i = 2131889258;
                i2 = 2131890869;
            } else if (i3 != 3) {
                a.pb(listView);
                i = 2131889260;
                i2 = 2131890870;
            } else {
                a.lb(listView);
                i = 2131889255;
                i2 = 2131890868;
            }
            b(a, i2, i);
            v1 A6 = a.A6();
            if (A6 != null) {
                A6.e(this.i, listView);
            }
        }
    }

    class t implements mh.f {
        t() {
        }

        @Override
        public void a(mh mhVar) {
            if (mhVar.v()) {
                return;
            }
            int A = mhVar.A();
            int C5 = Main.this.C5();
            int i = i1.b[Main.this.a0.ordinal()];
            if (i == 1) {
                wo.b bVar = wo.b.values()[A];
                Main.this.S.P4(C5, bVar);
                Main.this.x.E(C5, bVar, true);
            } else if (i == 2) {
                tn.f fVar = tn.f.values()[A];
                Main.this.S.R4(C5, fVar);
                Main.this.z.s(Main.this.S, C5, fVar);
            } else {
                if (i != 3) {
                    return;
                }
                dk.i iVar = dk.i.values()[A];
                Main.this.S.Q4(C5, iVar);
                Main.this.y.s(Main.this.S, C5, iVar);
            }
        }
    }

    class t0 implements PopupWindow.OnDismissListener {
        final si i;
        final c2 q;
        final View r;
        final boolean s;
        final int t;

        t0(si siVar, c2 c2Var, View view, boolean z, int i) {
            this.i = siVar;
            this.q = c2Var;
            this.r = view;
            this.s = z;
            this.t = i;
        }

        @Override
        public void onDismiss() {
            throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.Main.t0.onDismiss():void");
        }
    }

    private enum t1 {
        DeleteContents,
        KeepContents
    }

    class u implements zh.j {
        u() {
        }

        @Override
        public void a(int i, int i2, boolean z) {
        }

        @Override
        public void b(boolean z) {
        }

        @Override
        public void c(int i) {
            Main.this.X6(i);
        }

        @Override
        public void d(int i) {
            r7.f("T", "tabReselect: enabled: " + Main.q0 + " " + System.currentTimeMillis());
            if (Main.q0 && Main.this.m5(7, new Object[]{new Integer(i)})) {
                Main.this.X6(i);
            }
        }

        @Override
        public void e(int i, int i2, int i3, int i4) {
        }

        @Override
        public boolean f(int i, int i2, boolean z) {
            boolean z2;
            ListView s6;
            if (!Main.q0) {
                return false;
            }
            Main.this.P.setCurrentItem(i2);
            c2.a aVar = c2.a.values()[i2];
            c2.a aVar2 = c2.a.Variable;
            if (aVar == aVar2) {
                Main.this.J6(false, false, false, aVar2);
                z2 = Main.this.qd();
                Main.this.Q5();
            } else {
                z2 = false;
            }
            Main.this.Ub(z2, true, false, false);
            if (!Main.pd(Main.this) || Main.this.F.getVisibility() == 0 || (s6 = Main.this.s6(aVar)) == null || (s6.getLastVisiblePosition() - s6.getFirstVisiblePosition()) + 1 < s6.getAdapter().getCount()) {
                return true;
            }
            Main.this.v.y0(s6, false, "T/entityDrag");
            return true;
        }

        @Override
        public boolean g(int i) {
            return false;
        }
    }

    class u0 extends Handler {
        final c2.a a;
        final View b;
        final int c;
        final String d;

        u0(c2.a aVar, View view, int i, String str) {
            this.a = aVar;
            this.b = view;
            this.c = i;
            this.d = str;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what != 0) {
                Main.this.ec(this.a, this.b, this.c, this.d);
            } else {
                Main main = Main.this;
                main.P6(new int[]{main.U.C0()});
            }
        }
    }

    private enum u1 {
        Add,
        Delete,
        Export,
        Import,
        Lock,
        Rename,
        SetIcon,
        ShiftLeft,
        ShiftRight,
        Unlock,
        SelectProject,
        Properties
    }

    class v extends Handler {
        v() {
        }

        @Override
        public void handleMessage(Message message) {
            Main.S5("configChange", true);
        }
    }

    class v0 implements si.i {
        final wo a;
        final ho b;
        final View c;

        v0(wo woVar, ho hoVar, View view) {
            this.a = woVar;
            this.b = hoVar;
            this.c = view;
        }

        @Override
        public void a(si siVar) {
            boolean z = this.a.P0() == 0;
            if (siVar.f()) {
                if (z) {
                    Main.this.P6(new int[]{this.a.C0()});
                    return;
                }
                return;
            }
            if (siVar.g()) {
                String i = siVar.i();
                if (TextUtils.isEmpty(i)) {
                    if (z) {
                        dq.j0(Main.this, 2131887832, new Object[0]);
                        Main.this.Hb(this.a, this.b, this.c);
                        return;
                    } else {
                        this.b.O0(null);
                        Main.this.S.A4(this.a);
                        Main.this.L6(c2.a.Profile);
                        return;
                    }
                }
                if (Main.this.S.a1(i, this.b.B0())) {
                    dq.a0(Main.this, 2131891070, new Object[0]);
                    Main.this.Hb(this.a, this.b, this.c);
                    return;
                }
                this.b.O0(i);
                Main.this.S.A4(this.a);
                Main.this.L6(c2.a.Profile);
                if (z) {
                    Main.this.Rb(this.a, false);
                }
            }
        }
    }

    public class v1 extends FragmentPagerAdapter implements ViewPager.OnPageChangeListener {
        private ViewPager a;
        private ArrayList<a> b;
        private Activity c;
        private int d;

        final class a {
            private final Class<?> a;
            private final Bundle b;
            private ListView c = null;

            a(Class<?> cls, Bundle bundle) {
                this.a = cls;
                this.b = bundle;
            }

            public ListView d() {
                return this.c;
            }

            public void e(ListView listView) {
                this.c = listView;
            }
        }

        public v1(Activity activity, ViewPager viewPager) {
            super(activity.getFragmentManager());
            this.b = new ArrayList<>();
            this.d = 0;
            this.c = activity;
            this.a = viewPager;
            viewPager.setAdapter(this);
            this.a.setOnPageChangeListener(this);
        }

        public void a(Class<?> cls, Bundle bundle) {
            this.b.add(new a(cls, bundle));
        }

        public ListView b(Integer num) {
            if (num != null && num.intValue() < this.b.size()) {
                return this.b.get(num.intValue()).d();
            }
            return null;
        }

        public void c() {
            this.a = null;
            this.b = null;
            this.c = null;
        }

        public void d(boolean z) {
            for (int i = 0; i < this.b.size(); i++) {
                a aVar = this.b.get(i);
                if (aVar.c != null && z) {
                    MyActivity.unbindAllReferences(aVar.c);
                }
                aVar.e(null);
            }
            this.b.clear();
            if (z) {
                return;
            }
            try {
                notifyDataSetChanged();
            } catch (Exception unused) {
            }
        }

        public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
            super.destroyItem(viewGroup, i, obj);
            FragmentManager fragmentManager = ((Fragment) obj).getFragmentManager();
            if (fragmentManager != null) {
                try {
                    FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
                    beginTransaction.remove((Fragment) obj);
                    beginTransaction.commit();
                } catch (IllegalStateException unused) {
                }
            }
        }

        public void e(c2.a aVar, ListView listView) {
            if (aVar.ordinal() < this.b.size()) {
                this.b.get(aVar.ordinal()).e(listView);
            }
        }

        public int getCount() {
            ArrayList<a> arrayList = this.b;
            if (arrayList != null) {
                return arrayList.size();
            }
            MyActivity.L(this.c, "TabsAdapter getCount null");
            return 0;
        }

        public Fragment getItem(int i) {
            a aVar = this.b.get(i);
            return Fragment.instantiate(this.c, aVar.a.getName(), aVar.b);
        }

        public int getItemPosition(Object obj) {
            Fragment fragment = (Fragment) obj;
            for (int i = 0; i < this.b.size(); i++) {
                if (this.b.get(i).a == fragment.getClass()) {
                    return i;
                }
            }
            return -2;
        }

        public void onPageScrollStateChanged(int i) {
            this.d = i;
        }

        public void onPageScrolled(int i, float f, int i2) {
            if (Main.this.od() && tp.e0() && i == 2 && Main.this.qd()) {
                if (this.d == 1 && !Main.this.U5()) {
                    Main.this.Xa(true, false);
                }
                Main.this.E.setTranslationY(0.0f - ((1.0f - f) * Main.this.E.getHeight()));
            }
        }

        public void onPageSelected(int i) {
            if (Main.q0) {
                Main.this.v();
                if (Main.this.B5().intValue() != i) {
                    Main.this.J.D(i, false);
                    if (i == 3) {
                        Main.this.Gc();
                    }
                }
            }
        }
    }

    class w extends xg {
        final boolean b;

        w(boolean z) {
            this.b = z;
        }

        @Override
        public void e() {
            Main.this.Xa(true, this.b);
        }
    }

    class w0 implements si.i {
        final int a;

        w0(int i) {
            this.a = i;
        }

        @Override
        public void a(si siVar) {
            if (siVar.f() || !siVar.g()) {
                return;
            }
            String i = siVar.i();
            Main main = Main.this;
            if (main.n5(i, main.S.W2(i), null)) {
                Main.this.S.O4(this.a, i);
                Main.this.Ia();
                Main.this.v();
            }
        }
    }

    enum w1 {
        ProfileReselect,
        ProfileAddOfType
    }

    class x extends xg {
        final boolean b;

        x(boolean z) {
            this.b = z;
        }

        @Override
        public void e() {
            Main.this.Xa(false, this.b);
        }
    }

    class x0 extends qh {
        final ListView i;

        x0(Context context, yg ygVar, ImageView imageView, ImageView imageView2, ImageView imageView3, ListView listView) {
            super(context, ygVar, imageView, imageView2, imageView3);
            this.i = listView;
        }

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case 1:
                    List<Integer> f = d().f();
                    wo woVar = (wo) d().getItem(f.get(0).intValue());
                    if (f.size() == 1 && woVar.u()) {
                        Main main = Main.this;
                        main.Fb(this.i, woVar, main.J.v(c2.a.Profile.ordinal()), -1, woVar.getName());
                        actionMode.finish();
                    } else {
                        Iterator<Integer> it = d().f().iterator();
                        int i = -1;
                        while (it.hasNext()) {
                            wo X0 = Main.this.S.X0((wo) d().getItem(it.next().intValue()), true);
                            X0.t1(Main.this.p6() >= 6);
                            if (i == -1) {
                                i = X0.C0();
                            }
                        }
                        actionMode.finish();
                        Main.this.L6(c2.a.Profile);
                        Main.this.W4(this.i, i);
                    }
                    return true;
                case 2:
                    Main main2 = Main.this;
                    main2.p5(main2.Ba(d().g()));
                    return true;
                case 3:
                    Iterator<Object> it2 = d().g().iterator();
                    while (true) {
                        if (!it2.hasNext()) {
                            Main main3 = Main.this;
                            main3.Qb(main3.findViewById(2), d().g());
                        } else if (!((wo) it2.next()).u()) {
                            dq.a0(Main.this, 2131887696, new Object[0]);
                        }
                    }
                    return true;
                case 4:
                case 5:
                    Iterator<Object> it3 = d().g().iterator();
                    while (it3.hasNext()) {
                        ((wo) it3.next()).E(menuItem.getItemId() == 4);
                    }
                    Main.this.K6(false, c2.a.Profile);
                    Main.this.K6(false, c2.a.Task);
                    Main.this.v();
                    return true;
                case ClockContract.InstancesColumns.MISSED_STATE:
                case 7:
                    Iterator<Object> it4 = d().g().iterator();
                    while (it4.hasNext()) {
                        wo woVar2 = (wo) it4.next();
                        if (menuItem.getItemId() == 6) {
                            woVar2.A1(true);
                            woVar2.C1(0);
                        } else {
                            woVar2.A1(false);
                        }
                    }
                    Main.this.K6(false, c2.a.Profile);
                    Main.this.v();
                    return true;
                case 8:
                    Main main4 = Main.this;
                    main4.Ob(main4.findViewById(8), (wo) Main.this.x.d(), true, -1);
                    return true;
                case 9:
                    wo woVar3 = Main.this.U;
                    if (woVar3 != null) {
                        Main.this.Ic(ProfileProperties.j0(woVar3), 25);
                        Main.this.v();
                    }
                    return true;
                case 10:
                    Main.this.b0();
                    return true;
                case 11:
                    Main main5 = Main.this;
                    main5.ha(main5.Ba(main5.x.g()));
                    Main.this.K6(false, c2.a.Profile);
                    Main.this.v();
                    return true;
                case 12:
                    g(this.i);
                    return true;
                case 13:
                    Main main6 = Main.this;
                    main6.f0.o2(main6.x.g());
                    return true;
                default:
                    return false;
            }
        }

        @Override
        public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
            super.onCreateActionMode(actionMode, menu);
            return Main.this.U(actionMode);
        }

        @Override
        public void onDestroyActionMode(ActionMode actionMode) {
            super.onDestroyActionMode(actionMode);
            Main.this.U(null);
        }

        @Override
        public void onItemCheckedStateChanged(ActionMode actionMode, int i, long j, boolean z) {
            if (Main.this.a5(c2.a.Profile, i)) {
                return;
            }
            super.onItemCheckedStateChanged(actionMode, i, j, z);
        }

        @Override
        public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
            super.e(actionMode, menu, false);
            if (Main.this.u()) {
                Main.this.R4(menu, 10);
                return true;
            }
            int i = this.g;
            if (i == -1) {
                return false;
            }
            wo woVar = (wo) Main.this.x.getItem(i);
            boolean j1 = Settings.j1(Main.this.M);
            if (f()) {
                net.dinglisch.android.taskerm.a.E(Main.this, 8, menu);
            }
            if ((!f() || !vi.v(Main.this.M)) && woVar != null) {
                if (woVar.h1()) {
                    net.dinglisch.android.taskerm.a.n(Main.this, 6, menu, true);
                }
                if (!woVar.h1()) {
                    net.dinglisch.android.taskerm.a.p(Main.this, 7, menu, true);
                }
            }
            if (f() && !j1) {
                net.dinglisch.android.taskerm.a.K(Main.this, 9, menu);
            }
            Main.this.R4(menu, 10);
            if (!j1) {
                net.dinglisch.android.taskerm.a.f(Main.this, 1, menu, false);
            }
            net.dinglisch.android.taskerm.a.k(Main.this, 2, menu);
            net.dinglisch.android.taskerm.a.r(Main.this, 3, false, menu);
            if (woVar != null && !woVar.q() && !j1) {
                net.dinglisch.android.taskerm.a.w(Main.this, 4, false, menu);
            }
            if (Main.this.y6() == wo.b.User && (!f() || this.g > 0)) {
                net.dinglisch.android.taskerm.a.D(Main.this, 11, menu);
            }
            if (woVar != null && woVar.q()) {
                net.dinglisch.android.taskerm.a.R(Main.this, 5, false, menu);
            }
            if (!d().b()) {
                net.dinglisch.android.taskerm.a.P(Main.this, 12, menu);
            }
            if (Main.this.S.c2() > 1) {
                net.dinglisch.android.taskerm.a.C(Main.this, 13, false, menu);
            }
            return true;
        }
    }

    private enum x1 {
        AddEnter,
        AddExit,
        Add,
        Name,
        Unlink,
        Reselect,
        MoveToEnter,
        MoveToExit
    }

    class y implements TextWatcher {
        y() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            Main.this.A.u(editable.toString());
            Main.this.A.x();
        }

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }
    }

    class y0 implements si.i {
        final wo a;
        final ListView b;

        y0(wo woVar, ListView listView) {
            this.a = woVar;
            this.b = listView;
        }

        @Override
        public void a(si siVar) {
            if (siVar.f()) {
                return;
            }
            String i = siVar.i();
            wo X0 = Main.this.S.X0(this.a, true);
            if (i.length() > 0) {
                X0.G(i);
            }
            X0.t1(Main.this.p6() >= 6);
            Main.this.L6(c2.a.Profile);
            Main.this.W4(this.b, X0.C0());
        }
    }

    class z implements AdapterView.OnItemClickListener {
        z() {
        }

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
            if (Main.this.y()) {
                return;
            }
            Main.this.w7(i);
        }
    }

    class z0 extends Handler {
        final List a;

        z0(List list) {
            this.a = list;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                Iterator it = this.a.iterator();
                boolean z = false;
                while (it.hasNext()) {
                    String name = ((fq) it.next()).getName();
                    if (Main.this.A.t(name)) {
                        z = true;
                    }
                    kq.D(Main.this, name);
                }
                Main.this.A.x();
                if (z) {
                    lp.d(Main.this, 2131890857);
                }
                Main.this.v();
                Main.this.P7();
            }
        }
    }

    public c2.a A5() {
        Integer B5 = B5();
        if (B5 != null) {
            return T5(B5.intValue());
        }
        MyActivity.L(this, "curEntity tabNo null");
        return c2.a.Profile;
    }

    public static boolean A7() {
        return u0;
    }

    public void A8() {
        Ub(A5() == c2.a.Variable && qd(), false, true, true);
    }

    public lj.e0 A9(int i2) {
        o7(i2);
        return lj.e0.a;
    }

    public void Aa() {
        View view = this.H;
        if (view == null) {
            MyActivity.L(this, "populateViews projectTabHostShadow null");
            return;
        }
        if (tp.e0()) {
            up.D(view);
        } else {
            ImageView imageView = (ImageView) findViewById(R.id.home);
            if (imageView != null) {
                imageView.setBackgroundResource(tp.J(this, 2130968984));
                imageView.setOnLongClickListener(new r0());
            }
        }
        this.K = (ImageView) findViewById(2131296450);
        this.L = (ImageView) findViewById(2131296453);
        this.f0.h2();
        androidx.core.view.z0.c(this.K, "Test", new o3.q0() {
            public final boolean a(View view2, q0.a aVar) {
                boolean L8;
                L8 = Main.this.L8(view2, aVar);
                return L8;
            }
        });
        this.K.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                Main.this.M8(view2);
            }
        });
        this.L.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view2) {
                Main.this.N8(view2);
            }
        });
        this.K.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public final boolean onLongClick(View view2) {
                boolean O8;
                O8 = Main.this.O8(view2);
                return O8;
            }
        });
        ob(true);
        am amVar = new am();
        this.v = amVar;
        amVar.b0(this, "T", null, this.K, this.F, view, null, false, true, (ImageView) findViewById(2131297341), (ImageView) findViewById(2131297339), null, new c1());
        this.v.v0(this, null, pd(this), "onCreate");
        am.Z(this.L);
    }

    private void Ab(final int i2) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.j9(i2);
            }
        });
    }

    private void Ac(View view, wo woVar, int i2, int i3) {
        char c2;
        boolean c12 = woVar.c1(0);
        boolean c13 = woVar.c1(1);
        boolean u2 = this.S.K2(woVar, i2).u();
        boolean i12 = woVar.i1(this, com.joaomgcd.taskerm.util.x2.t(this.S, this, woVar, null, "showTaskOptionsFromProfile"));
        mh mhVar = new mh(this, view);
        String g2 = vh.g(this, 2131891163, new Object[0]);
        String g3 = vh.g(this, 2131891170, new Object[0]);
        if (!c12) {
            if (i12) {
                mhVar.k(x1.Add.ordinal(), 2131888739, 2130969155);
            } else {
                mhVar.n(x1.AddEnter.ordinal(), vh.g(this, 2131888740, g2), 2130969202);
            }
        }
        if (!c13) {
            if (i12) {
                mhVar.k(x1.Add.ordinal(), 2131888739, 2130969155);
            } else {
                mhVar.n(x1.AddExit.ordinal(), vh.g(this, 2131888740, g3), 2130969203);
            }
        }
        if (!i12) {
            if (c12) {
                c2 = 0;
            } else {
                c2 = 0;
                mhVar.n(x1.MoveToEnter.ordinal(), vh.g(this, 2131888921, g2), 2130969285);
            }
            if (!c13) {
                int ordinal = x1.MoveToExit.ordinal();
                Object[] objArr = new Object[1];
                objArr[c2] = g3;
                mhVar.n(ordinal, vh.g(this, 2131888921, objArr), 2130969285);
            }
        }
        if (!u2) {
            mhVar.k(x1.Name.ordinal(), 2131889790, 2130969235);
        }
        mhVar.k(x1.Reselect.ordinal(), 2131888952, 2130969269);
        mhVar.k(x1.Unlink.ordinal(), 2131889078, 2130969261);
        mhVar.F(new n0(view, woVar, i2, i3)).show();
    }

    public Integer B5() {
        zh zhVar = this.J;
        if (zhVar == null) {
            return null;
        }
        return Integer.valueOf(zhVar.r());
    }

    public tn.f B6() {
        tn.f fVar = tn.f.User;
        xi s2 = this.S.s2(C5(), "gts");
        if (s2 != null) {
            return s2.N();
        }
        r7.f("T", "gts: no project index " + C5());
        return fVar;
    }

    private boolean B7() {
        return z7() && this.d0.f();
    }

    public void B8() {
        setContentView(2131493567);
    }

    public void B9(xi xiVar, q1 q1Var, pe.g gVar) throws Exception {
        j6(xiVar.S(this, this.S, gVar), q1Var);
    }

    public int[] Ba(List<Object> list) {
        int size = list.size();
        int[] iArr = new int[size];
        for (int i2 = 0; i2 < size; i2++) {
            iArr[i2] = ((wo) list.get(i2)).C0();
        }
        return iArr;
    }

    public void Bb() {
        ExtensionsContextKt.m(this, "https://youtu.be/s6EAbLW5WSk");
    }

    public void Bc(final w1 w1Var, final View view, final wo woVar, final int i2) {
        final com.joaomgcd.taskerm.dialog.l l2 = com.joaomgcd.taskerm.dialog.l.l(this, 2131887199);
        this.f0.r(new Runnable() {
            @Override
            public final void run() {
                Main.this.P9(view, woVar, i2, w1Var, l2);
            }
        });
    }

    private void C7(java.io.File r17) {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.Main.C7(java.io.File):void");
    }

    public void C8() {
        rb(this, (ImageView) findViewById(R.id.home));
    }

    public void C9(int i2, mh mhVar) {
        if (mhVar.v()) {
            w5("projMenuCancelled");
            return;
        }
        final xi s2 = this.S.s2(Da(i2), "spen");
        final q1 q1Var = q1.values()[mhVar.A()];
        int ordinal = q1Var.ordinal();
        if (ordinal == 0) {
            b6(s2);
            return;
        }
        if (ordinal == 1 || ordinal == 2) {
            this.f0.m1(q1Var, new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.B9(s2, q1Var, (pe.g) obj);
                }
            });
            return;
        }
        if (ordinal == 5) {
            c6(s2);
            return;
        }
        if (ordinal == 6) {
            Y5(s2, false);
            return;
        }
        if (ordinal == 7) {
            Y5(s2, true);
            return;
        }
        r7.k("T", "unexpected export mode " + mhVar.A());
    }

    private int Ca(int i2) {
        return i2;
    }

    public void Cb() {
        ExtensionsContextKt.m(this, "https://youtu.be/Oufvnh_9RD0");
    }

    private void Cc(wo woVar) {
        wo woVar2 = this.U;
        Intent o02 = TimeSelect.o0(woVar2 == null ? null : (kp) woVar2.T0(1));
        kq.e(this, this.S, null, o02, null, woVar);
        Ic(o02, 23);
    }

    private g5 D7(File file) {
        g5 h3 = this.S.h3(this, file, C5());
        if (h3.a()) {
            dq.b0(this, h3.b(this), new Object[0]);
        } else {
            wo woVar = (wo) h3.c;
            k6(c2.a.Profile, c2.a.Task);
            W4(q6(), woVar.C0());
        }
        return h3;
    }

    public void D8() {
        ub();
        wb();
        vb();
        xb();
    }

    public int Da(int i2) {
        return i2;
    }

    public void Db() {
        ExtensionsContextKt.m(this, "https://youtu.be/bCJ3A-PZf5k");
    }

    private boolean Dc() {
        ig.a.a(this);
        return this.f0.f1(2131887254, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean Q9;
                Q9 = Main.this.Q9();
                return Q9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.S9();
            }
        });
    }

    public void E5(wo woVar, int i2) {
        this.U.h0(i2);
        this.U.d0();
        this.S.A4(this.U);
    }

    private g5 E7(File file) {
        g5 i3 = this.S.i3(this, getPackageManager(), file);
        if (i3.b == -1) {
            S4();
            k6(c2.a.values());
        } else {
            dq.a0(this, 2131887881, file.getName(), i3.b(this));
        }
        return i3;
    }

    public void E8(int i2) {
        Vb(c2.a.values()[i2]);
        ya();
    }

    public void E9() {
        this.a0 = null;
        Wb(null);
    }

    private void Ea(String str, boolean z2) {
        this.N.edit().putBoolean(str, z2).commit();
    }

    public void Eb() {
        ExtensionsContextKt.m(this, "https://youtu.be/rkQRH17H-DY");
    }

    public void Ec(List<Object> list) {
        TextBoxDialogFragment.Y(this, new z0(list), 2131887163);
    }

    private void F5() {
        final c2.a A5 = A5();
        if (A5 == c2.a.Scene || A5 == c2.a.Variable) {
            Fa(A5);
        } else {
            this.f0.p(new Runnable() {
                @Override
                public final void run() {
                    Main.this.S7(this, A5);
                }
            });
        }
    }

    private g5 F7(File file) {
        g5 l3 = this.S.l3(this, file, C5());
        if (l3.a()) {
            dq.b0(this, l3.b(this), new Object[0]);
        } else {
            dk dkVar = (dk) l3.c;
            k6(c2.a.Scene);
            X4(dkVar.getName());
        }
        return l3;
    }

    public void F8() {
        cb();
        Z4(D5());
    }

    public void F9(int i2, Integer num) throws Exception {
        if (od()) {
            this.I.L(this, i2, num.intValue());
        } else {
            this.I.K(i2, num.intValue());
        }
        this.S.S3(Da(i2), Da(num.intValue()));
    }

    private void Fa(final c2.a aVar) {
        this.f0.r(new Runnable() {
            @Override
            public final void run() {
                Main.this.P8(aVar);
            }
        });
    }

    public void Fb(ListView listView, wo woVar, View view, int i2, String str) {
        boolean z2;
        si siVar = new si(this, str);
        if (view != null || i2 == -1) {
            z2 = true;
        } else {
            siVar.l(q6(), i2);
            z2 = false;
        }
        siVar.o(new y0(woVar, listView)).p(2131887407).u(view, this.K, z2);
    }

    public void Fc(final fq fqVar, View view, ListView listView, int i2) {
        si siVar = new si(this, kq.B0(this, fqVar.getName()));
        siVar.o(new si.i() {
            @Override
            public final void a(si siVar2) {
                Main.this.T9(fqVar, siVar2);
            }
        }).n(15).l(listView, i2);
        siVar.v(j5(view, true), false);
    }

    private void G5(int i2, boolean z2) {
        if (od()) {
            xg.i(this, this.I.v(i2), 2130772003, 0L, 450L, new f(i2, z2));
        } else {
            H5(i2, z2);
        }
    }

    private void G6(net.dinglisch.android.taskerm.c cVar, List<Object> list) {
        Object remove = list.remove(0);
        if (remove.getClass() == tn.class) {
            y7((tn) remove, cVar, list);
        } else if (remove.getClass() == k7.class) {
            b7((k7) remove, list);
        }
    }

    private g5 G7(File file) {
        g5 o3 = this.S.o3(this, file, C5());
        if (o3.a()) {
            dq.b0(this, o3.b(this), new Object[0]);
        } else {
            tn tnVar = (tn) o3.c;
            k6(c2.a.Task);
            int H = this.S.H(tnVar.P0());
            if (H != C5()) {
                gd(H);
            }
            Y4(tnVar.P0());
        }
        return o3;
    }

    public void G8(com.joaomgcd.taskerm.util.x6 x6Var) throws Exception {
        if (!x6Var.b()) {
            com.joaomgcd.taskerm.util.p1 c2 = x6Var.c();
            dq.d0(this, c2 == null ? "Unknown error" : c2.getErrorMessage(), new Object[0]);
            return;
        }
        try {
            this.S.p1(this, GenericActionBackupToGoogleDrive.getTAG(), (String) x6Var.d(), true);
            C7(null);
            i6();
            Ta();
        } catch (Throwable th2) {
            pg.w0.X0(this, th2);
        }
    }

    public void G9(View view, final int i2, int i3, xi xiVar, mh mhVar) {
        if (mhVar.v()) {
            return;
        }
        u1 u1Var = u1.values()[mhVar.A()];
        switch (u1Var.ordinal()) {
            case 0:
                gc(view, null);
                break;
            case 1:
                oc(i2);
                break;
            case 2:
                O5(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.D9(i2);
                    }
                });
                break;
            case 3:
                O5(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.E9();
                    }
                });
                break;
            case 4:
            case 9:
                boolean b5 = this.S.b5(Da(i2));
                Ia();
                J6(false, false, false, c2.a.values());
                if (b5) {
                    id();
                    break;
                }
                break;
            case 5:
                rc(i2);
                break;
            case ClockContract.InstancesColumns.MISSED_STATE:
                Ic(ImageSelect.s0(this, 383), 13);
                break;
            case 7:
            case 8:
                com.joaomgcd.taskerm.helper.q qVar = this.f0;
                qVar.R(qVar.K1(i2, u1Var == u1.ShiftLeft, this.I.x()), new oi.d() {
                    @Override
                    public final void accept(Object obj) {
                        Main.this.F9(i2, (Integer) obj);
                    }
                });
                break;
            case 10:
                this.f0.N1();
                break;
            case 11:
                this.f0.y2(i3, xiVar);
                break;
        }
    }

    private void Ga(final boolean z2, final String str) {
        final com.joaomgcd.taskerm.dialog.l m2 = com.joaomgcd.taskerm.dialog.l.m(this, 2131887123, false);
        this.f0.l(new Runnable() {
            @Override
            public final void run() {
                Main.this.W8(str, z2, m2);
            }
        });
    }

    private void Gb() {
        TextBoxDialogFragment.Y(this, new l0(), 2131887155);
    }

    public boolean Gc() {
        return this.f0.f1(2131890851, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean bool;
                bool = Boolean.TRUE;
                return bool;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Eb();
            }
        });
    }

    public void H5(int i2, boolean z2) {
        int Da = Da(this.X);
        this.I.O(this.X);
        this.S.d1(getPackageManager(), Da, z2);
        this.x.E(C5(), y6(), false);
        L6(c2.a.values());
    }

    private void H6() {
        if (l6(32)) {
            Jb(this.J.v(c2.a.Profile.ordinal()));
        }
    }

    private void H7(v6 v6Var) {
        to toVar = this.Z;
        if (toVar == null) {
            MyActivity.L(this, "initKeyStoreOrLaunchFactory appExportData null");
            return;
        }
        toVar.s2(0, "ikslf").n0(v6Var);
        if (this.Y.getClass().equals(tn.class)) {
            ((tn) this.Y).x2(v6Var);
        } else {
            ((xi) this.Y).n0(v6Var);
        }
        Ta();
        if (jh.n(this)) {
            r7.f("T", "Spawn have user key");
            TextBoxDialogFragment.I(new d0(), com.joaomgcd.taskerm.util.x2.Q4(2131889495, this, new Object[0]), null, com.joaomgcd.taskerm.util.x2.Q4(2131886891, this, new Object[0]), com.joaomgcd.taskerm.util.x2.Q4(2131886867, this, new Object[0]), null, 37, null, 128, null, null).E(this);
            return;
        }
        r7.f("T", "Spawn don't have user key");
        if (jh.m(this)) {
            r7.f("T", "Spawn have basic key");
            this.f0.Z(Y9("keystore.auto", "bl^!)*(!*{a", "ImACertPass"), new Runnable() {
                @Override
                public final void run() {
                    Main.this.p8();
                }
            });
            return;
        }
        r7.f("T", "Spawn don't have basic key");
        Intent h2 = jh.h(this);
        r7.f("T", "Spawn created basic intent for key store");
        if (h2 == null) {
            dq.a0(this, 2131887816, new Object[0]);
            w5("initkey3");
        } else {
            r7.f("T", "Spawn starting activity for cert");
            Ic(h2, 18);
            r7.f("T", "Spawn started activity for cert");
        }
    }

    public void H8(String str) {
        oi.j(this, 2131888817, "\nID:\t" + str + "\n\nSDK:\t" + dq.g() + "\nRelease:\t" + Build.VERSION.RELEASE + "\nDisplay:\t" + Build.DISPLAY + "\n\nModel:\t" + Build.MODEL + "\nBrand:\t" + Build.BRAND + "\nDevice:\t" + Build.DEVICE + "\nProduct:\t" + Build.PRODUCT + "\n");
    }

    public void H9(si siVar, dk dkVar) {
        if (!siVar.f()) {
            String i2 = siVar.i();
            boolean p2 = this.S.p(i2);
            c2.a aVar = c2.a.Scene;
            if (n5(i2, p2, aVar) && !TextUtils.isEmpty(i2)) {
                if (this.S.p(i2)) {
                    dq.a0(this, 2131887890, i2);
                } else {
                    dk B0 = dkVar.B0();
                    B0.G(i2);
                    B0.w0(this.S);
                    this.S.y0(B0, C5());
                    L6(aVar);
                    X4(B0.getName());
                }
            }
        }
        v();
    }

    public void Ha() {
        this.S.U0();
        this.S.k(getPackageManager());
    }

    public void Hb(wo woVar, ho hoVar, View view) {
        si siVar = new si(this, hoVar.D0() ? hoVar.getName() : null);
        int x2 = this.x.x(woVar.C0());
        if (U4()) {
            siVar.p(2131887403);
        }
        siVar.l(q6(), x2);
        siVar.o(new v0(woVar, hoVar, view)).u(j5(view, true), this.F, false);
    }

    private boolean Hc() {
        if (com.joaomgcd.taskerm.util.k.d(this)) {
            return this.f0.f1(2131888079, new xj.a() {
                @Override
                public final Object invoke() {
                    Boolean V9;
                    V9 = Main.this.V9();
                    return V9;
                }
            }, new Runnable() {
                @Override
                public final void run() {
                    Main.this.W9();
                }
            });
        }
        return false;
    }

    private void I5() {
        Jc("runAction", new Intent(this, (Class<?>) ActionEdit.class).putExtra("raf", ActionEdit.b0.UI.toString()));
    }

    private void I6(ho hoVar, List<Object> list) {
        wo woVar = (wo) list.remove(0);
        Qa(c2.a.Profile, "handleCSR");
        int B0 = hoVar.B0();
        this.W = B0;
        Kc(woVar, B0, false);
    }

    public void I8() {
        final String f2 = Licence.s0(this).f();
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                Main.this.H8(f2);
            }
        });
    }

    public void I9(si siVar, tn tnVar) {
        if (!siVar.f()) {
            String i2 = siVar.i();
            if (!TextUtils.isEmpty(i2)) {
                if (this.S.N3(i2)) {
                    dq.a0(this, 2131888514, new Object[0]);
                } else {
                    tn r02 = tnVar.r0();
                    r02.t2(-1);
                    r02.G(i2);
                    this.S.B0(r02, C5());
                    r02.X1();
                    L6(c2.a.Task);
                    Y4(r02.P0());
                }
            }
        }
        v();
    }

    public void Ia() {
        xi s2;
        for (int i2 = 0; i2 < this.I.x(); i2++) {
            int Da = Da(i2);
            if (Da >= 0 && (s2 = this.S.s2(Da, "rpt")) != null) {
                if (s2.Q()) {
                    this.I.J(i2, Da == 0 ? getString(2131887369) : s2.getName());
                    this.I.H(i2);
                    this.I.W(this, i2, s2.getIcon());
                } else {
                    this.I.G(i2);
                    this.I.J(i2, s2.getName());
                    this.I.X(i2, 1);
                }
                this.I.Y(this, Da, sp.h0(s2.X(), false, sp.l0(this), sp.u0()));
            }
        }
    }

    private void Ib(wo woVar, int i2, View view, int i3) {
        mh mhVar = new mh(this, view);
        if (woVar.m1() < 4) {
            mhVar.k(n1.Add.ordinal(), 2131889432, 2130969155);
        }
        if (!Settings.j1(this.M)) {
            mhVar.k(n1.Clone.ordinal(), 2131888796, 2130969183);
        }
        mhVar.k(n1.Delete.ordinal(), 2131888810, 2130969299);
        mhVar.k(n1.Name.ordinal(), woVar.T0(i2).D0() ? 2131888950 : 2131889790, 2130969235);
        mhVar.F(new m0(view, woVar, i2)).show();
    }

    public void J6(boolean z2, boolean z3, boolean z4, c2.a... aVarArr) {
        pg.w0.p0(new q(z2, aVarArr, z3, z4));
    }

    public void J7() {
        to toVar = this.S;
        if (toVar == null) {
            return;
        }
        toVar.t3(this, true);
    }

    public void J8() {
        this.f0.o1(com.joaomgcd.taskerm.util.e5.o0(this), new Runnable() {
            @Override
            public final void run() {
                Main.this.I8();
            }
        });
    }

    private void Ja() {
        if (z7() && B7() && this.e0 != null) {
            r7.f("T", "remove monitor listener");
            MonitorService u6 = u6("rmsl");
            if (u6 != null) {
                u6.d8(this.e0);
            }
            this.e0 = null;
        }
    }

    public void Jb(View view) {
        boolean z2;
        String[] strArr = new String[8];
        Resources resources = this.O;
        if (resources == null) {
            MyActivity.L(this, "showContextSelectDialog res null");
            return;
        }
        int i2 = 0;
        int i3 = 0;
        int i4 = 0;
        while (true) {
            if (i2 >= 8) {
                break;
            }
            wo woVar = this.U;
            if (woVar == null || !woVar.Z0(i2)) {
                if (ho.I0(i2)) {
                    z2 = i4 <= 0;
                    i4++;
                }
                if (z2) {
                    strArr[i3] = ho.A0(resources, i2);
                    i3++;
                }
            }
            i2++;
        }
        String[] strArr2 = new String[i3];
        int i5 = i3;
        while (true) {
            int i6 = i5 - 1;
            if (i5 <= 0) {
                break;
            }
            strArr2[i6] = strArr[i6];
            i5 = i6;
        }
        int[] iArr = new int[i3];
        int[] iArr2 = new int[i3];
        for (int i7 = 0; i7 < i3; i7++) {
            String str = strArr2[i7];
            int i8 = 0;
            while (true) {
                if (i8 >= 8) {
                    break;
                }
                if (ho.A0(resources, i8).equals(str)) {
                    iArr[i7] = ho.u0(i8);
                    iArr2[i7] = i8;
                    break;
                }
                i8++;
            }
        }
        wo woVar2 = this.U;
        if (woVar2 != null && woVar2.I0() != 0) {
            z2 = false;
        }
        if (view == null) {
            view = this.K;
        }
        mh mhVar = new mh(this, view);
        for (int i9 = 0; i9 < i3; i9++) {
            mhVar.n(iArr2[i9], strArr2[i9], iArr[i9]);
        }
        if (z2 && U4()) {
            mhVar.G(2131887070);
        }
        mhVar.F(new f0(view)).show();
    }

    public boolean Jc(String str, Intent intent) {
        if (!ad("activity")) {
            return false;
        }
        Va(str, true);
        db();
        return dq.l3(this, intent);
    }

    private void K5() {
        String str;
        r7.f("T", "share start");
        Intent intent = null;
        try {
            str = this.S.C1(this, 52);
        } catch (Exception unused) {
            dq.b0(this, "failed to compile data for sharing", new Object[0]);
            str = null;
        }
        r7.f("T", "share got config data");
        Intent intent2 = new Intent();
        intent2.setType("text/plain");
        intent2.setAction("android.intent.action.SEND");
        if (str == null) {
            dq.b0(this, "failed to compile data for sharing (2)", new Object[0]);
        } else {
            r7.f("T", "share get bytes");
            long length = str.getBytes().length;
            r7.f("T", "share got " + length + " bytes");
            if (length < 130000) {
                intent2.putExtra("android.intent.extra.TEXT", str);
            } else {
                File u2 = com.joaomgcd.taskerm.util.g8.u(this, "share.txt");
                r7.f("T", "share bytes " + length + " too large, use temp file " + u2);
                try {
                    com.joaomgcd.taskerm.util.g8.M0(u2, str);
                    intent2.putExtra("android.intent.extra.STREAM", com.joaomgcd.taskerm.util.g8.i0(u2, this, null, intent2));
                } catch (Exception unused2) {
                    dq.a0(this, 2131887922, u2);
                }
            }
        }
        intent = intent2;
        if (intent != null) {
            if (dq.F(getPackageManager().queryIntentActivities(intent, 0))) {
                r7.f("T", "no activities match intent");
                dq.a0(this, 2131887839, vh.g(this, 2131891243, new Object[0]));
                return;
            }
            try {
                Ic(Intent.createChooser(intent, vh.g(this, 2131891243, new Object[0])), 26);
            } catch (Exception e2) {
                r7.H("T", "share", e2);
                dq.a0(this, 2131887839, vh.g(this, 2131891243, new Object[0]));
            }
        }
    }

    private boolean K7(int i2) {
        return i2 < v6();
    }

    public void K8(com.joaomgcd.taskerm.util.s6 s6Var) throws Exception {
        String string = getString(2131890723);
        if (!s6Var.b()) {
            string = getString(2131890724);
        }
        com.joaomgcd.taskerm.util.z2.M0(string, this);
    }

    public void K9() {
        ExtensionsContextKt.m(this, "https://tasker.joaoapps.com/userguide/en/faqs/faq-problem.html#00");
    }

    private ji.r<Boolean> Ka() {
        if (!com.joaomgcd.taskerm.settings.q0.e(this)) {
            return ji.r.w(Boolean.TRUE);
        }
        Yb(true);
        return this.f0.z(new xj.a() {
            @Override
            public final Object invoke() {
                ji.r Z8;
                Z8 = Main.this.Z8();
                return Z8;
            }
        });
    }

    private void Kb() {
        wo woVar = this.U;
        Ic(DaySelect.k0(woVar == null ? null : (net.dinglisch.android.taskerm.w1) woVar.T0(2)), 22);
    }

    private void L5() {
        M5(null);
    }

    public void L6(c2.a... aVarArr) {
        J6(true, true, false, aVarArr);
    }

    private boolean L7() {
        return l6(128);
    }

    public boolean L8(View view, q0.a aVar) {
        com.joaomgcd.taskerm.util.z2.K0("Testing Accessibility Action", this);
        return true;
    }

    public static void L9(mh mhVar) {
        mhVar.I();
        mhVar.K();
    }

    private ji.v<? extends Boolean> La() {
        final List<String> O = this.w.O();
        if (O.isEmpty()) {
            return ji.r.w(Boolean.TRUE);
        }
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                Main.this.b9(O);
            }
        };
        if (!this.w.Q0(this)) {
            return new GenericActionActivityRequestMissingPermissions(this.w.Q(), null).run(this).q(new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.c9(O, runnable, (com.joaomgcd.taskerm.util.s6) obj);
                }
            }).x(new oi.e() {
                @Override
                public final Object a(Object obj) {
                    Boolean d9;
                    d9 = Main.d9((com.joaomgcd.taskerm.util.s6) obj);
                    return d9;
                }
            });
        }
        runnable.run();
        return ji.r.w(Boolean.FALSE);
    }

    public void Lb(View view) {
        mh mhVar = new mh(this, view);
        if (MonitorService.c2(this)) {
            mhVar.k(o1.Disable.ordinal(), 2131888819, 2130969289);
        } else {
            mhVar.k(o1.Enable.ordinal(), 2131888841, 2130969288);
        }
        mhVar.F(new g0()).show();
    }

    public void Lc() {
        Ic(new Intent(this, (Class<?>) CreateKeyStore.class), 17);
    }

    private void M5(Boolean bool) {
        boolean c2 = bool == null ? MonitorService.c2(this) : !bool.booleanValue();
        if (c2) {
            dq.p3(this);
            Ya(2);
            dq.j0(this, 2131891153, new Object[0]);
        } else {
            dq.n3(this, false);
        }
        Ea(ClockContract.AlarmsColumns.ENABLED, !c2);
        MyActivity.Y(this, "T/doToggleOnOff");
        mb(this);
    }

    private void M6(c2.a... aVarArr) {
        J6(true, true, true, aVarArr);
    }

    private boolean M7() {
        c2.a A5 = A5();
        return (A5 == c2.a.Task && (B6() == tn.f.User || B6() == tn.f.UserReverse)) || (A5 == c2.a.Scene && z6() == dk.i.User) || (A5 == c2.a.Profile && y6() == wo.b.User);
    }

    public void M8(View view) {
        if (y()) {
            return;
        }
        F5();
    }

    public void M9(wo woVar, w1 w1Var, View view, int i2, mh mhVar) {
        if (mhVar.v()) {
            if (woVar.P0() == 0) {
                TextBoxDialogFragment.a0(this, new k1(woVar, w1Var, view, i2), vh.g(this, 2131887178, new Object[0]));
                return;
            }
            return;
        }
        int A = mhVar.A();
        if (A != 934524) {
            woVar.F1(i2, A);
            L6(c2.a.Profile);
        } else {
            this.U = woVar;
            this.W = i2;
            fc(c2.a.Task, view, this.x.x(woVar.C0()), null, -tp.Y(10));
        }
    }

    public boolean Ma(Context context, File file, String str, boolean z2) {
        boolean o4 = this.S.o4(context, file, str, z2, false, true);
        boolean z3 = false;
        if (o4) {
            if (jh.o(this)) {
                dq.j0(this, 2131890221, new Object[0]);
            } else {
                dq.j0(this, 2131887817, new Object[0]);
            }
            C7(file);
            i6();
            z3 = true;
        } else {
            dq.a0(this, 2131891078, new Object[0]);
        }
        Ta();
        return z3;
    }

    private void Mb() {
        TextBoxDialogFragment.a0(this, new g1(), vh.g(this, 2131887114, new Object[0]));
    }

    public void Mc(ListView listView, int i2, String str) {
        if (am.J(this)) {
            Ua(i2, listView, "startDrag");
            View childAt = listView.getChildAt(i2 - listView.getFirstVisiblePosition());
            boolean z2 = true;
            try {
                if (((c2) listView.getAdapter().getItem(i2)).r()) {
                    z2 = m5(15, null);
                }
            } catch (Exception unused) {
            }
            if (z2) {
                if (pd(this) && this.F.getVisibility() != 0) {
                    this.v.y0(listView, false, "T/startDrag");
                }
                yq.j(listView, null, new gh(childAt), Boolean.FALSE, 0);
            }
        }
    }

    private void N5(final Runnable runnable) {
        if (m6()) {
            runnable.run();
        }
        this.g0 = false;
        if (sp.l0(this)) {
            this.f0.R(com.joaomgcd.taskerm.dialog.a.X(this), new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.W7(runnable, (we.l0) obj);
                }
            });
        } else {
            runnable.run();
        }
    }

    public void f8(int i2) {
        if (i2 == 7) {
            Ab(28);
        } else if (i2 == 46) {
            K5();
        } else {
            if (i2 != 47) {
                return;
            }
            this.f0.m1(q1.DescrToEmail, new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.e8((pe.g) obj);
                }
            });
        }
    }

    public void N8(View view) {
        this.f0.d2();
    }

    public void N9(ArrayList arrayList, int i2, mh mhVar, int i3, int i4, ArrayList arrayList2, int i5, final w1 w1Var, final int i6, final wo woVar, final View view) {
        int P0;
        int i7 = this.N.getInt("lTsk", -1);
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            tn tnVar = (tn) it.next();
            int P02 = tnVar.P0();
            if (P02 != i2) {
                mhVar.r(P02, tnVar.getName(), tnVar.Q0(this, i3), i4, P02 == i7 ? mh.d.Top : mh.d.Bottom);
            }
        }
        Iterator it2 = arrayList2.iterator();
        while (it2.hasNext()) {
            tn tnVar2 = (tn) it2.next();
            if (!arrayList.contains(tnVar2) && (P0 = tnVar2.P0()) != i2) {
                mhVar.r(P0, tnVar2.getName(), tnVar2.Q0(this, i3), i5, P0 == i7 ? mh.d.Top : mh.d.Bottom);
            }
        }
        Drawable H = tp.H(this, 2130969155);
        up.w(H, up.f(this));
        mhVar.r(934524, vh.g(this, 2131887391, "T"), H, 0, mh.d.Top);
        if (U4() && w1Var == w1.ProfileAddOfType) {
            StringBuilder sb = new StringBuilder();
            sb.append(vh.g(this, i6 == 0 ? 2131891163 : 2131891170, new Object[0]));
            sb.append(" ");
            sb.append(vh.g(this, 2131891257, new Object[0]));
            mhVar.H(sb.toString());
        }
        if (mhVar.y() > 1) {
            mhVar.E(i7, true, true);
        }
        mhVar.F(new mh.f() {
            @Override
            public final void a(mh mhVar2) {
                Main.this.M9(woVar, w1Var, view, i6, mhVar2);
            }
        }).J(TextUtils.TruncateAt.MIDDLE);
    }

    public void Nb(dk dkVar, View view) {
        if (view == null) {
            view = this.J.v(c2.a.Scene.ordinal());
        }
        SceneEdit.b2(this, view, dkVar, new h1(dkVar), false);
    }

    private void Nc(wo woVar, k2 k2Var) {
        if (k2Var != null && j2.X(k2Var.j())) {
            ri.c cVar = ri.c.Event;
            if (!ri.T(cVar, k2Var.j())) {
                oi.t(this, k2Var, cVar, 1, 2);
                return;
            }
        }
        Intent intent = new Intent(this, (Class<?>) EventEdit.class);
        intent.addFlags(67108864);
        if (k2Var != null) {
            intent.putExtra("scntxt", k2Var.U(0).c0());
        }
        kq.f(this, this.S, null, intent, null, woVar, Integer.valueOf(C5()));
        Ic(intent, 4);
    }

    private boolean O5(Runnable runnable) {
        if (com.joaomgcd.taskerm.util.e5.y(this, 121).A()) {
            runnable.run();
            return true;
        }
        Va("reqPermsDialog", true);
        return this.f0.o1(com.joaomgcd.taskerm.util.e5.y(this, 131), runnable);
    }

    public void O6(final int i2) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.f8(i2);
            }
        });
    }

    public boolean O8(View view) {
        return this.f0.f2();
    }

    public void O9(final mh mhVar, final wo woVar, final int i2, final w1 w1Var, final View view, com.joaomgcd.taskerm.dialog.l lVar) {
        try {
            try {
                this.f0.m(new Runnable() {
                    @Override
                    public final void run() {
                        Main.L9(mh.this);
                    }
                });
                int C5 = C5();
                to toVar = this.S;
                tn.f fVar = tn.f.Alpha;
                final ArrayList<tn> K = toVar.K(C5, fVar);
                final ArrayList<tn> K2 = this.S.K(-2, fVar);
                final int Q0 = woVar.Q0(i2);
                int L = tp.L(this);
                final int argb = Color.argb(110, Color.red(L), Color.green(L), Color.blue(L));
                final int b2 = up.b(this);
                final int i3 = 0;
                this.f0.m(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.N9(K, Q0, mhVar, b2, i3, K2, argb, w1Var, i2, woVar, view);
                    }
                });
                com.joaomgcd.taskerm.helper.q qVar = this.f0;
                Objects.requireNonNull(mhVar);
                qVar.m(new Runnable() {
                    @Override
                    public final void run() {
                        mh.this.show();
                    }
                });
            } catch (NullPointerException unused) {
                com.joaomgcd.taskerm.util.z2.K0(getString(2131890722), this);
            } catch (Exception e2) {
                pg.w0.X0(this, e2);
            }
        } finally {
            lVar.c();
        }
    }

    public String[] Oa(List<Object> list) {
        int size = list.size();
        String[] strArr = new String[size];
        for (int i2 = 0; i2 < size; i2++) {
            strArr[i2] = ((dk) list.get(i2)).getName();
        }
        return strArr;
    }

    public void Ob(View view, c2 c2Var, boolean z2, int i2) {
        si siVar = new si(this, c2Var.u() ? c2Var.getName() : null);
        siVar.setOnDismissListener(new t0(siVar, c2Var, view, z2, i2));
        if (i2 != -1) {
            siVar.l(q6(), i2);
        }
        siVar.v(j5(view, z2), z2);
    }

    private void Oc() {
        to toVar = this.Z;
        if (toVar != null) {
            xi s2 = toVar.s2(0, "skk");
            v6 m2 = s2.m();
            if (m2 != null) {
                m2.z();
            }
            if (!U4() || s2.p() != 1) {
                Intent putExtra = new Intent(this, (Class<?>) KidConfig.class).putExtra("d", jr.d(this.Z.U(0).e0(0)));
                com.joaomgcd.taskerm.util.f1.g(putExtra);
                Ic(putExtra, 15);
                return;
            }
            if (m2 == null) {
                m2 = new v6();
                m2.Q();
                m2.I(s2.K().get(0).intValue());
            }
            m2.V();
            H7(m2);
        }
    }

    private void P5(boolean z2) {
        this.x.F(!z2);
        ImageView imageView = this.K;
        if (imageView != null) {
            imageView.setClickable(z2);
        }
        if (z2) {
            Q5();
        } else {
            for (ToggleButton toggleButton : this.C) {
                if (toggleButton != null) {
                    toggleButton.setEnabled(z2);
                }
            }
        }
        EditText editText = this.B;
        if (editText != null) {
            editText.setEnabled(z2);
        }
    }

    public void P6(int[] iArr) {
        for (int i2 : iArr) {
            this.S.c1(i2);
        }
        dq.j0(this, 2131888711, new Object[0]);
        L6(c2.a.Profile);
        v();
    }

    public void P7() {
        if (dq.L2(this, ExecuteService.class.getName())) {
            sendBroadcast(ExecuteService.f5(this));
        }
    }

    public void P8(c2.a aVar) {
        ViewGroup v2 = this.J.v(B5().intValue());
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            this.V = null;
            this.U = null;
            if (this.M.getBoolean("apn", false)) {
                ec(c2.a.Profile, v2, -1, null);
                return;
            } else {
                Jb(v2);
                return;
            }
        }
        if (i2 == 2) {
            this.U = null;
            this.W = 2;
            ec(c2.a.Task, v2, -1, null);
        } else if (i2 == 3) {
            ec(c2.a.Scene, v2, -1, null);
        } else {
            if (i2 != 4) {
                return;
            }
            ec(c2.a.Variable, v2, -1, null);
        }
    }

    public void P9(final View view, final wo woVar, final int i2, final w1 w1Var, final com.joaomgcd.taskerm.dialog.l lVar) {
        final mh mhVar = new mh(this, view);
        this.f0.p(new Runnable() {
            @Override
            public final void run() {
                Main.this.O9(mhVar, woVar, i2, w1Var, view, lVar);
            }
        });
    }

    private void Pa(int i2, String str) {
        int count;
        v1 v1Var = this.Q;
        if (v1Var == null) {
            r7.k("T", "selectEntityTab: " + str + ": no tabs adapter");
            count = 0;
        } else {
            count = v1Var.getCount();
        }
        if (i2 >= count) {
            i2 = 0;
        }
        ViewPager viewPager = this.P;
        if (viewPager != null) {
            if (viewPager.getCurrentItem() != i2) {
                this.P.setCurrentItem(i2);
            }
        } else {
            r7.k("T", "selectEntityTab: " + str + ": no view pager");
        }
    }

    public void Pb(int i2) {
        String[] i3;
        int ordinal;
        mh mhVar = new mh(this, j5(this.J.v(i2), true));
        int i4 = i1.b[this.a0.ordinal()];
        if (i4 == 1) {
            i3 = vh.i(this, RFactory.layout.super_toast);
            ordinal = y6().ordinal();
        } else if (i4 == 2) {
            i3 = tn.t1(this.O);
            ordinal = B6().ordinal();
        } else if (i4 != 3) {
            i3 = null;
            ordinal = -1;
        } else {
            i3 = dk.H1(this.O);
            ordinal = z6().ordinal();
        }
        for (int i5 = 0; i5 < i3.length; i5++) {
            mhVar.s(i5, i3[i5], null);
        }
        mhVar.E(ordinal, true, false);
        mhVar.F(new t()).show();
    }

    public void Q5() {
        ToggleButton toggleButton;
        iq.b[] values = iq.b.values();
        int length = values.length;
        for (int i2 = 0; i2 < length; i2++) {
            iq.b bVar = values[i2];
            boolean z2 = D5() == 0 || bVar != iq.b.Referenced;
            ToggleButton[] toggleButtonArr = this.C;
            if (toggleButtonArr != null && (toggleButton = toggleButtonArr[bVar.ordinal()]) != null) {
                toggleButton.setEnabled(z2);
            }
        }
    }

    public void Q6(String[] strArr) {
        for (String str : strArr) {
            this.S.f1(getPackageManager(), str);
        }
        dq.j0(this, 2131888711, new Object[0]);
        v();
        L6(c2.a.Scene);
    }

    public void Q7() {
        zh zhVar = this.I;
        if (zhVar == null) {
            MyActivity.L(this, "addProjectTab projectTabs null");
            return;
        }
        zhVar.m(this, false);
        zhVar.T();
        this.x.D(C5());
        Ia();
    }

    public Boolean Q9() {
        return Boolean.valueOf(com.joaomgcd.taskerm.util.p.o(this));
    }

    public void Qa(c2.a aVar, String str) {
        Pa(aVar.ordinal(), str);
    }

    public void Qb(View view, final List<Object> list) {
        mh mhVar = new mh(this, j5(view, true));
        final c2.a f2 = ((c2) list.get(0)).f();
        boolean z2 = list.size() == 1;
        boolean z3 = f2 != c2.a.Scene;
        if (z3) {
            mhVar.l(q1.ToLink.ordinal(), 2131888857, 2130969304, mh.d.Top);
        }
        if (f2 == c2.a.Task && z2) {
            mhVar.l(q1.AsApp.ordinal(), 2131888853, 2130969177, mh.d.Bottom);
        }
        int ordinal = q1.DescrToClip.ordinal();
        mh.d dVar = mh.d.Bottom;
        mhVar.l(ordinal, 2131888855, 2130969171, dVar);
        mhVar.l(q1.DescrToEmail.ordinal(), 2131888854, 2130969198, dVar);
        mhVar.l(q1.XmlToEmail.ordinal(), 2131888858, 2130969198, dVar);
        mhVar.l(q1.XmlToClip.ordinal(), 2131888859, 2130969171, dVar);
        mhVar.l(q1.XmlToSD.ordinal(), 2131888860, 2130969264, dVar);
        if (z3) {
            mhVar.l(q1.ToUri.ordinal(), 2131888856, 2130969304, dVar);
        }
        mhVar.F(new mh.f() {
            @Override
            public final void a(mh mhVar2) {
                Main.this.l9(f2, list, mhVar2);
            }
        });
        try {
            mhVar.show();
        } catch (Exception e2) {
            dq.b0(this, "showing export menu", new Object[0]);
            r7.l("T", "error showing export menu", e2);
        }
    }

    private void Qc(wo woVar) {
        q7 q7Var = woVar == null ? null : (q7) woVar.T0(3);
        int C0 = woVar == null ? -1 : woVar.C0();
        Intent intent = new Intent(this, (Class<?>) LocSelect.class);
        intent.addFlags(67108864);
        List<wo> G2 = this.S.G2(null, 3);
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i2 = 0; i2 < G2.size(); i2++) {
            wo woVar2 = G2.get(i2);
            q7 q7Var2 = (q7) woVar2.T0(3);
            if (C0 != woVar2.C0()) {
                String e02 = q7Var2.U(0).e0(0);
                if (e02 == null) {
                    r7.G("T", "failed to pack loc context");
                } else {
                    arrayList.add(e02);
                }
            }
        }
        if (arrayList.size() > 0) {
            intent.putStringArrayListExtra("olcntxt", arrayList);
        }
        if (q7Var != null) {
            intent.putExtra("scntxt", q7Var.U(0).c0());
        }
        Ic(intent, 5);
    }

    public void R4(Menu menu, int i2) {
        if (Settings.A1(this) == 5) {
            if (this.S.c2() > 1 || (q6() != null && q6().getCount() > 1)) {
                net.dinglisch.android.taskerm.a.B(this, i2, menu);
            }
        }
    }

    private void R5(boolean z2) {
        findViewById(2131297324).setVisibility(z2 ? 0 : 4);
    }

    public void R6(wo woVar, int i2) {
        this.S.h1(this, woVar, i2);
        this.S.A4(woVar);
        K6(false, c2.a.Profile);
    }

    public lj.e0 R7(int[] iArr) {
        x7(iArr);
        return lj.e0.a;
    }

    public void R9() {
        if (new GenericActionActivityConfigureNotificationChannel("quick", Boolean.FALSE).run(this).f().b()) {
            com.joaomgcd.taskerm.dialog.a.e1(this, 2131890864, "Great! You won't get any more useless notifications!").f();
        } else {
            com.joaomgcd.taskerm.dialog.a.e1(this, 2131890864, "Unfortunately you didn't disable the useless notifications yet. You'll be spammed with them.\n\nPlease disable them for a better Tasker experience.").f();
        }
        ig.a.a(this);
    }

    private void Ra() {
        for (c2.a aVar : c2.a.values()) {
            if (s6(aVar) != null) {
                ab(s6(aVar));
            }
        }
    }

    public void Rb(final wo woVar, boolean z2) {
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                Main.this.n9(woVar);
            }
        };
        if (z2 || this.f0.m2()) {
            pg.w0.l0(new Runnable() {
                @Override
                public final void run() {
                    Main.this.o9(runnable);
                }
            });
        } else {
            runnable.run();
        }
    }

    public void Rc(String str, String str2, int i2) {
        int i3;
        Intent intent = new Intent(this, (Class<?>) SceneEdit.class);
        intent.putExtra(ProfileManager.EXTRA_PROFILE_NAME, str);
        MyActivity.r(intent, i2);
        if (str2 != null) {
            intent.putExtra("el", str2);
            i3 = 512;
        } else {
            i3 = 0;
        }
        if (xl.R(str)) {
            i3 |= 48;
        }
        if (i3 != 0) {
            intent.putExtra("flags", i3);
        }
        intent.putExtra("projectid", C5());
        Ic(intent, 11);
    }

    private void S4() {
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                Main.this.Q7();
            }
        });
    }

    public static void S5(String str, boolean z2) {
        q0 = z2;
    }

    private boolean S6(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case 35:
                TextBoxDialogFragment.F(this, new j0(), 2131887476, null, 2131886891, 2131886867, -1, 229).E(this);
                return true;
            case 36:
                TextBoxDialogFragment.Y(this, new k0(), 2131887162);
                return true;
            case 37:
                if (to.g5("capabilities.xml") != null) {
                    dq.j0(this, 2131886891, new Object[0]);
                }
                return true;
            case 38:
                if (to.h5(this.O, "datadef.xml", true) != null) {
                    dq.j0(this, 2131886891, new Object[0]);
                }
                return true;
            case 39:
                sd();
                return true;
            case 40:
                if (jh.k(this).exists()) {
                    TextBoxDialogFragment.Y(this, new i0(), 2131887161);
                } else {
                    Lc();
                }
                return true;
            default:
                return false;
        }
    }

    public void S7(Main main, c2.a aVar) {
        com.joaomgcd.taskerm.util.t tVar = new com.joaomgcd.taskerm.util.t(main, 2131890725, new Object[0]);
        if (((we.l0) com.joaomgcd.taskerm.dialog.a.L(main, tVar, new com.joaomgcd.taskerm.util.t(main, 2131888290, com.joaomgcd.taskerm.util.x2.Q4(aVar.d(), main, new Object[0])), tVar, new com.joaomgcd.taskerm.util.t(main, 2131887082, new Object[0]), new com.joaomgcd.taskerm.util.s("importfromtaskernetonnew")).f()).o()) {
            this.f0.l2();
        } else {
            if (this.f0.j2(true).f().booleanValue()) {
                return;
            }
            Fa(aVar);
        }
    }

    public void S9() {
        this.f0.p(new Runnable() {
            @Override
            public final void run() {
                Main.this.R9();
            }
        });
    }

    private void Sa(boolean z2) {
        wl.y0(z2 ? new i() : null);
    }

    private boolean Sb() {
        return this.f0.f1(2131890878, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean p9;
                p9 = Main.this.p9();
                return p9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.q9();
            }
        });
    }

    public void Sc() {
        if (pa()) {
            bc(true, 0, null, new e0());
        } else {
            Ic(new Intent(this, (Class<?>) Search.class), 20);
        }
    }

    private c2.a T5(int i2) {
        return c2.a.values()[i2];
    }

    public void T6() {
        Ea("dscl", true);
        Va("overview", true);
        HTMLView.H0(this, "overview.html", 10, HTMLView.g.InformWithAccept);
    }

    public void T7() {
        invalidateOptionsMenu();
    }

    public void T8(boolean z2, AtomicBoolean atomicBoolean) {
        if (z2 || l6(64)) {
            if (!this.S.u3()) {
                to.w4(to.g.Passive, true);
                if (l6(8)) {
                    return;
                }
                y5(2);
                return;
            }
            if (Na(false)) {
                d5();
            } else {
                atomicBoolean.set(false);
                y5(2);
            }
        }
    }

    public void T9(fq fqVar, si siVar) {
        if (siVar.f() || !siVar.g()) {
            return;
        }
        String name = fqVar.getName();
        String i2 = siVar.i();
        kq.T1(this, name, i2, "showVV");
        this.f0.M1(name, i2);
        L6(c2.a.Variable);
        P7();
    }

    private void Tb(String str, HTMLView.g gVar) {
        Va(str, true);
        HTMLView.H0(this, str, -1, gVar);
    }

    private void Tc() {
        Ic(Settings.D1(this, false, -1), 3);
    }

    private boolean U4() {
        return Settings.j1(this.M);
    }

    public boolean U5() {
        ViewGroup viewGroup = this.E;
        return viewGroup != null && viewGroup.getVisibility() == 0;
    }

    public void U6() {
        int i2 = i1.b[A5().ordinal()];
        if (i2 == 1) {
            if (this.x.n()) {
                p5(Ba(this.x.g()));
                return;
            }
            wo woVar = (wo) this.x.getItem(this.b0);
            if (woVar != null) {
                p5(new int[]{woVar.C0()});
                return;
            }
            return;
        }
        if (i2 != 2) {
            if (i2 != 3) {
                return;
            }
            if (this.x.n()) {
                h5(Oa(this.y.g()));
                return;
            } else {
                h5(new String[]{((dk) this.y.getItem(this.b0)).getName()});
                return;
            }
        }
        if (this.x.n()) {
            t5(hd(this.z.g()));
            return;
        }
        tn tnVar = (tn) this.z.getItem(this.b0);
        if (tnVar != null) {
            t5(new int[]{tnVar.P0()});
            return;
        }
        r7.G("T", "handleDropOnBin: no task at position " + this.b0);
    }

    public void U7() throws Exception {
        Yb(false);
    }

    public void U8(com.joaomgcd.taskerm.dialog.l lVar, Boolean bool) throws Exception {
        lVar.c();
        finish();
    }

    private void Ua(int i2, ListView listView, String str) {
        this.b0 = this.f0.O1(i2, listView.getCount());
        this.v.r0(i2);
    }

    public void Ub(boolean z2, boolean z3, boolean z4, boolean z5) {
        if (z4 || z2 != U5()) {
            if (!z3 || !od()) {
                Xa(z2, z5);
            } else if (!z2) {
                xg.i(this, this.E, 2130772038, 0L, 200L, new x(z5));
            } else {
                this.E.setVisibility(0);
                xg.i(this, this.E, 2130772031, 0L, 200L, new w(z5));
            }
        }
    }

    private void Uc(wo woVar, pn pnVar) {
        if (pnVar != null && on.O(pnVar.j())) {
            ri.c cVar = ri.c.Condition;
            if (!ri.T(cVar, pnVar.j())) {
                oi.t(this, pnVar, cVar, 1, 2);
                return;
            }
        }
        Intent intent = new Intent(this, (Class<?>) StateEdit.class);
        intent.addFlags(67108864);
        if (pnVar != null) {
            intent.putExtra("scntxt", pnVar.U(0).c0());
        }
        kq.f(this, this.S, null, intent, null, woVar, Integer.valueOf(C5()));
        Ic(intent, 6);
    }

    public void V4() {
        if (z7()) {
            return;
        }
        wh whVar = new wh(this, new e1());
        this.d0 = whVar;
        if (whVar.d(MonitorService.class, 32)) {
            return;
        }
        r7.G("T", "failed to bind to " + this.d0.toString());
        this.d0 = null;
    }

    public void V5(final boolean z2, final String str) {
        r7.A("T", "exit/" + str);
        if (!str.equals("leaveHint") && !str.equals("back")) {
            Ga(z2, str);
        } else if (this.f0.Y1()) {
            this.f0.T1();
        } else {
            this.f0.R(cc(z2, str), new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.X7(z2, str, (q.a) obj);
                }
            });
        }
    }

    private boolean V6(ListView listView, float f2, float f3) {
        boolean z2 = true;
        if (M7()) {
            int d02 = am.d0(listView, (int) f2, (int) f3);
            int count = listView.getCount();
            int firstVisiblePosition = d02 == -1 ? count - 1 : listView.getFirstVisiblePosition() + d02;
            if (N7()) {
                firstVisiblePosition = this.f0.O1(firstVisiblePosition, count);
            }
            if (firstVisiblePosition != this.b0) {
                if (y()) {
                    ja(A5(), firstVisiblePosition);
                } else {
                    int i2 = i1.b[A5().ordinal()];
                    if (i2 == 1) {
                        this.S.Q3(((wo) this.x.getItem(this.b0)).C0(), C5(), firstVisiblePosition);
                    } else if (i2 == 2) {
                        tn tnVar = (tn) this.z.getItem(this.b0);
                        if (tnVar == null) {
                            r7.G("T", "handleDropOnList: no task at pos " + this.b0);
                        } else {
                            this.S.V3(tnVar.P0(), C5(), firstVisiblePosition);
                        }
                    } else if (i2 == 3) {
                        this.S.T3(((dk) this.y.getItem(this.b0)).getName(), C5(), firstVisiblePosition);
                    }
                }
            }
            K6(false, A5());
        } else {
            z2 = false;
        }
        v();
        return z2;
    }

    public void V7(final com.joaomgcd.taskerm.dialog.l lVar) {
        to r4 = this.S.r4(this);
        this.S = r4;
        if (!r4.u3() || !this.S.B4(this, this.M, this.O, t0, true, true)) {
            lVar.c();
            return;
        }
        to u12 = to.u1(this);
        this.S = u12;
        to.U4(to.g.Passive, u12);
        t0 = System.currentTimeMillis();
        d5();
        System.gc();
        if (MonitorService.c2(this)) {
            MonitorService.j8(this, true);
            y5(2);
        }
        this.f0.m(new Runnable() {
            @Override
            public final void run() {
                Main.this.T7();
            }
        });
        wm.i(this, false);
        ji.r<Boolean> n2 = Ka().n(new oi.a() {
            @Override
            public final void run() {
                Main.this.U7();
            }
        });
        Objects.requireNonNull(lVar);
        ed(n2.n(new oi.a() {
            @Override
            public final void run() {
                lVar.c();
            }
        }));
    }

    public void V8(String str, final boolean z2, final com.joaomgcd.taskerm.dialog.l lVar) {
        TaskerApp.s("stopLicenceHandler ", new Runnable() {
            @Override
            public final void run() {
                Main.this.Q8();
            }
        });
        TaskerApp.s("stopVariableReceiver ", new Runnable() {
            @Override
            public final void run() {
                Main.this.R8();
            }
        });
        TaskerApp.s("storeUISelections ", new Runnable() {
            @Override
            public final void run() {
                Main.this.S8();
            }
        });
        RunLog.t0(this);
        Search.y0(this);
        final AtomicBoolean atomicBoolean = new AtomicBoolean(true);
        if (this.S.u3()) {
            Ya(2);
        }
        r7.f("T", "EXIT: from " + str + ": save: " + z2 + " dirty: " + this.S.u3() + " must save: " + l6(64) + " prefsDirty: " + l6(8) + " need mrestart: " + l6(2));
        TaskerApp.s("saveData ", new Runnable() {
            @Override
            public final void run() {
                Main.this.T8(z2, atomicBoolean);
            }
        });
        this.f0.i2();
        t0 = -1L;
        if (atomicBoolean.get()) {
            to.w4(to.g.Passive, false);
        }
        System.gc();
        MonitorService.j8(this, l6(2));
        Va("exit", false);
        if (!m6()) {
            sp.o0("Main reallyexit");
        }
        if (isFinishing()) {
            lVar.c();
        } else if (str.equals("leaveHint") || str.equals("back")) {
            fd(Ka(), new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.U8(lVar, (Boolean) obj);
                }
            });
            r7.F("T", "dont finish, requesting permissions");
            return;
        } else {
            lVar.c();
            finish();
        }
        bb(false, "exit");
    }

    public Boolean V9() {
        return Boolean.valueOf(com.joaomgcd.taskerm.util.u5.p(this));
    }

    private void Va(String str, boolean z2) {
        this.c0 = str;
        Za(4, z2);
    }

    private void Vb(c2.a aVar) {
        am amVar = this.v;
        if (amVar == null) {
            MyActivity.L(this, "showHideProjectTabs scrollControl null");
            return;
        }
        boolean pd = pd(this);
        ListView q6 = this.J != null ? q6() : null;
        amVar.v0(this, q6, pd, "showHide");
        if (q6 != null) {
            amVar.t0(q6, pd, aVar == c2.a.Profile);
        }
    }

    public void W4(ListView listView, int i2) {
        vi viVar = this.x;
        if (viVar != null && A5() == c2.a.Profile) {
            for (int i3 = 0; i3 < viVar.getCount(); i3++) {
                wo woVar = (wo) viVar.getItem(i3);
                if (woVar != null && woVar.C0() == i2) {
                    dq.x(listView, i3);
                    return;
                }
            }
        }
    }

    public void W5(int i2) {
        this.f0.U1();
        wo c2 = this.S.c(i2);
        if (c2 != null) {
            c2.K1();
        }
    }

    private boolean W6(float f2, float f3) {
        int la;
        boolean z2;
        int y2 = this.I.y((int) f2, (int) f3);
        if (y2 == -1) {
            return false;
        }
        if (y2 == D5()) {
            return true;
        }
        int C5 = C5();
        int Da = Da(y2);
        int i2 = i1.b[A5().ordinal()];
        if (i2 == 1) {
            if (y()) {
                ka(C5, Da);
            } else {
                int C0 = ((wo) this.x.getItem(this.b0)).C0();
                this.S.u4(C5, C0);
                this.S.w0(C0, Da);
            }
            K6(false, c2.a.Profile);
        } else if (i2 == 2) {
            if (y()) {
                ma(C5, Da);
            } else {
                tn tnVar = (tn) this.z.getItem(this.b0);
                if (tnVar == null) {
                    r7.G("T", "handleDropOnProject: no task at position " + this.b0);
                } else {
                    int P0 = tnVar.P0();
                    this.S.x4(C5, P0);
                    this.S.D0(P0, Da);
                }
            }
            K6(false, c2.a.Profile, c2.a.Task);
        } else if (i2 == 3) {
            if (y()) {
                la = la(C5, Da);
                z2 = false;
            } else {
                String name = ((dk) this.y.getItem(this.b0)).getName();
                if (xl.P(name)) {
                    z2 = true;
                    la = 0;
                } else {
                    this.S.v4(C5, name);
                    this.S.z0(name, Da);
                    z2 = false;
                    la = 1;
                }
            }
            if (la > 0) {
                K6(false, c2.a.Scene);
            }
            if (z2) {
                dq.n0(this, 2131887777, new Object[0]);
            }
        }
        K6(false, c2.a.Variable);
        return true;
    }

    public void W7(Runnable runnable, we.l0 l0Var) throws Exception {
        this.g0 = true;
        if (l0Var.o()) {
            runnable.run();
        } else {
            V5(false, "wrong lock code from shortcut");
        }
    }

    public void W8(final String str, final boolean z2, final com.joaomgcd.taskerm.dialog.l lVar) {
        TaskerApp.s("Main really exit ", new Runnable() {
            @Override
            public final void run() {
                Main.this.V8(str, z2, lVar);
            }
        });
    }

    public void W9() {
        this.f0.Q(new GenericActionSendEmailToSupport("Functionality Not Working", "From Tasker: please let me know how I can get Wifi working again.").run(this));
        com.joaomgcd.taskerm.util.u5.y(this, false);
    }

    private void Wa(boolean z2) {
        if (tp.e0()) {
            nq.b(this.E, z2 ? tp.w(this, 2131166027) / 2 : 0);
        }
    }

    private void Wc(int i2, int i3, String str, int i4) {
        v();
        Intent intent = new Intent(this, this.f0.b2());
        intent.putExtra("son", true);
        intent.putExtra("amt", -1);
        intent.putExtra("tid", i2);
        intent.putExtra(ProfileManager.EXTRA_PROFILE_NAME, str);
        intent.putExtra("projectid", C5());
        MyActivity.r(intent, i4);
        if (i3 != -1) {
            intent.putExtra("actioncode", i3);
        }
        Ic(intent, 12);
    }

    private void X4(String str) {
        if (A5() == c2.a.Scene) {
            for (int i2 = 0; i2 < this.y.getCount(); i2++) {
                if (((dk) this.y.getItem(i2)).getName().equals(str)) {
                    dq.x(q6(), i2);
                    return;
                }
            }
        }
    }

    private boolean X5(to toVar) {
        boolean z2 = true;
        net.dinglisch.android.taskerm.g icon = toVar.s2(0, "eaaa").getIcon();
        toVar.p4();
        if (!hn.d0(this)) {
            TextBoxDialogFragment.F(this, new k(), 2131887499, vh.g(this, 2131887252, vh.g(this, 2131891127, new Object[0]).toLowerCase(), "Tasker App Factory"), 2131886891, 2131886867, -1, 196).E(this);
        } else if (th.y(getPackageManager(), "net.dinglisch.android.appfactory") < 5) {
            dq.a0(this, 2131887921, "Tasker App Factory");
        } else if (toVar.q3(134)) {
            dq.a0(this, 2131887818, net.dinglisch.android.taskerm.a1.v(134));
        } else {
            if (toVar.y2(getPackageManager(), true).size() <= 0) {
                if (!icon.g0() && icon.f0() && vh.q(icon.I(this))) {
                    dq.a0(this, 2131887792, new Object[0]);
                }
                r7.f("T", "eaaa: " + z2);
                return z2;
            }
            dq.a0(this, 2131887794, new Object[0]);
        }
        z2 = false;
        r7.f("T", "eaaa: " + z2);
        return z2;
    }

    public void X6(int i2) {
        if (i2 < 0) {
            MyActivity.L(this, "handleEntityTabLongClick tabNo < 0");
            return;
        }
        this.a0 = T5(i2);
        mh mhVar = new mh(this, j5(this.J.v(i2), true));
        c2.a aVar = this.a0;
        boolean z2 = aVar == c2.a.Variable;
        c2.a aVar2 = c2.a.Scene;
        boolean z3 = aVar == aVar2;
        boolean z4 = aVar == c2.a.Profile;
        c2.a aVar3 = c2.a.Task;
        boolean z5 = aVar == aVar3;
        if (z2) {
            mhVar.k(p1.ClearAll.ordinal(), 2131888786, 2130969299);
            mhVar.k(p1.ToggleTools.ordinal(), 2131891173, qd() ? 2130969261 : 2130969155);
        } else {
            mhVar.k(p1.SetSort.ordinal(), 2131889002, 2130969278);
            int i3 = z4 ? 2131888891 : 2131888890;
            if (z5) {
                i3 = 2131888894;
            }
            if (z3) {
                i3 = 2131888893;
            }
            mhVar.k(p1.Import.ordinal(), i3, 2130969218);
        }
        if (this.a0 == aVar2 && wl.B() > 0) {
            mhVar.k(p1.ClearAll.ordinal(), 2131888815, 2130969284);
        }
        if (this.a0 == aVar3 && dq.L2(this, ExecuteService.class.getName())) {
            mhVar.k(p1.ClearAll.ordinal(), 2131886818, 2130969284);
        }
        mhVar.F(new s(i2)).show();
    }

    public void X7(boolean z2, String str, q.a aVar) throws Exception {
        if (aVar.a()) {
            Ga(z2, str);
        }
    }

    public ji.v X8(we.l0 l0Var) throws Exception {
        if (!l0Var.o()) {
            return ji.r.w(Boolean.FALSE);
        }
        Va("reqPermsDialog", true);
        return La();
    }

    public static void X9(Object obj) throws Exception {
    }

    public void Xa(boolean z2, boolean z3) {
        ViewGroup viewGroup = this.E;
        if (viewGroup == null) {
            MyActivity.L(this, "setEntityToolsVis entityToolsLayout null");
        } else {
            gb(s6(c2.a.Variable), z2);
            viewGroup.setVisibility(z2 ? 0 : 8);
        }
    }

    private boolean Xb() {
        if (com.joaomgcd.taskerm.util.k8.F() || ng.d.g(this)) {
            return false;
        }
        if ((this.S.b2() <= 10 && this.S.e2() <= 15) || this.S.c2() <= 3) {
            return false;
        }
        this.f0.N(ng.d.e(this));
        return true;
    }

    private void Xc(wo woVar, int i2) {
        Yc(woVar, i2, Integer.MIN_VALUE, null);
    }

    public void Y4(int i2) {
        if (A5() == c2.a.Task) {
            for (int i3 = 0; i3 < this.z.getCount(); i3++) {
                if (this.z.getItemId(i3) == i2) {
                    dq.x(q6(), i3);
                    return;
                }
            }
        }
    }

    private void Y5(i5 i5Var, boolean z2) {
        to toVar = this.S;
        if (toVar == null) {
            return;
        }
        this.Y = i5Var;
        com.joaomgcd.taskerm.datashare.export.d.B(this, i5Var, toVar, 32, z2);
    }

    public void Y6(ho hoVar) {
        boolean z2;
        to w6 = w6("handleFinishContextEdit");
        if (w6 == null) {
            return;
        }
        if (this.U == null) {
            this.U = w6.V1(getBaseContext());
            if (!TextUtils.isEmpty(this.V)) {
                this.U.G(this.V);
            }
            z2 = true;
        } else {
            z2 = false;
        }
        this.V = null;
        this.U.Y(hoVar);
        w6.A4(this.U);
        if (z2) {
            if (p6() >= 2) {
                w6.Z0(C5());
            }
            w6.v0(this.U, C5());
            if (p6() >= 5) {
                this.U.t1(true);
            }
        }
        if (hoVar.D0()) {
            w6.c5(hoVar);
        }
        if (hoVar.B0() == 3 && !hoVar.D0()) {
            this.W = 3;
            dc(this.U, hoVar, true);
        } else if (this.U.P0() == 0) {
            Rb(this.U, true);
        }
        L6(c2.a.Profile);
        if (z2) {
            W4(q6(), this.U.C0());
        }
        int B0 = hoVar.B0();
        if (B0 == 4 || B0 == 5 || B0 == 6 || B0 == 7) {
            K6(false, c2.a.Variable);
        }
    }

    public void Y7(List list, q1 q1Var, pe.g gVar) {
        String m2;
        Iterator it = list.iterator();
        StringBuilder sb = null;
        while (it.hasNext()) {
            wo woVar = (wo) it.next();
            if (q1Var == q1.XmlToSD) {
                if (!d6(woVar.getName(), this.S.l2(woVar), wo.A0(this.M), ".prf.xml")) {
                    return;
                }
            } else if (q1Var == q1.ToLink) {
                Y5(woVar, false);
            } else if (q1Var == q1.ToUri) {
                Y5(woVar, true);
            } else {
                if (q1Var == q1.DescrToClip || q1Var == q1.DescrToEmail) {
                    m2 = this.S.m2(woVar, this, true, gVar);
                } else {
                    to l2 = this.S.l2(woVar);
                    m2 = l2 != null ? l2.C1(this, 2) : null;
                }
                if (sb == null) {
                    sb = new StringBuilder();
                } else {
                    sb.append("\n");
                }
                sb.append(m2);
            }
        }
        if (sb != null) {
            j6(sb.toString(), q1Var);
        }
        dq.j0(this, 2131886873, new Object[0]);
    }

    public void Y8() throws Exception {
        Yb(false);
    }

    public ji.b Y9(final String str, final String str2, final String str3) {
        r7.f("T", "Launching app factory");
        final com.joaomgcd.taskerm.dialog.l l2 = com.joaomgcd.taskerm.dialog.l.l(this, 2131887300);
        return pg.w0.Y(new Runnable() {
            @Override
            public final void run() {
                Main.this.r8(str, str2, str3);
            }
        }).o(new oi.a() {
            @Override
            public final void run() {
                l2.c();
            }
        });
    }

    public void Ya(int i2) {
        Za(i2, true);
    }

    private void Yb(final boolean z2) {
        this.f0.r(new Runnable() {
            @Override
            public final void run() {
                Main.this.s9(z2);
            }
        });
    }

    private void Yc(wo woVar, int i2, int i3, String str) {
        Intent intent = new Intent(this, this.f0.b2());
        this.W = i2;
        this.U = woVar;
        intent.putExtra(ProfileManager.EXTRA_PROFILE_NAME, str);
        if (i3 == Integer.MIN_VALUE) {
            i3 = woVar == null ? -1 : woVar.Q0(i2);
        }
        intent.putExtra("son", woVar != null);
        Bundle t2 = com.joaomgcd.taskerm.util.x2.t(this.S, this, woVar, null, "startTaskEditWithTaskIDFromProfile");
        if (woVar != null && woVar.i1(this, t2)) {
            i2 = 0;
        }
        intent.putExtra("amt", i2);
        intent.putExtra("tid", i3);
        intent.putExtra("projectid", C5());
        if (woVar != null) {
            intent.putExtra("profileid", woVar.C0());
        }
        Ic(intent, 27);
    }

    private void Z5(String str, boolean z2) {
        Intent intent = new Intent("android.intent.action.SEND");
        intent.putExtra("android.intent.extra.TEXT", str);
        intent.setType(z2 ? "text/xml" : "text/plain");
        Ic(intent, -1);
    }

    public g5 Z6(c2.a aVar, String str) {
        File file = new File(str);
        g5 g5Var = null;
        if (!file.isFile()) {
            dq.a0(this, 2131887893, new Object[0]);
            return null;
        }
        if (aVar == null) {
            return E7(file);
        }
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            g5Var = D7(file);
        } else if (i2 == 2) {
            g5Var = G7(file);
        } else if (i2 == 3) {
            g5Var = F7(file);
        }
        L6(c2.a.Variable);
        return g5Var;
    }

    public void Z7(xi xiVar) {
        if (d6(xiVar.getName(), this.S.v2(getPackageManager(), xiVar), xi.l(this.M), ".prj.xml")) {
            dq.j0(this, 2131886873, new Object[0]);
        }
    }

    public ji.r Z8() {
        HashMap<String, List<String>> S1 = this.S.S1(this, TaskerAppWidgetConfigure.l(this), false, true);
        HashSet hashSet = new HashSet(S1.keySet());
        hashSet.remove("android.permission.WRITE_SECURE_SETTINGS");
        hashSet.remove("android.permission.ACCESS_SUPERUSER");
        if (com.joaomgcd.taskerm.util.k.w()) {
            hashSet.add("android.permission.POST_NOTIFICATIONS");
        }
        this.w = new com.joaomgcd.taskerm.util.e5(this, 123, hashSet);
        r7.F("T", "needed: " + dq.x3(dq.y3(hashSet)));
        return this.w.B() ? ji.r.w(Boolean.FALSE) : nc(this.w.M(), S1).t(new oi.e() {
            @Override
            public final Object a(Object obj) {
                ji.v X8;
                X8 = Main.this.X8((we.l0) obj);
                return X8;
            }
        }).n(new oi.a() {
            @Override
            public final void run() {
                Main.this.Y8();
            }
        });
    }

    private boolean Z9(String str) {
        try {
            to J2 = to.J2(to.g.Passive, this, false);
            if (J2 != null) {
                this.S = J2;
            } else {
                to h2 = to.h2(this);
                this.S = h2;
                if (h2 == null) {
                    dq.n0(this, 2131891080, new Object[0]);
                } else {
                    r7.f("T", "loadData: p: " + this.S.c2());
                }
            }
        } catch (OutOfMemoryError unused) {
            dq.a0(this, 2131889311, new Object[0]);
            r7.k("T", "loadData: oom");
            System.exit(1);
        }
        if (this.S == null) {
            r7.G("T", str + "failed to load data, creating new");
            this.S = new to();
        } else {
            r7.f("T", "loadData: done: p: " + this.S.c2());
        }
        return false;
    }

    private void Za(int i2, boolean z2) {
        if (z2) {
            this.T = i2 | this.T;
        } else {
            this.T = (~i2) & this.T;
        }
    }

    public void Zb(View view) {
        mh mhVar = new mh(this, view);
        List<String> J1 = this.S.J1(3);
        for (int i2 = 0; i2 < J1.size(); i2++) {
            mhVar.n(i2, J1.get(i2), 2130969180);
        }
        mhVar.I().l(9535435, 2131888924, 2130969155, mh.d.Top).F(new h0(J1)).G(2131887495).show();
    }

    private void Zc() {
        iq iqVar = this.A;
        if (iqVar != null) {
            iqVar.v(true);
        }
    }

    public boolean a5(c2.a aVar, int i2) {
        if (!u()) {
            return false;
        }
        ja(aVar, i2);
        v();
        K6(false, aVar);
        return true;
    }

    public void k9(final List<Object> list, final q1 q1Var, final pe.g gVar) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.Y7(list, q1Var, gVar);
            }
        });
    }

    public boolean a7(c2.a aVar, ListView listView, View view, DragEvent dragEvent) {
        am amVar;
        if (dragEvent == null) {
            r7.G("T", "handleListDrag: null event");
        } else {
            int action = dragEvent.getAction();
            if (action == 1) {
                if (aVar == A5()) {
                    am.x0(this, this.K, false, "main: list started");
                }
                return true;
            }
            if (action != 2) {
                if (action == 3) {
                    return V6(listView, dragEvent.getX(), dragEvent.getY());
                }
                if (action == 4) {
                    x5(listView);
                    v();
                } else if (action == 6 && (amVar = this.v) != null) {
                    amVar.S(listView, dragEvent.getY(), 0);
                }
            } else if (this.v != null && M7() && am.d0(listView, (int) dragEvent.getX(), (int) dragEvent.getY()) != -1) {
                this.v.S(listView, dragEvent.getY(), this.v.w(listView, dragEvent.getY()));
            }
        }
        return false;
    }

    public void a8(File file, we.l0 l0Var) throws Exception {
        if (l0Var.o()) {
            com.joaomgcd.taskerm.util.g8.F0(file, this, true, "Share File To");
        }
    }

    public void a9(List list) {
        dq.b0(this, "Still missing permissions: " + com.joaomgcd.taskerm.util.x2.B3(list), new Object[0]);
    }

    private void aa(String str) {
        if (this.S == null) {
            r7.f("T", str + ": no data");
            return;
        }
        r7.f("T", str + ": pCount: " + this.S.c2());
    }

    public void ab(ListView listView) {
        listView.setHapticFeedbackEnabled(false);
    }

    private void ac(boolean z2, int i2, Object[] objArr) {
        bc(z2, i2, objArr, null);
    }

    private boolean ad(String str) {
        return !isFinishing() && this.R;
    }

    private boolean b5() {
        if (this.S.b2() > 3) {
            return Settings.j1(this.M) ? lp.d(this, 2131890847) : lp.d(this, 2131890965);
        }
        return false;
    }

    private void b6(xi xiVar) {
        to V = hn.V(this, this.S, xiVar, null);
        if (X5(V)) {
            if (!xiVar.W(this)) {
                this.f0.j1(2131887884);
            } else if (V.K(0, tn.f.Alpha).size() == 0) {
                this.f0.j1(2131887831);
            } else {
                i5(V, xiVar);
            }
        }
    }

    private void b7(k7 k7Var, List<Object> list) {
        Object remove = list.remove(0);
        if (remove.getClass() == net.dinglisch.android.taskerm.c.class) {
            y7((tn) list.remove(0), (net.dinglisch.android.taskerm.c) remove, list);
        } else if (remove.getClass() == sk.class || remove.getClass() == gl.class || remove.getClass() == cl.class) {
            t7((dk) list.remove(0), (qk) remove);
        }
    }

    public void b8(List list, q1 q1Var) {
        String B2;
        Iterator it = list.iterator();
        StringBuilder sb = null;
        while (it.hasNext()) {
            dk dkVar = (dk) it.next();
            if (q1Var != q1.XmlToSD) {
                if (q1Var == q1.DescrToClip || q1Var == q1.DescrToEmail) {
                    B2 = this.S.B2(dkVar, this.O);
                } else {
                    to A2 = this.S.A2(dkVar);
                    B2 = A2 != null ? A2.C1(this, 2) : null;
                }
                if (sb == null) {
                    sb = new StringBuilder();
                } else {
                    sb.append("\n");
                }
                sb.append(B2);
            } else if (!d6(dkVar.getName(), this.S.A2(dkVar), dk.i1(), ".scn.xml")) {
                return;
            }
        }
        if (sb != null) {
            j6(sb.toString(), q1Var);
        }
        dq.j0(this, 2131886873, new Object[0]);
    }

    public void b9(final List list) {
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                Main.this.a9(list);
            }
        });
    }

    private void ba(Menu menu) {
        if (MyAccessibilityService.a()) {
            menu.add(0, 57, 0, vh.g(this, 2131886297, new Object[0]));
        }
        menu.add(0, 62, 0, vh.g(this, 2131888748, new Object[0]));
        menu.add(0, 59, 0, vh.g(this, 2131888745, new Object[0]));
        if (sd.i()) {
            menu.add(0, 61, 0, vh.g(this, 2131888747, new Object[0]));
        }
        if (h4.Z() && yd.z.b()) {
            menu.add(0, 55, 0, vh.g(this, 2131888876, new Object[0]));
        }
        if (dq.g() >= 22) {
            menu.add(0, 56, 0, vh.g(this, 2131888746, new Object[0]));
        }
        if (dq.S1()) {
            menu.add(0, 64, 0, vh.g(this, 2131888743, new Object[0]));
            menu.add(0, 58, 0, vh.g(this, 2131890641, new Object[0]));
        }
        menu.add(0, 63, 0, vh.g(this, 2131888750, new Object[0]));
        if (sd.l()) {
            menu.add(0, 60, 0, vh.g(this, 2131888751, new Object[0]));
        }
        if (sd.l()) {
            menu.add(0, 80, 0, vh.g(this, 2131888744, new Object[0]));
        }
        if (com.joaomgcd.taskerm.util.k.t()) {
            menu.add(0, 69, 0, vh.g(this, 2131888752, new Object[0]));
        }
        if (com.joaomgcd.taskerm.util.k.u()) {
            menu.add(0, 73, 0, vh.g(this, 2131888911, new Object[0]));
        }
    }

    private void bb(boolean z2, String str) {
        boolean z3 = u0;
        u0 = z2;
        r7.f("T", "setInstanceFlag: was " + z3 + "now: " + u0);
    }

    private void bc(boolean z2, int i2, Object[] objArr, Runnable runnable) {
        if (v0) {
            return;
        }
        v0 = true;
        sp.t0(this, new q0(z2, i2, objArr, runnable)).E(this);
    }

    public void Q8() {
        Handler handler = this.D;
        if (handler == null || !handler.hasMessages(0)) {
            return;
        }
        this.D.removeMessages(0);
    }

    private boolean c5() {
        if (this.S.u3()) {
            TextBoxDialogFragment.F(this, new j(), 2131887061, vh.g(this, 2131887160, new Object[0]), 2131886795, 2131886867, 2131886812, 260).E(this);
            return false;
        }
        if (!l6(8)) {
            y5(2);
        }
        V5(false, "checkcancel");
        return true;
    }

    private void c6(final xi xiVar) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.Z7(xiVar);
            }
        });
    }

    public void c8(List list, q1 q1Var, pe.g gVar) throws Exception {
        String N2;
        Iterator it = list.iterator();
        StringBuilder sb = null;
        boolean z2 = true;
        while (it.hasNext()) {
            tn tnVar = (tn) it.next();
            if (q1Var == q1.AsApp) {
                f6(tnVar);
            } else if (q1Var == q1.ToLink) {
                Y5(tnVar, false);
            } else if (q1Var == q1.ToUri) {
                Y5(tnVar, true);
            } else if (q1Var != q1.XmlToSD) {
                if (q1Var == q1.DescrToClip || q1Var == q1.DescrToEmail) {
                    N2 = this.S.N2(this, tnVar, this.O, gVar);
                } else {
                    to M2 = to.M2(tnVar);
                    N2 = M2 != null ? M2.C1(this, 2) : null;
                }
                if (sb == null) {
                    sb = new StringBuilder();
                } else {
                    sb.append("\n");
                }
                sb.append(N2);
            } else if (!d6(tnVar.getName(), to.M2(tnVar), tn.L0(), ".tsk.xml")) {
                return;
            }
            z2 = false;
        }
        if (sb != null) {
            j6(sb.toString(), q1Var);
        }
        if (z2) {
            dq.j0(this, 2131886873, new Object[0]);
        }
    }

    public static void c9(List list, Runnable runnable, com.joaomgcd.taskerm.util.s6 s6Var) throws Exception {
        if (s6Var.b() || list.size() <= 0) {
            return;
        }
        runnable.run();
    }

    private void ca(Menu menu) {
        menu.add(0, 66, 0, vh.g(this, 2131891222, new Object[0]));
        menu.add(0, 67, 0, vh.g(this, 2131891258, new Object[0]));
        menu.add(0, 68, 0, vh.g(this, 2131891225, new Object[0]));
        menu.add(0, 72, 0, vh.g(this, 2131891278, new Object[0]));
    }

    private void cb() {
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences == null) {
            MyActivity.L(this, "setInitialProjectTab state null");
            return;
        }
        int i2 = 0;
        int i3 = sharedPreferences.getInt("spt", 0);
        if (i3 >= this.S.c2() || i3 < 0) {
            r7.k("T", "sip: bad project: " + i3 + ", resetting to 0");
        } else {
            i2 = i3;
        }
        this.I.S(i2);
    }

    private ji.r<q.a> cc(boolean z2, String str) {
        return pg.w0.j1(pg.w0.K0(new xj.a() {
            @Override
            public final Object invoke() {
                q.a t9;
                t9 = Main.this.t9();
                return t9;
            }
        }));
    }

    public void R8() {
        iq iqVar = this.A;
        if (iqVar != null) {
            iqVar.v(false);
        }
    }

    private boolean d6(String str, to toVar, File file, String str2) {
        String str3 = dq.H3(str) + str2;
        final File file2 = new File(file, str3);
        if (file2.exists()) {
            file2.delete();
        }
        if (!toVar.j5(this, file, str3, 6)) {
            dq.a0(this, 2131891083, new Object[0]);
            return false;
        }
        if (com.joaomgcd.taskerm.settings.o0.F(this)) {
            this.f0.R(com.joaomgcd.taskerm.dialog.a.r3(this, str3, com.joaomgcd.taskerm.util.x2.Q4(2131888012, this, file2.getAbsolutePath())), new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.a8(file2, (we.l0) obj);
                }
            });
        } else {
            com.joaomgcd.taskerm.util.z2.K0(com.joaomgcd.taskerm.util.x2.Q4(2131888011, this, file2.getAbsolutePath()), this);
        }
        return true;
    }

    private void d7(Intent intent) {
        pn pnVar = new pn(new qi(intent.getBundleExtra("scntxt")));
        int i2 = this.W;
        if (i2 == 5) {
            pnVar.Q0(5);
        } else if (i2 == 6) {
            pnVar.Q0(6);
        }
        Y6(pnVar);
    }

    public void d8(final q1 q1Var, final List list) {
        this.f0.m1(q1Var, new oi.d() {
            @Override
            public final void accept(Object obj) {
                Main.this.c8(list, q1Var, (pe.g) obj);
            }
        });
    }

    public static Boolean d9(com.joaomgcd.taskerm.util.s6 s6Var) throws Exception {
        return Boolean.TRUE;
    }

    private void da(Menu menu) {
        boolean d02 = hn.d0(this);
        boolean z2 = d02 && jh.k(this).exists();
        if (d02) {
            if (z2) {
                menu.add(0, 35, 0, vh.g(this, 2131888783, new Object[0]));
            } else {
                menu.add(0, 40, 0, vh.g(this, 2131888804, new Object[0]));
            }
        }
        if (z2) {
            menu.add(0, 36, 0, vh.g(this, 2131888811, new Object[0]));
        }
        menu.add(0, 37, 0, vh.g(this, 2131889093, new Object[0]));
        menu.add(0, 38, 0, vh.g(this, 2131889094, new Object[0]));
        menu.add(0, 39, 0, vh.g(this, 2131888973, new Object[0]));
    }

    private void dc(wo woVar, ho hoVar, boolean z2) {
        ImageView imageView = this.K;
        if (imageView == null) {
            MyActivity.L(this, "showNewContextNameSelector buttonAdd null");
            return;
        }
        h hVar = new h(imageView, woVar, hoVar);
        if (z2) {
            imageView.postDelayed(hVar, 200L);
        } else {
            hVar.run();
        }
    }

    public void S8() {
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences != null) {
            SharedPreferences.Editor edit = sharedPreferences.edit();
            edit.putInt("spt", D5());
            Integer B5 = B5();
            if (B5 != null) {
                edit.putInt("ent", B5.intValue());
            }
            edit.commit();
        }
    }

    public boolean e5() {
        if (this.U.m1() == 1) {
            p5(new int[]{this.U.C0()});
            return false;
        }
        if (this.M.getBoolean("lPdta", true)) {
            TextBoxDialogFragment.Y(this, new g(), 2131887169);
            return false;
        }
        E5(this.U, this.W);
        return true;
    }

    private void e6(final List<Object> list, final q1 q1Var) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.b8(list, q1Var);
            }
        });
    }

    private void e7(Intent intent) {
        this.S.N4(Da(this.X), ImageSelect.r0(intent));
        Ia();
        invalidateOptionsMenu();
    }

    public void e8(pe.g gVar) throws Exception {
        String L1 = this.S.L1(this, gVar);
        File k12 = dq.k1();
        if (!k12.exists()) {
            dq.a0(this, 2131887719, new Object[0]);
            return;
        }
        File file = new File(k12, "datadescr.txt");
        if (dq.C3(L1, file, false)) {
            dq.j0(this, 2131887923, file);
        } else {
            dq.j0(this, 2131887793, new Object[0]);
        }
    }

    public boolean e9(View view, DragEvent dragEvent) {
        try {
            return p7(view, dragEvent);
        } catch (Exception e2) {
            r7.l("T", "onDrag/project", e2);
            return false;
        }
    }

    private void ea(Menu menu) {
        menu.add(0, 3, 0, vh.g(this, 2131888880, new Object[0]));
        menu.add(0, 25, 0, vh.g(this, 2131888929, new Object[0]));
        ca(menu.addSubMenu(0, 9993, 0, vh.g(this, 2131889048, new Object[0])));
        menu.add(0, 2, 0, vh.g(this, 2131889085, new Object[0]));
        menu.add(0, 29, 0, vh.g(this, 2131888878, new Object[0]));
        menu.add(0, 17, 0, vh.g(this, 2131889057, new Object[0]));
        fa(menu.addSubMenu(0, 9993, 0, vh.g(this, 2131889054, new Object[0])));
    }

    public void eb(c2.a aVar, ListView listView) {
        int i2;
        if (listView != null) {
            int i3 = 0;
            if (aVar == c2.a.Profile) {
                listView.setClipToPadding(false);
                i2 = (tp.w(this, 2131165347) + tp.w(this, 2131165350)) - tp.Y(8);
            } else {
                if (pd(this) && !od()) {
                    i3 = tp.w(this, 2131165274);
                }
                i2 = i3;
            }
            oi.p(listView, i2);
        }
    }

    public void ec(c2.a aVar, View view, int i2, String str) {
        fc(aVar, view, i2, str, 0);
    }

    private <T> void ed(ji.r<T> rVar) {
        fd(rVar, new oi.d() {
            @Override
            public final void accept(Object obj) {
                Main.X9(obj);
            }
        });
    }

    private boolean f5() {
        File file = new File(dq.k1(), "crash.txt");
        boolean z2 = false;
        if (file.exists()) {
            long lastModified = file.lastModified();
            if (r0 != lastModified) {
                String X = dq.X(file);
                if (X != null) {
                    if (X.contains(OutOfMemoryError.class.getSimpleName())) {
                        oi.h(this, 2131887513, 2131887290);
                        r7.c();
                        file.delete();
                        z2 = true;
                    } else {
                        z2 = lp.d(this, 2131890860);
                    }
                }
                r0 = lastModified;
            }
            if (!z2 && System.currentTimeMillis() - lastModified > 3600000) {
                file.delete();
            }
        }
        return z2;
    }

    private void f6(tn tnVar) {
        r7.f("T", "etaa");
        to V = hn.V(this, this.S, null, tnVar);
        if (X5(V)) {
            if (tnVar.G1()) {
                i5(V, tnVar);
            } else {
                this.f0.j1(2131887703);
            }
        }
    }

    private void f7() {
        to w6 = w6("handleOARProfileProperties");
        if (w6 == null) {
            return;
        }
        w6.A4(this.U);
        L6(c2.a.Profile);
    }

    private void fa(Menu menu) {
        menu.add(0, 1, 0, vh.g(this, 2131888735, new Object[0]));
        menu.add(0, 31, 0, vh.g(this, 2131888940, new Object[0]));
        menu.add(0, 18, 0, vh.g(this, 2131888947, new Object[0]));
        menu.add(0, 14, 0, vh.g(this, 2131888817, new Object[0]));
        menu.add(0, 12, 0, vh.g(this, 2131888904, new Object[0]));
    }

    private void fb() {
        for (c2.a aVar : c2.a.values()) {
            eb(aVar, s6(aVar));
        }
    }

    private void fc(final net.dinglisch.android.taskerm.c2.a r14, final android.view.View r15, final int r16, final java.lang.String r17, int r18) {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.Main.fc(net.dinglisch.android.taskerm.c2$a, android.view.View, int, java.lang.String, int):void");
    }

    private <T> void fd(ji.r<T> rVar, oi.d<T> dVar) {
        this.f0.R(rVar, dVar);
    }

    private void g5(wo woVar) {
        if (woVar != null && woVar.Z0(2) && woVar.Z0(1)) {
            Bundle t2 = com.joaomgcd.taskerm.util.x2.t(this.S, this, woVar, null, "checkDayAndTimeTip");
            kp kpVar = (kp) woVar.T0(1);
            if (kpVar.s1() && kpVar.u1() && kpVar.d1(this, t2) > kpVar.o1(this, t2)) {
                lp.e(this, 1, 2131890862, 1);
            }
        }
    }

    private void g6(final List<Object> list, final q1 q1Var) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.d8(q1Var, list);
            }
        });
    }

    private void g7(Intent intent) {
        r7.f("T", "oar: scene edit");
        to w6 = w6("handleOARSceneEdit");
        if (intent == null) {
            r7.k("T", "handleOARSE:no result data");
        } else if (w6 == null) {
            r7.k("T", "handleOARSE:no data");
        } else {
            String stringExtra = intent.getStringExtra("sc");
            xi s2 = w6.s2(C5(), "hoars");
            aa("oar scene edit");
            if (s2 == null) {
                r7.k("T", "handleOARSE:no project with index " + C5());
            } else {
                r7.f("T", "have cur project: true");
                boolean T = s2.T(stringExtra);
                StringBuilder sb = new StringBuilder();
                sb.append("was new scene: ");
                sb.append(!T);
                r7.f("T", sb.toString());
                dk z2 = w6.z2(stringExtra);
                StringBuilder sb2 = new StringBuilder();
                sb2.append("have data scene: ");
                sb2.append(z2 != null);
                r7.f("T", sb2.toString());
                if (z2 == null) {
                    r7.k("T", "handleOARSE:no scene");
                } else {
                    if (wl.N(z2.getName())) {
                        wl.v(this, z2.getName(), true);
                    }
                    r7.f("T", "data scene name: " + z2.getName());
                    w6.z0(z2.getName(), C5());
                    r7.f("T", "reset entity edit data");
                    w6.A4(z2);
                    r7.f("T", "check links");
                    try {
                        for (yj yjVar : z2.h(getPackageManager())) {
                            if (yjVar.f() == yj.b.Task && w6.i(yjVar) && w6.Y4((tn) w6.N1(yjVar))) {
                                w6.D0(yjVar.b(), C5());
                            }
                        }
                    } catch (Exception e2) {
                        r7.H("T", "handleOAR", e2);
                    }
                    aa("handle data changed");
                    K6(false, c2.a.Scene);
                    r7.f("T", "handle data changed done");
                    if (!T) {
                        r7.f("T", "centre on scene");
                        X4(stringExtra);
                    }
                    w6.t4();
                    L6(c2.a.Variable);
                    aa("oar scene edit finished");
                }
            }
        }
        q5(intent);
    }

    public void g8() {
        if (isFinishing()) {
            MyActivity.L(this, "is finishing handleOnActivityReturnCancelled");
        } else {
            H6();
        }
    }

    public void g9() {
        ExtensionsContextKt.m(this, "https://youtu.be/gGa4OfxmlzU");
    }

    private void ga(Menu menu) {
        boolean z2 = to.E1().size() > 0;
        Settings.M3(this);
        SubMenu addSubMenu = menu.addSubMenu(0, 9999, 0, vh.g(this, 2131888955, new Object[0]));
        if (z2) {
            addSubMenu.add(0, 51, 0, vh.g(this, 2131888764, new Object[0]));
        }
        addSubMenu.add(0, 52, 0, vh.g(this, 2131888766, new Object[0]));
        addSubMenu.add(0, 65, 0, vh.g(this, 2131888765, new Object[0]));
    }

    public void gb(ListView listView, boolean z2) {
        oi.s(listView, z2 ? tp.w(this, 2131166028) : 0);
    }

    public void gc(View view, String str) {
        new si(this, null).o(new l1(view)).p(2131887508).r(str).v(view, false);
    }

    private void gd(int i2) {
        if (i2 < 0 || C5() == i2) {
            return;
        }
        q7(Ca(i2));
    }

    public boolean h5(String[] strArr) {
        if (!this.M.getBoolean("lPdta", true)) {
            Q6(strArr);
            return true;
        }
        int i2 = 0;
        for (String str : strArr) {
            i2 += this.S.O1(getPackageManager(), str);
        }
        String t3 = dq.t3(strArr);
        TextBoxDialogFragment.Z(this, new e(strArr), -1, i2 > 0 ? dq.r0(this, 2131887174, t3, Integer.valueOf(i2)) : dq.r0(this, 2131887175, t3));
        return false;
    }

    private boolean h6(String str) {
        if (ch.c(this, str, ch.a.None)) {
            return true;
        }
        dq.a0(this, 2131887707, new Object[0]);
        return false;
    }

    private void h7(Intent intent) {
        int i2 = intent.getExtras().getInt("taskidr");
        to w6 = w6("handleOARTaskEdit");
        if (w6 == null) {
            return;
        }
        if (w6.T(i2)) {
            tn R = w6.R(i2);
            w6.A4(R);
            xi s2 = w6.s2(C5(), "hoart");
            if (s2 == null) {
                r7.k("T", "handleOARTaskEdit: null project, index " + C5() + ", no proj " + w6.c2() + " taskID " + i2);
            } else {
                boolean V = s2.V(i2);
                if (w6.Y4(R)) {
                    w6.D0(i2, C5());
                }
                K6(false, c2.a.Profile, c2.a.Task);
                if (!V) {
                    Y4(i2);
                }
                if (w6.J0(this, w6.R(i2))) {
                    K6(false, c2.a.Scene);
                }
                M6(c2.a.Variable);
            }
        } else {
            r7.G("T", "oar: task edit: task ID " + i2 + " doesn't exist");
        }
        q5(intent);
        r7.f("T", "done");
    }

    public void ha(int[] iArr) {
        for (int length = iArr.length - 1; length >= 0; length--) {
            this.S.Q3(iArr[length], C5(), 0);
        }
    }

    public void hb(c2.a aVar, ListView listView) {
        if (am.J(this)) {
            listView.setOnDragListener(new s0(aVar, listView));
        }
    }

    public void hc() {
        ExtensionsContextKt.m(this, "https://www.youtube.com/watch?v=yWShp_Qz2So&tasker=true");
    }

    public int[] hd(List<Object> list) {
        int size = list.size();
        int[] iArr = new int[size];
        for (int i2 = 0; i2 < size; i2++) {
            iArr[i2] = ((tn) list.get(i2)).P0();
        }
        return iArr;
    }

    private void i5(to toVar, pi piVar) {
        this.Z = toVar;
        this.Y = piVar;
        if (this.N.contains("dsclk")) {
            Oc();
        } else {
            Va("kidDisclaimer", true);
            HTMLView.H0(this, "disclaimer_kid.html", 19, HTMLView.g.Confirm);
        }
    }

    public void i6() {
        J7();
        I7();
        J6(false, true, false, c2.a.values());
    }

    private void i7(Intent intent) {
        int Q0;
        tn R;
        int i2 = intent.getExtras().getInt("taskidr");
        to w6 = w6("handleOARTaskEditFromProfile");
        if (w6 == null) {
            return;
        }
        tn R2 = w6.R(i2);
        if (R2 != null && w6.Y4(R2)) {
            w6.D0(i2, C5());
        }
        w6.A4(R2);
        wo woVar = this.U;
        if (woVar == null) {
            r7.k("T", "taskEditFromProfileResult: profile null, can't connect task to profile");
        } else {
            if (!w6.V(woVar.C0())) {
                r7.G("T", "taskEditFromProfileResult: profile unknown in data");
            }
            int i3 = this.W;
            if (i3 != 0 && i3 != 1) {
                r7.k("T", "bad editingType: " + this.W + ": assuming pre");
                this.W = 0;
            }
            if (this.U.c1(this.W) && (Q0 = this.U.Q0(this.W)) != i2 && (R = w6.R(Q0)) != null && !R.u()) {
                r7.f("T", "delete previous (anonymous) task ID " + Q0);
                w6.g1(Q0);
            }
            this.U.F1(this.W, i2);
            w6.A4(this.U);
            if (this.U.u() || jg.c.r(this, new com.joaomgcd.taskerm.util.t(this, 2131890796, new Object[0]))) {
                lp.e(this, 0, 2131890927, 2);
            } else {
                this.f0.k1(2131890796);
            }
            if (w6.J0(this, w6.R(i2))) {
                K6(false, c2.a.Scene);
            }
        }
        L6(c2.a.Profile, c2.a.Task, c2.a.Variable);
        r7.f("T", "done");
    }

    public void i8(com.joaomgcd.taskerm.util.s6 s6Var) throws Exception {
        if (s6Var instanceof com.joaomgcd.taskerm.util.t6) {
            dq.k0(this, ((com.joaomgcd.taskerm.util.t6) s6Var).c());
        } else {
            dq.j0(this, 2131888715, new Object[0]);
        }
    }

    public void i9() {
        ExtensionsContextKt.m(this, "https://youtu.be/Uy4owfsBQKs");
    }

    public void ia(String[] strArr) {
        for (int length = strArr.length - 1; length >= 0; length--) {
            this.S.T3(strArr[length], C5(), 0);
        }
    }

    public void ib(ListView listView) {
        listView.setOnTouchListener(new j1(listView));
    }

    private boolean ic() {
        return this.f0.g1(2131890910, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean bool;
                bool = Boolean.TRUE;
                return bool;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.hc();
            }
        }, "https://www.youtube.com/watch?v=yWShp_Qz2So&tasker=true", Boolean.TRUE);
    }

    public void id() {
        if (this.M.getString("lcD", "").length() == 0) {
            lp.d(this, 2131890907);
        }
    }

    private View j5(View view, boolean z2) {
        if (view == null) {
            view = z2 ? this.G : this.K;
        }
        return view == null ? z2 ? q6() : this.K : view;
    }

    private boolean j6(String str, q1 q1Var) {
        if (str == null) {
            dq.a0(this, 2131887843, new Object[0]);
            return false;
        }
        if (q1Var != q1.DescrToEmail && q1Var != q1.XmlToEmail) {
            return h6(str);
        }
        Z5(str, q1Var == q1.XmlToEmail);
        return true;
    }

    public void h8(int i2, Intent intent) {
        if (i2 != 4 && i2 != 5 && i2 != 6) {
            if (i2 == 9) {
                if (oi.g(this)) {
                    Mb();
                    return;
                } else {
                    V5(false, "discfalse");
                    return;
                }
            }
            if (i2 == 11) {
                to toVar = this.S;
                if (toVar != null) {
                    toVar.t4();
                    return;
                }
                return;
            }
            if (i2 == 27) {
                wo woVar = this.U;
                if (woVar == null || woVar.P0() != 0) {
                    return;
                }
                TextBoxDialogFragment.a0(this, new l(), vh.g(this, 2131887178, new Object[0]));
                return;
            }
            if (i2 == 32) {
                w5("oarc: kid/create");
                return;
            }
            if (i2 != 15) {
                if (i2 == 16) {
                    dq.j0(this, 2131891134, new Object[0]);
                    w5("oarc: spawn");
                    return;
                } else if (i2 != 18 && i2 != 19) {
                    switch (i2) {
                    }
                }
            }
            r7.f("T", "Spawn create basic key cancelled");
            w5("oarc: create basic key");
            return;
        }
        ImageView imageView = this.K;
        if (imageView != null) {
            imageView.post(new Runnable() {
                @Override
                public final void run() {
                    Main.this.g8();
                }
            });
        }
    }

    public void j8() {
        w5("cert");
    }

    public void j9(int i2) {
        File Q2 = to.Q2(true);
        if (Q2 != null) {
            Ic(FileSelect.u0(this, null, Q2.toString() + File.separator + "backup.xml", FileSelect.e.File, ".xml", false, false), i2);
        }
    }

    private void ja(c2.a aVar, int i2) {
        yg ygVar = (yg) s6(aVar).getAdapter();
        List<Integer> f2 = ygVar.f();
        for (int size = f2.size() - 1; size >= 0; size--) {
            int intValue = f2.get(size).intValue();
            int i3 = i1.b[aVar.ordinal()];
            if (i3 == 1) {
                this.S.Q3(((wo) ygVar.getItem(intValue)).C0(), C5(), i2);
            } else if (i3 == 2) {
                this.S.V3(((tn) ygVar.getItem(intValue)).P0(), C5(), i2);
            } else if (i3 == 3) {
                this.S.T3(((dk) this.y.getItem(intValue)).getName(), C5(), i2);
            }
            if (intValue < i2) {
                i2--;
            }
        }
    }

    public void jb(ListView listView) {
        listView.setMultiChoiceModeListener(new x0(this, this.x, this.K, null, null, listView));
    }

    private boolean jc() {
        return this.f0.f1(2131890848, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean w9;
                w9 = Main.this.w9();
                return w9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Bb();
            }
        });
    }

    private void jd(wo woVar) {
        if (!woVar.h1()) {
            woVar.A1(false);
        } else if (woVar.j0()) {
            dq.a0(this, 2131887573, new Object[0]);
        } else {
            woVar.A1(true);
            woVar.C1(0);
        }
        this.S.A4(woVar);
        invalidateOptionsMenu();
    }

    private boolean k5(ListView listView, int i2, int i3, float f2, float f3, boolean z2, boolean z3) {
        View childAt = listView.getChildAt(i2 - listView.getFirstVisiblePosition());
        Rect rect = new Rect();
        if (childAt == null) {
            return false;
        }
        childAt.getHitRect(rect);
        int width = listView.getWidth();
        int N = z2 ? width - (am.N(this, width) / 2) : (int) f2;
        if (!this.v.y(listView, y(), i2) || !am.X(this, y(), N, width)) {
            return false;
        }
        this.v.E();
        if (z3) {
            return false;
        }
        Mc(listView, i2, "checkInitDrag");
        return true;
    }

    private void k6(c2.a... aVarArr) {
        if (!lp.e(this, 1, 2131890882, 1)) {
            dq.j0(this, 2131886873, new Object[0]);
        }
        L6(aVarArr);
    }

    private void k7(final int i2, final Intent intent) {
        this.f0.V1(new Runnable() {
            @Override
            public final void run() {
                Main.this.h8(i2, intent);
            }
        });
    }

    public void k8(Intent intent) {
        r7.f("T", "Spawn create basic key ok: with file permissions");
        if (jh.c(this, -1, intent, "keystore.auto")) {
            r7.f("T", "Spawn create basic key ok: lanching factory");
            this.f0.Z(Y9("keystore.auto", "bl^!)*(!*{a", "ImACertPass"), new Runnable() {
                @Override
                public final void run() {
                    Main.this.j8();
                }
            });
        } else {
            r7.k("T", "Couldn't create keystore from intent");
            dq.a0(this, 2131887816, new Object[0]);
        }
    }

    public int ka(int i2, int i3) {
        Iterator<Object> it = this.x.g().iterator();
        int i4 = 0;
        while (it.hasNext()) {
            int C0 = ((wo) it.next()).C0();
            this.S.u4(i2, C0);
            this.S.w0(C0, i3);
            i4++;
        }
        return i4;
    }

    private void kb() {
        RelativeLayout relativeLayout = this.F;
        if (relativeLayout == null) {
            MyActivity.L(this, "setProjectTabDragListener projectTabHost null");
        } else {
            relativeLayout.setOnDragListener(new View.OnDragListener() {
                @Override
                public final boolean onDrag(View view, DragEvent dragEvent) {
                    boolean e9;
                    e9 = Main.this.e9(view, dragEvent);
                    return e9;
                }
            });
        }
    }

    private boolean kc() {
        return this.f0.f1(2131890849, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean x9;
                x9 = Main.this.x9();
                return x9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Cb();
            }
        });
    }

    public void kd() {
        Ja();
        if (z7()) {
            r7.f("T", "unbind monitor service");
            this.d0.g();
            this.d0 = null;
        }
    }

    public void l5() {
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences == null) {
            MyActivity.L(this, "checkLicence state null");
            return;
        }
        this.f0.S1();
        if (nd()) {
            if (pa()) {
                ac(true, 0, null);
                return;
            } else {
                v5();
                return;
            }
        }
        int currentTimeMillis = (int) ((System.currentTimeMillis() - sharedPreferences.getLong(g6.n.b, -1L)) / 86400000);
        int i2 = 7 - currentTimeMillis;
        Licence.u0(sharedPreferences);
        if (currentTimeMillis >= 7 && !s0 && T4(to.Q2(true), "backup.xml")) {
            dq.h0(this, 2131888714, new Object[0]);
            s0 = true;
        }
        if (i2 <= 0) {
            Pc(true, true);
        } else if (i2 > 4) {
            Licence.q0(this);
        } else {
            Pc(false, true);
        }
    }

    private boolean l6(int i2) {
        return (i2 & this.T) > 0;
    }

    public void l8(int i2, final Intent intent) {
        switch (i2) {
            case 3:
                n7(Settings.x1());
                break;
            case 4:
                Y6(new k2(new qi(intent.getBundleExtra("scntxt"))));
                break;
            case 5:
                Y6(new q7(new qi(intent.getBundleExtra("scntxt"))));
                break;
            case ClockContract.InstancesColumns.MISSED_STATE:
                d7(intent);
                break;
            case 7:
            case 8:
                break;
            case 9:
                T6();
                break;
            case 10:
                jc();
                break;
            case 11:
                g7(intent);
                break;
            case 12:
                h7(intent);
                break;
            case 13:
                e7(intent);
                break;
            case 14:
                RunLog.h valueOf = RunLog.h.valueOf(intent.getStringExtra(ProfileManager.EXTRA_PROFILE_NAME));
                int intExtra = intent.getIntExtra("ID", Integer.MIN_VALUE);
                int i3 = i1.a[valueOf.ordinal()];
                if (i3 == 1) {
                    D6(intExtra);
                    break;
                } else if (i3 == 2 || i3 == 3) {
                    F6(intExtra);
                    Wc(intExtra, -1, null, 14);
                    break;
                }
                break;
            case 15:
                if (!intent.hasExtra("b")) {
                    r7.k("T", "oar: no config extra from KidConfig");
                    break;
                } else {
                    Bundle bundleExtra = intent.getBundleExtra("b");
                    if (bundleExtra == null) {
                        r7.k("T", "oar: null config data from KidConfig");
                        break;
                    } else {
                        H7(new v6(new qi(bundleExtra)));
                        break;
                    }
                }
            case 16:
                w5("spawn ok");
                break;
            case 17:
                File e2 = jh.e(this);
                if (e2.exists()) {
                    e2.delete();
                }
                jh.a(this);
                break;
            case 18:
                r7.f("T", "Spawn create basic key ok");
                O5(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.k8(intent);
                    }
                });
                break;
            case 19:
                Ea("dsclk", true);
                Oc();
                break;
            case 20:
                u7();
                break;
            case 21:
                Y6(new net.dinglisch.android.taskerm.g1(new qi(intent.getBundleExtra("ssc"))));
                break;
            case 22:
                Y6(new net.dinglisch.android.taskerm.w1(new qi(intent.getBundleExtra("context"))));
                g5(this.U);
                break;
            case 23:
                Y6(new kp(new qi(intent.getBundleExtra("sTsc"))));
                g5(this.U);
                break;
            case 24:
                pg.w0.l0(new n(intent.getExtras().getString("path")));
                break;
            case 25:
                f7();
                break;
            case 26:
            case 31:
            default:
                r7.k("T", "onActivityResult: bad request code: " + i2);
                break;
            case 27:
                i7(intent);
                break;
            case 28:
                File file = new File(intent.getExtras().getString("path"));
                String name = file.getName();
                if (T4(file.getParentFile(), name)) {
                    dq.j0(this, 2131888714, new Object[0]);
                    this.f0.R(GenericActionBackupToGoogleDrive.backupToGoogleDrive(this, name), new oi.d() {
                        @Override
                        public final void accept(Object obj) {
                            Main.this.i8((com.joaomgcd.taskerm.util.s6) obj);
                        }
                    });
                    break;
                }
                break;
            case 29:
                jf.d a2 = jf.a.a(this, new File(intent.getExtras().getString("path")));
                if (!a2.Z()) {
                    dq.n0(this, 2131887797, a2);
                    break;
                } else {
                    TextBoxDialogFragment.Y(this, new m(a2), 2131887312);
                    break;
                }
            case 30:
                h4.D(this, -1, intent);
                dq.j0(this, 2131886891, new Object[0]);
                break;
            case 32:
                if (!intent.hasExtra(com.joaomgcd.taskerm.datashare.export.d.f())) {
                    r7.k("T", "oar: no config extra from ShareDataConfig");
                    break;
                } else {
                    Bundle bundleExtra2 = intent.getBundleExtra(com.joaomgcd.taskerm.datashare.export.d.f());
                    if (bundleExtra2 == null) {
                        r7.k("T", "oar: null config data from ShareDataConfig");
                        break;
                    } else {
                        ue.b e3 = ue.b.e(new qi(bundleExtra2));
                        i5 i5Var = (i5) this.Y;
                        if (i5Var == null) {
                            r7.k("T", "oar: null importable for ShareDataConfig");
                            break;
                        } else {
                            i5Var.D(e3);
                            Ta();
                            w5("initkey");
                            com.joaomgcd.taskerm.datashare.export.d.C(this, this.S, i5Var, e3);
                            break;
                        }
                    }
                }
            case 33:
                this.f0.e2(intent);
                break;
        }
    }

    public void l9(c2.a aVar, final List list, mh mhVar) {
        if (mhVar.v()) {
            if (aVar == c2.a.Profile && hn.d0(this)) {
                lp.d(this, 2131890926);
                return;
            }
            return;
        }
        final q1 q1Var = q1.values()[mhVar.A()];
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            this.f0.m1(q1Var, new oi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.k9(list, q1Var, (pe.g) obj);
                }
            });
        } else if (i2 == 2) {
            g6(list, q1Var);
        } else {
            if (i2 != 3) {
                return;
            }
            e6(list, q1Var);
        }
    }

    public int la(int i2, int i3) {
        Iterator<Object> it = this.y.g().iterator();
        boolean z2 = false;
        int i4 = 0;
        while (it.hasNext()) {
            String name = ((dk) it.next()).getName();
            if (xl.P(name)) {
                z2 = true;
            } else {
                this.S.v4(i2, name);
                this.S.z0(name, i3);
                i4++;
            }
        }
        if (z2) {
            dq.n0(this, 2131887777, new Object[0]);
        }
        return i4;
    }

    public void lb(ListView listView) {
        listView.setMultiChoiceModeListener(new b1(this, this.y, this.K, null, null, listView));
    }

    private boolean lc() {
        return this.f0.f1(2131890850, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean y9;
                y9 = Main.this.y9();
                return y9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Db();
            }
        });
    }

    private void ld() {
        for (c2.a aVar : c2.a.values()) {
            md(aVar);
        }
    }

    public boolean m5(int i2, Object[] objArr) {
        if (!sp.r0(this)) {
            return true;
        }
        ac(false, i2, objArr);
        return false;
    }

    private boolean m6() {
        Intent intent = getIntent();
        if (intent == null) {
            return false;
        }
        return intent.getBooleanExtra(p0, false);
    }

    private void m7(final int i2, final Intent intent) {
        this.f0.V1(new Runnable() {
            @Override
            public final void run() {
                Main.this.l8(i2, intent);
            }
        });
    }

    public void m8(int i2, mh mhVar) {
        if (mhVar.v()) {
            return;
        }
        G5(i2, t1.values()[mhVar.A()] == t1.DeleteContents);
    }

    public void m9(wo woVar) {
        View findViewById;
        View view = this.K;
        View x6 = x6(woVar.C0());
        if (x6 != null && (findViewById = x6.findViewById(2131297575)) != null) {
            view = findViewById;
        }
        Bc(w1.ProfileAddOfType, view, woVar, 0);
    }

    public int ma(int i2, int i3) {
        Iterator<Object> it = this.z.g().iterator();
        int i4 = 0;
        while (it.hasNext()) {
            int P0 = ((tn) it.next()).P0();
            this.S.x4(i2, P0);
            this.S.D0(P0, i3);
            i4++;
        }
        return i4;
    }

    private static void mb(Activity activity) {
        if (tp.e0()) {
            String g2 = vh.g(activity, 2131891211, new Object[0]);
            SpannableString spannableString = new SpannableString(g2);
            spannableString.setSpan(new ForegroundColorSpan(up.e(activity)), 0, g2.length(), 0);
            ActionBar actionBar = activity.getActionBar();
            if (actionBar != null) {
                if (MonitorService.c2(activity)) {
                    spannableString = null;
                }
                actionBar.setSubtitle(spannableString);
            }
        }
    }

    private boolean mc() {
        return this.f0.x2();
    }

    public void md(c2.a aVar) {
        int C5 = C5();
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            vi viVar = this.x;
            if (viVar == null) {
                MyActivity.L(this, "updateEntityData profileAdapter is null");
                return;
            } else {
                viVar.E(C5, y6(), true);
                return;
            }
        }
        if (i2 == 2) {
            vn vnVar = this.z;
            if (vnVar == null) {
                MyActivity.L(this, "updateEntityData taskAdapter is null");
                return;
            } else {
                vnVar.s(this.S, C5, B6());
                return;
            }
        }
        if (i2 == 3) {
            ql qlVar = this.y;
            if (qlVar != null) {
                qlVar.s(this.S, C5, z6());
                return;
            } else {
                r7.G("T", "updateEntityData: no scene adapter");
                MyActivity.L(this, "updateEntityData sceneAdapter is null");
                return;
            }
        }
        if (i2 != 4) {
            return;
        }
        R8();
        iq iqVar = this.A;
        if (iqVar == null) {
            MyActivity.L(this, "updateEntityData variableAdapter is null");
            return;
        }
        iqVar.w(this.S, C5);
        iqVar.x();
        Zc();
    }

    public boolean n5(String str, boolean z2, c2.a aVar) {
        if (str.length() == 0) {
            dq.j0(this, 2131887832, new Object[0]);
        } else if (z2) {
            dq.a0(this, 2131887829, str);
        } else {
            if (aVar == null || aVar != c2.a.Scene) {
                return true;
            }
            if (xl.P(str)) {
                dq.a0(this, 2131887887, str);
            } else {
                if (!str.contains(xi.E())) {
                    return true;
                }
                dq.a0(this, 2131887830, vh.g(this, 2131891237, new Object[0]), xi.E());
            }
        }
        return false;
    }

    private void n7(int i2) {
        if ((i2 & 2) > 0) {
            Ya(2);
        }
        if ((i2 & 32) > 0) {
            Settings.c3(this);
        }
        vn vnVar = this.z;
        if ((i2 & 128) > 0 && vnVar != null) {
            vnVar.notifyDataSetChanged();
            I7();
            fb();
        }
        vi viVar = this.x;
        if ((i2 & 8) > 0 && viVar != null) {
            viVar.notifyDataSetInvalidated();
        }
        if ((i2 & 1) > 0) {
            J6(false, false, false, c2.a.Profile);
        }
        if ((i2 & 512) > 0) {
            if (viVar != null) {
                viVar.notifyDataSetInvalidated();
            }
            if (vnVar != null) {
                vnVar.notifyDataSetInvalidated();
            }
            ql qlVar = this.y;
            if (qlVar != null) {
                qlVar.notifyDataSetInvalidated();
            }
            iq iqVar = this.A;
            if (iqVar != null) {
                iqVar.notifyDataSetInvalidated();
            }
        }
        Ra();
        Ya(8);
    }

    public void n8(int i2, int i3) {
        Wc(i2, i3, null, 31);
    }

    public void n9(final wo woVar) {
        pg.w0.p0(new Runnable() {
            @Override
            public final void run() {
                Main.this.m9(woVar);
            }
        });
    }

    public void na(int[] iArr) {
        for (int length = iArr.length - 1; length >= 0; length--) {
            this.S.V3(iArr[length], C5(), 0);
        }
    }

    public void nb(ListView listView) {
        listView.setMultiChoiceModeListener(new a1(this, this.z, this.K, null, null, listView));
    }

    private ji.r<we.l0> nc(final String[] strArr, final HashMap<String, List<String>> hashMap) {
        return this.f0.z(new xj.a() {
            @Override
            public final Object invoke() {
                ji.r z9;
                z9 = Main.this.z9(hashMap, strArr);
                return z9;
            }
        });
    }

    private boolean nd() {
        if (this.N == null) {
            return false;
        }
        dq.N1();
        return true;
    }

    private boolean o5() {
        String p2 = r7.p();
        if (p2.length() <= 0) {
            return false;
        }
        oi.j(this, 2131888436, p2);
        r7.c();
        r7.f("T", "LOG: " + p2);
        return true;
    }

    public static Intent o6(Context context) {
        Intent intent = new Intent("android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS");
        intent.setData(Uri.parse("package:" + context.getPackageName()));
        return intent;
    }

    private void o7(final int i2) {
        new mh(this, this.I.v(i2)).k(t1.DeleteContents.ordinal(), 2131888812, 2130969299).k(t1.KeepContents.ordinal(), 2131888946, 2130969207).F(new mh.f() {
            @Override
            public final void a(mh mhVar) {
                Main.this.m8(i2, mhVar);
            }
        }).show();
    }

    public void o8(String str, String str2) {
        Rc(str, str2, 31);
    }

    public void o9(Runnable runnable) {
        ji.b.D(200L, TimeUnit.MILLISECONDS).h();
        this.f0.C2();
        runnable.run();
    }

    public boolean oa() {
        return dq.T1() && "OnePlus".equals(Build.BRAND);
    }

    private void ob(boolean z2) {
        if (z2) {
            r1 r1Var = new r1(this);
            this.D = r1Var;
            r1Var.sendEmptyMessageDelayed(0, 750L);
        }
    }

    private void oc(final int i2) {
        if (this.f0.R1(i2, new xj.a() {
            @Override
            public final Object invoke() {
                lj.e0 A9;
                A9 = Main.this.A9(i2);
                return A9;
            }
        })) {
            o7(i2);
        }
    }

    public boolean od() {
        return this.M.getBoolean("anm", false);
    }

    public void p5(int[] r6) {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.Main.p5(int[]):void");
    }

    public int p6() {
        return this.M.getInt("apl", 4);
    }

    private boolean p7(View view, DragEvent dragEvent) {
        if (this.I == null || dragEvent == null) {
            return false;
        }
        int action = dragEvent.getAction();
        if (action == 1) {
            return true;
        }
        if (action == 2) {
            this.I.a0(this.I.y((int) dragEvent.getX(), (int) dragEvent.getY()));
            this.v.F(view);
            return false;
        }
        if (action == 3) {
            return W6(dragEvent.getX(), dragEvent.getY());
        }
        if (action != 6) {
            return false;
        }
        this.I.p();
        return false;
    }

    public void p8() {
        w5("initkeybas");
    }

    public Boolean p9() {
        return Boolean.valueOf(!Settings.Q3(this) && (this.S.b2() > 0 || this.S.e2() > 0));
    }

    private boolean pa() {
        to toVar = this.S;
        if (toVar == null) {
            MyActivity.L(this, "needGateLock data null");
            return false;
        }
        try {
            if (!sp.l0(this)) {
                return false;
            }
            if (!toVar.w(Da(D5())).X() && !sp.q0(this)) {
                return false;
            }
            return this.g0;
        } catch (Throwable th2) {
            r7.l("T", "needGateLock", th2);
            return false;
        }
    }

    public void pb(ListView listView) {
        listView.setMultiChoiceModeListener(new d1(this, this.A, this.K, null, null, listView));
    }

    public void D9(final int i2) {
        new mh(this, this.I.v(i2)).k(q1.AsApp.ordinal(), 2131888853, 2130969177).k(q1.DescrToEmail.ordinal(), 2131888854, 2130969198).k(q1.DescrToClip.ordinal(), 2131888855, 2130969171).k(q1.XmlToSD.ordinal(), 2131888860, 2130969205).l(q1.ToLink.ordinal(), 2131888857, 2130969304, mh.d.Top).l(q1.ToUri.ordinal(), 2131888856, 2130969304, mh.d.Bottom).F(new mh.f() {
            @Override
            public final void a(mh mhVar) {
                Main.this.C9(i2, mhVar);
            }
        }).show();
    }

    public static boolean pd(Context context) {
        return !Settings.j1(dq.R0(context));
    }

    private void q5(Intent intent) {
        int x2 = MyActivity.x(intent);
        if (x2 == 14) {
            yc();
        } else if (x2 == 20) {
            Sc();
        } else if (x2 == 31) {
            V5(true, "reqCode");
        }
    }

    public void q8(Intent intent) {
        if (intent == null) {
            dq.a0(this, 2131887793, new Object[0]);
        } else {
            if (Ic(intent, 16)) {
                return;
            }
            w5("launchFactory");
            dq.a0(this, 2131887839, vh.g(this, 2131886700, new Object[0]));
        }
    }

    public void q9() {
        com.joaomgcd.taskerm.util.k8.k(this);
    }

    private void qa(boolean z2) {
        to toVar = this.S;
        if (toVar == null) {
            MyActivity.L(this, "onCreatePartFour data null");
            return;
        }
        r7.x(dq.g());
        PackageManager packageManager = getPackageManager();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.B8();
            }
        }).h();
        SharedPreferences sharedPreferences = this.M;
        if (sharedPreferences == null) {
            MyActivity.L(this, "onCreatePartFour prefs null");
            return;
        }
        if (U4()) {
            if (toVar.c2() > 1) {
                sharedPreferences.edit().putBoolean("beginnerMode", false).commit();
            }
        } else if (!z2) {
            sharedPreferences.edit().putBoolean("beginnerMode", true).commit();
        }
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.za();
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.C8();
            }
        }).h();
        toVar.k(packageManager);
        toVar.Y0();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.D8();
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.Aa();
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.xa();
            }
        }).h();
        SharedPreferences sharedPreferences2 = this.N;
        if (sharedPreferences2 == null) {
            MyActivity.L(this, "onCreatePartFour state null");
            return;
        }
        final int i2 = sharedPreferences2.getInt("ent", g6.n.a.a.ordinal());
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.E8(i2);
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.F8();
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.y8();
            }
        }).h();
        toVar.O0(packageManager, c2.a.values());
        ld();
        final zh zhVar = this.J;
        final ViewPager viewPager = this.P;
        if (zhVar == null || viewPager == null) {
            MyActivity.L(this, "onCreatePartFour entityTabs or mViewPager null");
            return;
        }
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.z8(zh.this, i2, viewPager);
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.A8();
            }
        }).h();
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.Q5();
            }
        }).h();
    }

    public void qb(boolean z2) {
        this.N.edit().putBoolean("lastVT", z2).commit();
    }

    public void qc(final int i2) {
        this.X = i2;
        final ViewGroup v2 = this.I.v(i2);
        mh mhVar = new mh(this, v2);
        int v6 = v6();
        boolean K7 = K7(i2);
        final int Da = Da(i2);
        final xi s2 = this.S.s2(Da, "spm");
        if (s2 == null) {
            dq.a0(this, 2131887784, new Object[0]);
            return;
        }
        mhVar.k(u1.Add.ordinal(), 2131889432, 2130969155);
        if (!K7) {
            mhVar.k(u1.Delete.ordinal(), 2131886871, 2130969299);
            mhVar.k(u1.Export.ordinal(), 2131888852, 2130969205);
            mhVar.k(u1.Properties.ordinal(), 2131886896, 2130969257);
        }
        mhVar.k(u1.Rename.ordinal(), 2131886899, 2130969235);
        if (s2.X()) {
            mhVar.k(u1.Unlock.ordinal(), 2131889079, 2130969302);
        } else {
            mhVar.k(u1.Lock.ordinal(), 2131888908, 2130969226);
        }
        mhVar.k(u1.Import.ordinal(), 2131888892, 2130969218);
        mhVar.k(u1.SetIcon.ordinal(), 2131889001, 2130969217);
        if (!K7) {
            if (i2 > v6) {
                mhVar.k(u1.ShiftLeft.ordinal(), 2131891190, 2130969253);
            }
            if (i2 < this.I.x() - 1) {
                mhVar.k(u1.ShiftRight.ordinal(), 2131891234, 2130969238);
            }
        }
        if (this.I.x() > 4) {
            mhVar.k(u1.SelectProject.ordinal(), 2131890314, 2130969188);
        }
        mhVar.F(new mh.f() {
            @Override
            public final void a(mh mhVar2) {
                Main.this.G9(v2, i2, Da, s2, mhVar2);
            }
        });
        try {
            mhVar.show();
        } catch (Throwable unused) {
            dq.a0(this, 2131887784, new Object[0]);
        }
    }

    public boolean qd() {
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences != null) {
            return sharedPreferences.getBoolean("lastVT", true);
        }
        MyActivity.L(this, "wantEntityTools state null");
        return false;
    }

    private boolean r5(boolean z2) {
        if (z2) {
            return false;
        }
        Va("disclaimer", true);
        HTMLView.H0(this, "disclaimer.html", 9, HTMLView.g.Confirm);
        return true;
    }

    public void r8(String str, String str2, String str3) {
        final Intent intent;
        jh.b(this);
        hn.e(this);
        r7.f("T", "Checking spawn version");
        if (hn.f(this)) {
            try {
                intent = hn.S(this, this.Z, str, str2, "Cert", str3);
            } catch (NullPointerException e2) {
                r7.l("T", "launchFactory", e2);
                intent = null;
            }
            pg.w0.c0(new Runnable() {
                @Override
                public final void run() {
                    Main.this.q8(intent);
                }
            }).h();
        }
    }

    public void r9(c2.a aVar) {
        File L0;
        String str;
        int i2;
        if (aVar == null) {
            L0 = xi.l(this.M);
            str = ".prj.xml";
            i2 = 2131887523;
        } else if (aVar == c2.a.Scene) {
            L0 = dk.i1();
            str = ".scn.xml";
            i2 = 2131887538;
        } else if (aVar == c2.a.Profile) {
            L0 = wo.A0(this.M);
            str = ".prf.xml";
            i2 = 2131887519;
        } else {
            L0 = tn.L0();
            str = ".tsk.xml";
            i2 = 2131887555;
        }
        String str2 = str;
        if (!L0.isDirectory()) {
            L0.mkdirs();
        }
        Ic(FileSelect.u0(this, vh.g(this, i2, new Object[0]), L0.toString(), FileSelect.e.File, str2, false, false), 24);
    }

    private void ra(Bundle bundle) {
        this.R = true;
        dq.R(this, true);
        this.O = getResources();
        if (bundle == null && !m6()) {
            sp.o0("Main onCreatePartOne icicle null");
        }
        w5.j(this, false);
        bi.b(this, "T");
    }

    public static ActionBar rb(Activity activity, ImageView imageView) {
        ActionBar actionBar = activity.getActionBar();
        if (tp.e0()) {
            mb(activity);
        } else {
            if (imageView != null) {
                imageView.setPadding(0, 0, tp.Y(17), 0);
            }
            actionBar.setDisplayShowTitleEnabled(false);
            actionBar.setDisplayOptions(2);
        }
        return actionBar;
    }

    private void rc(int i2) {
        int Da = Da(i2);
        si siVar = new si(this, this.S.z(Da));
        siVar.o(new w0(Da));
        boolean oa = oa();
        siVar.v(j5(oa ? this.G : this.I.v(i2), oa), false);
    }

    private boolean rd() {
        to toVar;
        return (U4() || (toVar = this.S) == null || !toVar.u3()) ? false : true;
    }

    public boolean s5(wo woVar, int i2) {
        if (woVar.P0() == 1) {
            p5(new int[]{woVar.C0()});
        } else {
            if (!this.M.getBoolean("lPdta", true) || this.S.K2(woVar, i2).u()) {
                R6(woVar, i2);
                return true;
            }
            TextBoxDialogFragment.a0(this, new b(woVar, i2), vh.g(this, 2131887176, vh.g(this, 2131891125, new Object[0])));
        }
        return false;
    }

    private void s7(hk hkVar, List<Object> list) {
        t7((dk) list.remove(0), hkVar);
    }

    public void s9(boolean z2) {
        setProgressBarIndeterminateVisibility(z2);
    }

    private void sa(boolean z2, Bundle bundle) {
        qi g2;
        to.P3();
        if (bundle == null) {
            r7.f("T", "onCreate: no icicle");
            System.gc();
            Z9("fresh");
            if (!z2) {
                this.S.K4();
            }
            r7.f("T", "loaded data, proj " + this.S.c2());
            C7(null);
            r7.f("T", "import and delete, proj " + this.S.c2());
            J7();
            r7.f("T", "done init, proj " + this.S.c2());
            this.S.N0();
            r7.f("T", "check delete disabled");
            Ya(2);
            return;
        }
        r7.f("T", "onCreate: from icicle");
        Z9("icicle");
        Ta();
        this.T = bundle.getInt("ssf", 0);
        if (bundle.containsKey("sspid")) {
            int i2 = bundle.getInt("sspid", -1);
            if (this.S.V(i2)) {
                this.U = this.S.c(i2);
            } else {
                this.U = null;
                if (i2 != -1) {
                    r7.k("T", "null editing profile pid " + i2);
                }
            }
        }
        this.W = bundle.getInt("sset", 0);
        if (bundle.containsKey("eent")) {
            this.a0 = c2.a.valueOf(bundle.getString("eent"));
        }
        this.X = bundle.getInt("etab", 0);
        this.V = bundle.getString("sspn");
        if (bundle.containsKey("ssed")) {
            to toVar = new to();
            this.Z = toVar;
            toVar.l1(this, "onCreate/icicle", "ssed", true);
        }
        if (bundle.containsKey("sseo") && (g2 = qi.g(this, "sseo", true)) != null) {
            if (g2.u().equals(tn.f1())) {
                tn tnVar = new tn(g2);
                if (this.S.T(tnVar.P0())) {
                    this.Y = this.S.R(tnVar.P0());
                } else {
                    this.Y = tnVar;
                }
            } else if (g2.u().equals(xi.q())) {
                xi xiVar = new xi(g2);
                if (this.S.W2(xiVar.getName())) {
                    this.Y = this.S.t2(xiVar.getName());
                } else {
                    this.Y = xiVar;
                }
            } else if (g2.H("Profile")) {
                wo woVar = new wo(this, g2, -1);
                int C0 = woVar.C0();
                if (this.S.V(C0)) {
                    this.Y = this.S.c(C0);
                } else {
                    this.Y = woVar;
                }
            }
        }
        this.c0 = bundle.getString("etag");
    }

    public void sc(View view, final dk dkVar) {
        final si siVar = new si(this, dkVar.getName());
        siVar.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                Main.this.H9(siVar, dkVar);
            }
        });
        siVar.v(j5(view, true), true);
    }

    private void sd() {
        File b2 = ti.b();
        if (b2 == null) {
            dq.a0(this, 2131887719, new Object[0]);
            return;
        }
        String libraryTemplate = c6.getLibraryTemplate();
        File file = new File(b2, c6.EXPORT_FILENAME);
        if (dq.C3(libraryTemplate, file, false)) {
            dq.j0(this, 2131887923, file);
        } else {
            dq.a0(this, 2131887922, file);
        }
    }

    public boolean t5(int[] iArr) {
        if (!this.f0.Q1(iArr) || !this.f0.P1(iArr, false, true, new xj.l() {
            @Override
            public final Object invoke(Object obj) {
                lj.e0 R7;
                R7 = Main.this.R7((int[]) obj);
                return R7;
            }
        })) {
            return false;
        }
        if (!this.M.getBoolean("lPdta", true)) {
            x7(iArr);
            return true;
        }
        int length = iArr.length;
        String[] strArr = new String[length];
        for (int i2 = 0; i2 < length; i2++) {
            strArr[i2] = this.S.l(iArr[i2]);
        }
        TextBoxDialogFragment.a0(this, new d(iArr), vh.g(this, 2131887176, dq.t3(strArr)));
        return false;
    }

    public int t6() {
        Rect rect = new Rect();
        this.K.getHitRect(rect);
        Rect rect2 = new Rect();
        this.F.getHitRect(rect2);
        return (rect2.right - rect.left) + tp.Y(5);
    }

    private void t7(dk dkVar, hk hkVar) {
        Qa(c2.a.Scene, "handleSSR");
        if (dkVar.r() && sp.r0(this)) {
            dq.a0(this, 2131887863, new Object[0]);
        } else if (hkVar == null) {
            Rc(dkVar.getName(), null, 20);
        } else {
            Rc(dkVar.getName(), hkVar.getName(), 20);
        }
    }

    public void t8() {
        MyActivity.t(this);
    }

    public q.a t9() {
        if (!MonitorService.c2(this)) {
            com.joaomgcd.taskerm.dialog.a.d1(this, 2131891085, 2131887344).f();
            return new q.a(true);
        }
        if (!dq.S1()) {
            return new q.a(false);
        }
        if (!yd.i0.d()) {
            r7.G("T", "on MM but no PM functions");
            return new q.a(false);
        }
        if (this.N.contains("USER_DOESNT_WANT_BATTERY_OPTIMIZATION_DIALOGs")) {
            return new q.a(true);
        }
        if (yd.i0.g((PowerManager) oi.d(getApplicationContext(), "power", "T", "showMMWarning"), getPackageName())) {
            return com.joaomgcd.taskerm.settings.q0.j(this) ? new q.a(true, ((we.l0) com.joaomgcd.taskerm.dialog.a.o3(this, 2131886701, 2131887309).f()).o()) : new q.a(false);
        }
        we.l0 l0Var = (we.l0) com.joaomgcd.taskerm.dialog.a.p3(this, 2131887457, 2131887137, 2131886902).f();
        if (l0Var.l()) {
            com.joaomgcd.taskerm.dialog.a.d1(this, 2131890864, 2131890846).f();
            return new q.a(true);
        }
        if (l0Var.n()) {
            this.N.edit().putBoolean("USER_DOESNT_WANT_BATTERY_OPTIMIZATION_DIALOGs", true).commit();
            com.joaomgcd.taskerm.dialog.a.d1(this, 2131890864, 2131890918).f();
            return new q.a(true);
        }
        if (!new GenericActionActivityDisableBatteryOptimizations().run(this).f().b()) {
            com.joaomgcd.taskerm.dialog.a.d1(this, 2131887457, 2131887332).f();
            return new q.a(true);
        }
        r7.G("T", "User tuned off battery optimization, yay!");
        if (!((we.l0) com.joaomgcd.taskerm.dialog.a.e3(new we.k(this, 2131891085, 2131887138, 2131886892, 2131886891)).f()).o()) {
            return new q.a(true);
        }
        ExtensionsContextKt.m(this, "https://tasker.joaoapps.com/userguide/en/faqs/faq-problem.html#00");
        return new q.a(true);
    }

    private boolean ta() {
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences == null) {
            return false;
        }
        long j2 = sharedPreferences.getLong(g6.n.b, -1L);
        long j3 = sharedPreferences.getLong(g6.n.a, -1L);
        long currentTimeMillis = System.currentTimeMillis();
        if (j2 > currentTimeMillis || j2 == -1) {
            sharedPreferences.edit().putLong(g6.n.b, currentTimeMillis).commit();
            j2 = currentTimeMillis;
        }
        if (j3 != -1 && j2 > j3) {
            r7.G("T", "validated date < install date, remove");
            sharedPreferences.edit().remove(g6.n.a).commit();
        }
        String string = sharedPreferences.getString("lvn", "none");
        r7.f("T", "v: 6.5.11 date " + currentTimeMillis + " lv: " + string + " date: " + sharedPreferences.getLong("lvd", currentTimeMillis));
        boolean contains = sharedPreferences.contains("dscl");
        if (!string.equals("6.5.11")) {
            r7.f("T", "versionchange, " + string + " -> 6.5.11");
            sharedPreferences.edit().putString("lvn", "6.5.11").putLong("lvd", currentTimeMillis).commit();
            Settings.p1(this.M, sharedPreferences);
            r7.j();
            kq.D(this, "%QTIME");
        }
        return contains;
    }

    public boolean tb() {
        MonitorService u6 = u6("smsel");
        if (u6 == null) {
            r7.G("T", "setupMonitorServiceEventListener: no service");
        } else {
            f1 f1Var = new f1();
            this.e0 = f1Var;
            u6.S1(f1Var);
        }
        return this.e0 != null;
    }

    public void tc(View view, final tn tnVar) {
        final si siVar = new si(this, tnVar.u() ? tnVar.getName() : null);
        siVar.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                Main.this.I9(siVar, tnVar);
            }
        });
        siVar.v(j5(view, true), true);
    }

    public MonitorService u6(String str) {
        wh whVar = this.d0;
        if (whVar != null) {
            return (MonitorService) whVar.e();
        }
        r7.k("T", "getMonitorService: " + str + ": connection is null");
        return null;
    }

    private void u7() {
        cm C0 = Search.C0();
        if (C0 == null) {
            return;
        }
        List<Object> e2 = C0.e();
        if (e2.size() > 0) {
            gd(Ca(e2.get(0).getClass() == xi.class ? this.S.k4(((xi) e2.remove(0)).getName()) : 0));
            if (e2.size() > 0) {
                Collections.reverse(e2);
                Object remove = e2.remove(0);
                Class<?> cls = remove.getClass();
                Class<? super Object> superclass = cls.getSuperclass();
                if (cls == wo.class) {
                    D6(((wo) remove).C0());
                    return;
                }
                if (cls == k7.class) {
                    b7((k7) remove, e2);
                    return;
                }
                if (cls == dk.class) {
                    t7((dk) remove, null);
                    return;
                }
                if (superclass == hk.class || superclass == jl.class) {
                    s7((hk) remove, e2);
                    return;
                }
                if (cls == tn.class) {
                    y7((tn) remove, null, e2);
                    return;
                }
                if (cls == net.dinglisch.android.taskerm.c.class) {
                    G6((net.dinglisch.android.taskerm.c) remove, e2);
                    return;
                }
                if (superclass == ho.class) {
                    I6((ho) remove, e2);
                    return;
                }
                if (cls == kr.class || superclass == kr.class || cls == net.dinglisch.android.taskerm.s1.class) {
                    Object remove2 = e2.remove(0);
                    Class<?> cls2 = remove2.getClass();
                    Class<? super Object> superclass2 = cls2.getSuperclass();
                    if (cls2 == net.dinglisch.android.taskerm.c.class) {
                        G6((net.dinglisch.android.taskerm.c) remove2, e2);
                        return;
                    }
                    if (cls2 == k2.class) {
                        I6((ho) remove2, e2);
                        return;
                    }
                    if (cls2 == pn.class) {
                        I6((ho) remove2, e2);
                    } else if (superclass2 == hk.class || superclass2 == jl.class) {
                        s7((hk) remove2, e2);
                    }
                }
            }
        }
    }

    public void u8() {
        if (com.joaomgcd.taskerm.settings.q0.v(this)) {
            MonitorService.j8(this, false);
        }
    }

    public void u9(c2.a aVar, View view, int i2, String str, si siVar) {
        wo woVar;
        wo woVar2;
        if (siVar.f()) {
            if (aVar == c2.a.Task && (woVar2 = this.U) != null && woVar2.P0() == 0) {
                TextBoxDialogFragment.a0(this, new u0(aVar, view, i2, str), vh.g(this, 2131887178, new Object[0]));
                return;
            }
            return;
        }
        if (siVar.g()) {
            String i3 = siVar.i();
            int i4 = i1.b[aVar.ordinal()];
            if (i4 == 1) {
                this.V = i3;
                Jb(view);
                return;
            }
            if (i4 != 2) {
                if (i4 != 3) {
                    if (i4 != 4) {
                        return;
                    }
                    if (!kq.c1(i3)) {
                        dq.a0(this, 2131887692, i3);
                    } else if (kq.W0(i3)) {
                        dq.j0(this, 2131887847, vh.g(this, 2131891164, new Object[0]));
                    } else {
                        if (!kq.S0(i3)) {
                            kq.T1(this, i3, "", "newvar");
                            L6(aVar);
                            return;
                        }
                        dq.a0(this, 2131890306, new Object[0]);
                    }
                } else if (n5(i3, this.S.p(i3), c2.a.Scene)) {
                    Rc(i3, null, -1);
                    return;
                }
            } else if (TextUtils.isEmpty(i3) && (woVar = this.U) != null) {
                Yc(woVar, this.W, -1, null);
                return;
            } else if (n5(i3, this.S.N3(i3), c2.a.Task)) {
                wo woVar3 = this.U;
                if (woVar3 == null) {
                    Wc(-1, -1, i3, -1);
                    return;
                } else {
                    Yc(woVar3, this.W, -1, i3);
                    return;
                }
            }
            ec(aVar, view, i2, i3);
        }
    }

    private void ub() {
        vi viVar = new vi(this, this.S, C5(), y6());
        this.x = viVar;
        viVar.C(this, this, this, this);
    }

    public void uc() {
        TextBoxDialogFragment.Y(this, new o0(), 2131887312);
    }

    private void v5() {
    }

    private int v6() {
        return 1;
    }

    private boolean v7() {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.Main.v7():boolean");
    }

    public void v8() {
        R5(false);
    }

    private void vb() {
        this.y = new ql(this);
    }

    private void vc() {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.uc();
            }
        });
    }

    public void w5(String str) {
        this.Z = null;
        this.Y = null;
        r7.f("T", "Clearing app export data: " + str);
        v();
    }

    public Boolean w9() {
        return Boolean.valueOf(this.S.b2() == 0);
    }

    public void wa() {
        if (dq.N3(this)) {
            this.F.performHapticFeedback(0, 2);
        }
    }

    private void wb() {
        this.z = new vn(this);
    }

    public void wc() {
        int i2;
        Long[] i3 = dq.i3(to.E1().keySet(), true);
        String[] strArr = new String[i3.length];
        String[] strArr2 = new String[i3.length];
        int i4 = 0;
        for (Long l2 : i3) {
            long longValue = l2.longValue();
            strArr[i4] = bh.l(this, bh.t(longValue)).replace(" ", ", ");
            long currentTimeMillis = System.currentTimeMillis() - longValue;
            long j2 = 86400000;
            if (currentTimeMillis > 86400000) {
                i2 = 2131889547;
            } else {
                j2 = 3600000;
                if (currentTimeMillis > 3600000) {
                    i2 = 2131889659;
                } else {
                    j2 = 60000;
                    if (currentTimeMillis > 60000) {
                        i2 = 2131889783;
                    } else {
                        j2 = 1000;
                        i2 = 2131889922;
                    }
                }
            }
            strArr2[i4] = String.valueOf(currentTimeMillis / j2) + " " + vh.g(this, 2131886189, vh.g(this, i2, new Object[0]));
            i4++;
        }
        wj.D(this, new p0(), 2131887462).I(strArr).S(strArr2).C(this);
    }

    public void x5(ListView listView) {
        if (this.b0 >= 0) {
            this.I.p();
            this.v.A();
            this.v.D();
        }
        this.v.W();
        Ua(-2, listView, "clearDrag");
        this.v.C();
        this.v.L("clearDrag");
    }

    public View x6(int i2) {
        ListView q6 = q6();
        if (q6 == null) {
            return null;
        }
        int x2 = this.x.x(i2) - q6.getFirstVisiblePosition();
        if (x2 >= 0 && x2 < q6.getChildCount()) {
            return q6.getChildAt(x2);
        }
        r7.f("T", "bad relpos: " + x2);
        return null;
    }

    public void x8(Bundle bundle) {
        this.f0.I();
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences == null) {
            MyActivity.L(this, "onAfterBackgroundInit state null");
            return;
        }
        r7.A("T", "onCreate start");
        pg.w0.c0(new Runnable() {
            @Override
            public final void run() {
                Main.this.t8();
            }
        }).h();
        ra(bundle);
        final boolean ta = ta();
        int t2 = th.t(this);
        final boolean F = th.F(this);
        sa(ta, bundle);
        qa(ta);
        this.f0.V1(new Runnable() {
            @Override
            public final void run() {
                Main.this.u8();
            }
        });
        if (bundle == null && !v7()) {
            if (pa()) {
                pg.w0.c0(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.v8();
                    }
                }).h();
            } else if (!this.c0.equals("disclaimer")) {
                pg.w0.c0(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.w8(ta, F);
                    }
                }).h();
            }
            try {
                pg.w0.c0(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.V4();
                    }
                }).h();
            } catch (Exception e2) {
                r7.l("T", "onCreate:bindMonitor", e2);
            }
        }
        sharedPreferences.edit().putInt("lvc", t2).commit();
        this.f0.W1();
        r7.A("T", "onCreate end");
    }

    public java.lang.Boolean x9() {
        throw new UnsupportedOperationException("Method not decompiled: net.dinglisch.android.taskerm.Main.x9():java.lang.Boolean");
    }

    private void xb() {
        this.A = new iq(this);
    }

    private void xc() {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.wc();
            }
        });
    }

    private void y5(int i2) {
        Za(i2, false);
    }

    public wo.b y6() {
        if (this.S == null) {
            return wo.b.values()[g6.i.b.b];
        }
        int C5 = C5();
        xi s2 = this.S.s2(C5, "gprofs");
        if (s2 != null) {
            return s2.x();
        }
        r7.G("T", "getProfileSort: no project for index " + C5);
        return wo.b.values()[g6.i.b.b];
    }

    private void y7(tn tnVar, net.dinglisch.android.taskerm.c cVar, List<Object> list) {
        int P0 = tnVar.P0();
        F6(P0);
        if (tnVar.r() && sp.r0(this)) {
            dq.a0(this, 2131887863, new Object[0]);
        } else {
            Wc(P0, cVar == null ? -1 : tnVar.R0(cVar), null, 20);
        }
    }

    public void y8() {
        Sa(true);
    }

    public Boolean y9() {
        return Boolean.valueOf(this.S.a2() == 0);
    }

    private void ya() {
        ViewGroup viewGroup = (ViewGroup) findViewById(2131296876);
        if (viewGroup == null) {
            MyActivity.L(this, "populateEntityTools entityToolsLayout null");
            return;
        }
        this.E = viewGroup;
        if (tp.e0()) {
            viewGroup.setBackgroundColor(tp.C(this, R.attr.panelBackground, "T/tools"));
            Wa(true);
        } else {
            viewGroup.setBackgroundColor(tp.B(this));
        }
        int i2 = 0;
        while (true) {
            int[] iArr = k0;
            if (i2 >= iArr.length) {
                EditText editText = (EditText) findViewById(2131297650);
                this.B = editText;
                editText.setHint(vh.g(this, 2131888231, new Object[0]));
                this.B.addTextChangedListener(new y());
                return;
            }
            this.C[i2] = (ToggleButton) findViewById(iArr[i2]);
            String g2 = vh.g(this, j0[i2], new Object[0]);
            this.C[i2].setTextOn(g2);
            this.C[i2].setTextOff(g2);
            this.C[i2].setChecked(this.M.getBoolean(h0[i2], i0[i2]));
            this.C[i2].setOnClickListener(this);
            i2++;
        }
    }

    private boolean yb() {
        return this.f0.g1(2131888076, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean bool;
                bool = Boolean.TRUE;
                return bool;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.g9();
            }
        }, "https://youtu.be/gGa4OfxmlzU", Boolean.TRUE);
    }

    private void yc() {
        Ic(new Intent(this, (Class<?>) RunLog.class), 14);
    }

    private void z5() {
        this.S = null;
        this.U = null;
        this.V = null;
        this.Y = null;
        this.Z = null;
        am amVar = this.v;
        if (amVar != null) {
            amVar.i0();
            this.v = null;
        }
        this.D = null;
        ViewGroup viewGroup = this.E;
        if (viewGroup != null) {
            viewGroup.removeAllViews();
            this.E = null;
        }
        this.F = null;
        this.H = null;
        zh zhVar = this.I;
        if (zhVar != null) {
            zhVar.M();
            this.I = null;
        }
        this.K = null;
        this.B = null;
        this.C = null;
        this.M = null;
        this.N = null;
        this.O = null;
        v1 v1Var = this.Q;
        if (v1Var != null) {
            v1Var.d(true);
            this.Q.c();
        }
        this.P = null;
        this.Q = null;
        vi viVar = this.x;
        if (viVar != null) {
            viVar.k();
            this.x = null;
        }
        ql qlVar = this.y;
        if (qlVar != null) {
            qlVar.k();
            this.y = null;
        }
        vn vnVar = this.z;
        if (vnVar != null) {
            vnVar.k();
            this.z = null;
        }
        iq iqVar = this.A;
        if (iqVar != null) {
            iqVar.k();
            this.A = null;
        }
        this.f0.J();
    }

    public dk.i z6() {
        dk.i iVar = dk.i.User;
        to toVar = this.S;
        if (toVar == null) {
            return iVar;
        }
        xi s2 = toVar.s2(C5(), "gss");
        if (s2 != null) {
            return s2.H();
        }
        r7.f("T", "gss: no project index " + C5());
        return iVar;
    }

    private boolean z7() {
        return this.d0 != null;
    }

    public static void z8(zh zhVar, int i2, ViewPager viewPager) {
        zhVar.S(i2);
        viewPager.setCurrentItem(i2);
    }

    public ji.r z9(HashMap hashMap, String[] strArr) {
        if (this.w == null) {
            return ji.r.w(new we.l0());
        }
        StringBuilder sb = new StringBuilder();
        sb.append("<P>");
        for (String str : com.joaomgcd.taskerm.util.e5.D()) {
            hashMap.remove(str);
        }
        HashMap hashMap2 = new HashMap();
        PackageManager packageManager = getPackageManager();
        for (String str2 : strArr) {
            String f2 = sd.f(this, packageManager, str2);
            List list = (List) hashMap.get(str2);
            if (list != null) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    dq.n(hashMap2, f2, (String) it.next());
                }
            }
        }
        if (hashMap2.size() == 0) {
            return ji.r.w(new we.l0(0));
        }
        for (String str3 : hashMap2.keySet()) {
            sb.append("<B>");
            sb.append(str3);
            sb.append("</B><BR>");
            Iterator it2 = ((HashSet) hashMap2.get(str3)).iterator();
            while (it2.hasNext()) {
                String str4 = (String) it2.next();
                sb.append(" * ");
                sb.append(str4);
                sb.append("<BR>");
            }
        }
        return com.joaomgcd.taskerm.dialog.a.e3(new we.k(this, 2131887500, vh.g(this, 2131887253, ExtensionsContextKt.Z(this), sb.toString()), 2131886891, 2131886867, -1, false, 4));
    }

    public void za() {
        RelativeLayout relativeLayout = (RelativeLayout) findViewById(2131297282);
        if (relativeLayout == null) {
            MyActivity.L(this, "populateProjectTabs projectTabHost null");
            return;
        }
        this.F = relativeLayout;
        this.H = findViewById(2131297281);
        kb();
        this.I = new zh(this, relativeLayout, zh.k.Filled, zh.i.No, 0, tp.x(this), 0, true, tp.Y(60), -1);
        if (tp.k(this) == tp.a.Tangerine) {
            this.I.P(2130968984);
        }
        this.I.V(new r());
        this.I.U(12);
        I7();
    }

    private boolean zb() {
        return this.f0.g1(2131888077, new xj.a() {
            @Override
            public final Object invoke() {
                Boolean bool;
                bool = Boolean.TRUE;
                return bool;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.i9();
            }
        }, "https://youtu.be/Uy4owfsBQKs", Boolean.TRUE);
    }

    public boolean w8(boolean z2, boolean z3) {
        if (this.M == null) {
            MyActivity.L(this, "showStartupDialogs prefs null");
            return true;
        }
        boolean r5 = r5(z2);
        if (!r5) {
            r5 = Hc();
        }
        if (!r5) {
            r5 = this.f0.f1(2131887139, new xj.a() {
                @Override
                public final Object invoke() {
                    Boolean bool;
                    bool = Boolean.TRUE;
                    return bool;
                }
            }, new Runnable() {
                @Override
                public final void run() {
                    Main.this.K9();
                }
            });
        }
        if (!r5) {
            r5 = yb();
        }
        if (!r5) {
            r5 = kc();
        }
        if (!r5) {
            r5 = Xb();
        }
        if (!r5) {
            r5 = mc();
        }
        if (!r5) {
            r5 = jc();
        }
        if (!r5) {
            r5 = Dc();
        }
        if (!r5) {
            r5 = ic();
        }
        if (!r5) {
            r5 = lc();
        }
        if (!r5) {
            r5 = zb();
        }
        if (!z3 && !r5 && !r5) {
            int[] iArr = {7, 6, 5};
            int[] iArr2 = {2131887150, 2131887149, 2131887148};
            int i2 = 0;
            while (true) {
                if (i2 >= 3) {
                    break;
                }
                if (dq.g() >= iArr[i2]) {
                    lp.g(this, iArr2[i2]);
                    lp.c(this, iArr2[i2]);
                    break;
                }
                i2++;
            }
        }
        if (!r5) {
            r5 = f5();
        }
        if (!r5) {
            r5 = o5();
        }
        if (!r5) {
            r5 = lp.e(this, 0, 2131890859, 2);
        }
        if (!r5) {
            r5 = lp.e(this, 0, 2131890898, 2);
        }
        if (!r5) {
            r5 = lp.e(this, 0, 2131890955, 5);
        }
        if (!r5) {
            r5 = lp.e(this, 0, 2131890839, 15);
        }
        if (!r5) {
            r5 = b5();
        }
        return !r5 ? Sb() : r5;
    }

    public v1 A6() {
        return this.Q;
    }

    public int C5() {
        return Da(D5());
    }

    public to C6(String str, to toVar) {
        if (toVar == null) {
            toVar = this.S;
        }
        if (toVar != null) {
            this.S = toVar;
            return toVar;
        }
        MyActivity.L(this, str + " data null");
        return null;
    }

    public int D5() {
        zh zhVar = this.I;
        if (zhVar != null) {
            return zhVar.r();
        }
        r7.k("T", "curTab: tabs null");
        return 0;
    }

    public void D6(int i2) {
        E6(i2, false);
    }

    public void E6(int i2, boolean z2) {
        gd(this.S.E(i2));
        Qa(c2.a.Profile, "gotoProfile");
        ListView q6 = q6();
        if (q6 != null) {
            q6.post(new p(q6, i2, z2));
        }
    }

    public void F6(int i2) {
        to toVar = this.S;
        if (toVar == null) {
            MyActivity.L(this, "gotoTask data null");
            return;
        }
        tn R = toVar.R(i2);
        if (R == null) {
            MyActivity.L(this, "gotoTask macroByID null");
            return;
        }
        if (!R.u()) {
            List<Integer> d02 = toVar.d0(i2);
            if (d02.size() > 0) {
                D6(d02.get(0).intValue());
                return;
            }
            return;
        }
        gd(toVar.H(i2));
        Qa(c2.a.Task, "gotoTask");
        ListView q6 = q6();
        if (q6 != null) {
            q6.post(new o(i2));
        }
    }

    public void I7() {
        this.I.N();
        for (int i2 = 0; i2 < this.S.c2(); i2++) {
            this.I.m(this, false);
        }
        Ia();
    }

    public boolean Ic(Intent intent, int i2) {
        db();
        if (!ad("subactivity " + i2)) {
            return false;
        }
        try {
            startActivityForResult(intent, i2);
            Va("startActivityResult", true);
            return true;
        } catch (ActivityNotFoundException unused) {
            dq.a0(this, 2131887839, intent.getAction());
            return false;
        } catch (Throwable th2) {
            dq.a0(this, 2131891164, th2.getMessage());
            return false;
        }
    }

    public void J5() {
        final com.joaomgcd.taskerm.dialog.l l2 = com.joaomgcd.taskerm.dialog.l.l(this, 2131887123);
        Yb(true);
        this.f0.l(new Runnable() {
            @Override
            public final void run() {
                Main.this.V7(l2);
            }
        });
    }

    public void K6(boolean z2, c2.a... aVarArr) {
        J6(true, z2, false, aVarArr);
    }

    public void Kc(wo woVar, int i2, boolean z2) {
        Za(32, z2);
        this.U = woVar;
        switch (i2) {
            case 0:
                Ic(AppSelect.G0(this, false, false, true, true, false, true, null, woVar != null ? (net.dinglisch.android.taskerm.g1) woVar.T0(0) : null), 21);
                break;
            case 1:
                Cc(woVar);
                break;
            case 2:
                Kb();
                break;
            case 3:
                Qc(woVar);
                break;
            case 4:
            case 5:
            case ClockContract.InstancesColumns.MISSED_STATE:
                Uc(woVar, woVar != null ? (pn) woVar.T0(i2) : null);
                break;
            case 7:
                Nc(woVar, woVar != null ? (k2) woVar.T0(i2) : null);
                break;
            default:
                Jb(null);
                break;
        }
    }

    @Override
    protected com.joaomgcd.taskerm.util.c<Bundle> N() {
        return new com.joaomgcd.taskerm.util.c() {
            @Override
            public final void a(Object obj) {
                Main.this.x8((Bundle) obj);
            }
        };
    }

    public boolean N7() {
        return A5() == c2.a.Task && B6() == tn.f.UserReverse;
    }

    public boolean Na(boolean z2) {
        aa("saveData: pre");
        to r4 = this.S.r4(this);
        this.S = r4;
        boolean z3 = true;
        if (!r4.B4(this, this.M, this.O, t0, z2, true)) {
            T4(to.H1(true), "emergencybackup.xml");
            z3 = false;
        }
        aa("saveData: ok: " + z3);
        return z3;
    }

    @Override
    protected void O() {
        super.O();
    }

    public void O7(int i2) {
        int x2 = this.x.x(i2);
        if ((x2 == -1 || x2 >= q6().getFirstVisiblePosition()) && x2 <= q6().getLastVisiblePosition()) {
            return;
        }
        q6().setSelectionFromTop(x2, 10);
    }

    public void Pc(boolean z2, boolean z3) {
        Intent intent = new Intent(this, (Class<?>) Licence.class);
        if (z3) {
            intent.putExtra("net.dinglisch.android.taskerm.EXTRA_AUTO_VALIDATE", true);
        }
        Ic(intent, z2 ? 8 : 7);
    }

    @Override
    protected boolean T() {
        return false;
    }

    public boolean T4(File file, String str) {
        boolean z2;
        if (file != null) {
            try {
            } catch (OutOfMemoryError unused) {
                z2 = false;
                dq.a0(this, 2131889311, new Object[0]);
                return z2;
            }
            if (this.S.k5(this, file, str, 52, com.joaomgcd.taskerm.settings.q0.f(this))) {
                z2 = true;
                try {
                    File k12 = dq.k1();
                    if (k12 != null) {
                        sn.c(k12, "usertabs.xml");
                    }
                    if (z2 && !jh.a(this)) {
                        dq.a0(this, 2131887815, new Object[0]);
                        return false;
                    }
                } catch (OutOfMemoryError unused2) {
                    dq.a0(this, 2131889311, new Object[0]);
                    return z2;
                }
                return z2;
            }
        }
        dq.n0(this, 2131891082, new Object[0]);
        z2 = false;
        if (z2) {
            dq.a0(this, 2131887815, new Object[0]);
            return false;
        }
        return z2;
    }

    public void Ta() {
        to toVar = this.S;
        if (toVar == null) {
            MyActivity.L(this, "setDataDirtyWrapper data null");
        } else {
            toVar.K4();
            invalidateOptionsMenu();
        }
    }

    @Override
    public boolean U(ActionMode actionMode) {
        P5(actionMode == null);
        return super.U(actionMode);
    }

    public void Vc(int i2) {
        Wc(i2, -1, null, -1);
    }

    void Wb(final c2.a aVar) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.r9(aVar);
            }
        });
    }

    public void Z4(int i2) {
        RelativeLayout relativeLayout = this.F;
        if (relativeLayout != null) {
            relativeLayout.post(new c0(i2));
        }
    }

    @Override
    public void a(View view, int i2, int i3, boolean z2) {
        if (!y() || z2) {
            if (z2) {
                wa();
            }
            wo woVar = (wo) this.x.getItem(i2);
            this.U = woVar;
            if (woVar == null) {
                r7.k("T", "unknown profile clicked, position " + i2 + " type " + i3);
                return;
            }
            tn K2 = this.S.K2(woVar, i3);
            if (((K2 == null || !K2.r()) && !this.U.r()) || m5(7, new Object[]{view, Integer.valueOf(i2), Integer.valueOf(i3), Boolean.valueOf(z2)})) {
                this.W = i3;
                if (i3 == 1 || i3 == 0) {
                    if (!z2) {
                        Xc(this.U, i3);
                        return;
                    } else {
                        v();
                        Ac(view, this.U, i3, i2);
                        return;
                    }
                }
                r7.k("T", "unknown task type " + this.W + " clicked, position " + i2);
            }
        }
    }

    @Override
    public boolean b(ListView listView, int i2, int i3, float f2, float f3, boolean z2, boolean z3) {
        boolean z4 = true;
        if (i3 == 2) {
            if (z3) {
                return false;
            }
            View childAt = listView.getChildAt(i2 - listView.getFirstVisiblePosition());
            if (childAt != null) {
                int y2 = ((int) childAt.getY()) + ((int) f3);
                if (this.v.g0(y2, "onProfileTouch")) {
                    z4 = k5(listView, i2, i3, f2, y2, z2, z3);
                }
            }
            return z4;
        }
        if (i3 == 1 || i3 == 3) {
            this.v.L("up/cancel");
            return false;
        }
        if (i3 != 0) {
            return false;
        }
        this.v.k0(i2);
        if (z3) {
            this.v.l0((int) f2, (int) f3);
            return k5(listView, i2, i3, f2, f3, z2, z3);
        }
        View childAt2 = listView.getChildAt(i2 - listView.getFirstVisiblePosition());
        if (childAt2 == null) {
            return false;
        }
        int y3 = ((int) childAt2.getY()) + ((int) f3);
        this.v.k0(i2);
        this.v.l0((int) f2, y3);
        if (!yg.j(listView, i2) || !am.I(this)) {
            return false;
        }
        this.v.E();
        return false;
    }

    @Override
    public void c(View view, int i2, int i3, boolean z2) {
        if (!y() || z2) {
            wo woVar = (wo) this.x.getItem(i2);
            this.U = woVar;
            if (z2) {
                wa();
            }
            if (!woVar.r() || m5(3, new Object[]{view, Integer.valueOf(i2), Integer.valueOf(i3), Boolean.valueOf(z2)})) {
                this.W = i3;
                if (!z2) {
                    Kc(woVar, i3, false);
                } else {
                    v();
                    Ib(woVar, i3, view, i2);
                }
            }
        }
    }

    public void c7(boolean z2, int i2, Object[] objArr) {
        Ia();
        if (z2) {
            R5(true);
            if (!this.c0.equals("disclaimer")) {
                w8(this.N.contains("dscl"), false);
            }
            v5();
            return;
        }
        switch (i2) {
            case 0:
                dq.j0(this, 2131887915, new Object[0]);
                break;
            case 1:
                Tc();
                break;
            case 2:
                Gb();
                break;
            case 3:
                try {
                    c((View) objArr[0], ((Integer) objArr[1]).intValue(), ((Integer) objArr[2]).intValue(), ((Boolean) objArr[3]).booleanValue());
                    break;
                } catch (Throwable th2) {
                    r7.l("T", "LOCK_CONTEXT_CLICK", th2);
                    return;
                }
            case 4:
                L5();
                if (lp.d(this, 2131890962)) {
                    invalidateOptionsMenu();
                    break;
                }
                break;
            case 5:
                d(q6(), ((Integer) objArr[0]).intValue(), ((Integer) objArr[1]).intValue());
                break;
            case ClockContract.InstancesColumns.MISSED_STATE:
            case 13:
            case 14:
            case 16:
            default:
                r7.k("T", "unknown lock action " + i2);
                break;
            case 7:
                a((View) objArr[0], ((Integer) objArr[1]).intValue(), ((Integer) objArr[2]).intValue(), ((Boolean) objArr[3]).booleanValue());
                break;
            case 8:
                r7(((Integer) objArr[0]).intValue());
                break;
            case 9:
                w7(((Integer) objArr[0]).intValue());
                break;
            case 10:
                q7(((Integer) objArr[0]).intValue());
                break;
            case 11:
                qc(((Integer) objArr[0]).intValue());
                break;
            case 12:
                I5();
                break;
            case 15:
                break;
            case 17:
                xc();
                break;
            case 18:
                Ab(29);
                break;
        }
    }

    @Override
    public void d(ListView listView, int i2, int i3) {
        wo woVar = (wo) this.x.getItem(i3);
        this.U = woVar;
        if (woVar == null) {
            r7.k("T", "onProfileCommand: no editingProfile");
            return;
        }
        boolean r2 = woVar.r();
        r7.f("T", "onProfileCommand: position: " + i3 + " command: " + i2 + " collapsed: " + this.U.f1() + " locked/Imp: " + r2);
        if (!r2 || m5(5, new Object[]{Integer.valueOf(i2), Integer.valueOf(i3)})) {
            if (i2 == 2) {
                ua(listView, i3, false);
                return;
            }
            if (i2 == 3) {
                ua(listView, i3, true);
            } else if (i2 == 0) {
                jd(this.U);
                z();
            }
        }
    }

    public void d5() {
        Iterator<dk> it = this.S.a(-2, dk.i.User, true).iterator();
        while (it.hasNext()) {
            wl.h(this, it.next());
        }
    }

    public void db() {
        Ya(128);
    }

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

    public to n6(String str) {
        return C6(str, to.u1(this));
    }

    @Override
    protected void onActivityResult(int i2, int i3, Intent intent) {
        this.R = true;
        Va("onActivityResult", false);
        if (i2 == 26) {
            return;
        }
        if (i3 == -1) {
            m7(i2, intent);
            return;
        }
        if (i3 != 1) {
            if (i3 == 0) {
                k7(i2, intent);
                return;
            } else {
                if (i3 == 2) {
                    V5(false, "licence");
                    return;
                }
                return;
            }
        }
        if (i2 == 16 || i2 == 17 || i2 == 18) {
            if (intent == null || !intent.hasExtra("errMsg")) {
                dq.a0(this, 2131887793, new Object[0]);
                return;
            }
            dq.b0(this, "factory: " + intent.getStringExtra("errMsg"), new Object[0]);
        }
    }

    @Override
    public void onBackPressed() {
        V5(true, "back");
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        int[] iArr = k0;
        if (id == iArr[0]) {
            this.M.edit().putBoolean(h0[0], this.C[0].isChecked()).commit();
            K6(false, c2.a.Variable);
        } else if (id == iArr[1]) {
            this.M.edit().putBoolean(h0[1], this.C[1].isChecked()).commit();
            K6(false, c2.a.Variable);
        } else if (id == iArr[2]) {
            this.M.edit().putBoolean(h0[2], this.C[2].isChecked()).commit();
            K6(false, c2.a.Variable);
        }
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        if (dq.g() < 16) {
            S5("configChange", false);
        }
        super.onConfigurationChanged(configuration);
        if (dq.g() < 16) {
            new v().sendEmptyMessageDelayed(0, 300L);
        }
        r7.f("T", "config change done");
    }

    @Override
    public void onCreate(Bundle bundle) {
        this.f0.A2();
        bb(true, "onCreate");
        S5("oncreate", false);
        this.N = dq.S0(this);
        this.M = dq.R0(this);
        super.onCreate(bundle);
    }

    @EventBusRxSubscription
    @Keep
    public void onDataImported(ue.a aVar) {
        i5 a2 = aVar.a();
        this.S = to.u1(this);
        if (a2 instanceof xi) {
            if (aVar.b()) {
                S4();
            }
            L6(c2.a.values());
        } else if (a2 instanceof wo) {
            L6(c2.a.Profile, c2.a.Task);
        } else if (a2 instanceof tn) {
            L6(c2.a.Task);
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        kd();
        Sa(false);
        R8();
        z5();
        bb(false, "onDestroy");
        System.gc();
    }

    @Override
    public boolean onKeyDown(int i2, KeyEvent keyEvent) {
        boolean g2 = this.f0.g2(i2, keyEvent);
        return !g2 ? super.onKeyDown(i2, keyEvent) : g2;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId != 0) {
            if (itemId == 1) {
                Tb("about.html", HTMLView.g.Inform);
            } else if (itemId == 2) {
                Tb("index.html", HTMLView.g.Inform);
            } else if (itemId == 3) {
                Tb("activity_main.html", HTMLView.g.Inform);
            } else if (itemId != 4) {
                if (itemId != 7) {
                    if (itemId != 21) {
                        if (itemId == 76) {
                            ExtensionsContextKt.j(this);
                        } else if (itemId == 10000) {
                            this.f0.Q(com.joaomgcd.taskerm.util.k8.i(this));
                        } else if (itemId == 16908332) {
                            V5(true, "apply");
                        } else if (itemId == 25) {
                            Tb("overview.html", HTMLView.g.Inform);
                        } else if (itemId == 26) {
                            yc();
                        } else if (itemId == 46) {
                            O6(itemId);
                        } else if (itemId != 47) {
                            if (itemId == 79) {
                                this.f0.a2();
                            } else if (itemId != 80) {
                                switch (itemId) {
                                    case 11:
                                        Jc("wikiProfile", new Intent("android.intent.action.VIEW", Uri.parse("https://tasker.joaoapps.com/profiles")));
                                        break;
                                    case 12:
                                        Tb("licences.html", HTMLView.g.Inform);
                                        break;
                                    case 13:
                                        Pc(false, false);
                                        break;
                                    case 14:
                                        pg.w0.l0(new Runnable() {
                                            @Override
                                            public final void run() {
                                                Main.this.J8();
                                            }
                                        });
                                        break;
                                    case 15:
                                    case 16:
                                        break;
                                    case 17:
                                        Tb("support.html", HTMLView.g.Inform);
                                        break;
                                    case 18:
                                        Jc("releaseNotes", new Intent("android.intent.action.VIEW", Uri.parse("https://tasker.joaoapps.com/changes.html")));
                                        break;
                                    default:
                                        switch (itemId) {
                                            case 29:
                                                Jc("guides", new Intent("android.intent.action.VIEW", Uri.parse("https://tasker.joaoapps.com/guides.html")));
                                                break;
                                            case 30:
                                                Sc();
                                                break;
                                            case 31:
                                                Jc("ppolicy", new Intent("android.intent.action.VIEW", Uri.parse("https://tasker.joaoapps.com/privacy.html")));
                                                break;
                                            case 32:
                                                c5();
                                                break;
                                            default:
                                                switch (itemId) {
                                                    case 42:
                                                    case 43:
                                                        if (u5() && !tp.e0()) {
                                                            oi.h(this, 2131890864, 2131890962);
                                                            break;
                                                        }
                                                        break;
                                                    case 44:
                                                        J5();
                                                        break;
                                                    default:
                                                        switch (itemId) {
                                                            case 50:
                                                                if (m5(16, null)) {
                                                                    vc();
                                                                    break;
                                                                }
                                                                break;
                                                            case 51:
                                                                if (m5(17, null)) {
                                                                    xc();
                                                                    break;
                                                                }
                                                                break;
                                                            case 52:
                                                                if (m5(18, null)) {
                                                                    Ab(29);
                                                                    break;
                                                                }
                                                                break;
                                                            case 53:
                                                                dq.j0(this, 2131888956, new Object[0]);
                                                                break;
                                                            default:
                                                                switch (itemId) {
                                                                    case 55:
                                                                        Ic(h4.w(true), 30);
                                                                        break;
                                                                    case 56:
                                                                        Ic(ji.j(), 26);
                                                                        break;
                                                                    case 57:
                                                                        Ic(MyAccessibilityService.f(), 26);
                                                                        break;
                                                                    case 58:
                                                                        if (!yd.i0.g((PowerManager) oi.d(getApplicationContext(), "power", "T", "androidpowermanagementmenu"), getPackageName())) {
                                                                            Ic(o6(this), 26);
                                                                            break;
                                                                        } else {
                                                                            this.f0.Q(com.joaomgcd.taskerm.dialog.a.e3(new we.k(this, 2131887454, 2131887136)));
                                                                            break;
                                                                        }
                                                                    case 59:
                                                                        TextBoxDialogFragment.Z(this, new a(), 2131888745, vh.g(this, 2131887179, new Object[0]));
                                                                        break;
                                                                    case 60:
                                                                        Ic(sd.h(this), 26);
                                                                        break;
                                                                    case 61:
                                                                        Ic(sd.d(this), 26);
                                                                        break;
                                                                    case 62:
                                                                        Ic(sd.g(this), 26);
                                                                        break;
                                                                    case 63:
                                                                        Ic(Settings.G1(this), 26);
                                                                        break;
                                                                    case 64:
                                                                        Ic(ji.k(), 26);
                                                                        break;
                                                                    case 65:
                                                                        if (m5(19, null)) {
                                                                            this.f0.R(GenericActionBackupToGoogleDrive.restoreFromGoogleDrive(this), new oi.d() {
                                                                                @Override
                                                                                public final void accept(Object obj) {
                                                                                    Main.this.G8((com.joaomgcd.taskerm.util.x6) obj);
                                                                                }
                                                                            });
                                                                            break;
                                                                        }
                                                                        break;
                                                                    case 66:
                                                                        Bb();
                                                                        break;
                                                                    case 67:
                                                                        Db();
                                                                        break;
                                                                    case 68:
                                                                        Cb();
                                                                        break;
                                                                    case 69:
                                                                        this.f0.R(new GenericActionActivityRequestCallScreeningAccess().run(this), new oi.d() {
                                                                            @Override
                                                                            public final void accept(Object obj) {
                                                                                Main.this.K8((com.joaomgcd.taskerm.util.s6) obj);
                                                                            }
                                                                        });
                                                                        break;
                                                                    case 70:
                                                                        this.f0.l2();
                                                                        break;
                                                                    case 71:
                                                                        this.f0.u2();
                                                                        break;
                                                                    case 72:
                                                                        Eb();
                                                                        break;
                                                                    case 73:
                                                                        this.f0.Q(new GenericActionActivityRequestManageExternalStorageAccess().run(this));
                                                                        break;
                                                                    default:
                                                                        boolean S6 = S6(menuItem);
                                                                        return !S6 ? vc.c.a(this, menuItem) : S6;
                                                                }
                                                        }
                                                }
                                        }
                                }
                            } else {
                                Ic(sd.c(), 26);
                            }
                        }
                    } else if (m5(12, null)) {
                        I5();
                    }
                }
                if (lp.g(this, 2131887134)) {
                    O6(itemId);
                } else {
                    TextBoxDialogFragment.Y(this, new m1(itemId), 2131887134);
                }
            } else {
                Tc();
            }
        } else if (m5(2, null)) {
            Gb();
        }
        return true;
    }

    @Override
    protected void onPause() {
        r7.f("T", "onpause");
        this.R = false;
        Q8();
        S8();
        r7.f("T", "onpausedone");
        r7.f("T", "Activity pausing. Launching activity: " + L7());
        if (!L7() && !m6()) {
            sp.o0("Main onPause");
        }
        super.onPause();
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        menu.add(0, 70, 0, 2131890725);
        menu.add(0, 71, 0, 2131890987);
        if (MonitorService.c2(this)) {
            menu.add(0, 42, 0, vh.g(this, 2131888826, new Object[0]));
        } else {
            menu.add(0, 43, 0, vh.g(this, 2131888844, new Object[0]));
        }
        if (!l6(64)) {
            net.dinglisch.android.taskerm.a.c(this, 32, 0, 2131886795, menu);
        }
        menu.add(0, 4, 0, vh.g(this, 2131889004, new Object[0]));
        SubMenu addSubMenu = menu.addSubMenu(0, 9995, 0, vh.g(this, 2131889053, new Object[0]));
        SubMenu addSubMenu2 = menu.addSubMenu(0, 9999, 0, vh.g(this, 2131889050, new Object[0]));
        addSubMenu2.add(0, 0, 0, vh.g(this, 2131888788, new Object[0]));
        addSubMenu2.add(0, 7, 0, vh.g(this, 2131888762, new Object[0]));
        ga(addSubMenu2);
        addSubMenu2.add(0, 46, 0, vh.g(this, 2131891243, new Object[0]));
        addSubMenu2.addSubMenu(0, 9999, 0, vh.g(this, 2131889560, new Object[0])).add(0, 47, 0, vh.g(this, 2131886645, new Object[0]));
        ea(menu.addSubMenu(0, 9998, 0, vh.g(this, 2131889052, new Object[0])));
        SubMenu addSubMenu3 = menu.addSubMenu(0, 9997, 0, vh.g(this, 2131889054, new Object[0]));
        addSubMenu3.addSubMenu(0, 9996, 0, vh.g(this, 2131889049, new Object[0])).add(0, 11, 0, vh.g(this, 2131888775, new Object[0]));
        ba(addSubMenu3.addSubMenu(0, 9997, 0, vh.g(this, 2131888749, new Object[0])));
        addSubMenu3.add(0, 21, 0, vh.g(this, 2131888971, new Object[0]));
        SharedPreferences sharedPreferences = this.M;
        if (sharedPreferences == null || !Settings.j1(sharedPreferences)) {
            da(addSubMenu3.addSubMenu(0, 9997, 0, vh.g(this, 2131889051, new Object[0])));
        }
        if (rd()) {
            net.dinglisch.android.taskerm.a.z(this, 44, menu, 2131886862, 2130969153, 1);
        }
        net.dinglisch.android.taskerm.a.z(this, 30, menu, 2131887544, 2130969268, 1);
        menu.add(0, 10000, 0, 2131888803);
        vc.c.b(menu, addSubMenu3, addSubMenu);
        addSubMenu.add(0, 26, 0, vh.g(this, 2131889087, new Object[0]));
        return true;
    }

    @Override
    public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
        Va("reqPermsDialog", false);
        this.f0.A0(i2, strArr, iArr);
        com.joaomgcd.taskerm.util.e5 e5Var = this.w;
        if (e5Var == null) {
            return;
        }
        for (com.joaomgcd.taskerm.util.l4 l4Var : e5Var.m0(i2, strArr, iArr)) {
            r7.F("T", "orpResult: perm: " + l4Var.c() + " res: " + l4Var.b());
        }
        finish();
    }

    @Override
    public void onResume() {
        this.R = true;
        try {
            super.onResume();
        } catch (Exception e2) {
            r7.l("T", "Couldn't 1234resume.", e2);
            finish();
        }
        this.f0.h2();
        File A0 = wo.A0(this.M);
        if (A0 != null && A0.exists() && !dq.r(A0.list()) && this.N.contains("dscl") && this.c0.equals("wikiProfile")) {
            lp.d(this, 2131890883);
        }
        Zc();
        if (t0 == -1) {
            t0 = System.currentTimeMillis();
        }
        S5("onResume", true);
        mb(this);
        r7.f("T", "onresume done");
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putInt("ssf", this.T);
        wo woVar = this.U;
        if (woVar != null) {
            bundle.putInt("sspid", woVar.C0());
        }
        String str = this.V;
        if (str != null) {
            bundle.putString("sspn", str);
        }
        bundle.putInt("sset", this.W);
        bundle.putInt("etab", this.X);
        String str2 = this.c0;
        if (str2 != null) {
            bundle.putString("etag", str2);
        }
        c2.a aVar = this.a0;
        if (aVar != null) {
            bundle.putString("eent", aVar.toString());
        }
        if (this.Z != null) {
            bundle.putBoolean("ssed", true);
            this.Z.U(0).d0(this, "ssed", 0);
        }
        if (this.Y != null) {
            bundle.putBoolean("sseo", true);
            this.Y.U(0).d0(this, "sseo", 0);
        }
    }

    @Override
    protected void onStart() {
        bb(true, "onStart");
        this.R = true;
        r7.f("T", "onStart");
        super.onStart();
        if (!v0) {
            this.f0.N(pg.d.k(this));
            r7.f("T", "onStart done");
            return;
        }
        v0 = false;
        r7.f("T", "Can't handle activity if it's recreated while showing lock dialog. Just finish activity.");
        this.R = false;
        bb(false, "onStart with lock dialog");
        Ga(false, "isShowingLockDialog");
    }

    @Override
    public void onStop() {
        super.onStop();
        pg.d.l(this);
    }

    @EventBusRxSubscription
    @Keep
    public void onTaskerEnabledChange(pf.o1 o1Var) {
        mb(this);
    }

    @Override
    protected void onUserLeaveHint() {
        boolean L7 = L7();
        r7.f("T", "User leaving. Launching activity: " + L7);
        if (!L7 && !m6()) {
            sp.o0("Main onUserLeaveHint");
        }
        if (!l6(4)) {
            r7.f("T", "userLeaveHint");
            J5();
        }
        super.onUserLeaveHint();
    }

    public ListView q6() {
        return r6(B5());
    }

    public boolean q7(int i2) {
        xi s2 = this.S.s2(Da(i2), "hptc");
        if (s2 == null) {
            return false;
        }
        if (s2.X() && !m5(10, new Object[]{Integer.valueOf(i2)})) {
            return false;
        }
        this.I.S(i2);
        Qa(A5(), "handleProjectTabClick");
        this.I.S(i2);
        Q5();
        ld();
        return true;
    }

    public ListView r6(Integer num) {
        v1 v1Var = this.Q;
        if (v1Var == null) {
            return null;
        }
        return v1Var.b(num);
    }

    public void r7(int i2) {
        this.W = i2;
        dk dkVar = (dk) this.y.getItem(i2);
        if (!dkVar.r() || m5(8, new Object[]{Integer.valueOf(i2)})) {
            Rc(dkVar.getName(), null, -1);
        }
    }

    public ListView s6(c2.a aVar) {
        return r6(Integer.valueOf(aVar.ordinal()));
    }

    public void sb(c2.a aVar, ListView listView) {
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            listView.setClickable(false);
            listView.setLongClickable(false);
        } else if (i2 == 2) {
            listView.setOnItemClickListener(new z());
        } else if (i2 == 3) {
            listView.setOnItemClickListener(new a0());
        } else {
            if (i2 != 4) {
                return;
            }
            listView.setOnItemClickListener(new b0());
        }
    }

    public boolean u5() {
        if (!m5(4, null)) {
            return false;
        }
        L5();
        return true;
    }

    public void ua(ListView listView, int i2, boolean z2) {
        vi viVar;
        r7.f("T", "click: pos: " + i2 + " long: " + z2 + " inAction: " + y());
        if (z2) {
            wa();
            if (y()) {
                return;
            }
            listView.setItemChecked(i2, true);
            return;
        }
        if (y()) {
            listView.setItemChecked(i2, !this.x.i(i2));
            return;
        }
        boolean f12 = this.U.f1();
        if (!this.U.K1() && p6() >= 1) {
            int C0 = this.U.C0();
            Iterator<Integer> it = this.S.n2().iterator();
            while (it.hasNext()) {
                int intValue = it.next().intValue();
                if (intValue != C0) {
                    this.S.c(intValue).c0();
                }
            }
        }
        K6(false, c2.a.Profile);
        if (f12 && (viVar = this.x) != null && i2 == viVar.getCount() - 1 && pd(this) && this.x.getCount() > listView.getChildCount()) {
            r7.f("T", "move up");
            listView.setSelection(i2);
        }
    }

    public void va() {
        V5(true, "Open Tasky");
        lh.k.c(this, true);
    }

    public to w6(String str) {
        return C6(str, to.i2(this, false));
    }

    public void w7(int i2) {
        this.U = null;
        tn tnVar = (tn) this.z.getItem(i2);
        if (tnVar == null) {
            r7.G("T", "handleTaskClick: no task at position " + i2);
            return;
        }
        this.W = tnVar.P0();
        if (!tnVar.r() || m5(9, new Object[]{Integer.valueOf(i2)})) {
            Vc(tnVar.P0());
        }
    }

    public void x7(int[] iArr) {
        for (int i2 : iArr) {
            this.S.g1(i2);
        }
        L6(c2.a.Profile, c2.a.Task);
        v();
        dq.j0(this, 2131888711, new Object[0]);
    }

    public void xa() {
        int i2;
        int i3;
        int i4;
        RelativeLayout relativeLayout = (RelativeLayout) findViewById(2131296875);
        if (relativeLayout == null) {
            MyActivity.L(this, "populateEntityTabs entityTabHost null");
            return;
        }
        this.G = relativeLayout;
        relativeLayout.removeAllViews();
        if (tp.h0(this)) {
            i2 = up.c(this);
            i3 = tp.L(this);
            i4 = tp.q(this);
        } else {
            i2 = 0;
            i3 = 0;
            i4 = 0;
        }
        zh A = zh.A(this, relativeLayout, i2, i3, i4);
        this.J = A;
        A.V(new u());
        this.J.U(12);
        if (this.P == null) {
            this.P = findViewById(2131297223);
        } else {
            this.Q.d(false);
        }
        this.Q = new v1(this, this.P);
        Bundle bundle = new Bundle();
        bundle.putString("type", c2.a.Profile.toString());
        Bundle bundle2 = new Bundle();
        bundle2.putString("type", c2.a.Task.toString());
        Bundle bundle3 = new Bundle();
        bundle3.putString("type", c2.a.Scene.toString());
        Bundle bundle4 = new Bundle();
        bundle4.putString("type", c2.a.Variable.toString());
        Bundle[] bundleArr = {bundle, bundle2, bundle3, bundle4};
        boolean j12 = Settings.j1(dq.R0(this));
        for (c2.a aVar : c2.a.values()) {
            if (!j12 || aVar != c2.a.Variable) {
                this.Q.a(s1.class, bundleArr[aVar.ordinal()]);
                this.J.m(this, true);
                this.J.G(aVar.ordinal());
                this.J.J(aVar.ordinal(), vh.g(this, c2.g(aVar), new Object[0]));
            }
        }
        this.Q.notifyDataSetChanged();
    }
}