mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
- Fix remaining conflicts with develop
- Disable thread awareness when threads are enabled
This commit is contained in:
parent
cd95fc41e4
commit
20357ce5c4
@ -36,7 +36,6 @@ import org.matrix.android.sdk.internal.crypto.algorithms.olm.OlmDecryptionResult
|
||||
import org.matrix.android.sdk.internal.crypto.model.event.EncryptedEventContent
|
||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
import org.matrix.android.sdk.internal.session.presence.model.PresenceContent
|
||||
import org.matrix.android.sdk.internal.session.room.send.removeInReplyFallbacks
|
||||
import timber.log.Timber
|
||||
|
||||
typealias Content = JsonDict
|
||||
@ -338,20 +337,22 @@ fun Event.isAttachmentMessage(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
fun Event.isPoll(): Boolean = getClearType() == EventType.POLL_START || getClearType() == EventType.POLL_END
|
||||
|
||||
fun Event.isSticker(): Boolean = getClearType() == EventType.STICKER
|
||||
|
||||
fun Event.getRelationContent(): RelationDefaultContent? {
|
||||
if(eventId?.contains("MgPN5Bqb") == true)
|
||||
Timber.i(":D")
|
||||
return if (isEncrypted()) {
|
||||
content.toModel<EncryptedEventContent>()?.relatesTo
|
||||
} else {
|
||||
content.toModel<MessageContent>()?.relatesTo ?: run{
|
||||
// Special case to handle stickers, while there is only a local msgtype for stickers
|
||||
if (getClearType() == EventType.STICKER) {
|
||||
getClearContent().toModel<MessageStickerContent>()?.relatesTo
|
||||
} else{
|
||||
null
|
||||
}
|
||||
content.toModel<MessageContent>()?.relatesTo ?: run {
|
||||
// Special case to handle stickers, while there is only a local msgtype for stickers
|
||||
if (getClearType() == EventType.STICKER) {
|
||||
getClearContent().toModel<MessageStickerContent>()?.relatesTo
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,9 @@ import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||
import org.matrix.android.sdk.api.session.events.model.getRelationContent
|
||||
import org.matrix.android.sdk.api.session.events.model.isEdition
|
||||
import org.matrix.android.sdk.api.session.events.model.isPoll
|
||||
import org.matrix.android.sdk.api.session.events.model.isReply
|
||||
import org.matrix.android.sdk.api.session.events.model.isSticker
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.EventAnnotationsSummary
|
||||
import org.matrix.android.sdk.api.session.room.model.ReadReceipt
|
||||
@ -145,6 +147,13 @@ fun TimelineEvent.isEdition(): Boolean {
|
||||
return root.isEdition()
|
||||
}
|
||||
|
||||
fun TimelineEvent.isPoll(): Boolean =
|
||||
root.isPoll()
|
||||
|
||||
fun TimelineEvent.isSticker(): Boolean {
|
||||
return root.isSticker()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest message body, after a possible edition, stripping the reply prefix if necessary
|
||||
*/
|
||||
|
@ -177,9 +177,9 @@ internal class DefaultRelationService @AssistedInject constructor(
|
||||
replyText = replyInThreadText,
|
||||
autoMarkdown = autoMarkdown,
|
||||
rootThreadEventId = rootThreadEventId)
|
||||
// ?.also {
|
||||
// saveLocalEcho(it)
|
||||
// }
|
||||
?.also {
|
||||
saveLocalEcho(it)
|
||||
}
|
||||
?: return null
|
||||
} else {
|
||||
eventFactory.createThreadTextEvent(
|
||||
@ -189,9 +189,9 @@ internal class DefaultRelationService @AssistedInject constructor(
|
||||
msgType = msgType,
|
||||
autoMarkdown = autoMarkdown,
|
||||
formattedText = formattedText)
|
||||
// .also {
|
||||
// saveLocalEcho(it)
|
||||
// }
|
||||
.also {
|
||||
saveLocalEcho(it)
|
||||
}
|
||||
}
|
||||
return eventSenderProcessor.postEvent(event, cryptoSessionInfoProvider.isRoomEncrypted(roomId))
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import io.realm.RealmQuery
|
||||
import io.realm.RealmResults
|
||||
import io.realm.Sort
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.matrix.android.sdk.BuildConfig
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
@ -639,7 +640,9 @@ internal class DefaultTimeline(
|
||||
}.map {
|
||||
EventMapper.map(it)
|
||||
}
|
||||
threadsAwarenessHandler.fetchRootThreadEventsIfNeeded(eventEntityList)
|
||||
if(!BuildConfig.THREADING_ENABLED) {
|
||||
threadsAwarenessHandler.fetchRootThreadEventsIfNeeded(eventEntityList)
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildTimelineEvent(eventEntity: TimelineEventEntity): TimelineEvent {
|
||||
|
@ -17,6 +17,7 @@ package org.matrix.android.sdk.internal.session.room.timeline
|
||||
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import org.matrix.android.sdk.BuildConfig
|
||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
@ -114,11 +115,17 @@ internal class TimelineEventDecryptor @Inject constructor(
|
||||
.findFirst()
|
||||
|
||||
eventEntity?.apply {
|
||||
val decryptedPayload = threadsAwarenessHandler.handleIfNeededDuringDecryption(
|
||||
it,
|
||||
roomId = event.roomId,
|
||||
event,
|
||||
result)
|
||||
|
||||
val decryptedPayload =
|
||||
if (!BuildConfig.THREADING_ENABLED) {
|
||||
threadsAwarenessHandler.handleIfNeededDuringDecryption(
|
||||
it,
|
||||
roomId = event.roomId,
|
||||
event,
|
||||
result)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
setDecryptionResult(result, decryptedPayload)
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.sync
|
||||
|
||||
import androidx.work.ExistingPeriodicWorkPolicy
|
||||
import com.zhuinden.monarchy.Monarchy
|
||||
import org.matrix.android.sdk.BuildConfig
|
||||
import org.matrix.android.sdk.api.pushrules.PushRuleService
|
||||
import org.matrix.android.sdk.api.pushrules.RuleScope
|
||||
import org.matrix.android.sdk.api.session.initsync.InitSyncStep
|
||||
@ -101,7 +102,9 @@ internal class SyncResponseHandler @Inject constructor(
|
||||
val aggregator = SyncResponsePostTreatmentAggregator()
|
||||
|
||||
// Prerequisite for thread events handling in RoomSyncHandler
|
||||
threadsAwarenessHandler.fetchRootThreadEventsIfNeeded(syncResponse)
|
||||
if(!BuildConfig.THREADING_ENABLED) {
|
||||
threadsAwarenessHandler.fetchRootThreadEventsIfNeeded(syncResponse)
|
||||
}
|
||||
|
||||
// Start one big transaction
|
||||
monarchy.awaitTransaction { realm ->
|
||||
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.session.sync.handler.room
|
||||
|
||||
import io.realm.Realm
|
||||
import io.realm.kotlin.createObject
|
||||
import org.matrix.android.sdk.BuildConfig
|
||||
import org.matrix.android.sdk.api.session.crypto.MXCryptoError
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
@ -375,10 +376,12 @@ internal class RoomSyncHandler @Inject constructor(private val readReceiptHandle
|
||||
decryptIfNeeded(event, roomId)
|
||||
}
|
||||
|
||||
threadsAwarenessHandler.handleIfNeeded(
|
||||
realm = realm,
|
||||
roomId = roomId,
|
||||
event = event)
|
||||
if(!BuildConfig.THREADING_ENABLED) {
|
||||
threadsAwarenessHandler.handleIfNeeded(
|
||||
realm = realm,
|
||||
roomId = roomId,
|
||||
event = event)
|
||||
}
|
||||
|
||||
val ageLocalTs = event.unsignedData?.age?.let { syncLocalTimestampMillis - it }
|
||||
val eventEntity = event.toEntity(roomId, SendState.SYNCED, ageLocalTs).copyToRealmOrIgnore(realm, insertType)
|
||||
|
@ -721,7 +721,7 @@ class TimelineFragment @Inject constructor(
|
||||
}
|
||||
|
||||
override fun onVoiceRecordingCancelled() {
|
||||
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = true))
|
||||
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = true, rootThreadEventId = getRootThreadEventId()))
|
||||
vibrate(requireContext())
|
||||
updateRecordingUiState(RecordingUiState.Idle)
|
||||
}
|
||||
@ -737,12 +737,12 @@ class TimelineFragment @Inject constructor(
|
||||
}
|
||||
|
||||
override fun onSendVoiceMessage() {
|
||||
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = false))
|
||||
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = false, rootThreadEventId = getRootThreadEventId()))
|
||||
updateRecordingUiState(RecordingUiState.Idle)
|
||||
}
|
||||
|
||||
override fun onDeleteVoiceMessage() {
|
||||
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = true))
|
||||
messageComposerViewModel.handle(MessageComposerAction.EndRecordingVoiceMessage(isCancelled = true, rootThreadEventId = getRootThreadEventId()))
|
||||
updateRecordingUiState(RecordingUiState.Idle)
|
||||
}
|
||||
|
||||
@ -1388,6 +1388,7 @@ class TimelineFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun updateJumpToReadMarkerViewVisibility() {
|
||||
if(isThreadTimeLine()) return
|
||||
viewLifecycleOwner.lifecycleScope.launchWhenResumed {
|
||||
withState(roomDetailViewModel) {
|
||||
val showJumpToUnreadBanner = when (it.unreadState) {
|
||||
@ -1606,28 +1607,28 @@ class TimelineFragment @Inject constructor(
|
||||
|
||||
private fun renderSendMessageResult(sendMessageResult: MessageComposerViewEvents.SendMessageResult) {
|
||||
when (sendMessageResult) {
|
||||
is MessageComposerViewEvents.SlashCommandLoading -> {
|
||||
is MessageComposerViewEvents.SlashCommandLoading -> {
|
||||
showLoading(null)
|
||||
}
|
||||
is MessageComposerViewEvents.SlashCommandError -> {
|
||||
is MessageComposerViewEvents.SlashCommandError -> {
|
||||
displayCommandError(getString(R.string.command_problem_with_parameters, sendMessageResult.command.command))
|
||||
}
|
||||
is MessageComposerViewEvents.SlashCommandUnknown -> {
|
||||
is MessageComposerViewEvents.SlashCommandUnknown -> {
|
||||
displayCommandError(getString(R.string.unrecognized_command, sendMessageResult.command))
|
||||
}
|
||||
is MessageComposerViewEvents.SlashCommandResultOk -> {
|
||||
is MessageComposerViewEvents.SlashCommandResultOk -> {
|
||||
dismissLoadingDialog()
|
||||
views.composerLayout.setTextIfDifferent("")
|
||||
sendMessageResult.messageRes?.let { showSnackWithMessage(getString(it)) }
|
||||
}
|
||||
is MessageComposerViewEvents.SlashCommandResultError -> {
|
||||
is MessageComposerViewEvents.SlashCommandResultError -> {
|
||||
dismissLoadingDialog()
|
||||
displayCommandError(errorFormatter.toHumanReadable(sendMessageResult.throwable))
|
||||
}
|
||||
is MessageComposerViewEvents.SlashCommandNotImplemented -> {
|
||||
is MessageComposerViewEvents.SlashCommandNotImplemented -> {
|
||||
displayCommandError(getString(R.string.not_implemented))
|
||||
}
|
||||
is TextComposerViewEvents.SlashCommandNotSupportedInThreads -> {
|
||||
is MessageComposerViewEvents.SlashCommandNotSupportedInThreads -> {
|
||||
displayCommandError(getString(R.string.command_not_supported_in_threads, sendMessageResult.command))
|
||||
}
|
||||
} // .exhaustive
|
||||
@ -2145,14 +2146,14 @@ class TimelineFragment @Inject constructor(
|
||||
}
|
||||
}
|
||||
is EventSharedAction.ReplyInThread -> {
|
||||
if (!views.voiceMessageRecorderView.isActive()) {
|
||||
if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) {
|
||||
navigateToThreadTimeline(action.eventId)
|
||||
} else {
|
||||
requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit)
|
||||
}
|
||||
}
|
||||
is EventSharedAction.ViewInRoom -> {
|
||||
if (!views.voiceMessageRecorderView.isActive()) {
|
||||
if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) {
|
||||
handleViewInRoomAction()
|
||||
} else {
|
||||
requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit)
|
||||
@ -2386,7 +2387,7 @@ class TimelineFragment @Inject constructor(
|
||||
AttachmentTypeSelectorView.Type.AUDIO -> attachmentsHelper.selectAudio(attachmentAudioActivityResultLauncher)
|
||||
AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact(attachmentContactActivityResultLauncher)
|
||||
AttachmentTypeSelectorView.Type.STICKER -> roomDetailViewModel.handle(RoomDetailAction.SelectStickerAttachment)
|
||||
AttachmentTypeSelectorView.Type.POLL -> navigator.openCreatePoll(requireContext(), roomDetailArgs.roomId)
|
||||
AttachmentTypeSelectorView.Type.POLL -> navigator.openCreatePoll(requireContext(), timelineArgs.roomId)
|
||||
}.exhaustive
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ sealed class MessageComposerAction : VectorViewModelAction {
|
||||
data class InitializeVoiceRecorder(val attachmentData: ContentAttachmentData) : MessageComposerAction()
|
||||
data class OnVoiceRecordingUiStateChanged(val uiState: VoiceMessageRecorderView.RecordingUiState) : MessageComposerAction()
|
||||
object StartRecordingVoiceMessage : MessageComposerAction()
|
||||
data class EndRecordingVoiceMessage(val isCancelled: Boolean) : MessageComposerAction()
|
||||
data class EndRecordingVoiceMessage(val isCancelled: Boolean,val rootThreadEventId: String?) : MessageComposerAction()
|
||||
object PauseRecordingVoiceMessage : MessageComposerAction()
|
||||
data class PlayOrPauseVoicePlayback(val eventId: String, val messageAudioContent: MessageAudioContent) : MessageComposerAction()
|
||||
object PlayOrPauseRecordingPlayback : MessageComposerAction()
|
||||
|
@ -93,7 +93,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
||||
is MessageComposerAction.OnTextChanged -> handleOnTextChanged(action)
|
||||
is MessageComposerAction.OnVoiceRecordingUiStateChanged -> handleOnVoiceRecordingUiStateChanged(action)
|
||||
is MessageComposerAction.StartRecordingVoiceMessage -> handleStartRecordingVoiceMessage()
|
||||
is MessageComposerAction.EndRecordingVoiceMessage -> handleEndRecordingVoiceMessage(action.isCancelled)
|
||||
is MessageComposerAction.EndRecordingVoiceMessage -> handleEndRecordingVoiceMessage(action.isCancelled, action.rootThreadEventId)
|
||||
is MessageComposerAction.PlayOrPauseVoicePlayback -> handlePlayOrPauseVoicePlayback(action)
|
||||
MessageComposerAction.PauseRecordingVoiceMessage -> handlePauseRecordingVoiceMessage()
|
||||
MessageComposerAction.PlayOrPauseRecordingPlayback -> handlePlayOrPauseRecordingPlayback()
|
||||
@ -188,7 +188,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
||||
_viewEvents.post(MessageComposerViewEvents.SlashCommandUnknown(slashCommandResult.slashCommand))
|
||||
}
|
||||
is ParsedCommand.ErrorCommandNotSupportedInThreads -> {
|
||||
_viewEvents.post(TextComposerViewEvents.SlashCommandNotSupportedInThreads(slashCommandResult.slashCommand))
|
||||
_viewEvents.post(MessageComposerViewEvents.SlashCommandNotSupportedInThreads(slashCommandResult.slashCommand))
|
||||
}
|
||||
is ParsedCommand.SendPlainText -> {
|
||||
// Send the text message to the room, without markdown
|
||||
@ -491,7 +491,7 @@ class MessageComposerViewModel @AssistedInject constructor(
|
||||
eventReplied = timelineEvent)
|
||||
} ?: room.replyToMessage(timelineEvent, action.text.toString(), action.autoMarkdown)
|
||||
|
||||
_viewEvents.post(TextComposerViewEvents.MessageSent)
|
||||
_viewEvents.post(MessageComposerViewEvents.MessageSent)
|
||||
popDraft()
|
||||
}
|
||||
is SendMode.Voice -> {
|
||||
@ -774,14 +774,18 @@ class MessageComposerViewModel @AssistedInject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleEndRecordingVoiceMessage(isCancelled: Boolean) {
|
||||
private fun handleEndRecordingVoiceMessage(isCancelled: Boolean, rootThreadEventId: String? = null) {
|
||||
voiceMessageHelper.stopPlayback()
|
||||
if (isCancelled) {
|
||||
voiceMessageHelper.deleteRecording()
|
||||
} else {
|
||||
voiceMessageHelper.stopRecording(convertForSending = true)?.let { audioType ->
|
||||
if (audioType.duration > 1000) {
|
||||
room.sendMedia(audioType.toContentAttachmentData(isVoiceMessage = true), false, emptySet())
|
||||
room.sendMedia(
|
||||
attachment = audioType.toContentAttachmentData(isVoiceMessage = true),
|
||||
compressBeforeSending = false,
|
||||
roomIds = emptySet(),
|
||||
rootThreadEventId = rootThreadEventId)
|
||||
} else {
|
||||
voiceMessageHelper.deleteRecording()
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ import org.matrix.android.sdk.api.session.room.send.SendState
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
|
||||
import org.matrix.android.sdk.api.session.room.timeline.hasBeenEdited
|
||||
import org.matrix.android.sdk.api.session.room.timeline.isPoll
|
||||
import org.matrix.android.sdk.api.session.room.timeline.isSticker
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.flow.unwrap
|
||||
|
||||
@ -442,14 +444,14 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
* Determine whether or not the Reply In Thread bottom sheet setting will be visible
|
||||
* to the user
|
||||
*/
|
||||
// TODO handle reply in thread for images etc
|
||||
private fun canReplyInThread(event: TimelineEvent,
|
||||
messageContent: MessageContent?,
|
||||
actionPermissions: ActionPermissions): Boolean {
|
||||
// Only event of type EventType.MESSAGE are supported for the moment
|
||||
if (!BuildConfig.THREADING_ENABLED) return false
|
||||
if (initialState.isFromThreadTimeline) return false
|
||||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||
if (event.root.getClearType() != EventType.MESSAGE &&
|
||||
!event.isSticker() && !event.isPoll()) return false
|
||||
if (!actionPermissions.canSendMessage) return false
|
||||
return when (messageContent?.msgType) {
|
||||
MessageType.MSGTYPE_TEXT,
|
||||
@ -458,8 +460,10 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
MessageType.MSGTYPE_IMAGE,
|
||||
MessageType.MSGTYPE_VIDEO,
|
||||
MessageType.MSGTYPE_AUDIO,
|
||||
MessageType.MSGTYPE_FILE -> true
|
||||
else -> false
|
||||
MessageType.MSGTYPE_FILE,
|
||||
MessageType.MSGTYPE_POLL_START,
|
||||
MessageType.MSGTYPE_STICKER_LOCAL -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@ -468,12 +472,13 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
* a thread timeline
|
||||
*/
|
||||
private fun canViewInRoom(event: TimelineEvent,
|
||||
messageContent: MessageContent?,
|
||||
actionPermissions: ActionPermissions): Boolean {
|
||||
messageContent: MessageContent?,
|
||||
actionPermissions: ActionPermissions): Boolean {
|
||||
// Only event of type EventType.MESSAGE are supported for the moment
|
||||
if (!BuildConfig.THREADING_ENABLED) return false
|
||||
if (!initialState.isFromThreadTimeline) return false
|
||||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||
if (!initialState.isFromThreadTimeline) return false
|
||||
if (event.root.getClearType() != EventType.MESSAGE &&
|
||||
!event.isSticker() && !event.isPoll()) return false
|
||||
if (!actionPermissions.canSendMessage) return false
|
||||
|
||||
return when (messageContent?.msgType) {
|
||||
@ -483,12 +488,13 @@ class MessageActionsViewModel @AssistedInject constructor(@Assisted
|
||||
MessageType.MSGTYPE_IMAGE,
|
||||
MessageType.MSGTYPE_VIDEO,
|
||||
MessageType.MSGTYPE_AUDIO,
|
||||
MessageType.MSGTYPE_FILE -> event.root.threadDetails?.isRootThread ?: false
|
||||
else -> false
|
||||
MessageType.MSGTYPE_FILE,
|
||||
MessageType.MSGTYPE_POLL_START,
|
||||
MessageType.MSGTYPE_STICKER_LOCAL -> event.root.threadDetails?.isRootThread ?: false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun canQuote(event: TimelineEvent, messageContent: MessageContent?, actionPermissions: ActionPermissions): Boolean {
|
||||
// Only event of type EventType.MESSAGE are supported for the moment
|
||||
if (event.root.getClearType() != EventType.MESSAGE) return false
|
||||
|
@ -226,6 +226,18 @@ class MessageItemFactory @Inject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
return PollItem_()
|
||||
.attributes(attributes)
|
||||
.eventId(informationData.eventId)
|
||||
.pollQuestion(pollContent.pollCreationInfo?.question?.question ?: "")
|
||||
.pollSent(isPollSent)
|
||||
.totalVotesText(totalVotesText)
|
||||
.optionViewStates(optionViewStates)
|
||||
.highlighted(highlight)
|
||||
.leftGuideline(avatarSizeProvider.leftGuideline)
|
||||
.callback(callback)
|
||||
}
|
||||
|
||||
private fun buildAudioMessageItem(messageContent: MessageAudioContent,
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
informationData: MessageInformationData,
|
||||
|
@ -19,15 +19,10 @@ package im.vector.app.features.home.room.threads
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.fragment.app.FragmentTransaction
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.extensions.addFragment
|
||||
import im.vector.app.core.extensions.addFragmentToBackstack
|
||||
import im.vector.app.core.extensions.replaceFragment
|
||||
import im.vector.app.core.platform.ToolbarConfigurable
|
||||
@ -42,6 +37,7 @@ import im.vector.app.features.home.room.threads.list.views.ThreadListFragment
|
||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class ThreadsActivity : VectorBaseActivity<ActivityThreadsBinding>(), ToolbarConfigurable {
|
||||
|
||||
@Inject
|
||||
@ -56,10 +52,6 @@ class ThreadsActivity : VectorBaseActivity<ActivityThreadsBinding>(), ToolbarCon
|
||||
|
||||
override fun getCoordinatorLayout() = views.coordinatorLayout
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
injector.inject(this)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
initFragment()
|
||||
@ -83,14 +75,14 @@ class ThreadsActivity : VectorBaseActivity<ActivityThreadsBinding>(), ToolbarCon
|
||||
|
||||
private fun initThreadListFragment(threadListArgs: ThreadListArgs) {
|
||||
replaceFragment(
|
||||
R.id.threadsActivityFragmentContainer,
|
||||
views.threadsActivityFragmentContainer,
|
||||
ThreadListFragment::class.java,
|
||||
threadListArgs)
|
||||
}
|
||||
|
||||
private fun initThreadTimelineFragment(threadTimelineArgs: ThreadTimelineArgs) =
|
||||
replaceFragment(
|
||||
R.id.threadsActivityFragmentContainer,
|
||||
views.threadsActivityFragmentContainer,
|
||||
TimelineFragment::class.java,
|
||||
TimelineArgs(
|
||||
roomId = threadTimelineArgs.roomId,
|
||||
@ -113,7 +105,7 @@ class ThreadsActivity : VectorBaseActivity<ActivityThreadsBinding>(), ToolbarCon
|
||||
it.setCustomAnimations(R.anim.animation_slide_in_right, R.anim.animation_slide_out_left, R.anim.animation_slide_in_left, R.anim.animation_slide_out_right)
|
||||
}
|
||||
addFragmentToBackstack(
|
||||
frameId = R.id.threadsActivityFragmentContainer,
|
||||
container = views.threadsActivityFragmentContainer,
|
||||
fragmentClass = TimelineFragment::class.java,
|
||||
params = TimelineArgs(
|
||||
roomId = timelineEvent.roomId,
|
||||
|
@ -39,7 +39,7 @@ class ThreadListBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetThr
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
threadListViewModel.subscribe(this) {
|
||||
threadListViewModel.onEach {
|
||||
renderState(it)
|
||||
}
|
||||
views.threadListModalAllThreads.views.bottomSheetActionClickableZone.debouncedClicks {
|
||||
|
@ -35,6 +35,7 @@ import org.matrix.android.sdk.api.session.permalinks.PermalinkData
|
||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkParser
|
||||
import org.matrix.android.sdk.api.session.permalinks.PermalinkService
|
||||
import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomType
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -86,33 +87,17 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
|
||||
|
||||
val rootThreadEventId = permalinkData.eventId?.let { eventId ->
|
||||
val room = roomId?.let { session?.getRoom(it) }
|
||||
// Root thread will be opened in timeline
|
||||
// if(room?.getTimeLineEvent(eventId)?.root?.threadDetails?.isRootThread == true){
|
||||
// room.getTimeLineEvent(eventId)?.root?.eventId
|
||||
// }else{
|
||||
room?.getTimeLineEvent(eventId)?.root?.getRootThreadEventId()
|
||||
// }
|
||||
|
||||
}
|
||||
// MERGE FROM DEVELOP CONFLICT A.K.
|
||||
// openRoom(
|
||||
// navigationInterceptor,
|
||||
// context = context,
|
||||
// roomId = roomId,
|
||||
// permalinkData = permalinkData,
|
||||
// rawLink = rawLink,
|
||||
// buildTask = buildTask
|
||||
// )
|
||||
if (navigationInterceptor?.navToRoom(roomId, permalinkData.eventId, rawLink,rootThreadEventId) != true) {
|
||||
openRoom(
|
||||
context = context,
|
||||
roomId = roomId,
|
||||
permalinkData = permalinkData,
|
||||
rawLink = rawLink,
|
||||
buildTask = buildTask,
|
||||
rootThreadEventId = rootThreadEventId
|
||||
)
|
||||
}
|
||||
openRoom(
|
||||
navigationInterceptor,
|
||||
context = context,
|
||||
roomId = roomId,
|
||||
permalinkData = permalinkData,
|
||||
rawLink = rawLink,
|
||||
buildTask = buildTask,
|
||||
rootThreadEventId = rootThreadEventId
|
||||
)
|
||||
true
|
||||
}
|
||||
is PermalinkData.GroupLink -> {
|
||||
@ -170,14 +155,13 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
|
||||
* Open room either joined, or not
|
||||
*/
|
||||
private fun openRoom(
|
||||
// A.K. conflict
|
||||
// navigationInterceptor: NavigationInterceptor?,
|
||||
navigationInterceptor: NavigationInterceptor?,
|
||||
context: Context,
|
||||
roomId: String?,
|
||||
permalinkData: PermalinkData.RoomLink,
|
||||
rawLink: Uri,
|
||||
buildTask: Boolean,
|
||||
rootThreadEventId: String? =null
|
||||
rootThreadEventId: String? = null
|
||||
) {
|
||||
val session = activeSessionHolder.getSafeActiveSession() ?: return
|
||||
if (roomId == null) {
|
||||
@ -194,13 +178,7 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
|
||||
membership?.isActive().orFalse() -> {
|
||||
if (!isSpace && membership == Membership.JOIN) {
|
||||
// If it's a room you're in, let's just open it, you can tap back if needed
|
||||
// A.K. Conflict
|
||||
// navigationInterceptor.openJoinedRoomScreen(buildTask, roomId, eventId, rawLink, context)
|
||||
rootThreadEventId?.let {
|
||||
val threadTimelineArgs = ThreadTimelineArgs(roomId, displayName = roomSummary.displayName, roomSummary.avatarUrl, it)
|
||||
navigator.openThread(context, threadTimelineArgs, eventId)
|
||||
} ?: navigator.openRoom(context, roomId, eventId, buildTask)
|
||||
|
||||
navigationInterceptor.openJoinedRoomScreen(buildTask, roomId, eventId, rawLink, context, rootThreadEventId, roomSummary)
|
||||
} else {
|
||||
// maybe open space preview navigator.openSpacePreview(context, roomId)? if already joined?
|
||||
navigator.openMatrixToBottomSheet(context, rawLink.toString())
|
||||
@ -213,9 +191,19 @@ class PermalinkHandler @Inject constructor(private val activeSessionHolder: Acti
|
||||
}
|
||||
}
|
||||
|
||||
private fun NavigationInterceptor?.openJoinedRoomScreen(buildTask: Boolean, roomId: String, eventId: String?, rawLink: Uri, context: Context) {
|
||||
if (this?.navToRoom(roomId, eventId, rawLink) != true) {
|
||||
navigator.openRoom(context, roomId, eventId, buildTask)
|
||||
private fun NavigationInterceptor?.openJoinedRoomScreen(buildTask: Boolean,
|
||||
roomId: String,
|
||||
eventId: String?,
|
||||
rawLink: Uri,
|
||||
context: Context,
|
||||
rootThreadEventId: String?,
|
||||
roomSummary: RoomSummary
|
||||
) {
|
||||
if (this?.navToRoom(roomId, eventId, rawLink, rootThreadEventId) != true) {
|
||||
rootThreadEventId?.let {
|
||||
val threadTimelineArgs = ThreadTimelineArgs(roomId, displayName = roomSummary.displayName, roomSummary.avatarUrl, it)
|
||||
navigator.openThread(context, threadTimelineArgs, eventId)
|
||||
} ?: navigator.openRoom(context, roomId, eventId, buildTask)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
package im.vector.app.features.room
|
||||
|
||||
import com.airbnb.mvrx.MavericksState
|
||||
import im.vector.app.features.home.room.detail.RoomDetailArgs
|
||||
import im.vector.app.features.home.room.detail.arguments.TimelineArgs
|
||||
import im.vector.app.features.roommemberprofile.RoomMemberProfileArgs
|
||||
import im.vector.app.features.roomprofile.RoomProfileArgs
|
||||
|
||||
@ -25,7 +25,7 @@ data class RequireActiveMembershipViewState(
|
||||
val roomId: String? = null
|
||||
) : MavericksState {
|
||||
|
||||
constructor(args: RoomDetailArgs) : this(roomId = args.roomId)
|
||||
constructor(args: TimelineArgs) : this(roomId = args.roomId)
|
||||
|
||||
constructor(args: RoomProfileArgs) : this(roomId = args.roomId)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user