use of android.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method quickEdit.
@SuppressLint("InflateParams")
private void quickEdit(final String previousValue, final OnValueEdited callback, final int hint, boolean password) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
View view = getLayoutInflater().inflate(R.layout.quickedit, null);
final EditText editor = (EditText) view.findViewById(R.id.editor);
OnClickListener mClickListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String value = editor.getText().toString();
if (!value.equals(previousValue) && value.trim().length() > 0) {
callback.onValueEdited(value);
}
}
};
if (password) {
editor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
builder.setPositiveButton(R.string.accept, mClickListener);
} else {
builder.setPositiveButton(R.string.edit, mClickListener);
}
if (hint != 0) {
editor.setHint(hint);
}
editor.requestFocus();
editor.setText("");
if (previousValue != null) {
editor.getText().append(previousValue);
}
builder.setView(view);
builder.setNegativeButton(R.string.cancel, null);
builder.create().show();
}
use of android.app.AlertDialog.Builder in project Conversations by siacs.
the class XmppActivity method showAskForPresenceDialog.
private void showAskForPresenceDialog(final Contact contact) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(contact.getJid().toString());
builder.setMessage(R.string.request_presence_updates);
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.request_now, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (xmppConnectionServiceBound) {
xmppConnectionService.sendPresencePacket(contact.getAccount(), xmppConnectionService.getPresenceGenerator().requestPresenceUpdatesFrom(contact));
}
}
});
builder.create().show();
}
use of android.app.AlertDialog.Builder in project ignition by mttkay.
the class IgnitedLocationSupport method buildWaitForLocationDialog.
/**
* Creates a builder for the wait for location dialog. By default dismissing the dialog will
* finish the {@link Activity} that created it.
*
* @param context
* @return a builder for the wait for location dialog
*/
public static Builder buildWaitForLocationDialog(final Context context) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(true);
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
((Activity) context).finish();
}
});
builder.setMessage(context.getString(R.string.ign_loc_dialog_wait_for_fix));
return builder;
}
use of android.app.AlertDialog.Builder in project ignition by mttkay.
the class IgnitedLocationSupport method createNoProvidersEnabledDialog.
public static Builder createNoProvidersEnabledDialog(final Activity activity, final boolean finishActivityOnDismiss) {
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == DialogInterface.BUTTON_POSITIVE) {
Intent intent = new Intent();
intent.setAction(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
} else {
dialog.cancel();
if (finishActivityOnDismiss) {
activity.finish();
}
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setPositiveButton(R.string.ign_loc_dialog_location_unavailable_change_settings, listener);
builder.setNegativeButton(android.R.string.no, listener);
builder.setCancelable(false);
builder.setTitle(R.string.ign_loc_dialog_location_unavailable_title);
builder.setMessage(R.string.ign_loc_dialog_location_unavailable_message);
builder.setIcon(android.R.drawable.ic_dialog_alert);
return builder;
}
use of android.app.AlertDialog.Builder in project ignition by mttkay.
the class IgnitedDialogs method newMessageDialog.
/**
* Builds a new AlertDialog to display a simple message
*
* @param context
* @param title
* @param message
* @param iconId
* @return
*/
public static AlertDialog.Builder newMessageDialog(final Context context, String title, String message, int iconId) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(false);
builder.setPositiveButton(context.getString(android.R.string.ok), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.setTitle(title);
builder.setMessage(message);
builder.setIcon(iconId);
return builder;
}
Aggregations