Skip to content

Conversation

@314systems
Copy link

Summary

  • Fix navigation drawer highlighting incorrect menu item after language/theme change
  • NavigationView's auto state restoration was conflicting with app's state management

What does this implement/fix?

  • Disables NavigationView's automatic state saving/restoration by adding android:saveEnabled="false"
  • Scope: Single line change in app/src/main/res/layout/main_activity.xml
  • Root cause: NavigationView was restoring its checked state (e.g., SETTINGS) in onRestoreInstanceState, overwriting the correct state set in onCreate from SharedPreferences

Before: Change language in Settings → Activity recreates → Shows AccessPoints screen but drawer highlights Settings
After: Change language in Settings → Activity recreates → Shows AccessPoints screen and drawer correctly highlights AccessPoints

How was this tested?

  • Devices / OS (e.g. Android 13 emulator, Pixel 6): Android 16 emulator
  • Steps to reproduce:
    1. Open app, note current screen (e.g., Access Points)
    2. Open drawer → tap Settings
    3. Change Language to different value
    4. App recreates → verify drawer highlights Access Points (not Settings)

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

Copilot AI review requested due to automatic review settings December 30, 2025 08:12
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 fixes a UI state management bug where the navigation drawer highlights the wrong menu item after the activity is recreated due to language or theme changes. The fix disables NavigationView's automatic state saving/restoration mechanism, allowing the app's manual state management through SharedPreferences to work correctly.

  • Adds android:saveEnabled="false" to NavigationView to prevent automatic state restoration conflicts
  • Resolves incorrect menu highlighting after activity recreation from configuration changes

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

android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:saveEnabled="false"
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The fix correctly disables automatic state restoration for the NavigationView, which prevents conflicts with the app's manual state management in MainActivity.onCreate(). However, there is no automated test coverage for this navigation state restoration behavior after activity recreation. Consider adding an instrumentation test that verifies the navigation drawer highlights the correct menu item after the activity is recreated due to a configuration change like language or theme change.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Dec 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.67%. Comparing base (5a0722f) to head (ce98511).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #580   +/-   ##
=========================================
  Coverage     97.67%   97.67%           
  Complexity      975      975           
=========================================
  Files           121      121           
  Lines          2579     2579           
  Branches        211      211           
=========================================
  Hits           2519     2519           
  Misses           21       21           
  Partials         39       39           
🚀 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