Skip to content

Commit

Permalink
works okay (no resend logic yet, offline message mode not reworked)
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Hibbe <[email protected]>
  • Loading branch information
mahibi committed Dec 11, 2024
1 parent 9e5634a commit 3758641
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -116,18 +121,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)

Expand All @@ -142,7 +154,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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 2 additions & 6 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2724,12 +2724,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
Expand Down Expand Up @@ -3640,6 +3635,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_replay_24.xml
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_report_problem_24.xml
Original file line number Diff line number Diff line change
@@ -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>
53 changes: 49 additions & 4 deletions app/src/main/res/layout/item_custom_outcoming_text_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down
18 changes: 15 additions & 3 deletions app/src/main/res/layout/item_temporary_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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>
Expand Down

0 comments on commit 3758641

Please sign in to comment.