导航菜单

页面标题

页面副标题

Tasker v6.5.11 - LocSelect.java 源代码

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

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


package net.dinglisch.android.taskerm;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.ToggleButton;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.joaomgcd.taskerm.spawn.RFactory;
import cyanogenmod.alarmclock.ClockContract;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.dinglisch.android.taskerm.HTMLView;
import w9.c;

public class LocSelect extends MyActivity implements LocationListener, pf.a {
    private static final int[] O = {3, 0};
    private ToggleButton B;
    private ToggleButton C;
    private Spinner D;
    private Resources E;
    private MapView F;
    private w9.c G;
    private TextView H;
    private EditText I;
    private EditText J;
    td v;
    private LocationManager w;
    private Location x = null;
    private boolean y = false;
    private Set<String> z = new HashSet();
    private int[] A = new int[2];
    private boolean K = false;
    private Set<q7> L = new HashSet();
    private q7 M = null;
    private com.joaomgcd.taskerm.helper.e<LocSelect> N = new com.joaomgcd.taskerm.helper.e<>(this);

    class a implements TextWatcher {
        a() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            LocSelect.this.G0(editable.toString(), dq.m1(LocSelect.this.J));
        }

        @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 b implements TextWatcher {
        b() {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            LocSelect locSelect = LocSelect.this;
            locSelect.G0(dq.m1(locSelect.I), editable.toString());
        }

        @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 c implements AdapterView.OnItemSelectedListener {
        c() {
        }

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
            LocSelect locSelect = LocSelect.this;
            td tdVar = locSelect.v;
            if (tdVar != null) {
                tdVar.k(locSelect.E0(i));
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    }

    class e implements com.joaomgcd.taskerm.util.c<Boolean> {
        e() {
        }

        @Override
        public void a(Boolean bool) {
            String str;
            LocSelect locSelect = LocSelect.this;
            if (bool.booleanValue()) {
                LocSelect.this.x0();
                LocSelect locSelect2 = LocSelect.this;
                locSelect2.R0(locSelect2.M);
                lp.d(locSelect, 2131890890);
                LocSelect.this.F.setVisibility(0);
                LocSelect.this.H.setVisibility(8);
                r7.f("LocSelect", "initialized map OK");
                LocSelect.this.K = true;
                return;
            }
            r7.f("LocSelect", "map init failed");
            LocSelect.this.H.setVisibility(0);
            LocSelect.this.F.setVisibility(8);
            int f = com.google.android.gms.common.c.f(locSelect);
            String valueOf = String.valueOf(f);
            if (f == 0) {
                str = vh.g(locSelect, 2131886891, new Object[0]);
            } else if (f == 2) {
                str = vh.g(locSelect, 2131890344, new Object[0]);
            } else if (f == 1) {
                str = vh.g(locSelect, 2131890343, new Object[0]);
            } else {
                str = vh.g(locSelect, 2131891164, new Object[0]) + " " + valueOf;
            }
            LocSelect.this.H.setText(vh.g(locSelect, 2131887279, str));
        }
    }

    private void A0(boolean z) {
        net.dinglisch.android.taskerm.c cVar = new net.dinglisch.android.taskerm.c(332);
        cVar.m1(0, z);
        ExecuteService.h6(this, new net.dinglisch.android.taskerm.c[]{cVar}, true);
        this.y = z;
    }

    private void B0() {
        Intent intent = new Intent();
        intent.putExtra("scntxt", this.M.U(0).c0());
        setResult(-1, intent);
        finish();
    }

    private void C0(Location location) {
        int i;
        int i2 = 0;
        td tdVar = this.v;
        if (tdVar == null) {
            MyActivity.L(this, "finishGrab mapItem null");
            return;
        }
        if (location != null) {
            dq.h0(this, 2131887798, Integer.valueOf(new Float(location.getAccuracy()).intValue()), location.getProvider());
            tdVar.i(location.getLatitude(), location.getLongitude());
            this.I.setText(String.valueOf(location.getLatitude()));
            this.J.setText(String.valueOf(location.getLongitude()));
            int[] intArray = this.E.getIntArray(RFactory.layout.scene_edit_element_event_filter_link_click);
            while (i2 < intArray.length - 1 && ((i = intArray[i2]) < 200 || i < location.getAccuracy() * 2.0f)) {
                i2++;
            }
            this.D.setSelection(i2);
            tdVar.k(i2);
        }
    }

    public float E0(int i) {
        if (i == -1) {
            i = this.D.getSelectedItemPosition();
        }
        if (i != -1) {
            return this.E.getIntArray(RFactory.layout.scene_edit_element_event_filter_link_click)[i];
        }
        r7.G("LocSelect", "getRadius: selected radius index -1");
        return -1.0f;
    }

    @SuppressLint({"MissingPermission"})
    private void F0() {
        this.N.o1(com.joaomgcd.taskerm.util.e5.g0(this), new Runnable() {
            @Override
            public final void run() {
                LocSelect.this.L0();
            }
        });
    }

    public void G0(String str, String str2) {
        LatLng W0 = W0(str, str2);
        if (W0 != null) {
            y0(W0, 13.0f);
        }
    }

    private boolean H0() {
        w9.c cVar = this.G;
        if (cVar == null) {
            return false;
        }
        int d2 = cVar.d();
        return d2 == 4 || d2 == 1;
    }

    private boolean I0() {
        w9.c cVar = this.G;
        if (cVar == null) {
            return false;
        }
        int d2 = cVar.d();
        return d2 == 4 || d2 == 2;
    }

    private void J0(final com.joaomgcd.taskerm.util.c<Boolean> cVar) {
        this.F.a(new w9.e() {
            public final void a(w9.c cVar2) {
                LocSelect.this.N0(cVar, cVar2);
            }
        });
    }

    public void K0() {
        LocationManager locationManager = this.w;
        if (locationManager != null) {
            locationManager.requestLocationUpdates("gps", 0L, 0.0f, this);
        }
    }

    public void L0() {
        if (this.w == null) {
            dq.a0(this, 2131887712, new Object[0]);
            return;
        }
        invalidateOptionsMenu();
        this.z.clear();
        this.x = null;
        int[] iArr = this.A;
        iArr[0] = 0;
        boolean z = true;
        iArr[1] = 0;
        if (this.B.isChecked()) {
            if (q7.o1(this.w, "gps")) {
                z = false;
            } else {
                A0(true);
            }
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    LocSelect.this.K0();
                }
            };
            if (z) {
                this.B.postDelayed(runnable, 800L);
            } else {
                runnable.run();
            }
            this.z.add("gps");
        }
        if (this.C.isChecked() && q7.o1(this.w, "network") && dq.x1(this, -1)) {
            this.w.requestLocationUpdates("network", 0L, 0.0f, this);
            if (!this.z.contains("gps")) {
                dq.j0(this, 2131887837, new Object[0]);
            }
            this.z.add("network");
        }
        if (this.z.size() == 0) {
            dq.a0(this, 2131887845, new Object[0]);
        }
    }

