From df909178cecc766c9b71b56c60a7e0c07e8e5667 Mon Sep 17 00:00:00 2001 From: Fox2Code Date: Mon, 11 Jul 2022 23:29:18 +0200 Subject: [PATCH] Make some changes / improvements to monet theming. --- README.md | 3 +-- app/src/main/java/com/fox2code/mmm/MainActivity.java | 3 ++- .../main/java/com/fox2code/mmm/MainApplication.java | 12 +++++++----- app/src/main/res/values-v31/bools.xml | 4 ++++ app/src/main/res/values/bools.xml | 2 +- app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/root_preferences.xml | 2 +- 7 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/values-v31/bools.xml diff --git a/README.md b/README.md index 8d2c31d..92b93d9 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,7 @@ For more information please check the [developer documentation](DEVELOPERS.md) See [`app/src/main/res/values/strings.xml`](https://github.com/Fox2Code/FoxMagiskModuleManager/blob/master/app/src/main/res/values/strings.xml) and [`app/src/main/res/values/arrays.xml`](https://github.com/Fox2Code/FoxMagiskModuleManager/blob/master/app/src/main/res/values/arrays.xml) -If your language is right to left you should make a copy of [`app/src/main/res/values/bools.xml`](https://github.com/Fox2Code/FoxMagiskModuleManager/blob/master/app/src/main/res/values/bools.xml) -and set `lang_support_rtl` to `true`. +If your language is right to left don't forget to set `lang_support_rtl` to `true`. Translators are not expected to have any previous coding experience. diff --git a/app/src/main/java/com/fox2code/mmm/MainActivity.java b/app/src/main/java/com/fox2code/mmm/MainActivity.java index 33f3106..b416c6b 100644 --- a/app/src/main/java/com/fox2code/mmm/MainActivity.java +++ b/app/src/main/java/com/fox2code/mmm/MainActivity.java @@ -222,7 +222,8 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O private void cardIconifyUpdate() { boolean iconified = this.searchView.isIconified(); - int backgroundAttr = iconified ? + int backgroundAttr = iconified ? MainApplication.isMonetEnabled() ? + R.attr.colorSecondaryContainer : // Monet is special... R.attr.colorSecondary : R.attr.colorPrimarySurface; Resources.Theme theme = this.searchCard.getContext().getTheme(); TypedValue value = new TypedValue(); diff --git a/app/src/main/java/com/fox2code/mmm/MainApplication.java b/app/src/main/java/com/fox2code/mmm/MainApplication.java index 17bde0f..6a31b50 100644 --- a/app/src/main/java/com/fox2code/mmm/MainApplication.java +++ b/app/src/main/java/com/fox2code/mmm/MainApplication.java @@ -26,6 +26,7 @@ import com.fox2code.mmm.utils.GMSProviderInstaller; import com.fox2code.mmm.utils.Http; import com.fox2code.rosettax.LanguageSwitcher; import com.google.android.material.color.DynamicColors; +import com.google.android.material.color.DynamicColorsOptions; import com.topjohnwu.superuser.Shell; import java.text.SimpleDateFormat; @@ -122,7 +123,8 @@ public class MainApplication extends CompatApplication { } public static boolean isMonetEnabled() { - return getSharedPreferences().getBoolean("pref_enable_monet", false); + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && + getSharedPreferences().getBoolean("pref_enable_monet", true); } public static boolean isBlurEnabled() { @@ -274,10 +276,10 @@ public class MainApplication extends CompatApplication { public void onCreate() { if (INSTANCE == null) INSTANCE = this; super.onCreate(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { - if (MainApplication.isMonetEnabled()) { - DynamicColors.applyToActivitiesIfAvailable(this); - } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && isMonetEnabled()) { + DynamicColors.applyToActivitiesIfAvailable(this, + new DynamicColorsOptions.Builder().setPrecondition( + (activity, theme) -> isMonetEnabled()).build()); } SharedPreferences sharedPreferences = MainApplication.getSharedPreferences(); // We are only one process so it's ok to do this diff --git a/app/src/main/res/values-v31/bools.xml b/app/src/main/res/values-v31/bools.xml new file mode 100644 index 0000000..af1e653 --- /dev/null +++ b/app/src/main/res/values-v31/bools.xml @@ -0,0 +1,4 @@ + + + true + \ No newline at end of file diff --git a/app/src/main/res/values/bools.xml b/app/src/main/res/values/bools.xml index c9c353d..5acc562 100644 --- a/app/src/main/res/values/bools.xml +++ b/app/src/main/res/values/bools.xml @@ -1,4 +1,4 @@ - false + false \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 611eb91..6525e78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -128,4 +128,6 @@ Backup modules Restore modules This operation require an internet connection + + false diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 11e32ce..38cc9e1 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -63,7 +63,7 @@ app:singleLineTitle="false" />