diff options
author | Thialfihar <thi@thialfihar.org> | 2015-07-21 22:37:52 +0200 |
---|---|---|
committer | Thialfihar <thi@thialfihar.org> | 2015-07-21 22:47:55 +0200 |
commit | a4470abc10452cd7a2867bc2379e94a3558baa47 (patch) | |
tree | 3d6f90260d5af75d7929777905ee64d19c7e6d88 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util | |
parent | 313188c69529bb426c6b09ce631812717d8be2d3 (diff) | |
download | open-keychain-a4470abc10452cd7a2867bc2379e94a3558baa47.tar.gz open-keychain-a4470abc10452cd7a2867bc2379e94a3558baa47.tar.bz2 open-keychain-a4470abc10452cd7a2867bc2379e94a3558baa47.zip |
Refactor theme selection of dialogs
This makes sure the dark theme also uses dark dialogs.
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util')
2 files changed, 15 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/InstallDialogFragmentHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/InstallDialogFragmentHelper.java index 5ddb013db..b2213ed10 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/InstallDialogFragmentHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/InstallDialogFragmentHelper.java @@ -31,6 +31,7 @@ import android.view.ContextThemeWrapper; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.ui.dialog.CustomAlertDialogBuilder; +import org.sufficientlysecure.keychain.ui.util.ThemeChanger; import org.sufficientlysecure.keychain.util.Log; public class InstallDialogFragmentHelper { @@ -65,11 +66,7 @@ public class InstallDialogFragmentHelper { final String installPath = args.getString(ARG_INSTALL_PATH); final boolean useMiddleButton = args.getBoolean(ARG_USE_MIDDLE_BUTTON); - // if the dialog is displayed from the application class, design is missing. - // hack to get holo design (which is not automatically applied due to activity's - // Theme.NoDisplay) - ContextThemeWrapper theme = new ContextThemeWrapper(activity, - R.style.Theme_AppCompat_Light_Dialog); + ContextThemeWrapper theme = ThemeChanger.getDialogThemeWrapper(activity); CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(theme); builder.setTitle(title).setMessage(message); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/ThemeChanger.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/ThemeChanger.java index 4878271a2..f53e43528 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/ThemeChanger.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/ThemeChanger.java @@ -29,6 +29,19 @@ public class ThemeChanger { private Preferences mPreferences; private String mCurrentTheme = null; + static public ContextThemeWrapper getDialogThemeWrapper(Context context) { + Preferences preferences = Preferences.getPreferences(context); + + // if the dialog is displayed from the application class, design is missing. + // hack to get holo design (which is not automatically applied due to activity's + // Theme.NoDisplay) + if (Constants.Pref.Theme.DARK.equals(preferences.getTheme())) { + return new ContextThemeWrapper(context, R.style.Theme_AppCompat_Dialog); + } else { + return new ContextThemeWrapper(context, R.style.Theme_AppCompat_Light_Dialog); + } + } + public ThemeChanger(Context context) { mContext = context; mPreferences = Preferences.getPreferences(mContext); |