mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
No longer move chat message position in long press dialog to match position in list + disabled emojis & reply action if chat room is read only
This commit is contained in:
parent
8794146df7
commit
e3c1280278
5 changed files with 35 additions and 45 deletions
|
|
@ -102,7 +102,7 @@ dependencies {
|
|||
// https://github.com/tommybuonomo/dotsindicator/blob/master/LICENSE Apache v2.0
|
||||
implementation("com.tbuonomo:dotsindicator:5.0")
|
||||
|
||||
implementation platform('com.google.firebase:firebase-bom:32.2.3')
|
||||
implementation platform('com.google.firebase:firebase-bom:32.3.1')
|
||||
implementation 'com.google.firebase:firebase-messaging'
|
||||
|
||||
//noinspection GradleDynamicVersion
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class ConversationEventAdapter(
|
|||
const val EVENT = 3
|
||||
}
|
||||
|
||||
val chatMessageLongPressEvent = MutableLiveData<Event<Pair<ChatMessageModel, Int>>>()
|
||||
val chatMessageLongPressEvent = MutableLiveData<Event<ChatMessageModel>>()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return when (viewType) {
|
||||
|
|
@ -112,10 +112,7 @@ class ConversationEventAdapter(
|
|||
model = message
|
||||
|
||||
setOnLongClickListener {
|
||||
val screen = IntArray(2)
|
||||
root.getLocationOnScreen(screen)
|
||||
|
||||
chatMessageLongPressEvent.value = Event(Pair(message, screen[1]))
|
||||
chatMessageLongPressEvent.value = Event(message)
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import android.app.Dialog
|
|||
import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.graphics.RenderEffect
|
||||
import android.graphics.Shader
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
|
|
@ -35,7 +34,6 @@ import android.view.ViewGroup
|
|||
import android.view.Window
|
||||
import android.view.WindowManager
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
|
@ -43,8 +41,6 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import org.linphone.R
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.databinding.ChatConversationFragmentBinding
|
||||
|
|
@ -135,8 +131,8 @@ class ConversationFragment : GenericFragment() {
|
|||
binding.eventsList.layoutManager = layoutManager
|
||||
|
||||
adapter.chatMessageLongPressEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { pair ->
|
||||
showChatMessageLongPressMenu(pair.first, pair.second)
|
||||
it.consume { model ->
|
||||
showChatMessageLongPressMenu(model)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,7 +170,7 @@ class ConversationFragment : GenericFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun showChatMessageLongPressMenu(chatMessageModel: ChatMessageModel, yPosition: Int) {
|
||||
private fun showChatMessageLongPressMenu(chatMessageModel: ChatMessageModel) {
|
||||
// TODO: handle backward compat for blurring
|
||||
val blurEffect = RenderEffect.createBlurEffect(16F, 16F, Shader.TileMode.MIRROR)
|
||||
binding.root.setRenderEffect(blurEffect)
|
||||
|
|
@ -216,22 +212,6 @@ class ConversationFragment : GenericFragment() {
|
|||
dialog.dismiss()
|
||||
}
|
||||
|
||||
val screenY = yPosition - AppUtils.getDimension(
|
||||
R.dimen.chat_bubble_long_press_menu_bubble_offset
|
||||
)
|
||||
val rect = Rect()
|
||||
binding.root.getGlobalVisibleRect(rect)
|
||||
val height = rect.height()
|
||||
val percent = ((screenY * 100) / height)
|
||||
// To prevent bubble from being behind the bottom actions or the emojis to be out of the screen
|
||||
val guideline = min(max(0.1f, (percent / 100)), 0.4f) // value must be between 0 and 1
|
||||
|
||||
val constraintLayout = layout.constraintLayout
|
||||
val set = ConstraintSet()
|
||||
set.clone(constraintLayout)
|
||||
set.setGuidelinePercent(R.id.guideline, guideline)
|
||||
set.applyTo(constraintLayout)
|
||||
|
||||
dialog.setContentView(layout.root)
|
||||
dialog.setOnDismissListener {
|
||||
binding.root.setRenderEffect(null)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ class ChatMessageModel @WorkerThread constructor(
|
|||
|
||||
val time = TimestampUtils.toString(chatMessage.time)
|
||||
|
||||
val chatRoomIsReadOnly = chatMessage.chatRoom.isReadOnly
|
||||
|
||||
val dismissLongPressMenuEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
MutableLiveData<Event<Boolean>>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,15 @@
|
|||
|
||||
<data>
|
||||
<import type="android.view.View" />
|
||||
<variable
|
||||
name="replyClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="copyClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="forwardClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="deleteClickListener"
|
||||
type="View.OnClickListener" />
|
||||
|
|
@ -23,12 +29,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/guideline"
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/emojis_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintGuide_percent="0.4" />
|
||||
app:constraint_referenced_ids="thumbs_up, love, laughing, surprised, tear, plus, emojis_background"
|
||||
android:visibility="@{model.chatRoomIsReadOnly ? View.GONE : View.VISIBLE}" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/emojis_background"
|
||||
|
|
@ -36,13 +42,16 @@
|
|||
android:layout_height="60dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:src="@drawable/shape_squircle_white_background"
|
||||
app:layout_constraintVertical_bias="1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/guideline"
|
||||
app:layout_constraintBottom_toBottomOf="@id/thumbs_up"/>
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/bubble"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/thumbs_up"
|
||||
android:onClick="@{() -> model.sendReaction(@string/emoji_thumbs_up)}"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -58,6 +67,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/love"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/love"
|
||||
android:onClick="@{() -> model.sendReaction(@string/emoji_love)}"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -71,6 +81,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/laughing"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/laughing"
|
||||
android:onClick="@{() -> model.sendReaction(@string/emoji_laughing)}"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -84,6 +95,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/surprised"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/surprised"
|
||||
android:onClick="@{() -> model.sendReaction(@string/emoji_surprised)}"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -97,6 +109,7 @@
|
|||
app:layout_constraintEnd_toStartOf="@id/tear"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/tear"
|
||||
android:onClick="@{() -> model.sendReaction(@string/emoji_tear)}"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
@ -128,14 +141,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
app:layout_constrainedWidth="true"
|
||||
app:layout_constrainedHeight="true"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintVertical_bias="0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/emojis_background"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/reply"
|
||||
model="@{model}"
|
||||
layout="@layout/chat_bubble_incoming"/>
|
||||
|
|
@ -149,11 +157,13 @@
|
|||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:id="@+id/reply"
|
||||
android:onClick="@{replyClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/menu_reply_to_chat_message"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:enabled="@{!model.chatRoomIsReadOnly}"
|
||||
android:background="@drawable/menu_item_background"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/arrow_bend_up_left_bold"
|
||||
|
|
@ -162,12 +172,12 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:id="@+id/copy"
|
||||
android:onClick="@{copyClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/menu_copy_chat_message"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:background="@drawable/menu_item_background"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/copy"
|
||||
|
|
@ -176,11 +186,12 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:id="@+id/forward"
|
||||
android:onClick="@{forwardClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/menu_forward_chat_message"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:background="@drawable/menu_item_background"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/arrow_bend_up_right_bold"
|
||||
|
|
@ -189,12 +200,12 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/context_menu_danger_action_label_style"
|
||||
android:id="@+id/delete"
|
||||
android:onClick="@{deleteClickListener}"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/menu_delete_selected_item"
|
||||
style="@style/context_menu_danger_action_label_style"
|
||||
android:background="@drawable/menu_item_background"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/trash_simple"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue