Fix Monet Setting and fix search icon with monet enabled.

pull/177/head
Fox2Code 2 years ago
parent df909178ce
commit c0fa98eac5

@ -235,17 +235,24 @@ public class MainApplication extends CompatApplication {
public void updateTheme() {
@StyleRes int themeResId;
String theme;
boolean monet = isMonetEnabled();
switch (theme = getSharedPreferences().getString("pref_theme", "system")) {
default:
Log.w("MainApplication", "Unknown theme id: " + theme);
case "system":
themeResId = R.style.Theme_MagiskModuleManager;
themeResId = monet ?
R.style.Theme_MagiskModuleManager_Monet :
R.style.Theme_MagiskModuleManager;
break;
case "dark":
themeResId = R.style.Theme_MagiskModuleManager_Dark;
themeResId = monet ?
R.style.Theme_MagiskModuleManager_Monet_Dark :
R.style.Theme_MagiskModuleManager_Dark;
break;
case "light":
themeResId = R.style.Theme_MagiskModuleManager_Light;
themeResId = monet ?
R.style.Theme_MagiskModuleManager_Monet_Light :
R.style.Theme_MagiskModuleManager_Light;
break;
}
this.setManagerThemeResId(themeResId);
@ -276,11 +283,11 @@ public class MainApplication extends CompatApplication {
public void onCreate() {
if (INSTANCE == null) INSTANCE = this;
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && isMonetEnabled()) {
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
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
SharedPreferences bootPrefs = MainApplication.bootSharedPreferences =

@ -108,6 +108,14 @@ public class SettingsActivity extends CompatActivity implements LanguageActivity
disableMonet.setSummary(R.string.require_android_12);
disableMonet.setEnabled(false);
}
disableMonet.setOnPreferenceClickListener(preference -> {
UiThreadHandler.handler.postDelayed(() -> {
MainApplication.getINSTANCE().updateTheme();
((CompatActivity) this.requireActivity()).setThemeRecreate(
MainApplication.getINSTANCE().getManagerThemeResId());
}, 1);
return true;
});
findPreference("pref_dns_over_https").setOnPreferenceChangeListener((p, v) -> {
Http.setDoh((Boolean) v);

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MagiskModuleManager.Monet" parent="Theme.MagiskModuleManager.Monet.Dark" />
</resources>

@ -1,11 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="Theme.MagiskModuleManager.Light" parent="Theme.Material3.DynamicColors.Light">
<style name="Theme.MagiskModuleManager.Monet.Light" parent="Theme.Material3.DynamicColors.Light">
<item name="android:statusBarColor">@color/status_bar_color</item>
<item name="colorBackgroundFloating">@color/system_accent2_200</item>
<item name="android:windowBackground">@color/system_accent2_100</item>
<item name="chipStyle">@style/Widget.Material3.Chip.Choice.Light</item>
</style>
<style name="Widget.Material3.Chip.Choice.Light" parent="Widget.Material3.Chip.Assist">
@ -13,14 +12,14 @@
<item name="chipStrokeWidth">0dp</item>
<item name="chipIconTint">?attr/colorControlNormal</item>
</style>
<style name="Theme.MagiskModuleManager.Transparent.Light" parent="Theme.MagiskModuleManager.Light" />
<style name="Theme.MagiskModuleManager.Dark" parent="Theme.Material3.DynamicColors.Dark">
<style name="Theme.MagiskModuleManager.Monet.Dark" parent="Theme.Material3.DynamicColors.Dark">
<item name="android:statusBarColor">@color/status_bar_color</item>
<item name="colorBackgroundFloating">@color/system_accent2_800</item>
<item name="android:windowBackground">@color/system_accent2_900</item>
<item name="chipStyle">@style/Widget.Material3.Chip.Choice.Dark</item>
</style>
<style name="Widget.Material3.Chip.Choice.Dark" parent="Widget.Material3.Chip.Assist">
@ -31,7 +30,6 @@
<!-- Base application theme. -->
<style name="Theme.MagiskModuleManager.Transparent.Dark" parent="Theme.MagiskModuleManager.Dark" />
<style name="Theme.MagiskModuleManager" parent="Theme.MagiskModuleManager.Light" />
<style name="Theme.MagiskModuleManager.Monet" parent="Theme.MagiskModuleManager.Monet.Light" />
</resources>
Loading…
Cancel
Save