Skip to content

Conversation

@tamaskozmer
Copy link
Contributor

@tamaskozmer tamaskozmer commented Jan 5, 2026

Summary

Fixed dark/light mode theme state preservation during screen rotation for HTML content views. When users switched the theme in WebView content and rotated the device, the theme would reset to default. This is now fixed for most HTML content fragments.

Changes

  • Updated CanvasWebViewWrapper to save and restore themeSwitched state during configuration changes
  • Added proper state restoration in onRestoreInstanceState() to reload content with correct theme

Limitations

The following scenarios remain unfixed due to ViewPager architectural constraints:

  • Syllabus fragments (Teacher/Student): ViewPager dynamically creates new fragments on rotation, bypassing normal state restoration
  • Module pages: PageDetailsFragment inside ModuleProgressionFragment's ViewPager has the same limitation

These cases would require significant architectural changes (retaining fragment instances or global theme state management) which are beyond the scope of this fix.

Test Plan

Fixed Scenarios ✓

Test Case 1: Global Announcement (Teacher Dashboard)

  1. Open Teacher app
  2. From Dashboard, tap on a Global Announcement
  3. Tap the theme switch button to change from dark to light mode
  4. Rotate the device
  5. Expected: Theme remains in light mode ✓

Test Case 2: Terms of Use (Parent App)

  1. Open Parent app
  2. Navigate to Settings → Legal → Terms of Use
  3. Switch theme to light mode
  4. Rotate device
  5. Expected: Theme remains in light mode ✓

Known Limitations (Unchanged) ⚠️

Scenario 1: Syllabus

  1. Open Teacher/Student app
  2. Navigate to any course → Syllabus
  3. Switch theme to light mode
  4. Rotate device
  5. Expected: Theme resets to dark mode (unchanged behavior)

Scenario 2: Module Pages

  1. Open Teacher/Student app
  2. Navigate to any course → Modules → Select a module item with a page
  3. Switch theme to light mode
  4. Rotate device
  5. Expected: Theme resets to dark mode (unchanged behavior)

refs: MBL-19610
affects: Teacher, Parent
release note: Fixed dark/light mode theme preservation during screen rotation for HTML content pages

  • Tested in dark and light mode
  • Tested in landscape and portrait orientations
  • Tested on tablet

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Review Summary

This PR adds a call to handleConfigurationChange(reloadContent = true) in the onRestoreInstanceState method to reload content with the restored theme after state restoration.

Potential Issues Found

  • WebView content reload side effects (line 198): Reloading WebView content during state restoration may cause lost scroll position, duplicate loads, and performance impact. Consider if reloadContent = false would suffice or if scroll position preservation is needed.

Positive Aspects

Preserves theme state: The change ensures that the themeSwitched state is properly applied when the view is restored
Clean implementation: The code reuses the existing handleConfigurationChange method rather than duplicating logic
Proper state restoration: Both themeSwitched and html are correctly restored from the saved state

Questions

Could you provide context on what specific issue this fixes? Understanding the root cause would help evaluate if this is the most appropriate solution or if there are alternatives that avoid the WebView reload side effects.

Code Quality

The code follows Kotlin conventions and integrates well with the existing codebase. The change is minimal and focused, which is good for maintainability.

@tamaskozmer tamaskozmer changed the title [MBL-19610][Teacher] Fix dark/light mode theme state on rotation for HTML content [MBL-19610][Teacher][Parent] Fix dark/light mode theme state on rotation for HTML content Jan 5, 2026
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

📊 Code Coverage Report

✅ Student

  • PR Coverage: 43.55%
  • Master Coverage: 43.55%
  • Delta: +0.00%

✅ Teacher

  • PR Coverage: 25.61%
  • Master Coverage: 25.61%
  • Delta: +0.00%

✅ Pandautils

  • PR Coverage: 22.92%
  • Master Coverage: 22.92%
  • Delta: +0.00%

📈 Overall Average

  • PR Coverage: 30.69%
  • Master Coverage: 30.69%
  • Delta: +0.00%

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

🧪 Unit Test Results

✅ 📱 Student App

  • Tests: 1241 total, 0 failed, 0 skipped
  • Duration: 0.000s
  • Success Rate: 100%

✅ 📱 Teacher App

  • Tests: 369 total, 0 failed, 0 skipped
  • Duration: 30.489s
  • Success Rate: 100%

✅ 🌅 Horizon

  • Tests: 449 total, 0 failed, 0 skipped
  • Duration: 34.310s
  • Success Rate: 100%

✅ 📦 Submodules

  • Tests: 2515 total, 0 failed, 0 skipped
  • Duration: 57.471s
  • Success Rate: 100%

📊 Summary

  • Total Tests: 4574
  • Failed: 0
  • Skipped: 0
  • Status: ✅ All tests passed!

Last updated: Mon, 05 Jan 2026 15:57:33 GMT

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Student Install Page

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Teacher Install Page

Copy link
Contributor

@adamNagy56 adamNagy56 left a comment

Choose a reason for hiding this comment

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

QA +1

Copy link
Contributor

@kdeakinstructure kdeakinstructure left a comment

Choose a reason for hiding this comment

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

QA 👍

@tamaskozmer tamaskozmer merged commit e20ef77 into master Jan 6, 2026
31 checks passed
@tamaskozmer tamaskozmer deleted the MBL-19610-dark-light-mode-rotation-issues branch January 6, 2026 13:40
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.

5 participants