Improve dialog consistency

pull/935/head
Alex Baker 5 years ago
parent 367d6a2288
commit f53d992152

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

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

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

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

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

@ -156,7 +156,8 @@ class Synchronization : InjectingPreferenceFragment() {
logoutConfirmation(googleTaskAccount)
}
}
.showThemedListView()
.setNegativeButton(android.R.string.cancel, null)
.show()
false
}
category.addPreference(preference)

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

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

@ -3,7 +3,7 @@
<style name="DayNightDialog" parent="Theme.MaterialComponents.Dialog"/>
<style name="DayNightAlert" parent="Theme.MaterialComponents.Dialog.Alert"/>
<style name="DayNightAlert" parent="ThemeOverlay.MaterialComponents.Dialog.Alert"/>
<style name="popup_overlay" parent="ThemeOverlay.MaterialComponents"/>
</resources>

@ -2,71 +2,71 @@
<resources>
<style name="AmberAccent" parent="BlackTint">
<item name="colorAccent">@color/amber_a400</item>
<item name="colorSecondary">@color/amber_a400</item>
</style>
<style name="BlueAccent" parent="WhiteTint">
<item name="colorAccent">@color/blue_a400</item>
<item name="colorSecondary">@color/blue_a400</item>
</style>
<style name="BlueGreyAccent" parent="WhiteTint">
<item name="colorAccent">@color/blue_grey_400</item>
<item name="colorSecondary">@color/blue_grey_400</item>
</style>
<style name="CyanAccent" parent="BlackTint">
<item name="colorAccent">@color/cyan_a400</item>
<item name="colorSecondary">@color/cyan_a400</item>
</style>
<style name="DeepOrangeAccent" parent="WhiteTint">
<item name="colorAccent">@color/deep_orange_a400</item>
<item name="colorSecondary">@color/deep_orange_a400</item>
</style>
<style name="DeepPurpleAccent" parent="WhiteTint">
<item name="colorAccent">@color/deep_purple_a400</item>
<item name="colorSecondary">@color/deep_purple_a400</item>
</style>
<style name="GreenAccent" parent="BlackTint">
<item name="colorAccent">@color/green_a400</item>
<item name="colorSecondary">@color/green_a400</item>
</style>
<style name="IndigoAccent" parent="WhiteTint">
<item name="colorAccent">@color/indigo_a400</item>
<item name="colorSecondary">@color/indigo_a400</item>
</style>
<style name="LightBlueAccent" parent="BlackTint">
<item name="colorAccent">@color/light_blue_a400</item>
<item name="colorSecondary">@color/light_blue_a400</item>
</style>
<style name="LightGreenAccent" parent="BlackTint">
<item name="colorAccent">@color/light_green_a400</item>
<item name="colorSecondary">@color/light_green_a400</item>
</style>
<style name="LimeAccent" parent="BlackTint">
<item name="colorAccent">@color/lime_a400</item>
<item name="colorSecondary">@color/lime_a400</item>
</style>
<style name="OrangeAccent" parent="BlackTint">
<item name="colorAccent">@color/orange_a400</item>
<item name="colorSecondary">@color/orange_a400</item>
</style>
<style name="PinkAccent" parent="WhiteTint">
<item name="colorAccent">@color/pink_a400</item>
<item name="colorSecondary">@color/pink_a400</item>
</style>
<style name="PurpleAccent" parent="WhiteTint">
<item name="colorAccent">@color/purple_a400</item>
<item name="colorSecondary">@color/purple_a400</item>
</style>
<style name="RedAccent" parent="WhiteTint">
<item name="colorAccent">@color/red_a400</item>
<item name="colorSecondary">@color/red_a400</item>
</style>
<style name="TealAccent" parent="BlackTint">
<item name="colorAccent">@color/teal_a400</item>
<item name="colorSecondary">@color/teal_a400</item>
</style>
<style name="YellowAccent" parent="BlackTint">
<item name="colorAccent">@color/yellow_a400</item>
<item name="colorSecondary">@color/yellow_a400</item>
</style>
</resources>

@ -36,17 +36,11 @@
<item name="android:actionOverflowButtonStyle">@style/BlackOverflow</item>
</style>
<style name="ThemeBase">
<item name="buttonBarPositiveButtonStyle">@style/AlertButtonStyle</item>
<item name="buttonBarNegativeButtonStyle">@style/AlertButtonStyle</item>
<item name="buttonBarNeutralButtonStyle">@style/AlertButtonStyle</item>
</style>
<style name="WhiteTint" parent="ThemeBase">
<style name="WhiteTint">
<item name="colorOnSecondary">@color/white_100</item>
</style>
<style name="BlackTint" parent="ThemeBase">
<style name="BlackTint">
<item name="colorOnSecondary">@color/black_87</item>
</style>
@ -182,7 +176,7 @@
</style>
<style name="AlertButtonStyle" parent="Widget.MaterialComponents.Button.TextButton.Dialog.Flush">
<item name="android:textColor">?attr/colorAccent</item>
<item name="android:textColor">?attr/colorSecondary</item>
</style>
</resources>

@ -5,7 +5,7 @@
<style name="DayNightDialog" parent="Theme.MaterialComponents.Light.Dialog" />
<style name="DayNightAlert" parent="Theme.MaterialComponents.Light.Dialog.Alert" />
<style name="DayNightAlert" parent="ThemeOverlay.MaterialComponents.Dialog.Alert" />
<style name="TasksBase" parent="DayNight">
<item name="android:windowBackground">@color/window_background</item>
@ -14,6 +14,7 @@
<item name="android:spinnerItemStyle">@style/SpinnerNoPadding</item>
<item name="dialogTheme">@style/TasksDialog</item>
<item name="android:dialogTheme">@style/TasksDialog</item>
<item name="alertDialogTheme">@style/TasksDialogAlert</item>
<item name="materialAlertDialogTheme">@style/TasksDialogAlert</item>
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:textColorSecondary">@color/text_secondary</item>
@ -31,6 +32,9 @@
<style name="TasksDialogAlert" parent="DayNightAlert">
<item name="android:textColorPrimary">@color/text_primary</item>
<item name="android:background">@color/dialog_background</item>
<item name="buttonBarPositiveButtonStyle">@style/AlertButtonStyle</item>
<item name="buttonBarNegativeButtonStyle">@style/AlertButtonStyle</item>
<item name="buttonBarNeutralButtonStyle">@style/AlertButtonStyle</item>
</style>
<style name="TasksDialog" parent="DayNightDialog"/>

Loading…
Cancel
Save