forked from GitHub-Mirror/riotX-android
Merge branch 'feature/timeline_new_events' into develop
This commit is contained in:
commit
14ac3a8ae6
@ -96,6 +96,7 @@ dependencies {
|
|||||||
kapt 'com.github.bumptech.glide:compiler:4.8.0'
|
kapt 'com.github.bumptech.glide:compiler:4.8.0'
|
||||||
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||||
implementation 'com.google.android.material:material:1.1.0-alpha02'
|
implementation 'com.google.android.material:material:1.1.0-alpha02'
|
||||||
|
implementation 'me.gujun.android:span:1.7'
|
||||||
|
|
||||||
// DI
|
// DI
|
||||||
implementation "org.koin:koin-android:$koin_version"
|
implementation "org.koin:koin-android:$koin_version"
|
||||||
|
@ -18,6 +18,7 @@ package im.vector.riotredesign.core.di
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.MODE_PRIVATE
|
import android.content.Context.MODE_PRIVATE
|
||||||
|
import im.vector.riotredesign.core.resources.ColorProvider
|
||||||
import im.vector.riotredesign.core.resources.LocaleProvider
|
import im.vector.riotredesign.core.resources.LocaleProvider
|
||||||
import im.vector.riotredesign.core.resources.StringProvider
|
import im.vector.riotredesign.core.resources.StringProvider
|
||||||
import im.vector.riotredesign.features.home.room.list.RoomSelectionRepository
|
import im.vector.riotredesign.features.home.room.list.RoomSelectionRepository
|
||||||
@ -35,6 +36,10 @@ class AppModule(private val context: Context) {
|
|||||||
StringProvider(context.resources)
|
StringProvider(context.resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
single {
|
||||||
|
ColorProvider(context)
|
||||||
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
context.getSharedPreferences("im.vector.riot", MODE_PRIVATE)
|
context.getSharedPreferences("im.vector.riot", MODE_PRIVATE)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.riotredesign.core.epoxy
|
||||||
|
|
||||||
|
import com.airbnb.epoxy.EpoxyModelClass
|
||||||
|
import im.vector.riotredesign.R
|
||||||
|
|
||||||
|
@EpoxyModelClass(layout = R.layout.item_empty)
|
||||||
|
abstract class EmptyItem : RiotEpoxyModel<EmptyItem.Holder>() {
|
||||||
|
class Holder : RiotEpoxyHolder()
|
||||||
|
}
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package im.vector.riotredesign.features.home
|
package im.vector.riotredesign.core.epoxy
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.riotredesign.core.resources
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.annotation.ColorRes
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
|
||||||
|
class ColorProvider(private val context: Context) {
|
||||||
|
|
||||||
|
fun getColor(@ColorRes colorRes: Int): Int {
|
||||||
|
return ContextCompat.getColor(context, colorRes)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,14 +18,7 @@ package im.vector.riotredesign.features.home
|
|||||||
|
|
||||||
import im.vector.riotredesign.features.home.group.SelectedGroupStore
|
import im.vector.riotredesign.features.home.group.SelectedGroupStore
|
||||||
import im.vector.riotredesign.features.home.room.VisibleRoomStore
|
import im.vector.riotredesign.features.home.room.VisibleRoomStore
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.DefaultItemFactory
|
import im.vector.riotredesign.features.home.room.detail.timeline.*
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.MessageItemFactory
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.RoomMemberItemFactory
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.RoomNameItemFactory
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.RoomTopicItemFactory
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineDateFormatter
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineEventController
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.TimelineItemFactory
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||||
import im.vector.riotredesign.features.home.room.list.RoomSummaryComparator
|
import im.vector.riotredesign.features.home.room.list.RoomSummaryComparator
|
||||||
import im.vector.riotredesign.features.home.room.list.RoomSummaryController
|
import im.vector.riotredesign.features.home.room.list.RoomSummaryController
|
||||||
@ -40,7 +33,7 @@ class HomeModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
MessageItemFactory(get(), get())
|
MessageItemFactory(get(), get(), get())
|
||||||
}
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
@ -55,12 +48,20 @@ class HomeModule {
|
|||||||
RoomMemberItemFactory(get())
|
RoomMemberItemFactory(get())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
single {
|
||||||
|
CallItemFactory(get())
|
||||||
|
}
|
||||||
|
|
||||||
|
single {
|
||||||
|
RoomHistoryVisibilityItemFactory(get())
|
||||||
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
DefaultItemFactory()
|
DefaultItemFactory()
|
||||||
}
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
TimelineItemFactory(get(), get(), get(), get(), get())
|
TimelineItemFactory(get(), get(), get(), get(), get(), get(), get())
|
||||||
}
|
}
|
||||||
|
|
||||||
single {
|
single {
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||||
|
|
||||||
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
|
import im.vector.matrix.android.api.session.room.model.RoomMember
|
||||||
|
import im.vector.matrix.android.api.session.room.model.call.CallInviteContent
|
||||||
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
|
import im.vector.riotredesign.R
|
||||||
|
import im.vector.riotredesign.core.resources.StringProvider
|
||||||
|
|
||||||
|
class CallItemFactory(private val stringProvider: StringProvider) {
|
||||||
|
|
||||||
|
fun create(event: TimelineEvent): NoticeItem? {
|
||||||
|
val roomMember = event.roomMember ?: return null
|
||||||
|
val text = buildNoticeText(event.root, roomMember) ?: return null
|
||||||
|
return NoticeItem_()
|
||||||
|
.noticeText(text)
|
||||||
|
.avatarUrl(roomMember.avatarUrl)
|
||||||
|
.memberName(roomMember.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun buildNoticeText(event: Event, roomMember: RoomMember): CharSequence? {
|
||||||
|
return when {
|
||||||
|
EventType.CALL_INVITE == event.type -> {
|
||||||
|
val content = event.content.toModel<CallInviteContent>()?: return null
|
||||||
|
val isVideoCall = content.offer.sdp == CallInviteContent.Offer.SDP_VIDEO
|
||||||
|
return if(isVideoCall){
|
||||||
|
stringProvider.getString(R.string.notice_placed_video_call, roomMember.displayName)
|
||||||
|
}else{
|
||||||
|
stringProvider.getString(R.string.notice_placed_voice_call, roomMember.displayName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EventType.CALL_ANSWER == event.type -> stringProvider.getString(R.string.notice_answered_call, roomMember.displayName)
|
||||||
|
EventType.CALL_HANGUP == event.type -> stringProvider.getString(R.string.notice_ended_call, roomMember.displayName)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -22,17 +22,18 @@ import im.vector.matrix.android.api.permalinks.MatrixLinkify
|
|||||||
import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
|
import im.vector.matrix.android.api.permalinks.MatrixPermalinkSpan
|
||||||
import im.vector.matrix.android.api.session.events.model.EventType
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.android.api.session.events.model.toModel
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageContent
|
import im.vector.matrix.android.api.session.room.model.message.*
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageEmoteContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageImageContent
|
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageTextContent
|
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
|
import im.vector.riotredesign.R
|
||||||
import im.vector.riotredesign.core.epoxy.RiotEpoxyModel
|
import im.vector.riotredesign.core.epoxy.RiotEpoxyModel
|
||||||
import im.vector.riotredesign.core.extensions.localDateTime
|
import im.vector.riotredesign.core.extensions.localDateTime
|
||||||
|
import im.vector.riotredesign.core.resources.ColorProvider
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||||
import im.vector.riotredesign.features.media.MediaContentRenderer
|
import im.vector.riotredesign.features.media.MediaContentRenderer
|
||||||
|
import me.gujun.android.span.span
|
||||||
|
|
||||||
class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSizeProvider,
|
class MessageItemFactory(private val colorProvider: ColorProvider,
|
||||||
|
private val timelineMediaSizeProvider: TimelineMediaSizeProvider,
|
||||||
private val timelineDateFormatter: TimelineDateFormatter) {
|
private val timelineDateFormatter: TimelineDateFormatter) {
|
||||||
|
|
||||||
private val messagesDisplayedWithInformation = HashSet<String?>()
|
private val messagesDisplayedWithInformation = HashSet<String?>()
|
||||||
@ -66,10 +67,11 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
|
|||||||
val informationData = MessageInformationData(time, avatarUrl, memberName, showInformation)
|
val informationData = MessageInformationData(time, avatarUrl, memberName, showInformation)
|
||||||
|
|
||||||
return when (messageContent) {
|
return when (messageContent) {
|
||||||
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
|
is MessageTextContent -> buildTextMessageItem(messageContent, informationData, callback)
|
||||||
is MessageImageContent -> buildImageMessageItem(messageContent, informationData)
|
is MessageImageContent -> buildImageMessageItem(messageContent, informationData)
|
||||||
is MessageEmoteContent -> buildEmoteMessageItem(messageContent, informationData, callback)
|
is MessageEmoteContent -> buildEmoteMessageItem(messageContent, informationData, callback)
|
||||||
else -> buildNotHandledMessageItem(messageContent)
|
is MessageNoticeContent -> buildNoticeMessageItem(messageContent, informationData, callback)
|
||||||
|
else -> buildNotHandledMessageItem(messageContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +108,23 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
|
|||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun buildNoticeMessageItem(messageContent: MessageNoticeContent,
|
||||||
|
informationData: MessageInformationData,
|
||||||
|
callback: TimelineEventController.Callback?): MessageTextItem? {
|
||||||
|
|
||||||
|
val message = messageContent.body.let {
|
||||||
|
val formattedBody = span {
|
||||||
|
text = it
|
||||||
|
textColor = colorProvider.getColor(R.color.slate_grey)
|
||||||
|
textStyle = "italic"
|
||||||
|
}
|
||||||
|
linkifyBody(formattedBody, callback)
|
||||||
|
}
|
||||||
|
return MessageTextItem_()
|
||||||
|
.message(message)
|
||||||
|
.informationData(informationData)
|
||||||
|
}
|
||||||
|
|
||||||
private fun buildEmoteMessageItem(messageContent: MessageEmoteContent,
|
private fun buildEmoteMessageItem(messageContent: MessageEmoteContent,
|
||||||
informationData: MessageInformationData,
|
informationData: MessageInformationData,
|
||||||
callback: TimelineEventController.Callback?): MessageTextItem? {
|
callback: TimelineEventController.Callback?): MessageTextItem? {
|
||||||
@ -119,7 +138,7 @@ class MessageItemFactory(private val timelineMediaSizeProvider: TimelineMediaSiz
|
|||||||
.informationData(informationData)
|
.informationData(informationData)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun linkifyBody(body: String, callback: TimelineEventController.Callback?): CharSequence {
|
private fun linkifyBody(body: CharSequence, callback: TimelineEventController.Callback?): CharSequence {
|
||||||
val spannable = SpannableStringBuilder(body)
|
val spannable = SpannableStringBuilder(body)
|
||||||
MatrixLinkify.addLinks(spannable, object : MatrixPermalinkSpan.Callback {
|
MatrixLinkify.addLinks(spannable, object : MatrixPermalinkSpan.Callback {
|
||||||
override fun onUrlClicked(url: String) {
|
override fun onUrlClicked(url: String) {
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.riotredesign.features.home.room.detail.timeline
|
||||||
|
|
||||||
|
import im.vector.matrix.android.api.session.events.model.Event
|
||||||
|
import im.vector.matrix.android.api.session.events.model.toModel
|
||||||
|
import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibility
|
||||||
|
import im.vector.matrix.android.api.session.room.model.RoomHistoryVisibilityContent
|
||||||
|
import im.vector.matrix.android.api.session.room.model.RoomMember
|
||||||
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
|
import im.vector.riotredesign.R
|
||||||
|
import im.vector.riotredesign.core.resources.StringProvider
|
||||||
|
|
||||||
|
|
||||||
|
class RoomHistoryVisibilityItemFactory(private val stringProvider: StringProvider) {
|
||||||
|
|
||||||
|
fun create(event: TimelineEvent): NoticeItem? {
|
||||||
|
val roomMember = event.roomMember ?: return null
|
||||||
|
val noticeText = buildNoticeText(event.root, roomMember) ?: return null
|
||||||
|
return NoticeItem_()
|
||||||
|
.noticeText(noticeText)
|
||||||
|
.avatarUrl(roomMember.avatarUrl)
|
||||||
|
.memberName(roomMember.displayName)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun buildNoticeText(event: Event, roomMember: RoomMember): CharSequence? {
|
||||||
|
val content = event.content.toModel<RoomHistoryVisibilityContent>() ?: return null
|
||||||
|
val formattedVisibility = when (content.historyVisibility) {
|
||||||
|
RoomHistoryVisibility.SHARED -> stringProvider.getString(R.string.notice_room_visibility_shared)
|
||||||
|
RoomHistoryVisibility.INVITED -> stringProvider.getString(R.string.notice_room_visibility_invited)
|
||||||
|
RoomHistoryVisibility.JOINED -> stringProvider.getString(R.string.notice_room_visibility_joined)
|
||||||
|
RoomHistoryVisibility.WORLD_READABLE -> stringProvider.getString(R.string.notice_room_visibility_world_readable)
|
||||||
|
}
|
||||||
|
return stringProvider.getString(R.string.notice_made_future_room_visibility, roomMember.displayName, formattedVisibility)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -23,9 +23,9 @@ import com.airbnb.epoxy.VisibilityState
|
|||||||
import im.vector.matrix.android.api.session.events.model.EventType
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineData
|
import im.vector.matrix.android.api.session.room.timeline.TimelineData
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
|
import im.vector.riotredesign.core.epoxy.LoadingItemModel_
|
||||||
import im.vector.riotredesign.core.epoxy.RiotEpoxyModel
|
import im.vector.riotredesign.core.epoxy.RiotEpoxyModel
|
||||||
import im.vector.riotredesign.core.extensions.localDateTime
|
import im.vector.riotredesign.core.extensions.localDateTime
|
||||||
import im.vector.riotredesign.features.home.LoadingItemModel_
|
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
import im.vector.riotredesign.features.home.room.detail.timeline.helper.TimelineMediaSizeProvider
|
||||||
import im.vector.riotredesign.features.home.room.detail.timeline.paging.PagedListEpoxyController
|
import im.vector.riotredesign.features.home.room.detail.timeline.paging.PagedListEpoxyController
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ class TimelineEventController(private val roomId: String,
|
|||||||
val nextDate = nextEvent?.root?.localDateTime()
|
val nextDate = nextEvent?.root?.localDateTime()
|
||||||
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
|
val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate()
|
||||||
|
|
||||||
timelineItemFactory.create(event, nextEvent, callback)?.also {
|
timelineItemFactory.create(event, nextEvent, callback).also {
|
||||||
it.id(event.localId)
|
it.id(event.localId)
|
||||||
it.setOnVisibilityStateChanged(TimelineEventVisibilityStateChangedListener(callback, event, currentPosition))
|
it.setOnVisibilityStateChanged(TimelineEventVisibilityStateChangedListener(callback, event, currentPosition))
|
||||||
epoxyModels.add(it)
|
epoxyModels.add(it)
|
||||||
|
@ -18,29 +18,45 @@ package im.vector.riotredesign.features.home.room.detail.timeline
|
|||||||
|
|
||||||
import im.vector.matrix.android.api.session.events.model.EventType
|
import im.vector.matrix.android.api.session.events.model.EventType
|
||||||
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
import im.vector.matrix.android.api.session.room.timeline.TimelineEvent
|
||||||
|
import im.vector.riotredesign.core.epoxy.EmptyItem_
|
||||||
import im.vector.riotredesign.core.epoxy.RiotEpoxyModel
|
import im.vector.riotredesign.core.epoxy.RiotEpoxyModel
|
||||||
|
|
||||||
class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
|
class TimelineItemFactory(private val messageItemFactory: MessageItemFactory,
|
||||||
private val roomNameItemFactory: RoomNameItemFactory,
|
private val roomNameItemFactory: RoomNameItemFactory,
|
||||||
private val roomTopicItemFactory: RoomTopicItemFactory,
|
private val roomTopicItemFactory: RoomTopicItemFactory,
|
||||||
private val roomMemberItemFactory: RoomMemberItemFactory,
|
private val roomMemberItemFactory: RoomMemberItemFactory,
|
||||||
|
private val roomHistoryVisibilityItemFactory: RoomHistoryVisibilityItemFactory,
|
||||||
|
private val callItemFactory: CallItemFactory,
|
||||||
private val defaultItemFactory: DefaultItemFactory) {
|
private val defaultItemFactory: DefaultItemFactory) {
|
||||||
|
|
||||||
fun create(event: TimelineEvent,
|
fun create(event: TimelineEvent,
|
||||||
nextEvent: TimelineEvent?,
|
nextEvent: TimelineEvent?,
|
||||||
callback: TimelineEventController.Callback?): RiotEpoxyModel<*>? {
|
callback: TimelineEventController.Callback?): RiotEpoxyModel<*> {
|
||||||
|
|
||||||
return try {
|
val computedModel = try {
|
||||||
when (event.root.type) {
|
when (event.root.type) {
|
||||||
EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, callback)
|
EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, callback)
|
||||||
EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event)
|
EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event)
|
||||||
EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event)
|
EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event)
|
||||||
EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event)
|
EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event)
|
||||||
else -> defaultItemFactory.create(event)
|
EventType.STATE_HISTORY_VISIBILITY -> roomHistoryVisibilityItemFactory.create(event)
|
||||||
|
|
||||||
|
EventType.CALL_INVITE,
|
||||||
|
EventType.CALL_HANGUP,
|
||||||
|
EventType.CALL_ANSWER -> callItemFactory.create(event)
|
||||||
|
|
||||||
|
EventType.ENCRYPTED,
|
||||||
|
EventType.ENCRYPTION,
|
||||||
|
EventType.STATE_ROOM_THIRD_PARTY_INVITE,
|
||||||
|
EventType.STICKER,
|
||||||
|
EventType.STATE_ROOM_CREATE -> defaultItemFactory.create(event)
|
||||||
|
|
||||||
|
else -> null
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
defaultItemFactory.create(event, e)
|
defaultItemFactory.create(event, e)
|
||||||
}
|
}
|
||||||
|
return computedModel ?: EmptyItem_()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
4
app/src/main/res/layout/item_empty.xml
Normal file
4
app/src/main/res/layout/item_empty.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<View xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"/>
|
@ -86,4 +86,10 @@ object EventType {
|
|||||||
return STATE_EVENTS.contains(type)
|
return STATE_EVENTS.contains(type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isCallEvent(type: String): Boolean {
|
||||||
|
return type == CALL_INVITE
|
||||||
|
|| type == CALL_CANDIDATES
|
||||||
|
|| type == CALL_ANSWER
|
||||||
|
|| type == CALL_HANGUP
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.api.session.room.model
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class RoomHistoryVisibilityContent(
|
||||||
|
@Json(name = "history_visibility") val historyVisibility: RoomHistoryVisibility
|
||||||
|
)
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.api.session.room.model.call
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class CallAnswerContent(
|
||||||
|
@Json(name = "call_id") val callId: String,
|
||||||
|
@Json(name = "version") val version: Int,
|
||||||
|
@Json(name = "answer") val answer: Answer
|
||||||
|
) {
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class Answer(
|
||||||
|
@Json(name = "type") val type: String,
|
||||||
|
@Json(name = "sdp") val sdp: String
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.api.session.room.model.call
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class CallCandidatesContent(
|
||||||
|
@Json(name = "call_id") val callId: String,
|
||||||
|
@Json(name = "version") val version: Int,
|
||||||
|
@Json(name = "candidates") val candidates: List<Candidate> = emptyList()
|
||||||
|
) {
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class Candidate(
|
||||||
|
@Json(name = "sdpMid") val sdpMid: String,
|
||||||
|
@Json(name = "sdpMLineIndex") val sdpMLineIndex: String,
|
||||||
|
@Json(name = "candidate") val candidate: String
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.api.session.room.model.call
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class CallHangupContent(
|
||||||
|
@Json(name = "call_id") val callId: String,
|
||||||
|
@Json(name = "version") val version: Int
|
||||||
|
)
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* * Copyright 2019 New Vector Ltd
|
||||||
|
* *
|
||||||
|
* * Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* * you may not use this file except in compliance with the License.
|
||||||
|
* * You may obtain a copy of the License at
|
||||||
|
* *
|
||||||
|
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* *
|
||||||
|
* * Unless required by applicable law or agreed to in writing, software
|
||||||
|
* * distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* * See the License for the specific language governing permissions and
|
||||||
|
* * limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.matrix.android.api.session.room.model.call
|
||||||
|
|
||||||
|
import com.squareup.moshi.Json
|
||||||
|
import com.squareup.moshi.JsonClass
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class CallInviteContent(
|
||||||
|
@Json(name = "call_id") val callId: String,
|
||||||
|
@Json(name = "version") val version: Int,
|
||||||
|
@Json(name = "lifetime") val lifetime: Int,
|
||||||
|
@Json(name = "offer") val offer: Offer
|
||||||
|
) {
|
||||||
|
|
||||||
|
@JsonClass(generateAdapter = true)
|
||||||
|
data class Offer(
|
||||||
|
@Json(name = "type") val type: String,
|
||||||
|
@Json(name = "sdp") val sdp: String
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
const val SDP_VIDEO = "m=video"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,5 +21,5 @@ import com.squareup.moshi.JsonClass
|
|||||||
|
|
||||||
@JsonClass(generateAdapter = true)
|
@JsonClass(generateAdapter = true)
|
||||||
data class RoomTagContent(
|
data class RoomTagContent(
|
||||||
@Json(name = "tags") val tags: Map<String, Map<String, Double>> = emptyMap()
|
@Json(name = "tags") val tags: Map<String, Map<String, Any>> = emptyMap()
|
||||||
)
|
)
|
||||||
|
@ -32,15 +32,16 @@ internal class RoomTagHandler {
|
|||||||
val tags = ArrayList<RoomTagEntity>()
|
val tags = ArrayList<RoomTagEntity>()
|
||||||
for (tagName in content.tags.keys) {
|
for (tagName in content.tags.keys) {
|
||||||
val params = content.tags[tagName]
|
val params = content.tags[tagName]
|
||||||
val tag = if (params != null) {
|
val order = params?.get("order")
|
||||||
RoomTagEntity(tagName, params["order"])
|
val tag = if (order is Double) {
|
||||||
|
RoomTagEntity(tagName, order)
|
||||||
} else {
|
} else {
|
||||||
RoomTagEntity(tagName, null)
|
RoomTagEntity(tagName, null)
|
||||||
}
|
}
|
||||||
tags.add(tag)
|
tags.add(tag)
|
||||||
}
|
}
|
||||||
val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst()
|
val roomSummaryEntity = RoomSummaryEntity.where(realm, roomId).findFirst()
|
||||||
?: RoomSummaryEntity(roomId)
|
?: RoomSummaryEntity(roomId)
|
||||||
|
|
||||||
roomSummaryEntity.tags.clear()
|
roomSummaryEntity.tags.clear()
|
||||||
roomSummaryEntity.tags.addAll(tags)
|
roomSummaryEntity.tags.addAll(tags)
|
||||||
|
Loading…
Reference in New Issue
Block a user