From 60c873aa6687b65b0c558bb6c0349e33c084230c Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 25 Jun 2020 12:12:50 +0200 Subject: [PATCH] Clean code --- .../im/vector/matrix/android/api/session/Session.kt | 1 - .../api/session/room/model/EventAnnotationsSummary.kt | 2 +- .../android/api/session/typing/TypingUsersTracker.kt | 1 - .../android/internal/database/query/ReadQueries.kt | 3 +-- .../internal/session/SessionLifecycleObserver.kt | 10 +++++----- .../internal/session/room/DefaultRoomService.kt | 3 --- .../session/room/summary/RoomSummaryDataSource.kt | 2 +- .../internal/session/room/timeline/DefaultTimeline.kt | 3 --- ...oadStateTracker.kt => DefaultTypingUsersTracker.kt} | 0 .../features/home/room/detail/RoomDetailViewModel.kt | 4 +--- .../features/home/room/detail/RoomDetailViewState.kt | 1 - .../detail/timeline/item/TimelineReadMarkerItem.kt | 1 - .../riotx/features/home/room/typing/TypingHelper.kt | 8 ++++++-- 13 files changed, 15 insertions(+), 24 deletions(-) rename matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/typing/{DefaultContentUploadStateTracker.kt => DefaultTypingUsersTracker.kt} (100%) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt index cce53b9e3b..018aae4580 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/Session.kt @@ -202,5 +202,4 @@ interface Session : } val sharedSecretStorageService: SharedSecretStorageService - } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/EventAnnotationsSummary.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/EventAnnotationsSummary.kt index f729e69055..5b5e18707d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/EventAnnotationsSummary.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/EventAnnotationsSummary.kt @@ -18,7 +18,7 @@ package im.vector.matrix.android.api.session.room.model data class EventAnnotationsSummary( var eventId: String, var reactionsSummary: List = emptyList(), - var editSummary: EditAggregatedSummary?= null, + var editSummary: EditAggregatedSummary? = null, var pollResponseSummary: PollResponseAggregatedSummary? = null, var referencesAggregatedSummary: ReferencesAggregatedSummary? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/typing/TypingUsersTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/typing/TypingUsersTracker.kt index 6abc61d2d7..642541fd2f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/typing/TypingUsersTracker.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/typing/TypingUsersTracker.kt @@ -34,5 +34,4 @@ interface TypingUsersTracker { * Returns a LiveData of the sender information of all currently typing users in a room, excluding yourself. */ fun getTypingUsersLive(roomId: String): LiveData> - } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/ReadQueries.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/ReadQueries.kt index 4d312522f0..df1f817f47 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/ReadQueries.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/ReadQueries.kt @@ -15,7 +15,6 @@ */ package im.vector.matrix.android.internal.database.query -import com.zhuinden.monarchy.Monarchy import im.vector.matrix.android.api.session.events.model.LocalEcho import im.vector.matrix.android.internal.database.model.ChunkEntity import im.vector.matrix.android.internal.database.model.ReadMarkerEntity @@ -36,7 +35,7 @@ internal fun isEventRead(realmConfiguration: RealmConfiguration, } var isEventRead = false - Realm.getInstance(realmConfiguration).use{ realm -> + Realm.getInstance(realmConfiguration).use { realm -> val liveChunk = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId) ?: return@use val eventToCheck = liveChunk.timelineEvents.find(eventId) isEventRead = if (eventToCheck == null || eventToCheck.root?.sender == userId) { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionLifecycleObserver.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionLifecycleObserver.kt index 92af3c1fe1..2147fc7bce 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionLifecycleObserver.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/SessionLifecycleObserver.kt @@ -27,16 +27,16 @@ internal interface SessionLifecycleObserver { Called when the session is opened */ @MainThread - fun onStart(){ - //noop + fun onStart() { + // noop } /* Called when the session is cleared */ @MainThread - fun onClearCache(){ - //noop + fun onClearCache() { + // noop } /* @@ -44,6 +44,6 @@ internal interface SessionLifecycleObserver { */ @MainThread fun onStop() { - //noop + // noop } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt index 177f803ab3..c773682c0f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/DefaultRoomService.kt @@ -17,7 +17,6 @@ package im.vector.matrix.android.internal.session.room import androidx.lifecycle.LiveData -import com.zhuinden.monarchy.Monarchy import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.session.room.Room import im.vector.matrix.android.api.session.room.RoomService @@ -26,8 +25,6 @@ import im.vector.matrix.android.api.session.room.model.RoomSummary import im.vector.matrix.android.api.session.room.model.create.CreateRoomParams import im.vector.matrix.android.api.util.Cancelable import im.vector.matrix.android.api.util.Optional -import im.vector.matrix.android.internal.database.mapper.RoomSummaryMapper -import im.vector.matrix.android.internal.di.SessionDatabase import im.vector.matrix.android.internal.session.room.alias.GetRoomIdByAliasTask import im.vector.matrix.android.internal.session.room.create.CreateRoomTask import im.vector.matrix.android.internal.session.room.membership.joining.JoinRoomTask diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryDataSource.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryDataSource.kt index 56fc9083c6..7c579a2719 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryDataSource.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/summary/RoomSummaryDataSource.kt @@ -54,7 +54,7 @@ internal class RoomSummaryDataSource @Inject constructor(@SessionDatabase privat }) } - fun getRoomSummaryLive(roomId: String): LiveData>{ + fun getRoomSummaryLive(roomId: String): LiveData> { val liveData = monarchy.findAllMappedWithChanges( { realm -> RoomSummaryEntity.where(realm, roomId).isNotEmpty(RoomSummaryEntityFields.DISPLAY_NAME) }, { roomSummaryMapper.map(it) } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt index f6a65457d5..8c0a75e4a9 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/DefaultTimeline.kt @@ -21,11 +21,8 @@ import im.vector.matrix.android.api.extensions.orFalse import im.vector.matrix.android.api.session.events.model.EventType import im.vector.matrix.android.api.session.events.model.RelationType import im.vector.matrix.android.api.session.events.model.toModel -import im.vector.matrix.android.api.session.room.model.EventAnnotationsSummary -import im.vector.matrix.android.api.session.room.model.ReactionAggregatedSummary import im.vector.matrix.android.api.session.room.model.ReadReceipt import im.vector.matrix.android.api.session.room.model.message.MessageContent -import im.vector.matrix.android.api.session.room.model.relation.ReactionContent import im.vector.matrix.android.api.session.room.send.SendState import im.vector.matrix.android.api.session.room.timeline.Timeline import im.vector.matrix.android.api.session.room.timeline.TimelineEvent diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/typing/DefaultContentUploadStateTracker.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/typing/DefaultTypingUsersTracker.kt similarity index 100% rename from matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/typing/DefaultContentUploadStateTracker.kt rename to matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/typing/DefaultTypingUsersTracker.kt diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt index 529218216c..3e8949e94c 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewModel.kt @@ -30,7 +30,6 @@ import com.squareup.inject.assisted.AssistedInject import im.vector.matrix.android.api.MatrixCallback import im.vector.matrix.android.api.MatrixPatterns import im.vector.matrix.android.api.NoOpMatrixCallback -import im.vector.matrix.android.api.extensions.orFalse import im.vector.matrix.android.api.query.QueryStringValue import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.events.model.EventType @@ -59,7 +58,6 @@ import im.vector.matrix.android.api.session.room.timeline.getTextEditableContent import im.vector.matrix.android.api.util.toOptional import im.vector.matrix.android.internal.crypto.attachments.toElementToDecrypt import im.vector.matrix.android.internal.crypto.model.event.EncryptedEventContent -import im.vector.matrix.android.internal.extensions.observeK import im.vector.matrix.rx.asObservable import im.vector.matrix.rx.rx import im.vector.matrix.rx.unwrap @@ -1045,7 +1043,7 @@ class RoomDetailViewModel @AssistedInject constructor( } } - private fun observeTypings(){ + private fun observeTypings() { typingHelper.getTypingMessage(initialState.roomId) .asObservable() .subscribe { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewState.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewState.kt index b7268e7c61..224dd61b65 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewState.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailViewState.kt @@ -26,7 +26,6 @@ import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.session.sync.SyncState import im.vector.matrix.android.api.session.user.model.User import im.vector.matrix.android.api.session.widgets.model.Widget -import im.vector.matrix.android.api.util.MatrixItem /** * Describes the current send mode: diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/TimelineReadMarkerItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/TimelineReadMarkerItem.kt index 0fa6e6fef6..01cb3d6b57 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/TimelineReadMarkerItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/TimelineReadMarkerItem.kt @@ -25,5 +25,4 @@ import im.vector.riotx.core.epoxy.VectorEpoxyModel abstract class TimelineReadMarkerItem : VectorEpoxyModel() { class Holder : VectorEpoxyHolder() - } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/typing/TypingHelper.kt b/vector/src/main/java/im/vector/riotx/features/home/room/typing/TypingHelper.kt index c6adea4ff4..0c6960551c 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/typing/TypingHelper.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/typing/TypingHelper.kt @@ -50,9 +50,13 @@ class TypingHelper @Inject constructor( typingUsers.size == 1 -> stringProvider.getString(R.string.room_one_user_is_typing, typingUsers[0].disambiguatedDisplayName) typingUsers.size == 2 -> - stringProvider.getString(R.string.room_two_users_are_typing, typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName) + stringProvider.getString(R.string.room_two_users_are_typing, + typingUsers[0].disambiguatedDisplayName, + typingUsers[1].disambiguatedDisplayName) else -> - stringProvider.getString(R.string.room_many_users_are_typing, typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName) + stringProvider.getString(R.string.room_many_users_are_typing, + typingUsers[0].disambiguatedDisplayName, + typingUsers[1].disambiguatedDisplayName) } } }