use of android.app.AlertDialog in project collect by opendatakit.
the class GeoPointOsmMapActivity method showGPSDisabledAlertToUser.
private void showGPSDisabledAlertToUser() {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage(getString(R.string.gps_enable_message)).setCancelable(false).setPositiveButton(getString(R.string.enable_gps), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
}
});
alertDialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
use of android.app.AlertDialog in project collect by opendatakit.
the class GeoShapeOsmMapActivity method showGPSDisabledAlertToUser.
private void showGPSDisabledAlertToUser() {
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage(getString(R.string.gps_enable_message)).setCancelable(false).setPositiveButton(getString(R.string.enable_gps), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
}
});
alertDialogBuilder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
use of android.app.AlertDialog in project collect by opendatakit.
the class InstanceUploaderList method showSentAndUnsentChoices.
private boolean showSentAndUnsentChoices() {
/**
* Create a dialog with options to save and exit, save, or quit without
* saving
*/
String[] items = { getString(R.string.show_unsent_forms), getString(R.string.show_sent_and_unsent_forms) };
logger.logAction(this, "changeView", "show");
AlertDialog alertDialog = new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_info).setTitle(getString(R.string.change_view)).setNeutralButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
logger.logAction(this, "changeView", "cancel");
dialog.cancel();
}
}).setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(which) {
case // show unsent
0:
logger.logAction(this, "changeView", "showUnsent");
InstanceUploaderList.this.showUnsent();
break;
case // show all
1:
logger.logAction(this, "changeView", "showAll");
InstanceUploaderList.this.showAll();
break;
case // do nothing
2:
break;
}
}
}).create();
alertDialog.show();
return true;
}
use of android.app.AlertDialog in project orgzly-android by orgzly.
the class MainActivity method onBookRenameRequest.
@Override
public void onBookRenameRequest(final long bookId) {
final Book book = BooksClient.get(this, bookId);
if (book == null) {
return;
}
final View dialogView = View.inflate(this, R.layout.dialog_book_rename, null);
final TextInputLayout nameInputLayout = dialogView.findViewById(R.id.name_input_layout);
final EditText name = dialogView.findViewById(R.id.name);
DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
switch(which) {
case DialogInterface.BUTTON_POSITIVE:
doRenameBook(book, name.getText().toString(), nameInputLayout);
break;
case DialogInterface.BUTTON_NEGATIVE:
break;
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(getString(R.string.rename_book, MiscUtils.quotedString(book.getName()))).setPositiveButton(R.string.rename, dialogClickListener).setNegativeButton(R.string.cancel, dialogClickListener).setView(dialogView);
name.setText(book.getName());
final AlertDialog dialog = builder.create();
/* Finish on keyboard action press. */
name.setOnEditorActionListener((v, actionId, event) -> {
dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
return true;
});
final Activity activity = this;
dialog.setOnShowListener(d -> ActivityUtils.INSTANCE.openSoftKeyboard(activity, name));
dialog.setOnDismissListener(d -> ActivityUtils.INSTANCE.closeSoftKeyboard(activity));
name.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable str) {
/* Disable the button is nothing is entered. */
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!TextUtils.isEmpty(str));
}
});
dialog.show();
}
use of android.app.AlertDialog in project pictureapp by EyeSeeTea.
the class Dialog method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String message = intent.getStringExtra("message");
String title = intent.getStringExtra("title");
alertDialog = new AlertDialog.Builder(this);
alertDialog.setTitle("");
alertDialog.setMessage(message);
alertDialog.setCancelable(false);
alertDialog.setTitle(title);
alertDialog.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
goBack();
}
});
alertDialog.show();
}
Aggregations