导航菜单

页面标题

页面副标题

Tasker v6.5.11 - AppSelect.java 源代码

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

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


package net.dinglisch.android.taskerm;

import android.app.ActionBar;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.joaomgcd.taskerm.util.App;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

public class AppSelect extends MyActivity implements AdapterView.OnItemClickListener, pf.a {
    private static List<c1> O = new ArrayList();
    private static List<c1> P = new ArrayList();
    private static boolean Q = false;
    private static boolean R = false;
    private static boolean S = false;
    private ToggleButton G;
    private ToggleButton H;
    private ToggleButton I;
    private ToggleButton J;
    private ImageView K;
    private List<c1> v;
    private GridView w;
    private PackageManager x;
    private LayoutInflater z;
    private g1 y = null;
    private ArrayList<String> A = null;
    private boolean B = false;
    private boolean C = false;
    private boolean D = false;
    private boolean E = false;
    private boolean F = false;
    private f L = null;
    private TextView M = null;
    private com.joaomgcd.taskerm.helper.e<AppSelect> N = new com.joaomgcd.taskerm.helper.e<>(this);

    class a implements View.OnClickListener {
        a() {
        }

        @Override
        public void onClick(View view) {
            AppSelect.R = AppSelect.this.H.isChecked();
            AppSelect.this.N0(AppSelect.R);
        }
    }

