Skip to content

Commit

Permalink
CHANGELOG: Improved dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Oct 17, 2024
1 parent e0b8e80 commit 77cd92c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<application
android:name=".OxygenCustomizerAIPlugin"
android:allowBackup="true"
android:theme="@style/Theme.OxygenCustomizer"
android:theme="@style/Theme.OxygenCustomizer.AIPlugin"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package it.dhd.oxygencustomizer.aiplugin.ui.activities;

import android.content.res.Configuration;
import android.os.Bundle;
import android.provider.Settings;
import android.view.MenuItem;

import androidx.appcompat.app.ActionBar;
Expand All @@ -25,6 +27,7 @@ public class SettingsActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setDarkTheme();
DynamicColors.applyToActivityIfAvailable(this);
fragmentManager = getSupportFragmentManager();
mBinding = ActivityMainBinding.inflate(getLayoutInflater());
Expand All @@ -39,6 +42,27 @@ protected void onCreate(Bundle savedInstanceState) {

}

private void setDarkTheme() {
if (isNightMode()) {
int darkStyle = Settings.System.getInt(getContentResolver(), "DarkMode_style_key", 2);
switch (darkStyle) {
case 0:
setTheme(R.style.Theme_OxygenCustomizer_AIPlugin_DarkHard);
break;
case 1:
setTheme(R.style.Theme_OxygenCustomizer_AIPlugin_DarkMedium);
break;
case 2:
setTheme(R.style.Theme_OxygenCustomizer_AIPlugin_DarkSoft);
break;
}
}
}

private boolean isNightMode() {
return (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.OxygenCustomizer" parent="Theme.Material3.Dark.NoActionBar">
<style name="Theme.OxygenCustomizer.AIPlugin" parent="Theme.Material3.Dark.NoActionBar">
<item name="colorPrimary">@color/md_theme_dark_primary</item>
<item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
<item name="colorPrimaryContainer">@color/md_theme_dark_primaryContainer</item>
Expand Down Expand Up @@ -48,21 +48,21 @@
<item name="popupMenuBackground">@drawable/custom_popup_background</item>
</style>

<style name="Theme.OxygenCustomizer.DarkSoft" parent="Theme.OxygenCustomizer">
<style name="Theme.OxygenCustomizer.AIPlugin.DarkSoft" parent="Theme.OxygenCustomizer.AIPlugin">
<!-- Background color. -->
<item name="android:windowBackground">@color/colorBackgroundSoft</item>
<item name="android:colorBackground">@color/colorBackgroundSoft</item>
<item name="preferenceBackgroundColor">#454545</item>
</style>

<style name="Theme.OxygenCustomizer.DarkMedium" parent="Theme.OxygenCustomizer">
<style name="Theme.OxygenCustomizer.AIPlugin.DarkMedium" parent="Theme.OxygenCustomizer.AIPlugin">
<!-- Background color. -->
<item name="android:windowBackground">@color/colorBackgroundMedium</item>
<item name="android:colorBackground">@color/colorBackgroundMedium</item>
<item name="preferenceBackgroundColor">#2F2F2F</item>
</style>

<style name="Theme.OxygenCustomizer.DarkHard" parent="Theme.OxygenCustomizer">
<style name="Theme.OxygenCustomizer.AIPlugin.DarkHard" parent="Theme.OxygenCustomizer.AIPlugin">
<!-- Background color. -->
<item name="android:windowBackground">@color/colorBackgroundHard</item>
<item name="android:colorBackground">@color/colorBackgroundHard</item>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.OxygenCustomizer" parent="Theme.Material3.Light.NoActionBar">
<style name="Theme.OxygenCustomizer.AIPlugin" parent="Theme.Material3.Light.NoActionBar">
<item name="colorPrimary">@color/md_theme_light_primary</item>
<item name="colorOnPrimary">@color/md_theme_light_onPrimary</item>
<item name="colorPrimaryContainer">@color/md_theme_light_primaryContainer</item>
Expand Down

0 comments on commit 77cd92c

Please sign in to comment.