Added date to editor details and changes related to design.

Signed-off-by: Sowjanya Kota<sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-02-14 16:03:48 +01:00
parent 8d4c0fb57c
commit 861b565c01
9 changed files with 49 additions and 46 deletions

View File

@ -114,10 +114,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
binding.messageText.text = processedMessageText
if (message.lastEditTimestamp != 0L && !message.isDeleted) {
binding.messageType.visibility = View.VISIBLE
binding.messageEditIndicator.visibility = View.VISIBLE
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.lastEditTimestamp)
} else {
binding.messageType.visibility = View.GONE
binding.messageEditIndicator.visibility = View.GONE
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
}

View File

@ -105,10 +105,10 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
binding.messageText.text = processedMessageText
if (message.lastEditTimestamp != 0L && !message.isDeleted) {
binding.messageType.visibility = View.VISIBLE
binding.messageEditIndicator.visibility = View.VISIBLE
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.lastEditTimestamp)
} else {
binding.messageType.visibility = View.GONE
binding.messageEditIndicator.visibility = View.GONE
binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp)
}

View File

@ -531,8 +531,6 @@ class ChatActivity :
context.getSharedPreferences(localClassName, MODE_PRIVATE).apply {
val text = getString(roomToken, "")
val cursor = getInt(roomToken + CURSOR_KEY, 0)
// val editFlag = getBoolean(EDIT_FLAG, false)
// editableBehaviorSubject.onNext(editFlag)
binding.messageInputView.messageInput.setText(text)
binding.messageInputView.messageInput.setSelection(cursor)
}
@ -559,7 +557,6 @@ class ChatActivity :
context.getSharedPreferences(localClassName, MODE_PRIVATE).edit().apply {
putString(roomToken, text)
putInt(roomToken + CURSOR_KEY, cursor)
// putBoolean(EDIT_FLAG, editableBehaviorSubject.value!!)
apply()
}
}
@ -763,13 +760,13 @@ class ChatActivity :
val filters = arrayOfNulls<InputFilter>(1)
val lengthFilter = CapabilitiesUtilNew.getMessageMaxLength(conversationUser)
binding.editView.editMessageView.visibility = View.GONE
if (editableBehaviorSubject.value!!) {
val editableText = Editable.Factory.getInstance().newEditable(editMessage.message)
binding.messageInputView.inputEditText.text = editableText
binding.messageInputView.inputEditText.setSelection(editableText.length)
binding.editView.editMessage.setText(editMessage.message)
} else {
binding.editView.editMessageView.visibility = View.GONE
}
filters[0] = InputFilter.LengthFilter(lengthFilter)
@ -918,14 +915,12 @@ class ChatActivity :
).show()
}
}
message.message = messageEdited.ocs?.data?.parentMessage?.text
message.lastEditTimestamp = messageEdited.ocs?.data?.lastEditTimestamp!!
adapter?.update(message)
adapter?.notifyDataSetChanged()
clearEditUI()
}
override fun onError(e: Throwable) {
Log.e(TAG, "failed to edit message", e)
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
}
override fun onComplete() {
@ -990,6 +985,9 @@ class ChatActivity :
binding.messageInputView.findViewById<ImageView>(R.id.editMessageButton)?.let {
viewThemeUtils.platform.colorImageView(it, ColorRole.PRIMARY)
}
binding.editView.clearEdit.let {
viewThemeUtils.platform.colorImageView(it, ColorRole.PRIMARY)
}
}
private fun setupActionBar() {
@ -4837,6 +4835,5 @@ class ChatActivity :
private const val MILISEC_15: Long = 15
private const val LINEBREAK = "\n"
private const val CURSOR_KEY = "_cursor"
private const val EDIT_FLAG = "_editFlag"
}
}

View File

@ -51,6 +51,7 @@ import com.nextcloud.talk.repositories.reactions.ReactionsRepository
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.ConversationUtils
import com.nextcloud.talk.utils.DateConstants
import com.nextcloud.talk.utils.DateUtils
import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew
import com.vanniktech.emoji.EmojiPopup
@ -93,12 +94,9 @@ class MessageActionsDialog(
private val messageHasRegularText = ChatMessage.MessageType.REGULAR_TEXT_MESSAGE == message
.getCalculateMessageType() && !message.isDeleted
private val isOlderThanTwentyFourHours = message.createdAt.before(
Date(
System.currentTimeMillis() -
AGE_THRESHOLD_FOR_EDIT_MESSAGE
)
)
private val isOlderThanTwentyFourHours = message
.createdAt
.before(Date(System.currentTimeMillis() - AGE_THRESHOLD_FOR_EDIT_MESSAGE))
private val isUserAllowedToEdit = chatActivity.userAllowedByPrivilages(message)
@ -375,7 +373,11 @@ class MessageActionsDialog(
private fun initMenuEditorDetails(showEditorDetails: Boolean) {
if (showEditorDetails) {
val editedTime = dateUtils.getLocalTimeStringFromTimestamp(message.lastEditTimestamp)
val editedTime = dateUtils.getLocalDateTimeStringFromTimestamp(
message.lastEditTimestamp *
DateConstants.SECOND_DIVIDER
)
val editorName = context.getString(R.string.nc_edited_by) + message.lastEditActorDisplayName
dialogMessageActionsBinding.editorName.setText(editorName)
dialogMessageActionsBinding.editedTime.setText(editedTime)

View File

@ -263,7 +263,9 @@
android:id="@+id/editView"
layout="@layout/edit_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"></include>
android:layout_height="wrap_content"
android:layout_marginEnd="6dp" >
</include>
<com.nextcloud.talk.ui.MessageInput
android:id="@+id/messageInputView"

View File

@ -141,26 +141,26 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding"
android:paddingStart="16dp"
android:paddingEnd="@dimen/standard_padding"
tools:text="@string/nc_edited_by_admin"
android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text"
android:maxLines="1"
android:ellipsize="end"
android:textSize="@dimen/bottom_sheet_text_size" />
android:textSize="15sp"
android:textColor = "@color/grey_600"/>
<TextView
android:id="@+id/edited_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:paddingStart="@dimen/standard_double_padding"
android:paddingStart="16dp"
android:paddingEnd="@dimen/standard_padding"
tools:text="12:30 AM"
android:textAlignment="viewStart"
android:textColor="@color/high_emphasis_text"
android:textSize="@dimen/bottom_sheet_text_size" />
android:textSize="15sp"
android:textColor ="@color/grey_600"/>
</LinearLayout>

View File

@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id = "@+id/edit_message_view"
android:id = "@+id/editMessageView"
android:orientation = "horizontal">
<ImageView
@ -52,8 +52,7 @@
android:layout_height="48dp"
android:padding = "12dp"
android:src = "@drawable/ic_clear_24"
android:gravity = "top|end"
app:tint="@color/colorPrimaryDark">
android:gravity = "top|end">
</ImageView>

View File

@ -95,11 +95,14 @@
<TextView
android:id="@+id/messageType"
android:id="@+id/messageEditIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
android:textIsSelectable="false"
app:layout_alignSelf="center"
android:text = "@string/hint_edited_message"
android:textSize="12sp">

View File

@ -73,6 +73,20 @@
app:layout_wrapBefore="false"
tools:text="10:35" />
<TextView
android:id="@+id/messageEditIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
android:textIsSelectable="false"
app:layout_alignSelf="center"
android:text = "@string/hint_edited_message"
android:textSize="12sp">
</TextView>
<ImageView
android:id="@+id/checkMark"
@ -84,20 +98,6 @@
app:layout_alignSelf="center"
app:tint="@color/high_emphasis_text" />
<TextView
android:id="@+id/messageType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
app:layout_alignSelf="center"
android:text = "@string/hint_edited_message"
android:textSize="12sp">
</TextView>
<include
android:id="@+id/reactions"
layout="@layout/reactions_inside_message" />