导航菜单

页面标题

页面副标题

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

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

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


package com.eveningoutpost.dexdrip;

import android.R;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.eveningoutpost.dexdrip.insulin.Insulin;
import com.eveningoutpost.dexdrip.insulin.InsulinManager;
import com.eveningoutpost.dexdrip.insulin.MultipleInsulins;
import com.eveningoutpost.dexdrip.models.BgReading;
import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore;
import com.eveningoutpost.dexdrip.utilitymodels.Pref;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class PhoneKeypadInputActivity extends BaseActivity {
    private static String currenttab = "insulin-1";
    private static Map<String, String> values = new HashMap();
    private Button backSpaceButton;
    private String bgUnits;
    private ImageButton bloodtesttabbutton;
    private ImageButton carbstabbutton;
    private Button eightButton;
    private Button fiveButton;
    private Button fourButton;
    private ImageButton insulintabbutton;
    private TextView mDialTextView;
    private Button multiButton1;
    private Button multiButton2;
    private Button multiButton3;
    private Button nineButton;
    private Button oneButton;
    private Button sevenButton;
    private Button sixButton;
    private ImageButton speakbutton;
    private Button starButton;
    private Button threeButton;
    private ImageButton timetabbutton;
    private Button twoButton;
    private Button zeroButton;
    private Insulin insulinProfile1 = null;
    private Insulin insulinProfile2 = null;
    private Insulin insulinProfile3 = null;
    private LinearLayout insulinTypesSection = null;
    private final boolean multipleInsulins = MultipleInsulins.isEnabled();

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131492991);
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        int i = displayMetrics.widthPixels;
        int i2 = displayMetrics.heightPixels;
        Log.d("KeypadInput", "Width height: " + i + " " + i2 + " DPI:" + displayMetrics.densityDpi);
        getWindow().setLayout(Math.min((displayMetrics.densityDpi * 520) / 320, i), Math.min((displayMetrics.densityDpi * 650) / 320, i2));
        getWindow().setBackgroundDrawableResource(R.color.transparent);
        getWindow().getAttributes().dimAmount = 0.5f;
        this.insulinProfile1 = InsulinManager.getProfile(0);
        this.insulinProfile2 = InsulinManager.getProfile(1);
        this.insulinProfile3 = InsulinManager.getProfile(2);
        getWindow().addFlags(2);
        this.mDialTextView = (TextView) findViewById(2131296550);
        this.zeroButton = (Button) findViewById(2131297212);
        this.oneButton = (Button) findViewById(2131296828);
        this.twoButton = (Button) findViewById(2131297150);
        this.threeButton = (Button) findViewById(2131297116);
        this.fourButton = (Button) findViewById(2131296631);
        this.fiveButton = (Button) findViewById(2131296619);
        this.sixButton = (Button) findViewById(2131296994);
        this.sevenButton = (Button) findViewById(2131296976);
        this.eightButton = (Button) findViewById(2131296576);
        this.nineButton = (Button) findViewById(2131296805);
        this.starButton = (Button) findViewById(2131297016);
        this.backSpaceButton = (Button) findViewById(2131296375);
        this.insulinTypesSection = (LinearLayout) findViewById(2131296681);
        this.multiButton1 = (Button) findViewById(2131296792);
        this.multiButton2 = (Button) findViewById(2131296793);
        this.multiButton3 = (Button) findViewById(2131296794);
        this.insulintabbutton = (ImageButton) findViewById(2131296682);
        this.bloodtesttabbutton = (ImageButton) findViewById(2131296397);
        this.timetabbutton = (ImageButton) findViewById(2131297126);
        this.carbstabbutton = (ImageButton) findViewById(2131296484);
        this.speakbutton = (ImageButton) findViewById(2131296411);
        this.mDialTextView.setText("");
        this.mDialTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.submitAll();
            }
        });
        this.zeroButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("0");
            }
        });
        this.oneButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("1");
            }
        });
        this.twoButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("2");
            }
        });
        this.threeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("3");
            }
        });
        this.fourButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("4");
            }
        });
        this.fiveButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("5");
            }
        });
        this.sixButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("6");
            }
        });
        this.sevenButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("7");
            }
        });
        this.eightButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("8");
            }
        });
        this.nineButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appCurrent("9");
            }
        });
        this.multiButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = PhoneKeypadInputActivity.currenttab.split("-")[0] + "-1";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        this.multiButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = PhoneKeypadInputActivity.currenttab.split("-")[0] + "-2";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        this.multiButton3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = PhoneKeypadInputActivity.currenttab.split("-")[0] + "-3";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        this.starButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (PhoneKeypadInputActivity.getValue(PhoneKeypadInputActivity.currenttab).contains(".")) {
                    return;
                }
                PhoneKeypadInputActivity.this.appCurrent(".");
            }
        });
        this.speakbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Home.startHomeWithExtra(PhoneKeypadInputActivity.this.getApplicationContext(), "START_APP_SPEECH_RECOGNITION", "ok");
                PhoneKeypadInputActivity.this.finish();
            }
        });
        this.speakbutton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Home.startHomeWithExtra(PhoneKeypadInputActivity.this.getApplicationContext(), "START_APP_TEXT_RECOGNITION", "ok");
                PhoneKeypadInputActivity.this.finish();
                return true;
            }
        });
        this.backSpaceButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                PhoneKeypadInputActivity.this.appBackSpace();
            }
        });
        this.backSpaceButton.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                PhoneKeypadInputActivity.values.put(PhoneKeypadInputActivity.currenttab, "");
                PhoneKeypadInputActivity.this.updateTab();
                return true;
            }
        });
        this.bloodtesttabbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = "bloodtest";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        this.insulintabbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = "insulin-1";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        this.carbstabbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = "carbs";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        this.timetabbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String unused = PhoneKeypadInputActivity.currenttab = "time";
                PhoneKeypadInputActivity.this.updateTab();
            }
        });
        if (Pref.getString("units", "mgdl").equals("mgdl")) {
            this.bgUnits = "mg/dl";
        } else {
            this.bgUnits = "mmol/l";
        }
        updateTab();
    }

    public static void resetValues() {
        values = new HashMap();
    }

    public static String getValue(String str) {
        if (values.containsKey(str)) {
            return values.get(str);
        }
        values.put(str, "");
        return values.get(str);
    }

    private static String appendValue(String str, String str2) {
        values.put(str, getValue(str) + str2);
        return values.get(str);
    }

    private static String appendCurrent(String str) {
        String value = getValue(currenttab);
        if (value.length() >= 6) {
            return value;
        }
        if (value.length() == 0 && str.equals(".")) {
            str = "0.";
        }
        return appendValue(currenttab, str);
    }

    public void appCurrent(String str) {
        appendCurrent(str);
        updateTab();
    }

    public void appBackSpace() {
        String value = getValue(currenttab);
        if (value.length() > 0) {
            values.put(currenttab, value.substring(0, value.length() - 1));
        }
        updateTab();
    }

    private boolean isNonzeroValueInTab(String str) {
        try {
            return BgReading.BESTOFFSET != Double.parseDouble(getValue(str));
        } catch (NumberFormatException unused) {
            return false;
        }
    }

    private boolean isInvalidTime() {
        String value = getValue("time");
        if (value.length() == 0) {
            return false;
        }
        if (!value.contains(".")) {
            return value.length() < 3;
        }
        String[] split = value.split("\\.");
        return (split.length == 2 && split[0].length() != 0 && split[1].length() == 2) ? false : true;
    }

    public void submitAll() {
        double d;
        boolean isNonzeroValueInTab = isNonzeroValueInTab("bloodtest");
        boolean isNonzeroValueInTab2 = isNonzeroValueInTab("carbs");
        boolean isNonzeroValueInTab3 = isNonzeroValueInTab("insulin-1");
        boolean isNonzeroValueInTab4 = isNonzeroValueInTab("insulin-2");
        boolean isNonzeroValueInTab5 = isNonzeroValueInTab("insulin-3");
        if (!isNonzeroValueInTab && !isNonzeroValueInTab2 && !isNonzeroValueInTab3 && !isNonzeroValueInTab4 && !isNonzeroValueInTab5) {
            Log.d("KeypadInput", "All zero values in tabs - not processing button click");
            return;
        }
        if (isInvalidTime()) {
            Log.d("KeypadInput", "Time value is invalid - not processing button click");
            return;
        }
        String value = getValue("time");
        if (value.length() > 2 && !value.contains(".")) {
            value = value.substring(0, value.length() - 2) + "." + value.substring(value.length() - 2);
        }
        DecimalFormat decimalFormat = new DecimalFormat("0.0#", new DecimalFormatSymbols(Locale.ENGLISH));
        String str = "";
        if (value.length() > 0) {
            str = "" + value + " time ";
        }
        if (isNonzeroValueInTab) {
            str = str + getValue("bloodtest") + " blood ";
        }
        if (isNonzeroValueInTab2) {
            str = str + getValue("carbs") + " g carbs ";
        }
        if (!isNonzeroValueInTab3 || this.insulinProfile1 == null) {
            d = 0.0d;
        } else {
            double parseDouble = Double.parseDouble(getValue("insulin-1"));
            if (this.multipleInsulins) {
                str = str + decimalFormat.format(parseDouble) + " " + this.insulinProfile1.getName() + " ";
            }
            d = parseDouble + BgReading.BESTOFFSET;
        }
        if (this.multipleInsulins) {
            if (isNonzeroValueInTab4 && this.insulinProfile2 != null) {
                double parseDouble2 = Double.parseDouble(getValue("insulin-2"));
                str = str + decimalFormat.format(parseDouble2) + " " + this.insulinProfile2.getName() + " ";
                d += parseDouble2;
            }
            if (isNonzeroValueInTab5 && this.insulinProfile3 != null) {
                double parseDouble3 = Double.parseDouble(getValue("insulin-3"));
                str = str + decimalFormat.format(parseDouble3) + " " + this.insulinProfile3.getName() + " ";
                d += parseDouble3;
            }
        }
        if (d > BgReading.BESTOFFSET) {
            str = str + decimalFormat.format(d) + " units ";
        }
        if (str.length() > 1) {
            resetValues();
            Home.startHomeWithExtra(this, "/xdrip_plus_voice_payload", str);
            finish();
        }
    }

    public void updateTab() {
        throw new UnsupportedOperationException("Method not decompiled: com.eveningoutpost.dexdrip.PhoneKeypadInputActivity.updateTab():void");
    }

    @Override
    protected void onResume() {
        String string = PersistentStore.getString("phone-keypad-treatment-last-tab");
        if (string.length() > 0) {
            currenttab = string;
        }
        if (!this.multipleInsulins && (currenttab.equals("insulin-2") || currenttab.equals("insulin-3"))) {
            currenttab = "insulin-1";
        }
        updateTab();
        super.onResume();
    }

    @Override
    protected void onPause() {
        PersistentStore.setString("phone-keypad-treatment-last-tab", currenttab);
        super.onPause();
    }
}