From 0bcc84cbd61ee2c6a2cc7f0d00e5f0c701e20ee9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 11 Oct 2019 11:16:38 +0200 Subject: [PATCH] Try to fix the bottom sheet showing expanded by default #2 Seems ok now --- .../VectorBaseBottomSheetDialogFragment.kt | 14 +++++++++++++- .../readreceipts/DisplayReadReceiptsBottomSheet.kt | 4 +--- .../timeline/action/MessageActionsBottomSheet.kt | 1 + .../edithistory/ViewEditHistoryBottomSheet.kt | 1 + .../timeline/reactions/ViewReactionsBottomSheet.kt | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseBottomSheetDialogFragment.kt b/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseBottomSheetDialogFragment.kt index 168aaf87f0..f793795910 100644 --- a/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseBottomSheetDialogFragment.kt +++ b/vector/src/main/java/im/vector/riotx/core/platform/VectorBaseBottomSheetDialogFragment.kt @@ -21,6 +21,7 @@ import android.os.Bundle import android.os.Parcelable import android.view.View import android.widget.FrameLayout +import androidx.annotation.CallSuper import com.airbnb.mvrx.MvRx import com.airbnb.mvrx.MvRxView import com.airbnb.mvrx.MvRxViewModelStore @@ -41,6 +42,8 @@ abstract class VectorBaseBottomSheetDialogFragment : BottomSheetDialogFragment() private lateinit var screenComponent: ScreenComponent final override val mvrxViewId: String by lazy { mvrxPersistedViewId } + private var bottomSheetBehavior: BottomSheetBehavior? = null + val vectorBaseActivity: VectorBaseActivity by lazy { activity as VectorBaseActivity } @@ -70,7 +73,8 @@ abstract class VectorBaseBottomSheetDialogFragment : BottomSheetDialogFragment() val d = dialog as BottomSheetDialog val bottomSheet = d.findViewById(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout? - BottomSheetBehavior.from(bottomSheet!!).state = BottomSheetBehavior.STATE_EXPANDED + bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet!!) + bottomSheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED } } } @@ -89,6 +93,14 @@ abstract class VectorBaseBottomSheetDialogFragment : BottomSheetDialogFragment() postInvalidate() } + @CallSuper + override fun invalidate() { + if (showExpanded) { + // Force the bottom sheet to be expanded + bottomSheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED + } + } + protected fun setArguments(args: Parcelable? = null) { arguments = args?.let { Bundle().apply { putParcelable(MvRx.KEY_ARG, it) } } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt index 80539d73e4..6cf5191a6d 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt @@ -73,9 +73,7 @@ class DisplayReadReceiptsBottomSheet : VectorBaseBottomSheetDialogFragment() { epoxyController.setData(displayReadReceiptArgs.readReceipts) } - override fun invalidate() { - // we are not using state for this one as it's static - } + // we are not using state for this one as it's static, so no need to override invalidate() companion object { fun newInstance(readReceipts: List): DisplayReadReceiptsBottomSheet { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt index 95b2170d68..e209a3d887 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt @@ -70,6 +70,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message override fun invalidate() = withState(viewModel) { messageActionsEpoxyController.setData(it) + super.invalidate() } companion object { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt index acdef2058d..f0da92e1dd 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt @@ -74,6 +74,7 @@ class ViewEditHistoryBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun invalidate() = withState(viewModel) { epoxyController.setData(it) + super.invalidate() } companion object { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt index deb2a84818..c93c41fa97 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt @@ -71,6 +71,7 @@ class ViewReactionsBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun invalidate() = withState(viewModel) { epoxyController.setData(it) + super.invalidate() } companion object {