导航菜单

页面标题

页面副标题

Tasker v6.6.3 - AppSelect.java 源代码

正在查看: Tasker v6.6.3 应用的 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, xf.a, ze.e {
    private static List<b1> O = new ArrayList();
    private static List<b1> 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<b1> v;
    private GridView w;
    private PackageManager x;
    private LayoutInflater z;
    private f1 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.h<AppSelect> N = new com.joaomgcd.taskerm.helper.h<>(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) {
            b1 b1Var = (b1) ((g) adapterView.getAdapter()).getItem(i);
            AppSelect.this.M0(b1Var.a, b1Var.c);
            return true;
        }
    }

    class c extends Handler {
        c() {
        }

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

    class d extends Handler {
        d() {
        }

        @Override
        public void handleMessage(Message message) {
            if (message.what == 0) {
                ip.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.Y0(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) {
            o7.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<b1> i = new ArrayList();

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

            a() {
            }
        }

        public g() {
            String packageName = AppSelect.this.getPackageName();
            for (b1 b1Var : AppSelect.this.v) {
                if (AppSelect.Q || !b1Var.a.equals(packageName)) {
                    if (AppSelect.this.A == null) {
                        this.i.add(b1Var);
                    } else {
                        Iterator it = AppSelect.this.A.iterator();
                        while (true) {
                            if (it.hasNext()) {
                                if (b1Var.a.equals((String) it.next())) {
                                    this.i.add(b1Var);
                                    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(2131297592);
                aVar.b = (ImageView) view.findViewById(2131296973);
                aVar.d = (ImageView) view.findViewById(2131297540);
                aVar.c = view.findViewById(2131297539);
                if (fp.e0()) {
                    gp.v(view);
                    aVar.b.setBackgroundColor(0);
                }
                view.setTag(aVar);
            } else {
                aVar = (a) view.getTag();
            }
            b1 b1Var = this.i.get(i);
            Bitmap a2 = b1Var.a(AppSelect.this.getApplicationContext());
            if (a2 == null) {
                aVar.b.setImageResource(2131230944);
            } else {
                aVar.b.setImageBitmap(a2);
            }
            aVar.a.setText(b1Var.c);
            if (AppSelect.this.D) {
                aVar.d.setVisibility(0);
            } else {
                aVar.d.setVisibility(8);
            }
            if (!AppSelect.this.C) {
                aVar.c.setBackgroundResource(fp.y(AppSelect.this, AppSelect.this.y.o1(b1Var.a, b1Var.b)));
            }
            return view;
        }
    }

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

    public static synchronized List<b1> E0(Context context, PackageManager packageManager, boolean z) {
        List<ResolveInfo> list;
        List<ResolveInfo> list2;
        List<b1> list3;
        synchronized (AppSelect.class) {
            int i = 0;
            try {
                String g2 = oh.g(context, 2131891263, new Object[0]);
                String g3 = oh.g(context, 2131887005, new Object[0]);
                List<b1> 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<b1> list4 = z ? P : O;
                List<ResolveInfo> o = mh.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) {
                        o7.G("AS", "system failed to return app list");
                        list = null;
                    }
                    List<ResolveInfo> list5 = list;
                    if (list5 != null) {
                        if (!pp.F(o)) {
                            try {
                                list5.addAll(o);
                            } catch (UnsupportedOperationException e2) {
                                o7.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, pp.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 b1(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.bi.s(list4, new ik.l() {
                    @Override
                    public final Object invoke(Object obj) {
                        String str3;
                        str3 = ((b1) obj).a;
                        return str3;
                    }
                });
            } catch (Throwable th2) {
                throw th2;
            }
        }
    }

    private static synchronized List<b1> F0(boolean z) {
        List<b1> 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, f1 f1Var) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(context, AppSelect.class.getName()));
        if (f1Var != null) {
            intent.putExtra("ssc", f1Var.X(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(f1 f1Var, b1 b1Var, b1 b1Var2) {
        return Boolean.compare(!f1Var.o1(b1Var.a, b1Var.b), !f1Var.o1(b1Var2.a, b1Var2.b));
    }

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

    public void M0(String str, String str2) {
        PackageManager packageManager = getPackageManager();
        List<ActivityInfo> exportedActivities = App.getExportedActivities(this, str);
        int i = 0;
        if (pp.F(exportedActivities)) {
            pp.k0(this, pp.J3(oh.g(this, 2131887874, 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] = pp.z2(str, activityInfo.name);
            net.dinglisch.android.taskerm.g gVar = new net.dinglisch.android.taskerm.g();
            gVar.q0(str, activityInfo.name);
            gVarArr[i] = gVar;
            CharSequence loadLabel = activityInfo.loadLabel(packageManager);
            strArr[i] = (TextUtils.isEmpty(loadLabel) || str2.equals(loadLabel)) ? "" : loadLabel.toString();
            i++;
        }
        fj.E(new e(exportedActivities, str2, strArr, strArr2, str), str2).J(strArr2, gVarArr).S(strArr).b0().C(this);
    }

    public void N0(boolean z) {
        List<b1> 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 f1 f1Var = this.y;
        if (f1Var != null) {
            Collections.sort(F0, new Comparator() {
                @Override
                public final int compare(Object obj, Object obj2) {
                    int K0;
                    K0 = AppSelect.K0(f1.this, (b1) obj, (b1) 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 (fp.e0()) {
            findViewById(2131297037).setBackgroundColor(0);
            findViewById(2131296952).setVisibility(0);
        }
        TextView textView = (TextView) findViewById(2131297253);
        this.M = textView;
        textView.setText(oh.g(this, 2131888416, new Object[0]));
        this.M.setTextColor(fp.L(this));
        this.G = (ToggleButton) findViewById(2131296512);
        this.I = (ToggleButton) findViewById(2131296565);
        this.J = (ToggleButton) findViewById(2131296459);
        String g2 = oh.g(this, 2131886817, new Object[0]);
        this.I.setTextOn(g2);
        this.I.setTextOff(g2);
        String g3 = oh.g(this, 2131891139, new Object[0]);
        this.J.setTextOn(g3);
        this.J.setTextOff(g3);
        String g4 = oh.g(this, 2131891207, new Object[0]);
        this.G.setTextOn(g4);
        this.G.setTextOff(g4);
        this.K = new ImageView(this);
        this.H = (ToggleButton) findViewById(2131296456);
        String g5 = oh.g(this, 2131886794, new Object[0]);
        this.H.setTextOn(g5);
        this.H.setTextOff(g5);
        this.H.setChecked(R);
        this.H.setOnClickListener(new a());
        GridView gridView = (GridView) findViewById(2131297572);
        this.w = gridView;
        gridView.setOnItemClickListener(this);
        if (fp.e0()) {
            int w = fp.w(this, 2131165267);
            this.w.setVerticalSpacing(w);
            this.w.setHorizontalSpacing(w);
            gp.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 f1(new ii(bundle.getBundle("ssc"))) : null);
    }

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

    private boolean V0() {
        boolean z = true;
        if (this.y.h1() == 0) {
            if (this.F) {
                return pp.a0(this, 2131889125, new Object[0]);
            }
        } else {
            if ((this.D || this.E) && !this.I.isChecked() && !this.J.isChecked()) {
                return pp.a0(this, 2131887899, this.J.getText(), this.I.getText());
            }
            if (this.J.isChecked() && f1.v1(this) && !MyAccessibilityService.q()) {
                Y0();
            } else if (this.J.isChecked() && f1.w1(this) && !ip.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);
        }
        f1 f1Var = this.y;
        if (f1Var != null) {
            if (this.B) {
                f1Var.R0(this.G.isChecked());
            }
            if (this.E) {
                this.y.s1(this.I.isChecked());
                this.y.r1(this.J.isChecked());
            }
            bundle.putBundle("ssc", this.y.X(0).c0());
        }
    }

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

    private void Y0() {
        TextBoxDialogFragment.F(this, new c(), 2131887412, oh.g(this, 2131886119, new Object[0]) + "\n\n" + oh.g(this, 2131887265, new Object[0]), 2131886894, 2131886892, -1, 0).E(this);
    }

    private void Z0() {
        TextBoxDialogFragment.F(this, new d(), 2131891305, oh.g(this, 2131887276, new Object[0]), 2131886894, 2131886892, -1, 0).E(this);
    }

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

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

    public void S0(boolean z, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, ArrayList<String> arrayList, f1 f1Var) {
        if (f1Var == null) {
            this.y = new f1();
        } else {
            f1 x0 = f1Var.x0();
            this.y = x0;
            x0.q1(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.L0());
            this.G.setVisibility(0);
        } else {
            this.G.setVisibility(8);
        }
        if (z2) {
            this.w.setOnItemLongClickListener(new b());
        }
        if (b1()) {
            this.y.W0(this, this.K);
        }
        if (this.E) {
            this.I.setChecked(this.y.y1());
            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.x1());
            this.I.setVisibility(0);
            this.J.setVisibility(0);
        } else {
            this.I.setVisibility(8);
            this.J.setVisibility(8);
        }
        ActionBar actionBar = getActionBar();
        if (this.y.H0()) {
            actionBar.setSubtitle(this.y.getName());
        }
        if (fp.e0()) {
            return;
        }
        actionBar.setHomeButtonEnabled(!z);
        actionBar.setDisplayOptions((z ? 0 : 4) | 10);
    }

    @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.N;
    }

    @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.g0();
        setResult(0);
        this.x = getPackageManager();
        this.z = LayoutInflater.from(this);
        R0();
        net.dinglisch.android.taskerm.a.T(this, true).setTitle(oh.g(this, 2131886725, new Object[0]));
        if (bundle == null) {
            bundle = getIntent().getExtras();
        }
        T0(bundle);
        X0();
        N0(R);
        if (this.D) {
            if (Settings.j1(pp.R0(this))) {
                this.D = false;
            } else {
                xo.d(this, 2131890853);
            }
        }
    }

    @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.h0();
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
        g gVar = (g) adapterView.getAdapter();
        b1 b1Var = (b1) gVar.getItem(i);
        o7.f("AS", "NAME:" + b1Var.b);
        o7.f("AS", "PKG:" + b1Var.a);
        if (this.y.o1(b1Var.a, b1Var.b)) {
            this.y.p1(b1Var.a, b1Var.b);
        } else {
            this.y.Y0(b1Var.a, b1Var.b, b1Var.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);
    }
}