use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project Signal-Android by WhisperSystems.
the class BaseRegistrationLockFragment method handleForgottenPin.
private void handleForgottenPin(long timeRemainingMs) {
int lockoutDays = getLockoutDays(timeRemainingMs);
new MaterialAlertDialogBuilder(requireContext()).setTitle(R.string.RegistrationLockFragment__forgot_your_pin).setMessage(requireContext().getResources().getQuantityString(R.plurals.RegistrationLockFragment__for_your_privacy_and_security_there_is_no_way_to_recover, lockoutDays, lockoutDays)).setPositiveButton(android.R.string.ok, null).setNeutralButton(R.string.PinRestoreEntryFragment_contact_support, (dialog, which) -> sendEmailToSupport()).show();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class GeoPolySettingsDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
View settingsView = getActivity().getLayoutInflater().inflate(R.layout.geopoly_dialog, null);
radioGroup = settingsView.findViewById(R.id.radio_group);
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
checkedRadioButtonId = checkedId;
autoOptions.setVisibility(checkedId == R.id.automatic_mode ? View.VISIBLE : View.GONE);
});
autoOptions = settingsView.findViewById(R.id.auto_options);
Spinner autoInterval = settingsView.findViewById(R.id.auto_interval);
autoInterval.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
intervalIndex = position;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
String[] options = new String[INTERVAL_OPTIONS.length];
for (int i = 0; i < INTERVAL_OPTIONS.length; i++) {
options[i] = formatInterval(INTERVAL_OPTIONS[i]);
}
populateSpinner(autoInterval, options);
Spinner accuracyThreshold = settingsView.findViewById(R.id.accuracy_threshold);
accuracyThreshold.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
accuracyThresholdIndex = position;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
options = new String[ACCURACY_THRESHOLD_OPTIONS.length];
for (int i = 0; i < ACCURACY_THRESHOLD_OPTIONS.length; i++) {
options[i] = formatAccuracyThreshold(ACCURACY_THRESHOLD_OPTIONS[i]);
}
populateSpinner(accuracyThreshold, options);
if (checkedRadioButtonId == -1) {
checkedRadioButtonId = callback.getCheckedId();
intervalIndex = callback.getIntervalIndex();
accuracyThresholdIndex = callback.getAccuracyThresholdIndex();
radioGroup.check(checkedRadioButtonId);
autoInterval.setSelection(intervalIndex);
accuracyThreshold.setSelection(accuracyThresholdIndex);
}
return new MaterialAlertDialogBuilder(getActivity()).setTitle(getString(R.string.input_method)).setView(settingsView).setPositiveButton(getString(R.string.start), (dialog, id) -> {
callback.updateRecordingMode(radioGroup.getCheckedRadioButtonId());
callback.setIntervalIndex(intervalIndex);
callback.setAccuracyThresholdIndex(accuracyThresholdIndex);
callback.startInput();
dismiss();
}).setNegativeButton(R.string.cancel, (dialog, id) -> {
dismiss();
}).create();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class InstanceUploaderListActivity method showSentAndUnsentChoices.
/*
* Create a dialog with options to save and exit, save, or quit without
* saving
*/
private boolean showSentAndUnsentChoices() {
String[] items = { getString(R.string.show_unsent_forms), getString(R.string.show_sent_and_unsent_forms) };
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this).setTitle(getString(R.string.change_view)).setNeutralButton(getString(R.string.cancel), (dialog, id) -> {
dialog.cancel();
}).setItems(items, (dialog, which) -> {
switch(which) {
case // show unsent
0:
showAllMode = false;
updateAdapter();
break;
case // show all
1:
showAllMode = true;
updateAdapter();
break;
case // do nothing
2:
break;
}
}).create();
alertDialog.show();
return true;
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class DrawActivity method createQuitDrawDialog.
/**
* Create a dialog with options to save and exit, save, or quit without
* saving
*/
private void createQuitDrawDialog() {
ListView listView = DialogUtils.createActionListView(this);
List<IconMenuItem> items;
items = ImmutableList.of(new IconMenuItem(R.drawable.ic_save, R.string.keep_changes), new IconMenuItem(R.drawable.ic_delete, R.string.do_not_save));
final IconMenuListAdapter adapter = new IconMenuListAdapter(this, items);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
IconMenuItem item = (IconMenuItem) adapter.getItem(position);
if (item.getTextResId() == R.string.keep_changes) {
saveAndClose();
} else {
cancelAndClose();
}
alertDialog.dismiss();
}
});
alertDialog = new MaterialAlertDialogBuilder(this).setTitle(alertTitleString).setPositiveButton(getString(R.string.do_not_exit), null).setView(listView).create();
alertDialog.show();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class FormEntryActivity method createLanguageDialog.
/**
* Creates and displays a dialog allowing the user to set the language for
* the form.
*/
private void createLanguageDialog() {
FormController formController = getFormController();
final String[] languages = formController.getLanguages();
int selected = -1;
if (languages != null) {
String language = formController.getLanguage();
for (int i = 0; i < languages.length; i++) {
if (language.equals(languages[i])) {
selected = i;
}
}
}
alertDialog = new MaterialAlertDialogBuilder(this).setSingleChoiceItems(languages, selected, (dialog, whichButton) -> {
Form form = formsRepository.getOneByPath(formPath);
if (form != null) {
formsRepository.save(new Form.Builder(form).language(languages[whichButton]).build());
}
getFormController().setLanguage(languages[whichButton]);
dialog.dismiss();
if (getFormController().currentPromptIsQuestion()) {
saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS);
}
onScreenRefresh();
}).setTitle(getString(R.string.change_language)).setNegativeButton(getString(R.string.do_not_change), null).create();
alertDialog.show();
}
Aggregations