导航菜单

页面标题

页面副标题

xDrip+ v04633772025.07.16 - ErrorsActivity.java 源代码

正在查看: xDrip+ v04633772025.07.16 应用的 ErrorsActivity.java JAVA 源代码文件

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


package com.eveningoutpost.dexdrip;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Switch;
import com.eveningoutpost.dexdrip.models.JoH;
import com.eveningoutpost.dexdrip.models.UserError;
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
import com.eveningoutpost.dexdrip.utilitymodels.SendFeedBack;
import com.eveningoutpost.dexdrip.utils.ActivityWithMenu;
import com.eveningoutpost.dexdrip.wearintegration.WatchUpdaterService;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ErrorsActivity extends ActivityWithMenu {
    private ErrorListAdapter adapter;
    private Switch autoRefreshSwitch;
    private ListView errorList;
    private List<UserError> errors;
    private CheckBox highCheckboxView;
    private CheckBox lowCheckboxView;
    private SharedPreferences mPrefs;
    private CheckBox mediumCheckboxView;
    private CheckBox userEventHighCheckboxView;
    private CheckBox userEventLowCheckboxView;
    private List<UserError> errors_tmp = new ArrayList();
    private boolean autoRefresh = false;
    private Handler handler = new Handler();
    private boolean is_visible = false;
    private View.OnClickListener checkboxListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ErrorsActivity.this.updateErrors();
        }
    };
    private CompoundButton.OnCheckedChangeListener switchChangeListener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            if (z && !ErrorsActivity.this.autoRefresh) {
                ErrorsActivity.this.handler.postDelayed(ErrorsActivity.this.runnable, 1000L);
            }
            ErrorsActivity.this.autoRefresh = z;
            if (ErrorsActivity.this.autoRefresh) {
                ErrorsActivity.this.getWindow().addFlags(128);
                if (ErrorsActivity.this.mPrefs.getBoolean("wear_sync", false) && ErrorsActivity.this.mPrefs.getBoolean("sync_wear_logs", false)) {
                    Home.startWatchUpdaterService(ErrorsActivity.this.getApplicationContext(), WatchUpdaterService.ACTION_SYNC_LOGS, "ErrorView");
                    return;
                }
                return;
            }
            ErrorsActivity.this.getWindow().clearFlags(128);
        }
    };
    private Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if (ErrorsActivity.this.autoRefresh && ErrorsActivity.this.is_visible) {
                ErrorsActivity.this.updateErrors(true);
                ErrorsActivity.this.handler.postDelayed(this, 1000L);
            }
        }
    };

    @Override
    public String getMenuName() {
        return "Errors";
    }

    @Override
    protected void onCreate(Bundle bundle) {
        Bundle extras;
        super.onCreate(bundle);
        SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        this.mPrefs = defaultSharedPreferences;
        if (defaultSharedPreferences.getBoolean("wear_sync", false) && this.mPrefs.getBoolean("sync_wear_logs", false)) {
            Home.startWatchUpdaterService(this, WatchUpdaterService.ACTION_SYNC_LOGS, "ErrorView");
        }
        setContentView(2131492911);
        this.highCheckboxView = (CheckBox) findViewById(2131296644);
        this.mediumCheckboxView = (CheckBox) findViewById(2131296743);
        this.lowCheckboxView = (CheckBox) findViewById(2131296731);
        this.userEventLowCheckboxView = (CheckBox) findViewById(2131297165);
        this.userEventHighCheckboxView = (CheckBox) findViewById(2131297164);
        this.autoRefreshSwitch = (Switch) findViewById(2131296370);
        this.highCheckboxView.setOnClickListener(this.checkboxListener);
        this.mediumCheckboxView.setOnClickListener(this.checkboxListener);
        this.lowCheckboxView.setOnClickListener(this.checkboxListener);
        this.userEventLowCheckboxView.setOnClickListener(this.checkboxListener);
        this.userEventHighCheckboxView.setOnClickListener(this.checkboxListener);
        this.autoRefreshSwitch.setOnCheckedChangeListener(this.switchChangeListener);
        Intent intent = getIntent();
        if (intent != null && (extras = intent.getExtras()) != null && extras.getString("events") != null) {
            this.userEventHighCheckboxView.setChecked(true);
            this.userEventLowCheckboxView.setChecked(PersistentStore.getBoolean("events-userlowcheckbox"));
            this.mediumCheckboxView.setChecked(PersistentStore.getBoolean("events-mediumcheckbox"));
            this.highCheckboxView.setChecked(PersistentStore.getBoolean("events-highcheckbox"));
            this.lowCheckboxView.setChecked(PersistentStore.getBoolean("events-lowcheckbox"));
        }
        updateErrors();
        this.errorList = (ListView) findViewById(2131296590);
        ErrorListAdapter errorListAdapter = new ErrorListAdapter(getApplicationContext(), this.errors);
        this.adapter = errorListAdapter;
        this.errorList.setAdapter((ListAdapter) errorListAdapter);
    }

    @Override
    public void onPause() {
        super.onPause();
        this.is_visible = false;
        this.autoRefresh = false;
    }

    @Override
    public void onResume() {
        super.onResume();
        this.is_visible = true;
        this.autoRefreshSwitch.setChecked(this.autoRefresh);
    }

    public void uploadLogs(View view) {
        StringBuilder sb = new StringBuilder(20000);
        sb.append("The following logs will be sent to the developers: \n\nPlease also include your email address or we will not know who they are from!\n\n");
        Iterator<UserError> it = this.errors.iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            sb.append(it.next().toString());
            sb.append("\n");
            if (sb.length() > 200000) {
                JoH.static_toast(this, "Could not package up all logs, using most recent", 1);
                break;
            }
        }
        startActivity(new Intent(getApplicationContext(), (Class<?>) SendFeedBack.class).putExtra("generic_text", sb.toString()));
    }

    public void updateErrors() {
        updateErrors(false);
    }

    public void updateErrors(boolean z) {
        ArrayList arrayList = new ArrayList();
        PersistentStore.setBoolean("events-highcheckbox", this.highCheckboxView.isChecked());
        PersistentStore.setBoolean("events-mediumcheckbox", this.mediumCheckboxView.isChecked());
        PersistentStore.setBoolean("events-lowcheckbox", this.lowCheckboxView.isChecked());
        PersistentStore.setBoolean("events-userlowcheckbox", this.userEventLowCheckboxView.isChecked());
        PersistentStore.setBoolean("events-userhighcheckbox", this.userEventHighCheckboxView.isChecked());
        if (this.highCheckboxView.isChecked()) {
            arrayList.add(3);
        }
        if (this.mediumCheckboxView.isChecked()) {
            arrayList.add(2);
        }
        if (this.lowCheckboxView.isChecked()) {
            arrayList.add(1);
        }
        if (this.userEventLowCheckboxView.isChecked()) {
            arrayList.add(5);
        }
        if (this.userEventHighCheckboxView.isChecked()) {
            arrayList.add(6);
        }
        List<UserError> list = this.errors;
        if (list == null) {
            this.errors = UserError.bySeverity((Integer[]) arrayList.toArray(new Integer[arrayList.size()]));
            ErrorListAdapter errorListAdapter = this.adapter;
            if (errorListAdapter != null) {
                errorListAdapter.notifyDataSetChanged();
                return;
            }
            return;
        }
        if (z) {
            this.errors_tmp.clear();
            this.errors_tmp.addAll(UserError.bySeverity((Integer[]) arrayList.toArray(new Integer[arrayList.size()])));
            if (this.errors_tmp.size() != this.errors.size()) {
                this.errors.clear();
                this.errors.addAll(this.errors_tmp);
                ErrorListAdapter errorListAdapter2 = this.adapter;
                if (errorListAdapter2 != null) {
                    errorListAdapter2.notifyDataSetChanged();
                    return;
                }
                return;
            }
            return;
        }
        list.clear();
        this.errors.addAll(UserError.bySeverity((Integer[]) arrayList.toArray(new Integer[arrayList.size()])));
        ErrorListAdapter errorListAdapter3 = this.adapter;
        if (errorListAdapter3 != null) {
            errorListAdapter3.notifyDataSetChanged();
        }
    }
}