diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java index 64030905..0251bae2 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java @@ -19,6 +19,7 @@ */ package com.github.dfa.diaspora_android.ui.theme; +import android.content.DialogInterface; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.PorterDuff; @@ -26,9 +27,11 @@ import android.os.Build; import android.support.design.widget.TabLayout; import android.support.v4.content.ContextCompat; import android.support.v4.widget.CompoundButtonCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.Toolbar; import android.view.View; +import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ProgressBar; @@ -153,4 +156,15 @@ public class ThemeHelper { public static int getNeutralGreyColor() { return ContextCompat.getColor(getInstance().appSettings.getApplicationContext(), R.color.md_grey_800); } + + public static void updateAlertDialogColor(AlertDialog alertDialog) { + if(alertDialog != null) { + for(int i : new int[]{DialogInterface.BUTTON_POSITIVE, DialogInterface.BUTTON_NEGATIVE, DialogInterface.BUTTON_NEUTRAL}) { + Button b = alertDialog.getButton(i); + if(b != null) { + b.setTextColor(getAccentColor()); + } + } + } + } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemedAlertDialogBuilder.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemedAlertDialogBuilder.java new file mode 100644 index 00000000..be6fa57c --- /dev/null +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemedAlertDialogBuilder.java @@ -0,0 +1,40 @@ +package com.github.dfa.diaspora_android.ui.theme; + +import android.content.Context; +import android.support.annotation.NonNull; +import android.support.annotation.StyleRes; +import android.support.v7.app.AlertDialog; + +import com.github.dfa.diaspora_android.util.AppSettings; + +/** + * AlertDialog Builder that colors its buttons + * Created by vanitas on 06.11.16. + */ + +public class ThemedAlertDialogBuilder extends AlertDialog.Builder { + protected AppSettings appSettings; + + public ThemedAlertDialogBuilder(@NonNull Context context, AppSettings appSettings) { + super(context); + this.appSettings = appSettings; + } + + public ThemedAlertDialogBuilder(@NonNull Context context, @StyleRes int themeResId, AppSettings appSettings) { + super(context, themeResId); + this.appSettings = appSettings; + } + + @Override + public AlertDialog create() { + AlertDialog dialog = super.create(); + applyColors(dialog); + return dialog; + } + + private void applyColors(AlertDialog alertDialog) { + ThemeHelper.getInstance(appSettings); + ThemeHelper.updateAlertDialogColor(alertDialog); + } + +}