Fing.apk(点击下载) / FenceActivity.java


package com.overlook.android.fing.ui.fence;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.TextView;
import androidx.appcompat.app.g;
import androidx.appcompat.widget.Toolbar;
import com.overlook.android.fing.R;
import com.overlook.android.fing.engine.j.a.e.r;
import com.overlook.android.fing.engine.model.net.HardwareAddress;
import com.overlook.android.fing.engine.services.agent.fingbox.digitalfence.DigitalFenceFilter;
import com.overlook.android.fing.engine.services.agent.fingbox.digitalfence.DigitalFenceRunner;
import com.overlook.android.fing.engine.services.agent.fingbox.digitalfence.d;
import com.overlook.android.fing.ui.base.ServiceActivity;
import com.overlook.android.fing.ui.fence.FenceDeviceListActivity;
import com.overlook.android.fing.ui.misc.WebViewActivity;
import com.overlook.android.fing.vl.components.ActionButton;
import com.overlook.android.fing.vl.components.AmountSeeker;
import com.overlook.android.fing.vl.components.Editor;
import com.overlook.android.fing.vl.components.MainButton;
import com.overlook.android.fing.vl.components.MeasurementCompact;
import com.overlook.android.fing.vl.components.NestedScrollView;
import com.overlook.android.fing.vl.components.ProgressIndicator;
import com.overlook.android.fing.vl.components.Separator;
import com.overlook.android.fing.vl.components.StackedBarChart;
import com.overlook.android.fing.vl.components.Switch;
import com.savvi.rangedatepicker.CalendarPickerView;
import e.f.a.a.b.f.e0;
import e.f.a.a.b.f.f0;
import e.f.a.a.b.j.j;
import e.f.a.a.b.j.k;
import e.f.a.a.b.j.l;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;

public class FenceActivity extends ServiceActivity implements DigitalFenceRunner.c {
    private StackedBarChart A;
    private a B;
    private ActionButton C;
    private ActionButton D;
    private ActionButton E;
    private ActionButton F;
    private DigitalFenceRunner G;
    private DigitalFenceRunner.State H;
    private NestedScrollView o;
    private MainButton p;
    private MainButton q;
    private MainButton t;
    private MainButton u;
    private ProgressIndicator v;
    private MeasurementCompact w;
    private MeasurementCompact x;
    private Separator y;
    private TextView z;

    /* access modifiers changed from: private */
    public class a implements StackedBarChart.StackedBarChartAdapter {

        /* renamed from: a  reason: collision with root package name */
        private List<DigitalFenceRunner.ChartDataPoint> f16572a = Collections.emptyList();

        a(l0 l0Var) {
        }

