Fix various story reply bottom sheet issues.
This commit is contained in:
parent
3da2fc4d9b
commit
87b00bb156
8 changed files with 37 additions and 39 deletions
|
@ -115,10 +115,6 @@ class StoryReplyComposer @JvmOverloads constructor(
|
|||
return trimmedText to mentions
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
callback?.onHeightChanged(h)
|
||||
}
|
||||
|
||||
fun openEmojiSearch() {
|
||||
emojiDrawer.onOpenEmojiSearch()
|
||||
}
|
||||
|
@ -154,7 +150,6 @@ class StoryReplyComposer @JvmOverloads constructor(
|
|||
fun onSendActionClicked()
|
||||
fun onPickReactionClicked()
|
||||
fun onInitializeEmojiDrawer(mediaKeyboard: MediaKeyboard)
|
||||
fun onHeightChanged(height: Int)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -104,8 +104,6 @@ class StoryDirectReplyDialogFragment :
|
|||
keyboardPagerViewModel.setOnlyPage(KeyboardPage.EMOJI)
|
||||
mediaKeyboard.setFragmentManager(childFragmentManager)
|
||||
}
|
||||
|
||||
override fun onHeightChanged(height: Int) = Unit
|
||||
}
|
||||
|
||||
viewModel.state.observe(viewLifecycleOwner) { state ->
|
||||
|
|
|
@ -15,7 +15,9 @@ import org.thoughtcrime.securesms.components.FixedRoundedCornerBottomSheetDialog
|
|||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.stories.viewer.page.StoryViewerPageViewModel
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.BottomSheetBehaviorDelegate
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil.requireCoordinatorLayout
|
||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
|
@ -45,10 +47,6 @@ class StoryGroupReplyBottomSheetDialogFragment : FixedRoundedCornerBottomSheetDi
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
view.updateLayoutParams {
|
||||
height = (resources.displayMetrics.heightPixels * 0.6f).roundToInt()
|
||||
}
|
||||
|
||||
lifecycleDisposable.bindTo(viewLifecycleOwner)
|
||||
if (savedInstanceState == null) {
|
||||
childFragmentManager.beginTransaction()
|
||||
|
@ -68,6 +66,18 @@ class StoryGroupReplyBottomSheetDialogFragment : FixedRoundedCornerBottomSheetDi
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
view.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
val parentHeight = requireCoordinatorLayout().height
|
||||
val desiredHeight = (resources.displayMetrics.heightPixels * 0.6f).roundToInt()
|
||||
val targetHeight = if (parentHeight != 0) min(parentHeight, desiredHeight) else desiredHeight
|
||||
|
||||
if (view.height != targetHeight) {
|
||||
view.updateLayoutParams {
|
||||
height = targetHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
|
|
|
@ -2,11 +2,10 @@ package org.thoughtcrime.securesms.stories.viewer.reply.group
|
|||
|
||||
import android.content.ClipData
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings.System.getConfiguration
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.doOnNextLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
@ -34,7 +33,6 @@ import org.thoughtcrime.securesms.reactions.any.ReactWithAnyEmojiBottomSheetDial
|
|||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.recipients.ui.bottomsheet.RecipientBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.BottomSheetBehaviorDelegate
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.StoryViewsAndRepliesPagerChild
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.StoryViewsAndRepliesPagerParent
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.composer.StoryReactionBar
|
||||
|
@ -42,9 +40,7 @@ import org.thoughtcrime.securesms.stories.viewer.reply.composer.StoryReplyCompos
|
|||
import org.thoughtcrime.securesms.util.DeleteDialog
|
||||
import org.thoughtcrime.securesms.util.FragmentDialogs.displayInDialogAboveAnchor
|
||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||
import org.thoughtcrime.securesms.util.Projection
|
||||
import org.thoughtcrime.securesms.util.ServiceUtil
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.PagingMappingAdapter
|
||||
import org.thoughtcrime.securesms.util.fragments.findListener
|
||||
import org.thoughtcrime.securesms.util.fragments.requireListener
|
||||
|
@ -56,7 +52,6 @@ import org.thoughtcrime.securesms.util.visible
|
|||
class StoryGroupReplyFragment :
|
||||
Fragment(R.layout.stories_group_replies_fragment),
|
||||
StoryViewsAndRepliesPagerChild,
|
||||
BottomSheetBehaviorDelegate,
|
||||
StoryReplyComposer.Callback,
|
||||
EmojiKeyboardCallback,
|
||||
ReactWithAnyEmojiBottomSheetDialogFragment.Callback,
|
||||
|
@ -123,10 +118,9 @@ class StoryGroupReplyFragment :
|
|||
}
|
||||
|
||||
viewModel.pageData.observe(viewLifecycleOwner) { pageData ->
|
||||
val isScrolledToBottom = recyclerView.canScrollVertically(-1)
|
||||
adapter.submitList(getConfiguration(pageData).toMappingModelList()) {
|
||||
if (isScrolledToBottom) {
|
||||
recyclerView.doOnNextLayout {
|
||||
recyclerView.post {
|
||||
if (recyclerView.canScrollVertically(1)) {
|
||||
recyclerView.smoothScrollToPosition(0)
|
||||
}
|
||||
}
|
||||
|
@ -196,14 +190,6 @@ class StoryGroupReplyFragment :
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSlide(bottomSheet: View) {
|
||||
val inputProjection = Projection.relativeToViewRoot(composer, null)
|
||||
val parentProjection = Projection.relativeToViewRoot(bottomSheet.parent as ViewGroup, null)
|
||||
composer.translationY = (parentProjection.height + parentProjection.y - (inputProjection.y + inputProjection.height))
|
||||
inputProjection.release()
|
||||
parentProjection.release()
|
||||
}
|
||||
|
||||
override fun onPageSelected(child: StoryViewsAndRepliesPagerParent.Child) {
|
||||
currentChild = child
|
||||
updateNestedScrolling()
|
||||
|
@ -274,10 +260,6 @@ class StoryGroupReplyFragment :
|
|||
sendReaction(emoji)
|
||||
}
|
||||
|
||||
override fun onHeightChanged(height: Int) {
|
||||
ViewUtil.setPaddingBottom(recyclerView, height)
|
||||
}
|
||||
|
||||
private fun initializeMentions() {
|
||||
Recipient.live(groupRecipientId).observe(viewLifecycleOwner) { recipient ->
|
||||
mentionsViewModel.onRecipientChange(recipient)
|
||||
|
|
|
@ -22,7 +22,9 @@ import org.thoughtcrime.securesms.stories.viewer.reply.BottomSheetBehaviorDelega
|
|||
import org.thoughtcrime.securesms.stories.viewer.reply.StoryViewsAndRepliesPagerChild
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.StoryViewsAndRepliesPagerParent
|
||||
import org.thoughtcrime.securesms.stories.viewer.reply.group.StoryGroupReplyFragment
|
||||
import org.thoughtcrime.securesms.util.BottomSheetUtil.requireCoordinatorLayout
|
||||
import org.thoughtcrime.securesms.util.LifecycleDisposable
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
|
@ -61,10 +63,6 @@ class StoryViewsAndRepliesDialogFragment : FixedRoundedCornerBottomSheetDialogFr
|
|||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
view.updateLayoutParams {
|
||||
height = (resources.displayMetrics.heightPixels * 0.6f).roundToInt()
|
||||
}
|
||||
|
||||
pager = view.findViewById(R.id.pager)
|
||||
|
||||
val bottomSheetBehavior = (requireDialog() as BottomSheetDialog).behavior
|
||||
|
@ -94,6 +92,18 @@ class StoryViewsAndRepliesDialogFragment : FixedRoundedCornerBottomSheetDialogFr
|
|||
}.attach()
|
||||
|
||||
lifecycleDisposable.bindTo(viewLifecycleOwner)
|
||||
|
||||
view.viewTreeObserver.addOnGlobalLayoutListener {
|
||||
val parentHeight = requireCoordinatorLayout().height
|
||||
val desiredHeight = (resources.displayMetrics.heightPixels * 0.6f).roundToInt()
|
||||
val targetHeight = if (parentHeight != 0) min(parentHeight, desiredHeight) else desiredHeight
|
||||
|
||||
if (view.height != targetHeight) {
|
||||
view.updateLayoutParams {
|
||||
height = targetHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
@ -21,6 +21,8 @@ class StoryViewsBottomSheetDialogFragment : FixedRoundedCornerBottomSheetDialogF
|
|||
override val themeResId: Int
|
||||
get() = R.style.Widget_Signal_FixedRoundedCorners_Stories
|
||||
|
||||
override val peekHeightPercentage: Float = 1f
|
||||
|
||||
private val storyId: Long
|
||||
get() = requireArguments().getLong(ARG_STORY_ID)
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:importantForAccessibility="no"
|
||||
app:srcCompat="@drawable/bottom_sheet_handle" />
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="240dp"
|
||||
android:layout_height="match_parent"
|
||||
tools:layout_gravity="bottom">
|
||||
|
||||
<TextView
|
||||
|
@ -21,9 +20,10 @@
|
|||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/composer"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
|
Loading…
Add table
Reference in a new issue