use of com.eveningoutpost.dexdrip.UtilityModels.NanoStatus in project xDrip-plus by jamorham.
the class Home method onCreate.
@SuppressLint("ObsoleteSdkInt")
@Override
protected void onCreate(Bundle savedInstanceState) {
mActivity = this;
if (!xdrip.checkAppContext(getApplicationContext())) {
toast(gs(R.string.unusual_internal_context_problem__please_report));
Log.wtf(TAG, "xdrip.checkAppContext FAILED!");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// not much to do
}
if (!xdrip.checkAppContext(getApplicationContext())) {
toast(gs(R.string.cannot_start__please_report_context_problem));
finish();
}
}
if (Build.VERSION.SDK_INT < 17) {
JoH.static_toast_long(gs(R.string.xdrip_will_not_work_below_android_version_42));
finish();
}
xdrip.checkForcedEnglish(Home.this);
super.onCreate(savedInstanceState);
// for toolbar mode
setTheme(R.style.AppThemeToolBarLite);
Injectors.getHomeShelfComponent().inject(this);
if (!Experience.gotData()) {
homeShelf.set("source_wizard", true);
homeShelf.set("source_wizard_auto", true);
}
nanoStatus = new NanoStatus("collector", 1000);
expiryStatus = new NanoStatus("sensor-expiry", 15000);
set_is_follower();
setVolumeControlStream(AudioManager.STREAM_MUSIC);
checkedeula = checkEula();
binding = ActivityHomeBinding.inflate(getLayoutInflater());
binding.setVs(homeShelf);
binding.setHome(this);
binding.setUi(ui);
binding.setNano(nanoStatus);
binding.setExpiry(expiryStatus);
setContentView(binding.getRoot());
Toolbar mToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(mToolbar);
final Home home = this;
mToolbar.setLongClickable(true);
mToolbar.setOnLongClickListener(v -> {
// show configurator
final ActivityHomeShelfSettingsBinding binding = ActivityHomeShelfSettingsBinding.inflate(getLayoutInflater());
final Dialog dialog = new Dialog(v.getContext());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
binding.setVs(homeShelf);
binding.setHome(home);
homeShelf.set("arrow_configurator", false);
dialog.setContentView(binding.getRoot());
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
return false;
});
// findViewById(R.id.home_layout_holder).setBackgroundColor(getCol(X.color_home_chart_background));
this.dexbridgeBattery = (TextView) findViewById(R.id.textBridgeBattery);
this.parakeetBattery = (TextView) findViewById(R.id.parakeetbattery);
this.sensorAge = (TextView) findViewById(R.id.libstatus);
this.extraStatusLineText = (TextView) findViewById(R.id.extraStatusLine);
this.currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
this.bpmButton = (Button) findViewById(R.id.bpmButton);
this.stepsButton = (Button) findViewById(R.id.walkButton);
extraStatusLineText.setText("");
dexbridgeBattery.setText("");
parakeetBattery.setText("");
sensorAge.setText("");
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
this.currentBgValueText.setTextSize(100);
}
this.notificationText = (TextView) findViewById(R.id.notices);
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
this.notificationText.setTextSize(40);
}
is_newbie = Experience.isNewbie();
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) && checkedeula) {
if (Experience.installedForAtLeast(5 * Constants.MINUTE_IN_MS)) {
checkBatteryOptimization();
}
}
// jamorham voice input et al
this.voiceRecognitionText = (TextView) findViewById(R.id.treatmentTextView);
this.textBloodGlucose = (TextView) findViewById(R.id.textBloodGlucose);
this.textCarbohydrates = (TextView) findViewById(R.id.textCarbohydrate);
this.textInsulinSumDose = (TextView) findViewById(R.id.textInsulinSumUnits);
this.textTime = (TextView) findViewById(R.id.textTimeButton);
this.btnBloodGlucose = (ImageButton) findViewById(R.id.bloodTestButton);
this.btnCarbohydrates = (ImageButton) findViewById(R.id.buttonCarbs);
this.textInsulinDose[0] = (TextView) findViewById(R.id.textInsulin1Units);
this.buttonInsulinSingleDose = (ImageButton) findViewById(R.id.buttonInsulin0);
this.btnInsulinDose[0] = (ImageButton) findViewById(R.id.buttonInsulin1);
this.textInsulinDose[1] = (TextView) findViewById(R.id.textInsulin2Units);
this.btnInsulinDose[1] = (ImageButton) findViewById(R.id.buttonInsulin2);
this.textInsulinDose[2] = (TextView) findViewById(R.id.textInsulin3Units);
this.btnInsulinDose[2] = (ImageButton) findViewById(R.id.buttonInsulin3);
this.btnCancel = (ImageButton) findViewById(R.id.cancelTreatment);
this.btnApprove = (ImageButton) findViewById(R.id.approveTreatment);
this.btnTime = (ImageButton) findViewById(R.id.timeButton);
this.btnUndo = (ImageButton) findViewById(R.id.btnUndo);
this.btnRedo = (ImageButton) findViewById(R.id.btnRedo);
this.btnVehicleMode = (ImageButton) findViewById(R.id.vehicleModeButton);
hideAllTreatmentButtons();
if (searchWords == null) {
initializeSearchWords("");
}
if (// TODO only when using multiples?
insulins == null)
insulins = InsulinManager.getDefaultInstance();
this.btnSpeak = (ImageButton) findViewById(R.id.btnTreatment);
btnSpeak.setOnClickListener(v -> promptTextInput());
btnSpeak.setOnLongClickListener(v -> {
promptSpeechInput();
return true;
});
this.btnNote = (ImageButton) findViewById(R.id.btnNote);
btnNote.setOnLongClickListener(v -> {
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
return false;
});
btnNote.setOnClickListener(v -> {
if (!Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
});
btnCancel.setOnClickListener(v -> cancelTreatment());
// handle single insulin button (non multiples)
buttonInsulinSingleDose.setOnClickListener(v -> {
// proccess and approve treatment
textInsulinSumDose.setVisibility(View.INVISIBLE);
buttonInsulinSingleDose.setVisibility(View.INVISIBLE);
Treatments.create(0, thisInsulinSumNumber, Treatments.getTimeStampWithOffset(thistimeoffset));
Pendiq.handleTreatment(thisInsulinSumNumber);
thisInsulinSumNumber = 0;
reset_viewport = true;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("insulin button");
}
});
for (int i = 0; i < maxInsulinProfiles; i++) {
int finalI = i;
btnInsulinDose[i].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// proccess and approve treatment
textInsulinDose[finalI].setVisibility(View.INVISIBLE);
btnInsulinDose[finalI].setVisibility(View.INVISIBLE);
// create individual treatment just for this entry
Treatments.create(0, thisinsulinnumber[finalI], Treatments.convertLegacyDoseToInjectionListByName(thisinsulinprofile[finalI].getName(), thisinsulinnumber[finalI]), Treatments.getTimeStampWithOffset(thistimeoffset));
thisinsulinnumber[finalI] = 0;
insulinset[finalI] = false;
textInsulinDose[finalI].setText("");
reset_viewport = true;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("insulin button");
}
}
});
}
btnApprove.setOnClickListener(v -> processAndApproveTreatment());
btnCarbohydrates.setOnClickListener(v -> {
// proccess and approve treatment
textCarbohydrates.setVisibility(View.INVISIBLE);
btnCarbohydrates.setVisibility(View.INVISIBLE);
reset_viewport = true;
Treatments.create(thiscarbsnumber, 0, new ArrayList<InsulinInjection>(), Treatments.getTimeStampWithOffset(thistimeoffset));
thiscarbsnumber = 0;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("carbs button");
}
});
btnBloodGlucose.setOnClickListener(v -> {
reset_viewport = true;
processCalibration();
});
btnTime.setOnClickListener(v -> {
// clears time if clicked
textTime.setVisibility(View.INVISIBLE);
btnTime.setVisibility(View.INVISIBLE);
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("time button");
}
});
final DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screen_width = dm.widthPixels;
int screen_height = dm.heightPixels;
if (screen_width <= 320) {
small_width = true;
small_screen = true;
}
if (screen_height <= 320) {
small_height = true;
small_screen = true;
}
// final int refdpi = 320;
Log.d(TAG, "Width height: " + screen_width + " " + screen_height + " DPI:" + dm.densityDpi);
JoH.fixActionBar(this);
try {
getSupportActionBar().setTitle(R.string.app_name);
} catch (NullPointerException e) {
Log.e(TAG, "Couldn't set title due to null pointer");
}
activityVisible = true;
statusReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String bwp = intent.getStringExtra("bwp");
if (bwp != null) {
statusBWP = bwp;
refreshStatusLine();
} else {
final String iob = intent.getStringExtra("iob");
if (iob != null) {
statusIOB = iob;
refreshStatusLine();
}
}
}
};
// handle incoming extras
final Bundle bundle = getIntent().getExtras();
processIncomingBundle(bundle);
checkBadSettings();
// lower priority
PlusSyncService.startSyncService(getApplicationContext(), "HomeOnCreate");
ParakeetHelper.notifyOnNextCheckin(false);
if (checkedeula && (!getString(R.string.app_name).equals("xDrip+"))) {
showcasemenu(SHOWCASE_VARIANT);
}
// clear any design prototyping default
currentBgValueText.setText("");
}
use of com.eveningoutpost.dexdrip.UtilityModels.NanoStatus in project xDrip by NightscoutFoundation.
the class Home method onCreate.
@SuppressLint("ObsoleteSdkInt")
@Override
protected void onCreate(Bundle savedInstanceState) {
mActivity = this;
if (!xdrip.checkAppContext(getApplicationContext())) {
toast(gs(R.string.unusual_internal_context_problem__please_report));
Log.wtf(TAG, "xdrip.checkAppContext FAILED!");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// not much to do
}
if (!xdrip.checkAppContext(getApplicationContext())) {
toast(gs(R.string.cannot_start__please_report_context_problem));
finish();
}
}
if (Build.VERSION.SDK_INT < 17) {
JoH.static_toast_long(gs(R.string.xdrip_will_not_work_below_android_version_42));
finish();
}
xdrip.checkForcedEnglish(Home.this);
super.onCreate(savedInstanceState);
// for toolbar mode
setTheme(R.style.AppThemeToolBarLite);
Injectors.getHomeShelfComponent().inject(this);
if (!Experience.gotData()) {
homeShelf.set("source_wizard", true);
homeShelf.set("source_wizard_auto", true);
}
nanoStatus = new NanoStatus("collector", 1000);
expiryStatus = new NanoStatus("sensor-expiry", 15000);
set_is_follower();
setVolumeControlStream(AudioManager.STREAM_MUSIC);
checkedeula = checkEula();
binding = ActivityHomeBinding.inflate(getLayoutInflater());
binding.setVs(homeShelf);
binding.setHome(this);
binding.setUi(ui);
binding.setNano(nanoStatus);
binding.setExpiry(expiryStatus);
setContentView(binding.getRoot());
Toolbar mToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(mToolbar);
final Home home = this;
mToolbar.setLongClickable(true);
mToolbar.setOnLongClickListener(v -> {
// show configurator
final ActivityHomeShelfSettingsBinding binding = ActivityHomeShelfSettingsBinding.inflate(getLayoutInflater());
final Dialog dialog = new Dialog(v.getContext());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
binding.setVs(homeShelf);
binding.setHome(home);
homeShelf.set("arrow_configurator", false);
dialog.setContentView(binding.getRoot());
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
return false;
});
// findViewById(R.id.home_layout_holder).setBackgroundColor(getCol(X.color_home_chart_background));
this.dexbridgeBattery = (TextView) findViewById(R.id.textBridgeBattery);
this.parakeetBattery = (TextView) findViewById(R.id.parakeetbattery);
this.sensorAge = (TextView) findViewById(R.id.libstatus);
this.extraStatusLineText = (TextView) findViewById(R.id.extraStatusLine);
this.currentBgValueText = (TextView) findViewById(R.id.currentBgValueRealTime);
this.bpmButton = (Button) findViewById(R.id.bpmButton);
this.stepsButton = (Button) findViewById(R.id.walkButton);
extraStatusLineText.setText("");
dexbridgeBattery.setText("");
parakeetBattery.setText("");
sensorAge.setText("");
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
this.currentBgValueText.setTextSize(100);
}
this.notificationText = (TextView) findViewById(R.id.notices);
if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) {
this.notificationText.setTextSize(40);
}
is_newbie = Experience.isNewbie();
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) && checkedeula) {
if (Experience.installedForAtLeast(5 * Constants.MINUTE_IN_MS)) {
checkBatteryOptimization();
}
}
// jamorham voice input et al
this.voiceRecognitionText = (TextView) findViewById(R.id.treatmentTextView);
this.textBloodGlucose = (TextView) findViewById(R.id.textBloodGlucose);
this.textCarbohydrates = (TextView) findViewById(R.id.textCarbohydrate);
this.textInsulinSumDose = (TextView) findViewById(R.id.textInsulinSumUnits);
this.textTime = (TextView) findViewById(R.id.textTimeButton);
this.btnBloodGlucose = (ImageButton) findViewById(R.id.bloodTestButton);
this.btnCarbohydrates = (ImageButton) findViewById(R.id.buttonCarbs);
this.textInsulinDose[0] = (TextView) findViewById(R.id.textInsulin1Units);
this.buttonInsulinSingleDose = (ImageButton) findViewById(R.id.buttonInsulin0);
this.btnInsulinDose[0] = (ImageButton) findViewById(R.id.buttonInsulin1);
this.textInsulinDose[1] = (TextView) findViewById(R.id.textInsulin2Units);
this.btnInsulinDose[1] = (ImageButton) findViewById(R.id.buttonInsulin2);
this.textInsulinDose[2] = (TextView) findViewById(R.id.textInsulin3Units);
this.btnInsulinDose[2] = (ImageButton) findViewById(R.id.buttonInsulin3);
this.btnCancel = (ImageButton) findViewById(R.id.cancelTreatment);
this.btnApprove = (ImageButton) findViewById(R.id.approveTreatment);
this.btnTime = (ImageButton) findViewById(R.id.timeButton);
this.btnUndo = (ImageButton) findViewById(R.id.btnUndo);
this.btnRedo = (ImageButton) findViewById(R.id.btnRedo);
this.btnVehicleMode = (ImageButton) findViewById(R.id.vehicleModeButton);
hideAllTreatmentButtons();
if (searchWords == null) {
initializeSearchWords("");
}
if (// TODO only when using multiples?
insulins == null)
insulins = InsulinManager.getDefaultInstance();
this.btnSpeak = (ImageButton) findViewById(R.id.btnTreatment);
btnSpeak.setOnClickListener(v -> promptTextInput());
btnSpeak.setOnLongClickListener(v -> {
promptSpeechInput();
return true;
});
this.btnNote = (ImageButton) findViewById(R.id.btnNote);
btnNote.setOnLongClickListener(v -> {
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
return false;
});
btnNote.setOnClickListener(v -> {
if (!Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
});
btnCancel.setOnClickListener(v -> cancelTreatment());
// handle single insulin button (non multiples)
buttonInsulinSingleDose.setOnClickListener(v -> {
// proccess and approve treatment
textInsulinSumDose.setVisibility(View.INVISIBLE);
buttonInsulinSingleDose.setVisibility(View.INVISIBLE);
Treatments.create(0, thisInsulinSumNumber, Treatments.getTimeStampWithOffset(thistimeoffset));
Pendiq.handleTreatment(thisInsulinSumNumber);
thisInsulinSumNumber = 0;
reset_viewport = true;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("insulin button");
}
});
for (int i = 0; i < maxInsulinProfiles; i++) {
int finalI = i;
btnInsulinDose[i].setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// proccess and approve treatment
textInsulinDose[finalI].setVisibility(View.INVISIBLE);
btnInsulinDose[finalI].setVisibility(View.INVISIBLE);
// create individual treatment just for this entry
Treatments.create(0, thisinsulinnumber[finalI], Treatments.convertLegacyDoseToInjectionListByName(thisinsulinprofile[finalI].getName(), thisinsulinnumber[finalI]), Treatments.getTimeStampWithOffset(thistimeoffset));
thisinsulinnumber[finalI] = 0;
insulinset[finalI] = false;
textInsulinDose[finalI].setText("");
reset_viewport = true;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("insulin button");
}
}
});
}
btnApprove.setOnClickListener(v -> processAndApproveTreatment());
btnCarbohydrates.setOnClickListener(v -> {
// proccess and approve treatment
textCarbohydrates.setVisibility(View.INVISIBLE);
btnCarbohydrates.setVisibility(View.INVISIBLE);
reset_viewport = true;
Treatments.create(thiscarbsnumber, 0, new ArrayList<InsulinInjection>(), Treatments.getTimeStampWithOffset(thistimeoffset));
thiscarbsnumber = 0;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("carbs button");
}
});
btnBloodGlucose.setOnClickListener(v -> {
reset_viewport = true;
processCalibration();
});
btnTime.setOnClickListener(v -> {
// clears time if clicked
textTime.setVisibility(View.INVISIBLE);
btnTime.setVisibility(View.INVISIBLE);
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("time button");
}
});
final DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screen_width = dm.widthPixels;
int screen_height = dm.heightPixels;
if (screen_width <= 320) {
small_width = true;
small_screen = true;
}
if (screen_height <= 320) {
small_height = true;
small_screen = true;
}
// final int refdpi = 320;
Log.d(TAG, "Width height: " + screen_width + " " + screen_height + " DPI:" + dm.densityDpi);
JoH.fixActionBar(this);
try {
getSupportActionBar().setTitle(R.string.app_name);
} catch (NullPointerException e) {
Log.e(TAG, "Couldn't set title due to null pointer");
}
activityVisible = true;
statusReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String bwp = intent.getStringExtra("bwp");
if (bwp != null) {
statusBWP = bwp;
refreshStatusLine();
} else {
final String iob = intent.getStringExtra("iob");
if (iob != null) {
statusIOB = iob;
refreshStatusLine();
}
}
}
};
// handle incoming extras
final Bundle bundle = getIntent().getExtras();
processIncomingBundle(bundle);
checkBadSettings();
// lower priority
PlusSyncService.startSyncService(getApplicationContext(), "HomeOnCreate");
ParakeetHelper.notifyOnNextCheckin(false);
if (checkedeula && (!getString(R.string.app_name).equals("xDrip+"))) {
showcasemenu(SHOWCASE_VARIANT);
}
// clear any design prototyping default
currentBgValueText.setText("");
}
Aggregations