        public void a(List<DigitalFenceRunner.ChartDataPoint> list) {
            if (list == null) {
                list = Collections.emptyList();
            }
            this.f16572a = list;
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public int colorForLine(int i2) {
            if (i2 == 2) {
                return androidx.core.content.a.b(FenceActivity.this.getContext(), R.color.grey50);
            }
            if (i2 == 0) {
                return androidx.core.content.a.b(FenceActivity.this.getContext(), R.color.accent100);
            }
            if (i2 == 1) {
                return androidx.core.content.a.b(FenceActivity.this.getContext(), R.color.green100);
            }
            return androidx.core.content.a.b(FenceActivity.this.getContext(), 0);
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public void didReleaseTouchFromGraphWithClosestIndex(int i2) {
            FenceActivity.this.o.H(true);
            List<DigitalFenceRunner.ChartDataPoint> list = this.f16572a;
            if (list != null && i2 >= 0 && i2 < list.size()) {
                if (FenceActivity.this.H.f16128i != null) {
                    DigitalFenceRunner.ChartDataPoint chartDataPoint = FenceActivity.this.H.f16128i;
                    int d2 = chartDataPoint.d();
                    int c2 = (int) chartDataPoint.c();
                    int a2 = (int) chartDataPoint.a();
                    FenceActivity.this.C.l(String.valueOf(d2 + c2 + a2));
                    FenceActivity.this.D.l(String.valueOf(d2));
                    FenceActivity.this.E.l(String.valueOf(c2));
                    FenceActivity.this.F.l(String.valueOf(a2));
                    return;
                }
                FenceActivity.this.C.l("0");
                FenceActivity.this.D.l("0");
                FenceActivity.this.E.l("0");
                FenceActivity.this.F.l("0");
            }
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public void didTouchGraphWithClosestIndex(int i2) {
            FenceActivity.this.o.H(false);
            List<DigitalFenceRunner.ChartDataPoint> list = this.f16572a;
            if (list != null && i2 >= 0 && i2 < list.size()) {
                DigitalFenceRunner.ChartDataPoint chartDataPoint = this.f16572a.get(i2);
                int d2 = chartDataPoint.d();
                int c2 = (int) chartDataPoint.c();
                int a2 = (int) chartDataPoint.a();
                FenceActivity.this.C.l(String.valueOf(d2 + c2 + a2));
                FenceActivity.this.D.l(String.valueOf(d2));
                FenceActivity.this.E.l(String.valueOf(c2));
                FenceActivity.this.F.l(String.valueOf(a2));
            }
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public void didZoomGraphWithClosestIndex(int i2) {
            List<DigitalFenceRunner.ChartDataPoint> list = this.f16572a;
            if (list != null && i2 >= 0 && i2 < list.size()) {
                DigitalFenceRunner.ChartDataPoint chartDataPoint = this.f16572a.get(i2);
                if (chartDataPoint.b() - chartDataPoint.e() >= 120000) {
                    DigitalFenceFilter.b v = DigitalFenceFilter.v(FenceActivity.this.H.f16122c);
                    v.M(new Date(this.f16572a.get(Math.max(0, i2 - 1)).e()));
                    List<DigitalFenceRunner.ChartDataPoint> list2 = this.f16572a;
                    v.K(new Date(list2.get(Math.min(list2.size() - 1, i2 + 1)).b()));
                    ((d) FenceActivity.this.G).f(v.C());
                    ((d) FenceActivity.this.G).n();
                }
            }
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public boolean isNightTimeInterval(int i2) {
            List<DigitalFenceRunner.ChartDataPoint> list = this.f16572a;
            if (list == null || list.size() == 0 || i2 < 0 || i2 >= this.f16572a.size()) {
                return false;
            }
            return !this.f16572a.get(i2).f();
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public String labelForTimeMarker(int i2) {
            l lVar = l.SHORT;
            k kVar = k.TIME;
            if (FenceActivity.this.H == null) {
                return "";
            }
            Date date = null;
            Date g2 = FenceActivity.this.H.f16122c != null ? FenceActivity.this.H.f16122c.g() : null;
            if (FenceActivity.this.H.f16122c != null) {
                date = FenceActivity.this.H.f16122c.e();
            }
            if (g2 == null && date == null) {
                Date date2 = new Date();
                Date date3 = new Date(System.currentTimeMillis() - 3600000);
                return j.b((((date2.getTime() - date3.getTime()) / ((long) 4)) * ((long) i2)) + date3.getTime(), kVar, lVar);
            } else if (g2 != null && date != null) {
                return j.b((((date.getTime() - g2.getTime()) / ((long) 4)) * ((long) i2)) + g2.getTime(), kVar, lVar);
            } else if (this.f16572a.size() <= 0) {
                return "";
            } else {
                DigitalFenceRunner.ChartDataPoint chartDataPoint = FenceActivity.this.H.j.get(0);
                long b2 = (FenceActivity.this.H.j.get(FenceActivity.this.H.j.size() - 1).b() - chartDataPoint.e()) / ((long) 4);
                if (b2 < 3600000) {
                    return j.b((b2 * ((long) i2)) + chartDataPoint.e(), kVar, lVar);
                }
                return j.l(FenceActivity.this.getContext(), (b2 * ((long) i2)) + chartDataPoint.e());
            }
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public int numberOfDataLines() {
            return 3;
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public int numberOfTimeIntervals() {
            return 12;
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public int numberOfTimeMarkers() {
            return 4;
        }

        @Override // com.overlook.android.fing.vl.components.StackedBarChart.StackedBarChartAdapter
        public float valueForPointAtLines(int i2, int i3) {
            if (i2 >= 0 && i2 < this.f16572a.size()) {
                DigitalFenceRunner.ChartDataPoint chartDataPoint = this.f16572a.get(i2);
                if (i3 == 2) {
                    return (float) chartDataPoint.a();
                }
                if (i3 == 0) {
                    return (float) chartDataPoint.c();
                }
                if (i3 == 1) {
                    return (float) chartDataPoint.d();
                }
            }
            return 0.0f;
        }
    }

    private void O1(FenceDeviceListActivity.a aVar) {
        DigitalFenceRunner.State state;
        if (M0() && this.b != null && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            boolean z2 = state.f16122c.r() && !this.H.f16122c.i().booleanValue();
            Intent intent = new Intent(this, FenceDeviceListActivity.class);
            ServiceActivity.e1(intent, this.b);
            intent.putExtra("selection_type", aVar);
            intent.putExtra("fence_type", z2 ? FenceDeviceListActivity.a.NEW_AND_KNOWN : FenceDeviceListActivity.a.ALL);
            startActivity(intent);
        }
    }

    private void R1() {
        DigitalFenceRunner.State state;
        DigitalFenceFilter digitalFenceFilter;
        DigitalFenceFilter digitalFenceFilter2;
        DigitalFenceRunner.State state2;
        DigitalFenceRunner.b bVar = DigitalFenceRunner.b.READY;
        if (!(!M0() || this.b == null || (state2 = this.H) == null)) {
            boolean z2 = state2.f16121a == bVar;
            if (z2) {
                this.v.e(ProgressIndicator.a.IDLE, true);
            } else {
                this.v.e(ProgressIndicator.a.ACTIVE, true);
                this.v.f(((float) this.H.f16123d) / 100.0f, true);
            }
            this.p.setEnabled(z2);
            this.q.setEnabled(z2);
            this.t.setEnabled(z2);
            this.u.setEnabled(z2);
        }
        l lVar = l.SHORT;
        k kVar = k.DATE_AND_TIME;
        if (M0() && this.b != null && (state = this.H) != null) {
            boolean z3 = state.f16121a == bVar;
            DigitalFenceFilter digitalFenceFilter3 = state.f16122c;
            Date g2 = digitalFenceFilter3 != null ? digitalFenceFilter3.g() : null;
            DigitalFenceRunner.State state3 = this.H;
            Date e2 = (state3 == null || (digitalFenceFilter2 = state3.f16122c) == null) ? null : digitalFenceFilter2.e();
            if (g2 == null && e2 == null) {
                this.w.o().setText(R.string.generic_when);
                this.w.p().setText(R.string.fboxfence_pill_last_hour);
                this.y.setVisibility(8);
                this.x.setVisibility(8);
            } else if (g2 == null || e2 == null) {
                DigitalFenceRunner.State state4 = this.H;
                if (state4 != null && !state4.j.isEmpty()) {
                    this.w.o().setText(R.string.generic_from);
                    this.w.p().setText(j.b(this.H.j.get(0).e(), kVar, lVar));
                    this.y.setVisibility(0);
                    this.x.setVisibility(0);
                    this.x.o().setText(R.string.generic_to);
                    this.x.p().setText(j.b(((DigitalFenceRunner.ChartDataPoint) e.a.a.a.a.h(this.H.j, 1)).b(), kVar, lVar));
                }
            } else {
                long p2 = j.p(j.s(System.currentTimeMillis()), 1);
                long p3 = j.p(p2, -1);
                long p4 = j.p(p2, -7);
                long p5 = j.p(p2, -30);
                boolean v2 = j.v(this.H.f16122c.e().getTime(), p3);
                if (v2 && Math.abs(g2.getTime() - p3) < 1) {
                    this.w.o().setText(R.string.generic_when);
                    this.w.p().setText(R.string.generic_today);
                    this.y.setVisibility(8);
                    this.x.setVisibility(8);
                } else if (v2 && Math.abs(g2.getTime() - p4) < 1) {
                    this.w.o().setText(R.string.generic_when);
                    this.w.p().setText(R.string.generic_last7days);
                    this.y.setVisibility(8);
                    this.x.setVisibility(8);
                } else if (!v2 || Math.abs(g2.getTime() - p5) >= 1) {
                    this.w.o().setText(R.string.generic_from);
                    this.w.p().setText(j.b(g2.getTime(), kVar, lVar));
                    this.y.setVisibility(0);
                    this.x.setVisibility(0);
                    this.x.o().setText(R.string.generic_to);
                    this.x.p().setText(j.b(e2.getTime(), kVar, lVar));
                } else {
                    this.w.o().setText(R.string.generic_when);
                    this.w.p().setText(R.string.generic_last30days);
                    this.y.setVisibility(8);
                    this.x.setVisibility(8);
                }
            }
            DigitalFenceRunner.State state5 = this.H;
            if (!(state5 == null || (digitalFenceFilter = state5.f16122c) == null)) {
                this.z.setText(getString(R.string.fboxfence_pill_signal, new Object[]{Integer.toString(100 - Math.max(0, Math.min(100, e.e.a.a.a.a.o0(digitalFenceFilter.d()))))}));
            }
            a aVar = this.B;
            DigitalFenceRunner.State state6 = this.H;
            aVar.a(state6 != null ? state6.j : null);
            this.A.setEnabled(z3);
            this.A.setTouchGestureReaction(z3 ? StackedBarChart.GestureReaction.HOVER : StackedBarChart.GestureReaction.NONE);
            this.A.refresh();
            DigitalFenceRunner.ChartDataPoint chartDataPoint = this.H.f16128i;
            if (chartDataPoint != null) {
                int d2 = chartDataPoint.d();
                int c2 = (int) this.H.f16128i.c();
                int a2 = (int) this.H.f16128i.a();
                this.C.l(String.valueOf(d2 + c2 + a2));
                this.D.l(String.valueOf(d2));
                this.E.l(String.valueOf(c2));
                this.F.l(String.valueOf(a2));
            } else {
                this.C.l("0");
                this.D.l("0");
                this.E.l("0");
                this.F.l("0");
            }
            DigitalFenceFilter digitalFenceFilter4 = this.H.f16122c;
            if (digitalFenceFilter4 == null || !digitalFenceFilter4.r() || this.H.f16122c.i().booleanValue()) {
                this.F.setVisibility(0);
            } else {
                this.F.setVisibility(8);
            }
            this.C.setEnabled(z3);
            this.D.setEnabled(z3);
            this.E.setEnabled(z3);
            this.F.setEnabled(z3);
        }
    }

    public void A1(View view) {
        DigitalFenceRunner.State state;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            int dimensionPixelSize = getResources().getDimensionPixelSize(R.dimen.spacing_small);
            AmountSeeker amountSeeker = new AmountSeeker(this);
            amountSeeker.setPaddingRelative(dimensionPixelSize, dimensionPixelSize, dimensionPixelSize, dimensionPixelSize);
            amountSeeker.d().setText(R.string.fboxfence_signalstrength);
            amountSeeker.k(new l0(this, amountSeeker));
            if (this.H.f16122c.o()) {
                amountSeeker.g(100 - e.e.a.a.a.a.o0(this.H.f16122c.d()));
            }
            f0 f0Var = new f0(this);
            f0Var.K(R.string.fboxfence_signalstrength_title);
            f0Var.d(false);
            f0Var.z(R.string.generic_cancel, null);
            f0Var.G(R.string.generic_ok, new i(this, amountSeeker));
            f0Var.s(amountSeeker);
            f0Var.M();
        }
    }

    public void B1(View view) {
        DigitalFenceRunner.State state;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            e0 e0Var = new e0(this);
            View inflate = LayoutInflater.from(this).inflate(R.layout.dialog_filter_fence, (ViewGroup) null);
            Switch r1 = (Switch) inflate.findViewById(R.id.anonymized_switch);
            r1.setChecked(!this.H.f16122c.r() || this.H.f16122c.i().booleanValue());
            r1.setOnCheckedChangeListener(new o(this));
            Switch r12 = (Switch) inflate.findViewById(R.id.access_points_switch);
            r12.setChecked(this.H.f16122c.h());
            r12.setOnCheckedChangeListener(new r(this));
            Switch r13 = (Switch) inflate.findViewById(R.id.my_network_switch);
            r13.setChecked(this.H.f16122c.k());
            r13.setOnCheckedChangeListener(new e(this));
            ((Editor) inflate.findViewById(R.id.excluded_ssid)).setOnClickListener(new c(this, e0Var));
            ((Editor) inflate.findViewById(R.id.excluded_macs)).setOnClickListener(new n(this, e0Var));
            inflate.findViewById(R.id.dialog_settings_done).setOnClickListener(new a(this, e0Var));
            j.y(this, "Fence_Settings");
            e0Var.setContentView(inflate);
            e0Var.show();
        }
    }

    public void C1(DigitalFenceRunner.State state) {
        this.H = state;
        R1();
    }

    public void D1(DigitalFenceRunner.State state, DigitalFenceRunner.a aVar) {
        this.H = state;
        R1();
        int ordinal = aVar.ordinal();
        if (ordinal == 0) {
            showToast(R.string.fboxgeneric_engine_nostart, new Object[0]);
        } else if (ordinal == 1) {
            showToast(R.string.fboxgeneric_engine_noprogress, new Object[0]);
        } else if (ordinal == 2) {
            showToast(R.string.fboxgeneric_engine_nostop, new Object[0]);
        }
    }

    public /* synthetic */ void E1(CalendarPickerView calendarPickerView, DialogInterface dialogInterface, int i2) {
        DigitalFenceRunner.State state;
        long j;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY && this.G != null) {
            ArrayList arrayList = (ArrayList) calendarPickerView.o1();
            if (arrayList.isEmpty()) {
                dialogInterface.dismiss();
                return;
            }
            long s = j.s(((Date) arrayList.get(0)).getTime());
            if (arrayList.size() == 1) {
                j = j.r(s);
            } else {
                j = j.r(((Date) arrayList.get(arrayList.size() - 1)).getTime());
            }
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(this.H.f16122c);
            v2.M(new Date(s));
            v2.K(new Date(j));
            ((d) this.G).f(v2.C());
            P1(false);
        }
    }

    public /* synthetic */ void F1(Date date, Date date2, CalendarPickerView calendarPickerView, g gVar) {
        Date date3;
        Date date4 = null;
        if (this.H.f16122c.g() != null && this.H.f16122c.e() != null) {
            date4 = this.H.f16122c.g();
            date3 = this.H.f16122c.e();
        } else if (!this.H.j.isEmpty()) {
            date4 = new Date(this.H.j.get(0).e());
            date3 = new Date(((DigitalFenceRunner.ChartDataPoint) e.a.a.a.a.h(this.H.j, 1)).b());
        } else {
            date3 = null;
        }
        if (date4 != null && date4.before(date)) {
            date4 = new Date(date.getTime() + 1);
        }
        if (date3 != null && date3.after(date2)) {
            date3 = new Date();
        }
        if (date4 != null && date3 != null) {
            calendarPickerView.u1(date4, true);
            calendarPickerView.u1(date3, true);
        }
    }

    public /* synthetic */ void G1(CompoundButton compoundButton, boolean z2) {
        DigitalFenceRunner.State state;
        DigitalFenceRunner digitalFenceRunner;
        Boolean bool;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY && (digitalFenceRunner = this.G) != null) {
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(state.f16122c);
            if (z2) {
                bool = null;
            } else {
                bool = Boolean.FALSE;
            }
            v2.O(bool);
            ((d) digitalFenceRunner).f(v2.C());
        }
    }

    public /* synthetic */ void H1(CompoundButton compoundButton, boolean z2) {
        DigitalFenceRunner.State state;
        DigitalFenceRunner digitalFenceRunner;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY && (digitalFenceRunner = this.G) != null) {
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(state.f16122c);
            v2.N(z2);
            ((d) digitalFenceRunner).f(v2.C());
        }
    }

    public /* synthetic */ void I1(CompoundButton compoundButton, boolean z2) {
        DigitalFenceRunner.State state;
        DigitalFenceRunner digitalFenceRunner;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY && (digitalFenceRunner = this.G) != null) {
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(state.f16122c);
            v2.Q(z2);
            ((d) digitalFenceRunner).f(v2.C());
        }
    }

    public /* synthetic */ void J1(e0 e0Var, View view) {
        DigitalFenceRunner.State state;
        if (M0() && this.b != null && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            e0Var.dismiss();
            Intent intent = new Intent(this, FenceExcludedSSIDActivity.class);
            ServiceActivity.e1(intent, this.b);
            startActivity(intent);
        }
    }

    public /* synthetic */ void K1(e0 e0Var, View view) {
        DigitalFenceRunner.State state;
        if (M0() && this.b != null && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            e0Var.dismiss();
            Intent intent = new Intent(this, FenceExcludedDeviceActivity.class);
            ServiceActivity.e1(intent, this.b);
            startActivity(intent);
        }
    }

    public void L1(AmountSeeker amountSeeker, DialogInterface dialogInterface, int i2) {
        DigitalFenceRunner.State state;
        if (M0() && this.G != null && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(state.f16122c);
            int b = 100 - amountSeeker.b();
            v2.J(b >= 100 ? -20 : b >= 99 ? -23 : b >= 98 ? -26 : b >= 97 ? -28 : b >= 96 ? -30 : b >= 95 ? -32 : b >= 94 ? -33 : b >= 93 ? -35 : b >= 92 ? -36 : b >= 91 ? -37 : b >= 90 ? -39 : b >= 89 ? -40 : b >= 88 ? -41 : b >= 87 ? -42 : b >= 86 ? -43 : b >= 84 ? -45 : b >= 83 ? -46 : b >= 82 ? -47 : b >= 81 ? -48 : b >= 80 ? -49 : b >= 79 ? -50 : b >= 78 ? -51 : b >= 76 ? -52 : b >= 75 ? -53 : b >= 74 ? -54 : b >= 73 ? -55 : b >= 71 ? -56 : b >= 70 ? -57 : b >= 69 ? -58 : b >= 67 ? -59 : b >= 66 ? -60 : b >= 64 ? -61 : b >= 63 ? -62 : b >= 61 ? -63 : b >= 60 ? -64 : b >= 58 ? -65 : b >= 56 ? -66 : b >= 55 ? -67 : b >= 53 ? -68 : b >= 51 ? -69 : b >= 50 ? -70 : b >= 48 ? -71 : b >= 46 ? -72 : b >= 44 ? -73 : b >= 42 ? -74 : b >= 40 ? -75 : b >= 38 ? -76 : b >= 36 ? -77 : b >= 34 ? -78 : b >= 32 ? -79 : b >= 30 ? -80 : b >= 28 ? -81 : b >= 26 ? -82 : b >= 24 ? -83 : b >= 22 ? -84 : b >= 20 ? -85 : b >= 17 ? -86 : b >= 15 ? -87 : b >= 13 ? -88 : b >= 10 ? -89 : b >= 8 ? -90 : b >= 6 ? -91 : b >= 3 ? -92 : -100);
            DigitalFenceFilter C2 = v2.C();
            j.w("Fence_Signal_Strength_Change");
            ((d) this.G).f(C2);
            P1(false);
        }
    }

    public void M1(DialogInterface dialogInterface, int i2) {
        DigitalFenceRunner.State state;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY && this.G != null) {
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(state.f16122c);
            long p2 = j.p(j.s(System.currentTimeMillis()), 1);
            if (i2 == 0) {
                v2.U();
            } else if (i2 == 1) {
                v2.K(new Date(System.currentTimeMillis()));
                v2.M(new Date(j.p(p2, -1)));
            } else if (i2 == 2) {
                v2.K(new Date(System.currentTimeMillis()));
                v2.M(new Date(j.p(p2, -7)));
            } else if (i2 == 3) {
                v2.K(new Date(System.currentTimeMillis()));
                v2.M(new Date(j.p(p2, -30)));
            } else if (i2 == 4) {
                dialogInterface.dismiss();
                View inflate = LayoutInflater.from(this).inflate(R.layout.dialog_calendar_fence, (ViewGroup) null);
                CalendarPickerView calendarPickerView = (CalendarPickerView) inflate.findViewById(R.id.calendar);
                calendarPickerView.m1(new ArrayList<>());
                long p3 = j.p(j.s(System.currentTimeMillis()), 1);
                Date date = new Date(p3);
                Calendar instance = Calendar.getInstance();
                instance.setTimeInMillis(p3);
                instance.add(2, -3);
                Date date2 = new Date(instance.getTimeInMillis());
                calendarPickerView.p1(date2, date).a(CalendarPickerView.g.RANGE);
                f0 f0Var = new f0(this);
                f0Var.d(false);
                f0Var.K(R.string.fboxfence_timeinterval_title);
                f0Var.z(R.string.generic_cancel, null);
                f0Var.G(R.string.generic_ok, new s(this, calendarPickerView));
                f0Var.F(new p(this, date2, date, calendarPickerView));
                f0Var.s(inflate);
                f0Var.M();
                return;
            }
            j.w("Fence_Time_Interval_Change");
            ((d) this.G).f(v2.C());
            ((d) this.G).n();
            dialogInterface.dismiss();
        }
    }

    public /* synthetic */ void N1(DialogInterface dialogInterface, int i2) {
        DigitalFenceRunner.State state;
        if (M0() && this.G != null && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            j.w("Fence_Use_Case_Change");
            DigitalFenceRunner digitalFenceRunner = this.G;
            DigitalFenceFilter.b v2 = DigitalFenceFilter.v(this.H.f16122c);
            v2.L(i2 != 0);
            ((d) digitalFenceRunner).f(v2.C());
            P1(false);
            dialogInterface.dismiss();
        }
    }

    public void P1(boolean z2) {
        DigitalFenceFilter digitalFenceFilter;
        if (M0() && this.b != null) {
            if (this.G == null) {
                this.G = ((r) A0()).J(this.b);
            }
            DigitalFenceRunner.State e2 = ((d) this.G).e(this);
            if (!z2 || (digitalFenceFilter = e2.f16122c) == null || digitalFenceFilter.m()) {
                ((d) this.G).n();
                return;
            }
            this.H = e2;
            R1();
        }
    }

    public void Q1(boolean z2) {
        DigitalFenceRunner digitalFenceRunner;
        if (M0() && (digitalFenceRunner = this.G) != null) {
            ((d) digitalFenceRunner).a();
            if (z2) {
                ((r) A0()).m0();
                this.G = null;
            }
        }
    }

    @Override // com.overlook.android.fing.engine.services.agent.fingbox.digitalfence.DigitalFenceRunner.c
    public void R(DigitalFenceRunner.State state) {
        runOnUiThread(new k(this, state));
    }

    @Override // com.overlook.android.fing.engine.services.agent.fingbox.digitalfence.DigitalFenceRunner.c
    public void W(DigitalFenceRunner.State state, DigitalFenceRunner.a aVar) {
        runOnUiThread(new h(this, state, aVar));
    }

    /* access modifiers changed from: protected */
    @Override // com.overlook.android.fing.ui.base.ServiceActivity
    public void b1(boolean z2) {
        super.b1(z2);
        P1(false);
    }

    /* access modifiers changed from: protected */
    @Override // com.overlook.android.fing.ui.base.ServiceActivity
    public void d1() {
        super.d1();
        P1(true);
    }

    @Override // com.overlook.android.fing.engine.services.agent.fingbox.digitalfence.DigitalFenceRunner.c
    public void f(HardwareAddress hardwareAddress, String str, boolean z2) {
    }

    @Override // androidx.activity.ComponentActivity, com.overlook.android.fing.ui.base.BaseActivity
    public void onBackPressed() {
        Q1(true);
        super.onBackPressed();
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.BaseActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_fence);
        setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
        this.o = (NestedScrollView) findViewById(R.id.nested_scroll_view);
        ProgressIndicator progressIndicator = (ProgressIndicator) findViewById(R.id.progress_indicator);
        this.v = progressIndicator;
        progressIndicator.e(ProgressIndicator.a.IDLE, false);
        this.v.f(0.0f, false);
        MainButton mainButton = (MainButton) findViewById(R.id.btn_type);
        this.p = mainButton;
        mainButton.setOnClickListener(new b(this));
        MainButton mainButton2 = (MainButton) findViewById(R.id.btn_time);
        this.q = mainButton2;
        mainButton2.setOnClickListener(new g(this));
        MainButton mainButton3 = (MainButton) findViewById(R.id.btn_signal);
        this.t = mainButton3;
        mainButton3.setOnClickListener(new q(this));
        MainButton mainButton4 = (MainButton) findViewById(R.id.btn_more);
        this.u = mainButton4;
        mainButton4.setOnClickListener(new f(this));
        this.y = (Separator) findViewById(R.id.meas_separator);
        this.w = (MeasurementCompact) findViewById(R.id.meas_from);
        this.x = (MeasurementCompact) findViewById(R.id.meas_to);
        this.z = (TextView) findViewById(R.id.fence_legend);
        this.B = new a(null);
        StackedBarChart stackedBarChart = (StackedBarChart) findViewById(R.id.chart);
        this.A = stackedBarChart;
        stackedBarChart.setLegendVisible(false);
        this.A.setBarWidthPercent(0.6f);
        this.A.setAdapter(this.B);
        if (com.overlook.android.fing.engine.d.a.k(this)) {
            this.A.setNightTimeColor(R.color.backdrop100);
        } else {
            this.A.setNightTimePattern(R.drawable.night_pattern);
        }
        this.A.refresh();
        ActionButton actionButton = (ActionButton) findViewById(R.id.devices_all);
        this.C = actionButton;
        boolean z2 = true;
        actionButton.setGravity(1);
        this.C.setOnClickListener(new u(this));
        ActionButton actionButton2 = (ActionButton) findViewById(R.id.devices_new);
        this.D = actionButton2;
        actionButton2.setOnClickListener(new d(this));
        ActionButton actionButton3 = (ActionButton) findViewById(R.id.devices_known);
        this.E = actionButton3;
        actionButton3.setOnClickListener(new m(this));
        ActionButton actionButton4 = (ActionButton) findViewById(R.id.devices_anon);
        this.F = actionButton4;
        actionButton4.setOnClickListener(new t(this));
        if (bundle == null) {
            z2 = false;
        }
        t0(false, z2);
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.action_info_menu, menu);
        return true;
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onDestroy() {
        Q1(true);
        super.onDestroy();
    }

    @Override // com.overlook.android.fing.ui.base.BaseActivity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != R.id.action_info) {
            return super.onOptionsItemSelected(menuItem);
        }
        j.w("Fence_Learn_More_Load");
        Intent intent = new Intent(this, WebViewActivity.class);
        intent.putExtra("title", getResources().getString(R.string.generic_support));
        intent.putExtra("url", "https://help.fing.com/knowledge-base/digitalfence-feature/");
        startActivity(intent);
        return true;
    }

    @Override // androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.BaseActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onPause() {
        Q1(false);
        super.onPause();
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
        e.e.a.a.a.a.f0(androidx.core.content.a.b(this, R.color.accent100), menu.findItem(R.id.action_info));
        return true;
    }

    @Override // androidx.fragment.app.FragmentActivity, com.overlook.android.fing.ui.base.BaseActivity, com.overlook.android.fing.ui.base.ServiceActivity
    public void onResume() {
        super.onResume();
        j.y(this, "Fence");
        P1(true);
    }

    public /* synthetic */ void u1(View view) {
        DigitalFenceRunner.State state = this.H;
        O1((state == null || !state.f16122c.r() || this.H.f16122c.i().booleanValue()) ? FenceDeviceListActivity.a.ALL : FenceDeviceListActivity.a.NEW_AND_KNOWN);
    }

    public /* synthetic */ void v1(View view) {
        O1(FenceDeviceListActivity.a.NEW);
    }

    public /* synthetic */ void w1(View view) {
        O1(FenceDeviceListActivity.a.KNOWN);
    }

    public /* synthetic */ void x1(View view) {
        O1(FenceDeviceListActivity.a.ANONYMOUS);
    }

    public void y1(View view) {
        DigitalFenceRunner.State state;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            f0 f0Var = new f0(this);
            int i2 = 0;
            f0Var.d(false);
            f0Var.z(R.string.generic_cancel, null);
            f0Var.K(R.string.fboxfence_usecasedialog_title);
            String[] strArr = {getString(R.string.generic_all), getString(R.string.fboxfence_firstseen)};
            DigitalFenceFilter digitalFenceFilter = this.H.f16122c;
            if (digitalFenceFilter != null && digitalFenceFilter.f()) {
                i2 = 1;
            }
            f0Var.J(strArr, i2, new l(this));
            f0Var.M();
        }
    }

    public void z1(View view) {
        DigitalFenceRunner.State state;
        if (M0() && (state = this.H) != null && state.f16121a == DigitalFenceRunner.b.READY) {
            f0 f0Var = new f0(this);
            f0Var.K(R.string.fboxfence_usecasedialog_title);
            f0Var.z(R.string.generic_cancel, null);
            f0Var.w(new String[]{getString(R.string.generic_now), getString(R.string.generic_today), getString(R.string.generic_last7days), getString(R.string.generic_last30days), getString(R.string.fboxfence_select_dates)}, new j(this));
            f0Var.M();
        }
    }
}