@Override public void onStart() { super.onStart(); AlertDialog dialog = (AlertDialog) getDialog(); // http://stackoverflow.com/a/16972670/1048340 //noinspection ConstantConditions dialog.getWindow() .clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); // Do not dismiss the dialog when clicking the neutral button. Button neutralButton = dialog.getButton(AlertDialog.BUTTON_NEUTRAL); if (neutralButton != null) { neutralButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { rootView.removeAllViews(); switch (dialogType) { case TYPE_CUSTOM: dialogType = TYPE_PRESETS; ((Button) v).setText(customButtonStringRes != 0 ? customButtonStringRes : R.string.cpv_custom); rootView.addView(createPresetsView()); break; case TYPE_PRESETS: dialogType = TYPE_CUSTOM; ((Button) v).setText(presetsButtonStringRes != 0 ? presetsButtonStringRes : R.string.cpv_presets); rootView.addView(createPickerView()); } } }); } }
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_about_durable_event, null); AlertDialog dialog = new AlertDialog.Builder(getActivity()) .setTitle(R.string.about_durable_event) .setView(view) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { sendResult(Activity.RESULT_OK, true); dismiss(); } }) .create(); dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation; return dialog; }
/** * Prompt the user to type in a name for the new chat room */ private void newChatRoom() { // Set an EditText view to get user input final View view = View.inflate(this, R.layout.dialog_input, null); final EditText input = view.findViewById(R.id.inputEditText); AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.new_chat_room) .setMessage(R.string.new_chat_room_desc) .setView(view) .setPositiveButton(R.string.create, (dialogInterface, whichButton) -> { String value = input.getText() .toString(); String randId = Integer.toHexString((int) (Math.random() * 4096)); createOrJoinChatRoom(randId + ':' + value); }) .setNegativeButton(android.R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow() .setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showError(String message) { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.error)) .setMessage(message) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showErrorDialog(String message) { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.error) .setMessage(message) .setIcon(R.drawable.ic_error_outline) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void displayCloseDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setMessage(R.string.discard_changes_question) .setNegativeButton(R.string.discard, (dialogInterface, which) -> finish()) .setPositiveButton(R.string.keep_editing, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showLogoutDialog() { AlertDialog dialog = new AlertDialog.Builder(mContext) .setMessage(R.string.logout_message) .setPositiveButton(R.string.logout, ((dialogInterface, i) -> logout())) .setNegativeButton(R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
@Override public void onClick(View v) { List<Rule> rules = new ArrayList<>(); for (Rule rule : getEntry().mRules) rules.add(new Rule(rule)); if (rules.size() == 0) rules.add(new Rule()); View view = LayoutInflater.from(itemView.getContext()).inflate( R.layout.settings_reconnect_dialog, null); RecyclerView recyclerView = view.findViewById(R.id.rules); RulesAdapter adapter = new RulesAdapter(rules); recyclerView.setLayoutManager(new LinearLayoutManager(itemView.getContext())); recyclerView.setAdapter(adapter); AlertDialog dialog = new AlertDialog.Builder(v.getContext()) .setPositiveButton(R.string.action_ok, (DialogInterface dialogInterface, int which) -> { getEntry().setRules(rules); }) .setView(view) .setTitle(getEntry().mName) .create(); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); adapter.setDialog(dialog); dialog.show(); dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); }
private void showDeleteProfileDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.eduroam_dialog_title) .setMessage(R.string.eduroam_dialog_info_text) .setNegativeButton(R.string.cancel, null) .setPositiveButton(R.string.eduroam_dialog_preferences, (dialogInterface, i) -> { Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(intent); }) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void handleTicketNotFetched() { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.error)) .setMessage(getString(R.string.ticket_not_fetched)) .setPositiveButton(R.string.ok, (dialogInterface, which) -> { loadingLayout.setVisibility(View.GONE); TransitionManager.beginDelayedTransition(loadingLayout); paymentButton.setEnabled(true); }) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showLeaveChatRoomDialog() { AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.leave_chat_room) .setMessage(getResources().getString(R.string.leave_chat_room_body)) .setPositiveButton(R.string.leave, (dialogInterface, i) -> leaveChatRoom()) .setNegativeButton(android.R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showLicense() { // @binkybear here goes the changelog etc... \n\n%s String readmeData = String.format("%s\n\n%s", getResources().getString(R.string.licenseInfo), getResources().getString(R.string.nhwarning)); AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle("README INFO") .setMessage(readmeData) .setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); //nhwarning AlertDialog ad = adb.create(); ad.setCancelable(false); ad.getWindow().getAttributes().windowAnimations = R.style.DialogStyle; ad.show(); }
private void showIngredientsInfo() { // Build a alert dialog containing the mapping of ingredients to the numbers CafeteriaMenuFormatter formatter = new CafeteriaMenuFormatter(this); SpannableString message = formatter.format(R.string.cafeteria_ingredients, true); AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.action_ingredients) .setMessage(message) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void resendIfError(Context context, ChatMessage message, OnRetrySendListener retryListener) { if (message.getSendingStatus() == ChatMessage.STATUS_ERROR) { AlertDialog dialog = new AlertDialog.Builder(context) .setMessage(R.string.chat_message_try_again) .setPositiveButton(R.string.retry, (dialogInterface, i) -> { retryListener.onRetrySending(message); }) .setNegativeButton(R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow() .setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); } }
/** * Display an obtrusive error dialog because on the provided {@link Throwable}. * @param throwable The {@link Throwable} that occurred */ private void displayErrorDialog(Throwable throwable) { int messageResId; if (throwable instanceof InactiveTokenException) { messageResId = R.string.error_access_token_inactive; } else if (throwable instanceof InvalidTokenException) { messageResId = R.string.error_invalid_access_token; } else if (throwable instanceof UnknownErrorException) { messageResId = R.string.error_unknown; } else if (throwable instanceof TokenLimitReachedException) { messageResId = R.string.error_access_token_limit_reached; } else if (throwable instanceof RequestLimitReachedException) { messageResId = R.string.error_request_limit_reached; } else { messageResId = R.string.error_access_token_could_not_be_generated; } AlertDialog dialog = new AlertDialog.Builder(this) .setMessage(messageResId) .setPositiveButton(R.string.ok, null) .setCancelable(true) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void getBackupLocation() { Location backup = new LocationManager(mContext).getLastLocation(); if (backup != null) { location = backup; return; } // we don't know anything about the location AlertDialog dialog = new AlertDialog.Builder(mContext) .setTitle(R.string.location_services_off_title) .setMessage(R.string.location_services_off_message) .setPositiveButton(R.string.ok, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
void showPictureOptionsDialog(Activity activity) { String[] options = { mContext.getString(R.string.feedback_take_picture), mContext.getString(R.string.gallery) }; AlertDialog dialog = new AlertDialog.Builder(mContext) .setTitle(R.string.feedback_add_picture) .setItems(options, (dialogInterface, i) -> { if (i == 0) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || checkPermission(Manifest.permission.CAMERA, activity)) { startTakingPicture(activity); } } else { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE, activity)) { openGallery(activity); } } }) .setNegativeButton(R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
public void onSendClicked(View view) { getFeedback(); if (feedback.getMessage().trim().isEmpty()) { if (feedback.getPicturePaths().isEmpty()) { feedbackView.setError(getString(R.string.feedback_empty)); } else { feedbackView.setError(getString(R.string.feedback_img_without_text)); } } AlertDialog dialog = new AlertDialog.Builder(this) .setTitle(R.string.send_feedback_question) .setPositiveButton(R.string.send, (dialogInterface, i) -> controller.sendFeedback(this, feedback, lrzId)) .setNegativeButton(R.string.no, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }
private void showConfirmDialog(ChatMember member) { String message = getString(R.string.add_user_to_chat_message, member.getDisplayName(), room.getTitle()); AlertDialog dialog = new AlertDialog.Builder(this) .setMessage(message) .setPositiveButton(R.string.add, (dialogInterface, i) -> { joinRoom(member); reset(); }) .setNegativeButton(android.R.string.cancel, null) .create(); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background); } dialog.show(); }