    class b implements AdapterView.OnItemLongClickListener {
        b() {
        }

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long j) {
            c1 c1Var = (c1) ((g) adapterView.getAdapter()).getItem(i);
            AppSelect.this.M0(c1Var.a, c1Var.c);
            return true;
        }
    }

    class c extends Handler {
        c() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                MyAccessibilityService.v(AppSelect.this);
            } else {
                AppSelect.this.D0();
            }
        }
    }

    class d extends Handler {
        d() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                wp.e(AppSelect.this);
            } else {
                AppSelect.this.D0();
            }
        }
    }

    class e extends Handler {
        final List a;
        final String b;
        final String[] c;
        final String[] d;
        final String e;

        e(List list, String str, String[] strArr, String[] strArr2, String str2) {
            this.a = list;
            this.b = str;
            this.c = strArr;
            this.d = strArr2;
            this.e = str2;
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 1) {
                int i = message.getData().getInt("index");
                String str = ((ActivityInfo) this.a.get(i)).name;
                StringBuilder sb = new StringBuilder();
                sb.append(this.b);
                sb.append(ConstantsCommonTaskerServer.ID_SEPARATOR);
                sb.append(this.c[i].length() > 0 ? this.c[i] : this.d[i]);
                AppSelect.this.y.U0(this.e, str, sb.toString());
                AppSelect.this.P0();
                AppSelect.this.finish();
            }
        }
    }

    public class f extends AsyncTask<Boolean, Integer, Boolean> {
        public f() {
        }

        @Override
        public Boolean doInBackground(Boolean... boolArr) {
            AppSelect appSelect = AppSelect.this;
            appSelect.v = AppSelect.E0(appSelect, appSelect.x, boolArr[0].booleanValue());
            return Boolean.TRUE;
        }

        @Override
        public void onPostExecute(Boolean bool) {
            r7.f("AS", "app list loaded");
            AppSelect.this.L = null;
            AppSelect.this.Q0(false);
            if (bool.booleanValue() && AppSelect.this.w != null) {
                AppSelect.this.w.setAdapter((ListAdapter) AppSelect.this.new g());
            }
            if (AppSelect.this.H != null) {
                AppSelect.this.H.setClickable(true);
            }
        }
    }

    public class g extends BaseAdapter {
        private List<c1> i = new ArrayList();

        class a {
            TextView a;
            ImageView b;
            View c;
            ImageView d;

            a() {
            }
        }

        public g() {
            String packageName = AppSelect.this.getPackageName();
            for (c1 c1Var : AppSelect.this.v) {
                if (AppSelect.Q || !c1Var.a.equals(packageName)) {
                    if (AppSelect.this.A == null) {
                        this.i.add(c1Var);
                    } else {
                        Iterator it = AppSelect.this.A.iterator();
                        while (true) {
                            if (it.hasNext()) {
                                if (c1Var.a.equals((String) it.next())) {
                                    this.i.add(c1Var);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }

        @Override
        public final int getCount() {
            return this.i.size();
        }

        @Override
        public final Object getItem(int i) {
            return this.i.get(i);
        }

        @Override
        public final long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            a aVar;
            if (view == null) {
                view = AppSelect.this.z.inflate(2131492899, (ViewGroup) null);
                aVar = new a();
                aVar.a = (TextView) view.findViewById(2131297590);
                aVar.b = (ImageView) view.findViewById(2131296972);
                aVar.d = (ImageView) view.findViewById(2131297538);
                aVar.c = view.findViewById(2131297537);
                if (tp.e0()) {
                    up.v(view);
                    aVar.b.setBackgroundColor(0);
                }
                view.setTag(aVar);
            } else {
                aVar = (a) view.getTag();
            }
            c1 c1Var = this.i.get(i);
            Bitmap a2 = c1Var.a(AppSelect.this.getApplicationContext());
            if (a2 == null) {
                aVar.b.setImageResource(2131230944);
            } else {
                aVar.b.setImageBitmap(a2);
            }
            aVar.a.setText(c1Var.c);
            if (AppSelect.this.D) {
                aVar.d.setVisibility(0);
            } else {
                aVar.d.setVisibility(8);
            }
            if (!AppSelect.this.C) {
                aVar.c.setBackgroundResource(tp.y(AppSelect.this, AppSelect.this.y.k1(c1Var.a, c1Var.b)));
            }
            return view;
        }
    }

    public void D0() {
        a1();
        P0();
        finish();
    }

    public static synchronized List<c1> E0(Context context, PackageManager packageManager, boolean z) {
        List<ResolveInfo> list;
        List<ResolveInfo> list2;
        List<c1> list3;
        synchronized (AppSelect.class) {
            int i = 0;
            try {
                String g2 = vh.g(context, 2131891241, new Object[0]);
                String g3 = vh.g(context, 2131887000, new Object[0]);
                List<c1> F0 = F0(z);
                if (F0 != null) {
                    return F0;
                }
                HashSet<String> hashSet = new HashSet();
                hashSet.add("android.intent.category.DESK_DOCK");
                hashSet.add("android.intent.category.LE_DESK_DOCK");
                hashSet.add("android.intent.category.HE_DESK_DOCK");
                hashSet.add("android.intent.category.CAR_DOCK");
                hashSet.add("android.intent.category.LAUNCHER");
                if (z) {
                    hashSet.add("android.intent.category.DEFAULT");
                }
                ArrayList arrayList = new ArrayList();
                HashSet hashSet2 = new HashSet();
                hashSet2.add(I0(context.getPackageName(), DockActivityCar.class.getName()));
                hashSet2.add(I0(context.getPackageName(), DockActivityDesk.class.getName()));
                List<c1> list4 = z ? P : O;
                List<ResolveInfo> o = th.o(packageManager);
                for (String str : hashSet) {
                    Intent intent = new Intent("android.intent.action.MAIN");
                    intent.addCategory(str);
                    try {
                        list = packageManager.queryIntentActivities(intent, i);
                    } catch (Exception unused) {
                        r7.G("AS", "system failed to return app list");
                        list = null;
                    }
                    List<ResolveInfo> list5 = list;
                    if (list5 != null) {
                        if (!dq.F(o)) {
                            try {
                                list5.addAll(o);
                            } catch (UnsupportedOperationException e2) {
                                r7.H("AS", "getAppList", e2);
                            }
                        }
                        Iterator<ResolveInfo> it = list5.iterator();
                        while (it.hasNext()) {
                            ActivityInfo activityInfo = it.next().activityInfo;
                            if (activityInfo != null) {
                                String str2 = activityInfo.name;
                                String I0 = I0(activityInfo.packageName, str2);
                                if (!hashSet2.contains(I0)) {
                                    hashSet2.add(I0);
                                    list2 = o;
                                    list3 = list4;
                                    String O0 = O0(context, activityInfo.packageName, str2, dq.y(activityInfo.loadLabel(packageManager)), g2, g3);
                                    int size = arrayList.size();
                                    int i2 = 0;
                                    while (i2 < size && O0.compareToIgnoreCase((String) arrayList.get(i2)) >= 0) {
                                        i2++;
                                    }
                                    list3.add(i2, new c1(activityInfo.packageName, str2, O0));
                                    arrayList.add(i2, O0);
                                    list4 = list3;
                                    o = list2;
                                }
                            }
                            list2 = o;
                            list3 = list4;
                            list4 = list3;
                            o = list2;
                        }
                    }
                    list4 = list4;
                    o = o;
                    i = 0;
                }
                return com.joaomgcd.taskerm.util.k8.j(list4, new xj.l() {
                    @Override
                    public final Object invoke(Object obj) {
                        String str3;
                        str3 = ((c1) obj).a;
                        return str3;
                    }
                });
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    private static synchronized List<c1> F0(boolean z) {
        List<c1> list;
        synchronized (AppSelect.class) {
            try {
                if (S) {
                    O.clear();
                    P.clear();
                    S = false;
                } else if (z) {
                    if (P.size() > 0) {
                        list = P;
                    }
                } else if (O.size() > 0) {
                    list = O;
                }
                list = null;
            } catch (Throwable th2) {
                throw th2;
            }
        }
        return list;
    }

    public static Intent G0(Context context, boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, ArrayList<String> arrayList, g1 g1Var) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(context, AppSelect.class.getName()));
        if (g1Var != null) {
            intent.putExtra("ssc", g1Var.U(0).c0());
        }
        intent.putExtra("a", z2);
        intent.putExtra("sv", z3);
        intent.putExtra("ns", z6);
        intent.putExtra("s", z4);
        intent.putExtra("o", z);
        intent.putExtra("at", z5);
        if (arrayList != null) {
            intent.putStringArrayListExtra("pkgs", arrayList);
        }
        return intent;
    }

    private static String H0(String str, String str2) {
        return str2.replace(str + ".", "").replace("Settings$", "").replace("com.samsung.", " Samsung ");
    }

    private static String I0(String str, String str2) {
        return str + "." + str2;
    }

    public static int K0(g1 g1Var, c1 c1Var, c1 c1Var2) {
        return Boolean.compare(!g1Var.k1(c1Var.a, c1Var.b), !g1Var.k1(c1Var2.a, c1Var2.b));
    }

    public void L0(CompoundButton compoundButton, boolean z) {
        if (z) {
            this.N.Q(com.joaomgcd.taskerm.dialog.a.l0(this));
        }
    }

    public void M0(String str, String str2) {
        PackageManager packageManager = getPackageManager();
        List<ActivityInfo> exportedActivities = App.getExportedActivities(this, str);
        int i = 0;
        if (dq.F(exportedActivities)) {
            dq.k0(this, dq.J3(vh.g(this, 2131887867, new Object[0])));
            return;
        }
        String[] strArr = new String[exportedActivities.size()];
        String[] strArr2 = new String[exportedActivities.size()];
        net.dinglisch.android.taskerm.g[] gVarArr = new net.dinglisch.android.taskerm.g[exportedActivities.size()];
        for (ActivityInfo activityInfo : exportedActivities) {
            strArr2[i] = dq.z2(str, activityInfo.name);
            net.dinglisch.android.taskerm.g gVar = new net.dinglisch.android.taskerm.g();
            gVar.p0(str, activityInfo.name);
            gVarArr[i] = gVar;
            CharSequence loadLabel = activityInfo.loadLabel(packageManager);
            strArr[i] = (TextUtils.isEmpty(loadLabel) || str2.equals(loadLabel)) ? "" : loadLabel.toString();
            i++;
        }
        wj.E(new e(exportedActivities, str2, strArr, strArr2, str), str2).J(strArr2, gVarArr).S(strArr).b0().C(this);
    }

    public void N0(boolean z) {
        List<c1> F0 = F0(z);
        if (F0 == null) {
            this.H.setClickable(false);
            Q0(true);
            f fVar = new f();
            this.L = fVar;
            fVar.execute(Boolean.valueOf(z));
            return;
        }
        Q0(false);
        final g1 g1Var = this.y;
        if (g1Var != null) {
            Collections.sort(F0, new Comparator() {
                @Override
                public final int compare(Object obj, Object obj2) {
                    int K0;
                    K0 = AppSelect.K0(g1.this, (c1) obj, (c1) obj2);
                    return K0;
                }
            });
        }
        this.v = F0;
        this.w.setAdapter((ListAdapter) new g());
    }

    private static String O0(Context context, String str, String str2, String str3, String str4, String str5) {
        String str6;
        if (!TextUtils.isEmpty(str3)) {
            if (!str3.equals(str4) && !str3.equals(str5)) {
                return str3;
            }
            return str3 + "\n" + H0(str, str2);
        }
        if (str.equals("com.android.settings")) {
            str6 = str4 + "\n";
        } else {
            str6 = "";
        }
        return str6 + H0(str, str2);
    }

    public void P0() {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        W0(bundle);
        intent.putExtras(bundle);
        setResult(-1, intent);
    }

    public void Q0(boolean z) {
        if (z) {
            TextView textView = this.M;
            if (textView != null) {
                textView.setVisibility(0);
            }
            GridView gridView = this.w;
            if (gridView != null) {
                gridView.setVisibility(4);
                return;
            }
            return;
        }
        TextView textView2 = this.M;
        if (textView2 != null) {
            textView2.setVisibility(8);
        }
        GridView gridView2 = this.w;
        if (gridView2 != null) {
            gridView2.setVisibility(0);
        }
    }

    private void R0() {
        setContentView(2131492898);
        if (tp.e0()) {
            findViewById(2131297036).setBackgroundColor(0);
            findViewById(2131296951).setVisibility(0);
        }
        TextView textView = (TextView) findViewById(2131297252);
        this.M = textView;
        textView.setText(vh.g(this, 2131888404, new Object[0]));
        this.M.setTextColor(tp.L(this));
        this.G = (ToggleButton) findViewById(2131296512);
        this.I = (ToggleButton) findViewById(2131296565);
        this.J = (ToggleButton) findViewById(2131296459);
        String g2 = vh.g(this, 2131886814, new Object[0]);
        this.I.setTextOn(g2);
        this.I.setTextOff(g2);
        String g3 = vh.g(this, 2131891117, new Object[0]);
        this.J.setTextOn(g3);
        this.J.setTextOff(g3);
        String g4 = vh.g(this, 2131891185, new Object[0]);
        this.G.setTextOn(g4);
        this.G.setTextOff(g4);
        this.K = new ImageView(this);
        this.H = (ToggleButton) findViewById(2131296456);
        String g5 = vh.g(this, 2131886791, new Object[0]);
        this.H.setTextOn(g5);
        this.H.setTextOff(g5);
        this.H.setChecked(R);
        this.H.setOnClickListener(new a());
        GridView gridView = (GridView) findViewById(2131297570);
        this.w = gridView;
        gridView.setOnItemClickListener(this);
        if (tp.e0()) {
            int w = tp.w(this, 2131165267);
            this.w.setVerticalSpacing(w);
            this.w.setHorizontalSpacing(w);
            up.D(findViewById(2131296440));
        }
    }

    private void T0(Bundle bundle) {
        if (bundle == null) {
            return;
        }
        S0(bundle.getBoolean("o"), bundle.getBoolean("a"), bundle.getBoolean("sv"), bundle.getBoolean("at"), bundle.getBoolean("s"), bundle.getBoolean("ns"), bundle.getStringArrayList("pkgs"), bundle.containsKey("ssc") ? new g1(new qi(bundle.getBundle("ssc"))) : null);
    }

    public static void U0() {
        S = true;
    }

    private boolean V0() {
        boolean z = true;
        if (this.y.d1() == 0) {
            if (this.F) {
                return dq.a0(this, 2131889113, new Object[0]);
            }
        } else {
            if ((this.D || this.E) && !this.I.isChecked() && !this.J.isChecked()) {
                return dq.a0(this, 2131887892, this.J.getText(), this.I.getText());
            }
            if (this.J.isChecked() && g1.r1(this) && !MyAccessibilityService.p()) {
                Y0();
            } else if (this.J.isChecked() && g1.s1(this) && !wp.c(this)) {
                Z0();
            }
            z = false;
        }
        if (z) {
            D0();
        }
        return z;
    }

    private void W0(Bundle bundle) {
        bundle.putBoolean("a", this.D);
        bundle.putBoolean("sv", this.E);
        bundle.putBoolean("ns", this.F);
        bundle.putBoolean("s", this.B);
        bundle.putBoolean("o", this.C);
        bundle.putBoolean("at", Q);
        ArrayList<String> arrayList = this.A;
        if (arrayList != null) {
            bundle.putStringArrayList("pkgs", arrayList);
        }
        g1 g1Var = this.y;
        if (g1Var != null) {
            if (this.B) {
                g1Var.N0(this.G.isChecked());
            }
            if (this.E) {
                this.y.o1(this.I.isChecked());
                this.y.n1(this.J.isChecked());
            }
            bundle.putBundle("ssc", this.y.U(0).c0());
        }
    }

    private void X0() {
        if (this.w != null) {
            Point point = new Point();
            getWindowManager().getDefaultDisplay().getSize(point);
            int Y = point.x / tp.Y(100);
            if (Y == 0) {
                Y = 3;
            }
            this.w.setNumColumns(Y);
        }
    }

    private void Y0() {
        TextBoxDialogFragment.F(this, new c(), 2131887405, vh.g(this, 2131886119, new Object[0]) + "\n\n" + vh.g(this, 2131887259, new Object[0]), 2131886891, 2131886889, -1, 0).E(this);
    }

    private void Z0() {
        TextBoxDialogFragment.F(this, new d(), 2131891282, vh.g(this, 2131887270, new Object[0]), 2131886891, 2131886889, -1, 0).E(this);
    }

    private void a1() {
        f fVar = this.L;
        if (fVar != null) {
            fVar.cancel(true);
        }
    }

    private boolean b1() {
        return this.B && ti.d(this.x);
    }

    public void S0(boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, ArrayList<String> arrayList, g1 g1Var) {
        if (g1Var == null) {
            this.y = new g1();
        } else {
            g1 t0 = g1Var.t0();
            this.y = t0;
            t0.m1(this.x);
        }
        this.D = z2;
        this.A = arrayList;
        this.C = z;
        this.B = z5;
        Q = z4;
        this.E = z3;
        this.F = z6;
        if (z5) {
            this.G.setChecked(this.y.H0());
            this.G.setVisibility(0);
        } else {
            this.G.setVisibility(8);
        }
        if (z2) {
            this.w.setOnItemLongClickListener(new b());
        }
        if (b1()) {
            this.y.S0(this, this.K);
        }
        if (this.E) {
            this.I.setChecked(this.y.u1());
            this.I.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public final void onCheckedChanged(CompoundButton compoundButton, boolean z7) {
                    AppSelect.this.L0(compoundButton, z7);
                }
            });
            this.J.setChecked(this.y.t1());
            this.I.setVisibility(0);
            this.J.setVisibility(0);
        } else {
            this.I.setVisibility(8);
            this.J.setVisibility(8);
        }
        ActionBar actionBar = getActionBar();
        if (this.y.D0()) {
            actionBar.setSubtitle(this.y.getName());
        }
        if (tp.e0()) {
            return;
        }
        actionBar.setHomeButtonEnabled(!z);
        actionBar.setDisplayOptions((z ? 0 : 4) | 10);
    }

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

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

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        X0();
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.N.I();
        setResult(0);
        this.x = getPackageManager();
        this.z = LayoutInflater.from(this);
        R0();
        net.dinglisch.android.taskerm.a.T(this, true).setTitle(vh.g(this, 2131886722, new Object[0]));
        if (bundle == null) {
            bundle = getIntent().getExtras();
        }
        T0(bundle);
        X0();
        N0(R);
        if (this.D) {
            if (Settings.j1(dq.R0(this))) {
                this.D = false;
            } else {
                lp.d(this, 2131890834);
            }
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.v = null;
        this.w = null;
        this.x = null;
        this.y = null;
        this.z = null;
        this.G = null;
        this.I = null;
        this.J = null;
        this.H = null;
        this.K = null;
        this.L = null;
        this.M = null;
        this.N.J();
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        g gVar = (g) adapterView.getAdapter();
        c1 c1Var = (c1) gVar.getItem(i);
        r7.f("AS", "NAME:" + c1Var.b);
        r7.f("AS", "PKG:" + c1Var.a);
        if (this.y.k1(c1Var.a, c1Var.b)) {
            this.y.l1(c1Var.a, c1Var.b);
        } else {
            this.y.U0(c1Var.a, c1Var.b, c1Var.c);
        }
        if (this.C) {
            P0();
            finish();
        } else {
            gVar.notifyDataSetChanged();
            this.w.setSelection(i);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 5) {
            finish();
            return true;
        }
        if (itemId != 16908332) {
            return true;
        }
        V0();
        return true;
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        if (b1()) {
            net.dinglisch.android.taskerm.a.J(this, 8, this.K, menu);
        }
        net.dinglisch.android.taskerm.a.d(this, 5, menu);
        return true;
    }

    @Override
    public void onRestoreInstanceState(Bundle bundle) {
        super.onRestoreInstanceState(bundle);
        T0(bundle);
    }

    @Override
    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        W0(bundle);
    }
}