mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
Update Edit Message
This commit is contained in:
parent
7d4abf19a1
commit
eb27b7039f
@ -334,7 +334,8 @@ public interface NcApi {
|
|||||||
|
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@PUT
|
@PUT
|
||||||
Observable<ChatOCSSingleMessage> editChatMessage(@Header("Authorization") String authorization, @Url String url, @Field("message") String message);
|
Observable<ChatOverallSingleMessage> editChatMessage(@Header("Authorization") String authorization, @Url String url, @Field(
|
||||||
|
"message") String message);
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
Observable<Response<ChatShareOverall>> getSharedItems(@Header("Authorization") String authorization, @Url String url, @Query("objectType") String objectType, @Nullable @Query("lastKnownMessageId") Integer lastKnownMessageId, @Nullable @Query("limit") Integer limit);
|
Observable<Response<ChatShareOverall>> getSharedItems(@Header("Authorization") String authorization, @Url String url, @Query("objectType") String objectType, @Nullable @Query("lastKnownMessageId") Integer lastKnownMessageId, @Nullable @Query("limit") Integer limit);
|
||||||
|
@ -84,7 +84,6 @@ import android.widget.RelativeLayout.BELOW
|
|||||||
import android.widget.RelativeLayout.LayoutParams
|
import android.widget.RelativeLayout.LayoutParams
|
||||||
import android.widget.SeekBar
|
import android.widget.SeekBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.OnBackPressedCallback
|
import androidx.activity.OnBackPressedCallback
|
||||||
import androidx.appcompat.view.ContextThemeWrapper
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
@ -168,7 +167,6 @@ import com.nextcloud.talk.models.domain.ObjectType
|
|||||||
import com.nextcloud.talk.models.domain.ReactionAddedModel
|
import com.nextcloud.talk.models.domain.ReactionAddedModel
|
||||||
import com.nextcloud.talk.models.domain.ReactionDeletedModel
|
import com.nextcloud.talk.models.domain.ReactionDeletedModel
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOCSSingleMessage
|
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOverall
|
import com.nextcloud.talk.models.json.chat.ChatOverall
|
||||||
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
|
||||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||||
@ -762,12 +760,13 @@ class ChatActivity :
|
|||||||
private fun initMessageInputView() {
|
private fun initMessageInputView() {
|
||||||
val filters = arrayOfNulls<InputFilter>(1)
|
val filters = arrayOfNulls<InputFilter>(1)
|
||||||
val lengthFilter = CapabilitiesUtilNew.getMessageMaxLength(conversationUser)
|
val lengthFilter = CapabilitiesUtilNew.getMessageMaxLength(conversationUser)
|
||||||
|
binding.editView.editMessageView.visibility = GONE
|
||||||
|
|
||||||
if (editableBehaviorSubject.value!!) {
|
if (editableBehaviorSubject.value!!) {
|
||||||
val editableText = Editable.Factory.getInstance().newEditable(editMessage.message)
|
val editableText = Editable.Factory.getInstance().newEditable(editMessage.message)
|
||||||
binding.messageInputView.inputEditText.text = editableText
|
binding.messageInputView.inputEditText.text = editableText
|
||||||
binding.messageInputView.inputEditText.setSelection(editableText.length)
|
binding.messageInputView.inputEditText.setSelection(editableText.length)
|
||||||
|
binding.editView.editMessage.setText(editMessage.message)
|
||||||
}
|
}
|
||||||
|
|
||||||
filters[0] = InputFilter.LengthFilter(lengthFilter)
|
filters[0] = InputFilter.LengthFilter(lengthFilter)
|
||||||
@ -835,7 +834,7 @@ class ChatActivity :
|
|||||||
binding.messageInputView.messageSendButton.visibility = View.GONE
|
binding.messageInputView.messageSendButton.visibility = View.GONE
|
||||||
binding.messageInputView.recordAudioButton.visibility = View.GONE
|
binding.messageInputView.recordAudioButton.visibility = View.GONE
|
||||||
binding.messageInputView.editMessageButton.visibility = View.VISIBLE
|
binding.messageInputView.editMessageButton.visibility = View.VISIBLE
|
||||||
binding.messageInputView.clearEditMessage.visibility = View.VISIBLE
|
binding.editView.editMessageView.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sharedText.isNotEmpty()) {
|
if (sharedText.isNotEmpty()) {
|
||||||
@ -851,13 +850,13 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
binding.messageInputView.editMessageButton.setOnClickListener {
|
binding.messageInputView.editMessageButton.setOnClickListener {
|
||||||
if(editMessage.message == editedTextBehaviorSubject.value!!){
|
if (editMessage.message == editedTextBehaviorSubject.value!!) {
|
||||||
clearEditUI()
|
clearEditUI()
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
editMessageAPI(editMessage, editedMessageText = editedTextBehaviorSubject.value!!)
|
editMessageAPI(editMessage, editedMessageText = editedTextBehaviorSubject.value!!)
|
||||||
}
|
}
|
||||||
binding.messageInputView.clearEditMessage.setOnClickListener {
|
binding.editView.clearEdit.setOnClickListener {
|
||||||
clearEditUI()
|
clearEditUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,48 +888,33 @@ class ChatActivity :
|
|||||||
), editedMessageText
|
), editedMessageText
|
||||||
)?.subscribeOn(Schedulers.io())
|
)?.subscribeOn(Schedulers.io())
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
?.subscribe(object : Observer<ChatOCSSingleMessage> {
|
?.subscribe(object : Observer<ChatOverallSingleMessage> {
|
||||||
override fun onSubscribe(d: Disposable) {
|
override fun onSubscribe(d: Disposable) {
|
||||||
// unused atm
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(message: ChatOCSSingleMessage) {
|
override fun onNext(messageEdited: ChatOverallSingleMessage) {
|
||||||
//unused atm
|
message.message = messageEdited.ocs?.data?.parentMessage?.text
|
||||||
when(message.meta!!.statusCode){
|
adapter?.update(message)
|
||||||
HTTP_BAD_REQUEST -> {
|
adapter?.notifyDataSetChanged()
|
||||||
Toast.makeText(context,
|
clearEditUI()
|
||||||
getString(R.string.edit_error_24_hours_old_message),Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
HTTP_FORBIDDEN -> {
|
|
||||||
Toast.makeText(context,
|
|
||||||
getString(R.string.conversation_is_read_only),
|
|
||||||
Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
HTTP_NOT_FOUND -> {
|
|
||||||
Toast.makeText(context,
|
|
||||||
"Conversation Cannot be Found",
|
|
||||||
Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
clearEditUI()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearEditUI() {
|
private fun clearEditUI() {
|
||||||
binding.messageInputView.editMessageButton.visibility = GONE
|
binding.messageInputView.editMessageButton.visibility = GONE
|
||||||
binding.messageInputView.clearEditMessage.visibility = View.GONE
|
|
||||||
editableBehaviorSubject.onNext(false)
|
editableBehaviorSubject.onNext(false)
|
||||||
binding.messageInputView.inputEditText.setText("")
|
binding.messageInputView.inputEditText.setText("")
|
||||||
|
binding.editView.editMessageView.visibility = GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun themeMessageInputView() {
|
private fun themeMessageInputView() {
|
||||||
@ -1004,7 +988,7 @@ class ChatActivity :
|
|||||||
)
|
)
|
||||||
|
|
||||||
adapter?.setLoadMoreListener(this)
|
adapter?.setLoadMoreListener(this)
|
||||||
adapter?.setDateHeadersFormatter { format(it) }
|
adapter?.setDateHeadersFormatter {format(it)}
|
||||||
adapter?.setOnMessageViewLongClickListener { view, message -> onMessageViewLongClick(view, message) }
|
adapter?.setOnMessageViewLongClickListener { view, message -> onMessageViewLongClick(view, message) }
|
||||||
adapter?.registerViewClickListener(
|
adapter?.registerViewClickListener(
|
||||||
R.id.playPauseBtn
|
R.id.playPauseBtn
|
||||||
@ -3839,10 +3823,8 @@ class ChatActivity :
|
|||||||
} else if (isPollVotedMessage(currentMessage)) {
|
} else if (isPollVotedMessage(currentMessage)) {
|
||||||
// delete poll system messages
|
// delete poll system messages
|
||||||
chatMessageIterator.remove()
|
chatMessageIterator.remove()
|
||||||
}else if(isEditMessage(currentMessage)){
|
} else if (isEditMessage(currentMessage)) {
|
||||||
if (!chatMessageMap.containsKey(currentMessage.value.parentMessage!!.id)){
|
chatMessageIterator.remove()
|
||||||
chatMessageIterator.remove()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chatMessageMap.values.toList()
|
return chatMessageMap.values.toList()
|
||||||
@ -3883,7 +3865,7 @@ class ChatActivity :
|
|||||||
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION_REVOKED
|
currentMessage.value.systemMessageType == ChatMessage.SystemMessageType.REACTION_REVOKED
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isEditMessage(currentMessage:MutableMap.MutableEntry<String,ChatMessage>):Boolean{
|
private fun isEditMessage(currentMessage: MutableMap.MutableEntry<String, ChatMessage>): Boolean {
|
||||||
return currentMessage.value.parentMessage != null && currentMessage.value.systemMessageType == ChatMessage
|
return currentMessage.value.parentMessage != null && currentMessage.value.systemMessageType == ChatMessage
|
||||||
.SystemMessageType.MESSAGE_EDITED
|
.SystemMessageType.MESSAGE_EDITED
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ class MessageInput : MessageInput {
|
|||||||
lateinit var micInputCloud: MicInputCloud
|
lateinit var micInputCloud: MicInputCloud
|
||||||
lateinit var playPauseBtn: MaterialButton
|
lateinit var playPauseBtn: MaterialButton
|
||||||
lateinit var editMessageButton:ImageButton
|
lateinit var editMessageButton:ImageButton
|
||||||
lateinit var clearEditMessage:ImageButton
|
|
||||||
lateinit var seekBar: SeekBar
|
lateinit var seekBar: SeekBar
|
||||||
|
|
||||||
constructor(context: Context?) : super(context) {
|
constructor(context: Context?) : super(context) {
|
||||||
@ -72,7 +71,6 @@ class MessageInput : MessageInput {
|
|||||||
playPauseBtn = findViewById(R.id.playPauseBtn)
|
playPauseBtn = findViewById(R.id.playPauseBtn)
|
||||||
seekBar = findViewById(R.id.seekbar)
|
seekBar = findViewById(R.id.seekbar)
|
||||||
editMessageButton = findViewById(R.id.editMessageButton)
|
editMessageButton = findViewById(R.id.editMessageButton)
|
||||||
clearEditMessage = findViewById(R.id.clearEditButton)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var messageInput: EmojiEditText
|
var messageInput: EmojiEditText
|
||||||
|
@ -140,8 +140,8 @@
|
|||||||
android:id="@+id/messagesListView"
|
android:id="@+id/messagesListView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingBottom="20dp"
|
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
|
android:paddingBottom="20dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:dateHeaderTextSize="13sp"
|
app:dateHeaderTextSize="13sp"
|
||||||
app:incomingBubblePaddingBottom="@dimen/message_bubble_corners_vertical_padding"
|
app:incomingBubblePaddingBottom="@dimen/message_bubble_corners_vertical_padding"
|
||||||
@ -170,11 +170,10 @@
|
|||||||
app:outcomingTextSize="@dimen/chat_text_size"
|
app:outcomingTextSize="@dimen/chat_text_size"
|
||||||
app:outcomingTimeTextSize="12sp"
|
app:outcomingTimeTextSize="12sp"
|
||||||
app:textAutoLink="all"
|
app:textAutoLink="all"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<com.nextcloud.ui.popupbubble.PopupBubble
|
<com.nextcloud.ui.popupbubble.PopupBubble
|
||||||
android:id="@+id/popupBubbleView"
|
android:id="@+id/popupBubbleView"
|
||||||
android:theme="@style/Button.Primary"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignBottom="@id/typing_indicator_wrapper"
|
android:layout_alignBottom="@id/typing_indicator_wrapper"
|
||||||
@ -183,11 +182,12 @@
|
|||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginEnd="64dp"
|
android:layout_marginEnd="64dp"
|
||||||
android:layout_marginBottom="26dp"
|
android:layout_marginBottom="26dp"
|
||||||
android:minHeight="@dimen/min_size_clickable_area"
|
|
||||||
android:layout_toStartOf="@+id/scrollDownButton"
|
android:layout_toStartOf="@+id/scrollDownButton"
|
||||||
android:text="@string/nc_new_messages"
|
|
||||||
app:background="@color/colorPrimary"
|
|
||||||
android:ellipsize="middle"
|
android:ellipsize="middle"
|
||||||
|
android:minHeight="@dimen/min_size_clickable_area"
|
||||||
|
android:text="@string/nc_new_messages"
|
||||||
|
android:theme="@style/Button.Primary"
|
||||||
|
app:background="@color/colorPrimary"
|
||||||
app:cornerRadius="@dimen/button_corner_radius"
|
app:cornerRadius="@dimen/button_corner_radius"
|
||||||
app:icon="@drawable/ic_baseline_arrow_downward_24px" />
|
app:icon="@drawable/ic_baseline_arrow_downward_24px" />
|
||||||
|
|
||||||
@ -227,9 +227,9 @@
|
|||||||
android:id="@+id/typing_indicator_wrapper"
|
android:id="@+id/typing_indicator_wrapper"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_marginBottom="-19dp">
|
android:layout_marginBottom="-19dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/separator_1"
|
android:id="@+id/separator_1"
|
||||||
@ -241,15 +241,14 @@
|
|||||||
android:id="@+id/typing_indicator"
|
android:id="@+id/typing_indicator"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="2"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:layout_marginStart="@dimen/side_margin"
|
android:layout_marginStart="@dimen/side_margin"
|
||||||
android:layout_marginEnd="@dimen/side_margin"
|
android:layout_marginEnd="@dimen/side_margin"
|
||||||
android:background="@color/bg_default"
|
android:background="@color/bg_default"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
android:textColor="@color/low_emphasis_text"
|
android:textColor="@color/low_emphasis_text"
|
||||||
tools:text="Marcel is typing"
|
tools:ignore="Overdraw"
|
||||||
tools:ignore="Overdraw">
|
tools:text="Marcel is typing"></TextView>
|
||||||
</TextView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@ -259,12 +258,12 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<include
|
|
||||||
layout = "@layout/edit_message_view"
|
<include
|
||||||
android:layout_width = "match_parent"
|
android:id="@+id/editView"
|
||||||
android:layout_height = "wrap_content"
|
layout="@layout/edit_message_view"
|
||||||
android:layout_above = "@id/messageInputView">
|
android:layout_width="match_parent"
|
||||||
</include>
|
android:layout_height="wrap_content"></include>
|
||||||
|
|
||||||
<com.nextcloud.talk.ui.MessageInput
|
<com.nextcloud.talk.ui.MessageInput
|
||||||
android:id="@+id/messageInputView"
|
android:id="@+id/messageInputView"
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
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_height="wrap_content">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:id = "@+id/edit_message_view"
|
||||||
android:orientation = "horizontal">
|
android:orientation = "horizontal">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -34,7 +31,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textColor = "@color/colorPrimaryDark"
|
android:textColor = "@color/colorPrimaryDark"
|
||||||
android:text = "Edit Message">
|
android:text = "@string/nc_edit_message_text">
|
||||||
|
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
@ -61,4 +58,3 @@
|
|||||||
</ImageView>
|
</ImageView>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</merge>
|
|
@ -71,7 +71,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/quotedChatMessageView"
|
android:layout_below="@+id/quotedChatMessageView"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_toStartOf="@id/messageSendButton"
|
android:layout_marginEnd = "48dp"
|
||||||
android:layout_toEndOf="@id/smileyButton"
|
android:layout_toEndOf="@id/smileyButton"
|
||||||
android:imeOptions="actionDone"
|
android:imeOptions="actionDone"
|
||||||
android:inputType="textAutoCorrect|textMultiLine|textCapSentences"
|
android:inputType="textAutoCorrect|textMultiLine|textCapSentences"
|
||||||
@ -253,20 +253,6 @@
|
|||||||
tools:visibility = "visible"
|
tools:visibility = "visible"
|
||||||
android:contentDescription="@string/nc_send_edit_message" />
|
android:contentDescription="@string/nc_send_edit_message" />
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/clearEditButton"
|
|
||||||
android:layout_width="48dp"
|
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_below="@id/quotedChatMessageView"
|
|
||||||
android:layout_alignParentEnd="true"
|
|
||||||
android:layout_marginEnd="48dp"
|
|
||||||
android:background="@color/transparent"
|
|
||||||
android:contentDescription="@string/nc_clear_edit_message"
|
|
||||||
android:src="@drawable/ic_clear_24"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility = "visible"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/editMessageButton" />
|
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:id="@id/attachmentButtonSpace"
|
android:id="@id/attachmentButtonSpace"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -792,4 +792,5 @@ How to translate with transifex:
|
|||||||
<string name="nc_clear_edit_message">Clear Edit Message</string>
|
<string name="nc_clear_edit_message">Clear Edit Message</string>
|
||||||
<string name="edit_error_24_hours_old_message">Cannot Edit Messages older than 24 hours</string>
|
<string name="edit_error_24_hours_old_message">Cannot Edit Messages older than 24 hours</string>
|
||||||
<string name="conversation_is_read_only">Conversation is read Only</string>
|
<string name="conversation_is_read_only">Conversation is read Only</string>
|
||||||
|
<string name="nc_edit_message_text">Edit Message Text</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user