    public void M0(LatLng latLng) {
        Y0();
        Q0(latLng);
    }

    public void N0(com.joaomgcd.taskerm.util.c cVar, w9.c cVar2) {
        boolean z = false;
        if (cVar2 != null) {
            this.G = cVar2;
            S0(true, false);
            cVar2.l(new c.c() {
                public final void a(LatLng latLng) {
                    LocSelect.this.M0(latLng);
                }
            });
            z = true;
        }
        cVar.a(Boolean.valueOf(z));
    }

    private void O0() {
        this.F = findViewById(2131297083);
        this.H = (TextView) findViewById(2131297082);
        this.I = (EditText) findViewById(2131297608);
        this.J = (EditText) findViewById(2131297609);
        this.I.setHint(vh.g(this, 2131889715, new Object[0]));
        this.J.setHint(vh.g(this, 2131889740, new Object[0]));
        this.I.addTextChangedListener(new a());
        this.J.addTextChangedListener(new b());
        Spinner spinner = (Spinner) findViewById(2131297298);
        this.D = spinner;
        spinner.setAdapter((SpinnerAdapter) dq.f1(this, RFactory.layout.scene_edit_element));
        this.D.setOnItemSelectedListener(new c());
        this.B = (ToggleButton) findViewById(2131296506);
        List<String> allProviders = this.w.getAllProviders();
        if (!allProviders.contains("gps")) {
            this.B.setChecked(false);
            this.B.setEnabled(false);
        }
        this.C = (ToggleButton) findViewById(2131296537);
        if (!allProviders.contains("network")) {
            this.C.setChecked(false);
            this.C.setEnabled(false);
        }
        if (tp.e0()) {
            findViewById(2131297036).setBackgroundColor(0);
            findViewById(2131297041).setBackgroundColor(0);
            findViewById(2131296952).setVisibility(0);
            findViewById(2131296951).setVisibility(0);
            findViewById(2131296952).setElevation(tp.w(this, 2131166027));
            up.D(findViewById(2131296440));
        }
    }

