use of android.app.AlertDialog in project platform_frameworks_base by android.
the class CreateDirectoryFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getActivity();
final ContentResolver resolver = context.getContentResolver();
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
final LayoutInflater dialogInflater = LayoutInflater.from(builder.getContext());
final View view = dialogInflater.inflate(R.layout.dialog_file_name, null, false);
final EditText editText = (EditText) view.findViewById(android.R.id.text1);
builder.setTitle(R.string.menu_create_dir);
builder.setView(view);
builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
createDirectory(editText.getText().toString());
}
});
builder.setNegativeButton(android.R.string.cancel, null);
final AlertDialog dialog = builder.create();
// Workaround for the problem - virtual keyboard doesn't show on the phone.
Shared.ensureKeyboardPresent(context, dialog);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView view, int actionId, @Nullable KeyEvent event) {
if ((actionId == EditorInfo.IME_ACTION_DONE) || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.hasNoModifiers())) {
createDirectory(editText.getText().toString());
dialog.dismiss();
return true;
}
return false;
}
});
return dialog;
}
use of android.app.AlertDialog in project platform_frameworks_base by android.
the class MainActivity method showDialog.
private void showDialog(String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(message).setTitle("OSU");
builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
dialogInterface.cancel();
finish();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
use of android.app.AlertDialog in project iosched by google.
the class MyScheduleActivity method showAnnouncementDialogIfNeeded.
private void showAnnouncementDialogIfNeeded(Intent intent) {
final String title = intent.getStringExtra(EXTRA_DIALOG_TITLE);
final String message = intent.getStringExtra(EXTRA_DIALOG_MESSAGE);
if (!mShowedAnnouncementDialog && !TextUtils.isEmpty(title) && !TextUtils.isEmpty(message)) {
LOGD(TAG, "showAnnouncementDialogIfNeeded, title: " + title);
LOGD(TAG, "showAnnouncementDialogIfNeeded, message: " + message);
final String yes = intent.getStringExtra(EXTRA_DIALOG_YES);
LOGD(TAG, "showAnnouncementDialogIfNeeded, yes: " + yes);
final String no = intent.getStringExtra(EXTRA_DIALOG_NO);
LOGD(TAG, "showAnnouncementDialogIfNeeded, no: " + no);
final String url = intent.getStringExtra(EXTRA_DIALOG_URL);
LOGD(TAG, "showAnnouncementDialogIfNeeded, url: " + url);
final SpannableString spannable = new SpannableString(message == null ? "" : message);
Linkify.addLinks(spannable, Linkify.WEB_URLS);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
if (!TextUtils.isEmpty(title)) {
builder.setTitle(title);
}
builder.setMessage(spannable);
if (!TextUtils.isEmpty(no)) {
builder.setNegativeButton(no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
}
if (!TextUtils.isEmpty(yes)) {
builder.setPositiveButton(yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
}
});
}
final AlertDialog dialog = builder.create();
dialog.show();
final TextView messageView = (TextView) dialog.findViewById(android.R.id.message);
if (messageView != null) {
// makes the embedded links in the text clickable, if there are any
messageView.setMovementMethod(LinkMovementMethod.getInstance());
}
mShowedAnnouncementDialog = true;
}
}
use of android.app.AlertDialog in project WordPress-Android by wordpress-mobile.
the class LinkDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.dialog_link, null);
final EditText urlEditText = (EditText) view.findViewById(R.id.linkURL);
final EditText linkEditText = (EditText) view.findViewById(R.id.linkText);
builder.setView(view).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent();
intent.putExtra(LINK_DIALOG_ARG_URL, urlEditText.getText().toString());
intent.putExtra(LINK_DIALOG_ARG_TEXT, linkEditText.getText().toString());
getTargetFragment().onActivityResult(getTargetRequestCode(), getTargetRequestCode(), intent);
}
}).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
LinkDialogFragment.this.getDialog().cancel();
}
});
// If updating an existing link, add a 'Delete' button
if (getTargetRequestCode() == LINK_DIALOG_REQUEST_CODE_UPDATE) {
builder.setNeutralButton(R.string.delete, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getTargetFragment().onActivityResult(getTargetRequestCode(), LINK_DIALOG_REQUEST_CODE_DELETE, null);
}
});
}
// Prepare initial state of EditTexts
Bundle bundle = getArguments();
if (bundle != null) {
linkEditText.setText(bundle.getString(LINK_DIALOG_ARG_TEXT));
String url = bundle.getString(LINK_DIALOG_ARG_URL);
if (url != null) {
urlEditText.setText(url);
}
urlEditText.selectAll();
}
AlertDialog dialog = builder.create();
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return dialog;
}
use of android.app.AlertDialog in project WordPress-Android by wordpress-mobile.
the class JetpackUtils method showJetpackStatsModuleAlert.
public static void showJetpackStatsModuleAlert(final Activity activity, final SiteModel site) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
if (site.isSelfHostedAdmin()) {
builder.setMessage(activity.getString(R.string.jetpack_stats_module_disabled_message)).setTitle(activity.getString(R.string.jetpack_info));
builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String stringToLoad = site.getAdminUrl();
String jetpackConnectPageAdminPath = "admin.php?page=jetpack#/engagement";
stringToLoad = stringToLoad.endsWith("/") ? stringToLoad + jetpackConnectPageAdminPath : stringToLoad + "/" + jetpackConnectPageAdminPath;
String authURL = WPWebViewActivity.getSiteLoginUrl(site);
Intent jetpackIntent = new Intent(activity, WPWebViewActivity.class);
jetpackIntent.putExtra(WPWebViewActivity.AUTHENTICATION_USER, site.getUsername());
jetpackIntent.putExtra(WPWebViewActivity.AUTHENTICATION_PASSWD, site.getPassword());
jetpackIntent.putExtra(WPWebViewActivity.URL_TO_LOAD, stringToLoad);
jetpackIntent.putExtra(WPWebViewActivity.AUTHENTICATION_URL, authURL);
activity.startActivityForResult(jetpackIntent, RequestCodes.REQUEST_JETPACK);
// TODO: track analytics here?
}
});
builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog. Hide current activity.
activity.finish();
}
});
} else {
builder.setMessage(activity.getString(R.string.jetpack_stats_module_disabled_message_not_admin)).setTitle(activity.getString(R.string.jetpack_info));
builder.setPositiveButton(R.string.yes, null);
}
AlertDialog dialog = builder.create();
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
// User pressed the back key. Hide current activity.
activity.finish();
}
});
dialog.show();
}
Aggregations