From f53d992152784d097da6b8949fc9a979ba21a24b Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Thu, 27 Feb 2020 13:46:54 -0600 Subject: [PATCH] Improve dialog consistency --- .../org/tasks/dialogs/AlertDialogBuilder.java | 17 ++-------- .../java/org/tasks/dialogs/DialogBuilder.java | 11 ++---- .../java/org/tasks/dialogs/SortDialog.java | 2 +- .../org/tasks/dialogs/ThemePickerDialog.kt | 1 + .../preferences/fragments/LookAndFeel.kt | 4 +-- .../preferences/fragments/Synchronization.kt | 3 +- .../java/org/tasks/sync/AddAccountDialog.java | 2 +- .../java/org/tasks/themes/ThemeCache.java | 2 +- app/src/main/res/values-night/styles.xml | 2 +- app/src/main/res/values/accents.xml | 34 +++++++++---------- app/src/main/res/values/styles.xml | 12 ++----- app/src/main/res/values/theme.xml | 6 +++- 12 files changed, 39 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java b/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java index c30b8a11d..bea4521d4 100644 --- a/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java +++ b/app/src/main/java/org/tasks/dialogs/AlertDialogBuilder.java @@ -10,18 +10,15 @@ import androidx.appcompat.app.AlertDialog; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import java.util.List; import org.tasks.locale.Locale; -import org.tasks.themes.Theme; public class AlertDialogBuilder { private final AlertDialog.Builder builder; private final Context context; - private final Theme theme; private final Locale locale; - AlertDialogBuilder(Context context, Theme theme, Locale locale) { + AlertDialogBuilder(Context context, Locale locale) { this.context = context; - this.theme = theme; this.locale = locale; builder = new MaterialAlertDialogBuilder(context); } @@ -129,17 +126,7 @@ public class AlertDialogBuilder { } public AlertDialog create() { - AlertDialog dialog = builder.create(); - theme.applyToContext(dialog.getContext()); - return dialog; - } - - public AlertDialog showThemedListView() { - AlertDialog dialog = create(); - theme.applyToContext(dialog.getListView().getContext()); - dialog.show(); - locale.applyDirectionality(dialog); - return dialog; + return builder.create(); } public AlertDialog show() { diff --git a/app/src/main/java/org/tasks/dialogs/DialogBuilder.java b/app/src/main/java/org/tasks/dialogs/DialogBuilder.java index c6ce10163..6e6399964 100644 --- a/app/src/main/java/org/tasks/dialogs/DialogBuilder.java +++ b/app/src/main/java/org/tasks/dialogs/DialogBuilder.java @@ -6,23 +6,20 @@ import android.graphics.drawable.ColorDrawable; import com.todoroo.andlib.utility.AndroidUtilities; import javax.inject.Inject; import org.tasks.locale.Locale; -import org.tasks.themes.Theme; public class DialogBuilder { private final Activity activity; - private final Theme theme; private final Locale locale; @Inject - public DialogBuilder(Activity activity, Theme theme, Locale locale) { + public DialogBuilder(Activity activity, Locale locale) { this.activity = activity; - this.theme = theme; this.locale = locale; } public AlertDialogBuilder newDialog() { - return new AlertDialogBuilder(activity, theme, locale); + return new AlertDialogBuilder(activity, locale); } public AlertDialogBuilder newDialog(int title) { @@ -38,9 +35,7 @@ public class DialogBuilder { } ProgressDialog newProgressDialog() { - ProgressDialog progressDialog = - new ProgressDialog(activity); - theme.applyToContext(progressDialog.getContext()); + ProgressDialog progressDialog = new ProgressDialog(activity); if (AndroidUtilities.preLollipop()) { ColorDrawable background = new ColorDrawable(activity.getResources().getColor(android.R.color.transparent)); diff --git a/app/src/main/java/org/tasks/dialogs/SortDialog.java b/app/src/main/java/org/tasks/dialogs/SortDialog.java index 6066732e2..48d4cd391 100644 --- a/app/src/main/java/org/tasks/dialogs/SortDialog.java +++ b/app/src/main/java/org/tasks/dialogs/SortDialog.java @@ -87,7 +87,7 @@ public class SortDialog extends InjectingDialogFragment { .setPositiveButton(R.string.TLA_menu_sort, (dialog, which) -> setSelection(false)) .setNeutralButton(R.string.reverse, (dialog, which) -> setSelection(true)) .setNegativeButton(android.R.string.cancel, null) - .showThemedListView(); + .show(); enableReverse(); diff --git a/app/src/main/java/org/tasks/dialogs/ThemePickerDialog.kt b/app/src/main/java/org/tasks/dialogs/ThemePickerDialog.kt index f41e21ed1..4e427bb50 100644 --- a/app/src/main/java/org/tasks/dialogs/ThemePickerDialog.kt +++ b/app/src/main/java/org/tasks/dialogs/ThemePickerDialog.kt @@ -71,6 +71,7 @@ class ThemePickerDialog : InjectingDialogFragment() { } dialog = dialogBuilder.newDialog() + .setTitle(R.string.theme) .setSingleChoiceItems(adapter, arguments!!.getInt(EXTRA_SELECTED)) { _, which -> selected = which if (available()) { diff --git a/app/src/main/java/org/tasks/preferences/fragments/LookAndFeel.kt b/app/src/main/java/org/tasks/preferences/fragments/LookAndFeel.kt index 75e75ec30..2684d60b6 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/LookAndFeel.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/LookAndFeel.kt @@ -186,7 +186,7 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange dialog.dismiss() } .setNegativeButton(android.R.string.cancel, null) - .showThemedListView() + .show() false } val mapProvider: Int = getMapProvider() @@ -218,7 +218,7 @@ class LookAndFeel : InjectingPreferenceFragment(), Preference.OnPreferenceChange dialog.dismiss() } .setNegativeButton(android.R.string.cancel, null) - .showThemedListView() + .show() false } val placeProvider: Int = getPlaceProvider() diff --git a/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt b/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt index c56916de0..1ffce6783 100644 --- a/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt +++ b/app/src/main/java/org/tasks/preferences/fragments/Synchronization.kt @@ -156,7 +156,8 @@ class Synchronization : InjectingPreferenceFragment() { logoutConfirmation(googleTaskAccount) } } - .showThemedListView() + .setNegativeButton(android.R.string.cancel, null) + .show() false } category.addPreference(preference) diff --git a/app/src/main/java/org/tasks/sync/AddAccountDialog.java b/app/src/main/java/org/tasks/sync/AddAccountDialog.java index 649e595eb..e7f53131f 100644 --- a/app/src/main/java/org/tasks/sync/AddAccountDialog.java +++ b/app/src/main/java/org/tasks/sync/AddAccountDialog.java @@ -77,6 +77,6 @@ public class AddAccountDialog { new Intent( Intent.ACTION_VIEW, Uri.parse(activity.getString(R.string.help_url_sync))))) .setNegativeButton(android.R.string.cancel, null) - .showThemedListView(); + .show(); } } diff --git a/app/src/main/java/org/tasks/themes/ThemeCache.java b/app/src/main/java/org/tasks/themes/ThemeCache.java index da92c9d3b..f7efcda59 100644 --- a/app/src/main/java/org/tasks/themes/ThemeCache.java +++ b/app/src/main/java/org/tasks/themes/ThemeCache.java @@ -79,7 +79,7 @@ public class ThemeCache { String[] accentNames = resources.getStringArray(R.array.accents); for (int i = 0; i < ThemeAccent.ACCENTS.length; i++) { Resources.Theme theme = new ContextThemeWrapper(context, ThemeAccent.ACCENTS[i]).getTheme(); - accents.add(new ThemeAccent(accentNames[i], i, resolveAttribute(theme, R.attr.colorAccent))); + accents.add(new ThemeAccent(accentNames[i], i, resolveAttribute(theme, R.attr.colorSecondary))); } String[] widgetBackgroundNames = resources.getStringArray(R.array.widget_background); for (int i = 0; i < WidgetTheme.BACKGROUNDS.length; i++) { diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 4721abd9b..325f303c4 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -3,7 +3,7 @@ \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6eda4faef..374a05dd7 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -36,17 +36,11 @@ @style/BlackOverflow - - - - @@ -182,7 +176,7 @@ diff --git a/app/src/main/res/values/theme.xml b/app/src/main/res/values/theme.xml index 69eddd995..6b9dbc381 100644 --- a/app/src/main/res/values/theme.xml +++ b/app/src/main/res/values/theme.xml @@ -5,7 +5,7 @@