    private boolean P0() {
        if (!D0(true)) {
            return false;
        }
        B0();
        return true;
    }

    public void Q0(LatLng latLng) {
        td tdVar = this.v;
        if (tdVar == null) {
            return;
        }
        tdVar.j(latLng);
        this.I.setText(String.valueOf(latLng.i));
        this.J.setText(String.valueOf(latLng.q));
    }

    public void R0(q7 q7Var) {
        if (this.G == null) {
            return;
        }
        String name = this.M.D0() ? q7Var.getName() : null;
        LatLng s1 = q7.s1(q7Var.d1(), q7Var.f1());
        td tdVar = new td(s1, q7Var.i1(), td.i, name, 2131230924);
        this.v = tdVar;
        tdVar.a(this.G);
        this.v.w();
        this.v.r();
        this.G.n(new d());
        if (q7Var.d1() == 0.0d || q7Var.f1() == 0.0d) {
            return;
        }
        y0(s1, 13.0f);
    }

    private void S0(boolean z, boolean z2) {
        w9.c cVar = this.G;
        if (cVar == null) {
            return;
        }
        cVar.h(zk.G4(z, z2));
    }

    private void T0() {
        float E0 = E0(-1);
        if (E0 != -1.0f) {
            this.M.z1(E0);
        }
    }

    private void U0(q7 q7Var, boolean z) {
        ActionBar S;
        if (this.B.isEnabled()) {
            this.B.setChecked(q7Var.k1());
        }
        if (this.C.isEnabled()) {
            this.C.setChecked(q7Var.l1());
        }
        if (q7Var.d1() != 0.0d) {
            this.I.setText(String.valueOf(q7Var.d1()));
        }
        if (q7Var.d1() != 0.0d) {
            this.J.setText(String.valueOf(q7Var.f1()));
        }
        this.D.setSelection(dq.J1((int) q7Var.i1(), this.E.getIntArray(RFactory.layout.scene_edit_element_event_filter_link_click)));
        if (!this.M.D0() || (S = net.dinglisch.android.taskerm.a.S(this, "LocSelect/setUIFromLoc")) == null) {
            return;
        }
        S.setSubtitle(q7Var.getName());
    }

    private void V0() {
        LocationManager locationManager = this.w;
        if (locationManager != null) {
            locationManager.removeUpdates(this);
        }
        Set<String> set = this.z;
        if (set != null) {
            set.clear();
        }
        if (this.y) {
            A0(false);
        }
        invalidateOptionsMenu();
    }

    private LatLng W0(String str, String str2) {
        boolean isEmpty = TextUtils.isEmpty(str);
        Float valueOf = Float.valueOf(0.0f);
        if ((isEmpty ? valueOf : dq.D3(str)) != null) {
            if (!TextUtils.isEmpty(str2)) {
                valueOf = dq.D3(str2);
            }
            if (valueOf != null) {
                return new LatLng(r5.floatValue(), valueOf.floatValue());
            }
        }
        return null;
    }

    private void X0(List<String> list) {
        if (list != null) {
            for (int i = 0; i < list.size(); i++) {
                this.L.add(new q7(new qi(list.get(i))));
            }
        }
    }

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

    public void x0() {
        if (this.G == null) {
            return;
        }
        for (q7 q7Var : this.L) {
            if (!this.M.D0() || !q7Var.D0() || !this.M.getName().equals(q7Var.getName())) {
                new td(q7.s1(q7Var.d1(), q7Var.f1()), q7Var.i1(), td.j, q7Var.D0() ? q7Var.getName() : null, 2131230924).a(this.G);
            }
        }
    }

