Migrate Java parts to Kotlin

Also fixing some detekt issues.

Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
Tim Krüger 2022-06-01 12:12:38 +02:00 committed by Andy Scherzinger (Rebase PR Action)
parent 6f5492bf74
commit 26c2c0065b
2 changed files with 34 additions and 32 deletions

View file

@ -102,23 +102,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
binding.messageQuote.quotedChatMessageView.visibility = View.GONE binding.messageQuote.quotedChatMessageView.visibility = View.GONE
} }
val readStatusDrawableInt = when (message.readStatus) { readStatusDrawableInt(message)?.let { drawableInt ->
ReadStatus.READ -> R.drawable.ic_check_all
ReadStatus.SENT -> R.drawable.ic_check
ReadStatus.SENDING -> R.drawable.ic_sending
ReadStatus.FAILED -> R.drawable.ic_warning_white
else -> null
}
val readStatusContentDescriptionString = when (message.readStatus) {
ReadStatus.READ -> context?.resources?.getString(R.string.nc_message_read)
ReadStatus.SENT -> context?.resources?.getString(R.string.nc_message_sent)
ReadStatus.SENDING -> context?.resources?.getString(R.string.nc_message_sending)
ReadStatus.FAILED -> context?.resources?.getString(R.string.nc_message_send_error)
else -> null
}
readStatusDrawableInt?.let { drawableInt ->
ResourcesCompat.getDrawable(context!!.resources, drawableInt, null)?.let { ResourcesCompat.getDrawable(context!!.resources, drawableInt, null)?.let {
binding.checkMark.setImageDrawable(it) binding.checkMark.setImageDrawable(it)
binding.checkMark.setColorFilter( binding.checkMark.setColorFilter(
@ -127,7 +111,7 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
} }
} }
binding.checkMark.setContentDescription(readStatusContentDescriptionString) binding.checkMark.setContentDescription(readStatusContentDescriptionString(message))
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable) itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
@ -150,6 +134,24 @@ class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewH
commonMessageInterface.onClickReaction(chatMessage, emoji) commonMessageInterface.onClickReaction(chatMessage, emoji)
} }
private fun readStatusContentDescriptionString(message: ChatMessage) =
when (message.readStatus) {
ReadStatus.READ -> context?.resources?.getString(R.string.nc_message_read)
ReadStatus.SENT -> context?.resources?.getString(R.string.nc_message_sent)
ReadStatus.SENDING -> context?.resources?.getString(R.string.nc_message_sending)
ReadStatus.FAILED -> context?.resources?.getString(R.string.nc_message_send_error)
else -> null
}
private fun readStatusDrawableInt(message: ChatMessage) =
when (message.readStatus) {
ReadStatus.READ -> R.drawable.ic_check_all
ReadStatus.SENT -> R.drawable.ic_check
ReadStatus.SENDING -> R.drawable.ic_sending
ReadStatus.FAILED -> R.drawable.ic_warning_white
else -> null
}
private fun processParentMessage(message: ChatMessage) { private fun processParentMessage(message: ChatMessage) {
val parentChatMessage = message.parentMessage val parentChatMessage = message.parentMessage
val textColor = viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant val textColor = viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant

View file

@ -2128,7 +2128,6 @@ class ChatController(args: Bundle) :
messObj.timestamp = tsLong messObj.timestamp = tsLong
messObj.jsonMessageId = 0 - tsLong.toInt() messObj.jsonMessageId = 0 - tsLong.toInt()
messObj.readStatus = ReadStatus.SENDING messObj.readStatus = ReadStatus.SENDING
if (conversationUser!!.userId != "?") { if (conversationUser!!.userId != "?") {
@ -3046,11 +3045,12 @@ class ChatController(args: Bundle) :
fun replyPrivately(message: IMessage?) { fun replyPrivately(message: IMessage?) {
val apiVersion = val apiVersion =
ApiUtils.getConversationApiVersion( ApiUtils.getConversationApiVersion(
conversationUser, intArrayOf( conversationUser,
ApiUtils.APIv4, intArrayOf(
1 ApiUtils.APIv4,
) 1
) )
)
val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom( val retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(
apiVersion, apiVersion,
conversationUser?.baseUrl, conversationUser?.baseUrl,
@ -3108,20 +3108,20 @@ class ChatController(args: Bundle) :
) )
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
Log.e(TAG, e.message, e) Log.e(TAG, e.message, e)
} }
override fun onComplete() {// unused atm override fun onComplete() { // unused atm
} }
}) })
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
Log.e(TAG, e.message, e) Log.e(TAG, e.message, e)
} }
override fun onComplete() { override fun onComplete() {
// unused atm // unused atm
} }
}) })