Skip to content

Fix/4629 drawer rotation#4676

Open
thirumani-vihaan wants to merge 2 commits into
TeamAmaze:release/4.0from
thirumani-vihaan:fix/4629-drawer-rotation
Open

Fix/4629 drawer rotation#4676
thirumani-vihaan wants to merge 2 commits into
TeamAmaze:release/4.0from
thirumani-vihaan:fix/4629-drawer-rotation

Conversation

@thirumani-vihaan

@thirumani-vihaan thirumani-vihaan commented Jul 14, 2026

Copy link
Copy Markdown

Description

When the device is rotated, the FragmentStateAdapter aggressively recreates TabFragment, which subsequently calls updatePaths(). In non-FILE modes (like OpenMode.CUSTOM for Images or OpenMode.RECENT for Recent Files), this inadvertently overwrote the database with the Home directory. This PR explicitly overrides onSaveInstanceState in MainFragment to preserve the currentPath and openMode, ensuring the state is correctly restored when the ViewModel is re-initialized post-rotation.

Issue tracker

Fixes #4629

Automatic tests

  • Added unit tests for specific individual functions
  • Added headless tests for new app functionality
  • Added emulator tests for new UI elements

Manual tests

  • Done

  • Device: Pixel Emulator

  • OS: Android 14 (API 34)

Build tasks success

Successfully running following tasks on local:

  • ./gradlew assembledebug
  • ./gradlew spotlessCheck

Generative code

  • This PR used generative code tools (GenAI, LLMs, etc.)

  • Model: Gemini 3.1

  • Version: 3.1

  • Provider: Google DeepMind

Fixes: TeamAmaze#4629

The issue occurs when a user navigates to a Drawer Category (like "Images") and rotates the device. After rotation, the view incorrectly resets to the default Home directory.

This happens because the MainFragmentViewModel's currentPath is either lost or re-initialized from the original fragment arguments (which contain the Home path) upon recreation. To fix this, I implemented state-saving logic in MainFragment using onSaveInstanceState to explicitly preserve the currentPath and openMode, and restore them in onCreate().
@thirumani-vihaan thirumani-vihaan changed the base branch from master to release/4.0 July 14, 2026 15:25
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.

Drawer category views reset to Home directory after rotation

1 participant