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