Add option to make dark theme a black theme

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 3 years ago
parent 39cfa8c52e
commit 29e3d7e58e

@ -295,9 +295,20 @@ public class MainApplication extends FoxApplication
R.style.Theme_MagiskModuleManager_Light;
break;
}
// Handle force black theme
if (theme.equals("dark") && isForceBlackThemeEnabled()) {
// just black background
themeResId = monet ?
R.style.Theme_MagiskModuleManager_Monet_Black :
R.style.Theme_MagiskModuleManager_Black;
}
this.setManagerThemeResId(themeResId);
}
private boolean isForceBlackThemeEnabled() {
return getSharedPreferences().getBoolean("pref_force_black_theme", false);
}
@StyleRes
public int getManagerThemeResId() {
return managerThemeResId;

@ -137,6 +137,20 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}, 1);
return true;
});
// Force black theme - depends on themePreference being system or dark
SwitchPreferenceCompat forceBlackPreference = findPreference("pref_force_black_theme");
// Set invisible if theme is not dark or system
forceBlackPreference.setVisible(themePreference.getValue().equals("dark") ||
themePreference.getValue().equals("system"));
forceBlackPreference.setOnPreferenceChangeListener((preference, newValue) -> {
devModeStep = 0;
UiThreadHandler.handler.postDelayed(() -> {
MainApplication.getINSTANCE().updateTheme();
FoxActivity.getFoxActivity(this).setThemeRecreate(
MainApplication.getINSTANCE().getManagerThemeResId());
}, 1);
return true;
});
// Crash reporting
TwoStatePreference crashReportingPreference = findPreference("pref_crash_reporting");
if (!SentryMain.IS_SENTRY_INSTALLED) crashReportingPreference.setVisible(false);

@ -22,6 +22,16 @@
<item name="chipStyle">@style/Widget.Material3.Chip.Choice.Dark</item>
</style>
<!-- Black monet theme, which is just dark monet theme with black background -->
<style name="Theme.MagiskModuleManager.Monet.Black" parent="Theme.MagiskModuleManager.Monet.Dark">
<item name="colorBackgroundFloating">@color/black</item>
<item name="android:windowBackground">@color/black</item>
<item name="boxBackgroundColor">@color/black</item>
<item name="cardBackgroundColor">@color/black</item>
<item name="backgroundColor">@color/black</item>
<item name="colorSurface">@color/black</item>
</style>
<style name="Widget.Material3.Chip.Choice.Dark" parent="Widget.Material3.Chip.Assist">
<item name="chipBackgroundColor">@color/system_accent2_700</item>
<item name="chipStrokeWidth">0dp</item>

@ -188,4 +188,7 @@
<string name="permission_notification_grant">Grant permission</string>
<string name="background_update_check_permission_required">Please enable notifications to enable this option.</string>
<string name="dont_ask_again">Don\'t ask again</string>
<string name="force_black_theme_desc">Forces AMOLED black backgrounds when using dark theme.
Please be aware this may have contrast problems with some color themes.</string>
<string name="force_black_theme_pref">Force black theme</string>
</resources>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme_MagiskModuleManager_ForceBlack">#000000</style>
</resources>

@ -83,6 +83,16 @@
<item name="chipStyle">@style/Widget.Material.Chip.Choice.Dark</item>
</style>
<!-- Black theme, which is just a dark theme with a black background -->
<style name="Theme.MagiskModuleManager.Black" parent="Theme.MagiskModuleManager.Dark">
<item name="colorBackgroundFloating">@color/black</item>
<item name="android:windowBackground">@color/black</item>
<item name="boxBackgroundColor">@color/black</item>
<item name="cardBackgroundColor">@color/black</item>
<item name="backgroundColor">@color/black</item>
<item name="colorSurface">@color/black</item>
</style>
<style name="Widget.Material.Chip.Choice.Dark" parent="Widget.MaterialComponents.Chip.Action">
<item name="chipBackgroundColor">@color/dark_chipBackgroundColor</item>
<item name="chipStrokeWidth">0dp</item>

@ -56,6 +56,15 @@
app:singleLineTitle="false"
app:title="@string/theme_pref" />
<!-- Force black theme -->
<SwitchPreferenceCompat
app:defaultValue="false"
app:icon="@drawable/ic_baseline_palette_24"
app:key="pref_force_black_theme"
app:singleLineTitle="false"
app:summary="@string/force_black_theme_desc"
app:title="@string/force_black_theme_pref" />
<Preference
app:icon="@drawable/ic_baseline_language_24"
app:key="pref_language_selector"

Loading…
Cancel
Save