mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-07 06:39:45 +00:00
works okay (no resend logic yet, offline message mode not reworked)
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
e1c1574d6c
commit
3f5f2f024a
@ -14,6 +14,7 @@ import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
@ -23,6 +24,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.chat.data.model.ChatMessage
|
||||
import com.nextcloud.talk.data.network.NetworkMonitor
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingTextMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||
@ -58,6 +60,9 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
@Inject
|
||||
lateinit var dateUtils: DateUtils
|
||||
|
||||
@Inject
|
||||
lateinit var networkMonitor: NetworkMonitor
|
||||
|
||||
lateinit var commonMessageInterface: CommonMessageInterface
|
||||
|
||||
override fun onBind(message: ChatMessage) {
|
||||
@ -115,18 +120,25 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
}
|
||||
|
||||
|
||||
when (message.readStatus) {
|
||||
ReadStatus.READ -> updateReadStatus(R.drawable.ic_check_all, context.resources?.getString(R.string.nc_message_read))
|
||||
ReadStatus.SENT -> updateReadStatus(R.drawable.ic_check, context.resources?.getString(R.string.nc_message_sent))
|
||||
ReadStatus.SENDING -> updateSendingStatus()
|
||||
ReadStatus.FAILED -> updateReadStatus(
|
||||
R.drawable.ic_baseline_close_24,
|
||||
"failed"
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
// CoroutineScope(Dispatchers.Main).launch {
|
||||
if (message.sendingFailed) {
|
||||
updateStatus(
|
||||
R.drawable.baseline_report_problem_24,
|
||||
"failed"
|
||||
)
|
||||
// } else if (message.isTempMessage && !networkMonitor.isOnline.first()) {
|
||||
// updateStatus(
|
||||
// R.drawable.ic_signal_wifi_off_white_24dp,
|
||||
// "offline"
|
||||
// )
|
||||
} else if (message.isTempMessage) {
|
||||
updateSendingStatus()
|
||||
} else if(message.readStatus == ReadStatus.READ){
|
||||
updateStatus(R.drawable.ic_check_all, context.resources?.getString(R.string.nc_message_read))
|
||||
} else if(message.readStatus == ReadStatus.SENT) {
|
||||
updateStatus(R.drawable.ic_check, context.resources?.getString(R.string.nc_message_sent))
|
||||
}
|
||||
// }
|
||||
|
||||
itemView.setTag(R.string.replyable_message_view_tag, message.replyable)
|
||||
|
||||
@ -141,7 +153,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateReadStatus(readStatusDrawableInt: Int, description: String?) {
|
||||
private fun updateStatus(readStatusDrawableInt: Int, description: String?) {
|
||||
binding.sendingProgress.visibility = View.GONE
|
||||
binding.checkMark.visibility = View.VISIBLE
|
||||
readStatusDrawableInt.let { drawableInt ->
|
||||
|
@ -13,6 +13,7 @@ import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.core.view.isVisible
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.nextcloud.android.common.ui.theme.utils.ColorRole
|
||||
@ -58,6 +59,14 @@ class TemporaryMessageViewHolder(outgoingView: View, payload: Any) :
|
||||
viewThemeUtils.platform.colorImageView(binding.tempMsgEdit, ColorRole.PRIMARY)
|
||||
viewThemeUtils.platform.colorImageView(binding.tempMsgDelete, ColorRole.PRIMARY)
|
||||
|
||||
binding.bubble.setOnClickListener {
|
||||
if (binding.tempMsgActions.isVisible) {
|
||||
binding.tempMsgActions.visibility = View.GONE
|
||||
} else {
|
||||
binding.tempMsgActions.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
binding.tempMsgEdit.setOnClickListener {
|
||||
isEditing = !isEditing
|
||||
if (isEditing) {
|
||||
|
@ -2934,12 +2934,7 @@ class ChatActivity :
|
||||
) {
|
||||
if (message.item is ChatMessage) {
|
||||
val chatMessage = message.item as ChatMessage
|
||||
|
||||
if (chatMessage.sendingFailed) {
|
||||
chatMessage.readStatus = ReadStatus.FAILED
|
||||
} else if (chatMessage.isTempMessage) {
|
||||
chatMessage.readStatus = ReadStatus.SENDING
|
||||
} else if (chatMessage.jsonMessageId <= xChatLastCommonRead) {
|
||||
if (chatMessage.jsonMessageId <= xChatLastCommonRead) {
|
||||
chatMessage.readStatus = ReadStatus.READ
|
||||
} else {
|
||||
chatMessage.readStatus = ReadStatus.SENT
|
||||
@ -3870,6 +3865,7 @@ class ChatActivity :
|
||||
CONTENT_TYPE_UNREAD_NOTICE_MESSAGE -> message.id == UNREAD_MESSAGES_MARKER_ID.toString()
|
||||
CONTENT_TYPE_CALL_STARTED -> message.id == "-2"
|
||||
CONTENT_TYPE_TEMP -> message.id == TEMPORARY_MESSAGE_ID_STRING
|
||||
// CONTENT_TYPE_TEMP -> message.readStatus == ReadStatus.FAILED
|
||||
CONTENT_TYPE_DECK_CARD -> message.isDeckCard()
|
||||
|
||||
else -> false
|
||||
|
@ -52,6 +52,7 @@ data class ChatMessageEntity(
|
||||
@ColumnInfo(name = "deleted") var deleted: Boolean = false,
|
||||
@ColumnInfo(name = "expirationTimestamp") var expirationTimestamp: Int = 0,
|
||||
@ColumnInfo(name = "isReplyable") var replyable: Boolean = false,
|
||||
@ColumnInfo(name = "isTemporary") var isTemporary: Boolean = false,
|
||||
@ColumnInfo(name = "lastEditActorDisplayName") var lastEditActorDisplayName: String? = null,
|
||||
@ColumnInfo(name = "lastEditActorId") var lastEditActorId: String? = null,
|
||||
@ColumnInfo(name = "lastEditActorType") var lastEditActorType: String? = null,
|
||||
@ -63,9 +64,8 @@ data class ChatMessageEntity(
|
||||
@ColumnInfo(name = "reactions") var reactions: LinkedHashMap<String, Int>? = null,
|
||||
@ColumnInfo(name = "reactionsSelf") var reactionsSelf: ArrayList<String>? = null,
|
||||
@ColumnInfo(name = "referenceId") var referenceId: String? = null,
|
||||
@ColumnInfo(name = "sendingFailed") var sendingFailed: Boolean = false,
|
||||
@ColumnInfo(name = "systemMessage") var systemMessageType: ChatMessage.SystemMessageType,
|
||||
@ColumnInfo(name = "timestamp") var timestamp: Long = 0,
|
||||
@ColumnInfo(name = "isTemporary") var isTemporary: Boolean = false,
|
||||
@ColumnInfo(name = "sendingFailed") var sendingFailed: Boolean = false,
|
||||
// missing/not needed: silent
|
||||
)
|
||||
|
5
app/src/main/res/drawable/baseline_replay_24.xml
Normal file
5
app/src/main/res/drawable/baseline_replay_24.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:tint="#000000" android:viewportWidth="24" android:viewportHeight="24">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,5V1L7,6l5,5V7c3.31,0 6,2.69 6,6s-2.69,6 -6,6 -6,-2.69 -6,-6H4c0,4.42 3.58,8 8,8s8,-3.58 8,-8 -3.58,-8 -8,-8z"/>
|
||||
|
||||
</vector>
|
5
app/src/main/res/drawable/baseline_report_problem_24.xml
Normal file
5
app/src/main/res/drawable/baseline_report_problem_24.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:tint="#000000" android:viewportWidth="24" android:viewportHeight="24">
|
||||
|
||||
<path android:fillColor="@android:color/white" android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
|
||||
|
||||
</vector>
|
@ -16,6 +16,42 @@
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginBottom="2dp">
|
||||
|
||||
<!-- <LinearLayout-->
|
||||
<!-- android:id="@+id/temp_msg_actions"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:orientation="horizontal"-->
|
||||
<!-- android:layout_below="@id/bubble"-->
|
||||
<!-- android:layout_alignParentEnd="true">-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/temp_msg_edit"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:contentDescription="@null"-->
|
||||
<!-- android:src="@drawable/ic_edit"-->
|
||||
<!-- android:paddingHorizontal="@dimen/standard_half_padding"-->
|
||||
<!-- android:layout_marginEnd="@dimen/standard_quarter_margin" />-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/temp_msg_delete"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:contentDescription="@null"-->
|
||||
<!-- android:src="@drawable/ic_delete"-->
|
||||
<!-- android:paddingHorizontal="@dimen/standard_half_padding"-->
|
||||
<!-- android:layout_marginStart="@dimen/standard_quarter_margin" />-->
|
||||
|
||||
<!-- <ImageView-->
|
||||
<!-- android:id="@+id/temp_msg_resend"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:contentDescription="@null"-->
|
||||
<!-- android:src="@drawable/baseline_replay_24"-->
|
||||
<!-- android:paddingHorizontal="@dimen/standard_half_padding"-->
|
||||
<!-- android:layout_marginStart="@dimen/standard_quarter_margin" />-->
|
||||
<!-- </LinearLayout>-->
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:id="@id/bubble"
|
||||
android:layout_width="wrap_content"
|
||||
@ -43,6 +79,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"-->
|
||||
<!-- tools:visibility="visible"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@id/messageTime"
|
||||
@ -76,13 +118,14 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/checkMark"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="@dimen/message_bubble_checkmark_height"
|
||||
android:layout_below="@id/messageTime"
|
||||
android:layout_marginStart="8dp"
|
||||
android:contentDescription="@null"
|
||||
app:layout_alignSelf="center"
|
||||
app:tint="@color/high_emphasis_text" />
|
||||
app:tint="@color/high_emphasis_text"
|
||||
tools:src="@drawable/ic_check_all" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sending_failed"
|
||||
@ -92,14 +135,16 @@
|
||||
android:layout_marginStart="8dp"
|
||||
android:contentDescription="@null"
|
||||
app:layout_alignSelf="center"
|
||||
app:tint="@color/high_emphasis_text" />
|
||||
app:tint="@color/high_emphasis_text"
|
||||
tools:src="@drawable/ic_warning_white"/>
|
||||
|
||||
<com.google.android.material.progressindicator.CircularProgressIndicator
|
||||
android:id="@+id/sending_progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="@dimen/message_bubble_checkmark_height"
|
||||
android:layout_below="@id/messageTime"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:contentDescription="@null"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"
|
||||
|
@ -16,10 +16,12 @@
|
||||
android:layout_marginBottom="2dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/temp_msg_actions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_centerVertical="true">
|
||||
android:layout_below="@id/bubble"
|
||||
android:layout_alignParentEnd="true">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/temp_msg_edit"
|
||||
@ -38,6 +40,15 @@
|
||||
android:src="@drawable/ic_delete"
|
||||
android:paddingHorizontal="@dimen/standard_half_padding"
|
||||
android:layout_marginStart="@dimen/standard_quarter_margin" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/temp_msg_resend"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/standard_quarter_margin"
|
||||
android:contentDescription="@null"
|
||||
android:paddingHorizontal="@dimen/standard_half_padding"
|
||||
android:src="@drawable/baseline_replay_24" />
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
@ -55,7 +66,7 @@
|
||||
android:id="@+id/message_quote"
|
||||
layout="@layout/item_message_quote"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
tools:visibility="gone"/>
|
||||
|
||||
<androidx.emoji2.widget.EmojiTextView
|
||||
android:id="@id/messageText"
|
||||
@ -71,7 +82,8 @@
|
||||
android:id="@+id/message_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user