Skip to content

Conversation

@314systems
Copy link
Contributor

Summary

  • Refactor theme implementation to use AppCompatDelegate for night mode control
  • Simplifies theme management by consolidating DARK/LIGHT/SYSTEM themes to use a single DayNight base theme

What does this implement/fix?

  • ThemeStyle.kt: Added nightMode property to control AppCompatDelegate behavior
  • MainActivity.kt: Uses AppCompatDelegate.setDefaultNightMode() before applying theme
  • Settings.kt: Changed default theme from DARK to SYSTEM
  • styles.xml: Removed redundant ThemeDark and ThemeLight style definitions

How was this tested?

  • Devices / OS: Android 16 emulator
  • Platform / Build variant: debug

test commands:

./gradlew ktlintCheck
./gradlew lintDebug
./gradlew testDebugUnitTest

Checklist (required before marking ready)

  • I added or updated unit tests (see app/src/test/)
  • I followed the project's coding style (ktlint) and formatting
  • I ran lint and addressed or documented any warnings
  • CI checks pass (unit tests, coverage, lint)
  • No sensitive data, keys, or secrets are included

Thank you for contributing!

Copilot AI review requested due to automatic review settings January 1, 2026 23:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the theme implementation to use AppCompatDelegate's night mode control instead of separate theme resource files. The refactoring consolidates DARK, LIGHT, and SYSTEM themes to use a single DayNight base theme (ThemeSystem), with theme switching controlled via AppCompatDelegate.setDefaultNightMode(). The default theme is changed from DARK to SYSTEM to respect user device preferences.

Key Changes:

  • Added nightMode property to ThemeStyle enum to control AppCompatDelegate behavior
  • Removed redundant ThemeDark and ThemeLight style definitions, consolidating to ThemeSystem
  • Changed default theme from DARK to SYSTEM for better UX

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
app/src/main/kotlin/com/vrem/wifianalyzer/settings/ThemeStyle.kt Added nightMode property; DARK, LIGHT, and SYSTEM themes now reference ThemeSystem with different nightMode values
app/src/main/kotlin/com/vrem/wifianalyzer/MainActivity.kt Added AppCompatDelegate.setDefaultNightMode() call before setTheme()
app/src/main/kotlin/com/vrem/wifianalyzer/settings/Settings.kt Changed default theme from DARK to SYSTEM
app/src/main/res/values/styles.xml Removed ThemeDark and ThemeLight style definitions
app/src/test/kotlin/com/vrem/wifianalyzer/settings/ThemeStyleTest.kt Updated test expectations to reflect new theme mappings and added nightMode test
app/src/test/kotlin/com/vrem/wifianalyzer/settings/SettingsTest.kt Updated default theme expectations from DARK to SYSTEM

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.
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.
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (782221a) to head (bf11c8a).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #584   +/-   ##
=========================================
  Coverage     97.82%   97.83%           
- Complexity      976      977    +1     
=========================================
  Files           121      121           
  Lines          2579     2582    +3     
  Branches        211      211           
=========================================
+ Hits           2523     2526    +3     
  Misses           19       19           
  Partials         37       37           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant