forked from upstream-mirrors/quik
fix(reactions): readable fallback, working swipe, hidden sender copy
- Rework the quik wire format: the visible body is now an iOS-style
fallback ("Reacted 👍 to \"...\"" or "Reacted 👍 to a message") and the
machine data (emoji, sender address, timestamp, text) is hidden in a
zero-width payload using U+2061..U+2064 so it never collides with the
iOS/Google tapback characters. Non-quik clients see a clean sentence.
- Fix swipe-to-react: the message item touch listener no longer consumes
events, so the RecyclerView's ItemTouchHelper receives swipes again.
- Restore long-press to select messages (removed long-press-to-react).
- Always hide our own outgoing reaction, even when the target message
can't be resolved locally, so the sender never sees the raw payload.
- Tune the reaction picker popup: theme-tinted background, themed text,
smaller emoji, and width capped to the screen so all options fit
without horizontal scrolling.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -733,28 +733,37 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
|
||||
override fun showReactionPicker(messageId: Long) {
|
||||
val defaultEmojis = listOf("❤️", "👍", "👎", "😂", "😮", "😢")
|
||||
val pad = 12.dpToPx(this)
|
||||
val theme = colors.theme()
|
||||
val vPad = 8.dpToPx(this)
|
||||
|
||||
// Cap the popup to the screen width (minus a margin) so every emoji + the "+" fit
|
||||
// without horizontal scrolling; each item shares the width evenly via layout weight.
|
||||
val margin = 16.dpToPx(this)
|
||||
val popupWidth = resources.displayMetrics.widthPixels - margin * 2
|
||||
|
||||
val row = LinearLayout(this).apply {
|
||||
orientation = LinearLayout.HORIZONTAL
|
||||
setPadding(pad, pad, pad, pad)
|
||||
setPadding(vPad, vPad, vPad, vPad)
|
||||
}
|
||||
|
||||
val popup = PopupWindow(
|
||||
row,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
true
|
||||
).apply {
|
||||
val background = ContextCompat.getDrawable(this, R.drawable.rounded_rectangle_4dp)
|
||||
?.mutate()
|
||||
?.apply { setTint(theme.theme) }
|
||||
|
||||
val popup = PopupWindow(row, popupWidth, ViewGroup.LayoutParams.WRAP_CONTENT, true).apply {
|
||||
elevation = 8.dpToPx(this@ComposeActivity).toFloat()
|
||||
setBackgroundDrawable(ContextCompat.getDrawable(this@ComposeActivity, R.drawable.rounded_rectangle_4dp))
|
||||
setBackgroundDrawable(background)
|
||||
}
|
||||
|
||||
fun emojiView(label: String, onClick: () -> Unit) = TextView(this).apply {
|
||||
text = label
|
||||
textSize = 24f
|
||||
textSize = 20f
|
||||
gravity = Gravity.CENTER
|
||||
setPadding(pad, pad / 2, pad, pad / 2)
|
||||
includeFontPadding = false
|
||||
setTextColor(theme.textPrimary)
|
||||
setPadding(0, vPad, 0, vPad)
|
||||
// weight = 1 so all items share the popup width equally and shrink to fit
|
||||
layoutParams = LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)
|
||||
setOnClickListener {
|
||||
onClick()
|
||||
popup.dismiss()
|
||||
@@ -786,8 +795,11 @@ class ComposeActivity : QkThemedActivity(), ComposeView {
|
||||
?.let { binding.messageList.layoutManager?.findViewByPosition(it) }
|
||||
|
||||
if (messageView != null) {
|
||||
row.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
|
||||
popup.showAsDropDown(messageView, 0, -(messageView.height + row.measuredHeight))
|
||||
row.measure(
|
||||
View.MeasureSpec.makeMeasureSpec(popupWidth, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.UNSPECIFIED
|
||||
)
|
||||
popup.showAsDropDown(messageView, margin, -(messageView.height + row.measuredHeight))
|
||||
} else {
|
||||
popup.showAtLocation(binding.messageList, Gravity.CENTER, 0, 0)
|
||||
}
|
||||
|
||||
@@ -174,10 +174,11 @@ class MessagesAdapter @Inject constructor(
|
||||
|
||||
return QkViewHolder(view).apply {
|
||||
val holder = this
|
||||
// A single GestureDetector on the item root handles tap / double-tap / long-press.
|
||||
// Child views (links, images, parts) keep handling their own touch events.
|
||||
// GestureDetector handles single-tap (select/expand) and double-tap (react).
|
||||
// It must NOT consume events, otherwise the RecyclerView's ItemTouchHelper never
|
||||
// sees swipe gestures. The view is long-clickable (below), so it stays a touch
|
||||
// target and the detector keeps receiving move/up events for double-tap detection.
|
||||
val gestureDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
||||
// must return true so the detector receives the subsequent events
|
||||
override fun onDown(e: MotionEvent): Boolean = true
|
||||
|
||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||
@@ -197,19 +198,19 @@ class MessagesAdapter @Inject constructor(
|
||||
getItem(holder.adapterPosition)?.let { doubleTapIntent.onNext(it.id) }
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onLongPress(e: MotionEvent) {
|
||||
getItem(holder.adapterPosition)?.let {
|
||||
// If a selection is already active, keep extending it (multi-select).
|
||||
// Otherwise, long-press opens the emoji reaction picker for this message.
|
||||
// Selection mode remains reachable via the toolbar (select all) once active.
|
||||
if (toggleSelection(it.id, false)) view.isActivated = isSelected(it.id)
|
||||
else reactionPickerIntent.onNext(it.id)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
view.setOnTouchListener { _, e -> gestureDetector.onTouchEvent(e) }
|
||||
// return false: don't consume, so swipe-to-react (ItemTouchHelper) keeps working
|
||||
view.setOnTouchListener { _, e -> gestureDetector.onTouchEvent(e); false }
|
||||
|
||||
// long-press enters/extends message selection mode
|
||||
view.setOnLongClickListener {
|
||||
getItem(holder.adapterPosition)?.let {
|
||||
toggleSelection(it.id)
|
||||
view.isActivated = isSelected(it.id)
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user