-
Notifications
You must be signed in to change notification settings - Fork 711
update theme style implementation and use AppCompatDelegate for night… #584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,15 +20,17 @@ package com.vrem.wifianalyzer.settings | |||||
| import android.graphics.Color | ||||||
| import androidx.annotation.ColorInt | ||||||
| import androidx.annotation.StyleRes | ||||||
| import androidx.appcompat.app.AppCompatDelegate | ||||||
| import com.vrem.wifianalyzer.R | ||||||
|
|
||||||
| enum class ThemeStyle( | ||||||
| @param:StyleRes val theme: Int, | ||||||
| @param:StyleRes val themeNoActionBar: Int, | ||||||
| @param:ColorInt val colorGraphText: Int, | ||||||
| val nightMode: Int, | ||||||
| ) { | ||||||
| DARK(R.style.ThemeDark, R.style.ThemeDarkNoActionBar, Color.WHITE), | ||||||
| LIGHT(R.style.ThemeLight, R.style.ThemeLightNoActionBar, Color.BLACK), | ||||||
| SYSTEM(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.GRAY), | ||||||
| BLACK(R.style.ThemeBlack, R.style.ThemeBlackNoActionBar, Color.WHITE), | ||||||
| DARK(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.WHITE, AppCompatDelegate.MODE_NIGHT_YES), | ||||||
| LIGHT(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.BLACK, AppCompatDelegate.MODE_NIGHT_NO), | ||||||
| SYSTEM(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.GRAY, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM), | ||||||
|
||||||
| SYSTEM(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.GRAY, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM), | |
| SYSTEM(R.style.ThemeSystem, R.style.ThemeSystemNoActionBar, Color.BLACK, AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM), |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,26 +18,6 @@ | |
|
|
||
| <resources> | ||
|
|
||
| <!-- Dark theme --> | ||
| <style name="ThemeDark" parent="Theme.AppCompat"> | ||
| <item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item> | ||
| <item name="android:actionMenuTextColor">@color/selected</item> | ||
| </style> | ||
| <style name="ThemeDarkNoActionBar" parent="ThemeDark"> | ||
| <item name="windowActionBar">false</item> | ||
| <item name="windowNoTitle">true</item> | ||
| </style> | ||
|
|
||
| <!-- Light theme --> | ||
| <style name="ThemeLight" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
| <item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item> | ||
| <item name="android:actionMenuTextColor">@color/selected</item> | ||
| </style> | ||
| <style name="ThemeLightNoActionBar" parent="ThemeLight"> | ||
| <item name="windowActionBar">false</item> | ||
| <item name="windowNoTitle">true</item> | ||
| </style> | ||
|
Comment on lines
-21
to
-39
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| <!-- Black theme --> | ||
| <style name="ThemeBlack" parent="Theme.AppCompat"> | ||
| <item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item> | ||
|
|
||



There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AppCompatDelegate.setDefaultNightMode() call is not covered by tests. While the PR description mentions that unit tests were added or updated, there's no test verifying that this method is called with the correct nightMode value from the theme.
Consider adding a test in MainActivityTest that verifies AppCompatDelegate.setDefaultNightMode() is called appropriately during activity creation. This would ensure the night mode is properly set for different theme configurations.