WIP Editing

Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
rapterjet2004 2024-09-27 09:20:11 -05:00 committed by Marcel Hibbe
parent 0041fb3b71
commit 8cd0983088
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
3 changed files with 38 additions and 2 deletions

View file

@ -7,6 +7,7 @@
package com.nextcloud.talk.adapters.messages
import android.content.Context
import android.view.View
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.ViewCompat
@ -30,7 +31,11 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@Inject
lateinit var context: Context
lateinit var temporaryMessageInterface: TemporaryMessageInterface
var isEditing = false
override fun onBind(message: ChatMessage) {
super.onBind(message)
@ -40,7 +45,32 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
viewThemeUtils.platform.colorImageView(binding.tempMsgDelete, ColorRole.PRIMARY)
binding.tempMsgEdit.setOnClickListener {
// TODO
isEditing = !isEditing
if (isEditing) {
binding.tempMsgEdit.setImageDrawable(
ResourcesCompat.getDrawable(
context.resources,
R.drawable.ic_check,
null
)
)
binding.messageEdit.visibility = View.VISIBLE
binding.messageEdit.setText(binding.messageText.text)
binding.messageText.visibility = View.GONE
} else {
binding.tempMsgEdit.setImageDrawable(
ResourcesCompat.getDrawable(
context.resources,
R.drawable.ic_edit,
null
)
)
binding.messageEdit.visibility = View.GONE
binding.messageText.visibility = View.VISIBLE
val newMessage = binding.messageEdit.text.toString()
message.message = newMessage
temporaryMessageInterface.editTemporaryMessage(message.tempMessageId, newMessage)
}
}
binding.tempMsgDelete.setOnClickListener {

View file

@ -3666,7 +3666,7 @@ class ChatActivity :
}
override fun editTemporaryMessage(id: Int, newMessage: String) {
// TODO("Not yet implemented")
// TODO update adapter item and call viewModel to persist data
}
override fun deleteTemporaryMessage(id: Int) {

View file

@ -65,6 +65,12 @@
android:textIsSelectable="false"
tools:text="Talk to you later!" />
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/message_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</com.google.android.flexbox.FlexboxLayout>
</RelativeLayout>