    private void y0(LatLng latLng, float f) {
        w9.c cVar = this.G;
        if (cVar == null || this.F == null || cVar == null) {
            return;
        }
        this.G.g(f == 0.0f ? w9.b.b(latLng) : w9.b.a(new CameraPosition.a().c(latLng).e(f).b()));
    }

    private void z0() {
        if (dq.x1(this, -1)) {
            startActivityForResult(new Intent(this, (Class<?>) GeoCoder.class), 1);
        } else {
            dq.n0(this, 2131891077, new Object[0]);
        }
    }

    public boolean D0(boolean z) {
        this.M.v1(this.B.isChecked());
        this.M.y1(this.C.isChecked());
        LatLng W0 = W0(dq.m1(this.I), dq.m1(this.J));
        if (W0 != null) {
            this.M.w1(W0.i);
            this.M.x1(W0.q);
        }
        T0();
        if (this.M.j1()) {
            return true;
        }
        dq.a0(this, 2131887713, new Object[0]);
        return false;
    }

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

    @Override
    public void onActivityResult(int i, int i2, Intent intent) {
        if (i == 1 && i2 == -1) {
            Q0(q7.s1(intent.getDoubleExtra("lat", 0.0d), intent.getDoubleExtra("lng", 0.0d)));
        }
    }

    @Override
    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        w6.e(getBaseContext());
    }

    @Override
    public void onCreate(Bundle bundle) {
        Bundle bundle2;
        ArrayList<String> stringArrayList;
        setResult(0);
        super.onCreate(bundle);
        this.E = getResources();
        this.w = (LocationManager) oi.d(this, "location", "LocSelect", "onCreate");
        setContentView(2131493558);
        if (this.w == null) {
            dq.h0(this, 2131887712, new Object[0]);
            finish();
        } else {
            O0();
            StringBuilder sb = new StringBuilder();
            sb.append("mapCreate: have resources: ");
            sb.append(this.E != null);
            r7.f("LocSelect", sb.toString());
            MyMapView.l(this.F, this, bundle);
            r7.f("LocSelect", "done map create");
            net.dinglisch.android.taskerm.a.T(this, true).setTitle(vh.g(this, 2131886727, new Object[0]));
            if (this.B.getVisibility() == 8 && this.C.getVisibility() == 8) {
                dq.h0(this, 2131887714, new Object[0]);
                finish();
            } else {
                if (bundle == null) {
                    Intent intent = getIntent();
                    bundle2 = intent.getBundleExtra("scntxt");
                    stringArrayList = intent.getStringArrayListExtra("olcntxt");
                } else {
                    bundle2 = bundle.getBundle("tloc");
                    stringArrayList = bundle.getStringArrayList("oloc");
                }
                X0(stringArrayList);
                if (bundle2 == null) {
                    this.M = new q7();
                } else {
                    this.M = new q7(new qi(bundle2));
                }
                w9.d.a(this);
                U0(this.M, true);
            }
        }
        this.N.I();
        this.N.n1(com.joaomgcd.taskerm.util.e5.h0(this, 111));
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.F.c();
        this.w = null;
        this.x = null;
        this.z = null;
        this.B = null;
        this.C = null;
        this.D = null;
        this.E = null;
        this.F = null;
        this.v = null;
        this.L = null;
        this.H = null;
        this.I = null;
        this.J = null;
        this.M = null;
        this.N.J();
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        return i == 4 ? !P0() : super.onKeyDown(i, keyEvent);
    }

    @Override
    public void onLocationChanged(Location location) {
        float accuracy = location.getAccuracy();
        String provider = location.getProvider();
        int i = !provider.equals("gps") ? 1 : 0;
        Location location2 = this.x;
        if (location2 == null || accuracy < location2.getAccuracy()) {
            this.x = location;
        } else {
            int[] iArr = this.A;
            iArr[i] = iArr[i] + 1;
        }
        int i2 = 1 - i;
        int i3 = this.A[i];
        int[] iArr2 = O;
        if (i3 >= iArr2[i]) {
            if (provider.equals("gps") || this.z.size() == 1 || this.A[i2] >= iArr2[i2]) {
                V0();
                C0(this.x);
            }
        }
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        MapView mapView = this.F;
        if (mapView != null) {
            mapView.d();
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 3) {
            HTMLView.G0(this, "index.html");
        } else if (itemId == 4) {
            HTMLView.H0(this, "activity_locselect.html", -1, HTMLView.g.Inform);
        } else if (itemId != 16908332) {
            switch (itemId) {
                case ClockContract.InstancesColumns.MISSED_STATE:
                    Intent intent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS");
                    intent.addFlags(1073741824);
                    if (!dq.l3(this, intent)) {
                        dq.a0(this, 2131887729, new Object[0]);
                        break;
                    }
                    break;
                case 7:
                    HTMLView.G0(this, "loctears.html");
                    break;
                case 8:
                    finish();
                    break;
                case 9:
                    if (this.B.isChecked() && !dq.x1(this, -1)) {
                        dq.n0(this, 2131891073, new Object[0]);
                    }
                    F0();
                    break;
                default:
                    switch (itemId) {
                        case 11:
                            V0();
                            C0(this.x);
                            break;
                        case 12:
                            S0(true, I0());
                            invalidateOptionsMenu();
                            break;
                        case 13:
                            S0(false, I0());
                            invalidateOptionsMenu();
                            break;
                        case 14:
                            S0(H0(), true);
                            invalidateOptionsMenu();
                            break;
                        case 15:
                            S0(H0(), false);
                            invalidateOptionsMenu();
                            break;
                        case 16:
                            z0();
                            break;
                        default:
                            return false;
                    }
            }
        } else {
            P0();
        }
        return true;
    }

    @Override
    public void onPause() {
        if (this.y) {
            A0(false);
        }
        V0();
        super.onPause();
        this.F.e();
    }

    @Override
    public boolean onPrepareOptionsMenu(Menu menu) {
        super.onPrepareOptionsMenu(menu);
        menu.clear();
        if (this.z.size() == 0) {
            net.dinglisch.android.taskerm.a.u(this, 9, menu);
        } else {
            net.dinglisch.android.taskerm.a.Q(this, 11, menu);
        }
        menu.add(0, 16, 0, vh.g(this, 2131889435, new Object[0]));
        if (this.G != null && this.F != null) {
            if (H0()) {
                menu.add(0, 13, 0, vh.g(this, 2131888882, new Object[0]));
            } else {
                menu.add(0, 12, 0, vh.g(this, 2131889012, new Object[0]));
            }
            if (I0()) {
                menu.add(0, 15, 0, vh.g(this, 2131888883, new Object[0]));
            } else {
                menu.add(0, 14, 0, vh.g(this, 2131889013, new Object[0]));
            }
        }
        net.dinglisch.android.taskerm.a.d(this, 8, menu);
        menu.add(0, 6, 0, vh.g(this, 2131888906, new Object[0]));
        menu.add(0, 7, 0, vh.g(this, 2131888910, new Object[0]));
        dq.l(this, menu, 4, 3);
        return true;
    }

    @Override
    public void onProviderDisabled(String str) {
    }

    @Override
    public void onProviderEnabled(String str) {
    }

    @Override
    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i, strArr, iArr);
        this.N.A0(i, strArr, iArr);
    }

    @Override
    public void onResume() {
        super.onResume();
        this.F.f();
        r7.f("LocSelect", "onResume: map initialized: " + this.K);
        if (this.K) {
            return;
        }
        J0(new e());
    }

    @Override
    protected void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        if (D0(false)) {
            bundle.putBundle("tloc", this.M.U(0).c0());
        }
        this.F.g(bundle);
    }

    @Override
    public void onStatusChanged(String str, int i, Bundle bundle) {
    }

    class d implements c.e {
        d() {
        }

        public void b(y9.e eVar) {
            LocSelect.this.Q0(eVar.a());
            LocSelect.this.v.v();
        }

        public void c(y9.e eVar) {
            LocSelect.this.Y0();
            LocSelect.this.v.h();
        }

        public void a(y9.e eVar) {
        }
    }
}