Repository: Automattic/pocket-casts-android
File: modules/features/settings/src/main/java/au/com/shiftyjelly/pocketcasts/settings/HelpFragment.kt (Kotlin)

Code before:
import javax.inject.Inject

@AndroidEntryPoint
class HelpFragment : BaseFragment(), HasBackstack {
    @Inject
    lateinit var settings: Settings

    private var webView: WebView? = null

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?,
    ) = content {
        AppThemeWithBackground(theme.activeTheme) {
            val density = LocalDensity.current
            val imeInsets = WindowInsets.ime
            val keyboardHeight = with(density) { imeInsets.getBottom(density).toDp() }
            
            val basePadding = 16.dp
            val keyboardPadding = if (keyboardHeight > 0.dp) {
                24.dp
            } else {
                0.dp
            }
            val totalPadding = basePadding + keyboardPadding

            HelpPage(
                activity = requireActivity(),
                onShowLogs = {
                    (requireActivity() as FragmentHostListener).addFragment(LogsFragment())
                },
                onShowStatusPage = {
                    (requireActivity() as FragmentHostListener).addFragment(StatusFragment())
                },
                onGoBack = {
                    @Suppress("DEPRECATION")
                    activity?.onBackPressed()
                },
                onWebViewCreated = { webView = it },
                onWebViewDisposed = { webView = null },
                modifier = Modifier
                    .fillMaxSize()
                    .padding(bottom = totalPadding),
            )
        }
    }

    override fun onAttach(context: Context) {
        super.onAttach(context)
        setupKeyboardModeResize()

Review comment (suggestion):
We need to account for previously used `settings.bottomInset`. Otherwise content will be obstructed by the mini player when it is available.

<img width="745" alt="Screenshot 2025-06-11 at 15 29 26" src="https://github.com/user-attachments/assets/96ff99d6-ff65-43ef-bfe1-8af86efa51b8" />


Code after:
import au.com.shiftyjelly.pocketcasts.views.helper.HasBackstack
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class HelpFragment : BaseFragment(), HasBackstack {
    @Inject
    lateinit var settings: Settings

    private var webView: WebView? = null

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?,
    ) = content {
        AppThemeWithBackground(theme.activeTheme) {
            val context = LocalContext.current
            val keyboardHeight = WindowInsets.ime.asPaddingValues().calculateBottomPadding()

            val bottomPadding by settings.bottomInset.collectAsState(0)
            val miniPlayerPadding = bottomPadding.pxToDp(context).dp

            val basePadding = 16.dp
            val keyboardPadding = if (keyboardHeight > 0.dp) {
                24.dp
            } else {
                0.dp
            }
            val totalPadding = basePadding + keyboardPadding + miniPlayerPadding

            HelpPage(
                activity = requireActivity(),
                onShowLogs = {
                    (requireActivity() as FragmentHostListener).addFragment(LogsFragment())
                },
                onShowStatusPage = {
                    (requireActivity() as FragmentHostListener).addFragment(StatusFragment())
                },
                onGoBack = {
                    @Suppress("DEPRECATION")
                    activity?.onBackPressed()
                },
                onWebViewCreated = { webView = it },
                onWebViewDisposed = { webView = null },
                modifier = Modifier
                    .fillMaxSize()
                    .padding(bottom = totalPadding),
            )
        }
    }