Use dialog title instead of message

pull/848/head
Alex Baker 5 years ago
parent f35dbaa529
commit 54755570ec

@ -270,7 +270,7 @@ public final class TaskEditFragment extends InjectingFragment
if (hasChanges( if (hasChanges(
taskEditControlSetFragmentManager.getFragmentsInPersistOrder(getChildFragmentManager()))) { taskEditControlSetFragmentManager.getFragmentsInPersistOrder(getChildFragmentManager()))) {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.discard_confirmation) .newDialog(R.string.discard_confirmation)
.setPositiveButton(R.string.keep_editing, null) .setPositiveButton(R.string.keep_editing, null)
.setNegativeButton(R.string.discard, (dialog, which) -> discard()) .setNegativeButton(R.string.discard, (dialog, which) -> discard())
.show(); .show();
@ -289,7 +289,7 @@ public final class TaskEditFragment extends InjectingFragment
private void deleteButtonClick() { private void deleteButtonClick() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.DLG_delete_this_task_question) .newDialog(R.string.DLG_delete_this_task_question)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, android.R.string.ok,
(dialog, which) -> { (dialog, which) -> {

@ -401,7 +401,7 @@ public final class TaskListFragment extends InjectingFragment
return true; return true;
case R.id.menu_clear_completed: case R.id.menu_clear_completed:
dialogBuilder dialogBuilder
.newMessageDialog(R.string.clear_completed_tasks_confirmation) .newDialog(R.string.clear_completed_tasks_confirmation)
.setPositiveButton(android.R.string.ok, (dialog, which) -> clearCompleted()) .setPositiveButton(android.R.string.ok, (dialog, which) -> clearCompleted())
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();

@ -159,8 +159,7 @@ public class TasksXmlImporter {
private void showSummary() { private void showSummary() {
Resources r = activity.getResources(); Resources r = activity.getResources();
dialogBuilder dialogBuilder
.newDialog() .newDialog(R.string.import_summary_title)
.setTitle(R.string.import_summary_title)
.setMessage( .setMessage(
activity.getString( activity.getString(
R.string.import_summary_message, R.string.import_summary_message,

@ -331,7 +331,7 @@ public class CustomFilterActivity extends ThemedInjectingAppCompatActivity
finish(); finish();
} else { } else {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.discard_changes) .newDialog(R.string.discard_changes)
.setPositiveButton(R.string.keep_editing, null) .setPositiveButton(R.string.keep_editing, null)
.setNegativeButton(R.string.discard, (dialog, which) -> finish()) .setNegativeButton(R.string.discard, (dialog, which) -> finish())
.show(); .show();

@ -116,7 +116,7 @@ class CustomFilterAdapter extends ArrayAdapter<CriterionInstance> {
/** Show options menu for the given criterioninstance */ /** Show options menu for the given criterioninstance */
public void showOptionsFor(final CriterionInstance item, final Runnable onComplete) { public void showOptionsFor(final CriterionInstance item, final Runnable onComplete) {
AlertDialogBuilder dialog = dialogBuilder.newDialog().setTitle(item.criterion.name); AlertDialogBuilder dialog = dialogBuilder.newDialog(item.criterion.name);
if (item.criterion instanceof MultipleSelectCriterion) { if (item.criterion instanceof MultipleSelectCriterion) {
MultipleSelectCriterion multiSelectCriterion = (MultipleSelectCriterion) item.criterion; MultipleSelectCriterion multiSelectCriterion = (MultipleSelectCriterion) item.criterion;

@ -81,7 +81,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity {
private void purgeDeletedTasks() { private void purgeDeletedTasks() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.EPr_manage_purge_deleted_message) .newDialog(R.string.EPr_manage_purge_deleted_message)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, android.R.string.ok,
(dialog, which) -> (dialog, which) ->
@ -93,7 +93,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity {
private void deleteCompletedEvents() { private void deleteCompletedEvents() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.EPr_manage_delete_completed_gcal_message) .newDialog(R.string.EPr_manage_delete_completed_gcal_message)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, android.R.string.ok,
(dialog, which) -> (dialog, which) ->
@ -109,7 +109,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity {
private void deleteAllCalendarEvents() { private void deleteAllCalendarEvents() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.EPr_manage_delete_all_gcal_message) .newDialog(R.string.EPr_manage_delete_all_gcal_message)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, android.R.string.ok,
(dialog, which) -> (dialog, which) ->
@ -133,7 +133,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity {
private void resetPreferences() { private void resetPreferences() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.EPr_reset_preferences_warning) .newDialog(R.string.EPr_reset_preferences_warning)
.setPositiveButton( .setPositiveButton(
R.string.EPr_reset_preferences, R.string.EPr_reset_preferences,
(dialog, which) -> { (dialog, which) -> {
@ -146,7 +146,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity {
private void deleteTaskData() { private void deleteTaskData() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.EPr_delete_task_data_warning) .newDialog(R.string.EPr_delete_task_data_warning)
.setPositiveButton( .setPositiveButton(
R.string.EPr_delete_task_data, R.string.EPr_delete_task_data,
(dialog, which) -> { (dialog, which) -> {

@ -140,7 +140,7 @@ public class FilesControlSet extends TaskEditControlFragment {
clearFile.setOnClickListener( clearFile.setOnClickListener(
v -> v ->
dialogBuilder dialogBuilder
.newMessageDialog(R.string.premium_remove_file_confirm) .newDialog(R.string.premium_remove_file_confirm)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, android.R.string.ok,
(dialog, which) -> { (dialog, which) -> {

@ -44,7 +44,7 @@ public class CalendarReminderActivity extends ThemedInjectingAppCompatActivity {
ignorePresses++; ignorePresses++;
if (ignorePresses == IGNORE_PROMPT_COUNT) { if (ignorePresses == IGNORE_PROMPT_COUNT) {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.CRA_ignore_body) .newDialog(R.string.CRA_ignore_body)
.setPositiveButton( .setPositiveButton(
R.string.CRA_ignore_all, R.string.CRA_ignore_all,
(dialog, which) -> { (dialog, which) -> {

@ -267,8 +267,7 @@ public class TasksJsonImporter {
private void showSummary() { private void showSummary() {
Resources r = activity.getResources(); Resources r = activity.getResources();
dialogBuilder dialogBuilder
.newDialog() .newDialog(R.string.import_summary_title)
.setTitle(R.string.import_summary_title)
.setMessage( .setMessage(
activity.getString( activity.getString(
R.string.import_summary_message, R.string.import_summary_message,

@ -82,8 +82,7 @@ public class NameYourPriceDialog extends InjectingDialogFragment implements OnPu
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
AlertDialog dialog = AlertDialog dialog =
dialogBuilder dialogBuilder
.newDialog() .newDialog(R.string.name_your_price)
.setTitle(R.string.name_your_price)
.setView(R.layout.dialog_name_your_price) .setView(R.layout.dialog_name_your_price)
.show(); .show();

@ -42,8 +42,7 @@ public class PurchaseDialog extends InjectingDialogFragment {
String[] rows = context.getResources().getStringArray(R.array.pro_description); String[] rows = context.getResources().getStringArray(R.array.pro_description);
textView.setText(Joiner.on('\n').join(transform(asList(rows), item -> "\u2022 " + item))); textView.setText(Joiner.on('\n').join(transform(asList(rows), item -> "\u2022 " + item)));
return dialogBuilder return dialogBuilder
.newDialog() .newDialog(R.string.pro_support_development)
.setTitle(R.string.pro_support_development)
.setView(view) .setView(view)
.setPositiveButton( .setPositiveButton(
R.string.name_your_price, R.string.name_your_price,

@ -123,7 +123,7 @@ public abstract class BaseListSettingsActivity extends ThemedInjectingAppCompatA
finish(); finish();
} else { } else {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.discard_changes) .newDialog(R.string.discard_changes)
.setPositiveButton(R.string.discard, (dialog, which) -> finish()) .setPositiveButton(R.string.discard, (dialog, which) -> finish())
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();
@ -174,7 +174,7 @@ public abstract class BaseListSettingsActivity extends ThemedInjectingAppCompatA
protected void promptDelete() { protected void promptDelete() {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.delete_tag_confirmation, getToolbarTitle()) .newDialog(R.string.delete_tag_confirmation, getToolbarTitle())
.setPositiveButton( .setPositiveButton(
R.string.delete, R.string.delete,
(dialog, which) -> delete()) (dialog, which) -> delete())

@ -409,7 +409,7 @@ public class CaldavAccountSettingsActivity extends ThemedInjectingAppCompatActiv
} }
dialogBuilder dialogBuilder
.newMessageDialog(R.string.logout_warning, caldavAccount.getName()) .newDialog(R.string.logout_warning, caldavAccount.getName())
.setPositiveButton( .setPositiveButton(
R.string.remove, R.string.remove,
(dialog, which) -> { (dialog, which) -> {
@ -431,7 +431,7 @@ public class CaldavAccountSettingsActivity extends ThemedInjectingAppCompatActiv
finish(); finish();
} else { } else {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.discard_changes) .newDialog(R.string.discard_changes)
.setPositiveButton(R.string.discard, (dialog, which) -> finish()) .setPositiveButton(R.string.discard, (dialog, which) -> finish())
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.show(); .show();

@ -50,11 +50,16 @@ public class AlertDialogBuilder {
return this; return this;
} }
public AlertDialogBuilder setTitle(int title) { AlertDialogBuilder setTitle(int title) {
builder.setTitle(title); builder.setTitle(title);
return this; return this;
} }
AlertDialogBuilder setTitle(int title, Object... formatArgs) {
builder.setTitle(context.getString(title, formatArgs));
return this;
}
public AlertDialogBuilder setItems( public AlertDialogBuilder setItems(
List<String> strings, DialogInterface.OnClickListener onClickListener) { List<String> strings, DialogInterface.OnClickListener onClickListener) {
return setItems(strings.toArray(new String[strings.size()]), onClickListener); return setItems(strings.toArray(new String[strings.size()]), onClickListener);
@ -115,7 +120,7 @@ public class AlertDialogBuilder {
return this; return this;
} }
public AlertDialogBuilder setTitle(String title) { AlertDialogBuilder setTitle(String title) {
builder.setTitle(title); builder.setTitle(title);
return this; return this;
} }

@ -29,11 +29,19 @@ public class DialogBuilder {
return new AlertDialogBuilder(activity, theme, locale); return new AlertDialogBuilder(activity, theme, locale);
} }
public AlertDialogBuilder newMessageDialog(int message, Object... formatArgs) { public AlertDialogBuilder newDialog(int title) {
return newDialog().setMessage(message, formatArgs); return newDialog().setTitle(title);
} }
public ProgressDialog newProgressDialog() { public AlertDialogBuilder newDialog(String title) {
return newDialog().setTitle(title);
}
public AlertDialogBuilder newDialog(int title, Object... formatArgs) {
return newDialog().setTitle(title, formatArgs);
}
ProgressDialog newProgressDialog() {
ProgressDialog progressDialog = ProgressDialog progressDialog =
new ProgressDialog(activity, theme.getThemeBase().getAlertDialogStyle()); new ProgressDialog(activity, theme.getThemeBase().getAlertDialogStyle());
theme.applyToContext(progressDialog.getContext()); theme.applyToContext(progressDialog.getContext());

@ -77,8 +77,7 @@ public class GeofenceDialog extends InjectingDialogFragment {
departureView.setChecked(hasLocationPermission && geofence.isDeparture()); departureView.setChecked(hasLocationPermission && geofence.isDeparture());
updateRadius(geofence.getRadius()); updateRadius(geofence.getRadius());
return dialogBuilder return dialogBuilder
.newDialog() .newDialog(original.getDisplayName())
.setTitle(original.getDisplayName())
.setView(view) .setView(view)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setOnCancelListener(this::sendResult) .setOnCancelListener(this::sendResult)

@ -75,8 +75,7 @@ public class Linkify {
break; break;
} }
dialogBuilder dialogBuilder
.newDialog() .newDialog(title)
.setTitle(title)
.setItems( .setItems(
asList(action, edit), asList(action, edit),
(dialogInterface, selected) -> { (dialogInterface, selected) -> {

@ -67,8 +67,7 @@ public class RecordAudioDialog extends InjectingDialogFragment
} }
return dialogBuilder return dialogBuilder
.newDialog() .newDialog(R.string.audio_recording_title)
.setTitle(R.string.audio_recording_title)
.setView(view) .setView(view)
.create(); .create();
} }

@ -271,8 +271,8 @@ public class LocationPickerActivity extends InjectingAppCompatActivity
moveToCurrentLocation(true); moveToCurrentLocation(true);
} else { } else {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.location_permission_required_location) .newDialog(R.string.missing_permissions)
.setTitle(R.string.missing_permissions) .setMessage(R.string.location_permission_required_location)
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.show(); .show();
} }

@ -36,8 +36,7 @@ public class NotificationDialog extends InjectingDialogFragment {
handler = (NotificationHandler) getActivity(); handler = (NotificationHandler) getActivity();
return dialogBuilder return dialogBuilder
.newDialog() .newDialog(title)
.setTitle(title)
.setItems( .setItems(
items, items,
(dialog, which) -> { (dialog, which) -> {

@ -80,8 +80,7 @@ public class SnoozeDialog extends InjectingDialogFragment {
items.add(getString(R.string.pick_a_date_and_time)); items.add(getString(R.string.pick_a_date_and_time));
return dialogBuilder return dialogBuilder
.newDialog() .newDialog(R.string.rmd_NoA_snooze)
.setTitle(R.string.rmd_NoA_snooze)
.setItems( .setItems(
items, items,
(dialog, which) -> { (dialog, which) -> {

@ -136,7 +136,7 @@ public class SynchronizationPreferences extends InjectingPreferenceActivity {
String name = account.getAccount(); String name = account.getAccount();
AlertDialog alertDialog = AlertDialog alertDialog =
dialogBuilder dialogBuilder
.newMessageDialog(R.string.logout_warning, name) .newDialog(R.string.logout_warning, name)
.setPositiveButton( .setPositiveButton(
R.string.logout, R.string.logout,
(dialog, which) -> { (dialog, which) -> {
@ -174,8 +174,7 @@ public class SynchronizationPreferences extends InjectingPreferenceActivity {
accountPreferences.setOnPreferenceClickListener( accountPreferences.setOnPreferenceClickListener(
preference -> { preference -> {
dialogBuilder dialogBuilder
.newDialog() .newDialog(account)
.setTitle(account)
.setItems( .setItems(
asList(getString(R.string.reinitialize_account), getString(R.string.logout)), asList(getString(R.string.reinitialize_account), getString(R.string.logout)),
(dialog, which) -> { (dialog, which) -> {

@ -92,7 +92,7 @@ public class ActionModeProvider {
return true; return true;
case R.id.delete: case R.id.delete:
dialogBuilder dialogBuilder
.newMessageDialog(R.string.delete_selected_tasks) .newDialog(R.string.delete_selected_tasks)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, (dialogInterface, i) -> deleteSelectedItems()) android.R.string.ok, (dialogInterface, i) -> deleteSelectedItems())
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -100,7 +100,7 @@ public class ActionModeProvider {
return true; return true;
case R.id.copy_tasks: case R.id.copy_tasks:
dialogBuilder dialogBuilder
.newMessageDialog(R.string.copy_selected_tasks) .newDialog(R.string.copy_selected_tasks)
.setPositiveButton( .setPositiveButton(
android.R.string.ok, ((dialogInterface, i) -> copySelectedItems())) android.R.string.ok, ((dialogInterface, i) -> copySelectedItems()))
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)

@ -205,7 +205,7 @@ public class CalendarControlSet extends TaskEditControlFragment {
clear(); clear();
} else { } else {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.delete_calendar_event_confirmation) .newDialog(R.string.delete_calendar_event_confirmation)
.setPositiveButton( .setPositiveButton(
R.string.delete, R.string.delete,
(dialog, which) -> { (dialog, which) -> {

@ -158,8 +158,7 @@ public class LocationControlSet extends TaskEditControlFragment {
options.add(Pair.create(R.string.choose_new_location, this::chooseLocation)); options.add(Pair.create(R.string.choose_new_location, this::chooseLocation));
options.add(Pair.create(R.string.delete, () -> setLocation(null))); options.add(Pair.create(R.string.delete, () -> setLocation(null)));
dialogBuilder dialogBuilder
.newDialog() .newDialog(location.getDisplayName())
.setTitle(location.getDisplayName())
.setItems( .setItems(
newArrayList(transform(options, o -> getString(o.first))), newArrayList(transform(options, o -> getString(o.first))),
(dialog, which) -> options.get(which).second.run()) (dialog, which) -> options.get(which).second.run())
@ -190,8 +189,8 @@ public class LocationControlSet extends TaskEditControlFragment {
showGeofenceOptions(); showGeofenceOptions();
} else { } else {
dialogBuilder dialogBuilder
.newMessageDialog(R.string.location_permission_required_geofence) .newDialog(R.string.missing_permissions)
.setTitle(R.string.missing_permissions) .setMessage(R.string.location_permission_required_geofence)
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.show(); .show();
} }

Loading…
Cancel
Save