More work on the new chat view

This commit is contained in:
Mario Danic 2019-12-19 14:50:01 +01:00
parent 404f56d9a7
commit f559ef9a47
No known key found for this signature in database
GPG Key ID: CDE0BBD2738C4CC0
3 changed files with 41 additions and 14 deletions

View File

@ -126,7 +126,7 @@ class ChatController(args: Bundle) : BaseController(), MessagesListAdapter
@BindView(R.id.lobby_view)
@JvmField
var lobbyView: RelativeLayout? = null
@BindView(R.id.lobby_text_view)
@BindView(R.id.lobbyTextView)
@JvmField
var conversationLobbyText: TextView? = null
var roomToken: String? = null

View File

@ -33,10 +33,7 @@ import com.nextcloud.talk.newarch.local.models.getMaxMessageLength
import com.nextcloud.talk.newarch.mvvm.ext.initRecyclerView
import com.nextcloud.talk.newarch.utils.Images
import com.nextcloud.talk.presenters.MentionAutocompletePresenter
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.DisplayUtils
import com.nextcloud.talk.utils.DrawableUtils
import com.nextcloud.talk.utils.MagicCharPolicy
import com.nextcloud.talk.utils.*
import com.nextcloud.talk.utils.bundle.BundleKeys
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_CONVERSATION_PASSWORD
import com.nextcloud.talk.utils.text.Spans
@ -47,6 +44,7 @@ import com.stfalcon.chatkit.messages.MessagesListAdapter
import com.stfalcon.chatkit.utils.DateFormatter
import kotlinx.android.synthetic.main.controller_chat.view.*
import kotlinx.android.synthetic.main.controller_conversations_rv.view.*
import kotlinx.android.synthetic.main.lobby_view.view.*
import kotlinx.android.synthetic.main.view_message_input.view.*
import org.koin.android.ext.android.inject
import org.parceler.Parcels
@ -67,8 +65,8 @@ class ChatView : BaseView(), MessageHolders.ContentChecker<IMessage>, MessagesLi
private var newMessagesCount = 0
lateinit var recyclerViewAdapter: MessagesListAdapter<ChatMessage>
lateinit var mentionAutocomplete: Autocomplete<*>
private lateinit var recyclerViewAdapter: MessagesListAdapter<ChatMessage>
private lateinit var mentionAutocomplete: Autocomplete<*>
override fun onCreateView(
inflater: LayoutInflater,
@ -80,15 +78,45 @@ class ChatView : BaseView(), MessageHolders.ContentChecker<IMessage>, MessagesLi
viewModel.init(args.getParcelable(BundleKeys.KEY_USER_ENTITY)!!, args.getString(BundleKeys.KEY_ROOM_TOKEN)!!, args.getString(KEY_CONVERSATION_PASSWORD))
viewModel.apply {
conversation.observe(this@ChatView) { value ->
conversation.observe(this@ChatView) { conversation ->
setTitle()
setupAdapter()
if (Conversation.ConversationType.ONE_TO_ONE_CONVERSATION == value?.type) {
if (Conversation.ConversationType.ONE_TO_ONE_CONVERSATION == conversation?.type) {
loadAvatar()
} else {
actionBar?.setIcon(null)
}
val shouldShowLobby = conversation!!.shouldShowLobby(user)
val isReadOnlyConversation = conversation.conversationReadOnlyState == Conversation.ConversationReadOnlyState.CONVERSATION_READ_ONLY
if (shouldShowLobby) {
view?.messagesListView?.visibility = View.GONE
view?.messageInputView?.visibility = View.GONE
view?.lobbyView?.visibility = View.VISIBLE
val timer = conversation.lobbyTimer
if (timer != null && timer != 0L) {
view?.lobbyTextView?.text = String.format(
resources!!.getString(R.string.nc_lobby_waiting_with_date),
DateUtils.getLocalDateStringFromTimestampForLobby(
conversation.lobbyTimer!!
))
} else {
view?.lobbyTextView?.setText(R.string.nc_lobby_waiting)
}
} else {
view?.messagesListView?.visibility = View.GONE
view?.lobbyView?.visibility = View.GONE
if (isReadOnlyConversation) {
view?.messageInputView?.visibility = View.GONE
} else {
view?.messageInputView?.visibility = View.VISIBLE
}
}
}
}
return super.onCreateView(inflater, container)
@ -358,7 +386,6 @@ class ChatView : BaseView(), MessageHolders.ContentChecker<IMessage>, MessagesLi
val needsAuthBasedOnUrl = url.contains("index.php/core/preview?fileId=") || url.contains("index.php/avatar/")
if (url.startsWith(viewModel.user.baseUrl) && needsAuthBasedOnUrl) {
addHeader("Authorization", viewModel.user.getCredentials())
}
}
})

View File

@ -19,23 +19,23 @@
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/lobby_view"
android:id="@+id/lobbyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_default">
<ImageView
android:id="@+id/lobby_image_view"
android:id="@+id/lobbyImageView"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_above="@id/lobby_text_view"
android:layout_above="@id/lobbyTextView"
android:layout_centerHorizontal="true"
android:layout_margin="@dimen/margin_between_elements"
android:src="@drawable/ic_room_service_black_24dp"
android:tint="@color/grey_600" />
<TextView
android:id="@+id/lobby_text_view"
android:id="@+id/lobbyTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"