diff --git a/app/src/main/java/one/mixin/android/ui/common/GroupBottomSheetDialogFragment.kt b/app/src/main/java/one/mixin/android/ui/common/GroupBottomSheetDialogFragment.kt index 6ebf7294bd..b60b073d85 100644 --- a/app/src/main/java/one/mixin/android/ui/common/GroupBottomSheetDialogFragment.kt +++ b/app/src/main/java/one/mixin/android/ui/common/GroupBottomSheetDialogFragment.kt @@ -33,7 +33,6 @@ import one.mixin.android.extension.alertDialogBuilder import one.mixin.android.extension.dayTime import one.mixin.android.extension.dp import one.mixin.android.extension.getClipboardManager -import one.mixin.android.extension.getSafeAreaInsetsBottom import one.mixin.android.extension.localTime import one.mixin.android.extension.navigationBarHeight import one.mixin.android.extension.notNullWithElse @@ -111,6 +110,32 @@ class GroupBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment( FragmentGroupBottomSheetBinding.bind(contentView) } + override fun getPeekHeight( + contentView: View, + behavior: BottomSheetBehavior<*>, + ): Int { + val titleView = contentView.findViewById(R.id.title) ?: return 0 + val scrollContent = contentView.findViewById(R.id.scroll_content) ?: return 0 + + val width = contentView.measuredWidth.takeIf { it > 0 } ?: contentView.width + val widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY) + + titleView.measure( + widthSpec, + View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), + ) + scrollContent.measure( + widthSpec, + View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), + ) + + // Calculate height excluding menu layout and adding proper spacing + val menuHeight = menuListLayout?.measuredHeight ?: 0 + val spacing = if (menuHeight > 0) 38.dp else 8.dp + + return titleView.measuredHeight + scrollContent.measuredHeight - menuHeight - spacing + } + override fun setupDialog( dialog: Dialog, style: Int, @@ -225,10 +250,14 @@ class GroupBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment( contentView.doOnPreDraw { binding.opsLl.updateLayoutParams { - bottomMargin = requireContext().navigationBarHeight() + 24.dp + bottomMargin = 24.dp + } + // Update peek height only if menu layout exists and has been measured + if (menuListLayout != null && menuListLayout?.measuredHeight != 0) { + val contentHeight = binding.title.height + binding.scrollContent.height - + (menuListLayout?.height ?: 0) - 38.dp + behavior?.peekHeight = requireContext().resolveBottomSheetPeekHeight(contentView, contentHeight) } - behavior?.peekHeight = binding.title.height + binding.scrollContent.height - - (menuListLayout?.height ?: 0) - if (menuListLayout != null) 38.dp else 8.dp } } @@ -405,8 +434,7 @@ class GroupBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment( .let { layout -> menuListLayout = layout binding.scrollContent.addView(layout) - val safeBottomHeight = layout.getSafeAreaInsetsBottom() - binding.scrollContent.setPadding(0,0,0,safeBottomHeight) + binding.scrollContent.setPadding(0, 0, 0, 0) binding.moreFl.setOnClickListener { if (behavior?.state == BottomSheetBehavior.STATE_COLLAPSED) { behavior?.state = BottomSheetBehavior.STATE_EXPANDED diff --git a/app/src/main/java/one/mixin/android/ui/common/UserBottomSheetDialogFragment.kt b/app/src/main/java/one/mixin/android/ui/common/UserBottomSheetDialogFragment.kt index 3fbb105568..6bc6cc586e 100644 --- a/app/src/main/java/one/mixin/android/ui/common/UserBottomSheetDialogFragment.kt +++ b/app/src/main/java/one/mixin/android/ui/common/UserBottomSheetDialogFragment.kt @@ -53,7 +53,6 @@ import one.mixin.android.extension.dp import one.mixin.android.extension.getClipboardManager import one.mixin.android.extension.getOtherPath import one.mixin.android.extension.getParcelableCompat -import one.mixin.android.extension.getSafeAreaInsetsBottom import one.mixin.android.extension.localTime import one.mixin.android.extension.navTo import one.mixin.android.extension.navigationBarHeight @@ -170,6 +169,32 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment() FragmentUserBottomSheetBinding.bind(contentView) } + override fun getPeekHeight( + contentView: View, + behavior: BottomSheetBehavior<*>, + ): Int { + val titleView = contentView.findViewById(R.id.title) ?: return 0 + val scrollContent = contentView.findViewById(R.id.scroll_content) ?: return 0 + + val width = contentView.measuredWidth.takeIf { it > 0 } ?: contentView.width + val widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY) + + titleView.measure( + widthSpec, + View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), + ) + scrollContent.measure( + widthSpec, + View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), + ) + + // Calculate height excluding menu layout and adding proper spacing + val menuHeight = menuListLayout?.measuredHeight ?: 0 + val spacing = if (menuHeight > 0) 38.dp else 8.dp + + return titleView.measuredHeight + scrollContent.measuredHeight - menuHeight - spacing + } + override fun setupDialog( dialog: Dialog, style: Int, @@ -219,12 +244,15 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment() contentView.doOnPreDraw { if (!isAdded) return@doOnPreDraw binding.opLl.updateLayoutParams { - bottomMargin = requireContext().navigationBarHeight() + 24.dp + bottomMargin = 24.dp + } + // Update peek height only if menu layout exists and has been measured + if (menuListLayout != null && menuListLayout?.measuredHeight != 0) { + val contentHeight = binding.title.height + + binding.scrollContent.height - + (menuListLayout?.height ?: 0) - 38.dp + behavior?.peekHeight = requireContext().resolveBottomSheetPeekHeight(contentView, contentHeight) } - behavior?.peekHeight = - binding.title.height + - binding.scrollContent.height - - (menuListLayout?.height ?: 0) - if (menuListLayout != null) 38.dp else 8.dp } }, ) @@ -286,12 +314,12 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment() apps?.let { binding.avatarGroup.setApps(it) contentView.doOnPreDraw { - behavior?.peekHeight = - binding.title.height + binding.scrollContent.height - - ( - menuListLayout?.height - ?: 0 - ) - if (menuListLayout != null) 38.dp else 8.dp + // Update peek height when apps are loaded + if (menuListLayout != null && menuListLayout?.measuredHeight != 0) { + val contentHeight = binding.title.height + binding.scrollContent.height - + (menuListLayout?.height ?: 0) - 38.dp + behavior?.peekHeight = requireContext().resolveBottomSheetPeekHeight(contentView, contentHeight) + } } } } @@ -619,8 +647,7 @@ class UserBottomSheetDialogFragment : MixinScrollableBottomSheetDialogFragment() list.createMenuLayout(requireContext()).let { layout -> menuListLayout = layout binding.scrollContent.addView(layout) - val safeBottomHeight = layout.getSafeAreaInsetsBottom() - binding.scrollContent.setPadding(0,0,0,safeBottomHeight) + binding.scrollContent.setPadding(0, 0, 0, 0) binding.moreFl.setOnClickListener { if (behavior?.state == BottomSheetBehavior.STATE_COLLAPSED) { behavior?.state = BottomSheetBehavior.STATE_EXPANDED diff --git a/app/src/main/java/one/mixin/android/ui/setting/ui/components/MemberUpgradePaymentButton.kt b/app/src/main/java/one/mixin/android/ui/setting/ui/components/MemberUpgradePaymentButton.kt index f98d65e80f..0db0b05823 100644 --- a/app/src/main/java/one/mixin/android/ui/setting/ui/components/MemberUpgradePaymentButton.kt +++ b/app/src/main/java/one/mixin/android/ui/setting/ui/components/MemberUpgradePaymentButton.kt @@ -64,7 +64,7 @@ fun MemberUpgradePaymentButton( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 30.dp) + .padding(start = 16.dp, end = 16.dp, top = 20.dp, bottom = 12.dp) ) { var buttonOffset by remember { mutableFloatStateOf(0f) } val interactionSource = remember { MutableInteractionSource() } @@ -95,7 +95,6 @@ fun MemberUpgradePaymentButton( Button( modifier = Modifier .fillMaxWidth() - .padding(16.dp) .height(48.dp) .offset(x = buttonOffset.dp), shape = RoundedCornerShape(24.dp), @@ -132,7 +131,7 @@ fun MemberUpgradePaymentButton( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 30.dp) + .padding(start = 16.dp, end = 16.dp, top = 20.dp, bottom = 12.dp) ) { val isPlanAvailable = isPlanAvailableInGooglePlay( selectedPlan, @@ -168,7 +167,6 @@ fun MemberUpgradePaymentButton( !isGooglePlayUnavailable), modifier = Modifier .fillMaxWidth() - .padding(16.dp) .height(48.dp), shape = RoundedCornerShape(24.dp), elevation = ButtonDefaults.elevation( diff --git a/app/src/main/java/one/mixin/android/ui/wallet/InputFragment.kt b/app/src/main/java/one/mixin/android/ui/wallet/InputFragment.kt index ebccc4b3e6..b7699fc325 100644 --- a/app/src/main/java/one/mixin/android/ui/wallet/InputFragment.kt +++ b/app/src/main/java/one/mixin/android/ui/wallet/InputFragment.kt @@ -1184,7 +1184,12 @@ class InputFragment : BaseFragment(R.layout.fragment_input), OnReceiveSelectionC } else { baseValue.toPlainString() } - v = BigDecimal(v).multiply(percentageOfBalance).max(BigDecimal.ZERO).setScale(8, RoundingMode.DOWN).toPlainString() + v = BigDecimal(v) + .multiply(percentageOfBalance) + .max(BigDecimal.ZERO) + .setScale(8, RoundingMode.DOWN) + .stripTrailingZeros() + .toPlainString() updateUI() } @@ -1516,4 +1521,3 @@ class InputFragment : BaseFragment(R.layout.fragment_input), OnReceiveSelectionC } } } - diff --git a/app/src/main/java/one/mixin/android/widget/BottomSheetDialogInsets.kt b/app/src/main/java/one/mixin/android/widget/BottomSheetDialogInsets.kt index 0439956838..4e5d50480a 100644 --- a/app/src/main/java/one/mixin/android/widget/BottomSheetDialogInsets.kt +++ b/app/src/main/java/one/mixin/android/widget/BottomSheetDialogInsets.kt @@ -5,6 +5,7 @@ import android.view.ViewGroup import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams import androidx.core.view.updateMargins +import androidx.core.view.updatePadding import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.internal.ViewUtils.doOnApplyWindowInsets @@ -27,4 +28,13 @@ internal fun BottomSheetDialog.applyBottomSheetContainerInsets(transparentStatus } findViewById(com.google.android.material.R.id.coordinator)?.fitsSystemWindows = false + findViewById(com.google.android.material.R.id.design_bottom_sheet)?.apply { + fitsSystemWindows = false + doOnApplyWindowInsets(this) { insetView, windowInsets, initialPadding -> + insetView.updatePadding( + bottom = initialPadding.bottom + windowInsets.getInsets(WindowInsetsCompat.Type.navigationBars()).bottom, + ) + windowInsets + } + } }