use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class InstanceChooserList method createErrorDialog.
private void createErrorDialog(String errorMsg, final boolean shouldExit) {
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this).create();
alertDialog.setMessage(errorMsg);
DialogInterface.OnClickListener errorListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
switch(i) {
case DialogInterface.BUTTON_POSITIVE:
if (shouldExit) {
finish();
}
break;
}
}
};
alertDialog.setCancelable(false);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), errorListener);
alertDialog.show();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class GoogleDriveActivity method createAlertDialog.
private void createAlertDialog(String message) {
AlertDialog alertDialog = new MaterialAlertDialogBuilder(this).create();
alertDialog.setTitle(getString(R.string.download_forms_result));
alertDialog.setMessage(message);
DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
switch(i) {
case // ok
DialogInterface.BUTTON1:
alertShowing = false;
finish();
break;
}
}
};
alertDialog.setCancelable(false);
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok), quitListener);
alertShowing = true;
alertMsg = message;
DialogUtils.showDialog(alertDialog, this);
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class GoogleSheetsUploaderActivity method onCreateDialog.
@Override
protected Dialog onCreateDialog(int id) {
if (id == GOOGLE_USER_DIALOG) {
MaterialAlertDialogBuilder gudBuilder = new MaterialAlertDialogBuilder(this);
gudBuilder.setTitle(getString(R.string.no_google_account));
gudBuilder.setMessage(getString(R.string.google_set_account));
gudBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
gudBuilder.setCancelable(false);
return gudBuilder.create();
}
return null;
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class NumberPickerDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.number_picker_dialog, null);
final NumberPicker numberPicker = view.findViewById(R.id.number_picker);
numberPicker.setMaxValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1);
numberPicker.setMinValue(0);
numberPicker.setWrapSelectorWheel(false);
numberPicker.setDisplayedValues((String[]) getArguments().getSerializable(DISPLAYED_VALUES));
numberPicker.setValue(((String[]) getArguments().getSerializable(DISPLAYED_VALUES)).length - 1 - getArguments().getInt(PROGRESS));
return new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.number_picker_title).setView(view).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
listener.onNumberPickerValueSelected(getArguments().getInt(WIDGET_ID), numberPicker.getValue());
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).create();
}
use of com.google.android.material.dialog.MaterialAlertDialogBuilder in project collect by opendatakit.
the class ShowQRCodeFragment method passwordWarningClicked.
private void passwordWarningClicked() {
if (dialog == null) {
final String[] items = { getString(R.string.admin_password), getString(R.string.server_password) };
dialog = new MaterialAlertDialogBuilder(getActivity()).setTitle(R.string.include_password_dialog).setMultiChoiceItems(items, checkedItems, (dialog, which, isChecked) -> checkedItems[which] = isChecked).setCancelable(false).setPositiveButton(R.string.generate, (dialog, which) -> {
qrCodeViewModel.setIncludedKeys(getSelectedPasswordKeys());
dialog.dismiss();
}).setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()).create();
// disable checkbox if password not set
dialog.getListView().setOnHierarchyChangeListener(new ViewGroup.OnHierarchyChangeListener() {
@Override
public void onChildViewAdded(View parent, View child) {
CharSequence text = ((AppCompatCheckedTextView) child).getText();
int itemIndex = Arrays.asList(items).indexOf(text);
if (!passwordsSet[itemIndex]) {
child.setEnabled(passwordsSet[itemIndex]);
child.setOnClickListener(null);
}
}
@Override
public void onChildViewRemoved(View view, View view1) {
}
});
}
dialog.show();
}
Aggregations