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(
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) -> {

@ -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();

@ -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,

@ -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();

@ -116,7 +116,7 @@ class CustomFilterAdapter extends ArrayAdapter<CriterionInstance> {
/** 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;

@ -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) -> {

@ -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) -> {

@ -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) -> {

@ -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,

@ -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();

@ -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,

@ -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())

@ -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();

@ -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<String> 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;
}

@ -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());

@ -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)

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

@ -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();
}

@ -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();
}

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

@ -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) -> {

@ -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) -> {

@ -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)

@ -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) -> {

@ -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();
}

Loading…
Cancel
Save