Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
Expand Down Expand Up @@ -61,7 +62,9 @@ class MainActivity :

val settings = mainContext.settings
settings.initializeDefaultValues()
setTheme(settings.themeStyle().themeNoActionBar)
val themeStyle = settings.themeStyle()
AppCompatDelegate.setDefaultNightMode(themeStyle.nightMode)
Copy link

Copilot AI Jan 1, 2026

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.

Copilot uses AI. Check for mistakes.
setTheme(themeStyle.themeNoActionBar)

mainReload = MainReload(settings)

Expand Down
10 changes: 6 additions & 4 deletions app/src/main/kotlin/com/vrem/wifianalyzer/settings/ThemeStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SYSTEM theme uses Color.GRAY for graph text, which may result in poor contrast in both light and dark modes. When using MODE_NIGHT_FOLLOW_SYSTEM, the actual theme will switch between light and dark based on system settings, but the graph text color remains fixed at gray. This could make graph labels difficult to read.

Consider using a dynamic approach for the SYSTEM theme's graph text color, such as resolving it from theme attributes at runtime, or defaulting to Color.BLACK as a compromise that works reasonably in both modes (though this is still suboptimal).

Suggested change
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),

Copilot uses AI. Check for mistakes.
BLACK(R.style.ThemeBlack, R.style.ThemeBlackNoActionBar, Color.WHITE, AppCompatDelegate.MODE_NIGHT_YES),
}
20 changes: 0 additions & 20 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing Theme.AppCompat and Theme.AppCompat.Light with Theme.AppCompat.DayNight can behave inconsistently on older devices (API 24–26), since these versions don’t support system‑wide dark mode and may resolve SYSTEM to LIGHT. To avoid regressions, we should either drop API 24–26, test on those devices, or avoid this change. It may also be reasonable to consider dropping these older APIs in a future release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On API levels 24–26, MODE_NIGHT_FOLLOW_SYSTEM may effectively behave as MODE_NIGHT_NO, since these Android versions do not support a system-wide dark mode. This behavior has been reviewed and is currently considered an acceptable outcome for this implementation.
Dark theme Light theme System theme (Android 7)


<!-- Black theme -->
<style name="ThemeBlack" parent="Theme.AppCompat">
<item name="android:windowAnimationStyle">@style/WindowAnimationTransition</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class SettingsTest {
// setup
doReturn(ThemeStyle.entries.size)
.whenever(repository)
.stringAsInteger(R.string.theme_key, ThemeStyle.DARK.ordinal)
.stringAsInteger(R.string.theme_key, ThemeStyle.SYSTEM.ordinal)
// execute
val actual = fixture.themeStyle()
// validate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.vrem.wifianalyzer.settings

import android.graphics.Color
import androidx.appcompat.app.AppCompatDelegate
import com.vrem.wifianalyzer.R
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
Expand All @@ -32,16 +33,16 @@ class ThemeStyleTest {

@Test
fun theme() {
assertThat(ThemeStyle.LIGHT.theme).isEqualTo(R.style.ThemeLight)
assertThat(ThemeStyle.DARK.theme).isEqualTo(R.style.ThemeDark)
assertThat(ThemeStyle.LIGHT.theme).isEqualTo(R.style.ThemeSystem)
assertThat(ThemeStyle.DARK.theme).isEqualTo(R.style.ThemeSystem)
assertThat(ThemeStyle.SYSTEM.theme).isEqualTo(R.style.ThemeSystem)
assertThat(ThemeStyle.BLACK.theme).isEqualTo(R.style.ThemeBlack)
}

@Test
fun themeNoActionBar() {
assertThat(ThemeStyle.DARK.themeNoActionBar).isEqualTo(R.style.ThemeDarkNoActionBar)
assertThat(ThemeStyle.LIGHT.themeNoActionBar).isEqualTo(R.style.ThemeLightNoActionBar)
assertThat(ThemeStyle.DARK.themeNoActionBar).isEqualTo(R.style.ThemeSystemNoActionBar)
assertThat(ThemeStyle.LIGHT.themeNoActionBar).isEqualTo(R.style.ThemeSystemNoActionBar)
assertThat(ThemeStyle.SYSTEM.themeNoActionBar).isEqualTo(R.style.ThemeSystemNoActionBar)
assertThat(ThemeStyle.BLACK.themeNoActionBar).isEqualTo(R.style.ThemeBlackNoActionBar)
}
Expand All @@ -54,6 +55,14 @@ class ThemeStyleTest {
assertThat(ThemeStyle.BLACK.colorGraphText).isEqualTo(Color.WHITE)
}

@Test
fun nightMode() {
assertThat(ThemeStyle.DARK.nightMode).isEqualTo(AppCompatDelegate.MODE_NIGHT_YES)
assertThat(ThemeStyle.LIGHT.nightMode).isEqualTo(AppCompatDelegate.MODE_NIGHT_NO)
assertThat(ThemeStyle.SYSTEM.nightMode).isEqualTo(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
assertThat(ThemeStyle.BLACK.nightMode).isEqualTo(AppCompatDelegate.MODE_NIGHT_YES)
}

@Test
fun themeStyleOrdinal() {
assertThat(ThemeStyle.DARK.ordinal).isEqualTo(0)
Expand Down