Skip to content

Fix/bottom padding bug#126

Merged
theovilardo merged 7 commits intomasterfrom
fix/bottom-padding-bug
Sep 7, 2025
Merged

Fix/bottom padding bug#126
theovilardo merged 7 commits intomasterfrom
fix/bottom-padding-bug

Conversation

@theovilardo
Copy link
Owner

No description provided.

google-labs-jules bot and others added 7 commits September 3, 2025 03:46
Refactored the main layout to resolve an issue where extra padding would intermittently appear at the bottom of the screen, particularly on certain OEM Android versions after a configuration change.

The root cause was a nested Scaffold and unpredictable automatic window inset handling.

The fix includes:
- Removing the nested Scaffold structure by eliminating the `MainLayout` composable.
- Disabling automatic window inset handling in the primary `Scaffold` in `MainActivity`.
- Manually calculating and passing down the required padding to the `AppNavigation` content, ensuring it is aware of the `UnifiedPlayerSheet` and system navigation bar.
…ed Scaffold

This commit resolves an issue where extra padding would intermittently appear at the bottom of the screen, particularly on certain OEM Android versions after a configuration change.

The root cause was a nested Scaffold within the AppNavigation composable, which caused conflicting and unpredictable window inset calculations.

The fix involves:
- Removing the MainLayout composable and its nested Scaffold.
- Refactoring AppNavigation to accept PaddingValues directly from the parent Scaffold in MainActivity.
- Ensuring the PaddingValues are passed down to the screen-level composables that need to pad their content.

Additionally, the enableEdgeToEdge() call in MainActivity has been moved before super.onCreate() to align with best practices and ensure consistent edge-to-edge behavior.
This commit resolves a persistent and intermittent issue where extra padding would appear at the bottom of the screen on certain OEM Android versions (e.g., OxygenOS) after a configuration change and resuming the app.

The solution includes several layers of fixes:
1.  **onResume Workaround:** The primary fix is to re-assert the edge-to-edge window flag when the app resumes. By calling `WindowCompat.setDecorFitsSystemWindows(window, false)` in `MainActivity.onResume()`, we force the OS to correct its state, fixing the bug where the window would fail to draw behind the navigation bar.
2.  **Nested Scaffold Removal:** A latent bug was fixed by removing a nested `Scaffold` that existed within `AppNavigation` via `MainLayout`. This simplifies the layout hierarchy and prevents conflicting inset calculations.
3.  **Correct Inset Propagation:** The `innerPadding` from the main `Scaffold` is now correctly passed down to the `AppNavigation` composable and its child screens, ensuring content is padded correctly.
4.  **Activity Lifecycle Correction:** The `enableEdgeToEdge()` call in `MainActivity` has been moved before `super.onCreate()` to align with best practices.
This commit resolves a persistent and intermittent issue where extra padding would appear at the bottom of the screen on certain OEM Android versions (e.g., OxygenOS) after a configuration change and resuming the app.

The solution includes several layers of fixes:
1.  **onResume Workaround:** The primary fix is to "jiggle" the window state when the app resumes. By toggling `WindowCompat.setDecorFitsSystemWindows` from true to false in `MainActivity.onResume()`, we force the OS to correct its layout state, fixing the bug where the window would fail to draw behind the navigation bar.
2.  **Nested Scaffold Removal:** A latent bug was fixed by removing a nested `Scaffold` that existed within `AppNavigation` via `MainLayout`. This simplifies the layout hierarchy and prevents conflicting inset calculations.
3.  **Correct Inset Propagation:** The `innerPadding` from the main `Scaffold` is now correctly passed down to the `AppNavigation` composable and its child screens, ensuring content is padded correctly.
4.  **Activity Lifecycle Correction:** The `enableEdgeToEdge()` call in `MainActivity` has been moved before `super.onCreate()` to align with best practices.
This reverts the previous attempts to fix the intermittent padding bug using `onResume` workarounds, as they were found to make the issue worse.

This commit leaves the codebase in the most stable and correct state achieved, which includes:
- Removal of a nested Scaffold that was a likely source of layout bugs.
- Correct propagation of `PaddingValues` from the main `Scaffold` to the navigation content.
- Correct placement of the `enableEdgeToEdge()` call in the Activity lifecycle.

While this version represents the most correct implementation at the application level, the underlying intermittent padding bug may still occur on certain OEM devices due to a suspected OS-level issue that cannot be reliably fixed from the app's code. This commit cleans up the unsuccessful workarounds.
This commit moves the `BottomNavItem` data class from `presentation.navigation` to `MainActivity.kt`.

This change centralizes the definition of this UI-related data structure within the main activity file, which is responsible for the overall application structure and navigation.

The import paths for `BottomNavItem` have been updated in:
- `PlayerInternalNavigationBar.kt`
- `UnifiedPlayerSheet.kt`

The `AppNavigation.kt` file no longer requires this import.
This commit updates how URIs are parsed for the "All Files Access" permission request and refactors the screen height calculation.

-   The `android.net.Uri.parse("package:$packageName")` has been replaced with `"package:$packageName".toUri()` for requesting all files access permission.
-   The screen height calculation now uses `LocalWindowInfo.current.containerSize.height` instead of `LocalConfiguration.current.screenHeightDp.dp.toPx()`.
-   The outer `Scaffold` has been commented out, potentially for simplification or as part of a larger UI refactor.
@theovilardo theovilardo merged commit 4e87400 into master Sep 7, 2025
@theovilardo theovilardo deleted the fix/bottom-padding-bug branch October 16, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant