Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit df90917

Browse files
committed
Make some changes / improvements to monet theming.
1 parent bb5cb08 commit df90917

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ For more information please check the [developer documentation](DEVELOPERS.md)
104104
See [`app/src/main/res/values/strings.xml`](https://github.com/Fox2Code/FoxMagiskModuleManager/blob/master/app/src/main/res/values/strings.xml)
105105
and [`app/src/main/res/values/arrays.xml`](https://github.com/Fox2Code/FoxMagiskModuleManager/blob/master/app/src/main/res/values/arrays.xml)
106106

107-
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)
108-
and set `lang_support_rtl` to `true`.
107+
If your language is right to left don't forget to set `lang_support_rtl` to `true`.
109108

110109
Translators are not expected to have any previous coding experience.
111110

app/src/main/java/com/fox2code/mmm/MainActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ public void commonNext() {
222222

223223
private void cardIconifyUpdate() {
224224
boolean iconified = this.searchView.isIconified();
225-
int backgroundAttr = iconified ?
225+
int backgroundAttr = iconified ? MainApplication.isMonetEnabled() ?
226+
R.attr.colorSecondaryContainer : // Monet is special...
226227
R.attr.colorSecondary : R.attr.colorPrimarySurface;
227228
Resources.Theme theme = this.searchCard.getContext().getTheme();
228229
TypedValue value = new TypedValue();

app/src/main/java/com/fox2code/mmm/MainApplication.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.fox2code.mmm.utils.Http;
2727
import com.fox2code.rosettax.LanguageSwitcher;
2828
import com.google.android.material.color.DynamicColors;
29+
import com.google.android.material.color.DynamicColorsOptions;
2930
import com.topjohnwu.superuser.Shell;
3031

3132
import java.text.SimpleDateFormat;
@@ -122,7 +123,8 @@ public static boolean isDohEnabled() {
122123
}
123124

124125
public static boolean isMonetEnabled() {
125-
return getSharedPreferences().getBoolean("pref_enable_monet", false);
126+
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S &&
127+
getSharedPreferences().getBoolean("pref_enable_monet", true);
126128
}
127129

128130
public static boolean isBlurEnabled() {
@@ -274,10 +276,10 @@ public boolean isLightTheme() {
274276
public void onCreate() {
275277
if (INSTANCE == null) INSTANCE = this;
276278
super.onCreate();
277-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
278-
if (MainApplication.isMonetEnabled()) {
279-
DynamicColors.applyToActivitiesIfAvailable(this);
280-
}
279+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && isMonetEnabled()) {
280+
DynamicColors.applyToActivitiesIfAvailable(this,
281+
new DynamicColorsOptions.Builder().setPrecondition(
282+
(activity, theme) -> isMonetEnabled()).build());
281283
}
282284
SharedPreferences sharedPreferences = MainApplication.getSharedPreferences();
283285
// We are only one process so it's ok to do this
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<bool name="monet_enabled_by_default">true</bool>
4+
</resources>

app/src/main/res/values/bools.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<bool name="lang_support_rtl">false</bool>
3+
<bool name="monet_enabled_by_default">false</bool>
44
</resources>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,6 @@
128128
<string name="backup_module_list">Backup modules</string>
129129
<string name="restore_module_list">Restore modules</string>
130130
<string name="require_internet">This operation require an internet connection</string>
131+
<!-- Set to true in translation file if your language is right to left -->
132+
<bool name="lang_support_rtl">false</bool>
131133
</resources>

app/src/main/res/xml/root_preferences.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
app:singleLineTitle="false" />
6464

6565
<SwitchPreferenceCompat
66-
app:defaultValue="false"
66+
app:defaultValue="@bool/monet_enabled_by_default"
6767
app:key="pref_enable_monet"
6868
app:icon="@drawable/ic_baseline_design_services_24"
6969
app:title="@string/enable_monet"

0 commit comments

Comments
 (0)