From 06dd3760c5af6259b03e93c6b9a669cdff210116 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 15 Jan 2019 15:47:03 +0100 Subject: [PATCH 1/2] Timeline : start handling some state events display --- .../vector/riotredesign/core/di/AppModule.kt | 5 + .../core/resources/StringProvider.kt | 39 ++++++++ .../features/home/HomeActivity.kt | 2 +- .../riotredesign/features/home/HomeModule.kt | 28 +++++- .../home/room/detail/timeline/BlankItem.kt | 2 +- .../room/detail/timeline/DaySeparatorItem.kt | 2 +- .../timeline/{TextItem.kt => DefaultItem.kt} | 4 +- ...xtItemFactory.kt => DefaultItemFactory.kt} | 6 +- .../home/room/detail/timeline/MessageItem.kt | 2 +- .../home/room/detail/timeline/NoticeItem.kt | 21 ++++ .../detail/timeline/RoomMemberItemFactory.kt | 97 +++++++++++++++++++ .../detail/timeline/RoomNameItemFactory.kt | 28 ++++++ .../detail/timeline/RoomTopicItemFactory.kt | 28 ++++++ .../timeline/TimelineEventController.kt | 14 +-- .../detail/timeline/TimelineItemFactory.kt | 29 ++++++ ...lank.xml => item_timeline_event_blank.xml} | 0 ... => item_timeline_event_day_separator.xml} | 0 ...xt.xml => item_timeline_event_default.xml} | 0 ...ge.xml => item_timeline_event_message.xml} | 0 .../res/layout/item_timeline_event_notice.xml | 35 +++++++ .../src/main/res/values-ar/strings.xml | 2 +- .../src/main/res/values-bg/strings.xml | 2 +- .../src/main/res/values-ca/strings.xml | 2 +- .../src/main/res/values-da/strings.xml | 2 +- .../src/main/res/values-de/strings.xml | 2 +- .../src/main/res/values-el/strings.xml | 2 +- .../src/main/res/values-es-rMX/strings.xml | 2 +- .../src/main/res/values-es/strings.xml | 2 +- .../src/main/res/values-eu/strings.xml | 2 +- .../src/main/res/values-fi/strings.xml | 2 +- .../src/main/res/values-fr/strings.xml | 2 +- .../src/main/res/values-gl/strings.xml | 2 +- .../src/main/res/values-hu/strings.xml | 2 +- .../src/main/res/values-is/strings.xml | 2 +- .../src/main/res/values-it/strings.xml | 2 +- .../src/main/res/values-lv/strings.xml | 2 +- .../src/main/res/values-nl/strings.xml | 2 +- .../src/main/res/values-nn/strings.xml | 2 +- .../src/main/res/values-pl/strings.xml | 2 +- .../src/main/res/values-pt-rBR/strings.xml | 2 +- .../src/main/res/values-pt/strings.xml | 2 +- .../src/main/res/values-ru/strings.xml | 2 +- .../src/main/res/values-sk/strings.xml | 2 +- .../src/main/res/values-te/strings.xml | 2 +- .../src/main/res/values-zh-rCN/strings.xml | 2 +- .../src/main/res/values-zh-rTW/strings.xml | 2 +- .../src/main/res/values/strings.xml | 2 +- 47 files changed, 346 insertions(+), 50 deletions(-) create mode 100644 app/src/main/java/im/vector/riotredesign/core/resources/StringProvider.kt rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{TextItem.kt => DefaultItem.kt} (82%) rename app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/{TextItemFactory.kt => DefaultItemFactory.kt} (63%) create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt create mode 100644 app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt rename app/src/main/res/layout/{item_event_blank.xml => item_timeline_event_blank.xml} (100%) rename app/src/main/res/layout/{item_event_day_separator.xml => item_timeline_event_day_separator.xml} (100%) rename app/src/main/res/layout/{item_event_text.xml => item_timeline_event_default.xml} (100%) rename app/src/main/res/layout/{item_event_message.xml => item_timeline_event_message.xml} (100%) create mode 100644 app/src/main/res/layout/item_timeline_event_notice.xml diff --git a/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt b/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt index 7a25d46d1e..7deaa45b83 100644 --- a/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt +++ b/app/src/main/java/im/vector/riotredesign/core/di/AppModule.kt @@ -3,6 +3,7 @@ package im.vector.riotredesign.core.di import android.content.Context import android.content.Context.MODE_PRIVATE import im.vector.riotredesign.core.resources.LocaleProvider +import im.vector.riotredesign.core.resources.StringProvider import im.vector.riotredesign.features.home.room.list.RoomSelectionRepository import org.koin.dsl.module.module @@ -14,6 +15,10 @@ class AppModule(private val context: Context) { LocaleProvider(context.resources) } + single { + StringProvider(context.resources) + } + single { context.getSharedPreferences("im.vector.riot", MODE_PRIVATE) } diff --git a/app/src/main/java/im/vector/riotredesign/core/resources/StringProvider.kt b/app/src/main/java/im/vector/riotredesign/core/resources/StringProvider.kt new file mode 100644 index 0000000000..18f9f63fa9 --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/core/resources/StringProvider.kt @@ -0,0 +1,39 @@ +package im.vector.riotredesign.core.resources + +import android.content.res.Resources +import android.support.annotation.NonNull +import android.support.annotation.StringRes + +class StringProvider(private val resources: Resources) { + + /** + * Returns a localized string from the application's package's + * default string table. + * + * @param resId Resource id for the string + * @return The string data associated with the resource, stripped of styled + * text information. + */ + @NonNull + fun getString(@StringRes resId: Int): String { + return resources.getString(resId) + } + + /** + * Returns a localized formatted string from the application's package's + * default string table, substituting the format arguments as defined in + * [java.util.Formatter] and [java.lang.String.format]. + * + * @param resId Resource id for the format string + * @param formatArgs The format arguments that will be used for + * substitution. + * @return The string data associated with the resource, formatted and + * stripped of styled text information. + */ + @NonNull + fun getString(@StringRes resId: Int, vararg formatArgs: Any?): String { + return resources.getString(resId, *formatArgs) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt index da6a67319f..bd0c8d991f 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeActivity.kt @@ -29,7 +29,7 @@ class HomeActivity : RiotActivity(), ToolbarConfigurable { private val homeNavigator by inject() override fun onCreate(savedInstanceState: Bundle?) { - loadKoinModules(listOf(HomeModule(this).definition)) + loadKoinModules(listOf(HomeModule().definition)) homeNavigator.activity = this super.onCreate(savedInstanceState) setContentView(R.layout.activity_home) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt b/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt index 1c30a4ca01..85aaa5e89b 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/HomeModule.kt @@ -2,13 +2,17 @@ package im.vector.riotredesign.features.home import im.vector.riotredesign.features.home.group.SelectedGroupHolder import im.vector.riotredesign.features.home.room.VisibleRoomHolder +import im.vector.riotredesign.features.home.room.detail.timeline.DefaultItemFactory import im.vector.riotredesign.features.home.room.detail.timeline.MessageItemFactory -import im.vector.riotredesign.features.home.room.detail.timeline.TextItemFactory +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 org.koin.dsl.module.module -class HomeModule(private val homeActivity: HomeActivity) { +class HomeModule { val definition = module(override = true) { @@ -21,7 +25,23 @@ class HomeModule(private val homeActivity: HomeActivity) { } single { - TextItemFactory() + RoomNameItemFactory(get()) + } + + single { + RoomTopicItemFactory(get()) + } + + single { + RoomMemberItemFactory(get()) + } + + single { + DefaultItemFactory() + } + + single { + TimelineItemFactory(get(), get(), get(), get(), get()) } single { @@ -29,7 +49,7 @@ class HomeModule(private val homeActivity: HomeActivity) { } factory { (roomId: String) -> - TimelineEventController(roomId, get(), get(), get()) + TimelineEventController(roomId, get(), get()) } single { diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/BlankItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/BlankItem.kt index 264d6da80e..e5593fd1ef 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/BlankItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/BlankItem.kt @@ -4,7 +4,7 @@ import im.vector.riotredesign.R import im.vector.riotredesign.core.epoxy.KotlinModel class BlankItem - : KotlinModel(R.layout.item_event_blank) { + : KotlinModel(R.layout.item_timeline_event_blank) { override fun bind() { //no-op diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt index 7fbcb2ae90..ba7261545e 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DaySeparatorItem.kt @@ -6,7 +6,7 @@ import im.vector.riotredesign.core.epoxy.KotlinModel data class DaySeparatorItem( val formattedDay: CharSequence -) : KotlinModel(R.layout.item_event_day_separator) { +) : KotlinModel(R.layout.item_timeline_event_day_separator) { private val dayTextView by bind(R.id.itemDayTextView) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TextItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItem.kt similarity index 82% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TextItem.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItem.kt index 4b827a5a99..822924aee4 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TextItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItem.kt @@ -4,9 +4,9 @@ import android.widget.TextView import im.vector.riotredesign.R import im.vector.riotredesign.core.epoxy.KotlinModel -class TextItem( +class DefaultItem( val text: CharSequence? = null -) : KotlinModel(R.layout.item_event_text) { +) : KotlinModel(R.layout.item_timeline_event_default) { private val messageView by bind(R.id.stateMessageView) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TextItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt similarity index 63% rename from app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TextItemFactory.kt rename to app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt index 1ca81862d3..555947931a 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TextItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/DefaultItemFactory.kt @@ -2,11 +2,11 @@ package im.vector.riotredesign.features.home.room.detail.timeline import im.vector.matrix.android.api.session.events.model.TimelineEvent -class TextItemFactory { +class DefaultItemFactory { - fun create(event: TimelineEvent): TextItem? { + fun create(event: TimelineEvent): DefaultItem? { val text = "${event.root.type} events are not yet handled" - return TextItem(text = text) + return DefaultItem(text = text) } } \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItem.kt index cdb5e35e8f..4aae5dd2ed 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItem.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItem.kt @@ -14,7 +14,7 @@ class MessageItem( val avatarUrl: String?, val memberName: CharSequence? = null, val showInformation: Boolean = true -) : KotlinModel(R.layout.item_event_message) { +) : KotlinModel(R.layout.item_timeline_event_message) { private val avatarImageView by bind(R.id.messageAvatarImageView) private val memberNameView by bind(R.id.messageMemberNameView) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt new file mode 100644 index 0000000000..5b1a2fc7bb --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/NoticeItem.kt @@ -0,0 +1,21 @@ +package im.vector.riotredesign.features.home.room.detail.timeline + +import android.widget.ImageView +import android.widget.TextView +import im.vector.riotredesign.R +import im.vector.riotredesign.core.epoxy.KotlinModel +import im.vector.riotredesign.features.home.AvatarRenderer + +class NoticeItem(private val noticeText: CharSequence? = null, + private val avatarUrl: String?, + private val memberName: CharSequence? = null) + : KotlinModel(R.layout.item_timeline_event_notice) { + + private val avatarImageView by bind(R.id.itemNoticeAvatarView) + private val noticeTextView by bind(R.id.itemNoticeTextView) + + override fun bind() { + noticeTextView.text = noticeText + AvatarRenderer.render(avatarUrl, memberName?.toString(), avatarImageView) + } +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt new file mode 100644 index 0000000000..4757784f9d --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomMemberItemFactory.kt @@ -0,0 +1,97 @@ +package im.vector.riotredesign.features.home.room.detail.timeline + +import android.text.TextUtils +import im.vector.matrix.android.api.session.events.model.TimelineEvent +import im.vector.matrix.android.api.session.events.model.toModel +import im.vector.matrix.android.api.session.room.model.Membership +import im.vector.matrix.android.api.session.room.model.RoomMember +import im.vector.riotredesign.R +import im.vector.riotredesign.core.resources.StringProvider + + +//TODO : complete with call membership events +class RoomMemberItemFactory(private val stringProvider: StringProvider) { + + fun create(event: TimelineEvent): NoticeItem? { + val roomMember = event.roomMember ?: return null + val noticeText = buildRoomMemberNotice(event) ?: return null + return NoticeItem(noticeText, roomMember.avatarUrl, roomMember.displayName) + } + + private fun buildRoomMemberNotice(event: TimelineEvent): String? { + val eventContent: RoomMember? = event.root.content.toModel() + val prevEventContent: RoomMember? = event.root.prevContent.toModel() + val isMembershipEvent = prevEventContent?.membership != eventContent?.membership + return if (isMembershipEvent) { + buildMembershipNotice(event, eventContent, prevEventContent) + } else { + buildProfileNotice(event, eventContent, prevEventContent) + } + } + + private fun buildProfileNotice(event: TimelineEvent, eventContent: RoomMember?, prevEventContent: RoomMember?): String? { + val displayText = StringBuilder() + // Check display name has been changed + if (!TextUtils.equals(eventContent?.displayName, prevEventContent?.displayName)) { + val displayNameText = when { + prevEventContent?.displayName.isNullOrEmpty() -> stringProvider.getString(R.string.notice_display_name_set, event.root.sender, eventContent?.displayName) + eventContent?.displayName.isNullOrEmpty() -> stringProvider.getString(R.string.notice_display_name_removed, event.root.sender, prevEventContent?.displayName) + else -> stringProvider.getString(R.string.notice_display_name_changed_from, event.root.sender, prevEventContent?.displayName, eventContent?.displayName) + } + displayText.append(displayNameText) + } + // Check whether the avatar has been changed + if (!TextUtils.equals(eventContent?.avatarUrl, prevEventContent?.avatarUrl)) { + val displayAvatarText = if (displayText.isNotEmpty()) { + displayText.append(" ") + stringProvider.getString(R.string.notice_avatar_changed_too) + } else { + stringProvider.getString(R.string.notice_avatar_url_changed, event.roomMember?.displayName) + } + displayText.append(displayAvatarText) + } + return displayText.toString() + } + + private fun buildMembershipNotice(event: TimelineEvent, eventContent: RoomMember?, prevEventContent: RoomMember?): String? { + val senderDisplayName = event.roomMember?.displayName ?: return null + val targetDisplayName = eventContent?.displayName ?: event.root.sender + return when { + Membership.INVITE == eventContent?.membership -> { + // TODO get userId + val selfUserId: String = "" + when { + eventContent.thirdPartyInvite != null -> stringProvider.getString(R.string.notice_room_third_party_registered_invite, targetDisplayName, eventContent.thirdPartyInvite?.displayName) + TextUtils.equals(event.root.stateKey, selfUserId) + -> stringProvider.getString(R.string.notice_room_invite_you, senderDisplayName) + event.root.stateKey.isNullOrEmpty() -> stringProvider.getString(R.string.notice_room_invite_no_invitee, senderDisplayName) + else -> stringProvider.getString(R.string.notice_room_invite, senderDisplayName, targetDisplayName) + } + } + Membership.JOIN == eventContent?.membership -> stringProvider.getString(R.string.notice_room_join, senderDisplayName) + Membership.LEAVE == eventContent?.membership -> // 2 cases here: this member may have left voluntarily or they may have been "left" by someone else ie. kicked + return if (TextUtils.equals(event.root.sender, event.root.stateKey)) { + if (prevEventContent?.membership == Membership.INVITE) { + stringProvider.getString(R.string.notice_room_reject, senderDisplayName) + } else { + stringProvider.getString(R.string.notice_room_leave, senderDisplayName) + } + } else if (prevEventContent?.membership == Membership.INVITE) { + stringProvider.getString(R.string.notice_room_withdraw, senderDisplayName, targetDisplayName) + } else if (prevEventContent?.membership == Membership.JOIN) { + stringProvider.getString(R.string.notice_room_kick, senderDisplayName, targetDisplayName) + } else if (prevEventContent?.membership == Membership.BAN) { + stringProvider.getString(R.string.notice_room_unban, senderDisplayName, targetDisplayName) + } else { + null + } + Membership.BAN == eventContent?.membership -> stringProvider.getString(R.string.notice_room_ban, senderDisplayName, targetDisplayName) + Membership.KNOCK == eventContent?.membership -> stringProvider.getString(R.string.notice_room_kick, senderDisplayName, targetDisplayName) + else -> null + } + } + + +} + + diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt new file mode 100644 index 0000000000..905d317eae --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomNameItemFactory.kt @@ -0,0 +1,28 @@ +package im.vector.riotredesign.features.home.room.detail.timeline + +import android.text.TextUtils +import im.vector.matrix.android.api.session.events.model.TimelineEvent +import im.vector.matrix.android.api.session.events.model.toModel +import im.vector.matrix.android.api.session.room.model.RoomNameContent +import im.vector.riotredesign.R +import im.vector.riotredesign.core.resources.StringProvider + +class RoomNameItemFactory(private val stringProvider: StringProvider) { + + fun create(event: TimelineEvent): NoticeItem? { + + val content: RoomNameContent? = event.root.content.toModel() + val roomMember = event.roomMember + if (content == null || roomMember == null) { + return null + } + val text = if (!TextUtils.isEmpty(content.name)) { + stringProvider.getString(R.string.notice_room_name_changed, roomMember.displayName, content.name) + } else { + stringProvider.getString(R.string.notice_room_name_removed, roomMember.displayName) + } + return NoticeItem(text, roomMember.avatarUrl, roomMember.displayName) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt new file mode 100644 index 0000000000..a8f0647cdd --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/RoomTopicItemFactory.kt @@ -0,0 +1,28 @@ +package im.vector.riotredesign.features.home.room.detail.timeline + +import android.text.TextUtils +import im.vector.matrix.android.api.session.events.model.TimelineEvent +import im.vector.matrix.android.api.session.events.model.toModel +import im.vector.matrix.android.api.session.room.model.RoomTopicContent +import im.vector.riotredesign.R +import im.vector.riotredesign.core.resources.StringProvider + +class RoomTopicItemFactory(private val stringProvider: StringProvider) { + + fun create(event: TimelineEvent): NoticeItem? { + + val content: RoomTopicContent? = event.root.content.toModel() + val roomMember = event.roomMember + if (content == null || roomMember == null) { + return null + } + val text = if (!TextUtils.isEmpty(content.topic)) { + stringProvider.getString(R.string.notice_room_topic_changed, roomMember.displayName, content.topic) + } else { + stringProvider.getString(R.string.notice_room_topic_removed, roomMember.displayName) + } + return NoticeItem(text, roomMember.avatarUrl, roomMember.displayName) + } + + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt index 0c32025cfb..b388f3ab0a 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt @@ -2,17 +2,16 @@ package im.vector.riotredesign.features.home.room.detail.timeline import com.airbnb.epoxy.EpoxyAsyncUtil import com.airbnb.epoxy.EpoxyModel -import im.vector.matrix.android.api.session.events.model.TimelineEvent import im.vector.matrix.android.api.session.events.model.EventType +import im.vector.matrix.android.api.session.events.model.TimelineEvent import im.vector.matrix.android.api.session.room.timeline.TimelineData import im.vector.riotredesign.core.extensions.localDateTime import im.vector.riotredesign.features.home.LoadingItemModel_ import im.vector.riotredesign.features.home.room.detail.timeline.paging.PagedListEpoxyController class TimelineEventController(private val roomId: String, - private val messageItemFactory: MessageItemFactory, - private val textItemFactory: TextItemFactory, - private val dateFormatter: TimelineDateFormatter + private val dateFormatter: TimelineDateFormatter, + private val timelineItemFactory: TimelineItemFactory ) : PagedListEpoxyController( EpoxyAsyncUtil.getAsyncBackgroundHandler(), EpoxyAsyncUtil.getAsyncBackgroundHandler() @@ -50,15 +49,10 @@ class TimelineEventController(private val roomId: String, val nextDate = nextEvent?.root?.localDateTime() val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate() - val item = when (event.root.type) { - EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, addDaySeparator, date, callback) - else -> textItemFactory.create(event) - } - item?.also { + timelineItemFactory.create(event, nextEvent, addDaySeparator, date, callback)?.also { it.id(event.localId) epoxyModels.add(it) } - if (addDaySeparator) { val formattedDay = dateFormatter.formatMessageDay(date) val daySeparatorItem = DaySeparatorItem(formattedDay).id(roomId + formattedDay) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt new file mode 100644 index 0000000000..fadc226822 --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt @@ -0,0 +1,29 @@ +package im.vector.riotredesign.features.home.room.detail.timeline + +import com.airbnb.epoxy.EpoxyModel +import im.vector.matrix.android.api.session.events.model.EventType +import im.vector.matrix.android.api.session.events.model.TimelineEvent +import org.threeten.bp.LocalDateTime + +class TimelineItemFactory(private val messageItemFactory: MessageItemFactory, + private val roomNameItemFactory: RoomNameItemFactory, + private val roomTopicItemFactory: RoomTopicItemFactory, + private val roomMemberItemFactory: RoomMemberItemFactory, + private val defaultItemFactory: DefaultItemFactory) { + + fun create(event: TimelineEvent, + nextEvent: TimelineEvent?, + addDaySeparator: Boolean, + date: LocalDateTime, + callback: TimelineEventController.Callback?): EpoxyModel<*>? { + + return when (event.root.type) { + EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, addDaySeparator, date, callback) + EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event) + EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event) + EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event) + else -> defaultItemFactory.create(event) + } + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/item_event_blank.xml b/app/src/main/res/layout/item_timeline_event_blank.xml similarity index 100% rename from app/src/main/res/layout/item_event_blank.xml rename to app/src/main/res/layout/item_timeline_event_blank.xml diff --git a/app/src/main/res/layout/item_event_day_separator.xml b/app/src/main/res/layout/item_timeline_event_day_separator.xml similarity index 100% rename from app/src/main/res/layout/item_event_day_separator.xml rename to app/src/main/res/layout/item_timeline_event_day_separator.xml diff --git a/app/src/main/res/layout/item_event_text.xml b/app/src/main/res/layout/item_timeline_event_default.xml similarity index 100% rename from app/src/main/res/layout/item_event_text.xml rename to app/src/main/res/layout/item_timeline_event_default.xml diff --git a/app/src/main/res/layout/item_event_message.xml b/app/src/main/res/layout/item_timeline_event_message.xml similarity index 100% rename from app/src/main/res/layout/item_event_message.xml rename to app/src/main/res/layout/item_timeline_event_message.xml diff --git a/app/src/main/res/layout/item_timeline_event_notice.xml b/app/src/main/res/layout/item_timeline_event_notice.xml new file mode 100644 index 0000000000..169fe15656 --- /dev/null +++ b/app/src/main/res/layout/item_timeline_event_notice.xml @@ -0,0 +1,35 @@ + + + + + + + + + \ No newline at end of file diff --git a/matrix-sdk-android/src/main/res/values-ar/strings.xml b/matrix-sdk-android/src/main/res/values-ar/strings.xml index 5d4d33f63a..e562007214 100644 --- a/matrix-sdk-android/src/main/res/values-ar/strings.xml +++ b/matrix-sdk-android/src/main/res/values-ar/strings.xml @@ -16,7 +16,7 @@ ضبط ⁨%1$s⁩ اسم العرض على ⁨%2$s⁩ غيّر ⁨%1$s⁩ اسم العرض من ⁨%2$s⁩ إلى ⁨%3$s⁩ أزال ⁨%1$s⁩ اسم العرض (⁨%2$s⁩) - غيّر ⁨%1$s⁩ الموضوع إلى: ⁨%2$s⁩ + غيّر ⁨%1$s⁩ الموضوع إلى: ⁨%2$s⁩ غيّر ⁨%1$s⁩ اسم الغرفة إلى: ⁨%2$s⁩ ردّ ⁨%s⁩ على المكالمة. أنهى ⁨%s⁩ المكالمة. diff --git a/matrix-sdk-android/src/main/res/values-bg/strings.xml b/matrix-sdk-android/src/main/res/values-bg/strings.xml index 70de11ac48..c6a38c0dfc 100644 --- a/matrix-sdk-android/src/main/res/values-bg/strings.xml +++ b/matrix-sdk-android/src/main/res/values-bg/strings.xml @@ -18,7 +18,7 @@ %1$s си сложи име %2$s %1$s смени своето име от %2$s на %3$s %1$s премахна своето име (%2$s) - %1$s смени темата на: %2$s + %1$s смени темата на: %2$s %1$s смени името на стаята на: %2$s %s започна видео разговор. %s започна гласов разговор. diff --git a/matrix-sdk-android/src/main/res/values-ca/strings.xml b/matrix-sdk-android/src/main/res/values-ca/strings.xml index 539ca6a14f..65ee606df7 100644 --- a/matrix-sdk-android/src/main/res/values-ca/strings.xml +++ b/matrix-sdk-android/src/main/res/values-ca/strings.xml @@ -18,7 +18,7 @@ %1$s ha canviat el seu nom visible de %2$s a %3$s %1$s ha eliminat el seu nom visible (%2$s) - %1$s ha canviat el tema a: %2$s + %1$s ha canviat el tema a: %2$s %1$s ha canviat el nom de la sala a: %2$s %s ha contestat la trucada. %s ha finalitzat la trucada. diff --git a/matrix-sdk-android/src/main/res/values-da/strings.xml b/matrix-sdk-android/src/main/res/values-da/strings.xml index d7c37c1ddd..98e477394a 100644 --- a/matrix-sdk-android/src/main/res/values-da/strings.xml +++ b/matrix-sdk-android/src/main/res/values-da/strings.xml @@ -18,7 +18,7 @@ %1$s satte sit viste navn til %2$s %1$s ændrede sit viste navn fra %2$s til %3$s %1$s fjernede sit viste navn (%2$s) - %1$s ændrede emnet til: %2$s + %1$s ændrede emnet til: %2$s %1$s ændrede rumnavnet til: %2$s %s startede et videoopkald. %s startede et stemmeopkald. diff --git a/matrix-sdk-android/src/main/res/values-de/strings.xml b/matrix-sdk-android/src/main/res/values-de/strings.xml index d58c94045d..27aaa30184 100644 --- a/matrix-sdk-android/src/main/res/values-de/strings.xml +++ b/matrix-sdk-android/src/main/res/values-de/strings.xml @@ -19,7 +19,7 @@ %1$s hat den Anzeigenamen geändert in %2$s %1$s hat den Anzeigenamen von %2$s auf %3$s geändert %1$s hat den Anzeigenamen gelöscht (%2$s) - %1$s hat das Raumthema geändert auf: %2$s + %1$s hat das Raumthema geändert auf: %2$s %1$s hat den Raumnamen geändert in: %2$s %s hat einen Videoanruf durchgeführt. %s hat einen Sprachanruf getätigt. diff --git a/matrix-sdk-android/src/main/res/values-el/strings.xml b/matrix-sdk-android/src/main/res/values-el/strings.xml index ff855d714e..0cef845bdc 100644 --- a/matrix-sdk-android/src/main/res/values-el/strings.xml +++ b/matrix-sdk-android/src/main/res/values-el/strings.xml @@ -18,7 +18,7 @@ Ο/Η %1$s άλλαξε το εμφανιζόμενό του/της όνομα σε %2$s Ο/Η %1$s άλλαξε το εμφανιζόμενό του/της όνομα από %2$s σε %3$s Ο/Η %1$s αφαίρεσε το εμφανιζόμενό του/της όνομα (%2$s) - Ο/Η %1$s άλλαξε το θέμα σε: %2$s + Ο/Η %1$s άλλαξε το θέμα σε: %2$s Ο/Η %1$s άλλαξε το όνομα του δωματίου σε: %2$s Ο/Η %s απάντησε στην κλήση. Ο/Η %s τερμάτισε την κλήση. diff --git a/matrix-sdk-android/src/main/res/values-es-rMX/strings.xml b/matrix-sdk-android/src/main/res/values-es-rMX/strings.xml index 57fb929b49..74734f89eb 100644 --- a/matrix-sdk-android/src/main/res/values-es-rMX/strings.xml +++ b/matrix-sdk-android/src/main/res/values-es-rMX/strings.xml @@ -19,7 +19,7 @@ %1$s estableció %2$s como su nombre visible %1$s cambió su nombre visible de %2$s a %3$s %1$s retiró su nombre visible (%2$s) - %1$s cambio el tema a: %2$s + %1$s cambio el tema a: %2$s %1$s cambió el nombre de la sala a: %2$s %s comenzó una llamada de video. %s comenzó una llamada de voz. diff --git a/matrix-sdk-android/src/main/res/values-es/strings.xml b/matrix-sdk-android/src/main/res/values-es/strings.xml index a6cc2bd706..255a2f4b1c 100644 --- a/matrix-sdk-android/src/main/res/values-es/strings.xml +++ b/matrix-sdk-android/src/main/res/values-es/strings.xml @@ -19,7 +19,7 @@ %1$s estableció %2$s como su nombre público %1$s cambió su nombre público de %2$s a %3$s %1$s eliminó su nombre público (%2$s) - %1$s cambió el tema a: %2$s + %1$s cambió el tema a: %2$s %1$s cambió el nombre de la sala a: %2$s %s realizó una llamada de vídeo. %s realizó una llamada de voz. diff --git a/matrix-sdk-android/src/main/res/values-eu/strings.xml b/matrix-sdk-android/src/main/res/values-eu/strings.xml index 41d306f671..b0ed968774 100644 --- a/matrix-sdk-android/src/main/res/values-eu/strings.xml +++ b/matrix-sdk-android/src/main/res/values-eu/strings.xml @@ -18,7 +18,7 @@ %1$s erabiltzaileak bere pantaila-izena aldatu du beste honetara: %2$s %1$s erabiltzaileak bere pantaila-izena aldatu du, honetatik: %2$s honetara: %3$s %1$s erabiltzaileak bere pantaila-izena kendu du (%2$s) - %1$s erabiltzaileak mintzagaia honetara aldatu du: %2$s + %1$s erabiltzaileak mintzagaia honetara aldatu du: %2$s %1$s erabiltzaileak gelaren izena honetara aldatu du: %2$s %s erabiltzaileak bideo deia hasi du. %s erabiltzaileak ahots deia hasi du. diff --git a/matrix-sdk-android/src/main/res/values-fi/strings.xml b/matrix-sdk-android/src/main/res/values-fi/strings.xml index dac28a3bba..44cf329ff0 100644 --- a/matrix-sdk-android/src/main/res/values-fi/strings.xml +++ b/matrix-sdk-android/src/main/res/values-fi/strings.xml @@ -15,7 +15,7 @@ %1$s asetti näyttönimekseen %2$s %1$s muutti näyttönimensä %2$s -> %3$s %1$s poisti näyttönimensä (%2$s) - %1$s muutti aiheeksi %2$s + %1$s muutti aiheeksi %2$s %1$s muutti huoneen nimeksi %2$s %s soitti videopuhelun. %s soitti puhelun. diff --git a/matrix-sdk-android/src/main/res/values-fr/strings.xml b/matrix-sdk-android/src/main/res/values-fr/strings.xml index 039e71290b..9a041fa539 100644 --- a/matrix-sdk-android/src/main/res/values-fr/strings.xml +++ b/matrix-sdk-android/src/main/res/values-fr/strings.xml @@ -18,7 +18,7 @@ %1$s a réglé son nom affiché en %2$s %1$s a modifié son nom affiché %2$s en %3$s %1$s a supprimé son nom affiché (%2$s) - %1$s a changé le sujet en : %2$s + %1$s a changé le sujet en : %2$s %1$s a changé le nom du salon en : %2$s %s a passé un appel vidéo. %s a passé un appel vocal. diff --git a/matrix-sdk-android/src/main/res/values-gl/strings.xml b/matrix-sdk-android/src/main/res/values-gl/strings.xml index 5110fb773a..db4c1e8f02 100644 --- a/matrix-sdk-android/src/main/res/values-gl/strings.xml +++ b/matrix-sdk-android/src/main/res/values-gl/strings.xml @@ -22,7 +22,7 @@ %1$s cambiou o seu nome a %2$s %1$s cambiou o seu nome de %2$s a %3$s %1$s borrou o seu nome público (%2$s) - %1$s cambiou o tema desta sala para: %2$s + %1$s cambiou o tema desta sala para: %2$s %1$s cambiou o nome desta sala para: %2$s %s iniciou unha chamada de vídeo. %s iniciou unha chamada de voz. diff --git a/matrix-sdk-android/src/main/res/values-hu/strings.xml b/matrix-sdk-android/src/main/res/values-hu/strings.xml index ccbcead0c1..40548dbe90 100644 --- a/matrix-sdk-android/src/main/res/values-hu/strings.xml +++ b/matrix-sdk-android/src/main/res/values-hu/strings.xml @@ -18,7 +18,7 @@ %1$s megváltoztatták a megjelenő nevüket erre: %2$s %1$s megváltoztatták a megjelenő nevüket erről %2$s erre %3$s %1$s eltávolították a megjelenő nevüket (%2$s) - %1$s megváltoztatta a témát erre: %2$s + %1$s megváltoztatta a témát erre: %2$s %1$s megváltoztatta a szoba nevét erre: %2$s %s videóhívást kezdeményezett. %s hanghívást kezdeményezett. diff --git a/matrix-sdk-android/src/main/res/values-is/strings.xml b/matrix-sdk-android/src/main/res/values-is/strings.xml index e665055ac3..5c69d656a6 100644 --- a/matrix-sdk-android/src/main/res/values-is/strings.xml +++ b/matrix-sdk-android/src/main/res/values-is/strings.xml @@ -45,7 +45,7 @@ %1$s setti birtingarnafn sitt sem %2$s %1$s breytti birtingarnafni sínu úr %2$s í %3$s %1$s fjarlægði birtingarnafn sitt (%2$s) - %1$s breytti umræðuefninu í: %2$s + %1$s breytti umræðuefninu í: %2$s %1$s breytti heiti spjallrásarinnar í: %2$s %s hringdi myndsamtal. %s hringdi raddsamtal. diff --git a/matrix-sdk-android/src/main/res/values-it/strings.xml b/matrix-sdk-android/src/main/res/values-it/strings.xml index 5348662fe5..f0b04fd29b 100644 --- a/matrix-sdk-android/src/main/res/values-it/strings.xml +++ b/matrix-sdk-android/src/main/res/values-it/strings.xml @@ -18,7 +18,7 @@ %1$s hanno cambiato il nome visualizzato con %2$s %1$s ha cambiato il nome visualizzato da %2$s a %3$s %1$s ha rimosso il nome visibile (%2$s) - %1$s ha cambiato l\'argomento con: %2$s + %1$s ha cambiato l\'argomento con: %2$s %1$s ha cambiato il nome della stanza con: %2$s %s ha iniziato una chiamata video. %s ha iniziato una chiamata vocale. diff --git a/matrix-sdk-android/src/main/res/values-lv/strings.xml b/matrix-sdk-android/src/main/res/values-lv/strings.xml index 0e7a9cc0ba..72757e4985 100644 --- a/matrix-sdk-android/src/main/res/values-lv/strings.xml +++ b/matrix-sdk-android/src/main/res/values-lv/strings.xml @@ -18,7 +18,7 @@ %1$s uzstādīja redzamo vārdu uz %2$s %1$s nomainīja redzamo vārdu no %2$s uz %3$s %1$s dzēsa savu redzamo vārdu (%2$s) - %1$s nomainīja tēmas nosaukumu uz: %2$s + %1$s nomainīja tēmas nosaukumu uz: %2$s %1$s nomainīja istabas nosaukumu uz: %2$s %s veica video zvanu. %s veica audio zvanu. diff --git a/matrix-sdk-android/src/main/res/values-nl/strings.xml b/matrix-sdk-android/src/main/res/values-nl/strings.xml index 11f8e438d1..6f43817623 100644 --- a/matrix-sdk-android/src/main/res/values-nl/strings.xml +++ b/matrix-sdk-android/src/main/res/values-nl/strings.xml @@ -19,7 +19,7 @@ %1$s heeft zijn of haar naam aangepast naar %2$s %1$s heeft zijn of haar naam aangepast van %2$s naar %3$s %1$s heeft zijn of haar naam verwijderd (%2$s) - %1$s heeft het onderwerp veranderd naar: %2$s + %1$s heeft het onderwerp veranderd naar: %2$s %1$s heeft de ruimtenaam veranderd naar: %2$s %s heeft een video-oproep geplaatst. %s heeft een spraak-oproep geplaatst. diff --git a/matrix-sdk-android/src/main/res/values-nn/strings.xml b/matrix-sdk-android/src/main/res/values-nn/strings.xml index b9010f0ceb..19845ddfe6 100644 --- a/matrix-sdk-android/src/main/res/values-nn/strings.xml +++ b/matrix-sdk-android/src/main/res/values-nn/strings.xml @@ -21,7 +21,7 @@ %1$s sette visingsnamnet sitt som %2$s %1$s endra visingsnamnet sitt frå %2$s til %3$s %1$s fjerna visingsnamnet sitt (%2$s) - %1$s endra emnet til: %2$s + %1$s endra emnet til: %2$s %1$s endra romnamnet til: %2$s %s starta ei videosamtale. %s starta ei røystsamtale. diff --git a/matrix-sdk-android/src/main/res/values-pl/strings.xml b/matrix-sdk-android/src/main/res/values-pl/strings.xml index 9cdc88bd10..27821c7f4b 100644 --- a/matrix-sdk-android/src/main/res/values-pl/strings.xml +++ b/matrix-sdk-android/src/main/res/values-pl/strings.xml @@ -17,7 +17,7 @@ %1$s zmienił wyświetlaną nazwę na %2$s %1$s zmienił wyświetlaną nazwę z %2$s na %3$s %1$s usunął swoją wyświetlaną nazwę (%2$s) - %1$s zmienił temat na: %2$s + %1$s zmienił temat na: %2$s Nie udało się wysłać wiadomości Nie udało się wysłać zdjęcia diff --git a/matrix-sdk-android/src/main/res/values-pt-rBR/strings.xml b/matrix-sdk-android/src/main/res/values-pt-rBR/strings.xml index 25e5739093..0feff860a0 100644 --- a/matrix-sdk-android/src/main/res/values-pt-rBR/strings.xml +++ b/matrix-sdk-android/src/main/res/values-pt-rBR/strings.xml @@ -19,7 +19,7 @@ %1$s definiu seu nome público como %2$s %1$s alterou seu nome públido de %2$s para %3$s %1$s apagou seu nome público (%2$s) - %1$s alterou o tópico desta sala para: %2$s + %1$s alterou o tópico desta sala para: %2$s %1$s alterou o nome desta sala para: %2$s %s iniciou uma chamada de vídeo. %s iniciou uma chamada de voz. diff --git a/matrix-sdk-android/src/main/res/values-pt/strings.xml b/matrix-sdk-android/src/main/res/values-pt/strings.xml index 6d8500a6a4..1fc2d17d9b 100644 --- a/matrix-sdk-android/src/main/res/values-pt/strings.xml +++ b/matrix-sdk-android/src/main/res/values-pt/strings.xml @@ -19,7 +19,7 @@ %1$s definiu seu nome público como %2$s %1$s alterou seu nome público de %2$s para %3$s %1$s apagou o seu nome público (%2$s) - %1$s alterou o tópico desta sala para: %2$s + %1$s alterou o tópico desta sala para: %2$s %1$s alterou o nome desta sala para: %2$s %s iniciou uma chamada de vídeo. %s iniciou uma chamada de voz. diff --git a/matrix-sdk-android/src/main/res/values-ru/strings.xml b/matrix-sdk-android/src/main/res/values-ru/strings.xml index 704ea394df..24ba2fc1bf 100644 --- a/matrix-sdk-android/src/main/res/values-ru/strings.xml +++ b/matrix-sdk-android/src/main/res/values-ru/strings.xml @@ -19,7 +19,7 @@ %1$s установил(а) имя %2$s %1$s изменил(а) имя с %2$s на %3$s %1$s удалил(а) свое имя (%2$s) - %1$s изменил(а) тему на: %2$s + %1$s изменил(а) тему на: %2$s %1$s изменил(а) название комнаты: %2$s %s начал(а) видеовызов. %s начал(а) голосовой вызов. diff --git a/matrix-sdk-android/src/main/res/values-sk/strings.xml b/matrix-sdk-android/src/main/res/values-sk/strings.xml index fb98be0233..60caf5c354 100644 --- a/matrix-sdk-android/src/main/res/values-sk/strings.xml +++ b/matrix-sdk-android/src/main/res/values-sk/strings.xml @@ -18,7 +18,7 @@ %1$s si nastavil zobrazované meno %2$s %1$s si zmenil zobrazované meno z %2$s na %3$s %1$s odstránil svoje zobrazované meno (%2$s) - %1$s zmenil tému na: %2$s + %1$s zmenil tému na: %2$s %1$s zmenil názov miestnosti na: %2$s %s uskutočnil video hovor. %s uskutočnil audio hovor. diff --git a/matrix-sdk-android/src/main/res/values-te/strings.xml b/matrix-sdk-android/src/main/res/values-te/strings.xml index 207e69c03f..b5e7333691 100644 --- a/matrix-sdk-android/src/main/res/values-te/strings.xml +++ b/matrix-sdk-android/src/main/res/values-te/strings.xml @@ -11,7 +11,7 @@ %1$s వారి డిస్ప్లే పేరును ని సెట్ చేసారు %2$s %1$s వారి ప్రదర్శన పేరును %2$s నుండి %3$s మార్చారు %1$s వారి ప్రదర్శన పేరుని తీసివేసారు (%2$s) - %1$s అంశం మార్చబడింది:%2$s + %1$s అంశం మార్చబడింది:%2$s %1$s గది పెరు మార్చబడింది %2$s %s ఒక వీడియో కాల్ని ఉంచింది. %s వాయిస్ కాల్ని ఉంచారు. diff --git a/matrix-sdk-android/src/main/res/values-zh-rCN/strings.xml b/matrix-sdk-android/src/main/res/values-zh-rCN/strings.xml index 5d5edf5c41..299bb2babf 100644 --- a/matrix-sdk-android/src/main/res/values-zh-rCN/strings.xml +++ b/matrix-sdk-android/src/main/res/values-zh-rCN/strings.xml @@ -14,7 +14,7 @@ %1$s 将他们的昵称设置为 %2$s %1$s 把他们的昵称从 %2$s 改为 %3$s %1$s 移除了他们的昵称 (%2$s) - %1$s 把主题改为: %2$s + %1$s 把主题改为: %2$s %1$s 把聊天室名称改为: %2$s %s 发起了一次视频通话。 %s 发起了一次语音通话。 diff --git a/matrix-sdk-android/src/main/res/values-zh-rTW/strings.xml b/matrix-sdk-android/src/main/res/values-zh-rTW/strings.xml index 516201cbf8..4c4c77ef04 100644 --- a/matrix-sdk-android/src/main/res/values-zh-rTW/strings.xml +++ b/matrix-sdk-android/src/main/res/values-zh-rTW/strings.xml @@ -18,7 +18,7 @@ %1$s 設定了他們的顯示名稱為 %2$s %1$s 變更了他們的顯示名稱從 %2$s 到 %3$s %1$s 移除了他們的顯示名稱 (%2$s) - %1$s 變更主題為:%2$s + %1$s 變更主題為:%2$s %1$s 變更房間名稱為:%2$s %s 撥出了視訊通話。 %s 撥出了語音通話。 diff --git a/matrix-sdk-android/src/main/res/values/strings.xml b/matrix-sdk-android/src/main/res/values/strings.xml index 1adced175b..e5e08506eb 100644 --- a/matrix-sdk-android/src/main/res/values/strings.xml +++ b/matrix-sdk-android/src/main/res/values/strings.xml @@ -19,7 +19,7 @@ %1$s set their display name to %2$s %1$s changed their display name from %2$s to %3$s %1$s removed their display name (%2$s) - %1$s changed the topic to: %2$s + %1$s changed the topic to: %2$s %1$s changed the room name to: %2$s %s placed a video call. %s placed a voice call. From cb05d10824790d3e583560ece25b35146d3e841b Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 16 Jan 2019 10:41:32 +0100 Subject: [PATCH 2/2] Timeline : fix minor UI issues --- .../room/detail/timeline/MessageItemFactory.kt | 17 +++++++++++++---- .../detail/timeline/TimelineEventController.kt | 2 +- .../room/detail/timeline/TimelineItemFactory.kt | 5 +---- .../res/layout/item_timeline_event_notice.xml | 4 +++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt index 2122e5457f..c1917b5aca 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/MessageItemFactory.kt @@ -4,10 +4,11 @@ import android.text.SpannableStringBuilder import android.text.util.Linkify import im.vector.matrix.android.api.permalinks.MatrixLinkify 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.TimelineEvent import im.vector.matrix.android.api.session.events.model.toModel import im.vector.matrix.android.api.session.room.model.MessageContent -import org.threeten.bp.LocalDateTime +import im.vector.riotredesign.core.extensions.localDateTime class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatter) { @@ -15,8 +16,6 @@ class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatte fun create(event: TimelineEvent, nextEvent: TimelineEvent?, - addDaySeparator: Boolean, - date: LocalDateTime, callback: TimelineEventController.Callback? ): MessageItem? { @@ -26,7 +25,17 @@ class MessageItemFactory(private val timelineDateFormatter: TimelineDateFormatte return null } val nextRoomMember = nextEvent?.roomMember - if (addDaySeparator || nextRoomMember != roomMember) { + + val date = event.root.localDateTime() + val nextDate = nextEvent?.root?.localDateTime() + val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate() + val isNextMessageReceivedMoreThanOneHourAgo = nextDate?.isBefore(date.minusMinutes(60)) + ?: false + + if (addDaySeparator + || nextRoomMember != roomMember + || nextEvent.root.type != EventType.MESSAGE + || isNextMessageReceivedMoreThanOneHourAgo) { messagesDisplayedWithInformation.add(event.root.eventId) } diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt index b388f3ab0a..caede52053 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineEventController.kt @@ -49,7 +49,7 @@ class TimelineEventController(private val roomId: String, val nextDate = nextEvent?.root?.localDateTime() val addDaySeparator = date.toLocalDate() != nextDate?.toLocalDate() - timelineItemFactory.create(event, nextEvent, addDaySeparator, date, callback)?.also { + timelineItemFactory.create(event, nextEvent, callback)?.also { it.id(event.localId) epoxyModels.add(it) } diff --git a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt index fadc226822..0d8e1f86ae 100644 --- a/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt +++ b/app/src/main/java/im/vector/riotredesign/features/home/room/detail/timeline/TimelineItemFactory.kt @@ -3,7 +3,6 @@ package im.vector.riotredesign.features.home.room.detail.timeline import com.airbnb.epoxy.EpoxyModel import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.events.model.TimelineEvent -import org.threeten.bp.LocalDateTime class TimelineItemFactory(private val messageItemFactory: MessageItemFactory, private val roomNameItemFactory: RoomNameItemFactory, @@ -13,12 +12,10 @@ class TimelineItemFactory(private val messageItemFactory: MessageItemFactory, fun create(event: TimelineEvent, nextEvent: TimelineEvent?, - addDaySeparator: Boolean, - date: LocalDateTime, callback: TimelineEventController.Callback?): EpoxyModel<*>? { return when (event.root.type) { - EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, addDaySeparator, date, callback) + EventType.MESSAGE -> messageItemFactory.create(event, nextEvent, callback) EventType.STATE_ROOM_NAME -> roomNameItemFactory.create(event) EventType.STATE_ROOM_TOPIC -> roomTopicItemFactory.create(event) EventType.STATE_ROOM_MEMBER -> roomMemberItemFactory.create(event) diff --git a/app/src/main/res/layout/item_timeline_event_notice.xml b/app/src/main/res/layout/item_timeline_event_notice.xml index 169fe15656..5edd7d345c 100644 --- a/app/src/main/res/layout/item_timeline_event_notice.xml +++ b/app/src/main/res/layout/item_timeline_event_notice.xml @@ -4,7 +4,9 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:paddingLeft="16dp" + android:paddingRight="16dp">