@@ -35,6 +35,7 @@ import androidx.core.content.ContextCompat
3535import androidx.core.view.ViewCompat
3636import androidx.core.view.WindowInsetsCompat
3737import androidx.core.view.children
38+ import androidx.core.view.doOnLayout
3839import androidx.core.view.updateLayoutParams
3940import com.google.android.material.bottomsheet.BottomSheetBehavior
4041import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
@@ -564,30 +565,21 @@ class SuperwallPaywallActivity : AppCompatActivity() {
564565 }
565566 }
566567 bottomSheetBehavior.skipCollapsed = true
568+ // Start hidden so the sheet slides up from the bottom
569+ bottomSheetBehavior.state = BottomSheetBehavior .STATE_HIDDEN
567570
568- val setState = {
569- if (! isModal) {
570- // Expanded by default
571- bottomSheetBehavior.state = BottomSheetBehavior .STATE_HALF_EXPANDED
572- } else {
573- bottomSheetBehavior.state = BottomSheetBehavior .STATE_EXPANDED
574- }
571+ val targetState = if (! isModal) {
572+ BottomSheetBehavior .STATE_HALF_EXPANDED
573+ } else {
574+ BottomSheetBehavior .STATE_EXPANDED
575575 }
576576
577- // Check if we need to delay state change for Samsung devices on Android 14
578- val isSamsungAndroid14 =
579- Build .VERSION .SDK_INT == Build .VERSION_CODES .UPSIDE_DOWN_CAKE &&
580- (
581- Build .MANUFACTURER .equals(" samsung" , ignoreCase = true ) ||
582- Build .BRAND .equals(" samsung" , ignoreCase = true )
583- )
584-
585- if (isSamsungAndroid14) {
586- // Post state change to next frame after layout is complete
587- // This fixes timing issues on Samsung devices with Android 14
588- content.post { setState() }
589- } else {
590- setState()
577+ // Wait for layout to complete before expanding, so the slide-up
578+ // animation runs correctly on all devices (including Samsung).
579+ content.doOnLayout {
580+ content.post {
581+ bottomSheetBehavior.state = targetState
582+ }
591583 }
592584 content.invalidate()
593585 var currentWebViewScroll = 0
0 commit comments