use of android.app.AlertDialog.Builder in project k-9 by k9mail.
the class MessageCompose method onCreateDialog.
@Override
public Dialog onCreateDialog(int id) {
switch(id) {
case DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE:
return new AlertDialog.Builder(this).setTitle(R.string.save_or_discard_draft_message_dlg_title).setMessage(R.string.save_or_discard_draft_message_instructions_fmt).setPositiveButton(R.string.save_draft_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
checkToSaveDraftAndSave();
}
}).setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
onDiscard();
}
}).create();
case DIALOG_CONFIRM_DISCARD_ON_BACK:
return new AlertDialog.Builder(this).setTitle(R.string.confirm_discard_draft_message_title).setMessage(R.string.confirm_discard_draft_message).setPositiveButton(R.string.cancel_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
}
}).setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_CONFIRM_DISCARD_ON_BACK);
Toast.makeText(MessageCompose.this, getString(R.string.message_discarded_toast), Toast.LENGTH_LONG).show();
onDiscard();
}
}).create();
case DIALOG_CHOOSE_IDENTITY:
Context context = new ContextThemeWrapper(this, (K9.getK9Theme() == K9.Theme.LIGHT) ? R.style.Theme_K9_Dialog_Light : R.style.Theme_K9_Dialog_Dark);
Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.send_as);
final IdentityAdapter adapter = new IdentityAdapter(context);
builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
IdentityContainer container = (IdentityContainer) adapter.getItem(which);
onAccountChosen(container.account, container.identity);
}
});
return builder.create();
case DIALOG_CONFIRM_DISCARD:
{
return new AlertDialog.Builder(this).setTitle(R.string.dialog_confirm_delete_title).setMessage(R.string.dialog_confirm_delete_message).setPositiveButton(R.string.dialog_confirm_delete_confirm_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
onDiscard();
}
}).setNegativeButton(R.string.dialog_confirm_delete_cancel_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).create();
}
}
return super.onCreateDialog(id);
}
use of android.app.AlertDialog.Builder in project ADWLauncher2 by boombuler.
the class LauncherActionPreference method onClick.
@Override
protected void onClick() {
AlertDialog.Builder builder = new Builder(getContext());
builder.setTitle(this.getTitle());
final ListAdapter adapter = LauncherActions.getInstance().getSelectActionAdapter();
builder.setAdapter(adapter, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Action act = (Action) adapter.getItem(which);
Intent intent = LauncherActions.getInstance().getIntentForAction(act);
String sIntent = intent.toUri(0).toString();
persistString(sIntent);
}
});
builder.create().show();
}
use of android.app.AlertDialog.Builder in project AnimeTaste by daimajia.
the class StartActivity method rateForUsOrCheckUpdate.
public void rateForUsOrCheckUpdate() {
if (mSharedPreferences.getInt("playcount", 0) > 10 && !mSharedPreferences.getBoolean("sharedApp", false)) {
AlertDialog.Builder builder = new Builder(mContext);
builder.setMessage(R.string.rate_share_message);
builder.setTitle(R.string.rate_share_title);
builder.setPositiveButton(R.string.rate_share_i_do, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getText(R.string.share_title));
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, getText(R.string.share_app_body));
startActivity(Intent.createChooser(shareIntent, getText(R.string.share_via)));
MobclickAgent.onEvent(mContext, "need_share");
}
});
builder.setNegativeButton(R.string.rate_share_sorry, null);
builder.show();
mSharedPreferences.edit().putBoolean("sharedApp", true).commit();
} else {
UmengUpdateAgent.update(this);
}
}
use of android.app.AlertDialog.Builder in project platform_frameworks_base by android.
the class ResolverTargetActionsDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments();
final int itemRes = args.getBoolean(PINNED_KEY, false) ? R.array.resolver_target_actions_unpin : R.array.resolver_target_actions_pin;
return new Builder(getContext()).setCancelable(true).setItems(itemRes, this).setTitle(args.getCharSequence(TITLE_KEY)).create();
}
use of android.app.AlertDialog.Builder in project AndEngine by nicolasgramlich.
the class BetaUtils method finishWhenExpired.
public static boolean finishWhenExpired(final Activity pActivity, final GregorianCalendar pExpirationDate, final int pTitleResourceID, final int pMessageResourceID, final Intent pOkIntent, final Intent pCancelIntent) {
final SharedPreferences spref = SimplePreferences.getInstance(pActivity);
final long now = System.currentTimeMillis();
final long lastuse = Math.max(now, spref.getLong(PREFERENCES_BETAUTILS_ID, -1));
spref.edit().putLong(PREFERENCES_BETAUTILS_ID, lastuse).commit();
final GregorianCalendar lastuseDate = new GregorianCalendar();
lastuseDate.setTimeInMillis(lastuse);
if (lastuseDate.after(pExpirationDate)) {
final Builder alertDialogBuilder = new AlertDialog.Builder(pActivity).setTitle(pTitleResourceID).setIcon(android.R.drawable.ic_dialog_alert).setMessage(pMessageResourceID);
alertDialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(final DialogInterface pDialog, final int pWhich) {
if (pOkIntent != null) {
pActivity.startActivity(pOkIntent);
}
pActivity.finish();
}
});
alertDialogBuilder.setNegativeButton(android.R.string.cancel, new OnClickListener() {
@Override
public void onClick(final DialogInterface pDialog, final int pWhich) {
if (pCancelIntent != null) {
pActivity.startActivity(pCancelIntent);
}
pActivity.finish();
}
}).create().show();
return true;
} else {
return false;
}
}
Aggregations