mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
WIP Editing
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
0041fb3b71
commit
8cd0983088
3 changed files with 38 additions and 2 deletions
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue