mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-07-25 15:34:49 +01:00
Fix emoji picker weird scrolling in RTL.
This commit is contained in:
+18
-16
@@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.keyboard.emoji.toMappingModels
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.reactions.any.ReactWithAnyEmojiBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.util.ViewUtil
|
||||
import org.thoughtcrime.securesms.util.adapter.mapping.MappingModel
|
||||
|
||||
class StoryReplyComposer @JvmOverloads constructor(
|
||||
@@ -47,7 +48,6 @@ class StoryReplyComposer @JvmOverloads constructor(
|
||||
private val emojiDrawer: MediaKeyboard
|
||||
private val reactionEmojiView: EmojiPageView
|
||||
private val anyReactionView: View
|
||||
private val emojiBar: View
|
||||
private val bubbleView: ViewGroup
|
||||
|
||||
val input: ComposeText
|
||||
@@ -70,7 +70,6 @@ class StoryReplyComposer @JvmOverloads constructor(
|
||||
emojiDrawer = findViewById(R.id.emoji_drawer)
|
||||
anyReactionView = findViewById(R.id.any_reaction)
|
||||
reactionEmojiView = findViewById(R.id.reaction_emoji_view)
|
||||
emojiBar = findViewById(R.id.emoji_bar)
|
||||
bubbleView = findViewById(R.id.bubble)
|
||||
|
||||
val reply: View = findViewById(R.id.reply)
|
||||
@@ -213,19 +212,13 @@ class StoryReplyComposer @JvmOverloads constructor(
|
||||
val numItems = reactionEmojiView.adapter?.itemCount ?: 0
|
||||
|
||||
decoration.firstItemOffset = anyReactionView.marginEnd
|
||||
|
||||
if (numItems > maxNumItems) {
|
||||
decoration.horizontalSpacing = 0
|
||||
reactionEmojiView.invalidateItemDecorations()
|
||||
decoration.horizontalSpacing = if (numItems > maxNumItems) {
|
||||
0
|
||||
} else {
|
||||
decoration.horizontalSpacing = (availableWidth - (numItems * emojiItemWidth)) / numItems
|
||||
reactionEmojiView.invalidateItemDecorations()
|
||||
(availableWidth - (numItems * emojiItemWidth)) / numItems
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
||||
super.onLayout(changed, left, top, right, bottom)
|
||||
updateEmojiSpacing()
|
||||
reactionEmojiView.invalidateItemDecorations()
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
@@ -243,11 +236,20 @@ class StoryReplyComposer @JvmOverloads constructor(
|
||||
|
||||
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
|
||||
super.getItemOffsets(outRect, view, parent, state)
|
||||
outRect.right = horizontalSpacing
|
||||
if (parent.getChildAdapterPosition(view) == 0) {
|
||||
outRect.left = firstItemOffset
|
||||
if (ViewUtil.isRtl(view)) {
|
||||
outRect.left = horizontalSpacing
|
||||
if (parent.getChildAdapterPosition(view) == 0) {
|
||||
outRect.right = firstItemOffset
|
||||
} else {
|
||||
outRect.right = 0
|
||||
}
|
||||
} else {
|
||||
outRect.left = 0
|
||||
outRect.right = horizontalSpacing
|
||||
if (parent.getChildAdapterPosition(view) == 0) {
|
||||
outRect.left = firstItemOffset
|
||||
} else {
|
||||
outRect.left = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
android:background="@color/signal_colorSurface"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/emoji_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:orientation="horizontal">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.EmojiPageView
|
||||
android:id="@+id/reaction_emoji_view"
|
||||
@@ -21,7 +20,11 @@
|
||||
android:layout_weight="1"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
android:fadingEdgeLength="8dp"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/any_reaction" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/any_reaction"
|
||||
@@ -30,10 +33,13 @@
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:contentDescription="@string/StoryViewerPageFragment_any_reaction_content_description"
|
||||
android:src="@drawable/ic_any_emoji_32"
|
||||
/>
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/bubble"
|
||||
|
||||
@@ -6490,6 +6490,8 @@
|
||||
<string name="StoryViewerPageFragment__send_failed">Send failed. Tap to retry</string>
|
||||
<!-- Label for the reply button in story viewer, which will launch the group story replies bottom sheet. -->
|
||||
<string name="StoryViewerPageFragment__reply_to_group">Reply to group</string>
|
||||
<!-- Content description for the any reaction button in reply to story composer, which will launch the emojis bottom sheet. -->
|
||||
<string name="StoryViewerPageFragment_any_reaction_content_description">More reactions</string>
|
||||
<!-- Displayed when a story has no views -->
|
||||
<string name="StoryViewsFragment__no_views_yet">No views yet</string>
|
||||
<!-- Displayed when user has disabled receipts -->
|
||||
|
||||
Reference in New Issue
Block a user