diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java index 953495a6f..6484502ee 100755 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskEditFragment.java @@ -270,7 +270,7 @@ public final class TaskEditFragment extends InjectingFragment if (hasChanges( taskEditControlSetFragmentManager.getFragmentsInPersistOrder(getChildFragmentManager()))) { dialogBuilder - .newMessageDialog(R.string.discard_confirmation) + .newDialog(R.string.discard_confirmation) .setPositiveButton(R.string.keep_editing, null) .setNegativeButton(R.string.discard, (dialog, which) -> discard()) .show(); @@ -289,7 +289,7 @@ public final class TaskEditFragment extends InjectingFragment private void deleteButtonClick() { dialogBuilder - .newMessageDialog(R.string.DLG_delete_this_task_question) + .newDialog(R.string.DLG_delete_this_task_question) .setPositiveButton( android.R.string.ok, (dialog, which) -> { diff --git a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java index 3162cc14d..96e38dfc2 100644 --- a/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java +++ b/app/src/main/java/com/todoroo/astrid/activity/TaskListFragment.java @@ -401,7 +401,7 @@ public final class TaskListFragment extends InjectingFragment return true; case R.id.menu_clear_completed: dialogBuilder - .newMessageDialog(R.string.clear_completed_tasks_confirmation) + .newDialog(R.string.clear_completed_tasks_confirmation) .setPositiveButton(android.R.string.ok, (dialog, which) -> clearCompleted()) .setNegativeButton(android.R.string.cancel, null) .show(); diff --git a/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java b/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java index 2590fb892..55a5e4b8e 100755 --- a/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java +++ b/app/src/main/java/com/todoroo/astrid/backup/TasksXmlImporter.java @@ -159,8 +159,7 @@ public class TasksXmlImporter { private void showSummary() { Resources r = activity.getResources(); dialogBuilder - .newDialog() - .setTitle(R.string.import_summary_title) + .newDialog(R.string.import_summary_title) .setMessage( activity.getString( R.string.import_summary_message, diff --git a/app/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java b/app/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java index 1cbc35b2f..63dc383fa 100644 --- a/app/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java +++ b/app/src/main/java/com/todoroo/astrid/core/CustomFilterActivity.java @@ -331,7 +331,7 @@ public class CustomFilterActivity extends ThemedInjectingAppCompatActivity finish(); } else { dialogBuilder - .newMessageDialog(R.string.discard_changes) + .newDialog(R.string.discard_changes) .setPositiveButton(R.string.keep_editing, null) .setNegativeButton(R.string.discard, (dialog, which) -> finish()) .show(); diff --git a/app/src/main/java/com/todoroo/astrid/core/CustomFilterAdapter.java b/app/src/main/java/com/todoroo/astrid/core/CustomFilterAdapter.java index afe32b980..9b5aadeb1 100644 --- a/app/src/main/java/com/todoroo/astrid/core/CustomFilterAdapter.java +++ b/app/src/main/java/com/todoroo/astrid/core/CustomFilterAdapter.java @@ -116,7 +116,7 @@ class CustomFilterAdapter extends ArrayAdapter { /** Show options menu for the given criterioninstance */ 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) { MultipleSelectCriterion multiSelectCriterion = (MultipleSelectCriterion) item.criterion; diff --git a/app/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java b/app/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java index 1191e2109..000fc9e31 100644 --- a/app/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java +++ b/app/src/main/java/com/todoroo/astrid/core/OldTaskPreferences.java @@ -81,7 +81,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity { private void purgeDeletedTasks() { dialogBuilder - .newMessageDialog(R.string.EPr_manage_purge_deleted_message) + .newDialog(R.string.EPr_manage_purge_deleted_message) .setPositiveButton( android.R.string.ok, (dialog, which) -> @@ -93,7 +93,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity { private void deleteCompletedEvents() { dialogBuilder - .newMessageDialog(R.string.EPr_manage_delete_completed_gcal_message) + .newDialog(R.string.EPr_manage_delete_completed_gcal_message) .setPositiveButton( android.R.string.ok, (dialog, which) -> @@ -109,7 +109,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity { private void deleteAllCalendarEvents() { dialogBuilder - .newMessageDialog(R.string.EPr_manage_delete_all_gcal_message) + .newDialog(R.string.EPr_manage_delete_all_gcal_message) .setPositiveButton( android.R.string.ok, (dialog, which) -> @@ -133,7 +133,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity { private void resetPreferences() { dialogBuilder - .newMessageDialog(R.string.EPr_reset_preferences_warning) + .newDialog(R.string.EPr_reset_preferences_warning) .setPositiveButton( R.string.EPr_reset_preferences, (dialog, which) -> { @@ -146,7 +146,7 @@ public class OldTaskPreferences extends InjectingPreferenceActivity { private void deleteTaskData() { dialogBuilder - .newMessageDialog(R.string.EPr_delete_task_data_warning) + .newDialog(R.string.EPr_delete_task_data_warning) .setPositiveButton( R.string.EPr_delete_task_data, (dialog, which) -> { diff --git a/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.java b/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.java index 12d870e6c..9a3ddee17 100644 --- a/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.java +++ b/app/src/main/java/com/todoroo/astrid/files/FilesControlSet.java @@ -140,7 +140,7 @@ public class FilesControlSet extends TaskEditControlFragment { clearFile.setOnClickListener( v -> dialogBuilder - .newMessageDialog(R.string.premium_remove_file_confirm) + .newDialog(R.string.premium_remove_file_confirm) .setPositiveButton( android.R.string.ok, (dialog, which) -> { diff --git a/app/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java b/app/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java index 8e851830c..69d337152 100644 --- a/app/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java +++ b/app/src/main/java/com/todoroo/astrid/gcal/CalendarReminderActivity.java @@ -44,7 +44,7 @@ public class CalendarReminderActivity extends ThemedInjectingAppCompatActivity { ignorePresses++; if (ignorePresses == IGNORE_PROMPT_COUNT) { dialogBuilder - .newMessageDialog(R.string.CRA_ignore_body) + .newDialog(R.string.CRA_ignore_body) .setPositiveButton( R.string.CRA_ignore_all, (dialog, which) -> { diff --git a/app/src/main/java/org/tasks/backup/TasksJsonImporter.java b/app/src/main/java/org/tasks/backup/TasksJsonImporter.java index 013fcff40..580dddb9d 100644 --- a/app/src/main/java/org/tasks/backup/TasksJsonImporter.java +++ b/app/src/main/java/org/tasks/backup/TasksJsonImporter.java @@ -267,8 +267,7 @@ public class TasksJsonImporter { private void showSummary() { Resources r = activity.getResources(); dialogBuilder - .newDialog() - .setTitle(R.string.import_summary_title) + .newDialog(R.string.import_summary_title) .setMessage( activity.getString( R.string.import_summary_message, diff --git a/app/src/main/java/org/tasks/billing/NameYourPriceDialog.java b/app/src/main/java/org/tasks/billing/NameYourPriceDialog.java index 9fa94b2d5..deda828ba 100644 --- a/app/src/main/java/org/tasks/billing/NameYourPriceDialog.java +++ b/app/src/main/java/org/tasks/billing/NameYourPriceDialog.java @@ -82,8 +82,7 @@ public class NameYourPriceDialog extends InjectingDialogFragment implements OnPu public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { AlertDialog dialog = dialogBuilder - .newDialog() - .setTitle(R.string.name_your_price) + .newDialog(R.string.name_your_price) .setView(R.layout.dialog_name_your_price) .show(); diff --git a/app/src/main/java/org/tasks/billing/PurchaseDialog.java b/app/src/main/java/org/tasks/billing/PurchaseDialog.java index 6e759ceef..77efc44d6 100644 --- a/app/src/main/java/org/tasks/billing/PurchaseDialog.java +++ b/app/src/main/java/org/tasks/billing/PurchaseDialog.java @@ -42,8 +42,7 @@ public class PurchaseDialog extends InjectingDialogFragment { String[] rows = context.getResources().getStringArray(R.array.pro_description); textView.setText(Joiner.on('\n').join(transform(asList(rows), item -> "\u2022 " + item))); return dialogBuilder - .newDialog() - .setTitle(R.string.pro_support_development) + .newDialog(R.string.pro_support_development) .setView(view) .setPositiveButton( R.string.name_your_price, diff --git a/app/src/main/java/org/tasks/caldav/BaseListSettingsActivity.java b/app/src/main/java/org/tasks/caldav/BaseListSettingsActivity.java index 11ee29052..42695f22b 100644 --- a/app/src/main/java/org/tasks/caldav/BaseListSettingsActivity.java +++ b/app/src/main/java/org/tasks/caldav/BaseListSettingsActivity.java @@ -123,7 +123,7 @@ public abstract class BaseListSettingsActivity extends ThemedInjectingAppCompatA finish(); } else { dialogBuilder - .newMessageDialog(R.string.discard_changes) + .newDialog(R.string.discard_changes) .setPositiveButton(R.string.discard, (dialog, which) -> finish()) .setNegativeButton(android.R.string.cancel, null) .show(); @@ -174,7 +174,7 @@ public abstract class BaseListSettingsActivity extends ThemedInjectingAppCompatA protected void promptDelete() { dialogBuilder - .newMessageDialog(R.string.delete_tag_confirmation, getToolbarTitle()) + .newDialog(R.string.delete_tag_confirmation, getToolbarTitle()) .setPositiveButton( R.string.delete, (dialog, which) -> delete()) diff --git a/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java b/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java index b9c3a7516..ed15b7d5e 100644 --- a/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java +++ b/app/src/main/java/org/tasks/caldav/CaldavAccountSettingsActivity.java @@ -409,7 +409,7 @@ public class CaldavAccountSettingsActivity extends ThemedInjectingAppCompatActiv } dialogBuilder - .newMessageDialog(R.string.logout_warning, caldavAccount.getName()) + .newDialog(R.string.logout_warning, caldavAccount.getName()) .setPositiveButton( R.string.remove, (dialog, which) -> { @@ -431,7 +431,7 @@ public class CaldavAccountSettingsActivity extends ThemedInjectingAppCompatActiv finish(); } else { dialogBuilder - .newMessageDialog(R.string.discard_changes) + .newDialog(R.string.discard_changes) .setPositiveButton(R.string.discard, (dialog, which) -> finish()) .setNegativeButton(android.R.string.cancel, null) .show(); diff --git a/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java b/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java index 94e6aaa43..da4b888cc 100644 --- a/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java +++ b/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java @@ -50,11 +50,16 @@ public class AlertDialogBuilder { return this; } - public AlertDialogBuilder setTitle(int title) { + AlertDialogBuilder setTitle(int title) { builder.setTitle(title); return this; } + AlertDialogBuilder setTitle(int title, Object... formatArgs) { + builder.setTitle(context.getString(title, formatArgs)); + return this; + } + public AlertDialogBuilder setItems( List strings, DialogInterface.OnClickListener onClickListener) { return setItems(strings.toArray(new String[strings.size()]), onClickListener); @@ -115,7 +120,7 @@ public class AlertDialogBuilder { return this; } - public AlertDialogBuilder setTitle(String title) { + AlertDialogBuilder setTitle(String title) { builder.setTitle(title); return this; } diff --git a/app/src/main/java/org/tasks/dialogs/DialogBuilder.java b/app/src/main/java/org/tasks/dialogs/DialogBuilder.java index 40b153afd..472362080 100644 --- a/app/src/main/java/org/tasks/dialogs/DialogBuilder.java +++ b/app/src/main/java/org/tasks/dialogs/DialogBuilder.java @@ -29,11 +29,19 @@ public class DialogBuilder { return new AlertDialogBuilder(activity, theme, locale); } - public AlertDialogBuilder newMessageDialog(int message, Object... formatArgs) { - return newDialog().setMessage(message, formatArgs); + public AlertDialogBuilder newDialog(int title) { + 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 = new ProgressDialog(activity, theme.getThemeBase().getAlertDialogStyle()); theme.applyToContext(progressDialog.getContext()); diff --git a/app/src/main/java/org/tasks/dialogs/GeofenceDialog.java b/app/src/main/java/org/tasks/dialogs/GeofenceDialog.java index 05849fef7..8d586d6dd 100644 --- a/app/src/main/java/org/tasks/dialogs/GeofenceDialog.java +++ b/app/src/main/java/org/tasks/dialogs/GeofenceDialog.java @@ -77,8 +77,7 @@ public class GeofenceDialog extends InjectingDialogFragment { departureView.setChecked(hasLocationPermission && geofence.isDeparture()); updateRadius(geofence.getRadius()); return dialogBuilder - .newDialog() - .setTitle(original.getDisplayName()) + .newDialog(original.getDisplayName()) .setView(view) .setNegativeButton(android.R.string.cancel, null) .setOnCancelListener(this::sendResult) diff --git a/app/src/main/java/org/tasks/dialogs/Linkify.java b/app/src/main/java/org/tasks/dialogs/Linkify.java index cdd1651b9..b5a270104 100644 --- a/app/src/main/java/org/tasks/dialogs/Linkify.java +++ b/app/src/main/java/org/tasks/dialogs/Linkify.java @@ -75,8 +75,7 @@ public class Linkify { break; } dialogBuilder - .newDialog() - .setTitle(title) + .newDialog(title) .setItems( asList(action, edit), (dialogInterface, selected) -> { diff --git a/app/src/main/java/org/tasks/dialogs/RecordAudioDialog.java b/app/src/main/java/org/tasks/dialogs/RecordAudioDialog.java index d10938692..323be5fb5 100644 --- a/app/src/main/java/org/tasks/dialogs/RecordAudioDialog.java +++ b/app/src/main/java/org/tasks/dialogs/RecordAudioDialog.java @@ -67,8 +67,7 @@ public class RecordAudioDialog extends InjectingDialogFragment } return dialogBuilder - .newDialog() - .setTitle(R.string.audio_recording_title) + .newDialog(R.string.audio_recording_title) .setView(view) .create(); } diff --git a/app/src/main/java/org/tasks/location/LocationPickerActivity.java b/app/src/main/java/org/tasks/location/LocationPickerActivity.java index 70eb0d902..ab700c1af 100644 --- a/app/src/main/java/org/tasks/location/LocationPickerActivity.java +++ b/app/src/main/java/org/tasks/location/LocationPickerActivity.java @@ -271,8 +271,8 @@ public class LocationPickerActivity extends InjectingAppCompatActivity moveToCurrentLocation(true); } else { dialogBuilder - .newMessageDialog(R.string.location_permission_required_location) - .setTitle(R.string.missing_permissions) + .newDialog(R.string.missing_permissions) + .setMessage(R.string.location_permission_required_location) .setPositiveButton(android.R.string.ok, null) .show(); } diff --git a/app/src/main/java/org/tasks/reminders/NotificationDialog.java b/app/src/main/java/org/tasks/reminders/NotificationDialog.java index c62c61882..797cade04 100644 --- a/app/src/main/java/org/tasks/reminders/NotificationDialog.java +++ b/app/src/main/java/org/tasks/reminders/NotificationDialog.java @@ -36,8 +36,7 @@ public class NotificationDialog extends InjectingDialogFragment { handler = (NotificationHandler) getActivity(); return dialogBuilder - .newDialog() - .setTitle(title) + .newDialog(title) .setItems( items, (dialog, which) -> { diff --git a/app/src/main/java/org/tasks/reminders/SnoozeDialog.java b/app/src/main/java/org/tasks/reminders/SnoozeDialog.java index 6e9a6e324..9fc0ce5c6 100644 --- a/app/src/main/java/org/tasks/reminders/SnoozeDialog.java +++ b/app/src/main/java/org/tasks/reminders/SnoozeDialog.java @@ -80,8 +80,7 @@ public class SnoozeDialog extends InjectingDialogFragment { items.add(getString(R.string.pick_a_date_and_time)); return dialogBuilder - .newDialog() - .setTitle(R.string.rmd_NoA_snooze) + .newDialog(R.string.rmd_NoA_snooze) .setItems( items, (dialog, which) -> { diff --git a/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java b/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java index ffecc0f9e..7b0b6cb2c 100644 --- a/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java +++ b/app/src/main/java/org/tasks/sync/SynchronizationPreferences.java @@ -136,7 +136,7 @@ public class SynchronizationPreferences extends InjectingPreferenceActivity { String name = account.getAccount(); AlertDialog alertDialog = dialogBuilder - .newMessageDialog(R.string.logout_warning, name) + .newDialog(R.string.logout_warning, name) .setPositiveButton( R.string.logout, (dialog, which) -> { @@ -174,8 +174,7 @@ public class SynchronizationPreferences extends InjectingPreferenceActivity { accountPreferences.setOnPreferenceClickListener( preference -> { dialogBuilder - .newDialog() - .setTitle(account) + .newDialog(account) .setItems( asList(getString(R.string.reinitialize_account), getString(R.string.logout)), (dialog, which) -> { diff --git a/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java b/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java index db859cfa7..4037c14fb 100644 --- a/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java +++ b/app/src/main/java/org/tasks/tasklist/ActionModeProvider.java @@ -92,7 +92,7 @@ public class ActionModeProvider { return true; case R.id.delete: dialogBuilder - .newMessageDialog(R.string.delete_selected_tasks) + .newDialog(R.string.delete_selected_tasks) .setPositiveButton( android.R.string.ok, (dialogInterface, i) -> deleteSelectedItems()) .setNegativeButton(android.R.string.cancel, null) @@ -100,7 +100,7 @@ public class ActionModeProvider { return true; case R.id.copy_tasks: dialogBuilder - .newMessageDialog(R.string.copy_selected_tasks) + .newDialog(R.string.copy_selected_tasks) .setPositiveButton( android.R.string.ok, ((dialogInterface, i) -> copySelectedItems())) .setNegativeButton(android.R.string.cancel, null) diff --git a/app/src/main/java/org/tasks/ui/CalendarControlSet.java b/app/src/main/java/org/tasks/ui/CalendarControlSet.java index 88a8370dd..6dd311075 100644 --- a/app/src/main/java/org/tasks/ui/CalendarControlSet.java +++ b/app/src/main/java/org/tasks/ui/CalendarControlSet.java @@ -205,7 +205,7 @@ public class CalendarControlSet extends TaskEditControlFragment { clear(); } else { dialogBuilder - .newMessageDialog(R.string.delete_calendar_event_confirmation) + .newDialog(R.string.delete_calendar_event_confirmation) .setPositiveButton( R.string.delete, (dialog, which) -> { diff --git a/app/src/main/java/org/tasks/ui/LocationControlSet.java b/app/src/main/java/org/tasks/ui/LocationControlSet.java index 34c8a9f7e..2b797dbe6 100644 --- a/app/src/main/java/org/tasks/ui/LocationControlSet.java +++ b/app/src/main/java/org/tasks/ui/LocationControlSet.java @@ -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.delete, () -> setLocation(null))); dialogBuilder - .newDialog() - .setTitle(location.getDisplayName()) + .newDialog(location.getDisplayName()) .setItems( newArrayList(transform(options, o -> getString(o.first))), (dialog, which) -> options.get(which).second.run()) @@ -190,8 +189,8 @@ public class LocationControlSet extends TaskEditControlFragment { showGeofenceOptions(); } else { dialogBuilder - .newMessageDialog(R.string.location_permission_required_geofence) - .setTitle(R.string.missing_permissions) + .newDialog(R.string.missing_permissions) + .setMessage(R.string.location_permission_required_geofence) .setPositiveButton(android.R.string.ok, null) .show(); }