use of com.eveningoutpost.dexdrip.databinding.ActivityHomeShelfSettingsBinding in project xDrip-plus by jamorham.
the class Home method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mActivity = this;
if (!xdrip.checkAppContext(getApplicationContext())) {
toast("Unusual internal context problem - please report");
Log.wtf(TAG, "xdrip.checkAppContext FAILED!");
try {
xdrip.initCrashlytics(getApplicationContext());
Crashlytics.log("xdrip.checkAppContext FAILED!");
} catch (Exception e) {
// nothing we can do really
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// not much to do
}
if (!xdrip.checkAppContext(getApplicationContext())) {
toast("Cannot start - please report context problem");
finish();
}
}
if (Build.VERSION.SDK_INT < 17) {
JoH.static_toast_long("xDrip+ will not work below Android version 4.2");
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);
}
set_is_follower();
setVolumeControlStream(AudioManager.STREAM_MUSIC);
final boolean checkedeula = checkEula();
binding = ActivityHomeBinding.inflate(getLayoutInflater());
binding.setVs(homeShelf);
binding.setHome(this);
binding.setUi(ui);
setContentView(binding.getRoot());
Toolbar mToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(mToolbar);
mToolbar.setLongClickable(true);
mToolbar.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View 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);
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.textInsulinDose = (TextView) findViewById(R.id.textInsulinUnits);
this.textTime = (TextView) findViewById(R.id.textTimeButton);
this.btnBloodGlucose = (ImageButton) findViewById(R.id.bloodTestButton);
this.btnCarbohydrates = (ImageButton) findViewById(R.id.buttonCarbs);
this.btnInsulinDose = (ImageButton) findViewById(R.id.buttonInsulin);
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("");
}
this.btnSpeak = (ImageButton) findViewById(R.id.btnTreatment);
btnSpeak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
promptTextInput();
}
});
btnSpeak.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
promptSpeechInput();
return true;
}
});
this.btnNote = (ImageButton) findViewById(R.id.btnNote);
btnNote.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
return false;
}
});
btnNote.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancelTreatment();
}
});
btnApprove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
processAndApproveTreatment();
}
});
btnInsulinDose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// proccess and approve treatment
textInsulinDose.setVisibility(View.INVISIBLE);
btnInsulinDose.setVisibility(View.INVISIBLE);
Treatments.create(0, thisinsulinnumber, Treatments.getTimeStampWithOffset(thistimeoffset));
thisinsulinnumber = 0;
reset_viewport = true;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("insulin button");
}
}
});
btnCarbohydrates.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// proccess and approve treatment
textCarbohydrates.setVisibility(View.INVISIBLE);
btnCarbohydrates.setVisibility(View.INVISIBLE);
reset_viewport = true;
Treatments.create(thiscarbsnumber, 0, Treatments.getTimeStampWithOffset(thistimeoffset));
thiscarbsnumber = 0;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("carbs button");
}
}
});
btnBloodGlucose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reset_viewport = true;
processCalibration();
}
});
btnTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View 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);
}
if (checkedeula && is_newbie && ((dialog == null) || !dialog.isShowing())) {
if (!SdcardImportExport.handleBackup(this)) {
if (!Pref.getString("units", "mgdl").equals("mmol")) {
Log.d(TAG, "Newbie mmol prompt");
if (Experience.defaultUnitsAreMmol()) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.glucose_units_mmol_or_mgdl);
builder.setMessage(R.string.is_your_typical_glucose_value);
builder.setNegativeButton("5.5", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Pref.setString("units", "mmol");
Preferences.handleUnitsChange(null, "mmol", null);
Home.staticRefreshBGCharts();
toast(getString(R.string.settings_updated_to_mmol));
}
});
builder.setPositiveButton("100", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Home.staticRefreshBGCharts();
dialog.dismiss();
}
});
dialog = builder.create();
dialog.show();
}
}
}
}
}
use of com.eveningoutpost.dexdrip.databinding.ActivityHomeShelfSettingsBinding in project xDrip by NightscoutFoundation.
the class Home method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
mActivity = this;
if (!xdrip.checkAppContext(getApplicationContext())) {
toast("Unusual internal context problem - please report");
Log.wtf(TAG, "xdrip.checkAppContext FAILED!");
try {
xdrip.initCrashlytics(getApplicationContext());
Crashlytics.log("xdrip.checkAppContext FAILED!");
} catch (Exception e) {
// nothing we can do really
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// not much to do
}
if (!xdrip.checkAppContext(getApplicationContext())) {
toast("Cannot start - please report context problem");
finish();
}
}
if (Build.VERSION.SDK_INT < 17) {
JoH.static_toast_long("xDrip+ will not work below Android version 4.2");
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);
}
set_is_follower();
setVolumeControlStream(AudioManager.STREAM_MUSIC);
final boolean checkedeula = checkEula();
binding = ActivityHomeBinding.inflate(getLayoutInflater());
binding.setVs(homeShelf);
binding.setHome(this);
binding.setUi(ui);
setContentView(binding.getRoot());
Toolbar mToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(mToolbar);
mToolbar.setLongClickable(true);
mToolbar.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View 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);
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.textInsulinDose = (TextView) findViewById(R.id.textInsulinUnits);
this.textTime = (TextView) findViewById(R.id.textTimeButton);
this.btnBloodGlucose = (ImageButton) findViewById(R.id.bloodTestButton);
this.btnCarbohydrates = (ImageButton) findViewById(R.id.buttonCarbs);
this.btnInsulinDose = (ImageButton) findViewById(R.id.buttonInsulin);
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("");
}
this.btnSpeak = (ImageButton) findViewById(R.id.btnTreatment);
btnSpeak.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
promptTextInput();
}
});
btnSpeak.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
promptSpeechInput();
return true;
}
});
this.btnNote = (ImageButton) findViewById(R.id.btnNote);
btnNote.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
return false;
}
});
btnNote.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showNoteTextInputDialog(v, 0);
} else {
promptSpeechNoteInput(v);
}
}
});
btnCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cancelTreatment();
}
});
btnApprove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
processAndApproveTreatment();
}
});
btnInsulinDose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// proccess and approve treatment
textInsulinDose.setVisibility(View.INVISIBLE);
btnInsulinDose.setVisibility(View.INVISIBLE);
Treatments.create(0, thisinsulinnumber, Treatments.getTimeStampWithOffset(thistimeoffset));
thisinsulinnumber = 0;
reset_viewport = true;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("insulin button");
}
}
});
btnCarbohydrates.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// proccess and approve treatment
textCarbohydrates.setVisibility(View.INVISIBLE);
btnCarbohydrates.setVisibility(View.INVISIBLE);
reset_viewport = true;
Treatments.create(thiscarbsnumber, 0, Treatments.getTimeStampWithOffset(thistimeoffset));
thiscarbsnumber = 0;
if (hideTreatmentButtonsIfAllDone()) {
updateCurrentBgInfo("carbs button");
}
}
});
btnBloodGlucose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
reset_viewport = true;
processCalibration();
}
});
btnTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View 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);
}
if (checkedeula && is_newbie && ((dialog == null) || !dialog.isShowing())) {
if (!SdcardImportExport.handleBackup(this)) {
if (!Pref.getString("units", "mgdl").equals("mmol")) {
Log.d(TAG, "Newbie mmol prompt");
if (Experience.defaultUnitsAreMmol()) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.glucose_units_mmol_or_mgdl);
builder.setMessage(R.string.is_your_typical_glucose_value);
builder.setNegativeButton("5.5", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Pref.setString("units", "mmol");
Preferences.handleUnitsChange(null, "mmol", null);
Home.staticRefreshBGCharts();
toast(getString(R.string.settings_updated_to_mmol));
}
});
builder.setPositiveButton("100", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Home.staticRefreshBGCharts();
dialog.dismiss();
}
});
dialog = builder.create();
dialog.show();
}
}
}
}
}
Aggregations