Skip to content

Remove unused code#6163

Open
SeniorZhai wants to merge 4 commits intomasterfrom
opt/compose_bottom
Open

Remove unused code#6163
SeniorZhai wants to merge 4 commits intomasterfrom
opt/compose_bottom

Conversation

@SeniorZhai
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

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 aims to remove unused/restricted code from the Compose-based bottom sheet dialog fragment implementation.

Changes:

  • Replaced com.google.android.material.internal.ViewUtils.doOnApplyWindowInsets usage with ViewCompat.setOnApplyWindowInsetsListener.
  • Removed onViewCreated logic that previously configured BottomSheetBehavior and safe-area padding.
Comments suppressed due to low confidence (2)

app/src/main/java/one/mixin/android/ui/common/MixinComposeBottomSheetDialogFragment.kt:96

  • Removing onViewCreated also removed all BottomSheetBehavior initialization (setting peekHeight via getBottomSheetHeight, disabling dragging, adding the callback, and applying safe-area bottom padding). After this change, getBottomSheetHeight() is no longer called anywhere and onBottomSheetStateChanged/onBottomSheetSlide hooks will never fire; either restore the behavior setup somewhere appropriate (e.g., onStart/setupDialog) or remove these now-dead APIs to avoid silent UI regressions.
    override fun onStart() {
        super.onStart()
        dialog?.window?.let { window ->
            SystemUIManager.lightUI(

app/src/main/java/one/mixin/android/ui/common/MixinComposeBottomSheetDialogFragment.kt:16

  • Some imports here appear unused after removing onViewCreated (e.g. CoordinatorLayout, WindowInsetsCompat, and doOnPreDraw). If the project enforces no-unused-imports via lint/formatting, this will fail CI; please remove any unused imports.
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type.systemBars
import androidx.core.view.doOnPreDraw

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

Comment on lines +65 to +68
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
val insets = windowInsets.getInsets(systemBars())
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(top = topMargin + insets.top)
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

updateMargins(top = topMargin + insets.top) will add the system-bar inset on top of the current top margin every time insets are re-applied (e.g., configuration change), causing the margin to grow. Capture and use the initial top margin (like the previous initialMargins.top) or store it once (e.g., via a tag) and always compute initialTop + insets.top.

Suggested change
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
val insets = windowInsets.getInsets(systemBars())
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(top = topMargin + insets.top)
val initialTopMargin = (layoutParams as? ViewGroup.MarginLayoutParams)?.topMargin ?: 0
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
val insets = windowInsets.getInsets(systemBars())
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
updateMargins(top = initialTopMargin + insets.top)

Copilot uses AI. Check for mistakes.
updateMargins(top = topMargin + insets.top)
}
windowInsets
}
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

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

After setting an OnApplyWindowInsetsListener, the codebase typically calls ViewCompat.requestApplyInsets(view) to ensure the listener runs immediately (see e.g. CreateAccountFragment.applySafeTopPadding and similar). Consider requesting insets here as well; otherwise the top margin update may never run if insets were already applied before this listener was set.

Suggested change
}
}
ViewCompat.requestApplyInsets(this)

Copilot uses AI. Check for mistakes.
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.

2 participants