导航菜单

页面标题

页面副标题

Tasker v6.6.3 - Main.java 源代码

正在查看: Tasker v6.6.3 应用的 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.r;
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 n3.b0;
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.b2;
import net.dinglisch.android.taskerm.d6;
import net.dinglisch.android.taskerm.fh;
import net.dinglisch.android.taskerm.fn;
import net.dinglisch.android.taskerm.fo;
import net.dinglisch.android.taskerm.fp;
import net.dinglisch.android.taskerm.hj;
import net.dinglisch.android.taskerm.io;
import net.dinglisch.android.taskerm.ji;
import net.dinglisch.android.taskerm.jl;
import net.dinglisch.android.taskerm.ki;
import net.dinglisch.android.taskerm.mj;
import net.dinglisch.android.taskerm.ni;
import net.dinglisch.android.taskerm.sh;
import net.dinglisch.android.taskerm.ud;
import net.dinglisch.android.taskerm.up;
import net.dinglisch.android.taskerm.vg;

public class Main extends MyActivity implements View.OnClickListener, ni.m, ni.n, ni.l, ni.o, xf.a, ze.e {
    private static final String[] h0 = {"tsIndexed", "tsEmpty", "tsRef"};
    private static final boolean[] i0 = {true, true, true};
    private static final int[] j0 = {2131886803, 2131886797, 2131886814};
    private static final int[] k0 = {2131297649, 2131297651, 2131297650};
    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 sh I;
    private sh 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 b2.a a0;
    public jl v;
    com.joaomgcd.taskerm.util.ac w = null;
    public ni x = null;
    private zk y = null;
    private hn z = null;
    private up A = null;
    private ToggleButton[] C = new ToggleButton[up.b.values().length];
    private Handler D = null;
    private boolean R = false;
    public fo S = new fo();
    private int T = 0;
    private io U = null;
    private String V = null;
    private hi Y = null;
    private fo Z = null;
    private int b0 = -2;
    private String c0 = "";
    private ph d0 = null;
    private MonitorService.z e0 = null;
    public com.joaomgcd.taskerm.helper.r f0 = new com.joaomgcd.taskerm.helper.r(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 jh {
        final ListView i;

        a1(Context context, rg rgVar, ImageView imageView, ImageView imageView2, ImageView imageView3, ListView listView) {
            super(context, rgVar, 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), (fn) 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()) {
                        ((fn) it.next()).A(menuItem.getItemId() == 4);
                    }
                    Main.this.K6(false, b2.a.Task);
                    Main.this.K6(false, b2.a.Profile);
                    Main.this.K6(false, b2.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), (fn) 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, b2.a.Task);
                    Main.this.v();
                    return true;
                case 11:
                    g(this.i);
                    return true;
                case 12:
                    fn fnVar = (fn) d().d();
                    fnVar.D2(100);
                    ExecuteService.d6(Main.this, fnVar, 9, -1, -1, -1, null, null, "ui", null);
                    Main.this.v();
                    return true;
                case 13:
                    Main.this.f0.P4((fn) d().d());
                    return true;
                case 14:
                    Main.this.f0.H4(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(b2.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;
            }
            fn fnVar = (fn) 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 (fnVar != null && fnVar.p()) {
                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() == fn.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;
                }
                fn fnVar2 = (fn) it.next();
                if (fnVar2 != null && fnVar2.q()) {
                    Main.this.m5(13, null);
                    break;
                }
            }
            if (f()) {
                net.dinglisch.android.taskerm.a.y(Main.this, 13, menu, 2131890604, 2130969223);
            }
            net.dinglisch.android.taskerm.a.C(Main.this, 14, false, menu);
            return true;
        }
    }

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

        b(io ioVar, int i) {
            this.a = ioVar;
            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(b2.a.Variable.ordinal()) : view.findViewById(2131297684);
            Main main = Main.this;
            main.Fc((rp) main.A.getItem(i), v, (ListView) adapterView, i);
        }
    }

    class b1 extends jh {
        final ListView i;

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

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            mj mjVar = (mj) d().d();
            switch (menuItem.getItemId()) {
                case 1:
                    Main main = Main.this;
                    main.sc(main.findViewById(1), mjVar);
                    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()) {
                        ((mj) it.next()).A(menuItem.getItemId() == 4);
                    }
                    Main.this.K6(false, b2.a.Scene);
                    Main.this.v();
                    if (mjVar.p()) {
                        Main.this.id();
                    }
                    return true;
                case ClockContract.InstancesColumns.MISSED_STATE:
                default:
                    return false;
                case 7:
                    Iterator<Object> it2 = d().g().iterator();
                    while (it2.hasNext()) {
                        mj mjVar2 = (mj) it2.next();
                        if (fl.N(mjVar2.getName())) {
                            fl.v(Main.this, mjVar2.getName(), true);
                        }
                    }
                    Main.this.L6(b2.a.Scene);
                    Main.this.v();
                    return true;
                case 8:
                    Main main4 = Main.this;
                    main4.Ob(main4.findViewById(8), (mj) 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, b2.a.Scene);
                    Main.this.v();
                    return true;
                case 11:
                    g(this.i);
                    return true;
                case 12:
                    Main main6 = Main.this;
                    main6.Nb(mjVar, main6.findViewById(8));
                    return true;
                case 13:
                    Main.this.f0.E4(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(b2.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;
            }
            mj mjVar = (mj) Main.this.y.getItem(this.g);
            boolean j1 = Settings.j1(Main.this.M);
            if (f() && !gl.P(mjVar.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 (fl.N(mjVar.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() && mjVar.t1() > 0) {
                net.dinglisch.android.taskerm.a.o(Main.this, 12, menu);
            }
            if (mjVar.p()) {
                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() == mj.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 (((mj) it.next()).q()) {
                    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 jl.l {
        c1() {
        }

        @Override
        public void e(jl.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.z0(main.Y9("keystore.user", "bl^!)*(!*{a", message.getData().getString("text")), new Runnable() {
                    @Override
                    public final void run() {
                        Main.d0.this.b();
                    }
                });
            }
        }
    }

    class d1 extends jh {
        final ListView i;

        d1(Context context, rg rgVar, ImageView imageView, ImageView imageView2, ImageView imageView3, ListView listView) {
            super(context, rgVar, 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(wp.B0(Main.this, ((rp) obj).getName()));
                }
                if (vg.c(Main.this, sb.toString(), vg.a.None)) {
                    pp.j0(Main.this, 2131888728, new Object[0]);
                } else {
                    pp.a0(Main.this, 2131887714, 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), (rp) 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;
            }
            rp rpVar = (rp) Main.this.A.getItem(this.g);
            boolean L0 = wp.L0(Main.this, rpVar.getName());
            if (f()) {
                Main main = Main.this;
                if (!main.S.I4(main, main.getPackageManager(), -2, false).contains(rpVar.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) {
                o7.f("T", "connected to monitor service");
                Main.this.tb();
                MonitorService u6 = Main.this.u6("bind:handleMessage");
                if (u6 != null) {
                    u6.r7();
                    return;
                } else {
                    o7.G("T", "no monitor service after bind, unbind");
                    Main.this.kd();
                    return;
                }
            }
            if (i == 2) {
                o7.G("T", "monitor service connection error");
                Main.this.d0 = null;
            } else if (i == 1) {
                o7.f("T", "disconnected from monitor service");
                fo foVar = Main.this.S;
                if (foVar != null) {
                    foVar.T0();
                }
            }
        }
    }

    class f extends qg {
        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 fh.f {
        final View a;

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

        @Override
        public void a(fh fhVar) {
            if (fhVar.v()) {
                return;
            }
            Main.this.W = fhVar.A();
            if (Main.this.W == 3 && Main.this.S.L1(3).size() > 0) {
                Main.this.Zb(this.a);
                return;
            }
            if (Main.this.U != null && sn.M0(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) {
            fo foVar = Main.this.S;
            if (foVar != null) {
                io c = foVar.c(i);
                if (c != null) {
                    c.e1();
                    Main main = Main.this;
                    if (main.x != null) {
                        io.b y6 = main.y6();
                        if (y6 == io.b.ActiveAlpha || y6 == io.b.ActiveContext) {
                            z = true;
                        } else {
                            Main.this.f0.O4();
                        }
                    }
                }
                if (z) {
                    Main.this.J6(false, false, false, b2.a.Profile);
                }
            }
        }

        @Override
        public void a(int i, int i2, boolean z, boolean z2) {
            io c;
            fo foVar = Main.this.S;
            if (foVar == null || (c = foVar.c(i)) == null || !c.Z0(i2)) {
                return;
            }
            sn T0 = c.T0(i2);
            o7.f("T", "Setting profile " + c.C0() + " context " + i2 + " to active " + z2);
            T0.Q0(z2);
            Main.this.f0.O4();
        }

        @Override
        public void b(final int i, boolean z, boolean z2, final boolean z3) {
            xg.e2.b1(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(b2.a.Profile);
                Main main2 = Main.this;
                main2.O7(main2.U.C0());
            }
        }
    }

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

        @Override
        public void a(fh fhVar) {
            if (fhVar.v()) {
                return;
            }
            Main.this.u5();
            xo.c(Main.this, 2131890981);
        }
    }

    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 io q;
        final sn r;

        h(ImageView imageView, io ioVar, sn snVar) {
            this.i = imageView;
            this.q = ioVar;
            this.r = snVar;
        }

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

    class h0 implements fh.f {
        final List a;

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

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

    class h1 implements fh.f {
        final mj a;

        h1(mj mjVar) {
            this.a = mjVar;
        }

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

    class i extends Handler {

        class a implements Runnable {
            a() {
            }

            @Override
            public void run() {
                Main.this.md(b2.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[b2.a.values().length];
            b = iArr;
            try {
                iArr[b2.a.Profile.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                b[b2.a.Task.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                b[b2.a.Scene.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                b[b2.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 (xo.g(Main.this, 2131890949)) {
                Main.this.V5(true, "menu1");
            } else {
                xo.c(Main.this, 2131890949);
                TextBoxDialogFragment.F(Main.this, new a(), 2131890883, oh.g(Main.this, 2131890949, new Object[0]), 2131886894, -1, -1, 4).E(Main.this);
            }
        }
    }

    class j0 extends Handler {
        j0() {
        }

        @Override
        public void handleMessage(Message message) {
            String l = ch.l(Main.this, message.getData().getString("text"));
            if (l != null) {
                TextBoxDialogFragment.F(Main.this, null, 2131888795, l, 2131886894, -1, -1, 521).E(Main.this);
            } else {
                Main main = Main.this;
                pp.a0(main, 2131887973, oh.g(main, 2131888795, 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() == b2.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 (!jl.X(main, main.y(), x, this.i.getWidth()) || jl.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 = ch.k(Main.this);
                if (k == null || !k.delete()) {
                    pp.a0(Main.this, 2131887962, k.getName());
                } else {
                    pp.j0(Main.this, 2131886894, new Object[0]);
                }
            }
        }
    }

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

        k1(io ioVar, w1 w1Var, View view, int i) {
            this.a = ioVar;
            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.R0("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, b2.a.values());
                Main.this.Qa(b2.a.Profile, "showConfirmClearData");
                Main.this.invalidateOptionsMenu();
            }
        }
    }

    class l1 implements ki.i {
        final View a;

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

        @Override
        public void a(ki kiVar) {
            if (kiVar.f() || !kiVar.g()) {
                return;
            }
            String i = kiVar.i();
            Main main = Main.this;
            if (!main.n5(i, main.S.a3(i), null)) {
                Main.this.gc(this.a, i);
                return;
            }
            pi piVar = new pi(i);
            piVar.q0(Main.this.S.u2(0, "snpnp").w());
            Main.this.S.z0(piVar);
            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 rf.d a;

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

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

    class m0 implements fh.f {
        final View a;
        final io b;
        final int c;

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

        @Override
        public void a(fh fhVar) {
            if (fhVar.v()) {
                return;
            }
            int ordinal = n1.values()[fhVar.A()].ordinal();
            if (ordinal == 0) {
                Main.this.Jb(this.a);
                return;
            }
            if (ordinal == 1) {
                if (Main.this.e5()) {
                    Main.this.L6(b2.a.Profile);
                    return;
                }
                return;
            }
            if (ordinal == 2) {
                Main main = Main.this;
                io ioVar = this.b;
                main.Hb(ioVar, ioVar.T0(this.c), this.a);
            } else {
                if (ordinal != 3) {
                    return;
                }
                Main main2 = Main.this;
                io Y0 = main2.S.Y0(this.b, main2.W);
                Y0.C(null);
                Main.this.L6(b2.a.Profile);
                Main.this.U = Y0;
                Main main3 = Main.this;
                main3.W4(main3.q6(), Main.this.U.C0());
                Main.this.Rb(Y0, true);
            }
        }
    }

    class m1 extends Handler {
        final int a;

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

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

    class n implements Runnable {
        final String i;

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

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

        public ti.r d(final String str) {
            return xg.e2.A1(new ik.a() {
                @Override
                public final Object e() {
                    e5 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.J(main, new ik.a() {
                @Override
                public final Object e() {
                    ti.r d;
                    d = Main.n.this.d(str);
                    return d;
                }
            });
        }
    }

    class n0 implements fh.f {
        final View a;
        final io b;
        final int c;
        final int d;

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

        @Override
        public void a(fh fhVar) {
            if (fhVar.v()) {
                return;
            }
            switch (x1.values()[fhVar.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.M2(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 ? 0 : 1;
                    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.F4(main7.U);
                    Main.this.K6(false, b2.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) {
                o7.f("T", "now restoring package: " + i + " (" + str + ")");
            }

            @Override
            public void restoreFinished(int i) {
                Main main = Main.this;
                fo foVar = main.S;
                if (foVar != null) {
                    if (i != 0) {
                        pp.b0(main, String.valueOf(i), new Object[0]);
                        return;
                    }
                    if (foVar.r4(main, "autobackup.xml")) {
                        Main.this.i6();
                        pp.j0(Main.this, 2131890237, new Object[0]);
                    } else {
                        pp.a0(Main.this, 2131891100, new Object[0]);
                    }
                    Main.this.Ta();
                }
            }

            @Override
            public void restoreStarting(int i) {
                o7.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) {
                        pp.b0(Main.this, String.valueOf(b), new Object[0]);
                    }
                } catch (SecurityException e) {
                    pp.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, b2.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> G1 = fo.G1();
                Long l = pp.i3(G1.keySet(), true)[i];
                l.longValue();
                TextBoxDialogFragment.Y(Main.this, new a(G1.get(l)), 2131887318);
            }
        }
    }

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

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

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

        public void b(fo foVar) {
            foVar.Q0(Main.this.getPackageManager(), b2.a.values());
        }

        @Override
        public void run() {
            if (this.i) {
                Main.this.Ta();
            }
            Main main = Main.this;
            final fo foVar = main.S;
            if (foVar == null) {
                MyActivity.L(main, "handleDataChanged data null");
                return;
            }
            for (b2.a aVar : this.q) {
                int i = i1.b[aVar.ordinal()];
                if (i == 1) {
                    Main main2 = Main.this;
                    ni niVar = main2.x;
                    if (niVar != null) {
                        niVar.z("dataChanged", main2.y6(), foVar);
                    }
                } else if (i != 2) {
                    if (i != 3) {
                        if (i == 4 && Main.this.A != null) {
                            Main.this.A.w(foVar, Main.this.C5());
                            Main.this.A.x();
                        }
                    } else if (Main.this.y != null) {
                        Main.this.y.s(foVar, Main.this.C5(), Main.this.z6());
                    }
                } else if (Main.this.z != null) {
                    Main.this.z.s(foVar, Main.this.C5(), Main.this.B6());
                }
            }
            if (this.r) {
                if (this.s) {
                    xg.e2.U0(new Runnable() {
                        @Override
                        public final void run() {
                            Main.q.this.b(foVar);
                        }
                    });
                } else {
                    foVar.Q0(Main.this.getPackageManager(), b2.a.values());
                }
            }
            Main.this.Ha();
        }
    }

    class q0 extends Handler {
        final boolean a;
        final int b;
        final r.b c;
        final Runnable d;

        q0(boolean z, int i, r.b bVar, Runnable runnable) {
            this.a = z;
            this.b = i;
            this.c = bVar;
            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 sh.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 r.d(i))) {
                Main.this.qc(i);
            }
        }

        @Override
        public void d(int i) {
            Main.this.v();
            if (Main.this.m5(11, new r.d(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);
            b2.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, b2.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 fh.f {
        final int a;

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

        public void c(df.p1 p1Var) throws Exception {
            if (p1Var.o()) {
                wp.E(Main.this, "", false, true, null);
                Main.this.md(b2.a.Variable);
            }
        }

        @Override
        public void a(fh fhVar) {
            if (fhVar.v()) {
                return;
            }
            int ordinal = p1.values()[fhVar.A()].ordinal();
            if (ordinal == 0) {
                if (Main.this.a0 == b2.a.Scene) {
                    fl.r(Main.this);
                    return;
                } else if (Main.this.a0 == b2.a.Task) {
                    pp.o3(Main.this, ExecuteService.class);
                    ExecuteService.o8(Main.this);
                    return;
                } else {
                    Main main = Main.this;
                    main.f0.q0(com.joaomgcd.taskerm.dialog.a.I7(main, 2131888798, 2131890200), new yi.d() {
                        @Override
                        public final void accept(Object obj) {
                            Main.s.this.c((df.p1) 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 b2.a a;
        final ListView b;

        s0(b2.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) {
                o7.l("T", "onDrag/list", e);
                return false;
            }
        }
    }

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

        private void b(Main main, int i, int i2) {
            setEmptyText(Html.fromHtml("<I><SMALL>" + oh.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 = b2.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 = b2.a.valueOf(bundle.getString("type"));
            }
            Main a = a();
            jl jlVar = a.v;
            ListView listView = getListView();
            a.eb(this.i, listView);
            if (jlVar != null) {
                jlVar.t0(listView, Main.pd(a), this.i == b2.a.Profile);
            }
            if (this.i == b2.a.Variable) {
                a.gb(listView, a.qd());
            }
            a.sb(this.i, listView);
            a.ib(listView);
            a.hb(this.i, listView);
            listView.setScrollBarStyle(33554432);
            gi.r(listView, fp.w(a, 2131165290));
            gi.q(listView, fp.w(a, 2131165289));
            listView.setChoiceMode(3);
            listView.setItemsCanFocus(true);
            listView.setDividerHeight(fp.w(a, 2131165379));
            a.ab(listView);
            int i3 = i1.b[this.i.ordinal()];
            if (i3 == 1) {
                a.jb(listView);
                i = 2131889268;
                i2 = 2131890886;
            } else if (i3 == 2) {
                a.nb(listView);
                i = 2131889272;
                i2 = 2131890888;
            } else if (i3 != 3) {
                a.pb(listView);
                i = 2131889274;
                i2 = 2131890889;
            } else {
                a.lb(listView);
                i = 2131889269;
                i2 = 2131890887;
            }
            b(a, i2, i);
            v1 A6 = a.A6();
            if (A6 != null) {
                A6.e(this.i, listView);
            }
        }
    }

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

        @Override
        public void a(fh fhVar) {
            if (fhVar.v()) {
                return;
            }
            int A = fhVar.A();
            int C5 = Main.this.C5();
            int i = i1.b[Main.this.a0.ordinal()];
            if (i == 1) {
                io.b bVar = io.b.values()[A];
                Main.this.S.U4(C5, bVar);
                Main.this.x.E(C5, bVar, true);
            } else if (i == 2) {
                fn.f fVar = fn.f.values()[A];
                Main.this.S.W4(C5, fVar);
                Main.this.z.s(Main.this.S, C5, fVar);
            } else {
                if (i != 3) {
                    return;
                }
                mj.i iVar = mj.i.values()[A];
                Main.this.S.V4(C5, iVar);
                Main.this.y.s(Main.this.S, C5, iVar);
            }
        }
    }

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

        t0(ki kiVar, b2 b2Var, View view, boolean z, int i) {
            this.i = kiVar;
            this.q = b2Var;
            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 sh.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) {
            o7.f("T", "tabReselect: enabled: " + Main.q0 + " " + System.currentTimeMillis());
            if (Main.q0 && Main.this.m5(20, new r.d(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);
            b2.a aVar = b2.a.values()[i2];
            b2.a aVar2 = b2.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()) {
                Main.this.v.y0(s6, false, "T/entityDrag");
            }
            return true;
        }

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

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

        u0(b2.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 ki.i {
        final io a;
        final sn b;
        final View c;

        v0(io ioVar, sn snVar, View view) {
            this.a = ioVar;
            this.b = snVar;
            this.c = view;
        }

        @Override
        public void a(ki kiVar) {
            boolean z = this.a.P0() == 0;
            if (kiVar.f()) {
                if (z) {
                    Main.this.P6(new int[]{this.a.C0()});
                    return;
                }
                return;
            }
            if (kiVar.g()) {
                String i = kiVar.i();
                if (TextUtils.isEmpty(i)) {
                    if (z) {
                        pp.j0(Main.this, 2131887839, new Object[0]);
                        Main.this.Hb(this.a, this.b, this.c);
                        return;
                    } else {
                        this.b.S0(null);
                        Main.this.S.F4(this.a);
                        Main.this.L6(b2.a.Profile);
                        return;
                    }
                }
                if (Main.this.S.c1(i, this.b.F0())) {
                    pp.a0(Main.this, 2131891092, new Object[0]);
                    Main.this.Hb(this.a, this.b, this.c);
                    return;
                }
                this.b.S0(i);
                Main.this.S.F4(this.a);
                Main.this.L6(b2.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(b2.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() && fp.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 qg {
        final boolean b;

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

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

    class w0 implements ki.i {
        final int a;

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

        @Override
        public void a(ki kiVar) {
            if (kiVar.f() || !kiVar.g()) {
                return;
            }
            String i = kiVar.i();
            Main main = Main.this;
            if (main.n5(i, main.S.a3(i), null)) {
                Main.this.S.T4(this.a, i);
                Main.this.Ia();
                Main.this.v();
            }
        }
    }

    enum w1 {
        ProfileReselect,
        ProfileAddOfType
    }

    class x extends qg {
        final boolean b;

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

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

    class x0 extends jh {
        final ListView i;

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

        @Override
        public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case 1:
                    List<Integer> f = d().f();
                    io ioVar = (io) d().getItem(f.get(0).intValue());
                    if (f.size() == 1 && ioVar.x()) {
                        Main main = Main.this;
                        main.Fb(this.i, ioVar, main.J.v(b2.a.Profile.ordinal()), -1, ioVar.getName());
                        actionMode.finish();
                    } else {
                        Iterator<Integer> it = d().f().iterator();
                        int i = -1;
                        while (it.hasNext()) {
                            io Z0 = Main.this.S.Z0((io) d().getItem(it.next().intValue()), true);
                            Z0.t1(Main.this.p6() >= 6);
                            if (i == -1) {
                                i = Z0.C0();
                            }
                        }
                        actionMode.finish();
                        Main.this.L6(b2.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 (!((io) it2.next()).x()) {
                            pp.a0(Main.this, 2131887703, new Object[0]);
                        }
                    }
                    return true;
                case 4:
                case 5:
                    Iterator<Object> it3 = d().g().iterator();
                    while (it3.hasNext()) {
                        ((io) it3.next()).A(menuItem.getItemId() == 4);
                    }
                    Main.this.K6(false, b2.a.Profile);
                    Main.this.K6(false, b2.a.Task);
                    Main.this.v();
                    return true;
                case ClockContract.InstancesColumns.MISSED_STATE:
                case 7:
                    Iterator<Object> it4 = d().g().iterator();
                    while (it4.hasNext()) {
                        io ioVar2 = (io) it4.next();
                        if (menuItem.getItemId() == 6) {
                            ioVar2.A1(true);
                            ioVar2.C1(0);
                        } else {
                            ioVar2.A1(false);
                        }
                    }
                    Main.this.K6(false, b2.a.Profile);
                    Main.this.v();
                    return true;
                case 8:
                    Main main4 = Main.this;
                    main4.Ob(main4.findViewById(8), (io) Main.this.x.d(), true, -1);
                    return true;
                case 9:
                    io ioVar3 = Main.this.U;
                    if (ioVar3 != null) {
                        Main.this.Ic(ProfileProperties.j0(ioVar3), 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, b2.a.Profile);
                    Main.this.v();
                    return true;
                case 12:
                    g(this.i);
                    return true;
                case 13:
                    Main main6 = Main.this;
                    main6.f0.B4(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(b2.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;
            }
            io ioVar = (io) 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() || !ni.v(Main.this.M)) && ioVar != null) {
                if (ioVar.h1()) {
                    net.dinglisch.android.taskerm.a.n(Main.this, 6, menu, true);
                }
                if (!ioVar.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 (ioVar != null && !ioVar.p() && !j1) {
                net.dinglisch.android.taskerm.a.w(Main.this, 4, false, menu);
            }
            if (Main.this.y6() == io.b.User && (!f() || this.g > 0)) {
                net.dinglisch.android.taskerm.a.D(Main.this, 11, menu);
            }
            if (ioVar != null && ioVar.p()) {
                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.e2() > 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 ki.i {
        final io a;
        final ListView b;

        y0(io ioVar, ListView listView) {
            this.a = ioVar;
            this.b = listView;
        }

        @Override
        public void a(ki kiVar) {
            if (kiVar.f()) {
                return;
            }
            String i = kiVar.i();
            io Z0 = Main.this.S.Z0(this.a, true);
            if (i.length() > 0) {
                Z0.C(i);
            }
            Z0.t1(Main.this.p6() >= 6);
            Main.this.L6(b2.a.Profile);
            Main.this.W4(this.b, Z0.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 = ((rp) it.next()).getName();
                    if (Main.this.A.t(name)) {
                        z = true;
                    }
                    wp.D(Main.this, name);
                }
                Main.this.A.x();
                if (z) {
                    xo.d(Main.this, 2131890876);
                }
                Main.this.v();
                Main.this.P7();
            }
        }
    }

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

    public static boolean A7() {
        return u0;
    }

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

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

    public void Aa() {
        View view = this.H;
        if (view == null) {
            MyActivity.L(this, "populateViews projectTabHostShadow null");
            return;
        }
        if (fp.e0()) {
            gp.D(view);
        } else {
            ImageView imageView = (ImageView) findViewById(R.id.home);
            if (imageView != null) {
                imageView.setBackgroundResource(fp.J(this, 2130968984));
                imageView.setOnLongClickListener(new r0());
            }
        }
        this.K = (ImageView) findViewById(2131296450);
        this.L = (ImageView) findViewById(2131296453);
        this.f0.q4();
        androidx.core.view.y0.c(this.K, "Test", new n3.b0() {
            public final boolean a(View view2, b0.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);
        jl jlVar = new jl();
        this.v = jlVar;
        jlVar.b0(this, "T", null, this.K, this.F, view, null, false, true, (ImageView) findViewById(2131297342), (ImageView) findViewById(2131297340), null, new c1());
        this.v.v0(this, null, pd(this), "onCreate");
        jl.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, io ioVar, int i2, int i3) {
        boolean c12 = ioVar.c1(0);
        boolean c13 = ioVar.c1(1);
        boolean x2 = this.S.M2(ioVar, i2).x();
        boolean i12 = ioVar.i1(this, com.joaomgcd.taskerm.util.b7.l0(this.S, this, ioVar, null, "showTaskOptionsFromProfile"));
        fh fhVar = new fh(this, view);
        String g2 = oh.g(this, 2131891185, new Object[0]);
        String g3 = oh.g(this, 2131891192, new Object[0]);
        if (!c12) {
            if (i12) {
                fhVar.k(x1.Add.ordinal(), 2131888751, 2130969155);
            } else {
                fhVar.n(x1.AddEnter.ordinal(), oh.g(this, 2131888752, g2), 2130969202);
            }
        }
        if (!c13) {
            if (i12) {
                fhVar.k(x1.Add.ordinal(), 2131888751, 2130969155);
            } else {
                fhVar.n(x1.AddExit.ordinal(), oh.g(this, 2131888752, g3), 2130969203);
            }
        }
        if (!i12) {
            if (!c12) {
                fhVar.n(x1.MoveToEnter.ordinal(), oh.g(this, 2131888933, g2), 2130969285);
            }
            if (!c13) {
                fhVar.n(x1.MoveToExit.ordinal(), oh.g(this, 2131888933, g3), 2130969285);
            }
        }
        if (!x2) {
            fhVar.k(x1.Name.ordinal(), 2131889804, 2130969235);
        }
        fhVar.k(x1.Reselect.ordinal(), 2131888964, 2130969269);
        fhVar.k(x1.Unlink.ordinal(), 2131889090, 2130969261);
        fhVar.F(new n0(view, ioVar, i2, i3)).show();
    }

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

    public fn.f B6() {
        fn.f fVar = fn.f.User;
        pi u2 = this.S.u2(C5(), "gts");
        if (u2 != null) {
            return u2.L();
        }
        o7.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(pi piVar, q1 q1Var, we.l lVar) throws Exception {
        j6(piVar.S(this, this.S, lVar), 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] = ((io) list.get(i2)).C0();
        }
        return iArr;
    }

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

    public void Bc(final w1 w1Var, final View view, final io ioVar, final int i2) {
        final com.joaomgcd.taskerm.dialog.b p2 = com.joaomgcd.taskerm.dialog.b.p(this, 2131887205);
        this.f0.O(new Runnable() {
            @Override
            public final void run() {
                Main.this.P9(view, ioVar, i2, w1Var, p2);
            }
        });
    }

    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, fh fhVar) {
        if (fhVar.v()) {
            w5("projMenuCancelled");
            return;
        }
        final pi u2 = this.S.u2(Da(i2), "spen");
        final q1 q1Var = q1.values()[fhVar.A()];
        int ordinal = q1Var.ordinal();
        if (ordinal == 0) {
            b6(u2);
            return;
        }
        if (ordinal == 1 || ordinal == 2) {
            this.f0.z2(q1Var, new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.B9(u2, q1Var, (we.l) obj);
                }
            });
            return;
        }
        if (ordinal == 5) {
            c6(u2);
            return;
        }
        if (ordinal == 6) {
            Y5(u2, false);
            return;
        }
        if (ordinal == 7) {
            Y5(u2, true);
            return;
        }
        o7.k("T", "unexpected export mode " + fhVar.A());
    }

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

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

    private void Cc(io ioVar) {
        io ioVar2 = this.U;
        Intent o02 = TimeSelect.o0(ioVar2 == null ? null : (wo) ioVar2.T0(1));
        wp.e(this, this.S, null, o02, null, ioVar);
        Ic(o02, 23);
    }

    private e5 D7(File file) {
        e5 l3 = this.S.l3(this, file, C5());
        if (l3.a()) {
            pp.b0(this, l3.b(this), new Object[0]);
        } else {
            io ioVar = (io) l3.c;
            k6(b2.a.Profile, b2.a.Task);
            W4(q6(), ioVar.C0());
        }
        return l3;
    }

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

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

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

    private boolean Dc() {
        qg.b.b(this);
        return this.f0.s2(2131887260, new ik.a() {
            @Override
            public final Object e() {
                Boolean Q9;
                Q9 = Main.this.Q9();
                return Q9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.S9();
            }
        });
    }

    public void E5(io ioVar, int i2) {
        this.U.g0(i2);
        this.U.c0();
        this.S.F4(this.U);
    }

    private e5 E7(File file) {
        e5 m3 = this.S.m3(this, getPackageManager(), file);
        if (m3.b == -1) {
            S4();
            k6(b2.a.values());
        } else {
            pp.a0(this, 2131887888, file.getName(), m3.b(this));
        }
        return m3;
    }

    public void E8(int i2) {
        Vb(b2.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.a0(this, "https://youtu.be/rkQRH17H-DY");
    }

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

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

    private e5 F7(File file) {
        e5 p3 = this.S.p3(this, file, C5());
        if (p3.a()) {
            pp.b0(this, p3.b(this), new Object[0]);
        } else {
            mj mjVar = (mj) p3.c;
            k6(b2.a.Scene);
            X4(mjVar.getName());
        }
        return p3;
    }

    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.X3(Da(i2), Da(num.intValue()));
    }

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

    public void Fb(ListView listView, io ioVar, View view, int i2, String str) {
        boolean z2;
        ki kiVar = new ki(this, str);
        if (view != null || i2 == -1) {
            z2 = true;
        } else {
            kiVar.l(q6(), i2);
            z2 = false;
        }
        kiVar.o(new y0(ioVar, listView)).p(2131887414).u(view, this.K, z2);
    }

    public void Fc(final rp rpVar, View view, ListView listView, int i2) {
        ki kiVar = new ki(this, wp.B0(this, rpVar.getName()));
        kiVar.o(new ki.i() {
            @Override
            public final void a(ki kiVar2) {
                Main.this.T9(rpVar, kiVar2);
            }
        }).n(15).l(listView, i2);
        kiVar.v(j5(view, true), false);
    }

    private void G5(int i2, boolean z2) {
        if (od()) {
            qg.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() == fn.class) {
            y7((fn) remove, cVar, list);
        } else if (remove.getClass() == h7.class) {
            b7((h7) remove, list);
        }
    }

    private e5 G7(File file) {
        e5 s3 = this.S.s3(this, file, C5());
        if (s3.a()) {
            pp.b0(this, s3.b(this), new Object[0]);
        } else {
            fn fnVar = (fn) s3.c;
            k6(b2.a.Task);
            int H = this.S.H(fnVar.P0());
            if (H != C5()) {
                gd(H);
            }
            Y4(fnVar.P0());
        }
        return s3;
    }

    public void G8(com.joaomgcd.taskerm.util.we weVar) throws Exception {
        if (!weVar.b()) {
            com.joaomgcd.taskerm.util.h3 c2 = weVar.c();
            pp.d0(this, c2 == null ? "Unknown error" : c2.getErrorMessage(), new Object[0]);
            return;
        }
        try {
            this.S.r1(this, GenericActionBackupToGoogleDrive.getTAG(), (String) weVar.d(), true);
            C7(null);
            i6();
            Ta();
        } catch (Throwable th2) {
            xg.e2.R1(this, th2);
        }
    }

    public void G9(View view, final int i2, int i3, pi piVar, fh fhVar) {
        if (fhVar.v()) {
            return;
        }
        u1 u1Var = u1.values()[fhVar.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 g5 = this.S.g5(Da(i2));
                Ia();
                J6(false, false, false, b2.a.values());
                if (g5) {
                    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.r rVar = this.f0;
                rVar.q0(rVar.B3(i2, u1Var == u1.ShiftLeft, this.I.x()), new yi.d() {
                    @Override
                    public final void accept(Object obj) {
                        Main.this.F9(i2, (Integer) obj);
                    }
                });
                break;
            case 10:
                this.f0.G3();
                break;
            case 11:
                this.f0.W4(i3, piVar);
                break;
        }
    }

    private void Ga(final boolean z2, final String str) {
        final com.joaomgcd.taskerm.dialog.b q2 = com.joaomgcd.taskerm.dialog.b.q(this, 2131887129, false);
        this.f0.E(new Runnable() {
            @Override
            public final void run() {
                Main.this.W8(str, z2, q2);
            }
        });
    }

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

    public boolean Gc() {
        return this.f0.s2(2131890870, new ik.a() {
            @Override
            public final Object e() {
                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.f1(getPackageManager(), Da, z2);
        this.x.E(C5(), y6(), false);
        L6(b2.a.values());
    }

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

    private void H7(s6 s6Var) {
        fo foVar = this.Z;
        if (foVar == null) {
            MyActivity.L(this, "initKeyStoreOrLaunchFactory appExportData null");
            return;
        }
        foVar.u2(0, "ikslf").m0(s6Var);
        if (this.Y.getClass().equals(fn.class)) {
            ((fn) this.Y).x2(s6Var);
        } else {
            ((pi) this.Y).m0(s6Var);
        }
        Ta();
        if (ch.n(this)) {
            o7.f("T", "Spawn have user key");
            TextBoxDialogFragment.I(new d0(), com.joaomgcd.taskerm.util.b7.j6(2131889509, this, new Object[0]), null, com.joaomgcd.taskerm.util.b7.j6(2131886894, this, new Object[0]), com.joaomgcd.taskerm.util.b7.j6(2131886870, this, new Object[0]), null, 37, null, 128, null, null).E(this);
            return;
        }
        o7.f("T", "Spawn don't have user key");
        if (ch.m(this)) {
            o7.f("T", "Spawn have basic key");
            this.f0.z0(Y9("keystore.auto", "bl^!)*(!*{a", "ImACertPass"), new Runnable() {
                @Override
                public final void run() {
                    Main.this.p8();
                }
            });
            return;
        }
        o7.f("T", "Spawn don't have basic key");
        Intent h2 = ch.h(this);
        o7.f("T", "Spawn created basic intent for key store");
        if (h2 == null) {
            pp.a0(this, 2131887823, new Object[0]);
            w5("initkey3");
        } else {
            o7.f("T", "Spawn starting activity for cert");
            Ic(h2, 18);
            o7.f("T", "Spawn started activity for cert");
        }
    }

    public void H8(String str) {
        gi.j(this, 2131888829, "\nID:\t" + str + "\n\nSDK:\t" + pp.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(ki kiVar, mj mjVar) {
        if (!kiVar.f()) {
            String i2 = kiVar.i();
            boolean p2 = this.S.p(i2);
            b2.a aVar = b2.a.Scene;
            if (n5(i2, p2, aVar) && !TextUtils.isEmpty(i2)) {
                if (this.S.p(i2)) {
                    pp.a0(this, 2131887897, i2);
                } else {
                    mj B0 = mjVar.B0();
                    B0.C(i2);
                    B0.w0(this.S);
                    this.S.A0(B0, C5());
                    L6(aVar);
                    X4(B0.getName());
                }
            }
        }
        v();
    }

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

    public void Hb(io ioVar, sn snVar, View view) {
        ki kiVar = new ki(this, snVar.H0() ? snVar.getName() : null);
        int x2 = this.x.x(ioVar.C0());
        if (U4()) {
            kiVar.p(2131887410);
        }
        kiVar.l(q6(), x2);
        kiVar.o(new v0(ioVar, snVar, view)).u(j5(view, true), this.F, false);
    }

    private boolean Hc() {
        if (com.joaomgcd.taskerm.util.r.d(this)) {
            return this.f0.s2(2131888086, new ik.a() {
                @Override
                public final Object e() {
                    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(sn snVar, List<Object> list) {
        io ioVar = (io) list.remove(0);
        Qa(b2.a.Profile, "handleCSR");
        int F0 = snVar.F0();
        this.W = F0;
        Kc(ioVar, F0, false);
    }

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

    public void I9(ki kiVar, fn fnVar) {
        if (!kiVar.f()) {
            String i2 = kiVar.i();
            if (!TextUtils.isEmpty(i2)) {
                if (this.S.S3(i2)) {
                    pp.a0(this, 2131888526, new Object[0]);
                } else {
                    fn q02 = fnVar.q0();
                    q02.t2(-1);
                    q02.C(i2);
                    this.S.D0(q02, C5());
                    q02.X1();
                    L6(b2.a.Task);
                    Y4(q02.P0());
                }
            }
        }
        v();
    }

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

    private void Ib(io ioVar, int i2, View view, int i3) {
        fh fhVar = new fh(this, view);
        if (ioVar.m1() < 4) {
            fhVar.k(n1.Add.ordinal(), 2131889446, 2130969155);
        }
        if (!Settings.j1(this.M)) {
            fhVar.k(n1.Clone.ordinal(), 2131888808, 2130969183);
        }
        fhVar.k(n1.Delete.ordinal(), 2131888822, 2130969299);
        fhVar.k(n1.Name.ordinal(), ioVar.T0(i2).H0() ? 2131888962 : 2131889804, 2130969235);
        fhVar.F(new m0(view, ioVar, i2)).show();
    }

    public void J6(boolean z2, boolean z3, boolean z4, b2.a... aVarArr) {
        xg.e2.b1(new q(z2, aVarArr, z3, z4));
    }

    public void J7() {
        fo foVar = this.S;
        if (foVar == null) {
            return;
        }
        foVar.y3(this, true);
    }

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

    private void Ja() {
        if (z7() && B7() && this.e0 != null) {
            o7.f("T", "remove monitor listener");
            MonitorService u6 = u6("rmsl");
            if (u6 != null) {
                u6.g8(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;
            }
            io ioVar = this.U;
            if (ioVar == null || !ioVar.Z0(i2)) {
                if (sn.M0(i2)) {
                    z2 = i4 <= 0;
                    i4++;
                }
                if (z2) {
                    strArr[i3] = sn.E0(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 (sn.E0(resources, i8).equals(str)) {
                    iArr[i7] = sn.y0(i8);
                    iArr2[i7] = i8;
                    break;
                }
                i8++;
            }
        }
        io ioVar2 = this.U;
        if (ioVar2 != null && ioVar2.I0() != 0) {
            z2 = false;
        }
        if (view == null) {
            view = this.K;
        }
        fh fhVar = new fh(this, view);
        for (int i9 = 0; i9 < i3; i9++) {
            fhVar.n(iArr2[i9], strArr2[i9], iArr[i9]);
        }
        if (z2 && U4()) {
            fhVar.G(2131887075);
        }
        fhVar.F(new f0(view)).show();
    }

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

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

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

    public void K8(com.joaomgcd.taskerm.util.pe peVar) throws Exception {
        String string = getString(2131890741);
        if (!peVar.b()) {
            string = getString(2131890742);
        }
        com.joaomgcd.taskerm.util.l7.e1(string, this);
    }

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

    private ti.r<Boolean> Ka() {
        if (!com.joaomgcd.taskerm.settings.d1.g(this)) {
            return ti.r.w(Boolean.TRUE);
        }
        Yb(true);
        return this.f0.W(new ik.a() {
            @Override
            public final Object e() {
                ti.r Z8;
                Z8 = Main.this.Z8();
                return Z8;
            }
        });
    }

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

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

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

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

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

    public static void L9(fh fhVar) {
        fhVar.I();
        fhVar.K();
    }

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

    public void Lb(View view) {
        fh fhVar = new fh(this, view);
        if (MonitorService.d2(this)) {
            fhVar.k(o1.Disable.ordinal(), 2131888831, 2130969289);
        } else {
            fhVar.k(o1.Enable.ordinal(), 2131888853, 2130969288);
        }
        fhVar.F(new g0()).show();
    }

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

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

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

    private boolean M7() {
        b2.a A5 = A5();
        return (A5 == b2.a.Task && (B6() == fn.f.User || B6() == fn.f.UserReverse)) || (A5 == b2.a.Scene && z6() == mj.i.User) || (A5 == b2.a.Profile && y6() == io.b.User);
    }

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

    public void M9(io ioVar, w1 w1Var, View view, int i2, fh fhVar) {
        if (fhVar.v()) {
            if (ioVar.P0() == 0) {
                TextBoxDialogFragment.a0(this, new k1(ioVar, w1Var, view, i2), oh.g(this, 2131887184, new Object[0]));
                return;
            }
            return;
        }
        int A = fhVar.A();
        if (A != 934524) {
            ioVar.F1(i2, A);
            L6(b2.a.Profile);
        } else {
            this.U = ioVar;
            this.W = i2;
            fc(b2.a.Task, view, this.x.x(ioVar.C0()), null, -fp.Y(10));
        }
    }

    public boolean Ma(Context context, File file, String str, boolean z2) {
        boolean t4 = this.S.t4(context, file, str, z2, false, true);
        boolean z3 = false;
        if (t4) {
            if (ch.o(this)) {
                pp.j0(this, 2131890237, new Object[0]);
            } else {
                pp.j0(this, 2131887824, new Object[0]);
            }
            C7(file);
            i6();
            z3 = true;
        } else {
            pp.a0(this, 2131891100, new Object[0]);
        }
        Ta();
        return z3;
    }

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

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

    private void N5(final Runnable runnable) {
        if (m6()) {
            runnable.run();
        }
        this.g0 = false;
        if (ep.l0(this)) {
            this.f0.q0(com.joaomgcd.taskerm.dialog.a.p2(this), new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.W7(runnable, (df.p1) 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.z2(q1.DescrToEmail, new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.e8((we.l) obj);
                }
            });
        }
    }

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

    public void N9(ArrayList arrayList, int i2, fh fhVar, int i3, int i4, ArrayList arrayList2, int i5, final w1 w1Var, final int i6, final io ioVar, final View view) {
        int P0;
        int i7 = this.N.getInt("lTsk", -1);
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            fn fnVar = (fn) it.next();
            int P02 = fnVar.P0();
            if (P02 != i2) {
                fhVar.r(P02, fnVar.getName(), fnVar.Q0(this, i3), i4, P02 == i7 ? fh.d.Top : fh.d.Bottom);
            }
        }
        Iterator it2 = arrayList2.iterator();
        while (it2.hasNext()) {
            fn fnVar2 = (fn) it2.next();
            if (!arrayList.contains(fnVar2) && (P0 = fnVar2.P0()) != i2) {
                fhVar.r(P0, fnVar2.getName(), fnVar2.Q0(this, i3), i5, P0 == i7 ? fh.d.Top : fh.d.Bottom);
            }
        }
        Drawable H = fp.H(this, 2130969155);
        gp.w(H, gp.f(this));
        fhVar.r(934524, oh.g(this, 2131887398, "T"), H, 0, fh.d.Top);
        if (U4() && w1Var == w1.ProfileAddOfType) {
            StringBuilder sb = new StringBuilder();
            sb.append(oh.g(this, i6 == 0 ? 2131891185 : 2131891192, new Object[0]));
            sb.append(" ");
            sb.append(oh.g(this, 2131891280, new Object[0]));
            fhVar.H(sb.toString());
        }
        if (fhVar.y() > 1) {
            fhVar.E(i7, true, true);
        }
        fhVar.F(new fh.f() {
            @Override
            public final void a(fh fhVar2) {
                Main.this.M9(ioVar, w1Var, view, i6, fhVar2);
            }
        }).J(TextUtils.TruncateAt.MIDDLE);
    }

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

    private void Nc(io ioVar, j2 j2Var) {
        if (j2Var != null && i2.X(j2Var.j())) {
            ji.c cVar = ji.c.Event;
            if (!ji.T(cVar, j2Var.j())) {
                gi.t(this, j2Var, cVar, 1, 2);
                return;
            }
        }
        Intent intent = new Intent(this, (Class<?>) EventEdit.class);
        intent.addFlags(67108864);
        if (j2Var != null) {
            intent.putExtra("scntxt", j2Var.X(0).c0());
        }
        wp.f(this, this.S, null, intent, null, ioVar, Integer.valueOf(C5()));
        Ic(intent, 4);
    }

    private boolean O5(Runnable runnable) {
        if (com.joaomgcd.taskerm.util.ac.f0(this, 121).h0()) {
            runnable.run();
            return true;
        }
        Va("reqPermsDialog", true);
        return this.f0.B2(com.joaomgcd.taskerm.util.ac.f0(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.n4();
    }

    public void O9(final fh fhVar, final io ioVar, final int i2, final w1 w1Var, final View view, com.joaomgcd.taskerm.dialog.b bVar) {
        try {
            try {
                this.f0.F(new Runnable() {
                    @Override
                    public final void run() {
                        Main.L9(fh.this);
                    }
                });
                int C5 = C5();
                fo foVar = this.S;
                fn.f fVar = fn.f.Alpha;
                final ArrayList<fn> K = foVar.K(C5, fVar);
                final ArrayList<fn> K2 = this.S.K(-2, fVar);
                final int Q0 = ioVar.Q0(i2);
                int L = fp.L(this);
                final int argb = Color.argb(110, Color.red(L), Color.green(L), Color.blue(L));
                final int b2 = gp.b(this);
                final int i3 = 0;
                this.f0.F(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.N9(K, Q0, fhVar, b2, i3, K2, argb, w1Var, i2, ioVar, view);
                    }
                });
                com.joaomgcd.taskerm.helper.r rVar = this.f0;
                Objects.requireNonNull(fhVar);
                rVar.F(new Runnable() {
                    @Override
                    public final void run() {
                        fh.this.show();
                    }
                });
            } catch (NullPointerException unused) {
                com.joaomgcd.taskerm.util.l7.c1(getString(2131890740), this);
            } catch (Exception e2) {
                xg.e2.R1(this, e2);
            }
        } finally {
            bVar.f();
        }
    }

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

    public void Ob(View view, b2 b2Var, boolean z2, int i2) {
        ki kiVar = new ki(this, b2Var.x() ? b2Var.getName() : null);
        kiVar.setOnDismissListener(new t0(kiVar, b2Var, view, z2, i2));
        if (i2 != -1) {
            kiVar.l(q6(), i2);
        }
        kiVar.v(j5(view, z2), z2);
    }

    private void Oc() {
        fo foVar = this.Z;
        if (foVar != null) {
            pi u2 = foVar.u2(0, "skk");
            s6 l2 = u2.l();
            if (l2 != null) {
                l2.A();
            }
            if (!U4() || u2.o() != 1) {
                Intent putExtra = new Intent(this, (Class<?>) KidConfig.class).putExtra("d", or.d(this.Z.X(0).e0(0)));
                com.joaomgcd.taskerm.util.t2.g(putExtra);
                Ic(putExtra, 15);
                return;
            }
            if (l2 == null) {
                l2 = new s6();
                l2.Q();
                l2.I(u2.J().get(0).intValue());
            }
            l2.V();
            H7(l2);
        }
    }

    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.e1(i2);
        }
        pp.j0(this, 2131888723, new Object[0]);
        L6(b2.a.Profile);
        v();
    }

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

    public void P8(b2.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(b2.a.Profile, v2, -1, null);
                return;
            } else {
                Jb(v2);
                return;
            }
        }
        if (i2 == 2) {
            this.U = null;
            this.W = 2;
            ec(b2.a.Task, v2, -1, null);
        } else if (i2 == 3) {
            ec(b2.a.Scene, v2, -1, null);
        } else {
            if (i2 != 4) {
                return;
            }
            ec(b2.a.Variable, v2, -1, null);
        }
    }

    public void P9(final View view, final io ioVar, final int i2, final w1 w1Var, final com.joaomgcd.taskerm.dialog.b bVar) {
        final fh fhVar = new fh(this, view);
        this.f0.N(new Runnable() {
            @Override
            public final void run() {
                Main.this.O9(fhVar, ioVar, i2, w1Var, view, bVar);
            }
        });
    }

    private void Pa(int i2, String str) {
        int count;
        v1 v1Var = this.Q;
        if (v1Var == null) {
            o7.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 {
            o7.k("T", "selectEntityTab: " + str + ": no view pager");
        }
    }

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

    public void Q5() {
        ToggleButton toggleButton;
        up.b[] values = up.b.values();
        int length = values.length;
        for (int i2 = 0; i2 < length; i2++) {
            up.b bVar = values[i2];
            boolean z2 = D5() == 0 || bVar != up.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.h1(getPackageManager(), str);
        }
        pp.j0(this, 2131888723, new Object[0]);
        v();
        L6(b2.a.Scene);
    }

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

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

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

    public void Qb(View view, final List<Object> list) {
        fh fhVar = new fh(this, j5(view, true));
        final b2.a e2 = ((b2) list.get(0)).e();
        boolean z2 = list.size() == 1;
        boolean z3 = e2 != b2.a.Scene;
        if (z3) {
            fhVar.l(q1.ToLink.ordinal(), 2131888869, 2130969304, fh.d.Top);
        }
        if (e2 == b2.a.Task && z2) {
            fhVar.l(q1.AsApp.ordinal(), 2131888865, 2130969177, fh.d.Bottom);
        }
        int ordinal = q1.DescrToClip.ordinal();
        fh.d dVar = fh.d.Bottom;
        fhVar.l(ordinal, 2131888867, 2130969171, dVar);
        fhVar.l(q1.DescrToEmail.ordinal(), 2131888866, 2130969198, dVar);
        fhVar.l(q1.XmlToEmail.ordinal(), 2131888870, 2130969198, dVar);
        fhVar.l(q1.XmlToClip.ordinal(), 2131888871, 2130969171, dVar);
        fhVar.l(q1.XmlToSD.ordinal(), 2131888872, 2130969264, dVar);
        if (z3) {
            fhVar.l(q1.ToUri.ordinal(), 2131888868, 2130969304, dVar);
        }
        fhVar.F(new fh.f() {
            @Override
            public final void a(fh fhVar2) {
                Main.this.l9(e2, list, fhVar2);
            }
        });
        try {
            fhVar.show();
        } catch (Exception e3) {
            pp.b0(this, "showing export menu", new Object[0]);
            o7.l("T", "error showing export menu", e3);
        }
    }

    private void Qc(io ioVar) {
        n7 n7Var = ioVar == null ? null : (n7) ioVar.T0(3);
        int C0 = ioVar == null ? -1 : ioVar.C0();
        Intent intent = new Intent(this, (Class<?>) LocSelect.class);
        intent.addFlags(67108864);
        List<io> I2 = this.S.I2(null, 3);
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i2 = 0; i2 < I2.size(); i2++) {
            io ioVar2 = I2.get(i2);
            n7 n7Var2 = (n7) ioVar2.T0(3);
            if (C0 != ioVar2.C0()) {
                String e02 = n7Var2.X(0).e0(0);
                if (e02 == null) {
                    o7.G("T", "failed to pack loc context");
                } else {
                    arrayList.add(e02);
                }
            }
        }
        if (arrayList.size() > 0) {
            intent.putStringArrayListExtra("olcntxt", arrayList);
        }
        if (n7Var != null) {
            intent.putExtra("scntxt", n7Var.X(0).c0());
        }
        Ic(intent, 5);
    }

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

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

    public void R6(io ioVar, int i2) {
        this.S.j1(this, ioVar, i2);
        this.S.F4(ioVar);
        K6(false, b2.a.Profile);
    }

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

    public void R9() {
        if (new GenericActionActivityConfigureNotificationChannel("quick", Boolean.FALSE).run(this).f().b()) {
            com.joaomgcd.taskerm.dialog.a.S3(this, 2131890883, "Great! You won't get any more useless notifications!").f();
        } else {
            com.joaomgcd.taskerm.dialog.a.S3(this, 2131890883, "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();
        }
        qg.b.b(this);
    }

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

    public void Rb(final io ioVar, boolean z2) {
        final Runnable runnable = new Runnable() {
            @Override
            public final void run() {
                Main.this.n9(ioVar);
            }
        };
        if (z2 || this.f0.z4()) {
            xg.e2.U0(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 (gl.R(str)) {
            i3 |= 48;
        }
        if (i3 != 0) {
            intent.putExtra("flags", i3);
        }
        intent.putExtra("projectid", C5());
        Ic(intent, 11);
    }

    private void S4() {
        xg.e2.b1(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(), 2131887483, null, 2131886894, 2131886870, -1, 229).E(this);
                return true;
            case 36:
                TextBoxDialogFragment.Y(this, new k0(), 2131887168);
                return true;
            case 37:
                if (fo.l5("capabilities.xml") != null) {
                    pp.j0(this, 2131886894, new Object[0]);
                }
                return true;
            case 38:
                if (fo.m5(this.O, "datadef.xml", true) != null) {
                    pp.j0(this, 2131886894, new Object[0]);
                }
                return true;
            case 39:
                sd();
                return true;
            case 40:
                if (ch.k(this).exists()) {
                    TextBoxDialogFragment.Y(this, new i0(), 2131887167);
                } else {
                    Lc();
                }
                return true;
            default:
                return false;
        }
    }

    public void S7(Main main, b2.a aVar) {
        com.joaomgcd.taskerm.util.h0 h0Var = new com.joaomgcd.taskerm.util.h0(main, 2131890743, new Object[0]);
        if (((df.p1) com.joaomgcd.taskerm.dialog.a.T1(main, h0Var, new com.joaomgcd.taskerm.util.h0(main, 2131888301, com.joaomgcd.taskerm.util.b7.j6(aVar.d(), main, new Object[0])), h0Var, new com.joaomgcd.taskerm.util.h0(main, 2131887087, new Object[0]), new com.joaomgcd.taskerm.util.g0("importfromtaskernetonnew")).f()).o()) {
            this.f0.x4();
        } else {
            if (this.f0.s4(true).f().booleanValue()) {
                return;
            }
            Fa(aVar);
        }
    }

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

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

    private boolean Sb() {
        return this.f0.s2(2131890897, new ik.a() {
            @Override
            public final Object e() {
                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 b2.a T5(int i2) {
        return b2.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.z3()) {
                fo.B4(fo.g.Passive, true);
                if (l6(8)) {
                    return;
                }
                y5(2);
                return;
            }
            if (Na(false)) {
                d5();
            } else {
                atomicBoolean.set(false);
                y5(2);
            }
        }
    }

    public void T9(rp rpVar, ki kiVar) {
        if (kiVar.f() || !kiVar.g()) {
            return;
        }
        String name = rpVar.getName();
        String i2 = kiVar.i();
        wp.T1(this, name, i2, "showVV");
        this.f0.E3(name, i2);
        L6(b2.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;
            }
            io ioVar = (io) this.x.getItem(this.b0);
            if (ioVar != null) {
                p5(new int[]{ioVar.C0()});
                return;
            }
            return;
        }
        if (i2 != 2) {
            if (i2 != 3) {
                return;
            }
            if (this.x.n()) {
                h5(Oa(this.y.g()));
                return;
            } else {
                h5(new String[]{((mj) this.y.getItem(this.b0)).getName()});
                return;
            }
        }
        if (this.x.n()) {
            t5(hd(this.z.g()));
            return;
        }
        fn fnVar = (fn) this.z.getItem(this.b0);
        if (fnVar != null) {
            t5(new int[]{fnVar.P0()});
            return;
        }
        o7.G("T", "handleDropOnBin: no task at position " + this.b0);
    }

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

    public void U8(com.joaomgcd.taskerm.dialog.b bVar, Boolean bool) throws Exception {
        bVar.f();
        finish();
    }

    private void Ua(int i2, ListView listView, String str) {
        this.b0 = this.f0.I3(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) {
                qg.i(this, this.E, 2130772038, 0L, 200L, new x(z5));
            } else {
                this.E.setVisibility(0);
                qg.i(this, this.E, 2130772031, 0L, 200L, new w(z5));
            }
        }
    }

    private void Uc(io ioVar, bn bnVar) {
        if (bnVar != null && an.O(bnVar.j())) {
            ji.c cVar = ji.c.Condition;
            if (!ji.T(cVar, bnVar.j())) {
                gi.t(this, bnVar, cVar, 1, 2);
                return;
            }
        }
        Intent intent = new Intent(this, (Class<?>) StateEdit.class);
        intent.addFlags(67108864);
        if (bnVar != null) {
            intent.putExtra("scntxt", bnVar.X(0).c0());
        }
        wp.f(this, this.S, null, intent, null, ioVar, Integer.valueOf(C5()));
        Ic(intent, 6);
    }

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

    public void V5(final boolean z2, final String str) {
        o7.A("T", "exit/" + str);
        if (!str.equals("leaveHint") && !str.equals("back")) {
            Ga(z2, str);
        } else if (this.f0.g4()) {
            this.f0.a4();
        } else {
            this.f0.q0(cc(z2, str), new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.X7(z2, str, (r.a) obj);
                }
            });
        }
    }

    private boolean V6(ListView listView, float f2, float f3) {
        boolean z2 = false;
        if (M7()) {
            int d02 = jl.d0(listView, (int) f2, (int) f3);
            int count = listView.getCount();
            int firstVisiblePosition = d02 == -1 ? count - 1 : listView.getFirstVisiblePosition() + d02;
            if (N7()) {
                firstVisiblePosition = this.f0.I3(firstVisiblePosition, count);
            }
            if (firstVisiblePosition != this.b0) {
                if (y()) {
                    ja(A5(), firstVisiblePosition);
                } else {
                    int i2 = i1.b[A5().ordinal()];
                    if (i2 == 1) {
                        this.S.V3(((io) this.x.getItem(this.b0)).C0(), C5(), firstVisiblePosition);
                    } else if (i2 == 2) {
                        fn fnVar = (fn) this.z.getItem(this.b0);
                        if (fnVar == null) {
                            o7.G("T", "handleDropOnList: no task at pos " + this.b0);
                        } else {
                            this.S.a4(fnVar.P0(), C5(), firstVisiblePosition);
                        }
                    } else if (i2 == 3) {
                        this.S.Y3(((mj) this.y.getItem(this.b0)).getName(), C5(), firstVisiblePosition);
                    }
                }
            }
            K6(false, A5());
            z2 = true;
        }
        v();
        return z2;
    }

    public void V7(final com.joaomgcd.taskerm.dialog.b bVar) {
        fo w4 = this.S.w4(this);
        this.S = w4;
        if (!w4.z3() || !this.S.G4(this, this.M, this.O, t0, true, true)) {
            bVar.f();
            return;
        }
        fo w12 = fo.w1(this);
        this.S = w12;
        fo.Z4(fo.g.Passive, w12);
        t0 = System.currentTimeMillis();
        d5();
        System.gc();
        if (MonitorService.d2(this)) {
            MonitorService.m8(this, true);
            y5(2);
        }
        this.f0.F(new Runnable() {
            @Override
            public final void run() {
                Main.this.T7();
            }
        });
        gm.i(this, false);
        ti.r<Boolean> n2 = Ka().n(new yi.a() {
            @Override
            public final void run() {
                Main.this.U7();
            }
        });
        Objects.requireNonNull(bVar);
        ed(n2.n(new yi.a() {
            @Override
            public final void run() {
                bVar.f();
            }
        }));
    }

    public void V8(String str, final boolean z2, final com.joaomgcd.taskerm.dialog.b bVar) {
        TaskerApp.V("stopLicenceHandler ", new Runnable() {
            @Override
            public final void run() {
                Main.this.Q8();
            }
        });
        TaskerApp.V("stopVariableReceiver ", new Runnable() {
            @Override
            public final void run() {
                Main.this.R8();
            }
        });
        TaskerApp.V("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.z3()) {
            Ya(2);
        }
        o7.f("T", "EXIT: from " + str + ": save: " + z2 + " dirty: " + this.S.z3() + " must save: " + l6(64) + " prefsDirty: " + l6(8) + " need mrestart: " + l6(2));
        TaskerApp.V("saveData ", new Runnable() {
            @Override
            public final void run() {
                Main.this.T8(z2, atomicBoolean);
            }
        });
        this.f0.r4();
        t0 = -1L;
        if (atomicBoolean.get()) {
            fo.B4(fo.g.Passive, false);
        }
        System.gc();
        MonitorService.m8(this, l6(2));
        Va("exit", false);
        if (!m6()) {
            ep.o0("Main reallyexit");
        }
        if (isFinishing()) {
            bVar.f();
        } else if (str.equals("leaveHint") || str.equals("back")) {
            fd(Ka(), new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.U8(bVar, (Boolean) obj);
                }
            });
            o7.F("T", "dont finish, requesting permissions");
            return;
        } else {
            bVar.f();
            finish();
        }
        bb(false, "exit");
    }

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

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

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

    public void W4(ListView listView, int i2) {
        ni niVar = this.x;
        if (niVar != null && A5() == b2.a.Profile) {
            for (int i3 = 0; i3 < niVar.getCount(); i3++) {
                io ioVar = (io) niVar.getItem(i3);
                if (ioVar != null && ioVar.C0() == i2) {
                    pp.x(listView, i3);
                    return;
                }
            }
        }
    }

    public void W5(int i2) {
        this.f0.b4();
        io 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()) {
            int C5 = C5();
            int Da = Da(y2);
            int i2 = i1.b[A5().ordinal()];
            if (i2 == 1) {
                if (y()) {
                    ka(C5, Da);
                } else {
                    int C0 = ((io) this.x.getItem(this.b0)).C0();
                    this.S.z4(C5, C0);
                    this.S.y0(C0, Da);
                }
                K6(false, b2.a.Profile);
            } else if (i2 == 2) {
                if (y()) {
                    ma(C5, Da);
                } else {
                    fn fnVar = (fn) this.z.getItem(this.b0);
                    if (fnVar == null) {
                        o7.G("T", "handleDropOnProject: no task at position " + this.b0);
                    } else {
                        int P0 = fnVar.P0();
                        this.S.C4(C5, P0);
                        this.S.F0(P0, Da);
                    }
                }
                K6(false, b2.a.Profile, b2.a.Task);
            } else if (i2 == 3) {
                if (y()) {
                    la = la(C5, Da);
                    z2 = false;
                } else {
                    String name = ((mj) this.y.getItem(this.b0)).getName();
                    if (gl.P(name)) {
                        la = 0;
                        z2 = true;
                    } else {
                        this.S.A4(C5, name);
                        this.S.B0(name, Da);
                        z2 = false;
                        la = 1;
                    }
                }
                if (la > 0) {
                    K6(false, b2.a.Scene);
                }
                if (z2) {
                    pp.n0(this, 2131887784, new Object[0]);
                }
            }
            K6(false, b2.a.Variable);
        }
        return true;
    }

    public void W7(Runnable runnable, df.p1 p1Var) throws Exception {
        this.g0 = true;
        if (p1Var.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.b bVar) {
        TaskerApp.V("Main really exit ", new Runnable() {
            @Override
            public final void run() {
                Main.this.V8(str, z2, bVar);
            }
        });
    }

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

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

    private void Wc(int i2, int i3, String str, int i4) {
        v();
        Intent intent = new Intent(this, this.f0.j4());
        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() == b2.a.Scene) {
            for (int i2 = 0; i2 < this.y.getCount(); i2++) {
                if (((mj) this.y.getItem(i2)).getName().equals(str)) {
                    pp.x(q6(), i2);
                    return;
                }
            }
        }
    }

    private boolean X5(fo foVar) {
        boolean z2 = false;
        net.dinglisch.android.taskerm.g icon = foVar.u2(0, "eaaa").getIcon();
        foVar.u4();
        if (!rm.d0(this)) {
            TextBoxDialogFragment.F(this, new k(), 2131887506, oh.g(this, 2131887258, oh.g(this, 2131891149, new Object[0]).toLowerCase(), "Tasker App Factory"), 2131886894, 2131886870, -1, 196).E(this);
        } else if (mh.y(getPackageManager(), "net.dinglisch.android.appfactory") < 5) {
            pp.a0(this, 2131887928, "Tasker App Factory");
        } else if (foVar.u3(134)) {
            pp.a0(this, 2131887825, net.dinglisch.android.taskerm.z0.v(134));
        } else if (foVar.A2(getPackageManager(), true).size() > 0) {
            pp.a0(this, 2131887801, new Object[0]);
        } else if (!icon.h0() && icon.g0() && oh.q(icon.I(this))) {
            pp.a0(this, 2131887799, new Object[0]);
        } else {
            z2 = true;
        }
        o7.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);
        fh fhVar = new fh(this, j5(this.J.v(i2), true));
        b2.a aVar = this.a0;
        boolean z2 = aVar == b2.a.Variable;
        b2.a aVar2 = b2.a.Scene;
        boolean z3 = aVar == aVar2;
        boolean z4 = aVar == b2.a.Profile;
        b2.a aVar3 = b2.a.Task;
        boolean z5 = aVar == aVar3;
        if (z2) {
            fhVar.k(p1.ClearAll.ordinal(), 2131888798, 2130969299);
            fhVar.k(p1.ToggleTools.ordinal(), 2131891195, qd() ? 2130969261 : 2130969155);
        } else {
            fhVar.k(p1.SetSort.ordinal(), 2131889014, 2130969278);
            int i3 = z4 ? 2131888903 : 2131888902;
            if (z5) {
                i3 = 2131888906;
            }
            if (z3) {
                i3 = 2131888905;
            }
            fhVar.k(p1.Import.ordinal(), i3, 2130969218);
        }
        if (this.a0 == aVar2 && fl.B() > 0) {
            fhVar.k(p1.ClearAll.ordinal(), 2131888827, 2130969284);
        }
        if (this.a0 == aVar3 && pp.L2(this, ExecuteService.class.getName())) {
            fhVar.k(p1.ClearAll.ordinal(), 2131886821, 2130969284);
        }
        fhVar.F(new s(i2)).show();
    }

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

    public ti.v X8(df.p1 p1Var) throws Exception {
        if (!p1Var.o()) {
            return ti.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(b2.a.Variable), z2);
            viewGroup.setVisibility(z2 ? 0 : 8);
        }
    }

    private boolean Xb() {
        if (com.joaomgcd.taskerm.util.bi.R() || vg.e.h(this)) {
            return false;
        }
        if ((this.S.d2() <= 10 && this.S.g2() <= 15) || this.S.e2() <= 3) {
            return false;
        }
        this.f0.m0(vg.e.e(this));
        return true;
    }

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

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

    private void Y5(f5 f5Var, boolean z2) {
        fo foVar = this.S;
        if (foVar == null) {
            return;
        }
        this.Y = f5Var;
        com.joaomgcd.taskerm.datashare.export.d.F0(this, f5Var, foVar, 32, z2);
    }

    public void Y6(sn snVar) {
        boolean z2;
        fo w6 = w6("handleFinishContextEdit");
        if (w6 == null) {
            return;
        }
        if (this.U == null) {
            this.U = w6.X1(getBaseContext());
            if (!TextUtils.isEmpty(this.V)) {
                this.U.C(this.V);
            }
            z2 = true;
        } else {
            z2 = false;
        }
        this.V = null;
        this.U.W(snVar);
        w6.F4(this.U);
        if (z2) {
            if (p6() >= 2) {
                w6.b1(C5());
            }
            w6.x0(this.U, C5());
            if (p6() >= 5) {
                this.U.t1(true);
            }
        }
        if (snVar.H0()) {
            w6.h5(snVar);
        }
        if (snVar.F0() == 3 && !snVar.H0()) {
            this.W = 3;
            dc(this.U, snVar, true);
        } else if (this.U.P0() == 0) {
            Rb(this.U, true);
        }
        L6(b2.a.Profile);
        if (z2) {
            W4(q6(), this.U.C0());
        }
        int F0 = snVar.F0();
        if (F0 == 4 || F0 == 5 || F0 == 6 || F0 == 7) {
            K6(false, b2.a.Variable);
        }
    }

    public void Y7(List list, q1 q1Var, we.l lVar) {
        String o2;
        Iterator it = list.iterator();
        StringBuilder sb = null;
        while (it.hasNext()) {
            io ioVar = (io) it.next();
            if (q1Var == q1.XmlToSD) {
                if (!d6(ioVar.getName(), this.S.n2(ioVar), io.A0(this.M), ".prf.xml")) {
                    return;
                }
            } else if (q1Var == q1.ToLink) {
                Y5(ioVar, false);
            } else if (q1Var == q1.ToUri) {
                Y5(ioVar, true);
            } else {
                if (q1Var == q1.DescrToClip || q1Var == q1.DescrToEmail) {
                    o2 = this.S.o2(ioVar, this, true, lVar);
                } else {
                    fo n2 = this.S.n2(ioVar);
                    o2 = n2 != null ? n2.E1(this, 2) : null;
                }
                if (sb == null) {
                    sb = new StringBuilder();
                } else {
                    sb.append("\n");
                }
                sb.append(o2);
            }
        }
        if (sb != null) {
            j6(sb.toString(), q1Var);
        }
        pp.j0(this, 2131886876, new Object[0]);
    }

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

    public ti.b Y9(final String str, final String str2, final String str3) {
        o7.f("T", "Launching app factory");
        final com.joaomgcd.taskerm.dialog.b p2 = com.joaomgcd.taskerm.dialog.b.p(this, 2131887306);
        return xg.e2.F0(new Runnable() {
            @Override
            public final void run() {
                Main.this.r8(str, str2, str3);
            }
        }).o(new yi.a() {
            @Override
            public final void run() {
                p2.f();
            }
        });
    }

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

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

    private void Yc(io ioVar, int i2, int i3, String str) {
        Intent intent = new Intent(this, this.f0.j4());
        this.W = i2;
        this.U = ioVar;
        intent.putExtra(ProfileManager.EXTRA_PROFILE_NAME, str);
        if (i3 == Integer.MIN_VALUE) {
            i3 = ioVar == null ? -1 : ioVar.Q0(i2);
        }
        intent.putExtra("son", ioVar != null);
        Bundle l02 = com.joaomgcd.taskerm.util.b7.l0(this.S, this, ioVar, null, "startTaskEditWithTaskIDFromProfile");
        if (ioVar != null && ioVar.i1(this, l02)) {
            i2 = 0;
        }
        intent.putExtra("amt", i2);
        intent.putExtra("tid", i3);
        intent.putExtra("projectid", C5());
        if (ioVar != null) {
            intent.putExtra("profileid", ioVar.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 e5 Z6(b2.a aVar, String str) {
        File file = new File(str);
        e5 e5Var = null;
        if (!file.isFile()) {
            pp.a0(this, 2131887900, new Object[0]);
            return null;
        }
        if (aVar == null) {
            return E7(file);
        }
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            e5Var = D7(file);
        } else if (i2 == 2) {
            e5Var = G7(file);
        } else if (i2 == 3) {
            e5Var = F7(file);
        }
        L6(b2.a.Variable);
        return e5Var;
    }

    public void Z7(pi piVar) {
        if (d6(piVar.getName(), this.S.x2(getPackageManager(), piVar), pi.k(this.M), ".prj.xml")) {
            pp.j0(this, 2131886876, new Object[0]);
        }
    }

    public ti.r Z8() {
        HashMap<String, List<String>> U1 = this.S.U1(this, TaskerAppWidgetConfigure.l(this), false, true);
        HashSet hashSet = new HashSet(U1.keySet());
        hashSet.remove("android.permission.WRITE_SECURE_SETTINGS");
        hashSet.remove("android.permission.ACCESS_SUPERUSER");
        if (com.joaomgcd.taskerm.util.r.x()) {
            hashSet.add("android.permission.POST_NOTIFICATIONS");
        }
        this.w = new com.joaomgcd.taskerm.util.ac(this, 123, hashSet);
        o7.F("T", "needed: " + pp.x3(pp.y3(hashSet)));
        return this.w.i0() ? ti.r.w(Boolean.FALSE) : nc(this.w.s0(), U1).t(new yi.e() {
            @Override
            public final Object a(Object obj) {
                ti.v X8;
                X8 = Main.this.X8((df.p1) obj);
                return X8;
            }
        }).n(new yi.a() {
            @Override
            public final void run() {
                Main.this.Y8();
            }
        });
    }

    private boolean Z9(String str) {
        try {
            fo L2 = fo.L2(fo.g.Passive, this, false);
            if (L2 != null) {
                this.S = L2;
            } else {
                fo j2 = fo.j2(this);
                this.S = j2;
                if (j2 == null) {
                    pp.n0(this, 2131891102, new Object[0]);
                } else {
                    o7.f("T", "loadData: p: " + this.S.e2());
                }
            }
        } catch (OutOfMemoryError unused) {
            pp.a0(this, 2131889325, new Object[0]);
            o7.k("T", "loadData: oom");
            System.exit(1);
        }
        if (this.S == null) {
            o7.G("T", str + "failed to load data, creating new");
            this.S = new fo();
        } else {
            o7.f("T", "loadData: done: p: " + this.S.e2());
        }
        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) {
        fh fhVar = new fh(this, view);
        List<String> L1 = this.S.L1(3);
        for (int i2 = 0; i2 < L1.size(); i2++) {
            fhVar.n(i2, L1.get(i2), 2130969180);
        }
        fhVar.I().l(9535435, 2131888936, 2130969155, fh.d.Top).F(new h0(L1)).G(2131887502).show();
    }

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

    public boolean a5(b2.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 we.l lVar) {
        O5(new Runnable() {
            @Override
            public final void run() {
                Main.this.Y7(list, q1Var, lVar);
            }
        });
    }

    public boolean a7(b2.a aVar, ListView listView, View view, DragEvent dragEvent) {
        jl jlVar;
        if (dragEvent == null) {
            o7.G("T", "handleListDrag: null event");
        } else {
            int action = dragEvent.getAction();
            if (action == 1) {
                if (aVar == A5()) {
                    jl.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 && (jlVar = this.v) != null) {
                    jlVar.S(listView, dragEvent.getY(), 0);
                }
            } else if (this.v != null && M7() && jl.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, df.p1 p1Var) throws Exception {
        if (p1Var.o()) {
            com.joaomgcd.taskerm.util.ph.W0(file, this, true, "Share File To");
        }
    }

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

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

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

    private void ac(boolean z2, int i2, r.b bVar) {
        bc(z2, i2, bVar, null);
    }

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

    private boolean b5() {
        if (this.S.d2() > 3) {
            return Settings.j1(this.M) ? xo.d(this, 2131890866) : xo.d(this, 2131890984);
        }
        return false;
    }

    private void b6(pi piVar) {
        fo V = rm.V(this, this.S, piVar, null);
        if (X5(V)) {
            if (!piVar.V(this)) {
                this.f0.w2(2131887891);
            } else if (V.K(0, fn.f.Alpha).size() == 0) {
                this.f0.w2(2131887838);
            } else {
                i5(V, piVar);
            }
        }
    }

    private void b7(h7 h7Var, List<Object> list) {
        Object remove = list.remove(0);
        if (remove.getClass() == net.dinglisch.android.taskerm.c.class) {
            y7((fn) list.remove(0), (net.dinglisch.android.taskerm.c) remove, list);
        } else if (remove.getClass() == bk.class || remove.getClass() == pk.class || remove.getClass() == lk.class) {
            t7((mj) list.remove(0), (zj) remove);
        }
    }

    public void b8(List list, q1 q1Var) {
        String D2;
        Iterator it = list.iterator();
        StringBuilder sb = null;
        while (it.hasNext()) {
            mj mjVar = (mj) it.next();
            if (q1Var != q1.XmlToSD) {
                if (q1Var == q1.DescrToClip || q1Var == q1.DescrToEmail) {
                    D2 = this.S.D2(mjVar, this.O);
                } else {
                    fo C2 = this.S.C2(mjVar);
                    D2 = C2 != null ? C2.E1(this, 2) : null;
                }
                if (sb == null) {
                    sb = new StringBuilder();
                } else {
                    sb.append("\n");
                }
                sb.append(D2);
            } else if (!d6(mjVar.getName(), this.S.C2(mjVar), mj.i1(), ".scn.xml")) {
                return;
            }
        }
        if (sb != null) {
            j6(sb.toString(), q1Var);
        }
        pp.j0(this, 2131886876, new Object[0]);
    }

    public void b9(final List list) {
        xg.e2.b1(new Runnable() {
            @Override
            public final void run() {
                Main.this.a9(list);
            }
        });
    }

    private void ba(Menu menu) {
        if (MyAccessibilityService.a()) {
            menu.add(0, 57, 0, oh.g(this, 2131886298, new Object[0]));
        }
        menu.add(0, 62, 0, oh.g(this, 2131888760, new Object[0]));
        menu.add(0, 59, 0, oh.g(this, 2131888757, new Object[0]));
        if (od.i()) {
            menu.add(0, 61, 0, oh.g(this, 2131888759, new Object[0]));
        }
        if (d4.Z() && ud.z.b()) {
            menu.add(0, 55, 0, oh.g(this, 2131888888, new Object[0]));
        }
        if (pp.g() >= 22) {
            menu.add(0, 56, 0, oh.g(this, 2131888758, new Object[0]));
        }
        if (pp.S1()) {
            menu.add(0, 64, 0, oh.g(this, 2131888755, new Object[0]));
            menu.add(0, 58, 0, oh.g(this, 2131890658, new Object[0]));
        }
        menu.add(0, 63, 0, oh.g(this, 2131888762, new Object[0]));
        if (od.l()) {
            menu.add(0, 60, 0, oh.g(this, 2131888763, new Object[0]));
        }
        if (od.l()) {
            menu.add(0, 80, 0, oh.g(this, 2131888756, new Object[0]));
        }
        if (com.joaomgcd.taskerm.util.r.u()) {
            menu.add(0, 69, 0, oh.g(this, 2131888764, new Object[0]));
        }
        if (com.joaomgcd.taskerm.util.r.v()) {
            menu.add(0, 73, 0, oh.g(this, 2131888923, new Object[0]));
        }
    }

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

    private void bc(boolean z2, int i2, r.b bVar, Runnable runnable) {
        if (v0) {
            return;
        }
        v0 = true;
        ep.t0(this, new q0(z2, i2, bVar, 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.z3()) {
            TextBoxDialogFragment.F(this, new j(), 2131887066, oh.g(this, 2131887166, new Object[0]), 2131886798, 2131886870, 2131886815, 260).E(this);
            return false;
        }
        if (!l6(8)) {
            y5(2);
        }
        V5(false, "checkcancel");
        return true;
    }

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

    public void c8(List list, q1 q1Var, we.l lVar) throws Exception {
        String P2;
        Iterator it = list.iterator();
        boolean z2 = true;
        StringBuilder sb = null;
        while (it.hasNext()) {
            fn fnVar = (fn) it.next();
            if (q1Var == q1.AsApp) {
                f6(fnVar);
            } else if (q1Var == q1.ToLink) {
                Y5(fnVar, false);
            } else if (q1Var == q1.ToUri) {
                Y5(fnVar, true);
            } else if (q1Var != q1.XmlToSD) {
                if (q1Var == q1.DescrToClip || q1Var == q1.DescrToEmail) {
                    P2 = this.S.P2(this, fnVar, this.O, lVar);
                } else {
                    fo O2 = fo.O2(fnVar);
                    P2 = O2 != null ? O2.E1(this, 2) : null;
                }
                if (sb == null) {
                    sb = new StringBuilder();
                } else {
                    sb.append("\n");
                }
                sb.append(P2);
            } else if (!d6(fnVar.getName(), fo.O2(fnVar), fn.L0(), ".tsk.xml")) {
                return;
            }
            z2 = false;
        }
        if (sb != null) {
            j6(sb.toString(), q1Var);
        }
        if (z2) {
            pp.j0(this, 2131886876, new Object[0]);
        }
    }

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

    private void ca(Menu menu) {
        menu.add(0, 66, 0, oh.g(this, 2131891244, new Object[0]));
        menu.add(0, 67, 0, oh.g(this, 2131891281, new Object[0]));
        menu.add(0, 68, 0, oh.g(this, 2131891247, new Object[0]));
        menu.add(0, 72, 0, oh.g(this, 2131891301, 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.e2() || i3 < 0) {
            o7.k("T", "sip: bad project: " + i3 + ", resetting to 0");
        } else {
            i2 = i3;
        }
        this.I.S(i2);
    }

    private ti.r<r.a> cc(boolean z2, String str) {
        return xg.e2.e2(xg.e2.y1(new ik.a() {
            @Override
            public final Object e() {
                r.a t9;
                t9 = Main.this.t9();
                return t9;
            }
        }));
    }

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

    private boolean d6(String str, fo foVar, File file, String str2) {
        String str3 = pp.H3(str) + str2;
        final File file2 = new File(file, str3);
        if (file2.exists()) {
            file2.delete();
        }
        if (!foVar.o5(this, file, str3, 6)) {
            pp.a0(this, 2131891105, new Object[0]);
            return false;
        }
        if (com.joaomgcd.taskerm.settings.u0.G(this)) {
            this.f0.q0(com.joaomgcd.taskerm.dialog.a.L7(this, str3, com.joaomgcd.taskerm.util.b7.j6(2131888019, this, file2.getAbsolutePath())), new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.a8(file2, (df.p1) obj);
                }
            });
            return true;
        }
        com.joaomgcd.taskerm.util.l7.c1(com.joaomgcd.taskerm.util.b7.j6(2131888018, this, file2.getAbsolutePath()), this);
        return true;
    }

    private void d7(Intent intent) {
        bn bnVar = new bn(new ii(intent.getBundleExtra("scntxt")));
        int i2 = this.W;
        if (i2 == 5) {
            bnVar.U0(5);
        } else if (i2 == 6) {
            bnVar.U0(6);
        }
        Y6(bnVar);
    }

    public void d8(final q1 q1Var, final List list) {
        this.f0.z2(q1Var, new yi.d() {
            @Override
            public final void accept(Object obj) {
                Main.this.c8(list, q1Var, (we.l) obj);
            }
        });
    }

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

    private void da(Menu menu) {
        boolean d02 = rm.d0(this);
        boolean z2 = d02 && ch.k(this).exists();
        if (d02) {
            if (z2) {
                menu.add(0, 35, 0, oh.g(this, 2131888795, new Object[0]));
            } else {
                menu.add(0, 40, 0, oh.g(this, 2131888816, new Object[0]));
            }
        }
        if (z2) {
            menu.add(0, 36, 0, oh.g(this, 2131888823, new Object[0]));
        }
        menu.add(0, 37, 0, oh.g(this, 2131889105, new Object[0]));
        menu.add(0, 38, 0, oh.g(this, 2131889106, new Object[0]));
        menu.add(0, 39, 0, oh.g(this, 2131888985, new Object[0]));
    }

    private void dc(io ioVar, sn snVar, boolean z2) {
        ImageView imageView = this.K;
        if (imageView == null) {
            MyActivity.L(this, "showNewContextNameSelector buttonAdd null");
            return;
        }
        h hVar = new h(imageView, ioVar, snVar);
        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(), 2131887175);
            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.S4(Da(this.X), ImageSelect.r0(intent));
        Ia();
        invalidateOptionsMenu();
    }

    public void e8(we.l lVar) throws Exception {
        String N1 = this.S.N1(this, lVar);
        File k12 = pp.k1();
        if (!k12.exists()) {
            pp.a0(this, 2131887726, new Object[0]);
            return;
        }
        File file = new File(k12, "datadescr.txt");
        if (pp.C3(N1, file, false)) {
            pp.j0(this, 2131887930, file);
        } else {
            pp.j0(this, 2131887800, new Object[0]);
        }
    }

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

    private void ea(Menu menu) {
        menu.add(0, 3, 0, oh.g(this, 2131888892, new Object[0]));
        menu.add(0, 25, 0, oh.g(this, 2131888941, new Object[0]));
        ca(menu.addSubMenu(0, 9993, 0, oh.g(this, 2131889060, new Object[0])));
        menu.add(0, 2, 0, oh.g(this, 2131889097, new Object[0]));
        menu.add(0, 29, 0, oh.g(this, 2131888890, new Object[0]));
        menu.add(0, 17, 0, oh.g(this, 2131889069, new Object[0]));
        fa(menu.addSubMenu(0, 9993, 0, oh.g(this, 2131889066, new Object[0])));
    }

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

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

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

    private boolean f5() {
        File file = new File(pp.k1(), "crash.txt");
        boolean z2 = false;
        if (file.exists()) {
            long lastModified = file.lastModified();
            if (r0 != lastModified) {
                String X = pp.X(file);
                if (X != null) {
                    if (X.contains(OutOfMemoryError.class.getSimpleName())) {
                        gi.h(this, 2131887520, 2131887296);
                        o7.c();
                        file.delete();
                        z2 = true;
                    } else {
                        z2 = xo.d(this, 2131890879);
                    }
                }
                r0 = lastModified;
            }
            if (!z2 && System.currentTimeMillis() - lastModified > 3600000) {
                file.delete();
            }
        }
        return z2;
    }

    private void f6(fn fnVar) {
        o7.f("T", "etaa");
        fo V = rm.V(this, this.S, null, fnVar);
        if (X5(V)) {
            if (fnVar.G1()) {
                i5(V, fnVar);
            } else {
                this.f0.w2(2131887710);
            }
        }
    }

    private void f7() {
        fo w6 = w6("handleOARProfileProperties");
        if (w6 == null) {
            return;
        }
        w6.F4(this.U);
        L6(b2.a.Profile);
    }

    private void fa(Menu menu) {
        menu.add(0, 1, 0, oh.g(this, 2131888747, new Object[0]));
        menu.add(0, 31, 0, oh.g(this, 2131888952, new Object[0]));
        menu.add(0, 18, 0, oh.g(this, 2131888959, new Object[0]));
        menu.add(0, 14, 0, oh.g(this, 2131888829, new Object[0]));
        menu.add(0, 12, 0, oh.g(this, 2131888916, new Object[0]));
    }

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

    private void fc(final net.dinglisch.android.taskerm.b2.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.b2$a, android.view.View, int, java.lang.String, int):void");
    }

    private <T> void fd(ti.r<T> rVar, yi.d<T> dVar) {
        this.f0.q0(rVar, dVar);
    }

    private void g5(io ioVar) {
        if (ioVar != null && ioVar.Z0(2) && ioVar.Z0(1)) {
            Bundle l02 = com.joaomgcd.taskerm.util.b7.l0(this.S, this, ioVar, null, "checkDayAndTimeTip");
            wo woVar = (wo) ioVar.T0(1);
            if (woVar.w1() && woVar.y1() && woVar.h1(this, l02) > woVar.s1(this, l02)) {
                xo.e(this, 1, 2131890881, 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) {
        o7.f("T", "oar: scene edit");
        fo w6 = w6("handleOARSceneEdit");
        if (intent == null) {
            o7.k("T", "handleOARSE:no result data");
        } else if (w6 == null) {
            o7.k("T", "handleOARSE:no data");
        } else {
            String stringExtra = intent.getStringExtra("sc");
            pi u2 = w6.u2(C5(), "hoars");
            aa("oar scene edit");
            if (u2 == null) {
                o7.k("T", "handleOARSE:no project with index " + C5());
            } else {
                o7.f("T", "have cur project: true");
                boolean T = u2.T(stringExtra);
                StringBuilder sb = new StringBuilder();
                sb.append("was new scene: ");
                sb.append(!T);
                o7.f("T", sb.toString());
                mj B2 = w6.B2(stringExtra);
                StringBuilder sb2 = new StringBuilder();
                sb2.append("have data scene: ");
                sb2.append(B2 != null);
                o7.f("T", sb2.toString());
                if (B2 == null) {
                    o7.k("T", "handleOARSE:no scene");
                } else {
                    if (fl.N(B2.getName())) {
                        fl.v(this, B2.getName(), true);
                    }
                    o7.f("T", "data scene name: " + B2.getName());
                    w6.B0(B2.getName(), C5());
                    o7.f("T", "reset entity edit data");
                    w6.F4(B2);
                    o7.f("T", "check links");
                    try {
                        for (hj hjVar : B2.g(getPackageManager())) {
                            if (hjVar.f() == hj.b.Task && w6.i(hjVar) && w6.d5((fn) w6.P1(hjVar))) {
                                w6.F0(hjVar.b(), C5());
                            }
                        }
                    } catch (Exception e2) {
                        o7.H("T", "handleOAR", e2);
                    }
                    aa("handle data changed");
                    K6(false, b2.a.Scene);
                    o7.f("T", "handle data changed done");
                    if (!T) {
                        o7.f("T", "centre on scene");
                        X4(stringExtra);
                    }
                    w6.y4();
                    L6(b2.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.a0(this, "https://youtu.be/gGa4OfxmlzU");
    }

    private void ga(Menu menu) {
        boolean z2 = fo.G1().size() > 0;
        Settings.M3(this);
        SubMenu addSubMenu = menu.addSubMenu(0, 9999, 0, oh.g(this, 2131888967, new Object[0]));
        if (z2) {
            addSubMenu.add(0, 51, 0, oh.g(this, 2131888776, new Object[0]));
        }
        addSubMenu.add(0, 52, 0, oh.g(this, 2131888778, new Object[0]));
        addSubMenu.add(0, 65, 0, oh.g(this, 2131888777, new Object[0]));
    }

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

    public void gc(View view, String str) {
        new ki(this, null).o(new l1(view)).p(2131887515).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.Q1(getPackageManager(), str);
        }
        String t3 = pp.t3(strArr);
        TextBoxDialogFragment.Z(this, new e(strArr), -1, i2 > 0 ? pp.r0(this, 2131887180, t3, Integer.valueOf(i2)) : pp.r0(this, 2131887181, t3));
        return false;
    }

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

    private void h7(Intent intent) {
        int i2 = intent.getExtras().getInt("taskidr");
        fo w6 = w6("handleOARTaskEdit");
        if (w6 == null) {
            return;
        }
        if (w6.U(i2)) {
            fn T = w6.T(i2);
            w6.F4(T);
            pi u2 = w6.u2(C5(), "hoart");
            if (u2 == null) {
                o7.k("T", "handleOARTaskEdit: null project, index " + C5() + ", no proj " + w6.e2() + " taskID " + i2);
            } else {
                boolean U = u2.U(i2);
                if (w6.d5(T)) {
                    w6.F0(i2, C5());
                }
                K6(false, b2.a.Profile, b2.a.Task);
                if (!U) {
                    Y4(i2);
                }
                if (w6.L0(this, w6.T(i2))) {
                    K6(false, b2.a.Scene);
                }
                M6(b2.a.Variable);
            }
        } else {
            o7.G("T", "oar: task edit: task ID " + i2 + " doesn't exist");
        }
        q5(intent);
        o7.f("T", "done");
    }

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

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

    public void hc() {
        ExtensionsContextKt.a0(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] = ((fn) list.get(i2)).P0();
        }
        return iArr;
    }

    private void i5(fo foVar, hi hiVar) {
        this.Z = foVar;
        this.Y = hiVar;
        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, b2.a.values());
    }

    private void i7(Intent intent) {
        int Q0;
        fn T;
        int i2 = intent.getExtras().getInt("taskidr");
        fo w6 = w6("handleOARTaskEditFromProfile");
        if (w6 == null) {
            return;
        }
        fn T2 = w6.T(i2);
        if (T2 != null && w6.d5(T2)) {
            w6.F0(i2, C5());
        }
        w6.F4(T2);
        io ioVar = this.U;
        if (ioVar == null) {
            o7.k("T", "taskEditFromProfileResult: profile null, can't connect task to profile");
        } else {
            if (!w6.V(ioVar.C0())) {
                o7.G("T", "taskEditFromProfileResult: profile unknown in data");
            }
            int i3 = this.W;
            if (i3 != 0 && i3 != 1) {
                o7.k("T", "bad editingType: " + this.W + ": assuming pre");
                this.W = 0;
            }
            if (this.U.c1(this.W) && (Q0 = this.U.Q0(this.W)) != i2 && (T = w6.T(Q0)) != null && !T.x()) {
                o7.f("T", "delete previous (anonymous) task ID " + Q0);
                w6.i1(Q0);
            }
            this.U.F1(this.W, i2);
            w6.F4(this.U);
            if (this.U.x() || rg.i.y(this, new com.joaomgcd.taskerm.util.h0(this, 2131890814, new Object[0]))) {
                xo.e(this, 0, 2131890946, 2);
            } else {
                this.f0.x2(2131890814);
            }
            if (w6.L0(this, w6.T(i2))) {
                K6(false, b2.a.Scene);
            }
        }
        L6(b2.a.Profile, b2.a.Task, b2.a.Variable);
        o7.f("T", "done");
    }

    public void i8(com.joaomgcd.taskerm.util.pe peVar) throws Exception {
        if (peVar instanceof com.joaomgcd.taskerm.util.se) {
            pp.k0(this, ((com.joaomgcd.taskerm.util.se) peVar).g());
        } else {
            pp.j0(this, 2131888727, new Object[0]);
        }
    }

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

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

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

    private boolean ic() {
        return this.f0.t2(2131890929, new ik.a() {
            @Override
            public final Object e() {
                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) {
            xo.d(this, 2131890926);
        }
    }

    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) {
            pp.a0(this, 2131887850, 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 (gi.g(this)) {
                    Mb();
                    return;
                } else {
                    V5(false, "discfalse");
                    return;
                }
            }
            if (i2 == 11) {
                fo foVar = this.S;
                if (foVar != null) {
                    foVar.y4();
                    return;
                }
                return;
            }
            if (i2 == 27) {
                io ioVar = this.U;
                if (ioVar == null || ioVar.P0() != 0) {
                    return;
                }
                TextBoxDialogFragment.a0(this, new l(), oh.g(this, 2131887184, new Object[0]));
                return;
            }
            if (i2 == 32) {
                w5("oarc: kid/create");
                return;
            }
            if (i2 != 15) {
                if (i2 == 16) {
                    pp.j0(this, 2131891156, new Object[0]);
                    w5("oarc: spawn");
                    return;
                } else if (i2 != 18 && i2 != 19) {
                    switch (i2) {
                    }
                }
            }
            o7.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 S2 = fo.S2(true);
        if (S2 != null) {
            Ic(FileSelect.u0(this, null, S2.toString() + File.separator + "backup.xml", FileSelect.e.File, ".xml", false, false), i2);
        }
    }

    private void ja(b2.a aVar, int i2) {
        rg rgVar = (rg) s6(aVar).getAdapter();
        List<Integer> f2 = rgVar.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.V3(((io) rgVar.getItem(intValue)).C0(), C5(), i2);
            } else if (i3 == 2) {
                this.S.a4(((fn) rgVar.getItem(intValue)).P0(), C5(), i2);
            } else if (i3 == 3) {
                this.S.Y3(((mj) 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.s2(2131890867, new ik.a() {
            @Override
            public final Object e() {
                Boolean w9;
                w9 = Main.this.w9();
                return w9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Bb();
            }
        });
    }

    private void jd(io ioVar) {
        if (!ioVar.h1()) {
            ioVar.A1(false);
        } else if (ioVar.i0()) {
            pp.a0(this, 2131887580, new Object[0]);
        } else {
            ioVar.A1(true);
            ioVar.C1(0);
        }
        this.S.F4(ioVar);
        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 - (jl.N(this, width) / 2) : (int) f2;
        if (!this.v.y(listView, y(), i2) || !jl.X(this, y(), N, width)) {
            return false;
        }
        this.v.E();
        if (z3) {
            return false;
        }
        Mc(listView, i2, "checkInitDrag");
        return true;
    }

    private void k6(b2.a... aVarArr) {
        if (!xo.e(this, 1, 2131890901, 1)) {
            pp.j0(this, 2131886876, new Object[0]);
        }
        L6(aVarArr);
    }

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

    public void k8(Intent intent) {
        o7.f("T", "Spawn create basic key ok: with file permissions");
        if (ch.c(this, -1, intent, "keystore.auto")) {
            o7.f("T", "Spawn create basic key ok: lanching factory");
            this.f0.z0(Y9("keystore.auto", "bl^!)*(!*{a", "ImACertPass"), new Runnable() {
                @Override
                public final void run() {
                    Main.this.j8();
                }
            });
        } else {
            o7.k("T", "Couldn't create keystore from intent");
            pp.a0(this, 2131887823, 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 = ((io) it.next()).C0();
            this.S.z4(i2, C0);
            this.S.y0(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.s2(2131890868, new ik.a() {
            @Override
            public final Object e() {
                Boolean x9;
                x9 = Main.this.x9();
                return x9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Cb();
            }
        });
    }

    public void kd() {
        Ja();
        if (z7()) {
            o7.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.X3();
        if (nd()) {
            if (pa()) {
                ac(true, 0, null);
                return;
            } else {
                v5();
                return;
            }
        }
        int currentTimeMillis = (int) ((System.currentTimeMillis() - sharedPreferences.getLong(d6.n.b, -1L)) / 86400000);
        int i2 = 7 - currentTimeMillis;
        Licence.u0(sharedPreferences);
        if (currentTimeMillis >= 7 && !s0 && T4(fo.S2(true), "backup.xml")) {
            pp.h0(this, 2131888726, 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 j2(new ii(intent.getBundleExtra("scntxt"))));
                break;
            case 5:
                Y6(new n7(new ii(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")) {
                    o7.k("T", "oar: no config extra from KidConfig");
                    break;
                } else {
                    Bundle bundleExtra = intent.getBundleExtra("b");
                    if (bundleExtra == null) {
                        o7.k("T", "oar: null config data from KidConfig");
                        break;
                    } else {
                        H7(new s6(new ii(bundleExtra)));
                        break;
                    }
                }
            case 16:
                w5("spawn ok");
                break;
            case 17:
                File e2 = ch.e(this);
                if (e2.exists()) {
                    e2.delete();
                }
                ch.a(this);
                break;
            case 18:
                o7.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.f1(new ii(intent.getBundleExtra("ssc"))));
                break;
            case 22:
                Y6(new net.dinglisch.android.taskerm.v1(new ii(intent.getBundleExtra("context"))));
                g5(this.U);
                break;
            case 23:
                Y6(new wo(new ii(intent.getBundleExtra("sTsc"))));
                g5(this.U);
                break;
            case 24:
                xg.e2.U0(new n(intent.getExtras().getString("path")));
                break;
            case 25:
                f7();
                break;
            case 26:
            case 31:
            default:
                o7.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)) {
                    pp.j0(this, 2131888726, new Object[0]);
                    this.f0.q0(GenericActionBackupToGoogleDrive.backupToGoogleDrive(this, name), new yi.d() {
                        @Override
                        public final void accept(Object obj) {
                            Main.this.i8((com.joaomgcd.taskerm.util.pe) obj);
                        }
                    });
                    break;
                }
                break;
            case 29:
                rf.d a2 = rf.a.a(this, new File(intent.getExtras().getString("path")));
                if (!a2.b0()) {
                    pp.n0(this, 2131887804, a2);
                    break;
                } else {
                    TextBoxDialogFragment.Y(this, new m(a2), 2131887318);
                    break;
                }
            case 30:
                d4.D(this, -1, intent);
                pp.j0(this, 2131886894, new Object[0]);
                break;
            case 32:
                if (!intent.hasExtra(com.joaomgcd.taskerm.datashare.export.d.G())) {
                    o7.k("T", "oar: no config extra from ShareDataConfig");
                    break;
                } else {
                    Bundle bundleExtra2 = intent.getBundleExtra(com.joaomgcd.taskerm.datashare.export.d.G());
                    if (bundleExtra2 == null) {
                        o7.k("T", "oar: null config data from ShareDataConfig");
                        break;
                    } else {
                        bf.b e3 = bf.b.e(new ii(bundleExtra2));
                        f5 f5Var = (f5) this.Y;
                        if (f5Var == null) {
                            o7.k("T", "oar: null importable for ShareDataConfig");
                            break;
                        } else {
                            f5Var.t(e3);
                            Ta();
                            w5("initkey");
                            com.joaomgcd.taskerm.datashare.export.d.H0(this, this.S, f5Var, e3);
                            break;
                        }
                    }
                }
            case 33:
                this.f0.m4(intent);
                break;
        }
    }

    public void l9(b2.a aVar, final List list, fh fhVar) {
        if (fhVar.v()) {
            if (aVar == b2.a.Profile && rm.d0(this)) {
                xo.d(this, 2131890945);
                return;
            }
            return;
        }
        final q1 q1Var = q1.values()[fhVar.A()];
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            this.f0.z2(q1Var, new yi.d() {
                @Override
                public final void accept(Object obj) {
                    Main.this.k9(list, q1Var, (we.l) 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 = ((mj) it.next()).getName();
            if (gl.P(name)) {
                z2 = true;
            } else {
                this.S.A4(i2, name);
                this.S.B0(name, i3);
                i4++;
            }
        }
        if (z2) {
            pp.n0(this, 2131887784, 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.s2(2131890869, new ik.a() {
            @Override
            public final Object e() {
                Boolean y9;
                y9 = Main.this.y9();
                return y9;
            }
        }, new Runnable() {
            @Override
            public final void run() {
                Main.this.Db();
            }
        });
    }

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

    public boolean m5(int i2, r.b bVar) {
        if (!ep.r0(this)) {
            return true;
        }
        ac(false, i2, bVar);
        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.c4(new Runnable() {
            @Override
            public final void run() {
                Main.this.l8(i2, intent);
            }
        });
    }

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

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

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

    private static void mb(Activity activity) {
        if (fp.e0()) {
            String g2 = oh.g(activity, 2131891233, new Object[0]);
            SpannableString spannableString = new SpannableString(g2);
            spannableString.setSpan(new ForegroundColorSpan(gp.e(activity)), 0, g2.length(), 0);
            ActionBar actionBar = activity.getActionBar();
            if (actionBar != null) {
                if (MonitorService.d2(activity)) {
                    spannableString = null;
                }
                actionBar.setSubtitle(spannableString);
            }
        }
    }

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

    public void md(b2.a aVar) {
        int C5 = C5();
        int i2 = i1.b[aVar.ordinal()];
        if (i2 == 1) {
            ni niVar = this.x;
            if (niVar == null) {
                MyActivity.L(this, "updateEntityData profileAdapter is null");
                return;
            } else {
                niVar.E(C5, y6(), true);
                return;
            }
        }
        if (i2 == 2) {
            hn hnVar = this.z;
            if (hnVar == null) {
                MyActivity.L(this, "updateEntityData taskAdapter is null");
                return;
            } else {
                hnVar.s(this.S, C5, B6());
                return;
            }
        }
        if (i2 == 3) {
            zk zkVar = this.y;
            if (zkVar != null) {
                zkVar.s(this.S, C5, z6());
                return;
            } else {
                o7.G("T", "updateEntityData: no scene adapter");
                MyActivity.L(this, "updateEntityData sceneAdapter is null");
                return;
            }
        }
        if (i2 != 4) {
            return;
        }
        R8();
        up upVar = this.A;
        if (upVar == null) {
            MyActivity.L(this, "updateEntityData variableAdapter is null");
            return;
        }
        upVar.w(this.S, C5);
        upVar.x();
        Zc();
    }

    public boolean n5(String str, boolean z2, b2.a aVar) {
        if (str.length() == 0) {
            pp.j0(this, 2131887839, new Object[0]);
            return false;
        }
        if (z2) {
            pp.a0(this, 2131887836, str);
            return false;
        }
        if (aVar != null && aVar == b2.a.Scene) {
            if (gl.P(str)) {
                pp.a0(this, 2131887894, str);
                return false;
            }
            if (str.contains(pi.C())) {
                pp.a0(this, 2131887837, oh.g(this, 2131891259, new Object[0]), pi.C());
                return false;
            }
        }
        return true;
    }

    private void n7(int i2) {
        if ((i2 & 2) > 0) {
            Ya(2);
        }
        if ((i2 & 32) > 0) {
            Settings.c3(this);
        }
        hn hnVar = this.z;
        if ((i2 & 128) > 0 && hnVar != null) {
            hnVar.notifyDataSetChanged();
            I7();
            fb();
        }
        ni niVar = this.x;
        if ((i2 & 8) > 0 && niVar != null) {
            niVar.notifyDataSetInvalidated();
        }
        if ((i2 & 1) > 0) {
            J6(false, false, false, b2.a.Profile);
        }
        if ((i2 & 512) > 0) {
            if (niVar != null) {
                niVar.notifyDataSetInvalidated();
            }
            if (hnVar != null) {
                hnVar.notifyDataSetInvalidated();
            }
            zk zkVar = this.y;
            if (zkVar != null) {
                zkVar.notifyDataSetInvalidated();
            }
            up upVar = this.A;
            if (upVar != null) {
                upVar.notifyDataSetInvalidated();
            }
        }
        Ra();
        Ya(8);
    }

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

    public void n9(final io ioVar) {
        xg.e2.b1(new Runnable() {
            @Override
            public final void run() {
                Main.this.m9(ioVar);
            }
        });
    }

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

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

    private ti.r<df.p1> nc(final String[] strArr, final HashMap<String, List<String>> hashMap) {
        return this.f0.W(new ik.a() {
            @Override
            public final Object e() {
                ti.r z9;
                z9 = Main.this.z9(hashMap, strArr);
                return z9;
            }
        });
    }

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

    private boolean o5() {
        String p2 = o7.p();
        if (p2.length() <= 0) {
            return false;
        }
        gi.j(this, 2131888448, p2);
        o7.c();
        o7.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 fh(this, this.I.v(i2)).k(t1.DeleteContents.ordinal(), 2131888824, 2130969299).k(t1.KeepContents.ordinal(), 2131888958, 2130969207).F(new fh.f() {
            @Override
            public final void a(fh fhVar) {
                Main.this.m8(i2, fhVar);
            }
        }).show();
    }

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

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

    public boolean oa() {
        return pp.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.V3(i2, new ik.a() {
            @Override
            public final Object e() {
                vj.e0 A9;
                A9 = Main.this.A9(i2);
                return A9;
            }
        })) {
            o7(i2);
        }
    }

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

    public void p5(int[] r5) {
        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.d2() > 0 || this.S.g2() > 0));
    }

    private boolean pa() {
        fo foVar = this.S;
        if (foVar == null) {
            MyActivity.L(this, "needGateLock data null");
            return false;
        }
        try {
            if (!ep.l0(this)) {
                return false;
            }
            if (!foVar.w(Da(D5())).W() && !ep.q0(this)) {
                return false;
            }
            return this.g0;
        } catch (Throwable th2) {
            o7.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 fh(this, this.I.v(i2)).k(q1.AsApp.ordinal(), 2131888865, 2130969177).k(q1.DescrToEmail.ordinal(), 2131888866, 2130969198).k(q1.DescrToClip.ordinal(), 2131888867, 2130969171).k(q1.XmlToSD.ordinal(), 2131888872, 2130969205).l(q1.ToLink.ordinal(), 2131888869, 2130969304, fh.d.Top).l(q1.ToUri.ordinal(), 2131888868, 2130969304, fh.d.Bottom).F(new fh.f() {
            @Override
            public final void a(fh fhVar) {
                Main.this.C9(i2, fhVar);
            }
        }).show();
    }

    public static boolean pd(Context context) {
        return !Settings.j1(pp.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) {
            pp.a0(this, 2131887800, new Object[0]);
        } else {
            if (Ic(intent, 16)) {
                return;
            }
            w5("launchFactory");
            pp.a0(this, 2131887846, oh.g(this, 2131886702, new Object[0]));
        }
    }

    public void q9() {
        com.joaomgcd.taskerm.util.bi.t(this);
    }

    private void qa(boolean z2) {
        fo foVar = this.S;
        if (foVar == null) {
            MyActivity.L(this, "onCreatePartFour data null");
            return;
        }
        o7.x(pp.g());
        PackageManager packageManager = getPackageManager();
        xg.e2.J0(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 (foVar.e2() > 1) {
                sharedPreferences.edit().putBoolean("beginnerMode", false).commit();
            }
        } else if (!z2) {
            sharedPreferences.edit().putBoolean("beginnerMode", true).commit();
        }
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.za();
            }
        }).h();
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.C8();
            }
        }).h();
        foVar.k(packageManager);
        foVar.a1();
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.D8();
            }
        }).h();
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.Aa();
            }
        }).h();
        xg.e2.J0(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", d6.n.a.a.ordinal());
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.E8(i2);
            }
        }).h();
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.F8();
            }
        }).h();
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.y8();
            }
        }).h();
        foVar.Q0(packageManager, b2.a.values());
        ld();
        final sh shVar = this.J;
        final ViewPager viewPager = this.P;
        if (shVar == null || viewPager == null) {
            MyActivity.L(this, "onCreatePartFour entityTabs or mViewPager null");
            return;
        }
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.z8(sh.this, i2, viewPager);
            }
        }).h();
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.A8();
            }
        }).h();
        xg.e2.J0(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);
        fh fhVar = new fh(this, v2);
        int v6 = v6();
        boolean K7 = K7(i2);
        final int Da = Da(i2);
        final pi u2 = this.S.u2(Da, "spm");
        if (u2 == null) {
            pp.a0(this, 2131887791, new Object[0]);
            return;
        }
        fhVar.k(u1.Add.ordinal(), 2131889446, 2130969155);
        if (!K7) {
            fhVar.k(u1.Delete.ordinal(), 2131886874, 2130969299);
            fhVar.k(u1.Export.ordinal(), 2131888864, 2130969205);
            fhVar.k(u1.Properties.ordinal(), 2131886899, 2130969257);
        }
        fhVar.k(u1.Rename.ordinal(), 2131886902, 2130969235);
        if (u2.W()) {
            fhVar.k(u1.Unlock.ordinal(), 2131889091, 2130969302);
        } else {
            fhVar.k(u1.Lock.ordinal(), 2131888920, 2130969226);
        }
        fhVar.k(u1.Import.ordinal(), 2131888904, 2130969218);
        fhVar.k(u1.SetIcon.ordinal(), 2131889013, 2130969217);
        if (!K7) {
            if (i2 > v6) {
                fhVar.k(u1.ShiftLeft.ordinal(), 2131891212, 2130969253);
            }
            if (i2 < this.I.x() - 1) {
                fhVar.k(u1.ShiftRight.ordinal(), 2131891256, 2130969238);
            }
        }
        if (this.I.x() > 4) {
            fhVar.k(u1.SelectProject.ordinal(), 2131890330, 2130969188);
        }
        fhVar.F(new fh.f() {
            @Override
            public final void a(fh fhVar2) {
                Main.this.G9(v2, i2, Da, u2, fhVar2);
            }
        });
        try {
            fhVar.show();
        } catch (Throwable unused) {
            pp.a0(this, 2131887791, 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;
        ch.b(this);
        rm.e(this);
        o7.f("T", "Checking spawn version");
        if (rm.f(this, this.Z)) {
            try {
                intent = rm.S(this, this.Z, str, str2, "Cert", str3);
            } catch (NullPointerException e2) {
                o7.l("T", "launchFactory", e2);
                intent = null;
            }
            xg.e2.J0(new Runnable() {
                @Override
                public final void run() {
                    Main.this.q8(intent);
                }
            }).h();
        }
    }

    public void r9(b2.a aVar) {
        File L0;
        String str;
        int i2;
        if (aVar == null) {
            L0 = pi.k(this.M);
            str = ".prj.xml";
            i2 = 2131887530;
        } else if (aVar == b2.a.Scene) {
            L0 = mj.i1();
            str = ".scn.xml";
            i2 = 2131887545;
        } else if (aVar == b2.a.Profile) {
            L0 = io.A0(this.M);
            str = ".prf.xml";
            i2 = 2131887526;
        } else {
            L0 = fn.L0();
            str = ".tsk.xml";
            i2 = 2131887562;
        }
        String str2 = str;
        if (!L0.isDirectory()) {
            L0.mkdirs();
        }
        Ic(FileSelect.u0(this, oh.g(this, i2, new Object[0]), L0.toString(), FileSelect.e.File, str2, false, false), 24);
    }

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

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

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

    private boolean rd() {
        fo foVar;
        return (U4() || (foVar = this.S) == null || !foVar.z3()) ? false : true;
    }

    public boolean s5(io ioVar, int i2) {
        if (ioVar.P0() == 1) {
            p5(new int[]{ioVar.C0()});
        } else {
            if (!this.M.getBoolean("lPdta", true) || this.S.M2(ioVar, i2).x()) {
                R6(ioVar, i2);
                return true;
            }
            TextBoxDialogFragment.a0(this, new b(ioVar, i2), oh.g(this, 2131887182, oh.g(this, 2131891147, new Object[0])));
        }
        return false;
    }

    private void s7(qj qjVar, List<Object> list) {
        t7((mj) list.remove(0), qjVar);
    }

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

    private void sa(boolean z2, Bundle bundle) {
        ii g2;
        fo.U3();
        if (bundle == null) {
            o7.f("T", "onCreate: no icicle");
            System.gc();
            Z9("fresh");
            if (!z2) {
                this.S.P4();
            }
            o7.f("T", "loaded data, proj " + this.S.e2());
            C7(null);
            o7.f("T", "import and delete, proj " + this.S.e2());
            J7();
            o7.f("T", "done init, proj " + this.S.e2());
            this.S.P0();
            o7.f("T", "check delete disabled");
            Ya(2);
            return;
        }
        o7.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) {
                    o7.k("T", "null editing profile pid " + i2);
                }
            }
        }
        this.W = bundle.getInt("sset", 0);
        if (bundle.containsKey("eent")) {
            this.a0 = b2.a.valueOf(bundle.getString("eent"));
        }
        this.X = bundle.getInt("etab", 0);
        this.V = bundle.getString("sspn");
        if (bundle.containsKey("ssed")) {
            fo foVar = new fo();
            this.Z = foVar;
            foVar.n1(this, "onCreate/icicle", "ssed", true);
        }
        if (bundle.containsKey("sseo") && (g2 = ii.g(this, "sseo", true)) != null) {
            if (g2.u().equals(fn.f1())) {
                fn fnVar = new fn(g2);
                if (this.S.U(fnVar.P0())) {
                    this.Y = this.S.T(fnVar.P0());
                } else {
                    this.Y = fnVar;
                }
            } else if (g2.u().equals(pi.p())) {
                pi piVar = new pi(g2);
                if (this.S.a3(piVar.getName())) {
                    this.Y = this.S.v2(piVar.getName());
                } else {
                    this.Y = piVar;
                }
            } else if (g2.H("Profile")) {
                io ioVar = new io(this, g2, -1);
                int C0 = ioVar.C0();
                if (this.S.V(C0)) {
                    this.Y = this.S.c(C0);
                } else {
                    this.Y = ioVar;
                }
            }
        }
        this.c0 = bundle.getString("etag");
    }

    public void sc(View view, final mj mjVar) {
        final ki kiVar = new ki(this, mjVar.getName());
        kiVar.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                Main.this.H9(kiVar, mjVar);
            }
        });
        kiVar.v(j5(view, true), true);
    }

    private void sd() {
        File b2 = li.b();
        if (b2 == null) {
            pp.a0(this, 2131887726, new Object[0]);
            return;
        }
        String libraryTemplate = z5.getLibraryTemplate();
        File file = new File(b2, z5.EXPORT_FILENAME);
        if (pp.C3(libraryTemplate, file, false)) {
            pp.j0(this, 2131887930, file);
        } else {
            pp.a0(this, 2131887929, file);
        }
    }

    public boolean t5(int[] iArr) {
        if (!this.f0.T3(iArr) || !this.f0.J3(iArr, false, true, new ik.l() {
            @Override
            public final Object invoke(Object obj) {
                vj.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), oh.g(this, 2131887182, pp.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) + fp.Y(5);
    }

    private void t7(mj mjVar, qj qjVar) {
        Qa(b2.a.Scene, "handleSSR");
        if (mjVar.q() && ep.r0(this)) {
            pp.a0(this, 2131887870, new Object[0]);
        } else if (qjVar == null) {
            Rc(mjVar.getName(), null, 20);
        } else {
            Rc(mjVar.getName(), qjVar.getName(), 20);
        }
    }

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

    public r.a t9() {
        if (!MonitorService.d2(this)) {
            com.joaomgcd.taskerm.dialog.a.R3(this, 2131891107, 2131887351).f();
            return new r.a(true);
        }
        if (!pp.S1()) {
            return new r.a(false);
        }
        if (!ud.i0.d()) {
            o7.G("T", "on MM but no PM functions");
            return new r.a(false);
        }
        if (this.N.contains("USER_DOESNT_WANT_BATTERY_OPTIMIZATION_DIALOGs")) {
            return new r.a(true);
        }
        if (ud.i0.g((PowerManager) gi.d(getApplicationContext(), "power", "T", "showMMWarning"), getPackageName())) {
            return com.joaomgcd.taskerm.settings.d1.l(this) ? new r.a(true, ((df.p1) com.joaomgcd.taskerm.dialog.a.I7(this, 2131886703, 2131887315).f()).o()) : new r.a(false);
        }
        df.p1 p1Var = (df.p1) com.joaomgcd.taskerm.dialog.a.J7(this, 2131887464, 2131887143, 2131886905).f();
        if (p1Var.l()) {
            com.joaomgcd.taskerm.dialog.a.R3(this, 2131890883, 2131890865).f();
            return new r.a(true);
        }
        if (p1Var.n()) {
            this.N.edit().putBoolean("USER_DOESNT_WANT_BATTERY_OPTIMIZATION_DIALOGs", true).commit();
            com.joaomgcd.taskerm.dialog.a.R3(this, 2131890883, 2131890937).f();
            return new r.a(true);
        }
        if (!new GenericActionActivityDisableBatteryOptimizations().run(this).f().b()) {
            com.joaomgcd.taskerm.dialog.a.R3(this, 2131887464, 2131887339).f();
            return new r.a(true);
        }
        o7.G("T", "User tuned off battery optimization, yay!");
        if (!((df.p1) com.joaomgcd.taskerm.dialog.a.w7(new df.r(this, 2131891107, 2131887144, 2131886895, 2131886894)).f()).o()) {
            return new r.a(true);
        }
        ExtensionsContextKt.a0(this, "https://tasker.joaoapps.com/userguide/en/faqs/faq-problem.html#00");
        return new r.a(true);
    }

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

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

    public void tc(View view, final fn fnVar) {
        final ki kiVar = new ki(this, fnVar.x() ? fnVar.getName() : null);
        kiVar.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public final void onDismiss() {
                Main.this.I9(kiVar, fnVar);
            }
        });
        kiVar.v(j5(view, true), true);
    }

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

    private void u7() {
        ll C0 = Search.C0();
        if (C0 == null) {
            return;
        }
        List<Object> e2 = C0.e();
        if (e2.size() > 0) {
            gd(Ca(e2.get(0).getClass() == pi.class ? this.S.p4(((pi) 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 == io.class) {
                    D6(((io) remove).C0());
                    return;
                }
                if (cls == h7.class) {
                    b7((h7) remove, e2);
                    return;
                }
                if (cls == mj.class) {
                    t7((mj) remove, null);
                    return;
                }
                if (superclass == qj.class || superclass == sk.class) {
                    s7((qj) remove, e2);
                    return;
                }
                if (cls == fn.class) {
                    y7((fn) remove, null, e2);
                    return;
                }
                if (cls == net.dinglisch.android.taskerm.c.class) {
                    G6((net.dinglisch.android.taskerm.c) remove, e2);
                    return;
                }
                if (superclass == sn.class) {
                    I6((sn) remove, e2);
                    return;
                }
                if (cls == pr.class || superclass == pr.class || cls == net.dinglisch.android.taskerm.r1.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 == j2.class) {
                        I6((sn) remove2, e2);
                        return;
                    }
                    if (cls2 == bn.class) {
                        I6((sn) remove2, e2);
                    } else if (superclass2 == qj.class || superclass2 == sk.class) {
                        s7((qj) remove2, e2);
                    }
                }
            }
        }
    }

    public void u8() {
        if (com.joaomgcd.taskerm.settings.d1.x(this)) {
            MonitorService.m8(this, false);
        }
    }

    public void u9(b2.a aVar, View view, int i2, String str, ki kiVar) {
        io ioVar;
        io ioVar2;
        if (kiVar.f()) {
            if (aVar == b2.a.Task && (ioVar2 = this.U) != null && ioVar2.P0() == 0) {
                TextBoxDialogFragment.a0(this, new u0(aVar, view, i2, str), oh.g(this, 2131887184, new Object[0]));
                return;
            }
            return;
        }
        if (kiVar.g()) {
            String i3 = kiVar.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 (!wp.c1(i3)) {
                        pp.a0(this, 2131887699, i3);
                    } else if (wp.W0(i3)) {
                        pp.j0(this, 2131887854, oh.g(this, 2131891186, new Object[0]));
                    } else {
                        if (!wp.S0(i3)) {
                            wp.T1(this, i3, "", "newvar");
                            L6(aVar);
                            return;
                        }
                        pp.a0(this, 2131890322, new Object[0]);
                    }
                } else if (n5(i3, this.S.p(i3), b2.a.Scene)) {
                    Rc(i3, null, -1);
                    return;
                }
            } else if (TextUtils.isEmpty(i3) && (ioVar = this.U) != null) {
                Yc(ioVar, this.W, -1, null);
                return;
            } else if (n5(i3, this.S.S3(i3), b2.a.Task)) {
                io ioVar3 = this.U;
                if (ioVar3 == null) {
                    Wc(-1, -1, i3, -1);
                    return;
                } else {
                    Yc(ioVar3, this.W, -1, i3);
                    return;
                }
            }
            ec(aVar, view, i2, i3);
        }
    }

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

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

    private void v5() {
    }

    private int v6() {
        return 1;
    }

    private boolean v7() {
        boolean z2;
        boolean z3;
        final String stringExtra;
        fo foVar = this.S;
        if (foVar == null) {
            MyActivity.L(this, "handleStartEntity data null");
            return false;
        }
        Intent intent = getIntent();
        if (intent != null) {
            String stringExtra2 = intent.getStringExtra(l0);
            final int intExtra = intent.getIntExtra(m0, -1);
            Integer valueOf = Integer.valueOf(intExtra);
            if (stringExtra2 == null && intExtra == -1) {
                z2 = false;
                z3 = false;
            } else {
                o7.f("T", "start with taskName " + stringExtra2 + " and id " + valueOf);
                if (intExtra == -1) {
                    intExtra = foVar.n(stringExtra2);
                }
                if (intExtra == -1) {
                    o7.G("T", "handleStartEntity: unknown task: " + stringExtra2);
                    z3 = false;
                    z2 = true;
                } else {
                    String stringExtra3 = intent.getStringExtra(o0);
                    final int intValue = !TextUtils.isEmpty(stringExtra3) ? pp.E3(stringExtra3).intValue() : -1;
                    o7.f("T", "action: " + intValue);
                    fn T = foVar.T(intExtra);
                    if (T == null) {
                        o7.G("T", "handleStartEntity:  unknown task ID " + intExtra + " for " + stringExtra2);
                    } else if (ep.l0(this) && T.q()) {
                        o7.G("T", "handleStartEntity: task is locked or implicity locked: " + stringExtra2);
                    } else if (intValue == -1 || intValue < T.c1()) {
                        N5(new Runnable() {
                            @Override
                            public final void run() {
                                Main.this.n8(intExtra, intValue);
                            }
                        });
                        z2 = false;
                        z3 = true;
                    } else {
                        o7.G("T", "handleStartEntity: task " + stringExtra2 + " doesn't have " + intValue + " actions ");
                    }
                    z2 = true;
                    z3 = true;
                }
            }
            if (!z3 && (stringExtra = intent.getStringExtra(n0)) != null) {
                final String stringExtra4 = intent.getStringExtra(o0);
                o7.f("T", "start with scene " + stringExtra + " / " + stringExtra4);
                mj B2 = foVar.B2(stringExtra);
                if (B2 == null) {
                    o7.G("T", "handleStartEntity:  unknown scene " + stringExtra);
                } else if (!TextUtils.isEmpty(stringExtra4) && !B2.j2(stringExtra4)) {
                    o7.G("T", "handleStartEntity: scene " + stringExtra + " has no element " + stringExtra4);
                } else if (ep.l0(this) && B2.q()) {
                    o7.G("T", "handleStartEntity: scene is locked or implicity locked: " + stringExtra);
                } else {
                    N5(new Runnable() {
                        @Override
                        public final void run() {
                            Main.this.o8(stringExtra, stringExtra4);
                        }
                    });
                    z3 = true;
                }
                z2 = true;
                z3 = true;
            }
        } else {
            z2 = false;
            z3 = false;
        }
        if (!z2) {
            return z3;
        }
        V5(false, "handleStartEntity");
        return true;
    }

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

    private void vb() {
        this.y = new zk(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;
        o7.f("T", "Clearing app export data: " + str);
        v();
    }

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

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

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

    public void wc() {
        int i2;
        Long[] i3 = pp.i3(fo.G1().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] = ug.l(this, ug.t(longValue)).replace(" ", ", ");
            long currentTimeMillis = System.currentTimeMillis() - longValue;
            long j2 = 86400000;
            if (currentTimeMillis > 86400000) {
                i2 = 2131889561;
            } else {
                j2 = 3600000;
                if (currentTimeMillis > 3600000) {
                    i2 = 2131889673;
                } else {
                    j2 = 60000;
                    if (currentTimeMillis > 60000) {
                        i2 = 2131889797;
                    } else {
                        j2 = 1000;
                        i2 = 2131889936;
                    }
                }
            }
            strArr2[i4] = String.valueOf(currentTimeMillis / j2) + " " + oh.g(this, 2131886190, oh.g(this, i2, new Object[0]));
            i4++;
        }
        fj.D(this, new p0(), 2131887469).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);
        }
        o7.f("T", "bad relpos: " + x2);
        return null;
    }

    public void x8(Bundle bundle) {
        this.f0.g0();
        SharedPreferences sharedPreferences = this.N;
        if (sharedPreferences == null) {
            MyActivity.L(this, "onAfterBackgroundInit state null");
            return;
        }
        o7.A("T", "onCreate start");
        xg.e2.J0(new Runnable() {
            @Override
            public final void run() {
                Main.this.t8();
            }
        }).h();
        ra(bundle);
        final boolean ta = ta();
        int t2 = mh.t(this);
        final boolean F = mh.F(this);
        sa(ta, bundle);
        qa(ta);
        this.f0.c4(new Runnable() {
            @Override
            public final void run() {
                Main.this.u8();
            }
        });
        if (bundle == null && !v7()) {
            if (pa()) {
                xg.e2.J0(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.v8();
                    }
                }).h();
            } else if (!this.c0.equals("disclaimer")) {
                xg.e2.J0(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.w8(ta, F);
                    }
                }).h();
            }
            try {
                xg.e2.J0(new Runnable() {
                    @Override
                    public final void run() {
                        Main.this.V4();
                    }
                }).h();
            } catch (Exception e2) {
                o7.l("T", "onCreate:bindMonitor", e2);
            }
        }
        sharedPreferences.edit().putInt("lvc", t2).commit();
        this.f0.e4();
        o7.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 up(this);
    }

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

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

    public io.b y6() {
        if (this.S == null) {
            return io.b.values()[d6.i.b.b];
        }
        int C5 = C5();
        pi u2 = this.S.u2(C5, "gprofs");
        if (u2 != null) {
            return u2.w();
        }
        o7.G("T", "getProfileSort: no project for index " + C5);
        return io.b.values()[d6.i.b.b];
    }

    private void y7(fn fnVar, net.dinglisch.android.taskerm.c cVar, List<Object> list) {
        int P0 = fnVar.P0();
        F6(P0);
        if (fnVar.q() && ep.r0(this)) {
            pp.a0(this, 2131887870, new Object[0]);
        } else {
            Wc(P0, cVar == null ? -1 : fnVar.R0(cVar), null, 20);
        }
    }

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

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

    private void ya() {
        ViewGroup viewGroup = (ViewGroup) findViewById(2131296877);
        if (viewGroup == null) {
            MyActivity.L(this, "populateEntityTools entityToolsLayout null");
            return;
        }
        this.E = viewGroup;
        if (fp.e0()) {
            viewGroup.setBackgroundColor(fp.C(this, R.attr.panelBackground, "T/tools"));
            Wa(true);
        } else {
            viewGroup.setBackgroundColor(fp.B(this));
        }
        int i2 = 0;
        while (true) {
            int[] iArr = k0;
            if (i2 >= iArr.length) {
                EditText editText = (EditText) findViewById(2131297652);
                this.B = editText;
                editText.setHint(oh.g(this, 2131888239, new Object[0]));
                this.B.addTextChangedListener(new y());
                return;
            }
            this.C[i2] = (ToggleButton) findViewById(iArr[i2]);
            String g2 = oh.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.t2(2131888083, new ik.a() {
            @Override
            public final Object e() {
                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;
        jl jlVar = this.v;
        if (jlVar != null) {
            jlVar.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;
        sh shVar = this.I;
        if (shVar != null) {
            shVar.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;
        ni niVar = this.x;
        if (niVar != null) {
            niVar.k();
            this.x = null;
        }
        zk zkVar = this.y;
        if (zkVar != null) {
            zkVar.k();
            this.y = null;
        }
        hn hnVar = this.z;
        if (hnVar != null) {
            hnVar.k();
            this.z = null;
        }
        up upVar = this.A;
        if (upVar != null) {
            upVar.k();
            this.A = null;
        }
        this.f0.h0();
    }

    public mj.i z6() {
        mj.i iVar = mj.i.User;
        fo foVar = this.S;
        if (foVar == null) {
            return iVar;
        }
        pi u2 = foVar.u2(C5(), "gss");
        if (u2 != null) {
            return u2.F();
        }
        o7.f("T", "gss: no project index " + C5());
        return iVar;
    }

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

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

    public ti.r z9(HashMap hashMap, String[] strArr) {
        if (this.w == null) {
            return ti.r.w(new df.p1());
        }
        StringBuilder sb = new StringBuilder();
        sb.append("<P>");
        for (String str : com.joaomgcd.taskerm.util.ac.k0()) {
            hashMap.remove(str);
        }
        HashMap hashMap2 = new HashMap();
        PackageManager packageManager = getPackageManager();
        for (String str2 : strArr) {
            String f2 = od.f(this, packageManager, str2);
            List list = (List) hashMap.get(str2);
            if (list != null) {
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    pp.n(hashMap2, f2, (String) it.next());
                }
            }
        }
        if (hashMap2.size() == 0) {
            return ti.r.w(new df.p1(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.w7(new df.r(this, 2131887507, oh.g(this, 2131887259, ExtensionsContextKt.Q0(this), sb.toString()), 2131886894, 2131886870, -1, false, 4));
    }

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

    private boolean zb() {
        return this.f0.t2(2131888084, new ik.a() {
            @Override
            public final Object e() {
                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.s2(2131887145, new ik.a() {
                @Override
                public final Object e() {
                    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 = {2131887156, 2131887155, 2131887154};
            int i2 = 0;
            while (true) {
                if (i2 >= 3) {
                    break;
                }
                if (pp.g() >= iArr[i2]) {
                    xo.g(this, iArr2[i2]);
                    xo.c(this, iArr2[i2]);
                    break;
                }
                i2++;
            }
        }
        if (!r5) {
            r5 = f5();
        }
        if (!r5) {
            r5 = o5();
        }
        if (!r5) {
            r5 = xo.e(this, 0, 2131890878, 2);
        }
        if (!r5) {
            r5 = xo.e(this, 0, 2131890917, 2);
        }
        if (!r5) {
            r5 = xo.e(this, 0, 2131890974, 5);
        }
        if (!r5) {
            r5 = xo.e(this, 0, 2131890858, 15);
        }
        if (!r5) {
            r5 = b5();
        }
        return !r5 ? Sb() : r5;
    }

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

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

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

    public int D5() {
        sh shVar = this.I;
        if (shVar != null) {
            return shVar.r();
        }
        o7.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(b2.a.Profile, "gotoProfile");
        ListView q6 = q6();
        if (q6 != null) {
            q6.post(new p(q6, i2, z2));
        }
    }

    public void F6(int i2) {
        fo foVar = this.S;
        if (foVar == null) {
            MyActivity.L(this, "gotoTask data null");
            return;
        }
        fn T = foVar.T(i2);
        if (T == null) {
            MyActivity.L(this, "gotoTask macroByID null");
            return;
        }
        if (!T.x()) {
            List<Integer> e02 = foVar.e0(i2);
            if (e02.size() > 0) {
                D6(e02.get(0).intValue());
                return;
            }
            return;
        }
        gd(foVar.H(i2));
        Qa(b2.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.e2(); i2++) {
            this.I.m(this, false);
        }
        Ia();
    }

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

    public void J5() {
        final com.joaomgcd.taskerm.dialog.b p2 = com.joaomgcd.taskerm.dialog.b.p(this, 2131887129);
        Yb(true);
        this.f0.E(new Runnable() {
            @Override
            public final void run() {
                Main.this.V7(p2);
            }
        });
    }

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

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

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

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

    public boolean Na(boolean z2) {
        aa("saveData: pre");
        fo w4 = this.S.w4(this);
        this.S = w4;
        boolean z3 = true;
        if (!w4.G4(this, this.M, this.O, t0, z2, true)) {
            T4(fo.J1(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;
                pp.a0(this, 2131889325, new Object[0]);
                return z2;
            }
            if (this.S.p5(this, file, str, 52, com.joaomgcd.taskerm.settings.d1.h(this))) {
                z2 = true;
                try {
                    File k12 = pp.k1();
                    if (k12 != null) {
                        en.c(k12, "usertabs.xml");
                    }
                    if (z2 && !ch.a(this)) {
                        pp.a0(this, 2131887822, new Object[0]);
                        return false;
                    }
                } catch (OutOfMemoryError unused2) {
                    pp.a0(this, 2131889325, new Object[0]);
                    return z2;
                }
                return z2;
            }
        }
        pp.n0(this, 2131891104, new Object[0]);
        z2 = false;
        if (z2) {
            pp.a0(this, 2131887822, new Object[0]);
            return false;
        }
        return z2;
    }

    public void Ta() {
        fo foVar = this.S;
        if (foVar == null) {
            MyActivity.L(this, "setDataDirtyWrapper data null");
        } else {
            foVar.P4();
            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 b2.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();
            }
            io ioVar = (io) this.x.getItem(i2);
            this.U = ioVar;
            if (ioVar == null) {
                o7.k("T", "unknown profile clicked, position " + i2 + " type " + i3);
                return;
            }
            fn M2 = this.S.M2(ioVar, i3);
            if (((M2 == null || !M2.q()) && !this.U.q()) || m5(7, new r.c(view, i2, i3, 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;
                    }
                }
                o7.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 (!rg.j(listView, i2) || !jl.I(this)) {
            return false;
        }
        this.v.E();
        return false;
    }

    @Override
    public void c(View view, int i2, int i3, boolean z2) {
        if (!y() || z2) {
            io ioVar = (io) this.x.getItem(i2);
            this.U = ioVar;
            if (z2) {
                wa();
            }
            if (!ioVar.q() || m5(3, new r.c(view, i2, i3, z2))) {
                this.W = i3;
                if (!z2) {
                    Kc(ioVar, i3, false);
                } else {
                    v();
                    Ib(ioVar, i3, view, i2);
                }
            }
        }
    }

    public void c7(boolean z2, int i2, r.b bVar) {
        Ia();
        if (z2) {
            R5(true);
            if (!this.c0.equals("disclaimer")) {
                w8(this.N.contains("dscl"), false);
            }
            v5();
            return;
        }
        switch (i2) {
            case 0:
                pp.j0(this, 2131887922, new Object[0]);
                break;
            case 1:
                Tc();
                break;
            case 2:
                Gb();
                break;
            case 3:
                try {
                    if (bVar instanceof r.c) {
                        r.c cVar = (r.c) bVar;
                        c(cVar.c(), cVar.a(), cVar.d(), cVar.b());
                        break;
                    }
                } catch (Throwable th2) {
                    o7.l("T", "LOCK_CONTEXT_CLICK", th2);
                    return;
                }
                break;
            case 4:
                L5();
                if (xo.d(this, 2131890981)) {
                    invalidateOptionsMenu();
                    break;
                }
                break;
            case 5:
                if (bVar instanceof r.e) {
                    r.e eVar = (r.e) bVar;
                    d(q6(), eVar.b(), eVar.a());
                    break;
                }
                break;
            case ClockContract.InstancesColumns.MISSED_STATE:
            case 13:
            case 14:
            case 16:
            case 19:
            default:
                o7.k("T", "unknown lock action " + i2);
                break;
            case 7:
                if (bVar instanceof r.c) {
                    r.c cVar2 = (r.c) bVar;
                    a(cVar2.c(), cVar2.a(), cVar2.d(), cVar2.b());
                    break;
                }
                break;
            case 8:
                if (bVar instanceof r.d) {
                    r7(((r.d) bVar).a());
                    break;
                }
                break;
            case 9:
                if (bVar instanceof r.d) {
                    w7(((r.d) bVar).a());
                    break;
                }
                break;
            case 10:
                if (bVar instanceof r.d) {
                    q7(((r.d) bVar).a());
                    break;
                }
                break;
            case 11:
                if (bVar instanceof r.d) {
                    qc(((r.d) bVar).a());
                    break;
                }
                break;
            case 12:
                I5();
                break;
            case 15:
                break;
            case 17:
                xc();
                break;
            case 18:
                Ab(29);
                break;
            case 20:
                if (bVar instanceof r.d) {
                    X6(((r.d) bVar).a());
                    break;
                }
                break;
        }
    }

    @Override
    public void d(ListView listView, int i2, int i3) {
        io ioVar = (io) this.x.getItem(i3);
        this.U = ioVar;
        if (ioVar == null) {
            o7.k("T", "onProfileCommand: no editingProfile");
            return;
        }
        boolean q2 = ioVar.q();
        o7.f("T", "onProfileCommand: position: " + i3 + " command: " + i2 + " collapsed: " + this.U.f1() + " locked/Imp: " + q2);
        if (!q2 || m5(5, new r.e(i2, 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<mj> it = this.S.a(-2, mj.i.User, true).iterator();
        while (it.hasNext()) {
            fl.h(this, it.next());
        }
    }

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

    @Override
    public void g(com.joaomgcd.taskerm.util.ac acVar, com.joaomgcd.taskerm.util.se seVar) {
    }

    public uk.n0 getCoroutineScope() {
        return super.getCoroutineScope();
    }

    @Override
    public com.joaomgcd.taskerm.helper.j getHelper() {
        return this.f0;
    }

    public fo n6(String str) {
        return C6(str, fo.w1(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")) {
                pp.a0(this, 2131887800, new Object[0]);
                return;
            }
            pp.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, b2.a.Variable);
        } else if (id == iArr[1]) {
            this.M.edit().putBoolean(h0[1], this.C[1].isChecked()).commit();
            K6(false, b2.a.Variable);
        } else if (id == iArr[2]) {
            this.M.edit().putBoolean(h0[2], this.C[2].isChecked()).commit();
            K6(false, b2.a.Variable);
        }
    }

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

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

    @EventBusRxSubscription
    @Keep
    public void onDataImported(bf.a aVar) {
        f5 a2 = aVar.a();
        this.S = fo.w1(this);
        if (a2 instanceof pi) {
            if (aVar.b()) {
                S4();
            }
            L6(b2.a.values());
        } else if (a2 instanceof io) {
            L6(b2.a.Profile, b2.a.Task);
        } else if (a2 instanceof fn) {
            L6(b2.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 p4 = this.f0.p4(i2, keyEvent);
        return !p4 ? super.onKeyDown(i2, keyEvent) : p4;
    }

    @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.X(this);
                        } else if (itemId == 10000) {
                            this.f0.p0(com.joaomgcd.taskerm.util.bi.o(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.i4();
                            } 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:
                                        xg.e2.U0(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() && !fp.e0()) {
                                                            gi.h(this, 2131890883, 2131890981);
                                                            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:
                                                                pp.j0(this, 2131888968, new Object[0]);
                                                                break;
                                                            default:
                                                                switch (itemId) {
                                                                    case 55:
                                                                        Ic(d4.w(true), 30);
                                                                        break;
                                                                    case 56:
                                                                        Ic(bi.j(), 26);
                                                                        break;
                                                                    case 57:
                                                                        Ic(MyAccessibilityService.f(), 26);
                                                                        break;
                                                                    case 58:
                                                                        if (!ud.i0.g((PowerManager) gi.d(getApplicationContext(), "power", "T", "androidpowermanagementmenu"), getPackageName())) {
                                                                            Ic(o6(this), 26);
                                                                            break;
                                                                        } else {
                                                                            this.f0.p0(com.joaomgcd.taskerm.dialog.a.w7(new df.r(this, 2131887461, 2131887142)));
                                                                            break;
                                                                        }
                                                                    case 59:
                                                                        TextBoxDialogFragment.Z(this, new a(), 2131888757, oh.g(this, 2131887185, new Object[0]));
                                                                        break;
                                                                    case 60:
                                                                        Ic(od.h(this), 26);
                                                                        break;
                                                                    case 61:
                                                                        Ic(od.d(this), 26);
                                                                        break;
                                                                    case 62:
                                                                        Ic(od.g(this), 26);
                                                                        break;
                                                                    case 63:
                                                                        Ic(Settings.G1(this), 26);
                                                                        break;
                                                                    case 64:
                                                                        Ic(bi.k(), 26);
                                                                        break;
                                                                    case 65:
                                                                        if (m5(19, null)) {
                                                                            this.f0.q0(GenericActionBackupToGoogleDrive.restoreFromGoogleDrive(this), new yi.d() {
                                                                                @Override
                                                                                public final void accept(Object obj) {
                                                                                    Main.this.G8((com.joaomgcd.taskerm.util.we) obj);
                                                                                }
                                                                            });
                                                                            break;
                                                                        }
                                                                        break;
                                                                    case 66:
                                                                        Bb();
                                                                        break;
                                                                    case 67:
                                                                        Db();
                                                                        break;
                                                                    case 68:
                                                                        Cb();
                                                                        break;
                                                                    case 69:
                                                                        this.f0.q0(new GenericActionActivityRequestCallScreeningAccess().run(this), new yi.d() {
                                                                            @Override
                                                                            public final void accept(Object obj) {
                                                                                Main.this.K8((com.joaomgcd.taskerm.util.pe) obj);
                                                                            }
                                                                        });
                                                                        break;
                                                                    case 70:
                                                                        this.f0.x4();
                                                                        break;
                                                                    case 71:
                                                                        this.f0.N4();
                                                                        break;
                                                                    case 72:
                                                                        Eb();
                                                                        break;
                                                                    case 73:
                                                                        this.f0.p0(new GenericActionActivityRequestManageExternalStorageAccess().run(this));
                                                                        break;
                                                                    default:
                                                                        boolean S6 = S6(menuItem);
                                                                        return !S6 ? sc.e.a(this, menuItem) : S6;
                                                                }
                                                        }
                                                }
                                        }
                                }
                            } else {
                                Ic(od.c(), 26);
                            }
                        }
                    } else if (m5(12, null)) {
                        I5();
                    }
                }
                if (xo.g(this, 2131887140)) {
                    O6(itemId);
                } else {
                    TextBoxDialogFragment.Y(this, new m1(itemId), 2131887140);
                }
            } else {
                Tc();
            }
        } else if (m5(2, null)) {
            Gb();
        }
        return true;
    }

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

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        menu.add(0, 70, 0, 2131890743);
        menu.add(0, 71, 0, 2131891006);
        if (MonitorService.d2(this)) {
            menu.add(0, 42, 0, oh.g(this, 2131888838, new Object[0]));
        } else {
            menu.add(0, 43, 0, oh.g(this, 2131888856, new Object[0]));
        }
        if (!l6(64)) {
            net.dinglisch.android.taskerm.a.c(this, 32, 0, 2131886798, menu);
        }
        menu.add(0, 4, 0, oh.g(this, 2131889016, new Object[0]));
        SubMenu addSubMenu = menu.addSubMenu(0, 9995, 0, oh.g(this, 2131889065, new Object[0]));
        SubMenu addSubMenu2 = menu.addSubMenu(0, 9999, 0, oh.g(this, 2131889062, new Object[0]));
        addSubMenu2.add(0, 0, 0, oh.g(this, 2131888800, new Object[0]));
        addSubMenu2.add(0, 7, 0, oh.g(this, 2131888774, new Object[0]));
        ga(addSubMenu2);
        addSubMenu2.add(0, 46, 0, oh.g(this, 2131891265, new Object[0]));
        addSubMenu2.addSubMenu(0, 9999, 0, oh.g(this, 2131889574, new Object[0])).add(0, 47, 0, oh.g(this, 2131886646, new Object[0]));
        ea(menu.addSubMenu(0, 9998, 0, oh.g(this, 2131889064, new Object[0])));
        SubMenu addSubMenu3 = menu.addSubMenu(0, 9997, 0, oh.g(this, 2131889066, new Object[0]));
        addSubMenu3.addSubMenu(0, 9996, 0, oh.g(this, 2131889061, new Object[0])).add(0, 11, 0, oh.g(this, 2131888787, new Object[0]));
        ba(addSubMenu3.addSubMenu(0, 9997, 0, oh.g(this, 2131888761, new Object[0])));
        addSubMenu3.add(0, 21, 0, oh.g(this, 2131888983, new Object[0]));
        SharedPreferences sharedPreferences = this.M;
        if (sharedPreferences == null || !Settings.j1(sharedPreferences)) {
            da(addSubMenu3.addSubMenu(0, 9997, 0, oh.g(this, 2131889063, new Object[0])));
        }
        if (rd()) {
            net.dinglisch.android.taskerm.a.z(this, 44, menu, 2131886865, 2130969153, 1);
        }
        net.dinglisch.android.taskerm.a.z(this, 30, menu, 2131887551, 2130969268, 1);
        menu.add(0, 10000, 0, 2131888815);
        sc.e.b(menu, addSubMenu3, addSubMenu);
        addSubMenu.add(0, 26, 0, oh.g(this, 2131889099, new Object[0]));
        return true;
    }

    @Override
    public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
        Va("reqPermsDialog", false);
        this.f0.x1(i2, strArr, iArr);
        com.joaomgcd.taskerm.util.ac acVar = this.w;
        if (acVar == null) {
            return;
        }
        for (com.joaomgcd.taskerm.util.u9 u9Var : acVar.T0(i2, strArr, iArr)) {
            o7.F("T", "orpResult: perm: " + u9Var.c() + " res: " + u9Var.b());
        }
        finish();
    }

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

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        bundle.putInt("ssf", this.T);
        io ioVar = this.U;
        if (ioVar != null) {
            bundle.putInt("sspid", ioVar.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);
        }
        b2.a aVar = this.a0;
        if (aVar != null) {
            bundle.putString("eent", aVar.toString());
        }
        if (this.Z != null) {
            bundle.putBoolean("ssed", true);
            this.Z.X(0).d0(this, "ssed", 0);
        }
        if (this.Y != null) {
            bundle.putBoolean("sseo", true);
            this.Y.X(0).d0(this, "sseo", 0);
        }
    }

    @Override
    protected void onStart() {
        bb(true, "onStart");
        this.R = true;
        o7.f("T", "onStart");
        super.onStart();
        if (!v0) {
            this.f0.m0(xg.h.o(this));
            o7.f("T", "onStart done");
            return;
        }
        v0 = false;
        o7.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();
        xg.h.q(this);
    }

    @EventBusRxSubscription
    @Keep
    public void onTaskerEnabledChange(xf.k7 k7Var) {
        mb(this);
    }

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

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

    public boolean q7(int i2) {
        pi u2 = this.S.u2(Da(i2), "hptc");
        if (u2 == null) {
            return false;
        }
        if (u2.W() && !m5(10, new r.d(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;
        mj mjVar = (mj) this.y.getItem(i2);
        if (!mjVar.q() || m5(8, new r.d(i2))) {
            Rc(mjVar.getName(), null, -1);
        }
    }

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

    public void sb(b2.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) {
        ni niVar;
        o7.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.p2().iterator();
            while (it.hasNext()) {
                int intValue = it.next().intValue();
                if (intValue != C0) {
                    this.S.c(intValue).b0();
                }
            }
        }
        K6(false, b2.a.Profile);
        if (f12 && (niVar = this.x) != null && i2 == niVar.getCount() - 1 && pd(this) && this.x.getCount() > listView.getChildCount()) {
            o7.f("T", "move up");
            listView.setSelection(i2);
        }
    }

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

    public fo w6(String str) {
        return C6(str, fo.k2(this, false));
    }

    public void w7(int i2) {
        this.U = null;
        fn fnVar = (fn) this.z.getItem(i2);
        if (fnVar == null) {
            o7.G("T", "handleTaskClick: no task at position " + i2);
            return;
        }
        this.W = fnVar.P0();
        if (!fnVar.q() || m5(9, new r.d(i2))) {
            Vc(fnVar.P0());
        }
    }

    public void x7(int[] iArr) {
        for (int i2 : iArr) {
            this.S.i1(i2);
        }
        L6(b2.a.Profile, b2.a.Task);
        v();
        pp.j0(this, 2131888723, new Object[0]);
    }

    public void xa() {
        int i2;
        int i3;
        int i4;
        RelativeLayout relativeLayout = (RelativeLayout) findViewById(2131296876);
        if (relativeLayout == null) {
            MyActivity.L(this, "populateEntityTabs entityTabHost null");
            return;
        }
        this.G = relativeLayout;
        relativeLayout.removeAllViews();
        if (fp.h0(this)) {
            i2 = gp.c(this);
            i3 = fp.L(this);
            i4 = fp.q(this);
        } else {
            i2 = 0;
            i3 = 0;
            i4 = 0;
        }
        sh A = sh.A(this, relativeLayout, i2, i3, i4);
        this.J = A;
        A.V(new u());
        this.J.U(12);
        if (this.P == null) {
            this.P = findViewById(2131297224);
        } else {
            this.Q.d(false);
        }
        this.Q = new v1(this, this.P);
        Bundle bundle = new Bundle();
        bundle.putString("type", b2.a.Profile.toString());
        Bundle bundle2 = new Bundle();
        bundle2.putString("type", b2.a.Task.toString());
        Bundle bundle3 = new Bundle();
        bundle3.putString("type", b2.a.Scene.toString());
        Bundle bundle4 = new Bundle();
        bundle4.putString("type", b2.a.Variable.toString());
        Bundle[] bundleArr = {bundle, bundle2, bundle3, bundle4};
        boolean j12 = Settings.j1(pp.R0(this));
        for (b2.a aVar : b2.a.values()) {
            if (!j12 || aVar != b2.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(), oh.g(this, b2.f(aVar), new Object[0]));
            }
        }
        this.Q.notifyDataSetChanged();
    }
}