Commit 40004009 authored by Shailesh Baldaniya's avatar Shailesh Baldaniya

fix: Errors after cherrypick

parent 8266b7d2
...@@ -2,17 +2,19 @@ package chat.rocket.android.chatroom.adapter ...@@ -2,17 +2,19 @@ package chat.rocket.android.chatroom.adapter
import android.app.AlertDialog import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.net.Uri
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import android.view.MenuItem import android.view.MenuItem
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.Toast
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.res.ResourcesCompat
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.chatroom.presentation.ChatRoomPresenter import chat.rocket.android.chatroom.presentation.ChatRoomPresenter
import chat.rocket.android.chatroom.uimodel.* import chat.rocket.android.chatroom.uimodel.*
import chat.rocket.android.customtab.CustomTab
import chat.rocket.android.customtab.WebViewFallback
import chat.rocket.android.util.extensions.inflate import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.emoji.EmojiReactionListener import chat.rocket.android.emoji.EmojiReactionListener
import chat.rocket.android.helper.ToastHelper import chat.rocket.android.util.extensions.openTabbedUrl
import chat.rocket.core.model.attachment.actions.Action import chat.rocket.core.model.attachment.actions.Action
import chat.rocket.core.model.attachment.actions.ButtonAction import chat.rocket.core.model.attachment.actions.ButtonAction
import chat.rocket.core.model.Message import chat.rocket.core.model.Message
...@@ -222,10 +224,19 @@ class ChatRoomAdapter( ...@@ -222,10 +224,19 @@ class ChatRoomAdapter(
if (temp.url != null && temp.isWebView != null) { if (temp.url != null && temp.isWebView != null) {
if (temp.isWebView!!) { if (temp.isWebView!!) {
//Open in a configurable sizable webview //Open in a configurable sizable webview
ToastHelper.showCustomToast(this@ChatRoomAdapter.context, "Open in a configurable sizable webview") Toast.makeText(context, "Open in a configurable sizable webview", Toast.LENGTH_SHORT).show()
} else { } else {
//Open in chrome custom tab //Open in chrome custom tab
CustomTab.openCustomTab(this@ChatRoomAdapter.context!!, temp.url!!, WebViewFallback()) with(this) {
val customTabsBuilder = CustomTabsIntent.Builder()
customTabsBuilder.setToolbarColor(ResourcesCompat.getColor(context!!.resources, R.color.colorPrimary, context.theme))
val customTabsIntent = customTabsBuilder.build()
try {
customTabsIntent.launchUrl(context, Uri.parse(temp.url!!))
} catch (ex: Exception) {
Timber.d(ex, "Unable to launch URL")
}
}
} }
} else if (temp.message != null && temp.isMessageInChatWindow != null) { } else if (temp.message != null && temp.isMessageInChatWindow != null) {
if (temp.isMessageInChatWindow!!) { if (temp.isMessageInChatWindow!!) {
...@@ -237,7 +248,7 @@ class ChatRoomAdapter( ...@@ -237,7 +248,7 @@ class ChatRoomAdapter(
} }
} else { } else {
//Send to bot but not in chat window //Send to bot but not in chat window
ToastHelper.showCustomToast(this@ChatRoomAdapter.context, "Send to bot but not in chat window") Toast.makeText(context, "Send to bot but not in chat window", Toast.LENGTH_SHORT).show()
} }
} }
} }
......
...@@ -15,7 +15,11 @@ data class ActionsAttachmentUiModel( ...@@ -15,7 +15,11 @@ data class ActionsAttachmentUiModel(
override var reactions: List<ReactionUiModel>, override var reactions: List<ReactionUiModel>,
override var nextDownStreamMessage: BaseUiModel<*>? = null, override var nextDownStreamMessage: BaseUiModel<*>? = null,
override var preview: Message? = null, override var preview: Message? = null,
override var isTemporary: Boolean = false override var isTemporary: Boolean = false,
override var unread: Boolean? = null,
override var menuItemsToHide: MutableList<Int> = mutableListOf(),
override var currentDayMarkerText: String,
override var showDayMarker: Boolean
) : BaseAttachmentUiModel<ActionsAttachment> { ) : BaseAttachmentUiModel<ActionsAttachment> {
override val viewType: Int override val viewType: Int
get() = BaseUiModel.ViewType.ACTIONS_ATTACHMENT.viewType get() = BaseUiModel.ViewType.ACTIONS_ATTACHMENT.viewType
......
...@@ -315,10 +315,14 @@ class UiModelMapper @Inject constructor( ...@@ -315,10 +315,14 @@ class UiModelMapper @Inject constructor(
return with(attachment) { return with(attachment) {
val content = stripMessageQuotes(message) val content = stripMessageQuotes(message)
val localDateTime = DateTimeHelper.getLocalDateTime(message.timestamp)
val dayMarkerText = DateTimeHelper.getFormattedDateForMessages(localDateTime, context)
ActionsAttachmentUiModel(attachmentUrl = url, title = title, ActionsAttachmentUiModel(attachmentUrl = url, title = title,
actions = actions, message = message, rawData = attachment, actions = actions, message = message, rawData = attachment,
messageId = message.id, reactions = getReactions(message), messageId = message.id, reactions = getReactions(message),
preview = message.copy(message = content.message)) preview = message.copy(message = content.message), unread = message.unread,
showDayMarker = false, currentDayMarkerText = dayMarkerText)
} }
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
style="@style/Widget.MaterialComponents.Button" style="@style/Widget.MaterialComponents.Button"
android:id="@+id/action_button" android:id="@+id/action_button"
android:textSize="12sp" android:textSize="12sp"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment