use of com.eveningoutpost.dexdrip.UtilityModels.Constants.MINUTE_IN_MS in project xDrip by NightscoutFoundation.
the class Home method showNoteTextInputDialog.
public void showNoteTextInputDialog(View myitem, final long timestamp, final double position) {
Log.d(TAG, "showNoteTextInputDialog: ts:" + timestamp + " pos:" + position);
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.note_dialog_phone, null);
dialogBuilder.setView(dialogView);
final EditText edt = (EditText) dialogView.findViewById(R.id.treatment_note_edit_text);
final CheckBox cbx = (CheckBox) dialogView.findViewById(R.id.default_to_voice_input);
cbx.setChecked(Pref.getBooleanDefaultFalse("default_to_voice_notes"));
dialogBuilder.setTitle(R.string.treatment_note);
// dialogBuilder.setMessage("Enter text below");
dialogBuilder.setPositiveButton(R.string.done, (dialog, whichButton) -> {
String treatment_text = edt.getText().toString().trim();
Log.d(TAG, "Got treatment note: " + treatment_text);
// timestamp?
Treatments.create_note(treatment_text, timestamp, position);
Home.staticRefreshBGCharts();
if (treatment_text.length() > 0) {
// display snackbar of the snackbar
final View.OnClickListener mOnClickListener = v -> Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, Long.toString(timestamp), Double.toString(position));
Home.snackBar(R.string.add_note, getString(R.string.added) + ": " + treatment_text, mOnClickListener, mActivity);
}
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showcasemenu(SHOWCASE_NOTE_LONG);
}
});
dialogBuilder.setNegativeButton(getString(R.string.cancel), (dialog, whichButton) -> {
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showcasemenu(SHOWCASE_NOTE_LONG);
}
});
if (Treatments.byTimestamp(timestamp, (int) (2.5 * MINUTE_IN_MS)) != null) {
dialogBuilder.setNeutralButton(R.string.delete, (dialog, whichButton) -> {
// are you sure?
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle(gs(R.string.confirm_delete));
builder.setMessage(gs(R.string.are_you_sure_you_want_to_delete_this_treatment));
builder.setPositiveButton(gs(R.string.yes_delete), (dialog1, which) -> {
dialog1.dismiss();
// 2.5 min resolution
Treatments.delete_by_timestamp(timestamp, (int) (2.5 * MINUTE_IN_MS), true);
staticRefreshBGCharts();
JoH.static_toast_short(gs(R.string.deleted));
});
builder.setNegativeButton(gs(R.string.no), (dialog12, which) -> dialog12.dismiss());
final AlertDialog alert = builder.create();
alert.show();
});
}
dialog = dialogBuilder.create();
edt.setInputType(InputType.TYPE_CLASS_TEXT);
edt.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus && dialog != null)
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
});
dialog.show();
}
use of com.eveningoutpost.dexdrip.UtilityModels.Constants.MINUTE_IN_MS in project xDrip-plus by jamorham.
the class Home method showNoteTextInputDialog.
public void showNoteTextInputDialog(View myitem, final long timestamp, final double position) {
Log.d(TAG, "showNoteTextInputDialog: ts:" + timestamp + " pos:" + position);
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.note_dialog_phone, null);
dialogBuilder.setView(dialogView);
final EditText edt = (EditText) dialogView.findViewById(R.id.treatment_note_edit_text);
final CheckBox cbx = (CheckBox) dialogView.findViewById(R.id.default_to_voice_input);
cbx.setChecked(Pref.getBooleanDefaultFalse("default_to_voice_notes"));
dialogBuilder.setTitle(R.string.treatment_note);
// dialogBuilder.setMessage("Enter text below");
dialogBuilder.setPositiveButton(R.string.done, (dialog, whichButton) -> {
String treatment_text = edt.getText().toString().trim();
Log.d(TAG, "Got treatment note: " + treatment_text);
// timestamp?
Treatments.create_note(treatment_text, timestamp, position);
Home.staticRefreshBGCharts();
if (treatment_text.length() > 0) {
// display snackbar of the snackbar
final View.OnClickListener mOnClickListener = v -> Home.startHomeWithExtra(xdrip.getAppContext(), Home.CREATE_TREATMENT_NOTE, Long.toString(timestamp), Double.toString(position));
Home.snackBar(R.string.add_note, getString(R.string.added) + ": " + treatment_text, mOnClickListener, mActivity);
}
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showcasemenu(SHOWCASE_NOTE_LONG);
}
});
dialogBuilder.setNegativeButton(getString(R.string.cancel), (dialog, whichButton) -> {
if (Pref.getBooleanDefaultFalse("default_to_voice_notes")) {
showcasemenu(SHOWCASE_NOTE_LONG);
}
});
if (Treatments.byTimestamp(timestamp, (int) (2.5 * MINUTE_IN_MS)) != null) {
dialogBuilder.setNeutralButton(R.string.delete, (dialog, whichButton) -> {
// are you sure?
final AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
builder.setTitle(gs(R.string.confirm_delete));
builder.setMessage(gs(R.string.are_you_sure_you_want_to_delete_this_treatment));
builder.setPositiveButton(gs(R.string.yes_delete), (dialog1, which) -> {
dialog1.dismiss();
// 2.5 min resolution
Treatments.delete_by_timestamp(timestamp, (int) (2.5 * MINUTE_IN_MS), true);
staticRefreshBGCharts();
JoH.static_toast_short(gs(R.string.deleted));
});
builder.setNegativeButton(gs(R.string.no), (dialog12, which) -> dialog12.dismiss());
final AlertDialog alert = builder.create();
alert.show();
});
}
dialog = dialogBuilder.create();
edt.setInputType(InputType.TYPE_CLASS_TEXT);
edt.setOnFocusChangeListener((v, hasFocus) -> {
if (hasFocus && dialog != null)
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
});
dialog.show();
}
Aggregations