From b3fdb5ed17d057003581bebefd64352e9c3abbd2 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 23 May 2022 12:57:57 +0200 Subject: [PATCH] Changes code style when arrow alignment --- .editorconfig | 2 +- .../AttachmentViewerActivity.kt | 4 +- .../attachmentviewer/AttachmentsAdapter.kt | 14 +- .../lib/attachmentviewer/SwipeDirection.kt | 6 +- .../SwipeDirectionDetector.kt | 4 +- .../attachmentviewer/SwipeToDismissHandler.kt | 4 +- .../lib/attachmentviewer/VideoViewHolder.kt | 2 +- .../jsonviewer/JSonViewerEpoxyController.kt | 12 +- .../jsonviewer/JSonViewerModel.kt | 10 +- .../im/vector/lib/multipicker/FilePicker.kt | 2 +- .../im/vector/lib/multipicker/MultiPicker.kt | 16 +- .../sdk/internal/crypto/E2eeSanityTests.kt | 8 +- .../internal/crypto/verification/SASTest.kt | 12 +- .../session/room/send/TestPermalinkService.kt | 2 +- .../room/timeline/PollAggregationTest.kt | 4 +- .../org/commonmark/ext/maths/InlineMaths.kt | 4 +- .../matrix/android/sdk/api/auth/converter.kt | 10 +- .../sdk/api/auth/data/SsoIdentityProvider.kt | 10 +- .../registration/RegistrationFlowResponse.kt | 10 +- .../android/sdk/api/extensions/Strings.kt | 2 +- .../sdk/api/network/ssl/Fingerprint.kt | 2 +- .../keysbackup/KeysBackupLastVersionResult.kt | 2 +- .../sdk/api/session/events/model/Event.kt | 32 +-- .../model/content/RoomKeyWithHeldContent.kt | 10 +- .../homeserver/HomeServerCapabilities.kt | 4 +- .../sdk/api/session/identity/ThreePid.kt | 2 +- .../session/permalinks/MatrixToConverter.kt | 4 +- .../api/session/permalinks/PermalinkParser.kt | 10 +- .../sdk/api/session/pushrules/Action.kt | 16 +- .../pushrules/ContainsDisplayNameCondition.kt | 2 +- .../android/sdk/api/session/pushrules/Kind.kt | 8 +- .../pushrules/RoomMemberCountCondition.kt | 4 +- .../session/pushrules/rest/PushCondition.kt | 8 +- .../session/room/model/PowerLevelsContent.kt | 4 +- .../room/model/RoomGuestAccessContent.kt | 4 +- .../model/RoomHistoryVisibilityContent.kt | 8 +- .../room/model/RoomJoinRulesContent.kt | 10 +- .../sdk/api/session/room/powerlevels/Role.kt | 6 +- .../sdk/api/session/room/send/UserDraft.kt | 2 +- .../sdk/api/session/room/sender/SenderInfo.kt | 6 +- .../session/room/timeline/TimelineEvent.kt | 8 +- .../sdk/api/session/sync/job/SyncService.kt | 2 +- .../matrix/android/sdk/api/util/MatrixItem.kt | 10 +- .../auth/DefaultAuthenticationService.kt | 2 +- .../internal/auth/login/DirectLoginTask.kt | 2 +- .../AddThreePidRegistrationParams.kt | 2 +- .../registration/DefaultRegistrationWizard.kt | 4 +- .../registration/RegisterAddThreePidTask.kt | 2 +- .../auth/registration/ThreePidData.kt | 2 +- .../auth/version/HomeServerVersion.kt | 2 +- .../internal/crypto/DefaultCryptoService.kt | 26 +- .../sdk/internal/crypto/DeviceListManager.kt | 4 +- .../crypto/IncomingKeyRequestManager.kt | 4 +- .../sdk/internal/crypto/MXCryptoAlgorithms.kt | 4 +- .../crypto/OutgoingKeyRequestManager.kt | 24 +- .../internal/crypto/RoomDecryptorProvider.kt | 2 +- .../internal/crypto/RoomEncryptorsStore.kt | 4 +- .../sdk/internal/crypto/SecretShareManager.kt | 4 +- .../crypto/algorithms/olm/MXOlmDecryption.kt | 6 +- .../crypto/crosssigning/CrossSigningOlm.kt | 12 +- .../crypto/crosssigning/UpdateTrustWorker.kt | 2 +- .../keysbackup/DefaultKeysBackupService.kt | 12 +- .../model/rest/VerificationMethodValues.kt | 2 +- .../DefaultSharedSecretStorageService.kt | 2 +- .../store/db/migration/MigrateCryptoTo004.kt | 6 +- .../crypto/store/db/model/AuditTrailMapper.kt | 8 +- ...comingSASDefaultVerificationTransaction.kt | 14 +- ...tgoingSASDefaultVerificationTransaction.kt | 14 +- .../DefaultVerificationService.kt | 40 +-- .../SASDefaultVerificationTransaction.kt | 8 +- .../crypto/verification/VerificationEmoji.kt | 126 ++++----- .../verification/VerificationInfoStart.kt | 4 +- .../VerificationMessageProcessor.kt | 2 +- .../DefaultQrCodeVerificationTransaction.kt | 14 +- .../crypto/verification/qrcode/Extensions.kt | 10 +- .../database/helper/ChunkEntityHelper.kt | 2 +- .../database/helper/ThreadSummaryHelper.kt | 2 +- .../internal/database/mapper/DraftMapper.kt | 18 +- .../database/mapper/IsUselessResolver.kt | 2 +- .../database/mapper/RoomSummaryMapper.kt | 2 +- .../internal/database/query/ReadQueries.kt | 8 +- .../android/sdk/internal/network/Request.kt | 8 +- .../internal/network/RetrofitExtensions.kt | 4 +- .../network/parsing/ForceToBoolean.kt | 4 +- .../internal/query/QueryRoomOrderProcessor.kt | 6 +- .../query/QueryStringValueProcessor.kt | 16 +- .../android/sdk/internal/raw/GetUrlTask.kt | 4 +- .../internal/session/DefaultFileService.kt | 2 +- .../session/call/CallSignalingHandler.kt | 14 +- .../session/content/ImageCompressor.kt | 14 +- .../session/content/UploadContentWorker.kt | 6 +- .../session/content/VideoCompressor.kt | 2 +- .../db/RealmContentScannerStore.kt | 2 +- .../internal/session/filter/SaveFilterTask.kt | 4 +- .../session/group/GetGroupDataTask.kt | 2 +- .../identity/DefaultIdentityService.kt | 4 +- .../IdentityRequestTokenForBindingTask.kt | 2 +- .../session/media/GetPreviewUrlTask.kt | 4 +- .../session/permalinks/PermalinkFactory.kt | 22 +- .../session/profile/AddThreePidTask.kt | 2 +- .../profile/RefreshUserThreePidsTask.kt | 6 +- .../session/pushers/AddPusherWorker.kt | 2 +- .../pushrules/ProcessEventForPushTask.kt | 2 +- .../EventRelationsAggregationProcessor.kt | 34 +-- .../room/crypto/DefaultRoomCryptoService.kt | 4 +- .../room/membership/LoadRoomMembersTask.kt | 4 +- .../RoomChangeMembershipStateDataSource.kt | 4 +- .../membership/RoomDisplayNameResolver.kt | 10 +- .../membership/admin/MembershipAdminTask.kt | 4 +- .../room/notification/RoomPushRuleMapper.kt | 8 +- .../session/room/peeking/PeekRoomTask.kt | 2 +- .../room/prune/RedactionEventProcessor.kt | 14 +- .../session/room/send/DefaultSendService.kt | 4 +- .../room/send/LocalEchoEventFactory.kt | 20 +- .../session/room/send/LocalEchoRepository.kt | 4 +- .../session/room/send/RedactEventWorker.kt | 2 +- .../session/room/send/WaveFormSanitizer.kt | 2 +- .../send/pills/MentionLinkSpecComparator.kt | 6 +- .../session/room/send/pills/TextPillsUtils.kt | 2 +- .../queue/EventSenderProcessorCoroutine.kt | 6 +- .../send/queue/EventSenderProcessorThread.kt | 8 +- .../session/room/send/queue/QueueMemento.kt | 6 +- .../room/send/queue/SendEventQueuedTask.kt | 2 +- .../session/room/state/DefaultStateService.kt | 2 +- .../session/room/summary/GraphUtils.kt | 4 +- .../room/summary/RoomSummaryDataSource.kt | 18 +- .../session/room/timeline/DefaultTimeline.kt | 6 +- .../room/timeline/LoadTimelineStrategy.kt | 4 +- .../room/timeline/PaginationDirection.kt | 2 +- .../session/room/timeline/TimelineChunk.kt | 8 +- .../room/timeline/TokenChunkEventPersistor.kt | 2 +- .../session/room/timeline/UIEchoManager.kt | 2 +- .../securestorage/SecretStoringUtils.kt | 12 +- .../sdk/internal/session/sync/SyncPresence.kt | 6 +- .../session/sync/handler/GroupSyncHandler.kt | 4 +- .../handler/UserAccountDataSyncHandler.kt | 6 +- .../sync/handler/room/RoomSyncHandler.kt | 8 +- .../internal/session/sync/job/SyncThread.kt | 4 +- .../session/terms/DefaultTermsService.kt | 2 +- .../android/sdk/internal/task/TaskExecutor.kt | 10 +- .../matrix/android/sdk/internal/util/Glob.kt | 6 +- .../sdk/internal/util/JsonCanonicalizer.kt | 6 +- .../android/sdk/internal/util/UrlUtils.kt | 8 +- .../internal/wellknown/GetWellknownTask.kt | 10 +- .../internal/worker/MatrixWorkerFactory.kt | 18 +- .../java/im/vector/app/EspressoExt.kt | 2 +- .../im/vector/app/ui/robot/ElementRobot.kt | 2 +- .../app/ui/robot/OnboardingServersRobot.kt | 2 +- .../debug/features/BooleanFeatureItem.kt | 6 +- .../debug/features/EnumFeatureItem.kt | 2 +- .../settings/DebugPrivateSettingsViewModel.kt | 6 +- .../debug/settings/OverrideDropdownView.kt | 2 +- .../debug/settings/PrivateSettingOverrides.kt | 8 +- .../im/vector/app/receivers/DebugReceiver.kt | 4 +- .../app/fdroid/BackgroundSyncStarter.kt | 4 +- .../TestBackgroundRestrictions.kt | 4 +- .../troubleshoot/TestFirebaseToken.kt | 6 +- .../java/im/vector/app/AppStateHandler.kt | 2 +- .../app/core/date/VectorDateFormatter.kt | 12 +- .../app/core/dialogs/ExportKeysDialog.kt | 4 +- .../dialogs/GalleryOrCameraDialogHelper.kt | 2 +- .../app/core/dialogs/PhotoOrVideoDialog.kt | 4 +- .../vector/app/core/error/ErrorFormatter.kt | 72 +++--- .../app/core/extensions/TextInputLayout.kt | 2 +- .../im/vector/app/core/extensions/ThreePid.kt | 2 +- .../vector/app/core/extensions/ViewPager2.kt | 2 +- .../vector/app/core/linkify/VectorLinkify.kt | 2 +- .../app/core/platform/LifecycleAwareLazy.kt | 2 +- .../core/platform/ScreenOrientationLocker.kt | 2 +- .../im/vector/app/core/platform/StateView.kt | 4 +- .../app/core/platform/VectorBaseActivity.kt | 2 +- .../app/core/preference/KeywordPreference.kt | 6 +- .../app/core/preference/PushRulePreference.kt | 14 +- .../core/services/BluetoothHeadsetReceiver.kt | 6 +- .../vector/app/core/services/CallService.kt | 6 +- .../services/WiredHeadsetStateReceiver.kt | 6 +- .../im/vector/app/core/ui/list/ItemStyle.kt | 6 +- .../app/core/ui/views/CompatKonfetti.kt | 2 +- .../app/core/ui/views/CurrentCallsView.kt | 4 +- .../app/core/ui/views/KeysBackupBanner.kt | 20 +- .../app/core/ui/views/NotificationAreaView.kt | 12 +- .../core/ui/views/PresenceStateImageView.kt | 8 +- .../app/core/ui/views/ReadReceiptsView.kt | 6 +- .../app/core/ui/views/SendStateImageView.kt | 6 +- .../app/core/ui/views/ShieldImageView.kt | 14 +- .../core/utils/ExternalApplicationsUtil.kt | 8 +- .../vector/app/core/utils/FirstThrottler.kt | 2 +- .../im/vector/app/core/utils/TextUtils.kt | 10 +- .../java/im/vector/app/core/utils/UrlUtils.kt | 8 +- .../im/vector/app/features/MainActivity.kt | 12 +- .../analytics/DecryptionFailureTracker.kt | 6 +- .../analytics/extensions/JoinedRoomExt.kt | 8 +- .../extensions/PerformanceTimerExt.kt | 2 +- .../analytics/extensions/UserPropertiesExt.kt | 6 +- .../analytics/extensions/ViewRoomExt.kt | 2 +- .../analytics/impl/DefaultVectorAnalytics.kt | 2 +- .../attachments/AttachmentTypeSelectorView.kt | 12 +- .../features/attachments/AttachmentsMapper.kt | 8 +- .../preview/AttachmentsPreviewFragment.kt | 6 +- .../preview/AttachmentsPreviewViewModel.kt | 4 +- .../app/features/auth/PromptFragment.kt | 12 +- .../app/features/auth/ReAuthActivity.kt | 8 +- .../app/features/auth/ReAuthViewModel.kt | 4 +- .../member/AutocompleteMemberController.kt | 4 +- .../app/features/call/CallControlsView.kt | 6 +- .../call/CallSoundDeviceChooserBottomSheet.kt | 4 +- .../app/features/call/VectorCallActivity.kt | 26 +- .../app/features/call/VectorCallViewModel.kt | 38 +-- .../call/audio/API23AudioDeviceDetector.kt | 6 +- .../call/audio/DefaultAudioDeviceRouter.kt | 2 +- .../call/conference/ConferenceEvent.kt | 6 +- .../conference/JitsiActiveConferenceHolder.kt | 4 +- .../call/conference/JitsiCallViewModel.kt | 2 +- .../call/conference/RemoveJitsiWidgetView.kt | 12 +- .../call/conference/VectorJitsiActivity.kt | 14 +- .../call/lookup/CallProtocolsChecker.kt | 4 +- .../call/transfer/CallTransferActivity.kt | 4 +- .../call/webrtc/PeerConnectionObserver.kt | 22 +- .../app/features/call/webrtc/WebRtcCall.kt | 4 +- .../app/features/command/CommandParser.kt | 82 +++--- .../contactsbook/ContactsBookController.kt | 6 +- .../createdirect/CreateDirectRoomActivity.kt | 22 +- .../createdirect/CreateDirectRoomViewModel.kt | 4 +- .../app/features/crypto/keys/KeysExporter.kt | 2 +- .../restore/KeysBackupRestoreActivity.kt | 6 +- .../settings/KeysBackupManageActivity.kt | 6 +- ...eysBackupSettingsRecyclerViewController.kt | 18 +- .../settings/KeysBackupSettingsViewModel.kt | 10 +- .../setup/KeysBackupSetupActivity.kt | 8 +- .../setup/KeysBackupSetupStep2Fragment.kt | 8 +- .../quads/SharedSecureStorageActivity.kt | 18 +- .../quads/SharedSecureStorageViewModel.kt | 16 +- .../quads/SharedSecuredStorageKeyFragment.kt | 2 +- .../SharedSecuredStoragePassphraseFragment.kt | 2 +- .../recover/BackupToQuadSMigrationTask.kt | 4 +- .../crypto/recover/BootstrapBottomSheet.kt | 24 +- .../BootstrapConfirmPassphraseFragment.kt | 4 +- .../recover/BootstrapSharedViewModel.kt | 76 +++--- .../features/crypto/recover/BootstrapStep.kt | 2 +- .../recover/BootstrapWaitingFragment.kt | 2 +- .../verification/VerificationBottomSheet.kt | 18 +- .../VerificationBottomSheetViewModel.kt | 26 +- .../VerificationConclusionController.kt | 4 +- .../VerificationConclusionViewModel.kt | 2 +- .../emoji/VerificationEmojiCodeController.kt | 8 +- .../emoji/VerificationEmojiCodeViewModel.kt | 10 +- .../request/VerificationRequestController.kt | 6 +- .../features/devtools/RoomDevToolActivity.kt | 28 +- .../features/devtools/RoomDevToolViewModel.kt | 32 +-- .../devtools/RoomStateListController.kt | 4 +- .../discovery/DiscoverySettingsController.kt | 26 +- .../discovery/DiscoverySettingsViewModel.kt | 26 +- .../features/discovery/SettingsButtonItem.kt | 2 +- .../SettingsTextButtonSingleLineItem.kt | 10 +- .../change/SetIdentityServerFragment.kt | 10 +- .../change/SetIdentityServerViewModel.kt | 6 +- .../app/features/form/FormEditTextItem.kt | 4 +- .../form/FormEditTextWithDeleteItem.kt | 2 +- .../form/FormEditableSquareAvatarItem.kt | 4 +- .../app/features/home/AvatarRenderer.kt | 4 +- .../vector/app/features/home/HomeActivity.kt | 42 +-- .../features/home/HomeActivityViewModel.kt | 10 +- .../app/features/home/HomeDetailFragment.kt | 28 +- .../app/features/home/HomeDetailViewModel.kt | 8 +- .../features/home/InitSyncStepFormatter.kt | 18 +- .../app/features/home/ShortcutCreator.kt | 2 +- .../home/UnreadMessagesSharedViewModel.kt | 4 +- .../home/room/detail/AutoCompleter.kt | 4 +- .../home/room/detail/ChatEffectManager.kt | 6 +- .../detail/JoinReplacementRoomBottomSheet.kt | 2 +- .../JumpToBottomViewVisibilityManager.kt | 2 +- .../home/room/detail/RoomDetailActivity.kt | 2 +- .../room/detail/StartCallActionsHandler.kt | 4 +- .../home/room/detail/TimelineFragment.kt | 244 +++++++++--------- .../home/room/detail/TimelineViewModel.kt | 144 +++++------ .../composer/MessageComposerViewModel.kt | 138 +++++----- .../composer/MessageComposerViewState.kt | 6 +- .../composer/voice/DraggableStateProcessor.kt | 18 +- .../voice/VoiceMessageRecorderView.kt | 24 +- .../composer/voice/VoiceMessageViews.kt | 6 +- .../home/room/detail/search/SearchFragment.kt | 4 +- .../room/detail/search/SearchViewModel.kt | 4 +- .../detail/timeline/MessageColorProvider.kt | 8 +- .../action/MessageActionsEpoxyController.kt | 4 +- .../action/MessageActionsViewModel.kt | 26 +- .../ViewEditHistoryEpoxyController.kt | 4 +- .../timeline/factory/CallItemFactory.kt | 2 +- .../timeline/factory/EncryptedItemFactory.kt | 4 +- .../LiveLocationShareMessageItemFactory.kt | 12 +- .../timeline/factory/MessageItemFactory.kt | 46 ++-- .../timeline/factory/TimelineItemFactory.kt | 20 +- .../factory/VerificationItemFactory.kt | 4 +- .../timeline/factory/WidgetItemFactory.kt | 2 +- .../format/DisplayableEventFormatter.kt | 60 ++--- .../timeline/format/EventDetailsFormatter.kt | 4 +- .../timeline/format/NoticeEventFormatter.kt | 116 ++++----- .../format/RoomHistoryVisibilityFormatter.kt | 12 +- .../helper/AudioMessagePlaybackTracker.kt | 8 +- .../ContentDownloadStateTrackerBinder.kt | 8 +- .../helper/ContentUploadStateTrackerBinder.kt | 16 +- .../helper/MatrixItemColorProvider.kt | 20 +- .../helper/MessageInformationDataFactory.kt | 10 +- .../helper/TimelineDisplayableEvents.kt | 4 +- .../image/ImageContentRendererFactory.kt | 2 +- .../timeline/item/AbsBaseMessageItem.kt | 2 +- .../timeline/item/CallTileTimelineItem.kt | 26 +- .../detail/timeline/item/MessageAudioItem.kt | 6 +- .../timeline/item/MessageLiveLocationItem.kt | 6 +- .../detail/timeline/item/MessageVoiceItem.kt | 8 +- .../room/detail/timeline/item/NoticeItem.kt | 2 +- .../detail/timeline/item/PollOptionView.kt | 8 +- .../timeline/item/StatusTileTimelineItem.kt | 2 +- .../timeline/item/VerificationRequestItem.kt | 8 +- .../reactions/ViewReactionsEpoxyController.kt | 2 +- .../style/TimelineMessageLayoutFactory.kt | 12 +- .../detail/timeline/url/PreviewUrlView.kt | 18 +- .../detail/upgrade/MigrateRoomBottomSheet.kt | 8 +- .../room/list/AlphabeticalRoomComparator.kt | 4 +- .../room/list/ChronologicalRoomComparator.kt | 6 +- .../room/list/RoomListFooterController.kt | 2 +- .../home/room/list/RoomListFragment.kt | 56 ++-- .../room/list/RoomListSectionBuilderGroup.kt | 6 +- .../room/list/RoomListSectionBuilderSpace.kt | 14 +- .../home/room/list/RoomListViewModel.kt | 22 +- .../home/room/list/RoomSummaryItemFactory.kt | 2 +- .../RoomListQuickActionsBottomSheet.kt | 4 +- .../RoomListQuickActionsEpoxyController.kt | 6 +- .../home/room/threads/ThreadsActivity.kt | 4 +- .../room/threads/list/model/ThreadListItem.kt | 4 +- .../list/viewmodel/ThreadListController.kt | 2 +- .../list/viewmodel/ThreadListViewModel.kt | 2 +- .../threads/list/views/ThreadListFragment.kt | 6 +- .../features/home/room/typing/TypingHelper.kt | 4 +- .../app/features/html/FontTagHandler.kt | 32 +-- .../app/features/html/PillsPostProcessor.kt | 8 +- .../invite/InviteButtonStateBinder.kt | 6 +- .../invite/InviteUsersToRoomActivity.kt | 8 +- .../invite/InviteUsersToRoomViewModel.kt | 6 +- .../VectorActivityLifecycleCallbacks.kt | 4 +- .../app/features/link/LinkHandlerActivity.kt | 10 +- .../location/LocationSharingActivity.kt | 2 +- .../location/LocationSharingFragment.kt | 10 +- .../location/LocationSharingViewModel.kt | 8 +- .../app/features/location/LocationTracker.kt | 2 +- .../duration/ChooseLiveDurationBottomSheet.kt | 2 +- .../features/login/AbstractLoginFragment.kt | 6 +- .../app/features/login/LoginActivity.kt | 48 ++-- .../app/features/login/LoginFragment.kt | 36 +-- .../LoginGenericTextInputFormFragment.kt | 26 +- .../im/vector/app/features/login/LoginMode.kt | 8 +- .../login/LoginResetPasswordFragment.kt | 4 +- ...inResetPasswordMailConfirmationFragment.kt | 2 +- .../login/LoginServerUrlFormFragment.kt | 4 +- .../LoginSignUpSignInSelectionFragment.kt | 10 +- .../app/features/login/LoginViewModel.kt | 84 +++--- .../app/features/login/LoginWebFragment.kt | 6 +- .../features/login/SocialLoginButtonsView.kt | 20 +- .../features/login2/AbstractLoginFragment2.kt | 6 +- .../LoginGenericTextInputFormFragment2.kt | 30 +-- .../login2/LoginServerSelectionFragment2.kt | 4 +- .../login2/LoginServerUrlFormFragment2.kt | 2 +- .../app/features/login2/LoginViewModel2.kt | 112 ++++---- .../app/features/login2/LoginWebFragment2.kt | 6 +- .../login2/created/AccountCreatedViewModel.kt | 2 +- .../features/matrixto/MatrixToBottomSheet.kt | 14 +- .../matrixto/MatrixToBottomSheetViewModel.kt | 32 +-- .../matrixto/MatrixToRoomSpaceFragment.kt | 34 +-- .../features/matrixto/MatrixToUserFragment.kt | 12 +- .../app/features/matrixto/OriginOfMatrixTo.kt | 20 +- .../media/DataAttachmentRoomProvider.kt | 2 +- .../features/media/ImageContentRenderer.kt | 4 +- .../features/navigation/DefaultNavigator.kt | 22 +- .../notifications/NotifiableEventProcessor.kt | 10 +- .../notifications/NotifiableEventResolver.kt | 8 +- .../notifications/NotificationAction.kt | 6 +- .../NotificationBroadcastReceiver.kt | 10 +- .../notifications/NotificationEventQueue.kt | 18 +- .../notifications/NotificationFactory.kt | 8 +- .../notifications/NotificationRenderer.kt | 8 +- .../notifications/RoomGroupMessageCreator.kt | 2 +- .../features/onboarding/DirectLoginUseCase.kt | 2 +- .../app/features/onboarding/Login2Variant.kt | 50 ++-- .../onboarding/OnboardingVariantFactory.kt | 4 +- .../onboarding/OnboardingViewModel.kt | 112 ++++---- .../onboarding/RegistrationActionHandler.kt | 26 +- .../StartAuthenticationFlowUseCase.kt | 8 +- .../onboarding/UriFilenameResolver.kt | 2 +- .../ftueauth/AbstractFtueAuthFragment.kt | 6 +- .../onboarding/ftueauth/CaptchaWebview.kt | 2 +- .../FtueAuthChooseDisplayNameFragment.kt | 2 +- .../FtueAuthChooseProfilePictureFragment.kt | 2 +- .../FtueAuthCombinedRegisterFragment.kt | 2 +- ...FtueAuthCombinedServerSelectionFragment.kt | 2 +- .../FtueAuthGenericTextInputFormFragment.kt | 26 +- .../ftueauth/FtueAuthLoginFragment.kt | 40 +-- .../ftueauth/FtueAuthServerUrlFormFragment.kt | 4 +- .../FtueAuthSignUpSignInSelectionFragment.kt | 10 +- .../onboarding/ftueauth/FtueAuthVariant.kt | 86 +++--- .../ftueauth/FtueAuthWaitForEmailFragment.kt | 4 +- .../ftueauth/FtueAuthWebFragment.kt | 6 +- ...FtueMissingRegistrationStagesComparator.kt | 10 +- .../ftueauth/SplashCarouselStateFactory.kt | 2 +- .../features/permalink/PermalinkHandler.kt | 18 +- .../im/vector/app/features/pin/PinFragment.kt | 6 +- .../poll/create/CreatePollFragment.kt | 6 +- .../poll/create/CreatePollViewModel.kt | 14 +- .../poll/create/PollTypeSelectionItem.kt | 2 +- .../features/qrcode/QrCodeScannerActivity.kt | 4 +- .../features/qrcode/QrCodeScannerViewModel.kt | 4 +- .../features/rageshake/BugReportActivity.kt | 20 +- .../app/features/rageshake/BugReporter.kt | 20 +- .../reactions/EmojiRecyclerAdapter.kt | 6 +- .../room/RequireActiveMembershipViewModel.kt | 4 +- .../VectorRoomDisplayNameFallbackProvider.kt | 8 +- .../features/roomdirectory/PublicRoomItem.kt | 6 +- .../roomdirectory/PublicRoomsController.kt | 10 +- .../roomdirectory/PublicRoomsFragment.kt | 4 +- .../roomdirectory/RoomDirectoryActivity.kt | 8 +- .../roomdirectory/RoomDirectoryViewModel.kt | 6 +- .../createroom/CreateRoomActivity.kt | 4 +- .../createroom/CreateRoomFragment.kt | 2 +- .../createroom/CreateRoomViewModel.kt | 28 +- .../createroom/RoomAliasErrorFormatter.kt | 6 +- .../picker/RoomDirectoryPickerController.kt | 8 +- .../picker/RoomDirectoryPickerViewModel.kt | 8 +- .../RoomPreviewNoPreviewFragment.kt | 12 +- .../roompreview/RoomPreviewViewModel.kt | 10 +- .../RoomMemberProfileFragment.kt | 24 +- .../RoomMemberProfileViewModel.kt | 28 +- .../devices/DeviceListBottomSheetViewModel.kt | 2 +- .../devices/DeviceListEpoxyController.kt | 6 +- .../powerlevel/EditPowerLevelDialogs.kt | 12 +- .../roomprofile/RoomProfileActivity.kt | 16 +- .../roomprofile/RoomProfileFragment.kt | 16 +- .../roomprofile/RoomProfileViewModel.kt | 10 +- .../roomprofile/alias/RoomAliasController.kt | 16 +- .../roomprofile/alias/RoomAliasFragment.kt | 14 +- .../roomprofile/alias/RoomAliasViewModel.kt | 32 +-- .../banned/RoomBannedMemberListFragment.kt | 2 +- .../banned/RoomBannedMemberListViewModel.kt | 2 +- .../members/RoomMemberListViewModel.kt | 10 +- .../members/RoomMemberSummaryComparator.kt | 8 +- .../RoomNotificationSettingsController.kt | 6 +- .../RoomNotificationSettingsViewState.kt | 4 +- .../roomprofile/permissions/RoleFormatter.kt | 4 +- .../permissions/RoomPermissionsController.kt | 34 +-- .../permissions/RoomPermissionsFragment.kt | 2 +- .../permissions/RoomPermissionsViewModel.kt | 16 +- .../settings/RoomSettingsController.kt | 4 +- .../settings/RoomSettingsFragment.kt | 8 +- .../settings/RoomSettingsViewModel.kt | 18 +- .../settings/RoomSettingsViewState.kt | 8 +- .../settings/joinrule/RoomJoinRuleActivity.kt | 8 +- .../advanced/ChooseRestrictedController.kt | 2 +- .../RoomJoinRuleChooseRestrictedViewModel.kt | 14 +- .../uploads/RoomUploadsFragment.kt | 4 +- .../uploads/RoomUploadsViewModel.kt | 6 +- .../uploads/files/RoomUploadsFilesFragment.kt | 4 +- .../uploads/media/RoomUploadsMediaFragment.kt | 6 +- .../features/settings/VectorPreferences.kt | 12 +- .../settings/VectorSettingsActivity.kt | 26 +- .../VectorSettingsPreferencesFragment.kt | 2 +- .../VectorSettingsSecurityPrivacyFragment.kt | 12 +- .../deactivation/DeactivateAccountFragment.kt | 12 +- .../DeactivateAccountViewModel.kt | 6 +- .../CrossSigningSettingsController.kt | 6 +- .../CrossSigningSettingsFragment.kt | 10 +- .../CrossSigningSettingsViewModel.kt | 6 +- ...ceVerificationInfoBottomSheetController.kt | 4 +- .../settings/devices/DevicesController.kt | 4 +- .../settings/devices/DevicesViewModel.kt | 18 +- .../features/settings/devices/TrustUtils.kt | 6 +- .../devices/VectorSettingsDevicesFragment.kt | 16 +- .../devtools/AccountDataEpoxyController.kt | 4 +- .../devtools/GossipingEventsSerializer.kt | 8 +- .../GossipingTrailPagedEpoxyController.kt | 10 +- .../settings/devtools/KeyRequestsFragment.kt | 6 +- .../HomeserverSettingsController.kt | 6 +- .../VectorSettingsIgnoredUsersFragment.kt | 2 +- .../settings/legals/LegalsController.kt | 2 +- .../settings/locale/LocalePickerController.kt | 2 +- .../notifications/PushRuleDefinitions.kt | 72 +++--- ...rSettingsNotificationPreferenceFragment.kt | 8 +- ...ttingsNotificationsTroubleshootFragment.kt | 6 +- .../features/settings/push/PushGatewayItem.kt | 4 +- .../settings/push/PushGatewaysFragment.kt | 2 +- .../settings/push/PushGatewaysViewModel.kt | 2 +- .../threepids/ThreePidsSettingsController.kt | 14 +- .../threepids/ThreePidsSettingsFragment.kt | 6 +- .../threepids/ThreePidsSettingsViewModel.kt | 16 +- ...ficationTroubleshootRecyclerViewAdapter.kt | 8 +- .../features/share/IncomingShareFragment.kt | 6 +- .../features/share/IncomingShareViewModel.kt | 14 +- .../signout/soft/SoftLogoutActivity.kt | 4 +- .../signout/soft/SoftLogoutController.kt | 10 +- .../signout/soft/SoftLogoutFragment.kt | 6 +- .../signout/soft/SoftLogoutViewModel.kt | 12 +- .../features/spaces/SpaceCreationActivity.kt | 30 +-- .../features/spaces/SpaceExploreActivity.kt | 6 +- .../app/features/spaces/SpaceListFragment.kt | 10 +- .../app/features/spaces/SpaceListViewModel.kt | 16 +- .../app/features/spaces/SpaceMenuViewModel.kt | 6 +- .../features/spaces/SpacePreviewActivity.kt | 6 +- .../spaces/create/CreateSpaceViewModel.kt | 38 +-- .../explore/SpaceDirectoryController.kt | 4 +- .../spaces/explore/SpaceDirectoryFragment.kt | 10 +- .../spaces/explore/SpaceDirectoryViewModel.kt | 26 +- .../spaces/invite/SpaceInviteBottomSheet.kt | 12 +- .../spaces/leave/SelectChildrenController.kt | 6 +- .../leave/SpaceLeaveAdvancedActivity.kt | 4 +- .../leave/SpaceLeaveAdvancedFragment.kt | 12 +- .../spaces/manage/SpaceAddRoomFragment.kt | 4 +- .../spaces/manage/SpaceAddRoomsViewModel.kt | 4 +- .../spaces/manage/SpaceManageActivity.kt | 20 +- .../spaces/manage/SpaceManageRoomsFragment.kt | 8 +- .../manage/SpaceManageRoomsViewModel.kt | 12 +- .../manage/SpaceManageSharedViewModel.kt | 14 +- .../spaces/manage/SpaceSettingsController.kt | 4 +- .../spaces/manage/SpaceSettingsFragment.kt | 8 +- .../spaces/people/SpacePeopleActivity.kt | 8 +- .../spaces/people/SpacePeopleFragment.kt | 4 +- .../spaces/people/SpacePeopleViewModel.kt | 2 +- .../spaces/preview/SpacePreviewController.kt | 2 +- .../spaces/preview/SpacePreviewFragment.kt | 8 +- .../spaces/preview/SpacePreviewViewModel.kt | 8 +- .../spaces/share/ShareSpaceBottomSheet.kt | 2 +- .../app/features/sync/widget/SyncStateView.kt | 20 +- .../app/features/terms/ReviewTermsActivity.kt | 2 +- .../app/features/terms/ReviewTermsFragment.kt | 6 +- .../features/terms/ReviewTermsViewModel.kt | 4 +- .../app/features/terms/TermsController.kt | 2 +- .../vector/app/features/themes/ThemeUtils.kt | 10 +- .../ui/SharedPreferencesUiStateRepository.kt | 8 +- .../app/features/usercode/UserCodeActivity.kt | 20 +- .../usercode/UserCodeSharedViewModel.kt | 18 +- .../userdirectory/PendingSelection.kt | 4 +- .../userdirectory/UserListController.kt | 22 +- .../userdirectory/UserListFragment.kt | 4 +- .../userdirectory/UserListViewModel.kt | 14 +- .../userdirectory/UserListViewState.kt | 2 +- .../app/features/voice/AudioWaveformView.kt | 2 +- .../app/features/voice/VoicePlayerHelper.kt | 4 +- .../app/features/voice/VoiceRecorderL.kt | 4 +- .../app/features/widgets/WidgetActivity.kt | 6 +- .../app/features/widgets/WidgetArgsBuilder.kt | 4 +- .../app/features/widgets/WidgetFragment.kt | 24 +- .../features/widgets/WidgetPostAPIHandler.kt | 28 +- .../app/features/widgets/WidgetViewModel.kt | 12 +- .../RoomWidgetPermissionViewModel.kt | 2 +- .../widgets/webview/WebviewPermissionUtils.kt | 6 +- .../signout/ServerBackupStatusViewModel.kt | 2 +- .../SignOutBottomSheetDialogFragment.kt | 8 +- .../workers/signout/SignoutCheckViewModel.kt | 2 +- 553 files changed, 3106 insertions(+), 3106 deletions(-) diff --git a/.editorconfig b/.editorconfig index 4640e50d15..231d35cfe4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -764,7 +764,7 @@ ij_groovy_while_on_new_line = false ij_groovy_wrap_long_lines = false [{*.gradle.kts,*.kt,*.kts,*.main.kts}] -ij_kotlin_align_in_columns_case_branch = true +ij_kotlin_align_in_columns_case_branch = false ij_kotlin_align_multiline_binary_operation = false ij_kotlin_align_multiline_extends_list = false ij_kotlin_align_multiline_method_parentheses = false diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt index 21af114c26..764cf8419a 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentViewerActivity.kt @@ -271,7 +271,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi directionDetector.handleTouchEvent(event) return when (swipeDirection) { - SwipeDirection.Up, SwipeDirection.Down -> { + SwipeDirection.Up, SwipeDirection.Down -> { if (isSwipeToDismissAllowed && !wasScaled && isImagePagerIdle) { swipeDismissHandler.onTouch(views.rootContainer, event) } else true @@ -279,7 +279,7 @@ abstract class AttachmentViewerActivity : AppCompatActivity(), AttachmentEventLi SwipeDirection.Left, SwipeDirection.Right -> { views.attachmentPager.dispatchTouchEvent(event) } - else -> true + else -> true } } diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentsAdapter.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentsAdapter.kt index 4805a1186b..77ddb27c63 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentsAdapter.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/AttachmentsAdapter.kt @@ -42,18 +42,18 @@ class AttachmentsAdapter : RecyclerView.Adapter() { val inflater = LayoutInflater.from(parent.context) val itemView = inflater.inflate(viewType, parent, false) return when (viewType) { - R.layout.item_image_attachment -> ZoomableImageViewHolder(itemView) + R.layout.item_image_attachment -> ZoomableImageViewHolder(itemView) R.layout.item_animated_image_attachment -> AnimatedImageViewHolder(itemView) - R.layout.item_video_attachment -> VideoViewHolder(itemView) - else -> UnsupportedViewHolder(itemView) + R.layout.item_video_attachment -> VideoViewHolder(itemView) + else -> UnsupportedViewHolder(itemView) } } override fun getItemViewType(position: Int): Int { val info = attachmentSourceProvider!!.getAttachmentInfoAt(position) return when (info) { - is AttachmentInfo.Image -> R.layout.item_image_attachment - is AttachmentInfo.Video -> R.layout.item_video_attachment + is AttachmentInfo.Image -> R.layout.item_image_attachment + is AttachmentInfo.Video -> R.layout.item_video_attachment is AttachmentInfo.AnimatedImage -> R.layout.item_animated_image_attachment // is AttachmentInfo.Audio -> TODO() // is AttachmentInfo.File -> TODO() @@ -68,13 +68,13 @@ class AttachmentsAdapter : RecyclerView.Adapter() { attachmentSourceProvider?.getAttachmentInfoAt(position)?.let { holder.bind(it) when (it) { - is AttachmentInfo.Image -> { + is AttachmentInfo.Image -> { attachmentSourceProvider?.loadImage((holder as ZoomableImageViewHolder).target, it) } is AttachmentInfo.AnimatedImage -> { attachmentSourceProvider?.loadImage((holder as AnimatedImageViewHolder).target, it) } - is AttachmentInfo.Video -> { + is AttachmentInfo.Video -> { attachmentSourceProvider?.loadVideo((holder as VideoViewHolder).target, it) } // else -> { diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirection.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirection.kt index 7948f37ae8..7816a5a2cc 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirection.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirection.kt @@ -27,12 +27,12 @@ sealed class SwipeDirection { companion object { fun fromAngle(angle: Double): SwipeDirection { return when (angle) { - in 0.0..45.0 -> Right - in 45.0..135.0 -> Up + in 0.0..45.0 -> Right + in 45.0..135.0 -> Up in 135.0..225.0 -> Left in 225.0..315.0 -> Down in 315.0..360.0 -> Right - else -> NotDetected + else -> NotDetected } } } diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirectionDetector.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirectionDetector.kt index 6575248b2d..7b72637c06 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirectionDetector.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeDirectionDetector.kt @@ -33,7 +33,7 @@ class SwipeDirectionDetector( fun handleTouchEvent(event: MotionEvent) { when (event.action) { - MotionEvent.ACTION_DOWN -> { + MotionEvent.ACTION_DOWN -> { startX = event.x startY = event.y } @@ -45,7 +45,7 @@ class SwipeDirectionDetector( startX = startY isDetected = false } - MotionEvent.ACTION_MOVE -> if (!isDetected && getEventDistance(event) > touchSlop) { + MotionEvent.ACTION_MOVE -> if (!isDetected && getEventDistance(event) > touchSlop) { isDetected = true onDirectionDetected(getDirection(startX, startY, event.x, event.y)) } diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeToDismissHandler.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeToDismissHandler.kt index 85d7c13398..7a83ee28d4 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeToDismissHandler.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/SwipeToDismissHandler.kt @@ -79,8 +79,8 @@ class SwipeToDismissHandler( private fun onTrackingEnd(parentHeight: Int) { val animateTo = when { swipeView.translationY < -translationLimit -> -parentHeight.toFloat() - swipeView.translationY > translationLimit -> parentHeight.toFloat() - else -> 0f + swipeView.translationY > translationLimit -> parentHeight.toFloat() + else -> 0f } if (animateTo != 0f && !shouldAnimateDismiss()) { diff --git a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/VideoViewHolder.kt b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/VideoViewHolder.kt index 12213a8786..92d28d26c9 100644 --- a/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/VideoViewHolder.kt +++ b/library/attachment-viewer/src/main/java/im/vector/lib/attachmentviewer/VideoViewHolder.kt @@ -146,7 +146,7 @@ class VideoViewHolder constructor(itemView: View) : wasPaused = true views.videoView.pause() } - is AttachmentCommands.SeekTo -> { + is AttachmentCommands.SeekTo -> { val duration = views.videoView.duration if (duration > 0) { val seekDuration = duration * (commands.percentProgress / 100f) diff --git a/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerEpoxyController.kt b/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerEpoxyController.kt index 9f8093f801..24b9f2ec26 100644 --- a/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerEpoxyController.kt +++ b/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerEpoxyController.kt @@ -43,7 +43,7 @@ internal class JSonViewerEpoxyController(private val context: Context) : text(async.error.localizedMessage?.toEpoxyCharSequence()) } } - else -> { + else -> { async.invoke()?.let { buildRec(it, 0, "") } @@ -98,7 +98,7 @@ internal class JSonViewerEpoxyController(private val context: Context) : } } } - is JSonViewerArray -> { + is JSonViewerArray -> { if (model.isExpanded) { open(id, model.key, model.index, depth, false, model) model.items.forEach { @@ -137,7 +137,7 @@ internal class JSonViewerEpoxyController(private val context: Context) : } } } - is JSonViewerLeaf -> { + is JSonViewerLeaf -> { valueItem { id(id) depth(depth) @@ -172,12 +172,12 @@ internal class JSonViewerEpoxyController(private val context: Context) : private fun valueToSpan(leaf: JSonViewerLeaf): Span { val host = this return when (leaf.type) { - JSONType.STRING -> { + JSONType.STRING -> { span("\"${leaf.stringRes}\"") { textColor = host.styleProvider.stringColor } } - JSONType.NUMBER -> { + JSONType.NUMBER -> { span(leaf.stringRes) { textColor = host.styleProvider.numberColor } @@ -187,7 +187,7 @@ internal class JSonViewerEpoxyController(private val context: Context) : textColor = host.styleProvider.booleanColor } } - JSONType.NULL -> { + JSONType.NULL -> { span("null") { textColor = host.styleProvider.booleanColor } diff --git a/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerModel.kt b/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerModel.kt index 6940e79e3f..2492b5454c 100644 --- a/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerModel.kt +++ b/library/jsonviewer/src/main/java/org/billcarsonfr/jsonviewer/JSonViewerModel.kt @@ -82,7 +82,7 @@ internal object ModelParser { } parent.addChild(objectComposed) } - is JSONArray -> { + is JSONArray -> { val objectComposed = JSonViewerArray(key, index, obj) .apply { isExpanded = initialOpenDepth == -1 || depth <= initialOpenDepth } objectComposed.depth = depth @@ -91,25 +91,25 @@ internal object ModelParser { } parent.addChild(objectComposed) } - is String -> { + is String -> { JSonViewerLeaf(key, index, obj, JSONType.STRING).let { it.depth = depth parent.addChild(it) } } - is Number -> { + is Number -> { JSonViewerLeaf(key, index, obj.toString(), JSONType.NUMBER).let { it.depth = depth parent.addChild(it) } } - is Boolean -> { + is Boolean -> { JSonViewerLeaf(key, index, obj.toString(), JSONType.BOOLEAN).let { it.depth = depth parent.addChild(it) } } - else -> { + else -> { if (obj == JSONObject.NULL) { JSonViewerLeaf(key, index, "null", JSONType.NULL).let { it.depth = depth diff --git a/library/multipicker/src/main/java/im/vector/lib/multipicker/FilePicker.kt b/library/multipicker/src/main/java/im/vector/lib/multipicker/FilePicker.kt index 13ef5aa637..928fdf894c 100644 --- a/library/multipicker/src/main/java/im/vector/lib/multipicker/FilePicker.kt +++ b/library/multipicker/src/main/java/im/vector/lib/multipicker/FilePicker.kt @@ -48,7 +48,7 @@ class FilePicker : Picker() { type.isMimeTypeVideo() -> selectedUri.toMultiPickerVideoType(context) type.isMimeTypeImage() -> selectedUri.toMultiPickerImageType(context) type.isMimeTypeAudio() -> selectedUri.toMultiPickerAudioType(context) - else -> { + else -> { // Other files context.contentResolver.query(selectedUri, null, null, null, null) ?.use { cursor -> diff --git a/library/multipicker/src/main/java/im/vector/lib/multipicker/MultiPicker.kt b/library/multipicker/src/main/java/im/vector/lib/multipicker/MultiPicker.kt index e7883c9e53..9377345886 100644 --- a/library/multipicker/src/main/java/im/vector/lib/multipicker/MultiPicker.kt +++ b/library/multipicker/src/main/java/im/vector/lib/multipicker/MultiPicker.kt @@ -31,15 +31,15 @@ class MultiPicker private constructor() { @Suppress("UNCHECKED_CAST") fun get(type: MultiPicker): T { return when (type) { - IMAGE -> ImagePicker() as T - VIDEO -> VideoPicker() as T - MEDIA -> MediaPicker() as T - FILE -> FilePicker() as T - AUDIO -> AudioPicker() as T - CONTACT -> ContactPicker() as T - CAMERA -> CameraPicker() as T + IMAGE -> ImagePicker() as T + VIDEO -> VideoPicker() as T + MEDIA -> MediaPicker() as T + FILE -> FilePicker() as T + AUDIO -> AudioPicker() as T + CONTACT -> ContactPicker() as T + CAMERA -> CameraPicker() as T CAMERA_VIDEO -> CameraVideoPicker() as T - else -> throw IllegalArgumentException("Unsupported type $type") + else -> throw IllegalArgumentException("Unsupported type $type") } } } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeSanityTests.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeSanityTests.kt index 552936971f..3a8053dfa7 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeSanityTests.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/E2eeSanityTests.kt @@ -651,7 +651,7 @@ class E2eeSanityTests : InstrumentedTest { // we can release this latch? oldCompleteLatch.countDown() } - else -> Unit + else -> Unit } } }) @@ -678,17 +678,17 @@ class E2eeSanityTests : InstrumentedTest { IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT -> { // no need to accept as there was a request first it will auto accept } - IncomingSasVerificationTransaction.UxState.SHOW_SAS -> { + IncomingSasVerificationTransaction.UxState.SHOW_SAS -> { if (matchOnce) { sasTx.userHasVerifiedShortCode() newCode = sasTx.getDecimalCodeRepresentation() matchOnce = false } } - IncomingSasVerificationTransaction.UxState.VERIFIED -> { + IncomingSasVerificationTransaction.UxState.VERIFIED -> { newCompleteLatch.countDown() } - else -> Unit + else -> Unit } } }) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt index 89a9430a5e..a35c4a7418 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/crypto/verification/SASTest.kt @@ -439,7 +439,7 @@ class SASTest : InstrumentedTest { OutgoingSasVerificationTransaction.UxState.SHOW_SAS -> { aliceSASLatch.countDown() } - else -> Unit + else -> Unit } } } @@ -453,7 +453,7 @@ class SASTest : InstrumentedTest { IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT -> { tx.performAccept() } - else -> Unit + else -> Unit } if (uxState === IncomingSasVerificationTransaction.UxState.SHOW_SAS) { bobSASLatch.countDown() @@ -507,7 +507,7 @@ class SASTest : InstrumentedTest { aliceSASLatch.countDown() } } - else -> Unit + else -> Unit } } } @@ -527,16 +527,16 @@ class SASTest : InstrumentedTest { tx.performAccept() } } - IncomingSasVerificationTransaction.UxState.SHOW_SAS -> { + IncomingSasVerificationTransaction.UxState.SHOW_SAS -> { if (matchOnce) { matchOnce = false tx.userHasVerifiedShortCode() } } - IncomingSasVerificationTransaction.UxState.VERIFIED -> { + IncomingSasVerificationTransaction.UxState.VERIFIED -> { bobSASLatch.countDown() } - else -> Unit + else -> Unit } } } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/TestPermalinkService.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/TestPermalinkService.kt index 2f9a5e0a73..3a267ec694 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/TestPermalinkService.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/internal/session/room/send/TestPermalinkService.kt @@ -44,7 +44,7 @@ class TestPermalinkService : PermalinkService { override fun createMentionSpanTemplate(type: PermalinkService.SpanTemplateType, forceMatrixTo: Boolean): String { return when (type) { - HTML -> "%2\$s" + HTML -> "%2\$s" MARKDOWN -> "[%2\$s](https://matrix.to/#/%1\$s)" } } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/PollAggregationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/PollAggregationTest.kt index 61ab6d4b40..3c57cb8dd5 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/PollAggregationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/PollAggregationTest.kt @@ -80,7 +80,7 @@ class PollAggregationTest : InstrumentedTest { } when (lock.count.toInt()) { - TOTAL_TEST_COUNT -> { + TOTAL_TEST_COUNT -> { // Poll has just been created. testInitialPollConditions(pollContent, pollSummary) lock.countDown() @@ -122,7 +122,7 @@ class PollAggregationTest : InstrumentedTest { testEndedPoll(pollSummary) lock.countDown() } - else -> { + else -> { fail("Lock count ${lock.count} didn't handled.") } } diff --git a/matrix-sdk-android/src/main/java/org/commonmark/ext/maths/InlineMaths.kt b/matrix-sdk-android/src/main/java/org/commonmark/ext/maths/InlineMaths.kt index 3fe8d15696..556579942b 100644 --- a/matrix-sdk-android/src/main/java/org/commonmark/ext/maths/InlineMaths.kt +++ b/matrix-sdk-android/src/main/java/org/commonmark/ext/maths/InlineMaths.kt @@ -26,14 +26,14 @@ internal class InlineMaths(private val delimiter: InlineDelimiter) : CustomNode( override fun getOpeningDelimiter(): String { return when (delimiter) { - InlineDelimiter.SINGLE_DOLLAR -> "$" + InlineDelimiter.SINGLE_DOLLAR -> "$" InlineDelimiter.ROUND_BRACKET_ESCAPED -> "\\(" } } override fun getClosingDelimiter(): String { return when (delimiter) { - InlineDelimiter.SINGLE_DOLLAR -> "$" + InlineDelimiter.SINGLE_DOLLAR -> "$" InlineDelimiter.ROUND_BRACKET_ESCAPED -> "\\)" } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/converter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/converter.kt index c840a7453d..e2f16ceee8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/converter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/converter.kt @@ -69,8 +69,8 @@ fun TermPolicies.toLocalizedLoginTerms( // Search for language policy.keys.forEach { policyKey -> when (policyKey) { - "version" -> Unit // Ignore - userLanguage -> { + "version" -> Unit // Ignore + userLanguage -> { // We found the data for the user language userLanguageUrlAndName = extractUrlAndName(policy[policyKey]) } @@ -78,7 +78,7 @@ fun TermPolicies.toLocalizedLoginTerms( // We found default language defaultLanguageUrlAndName = extractUrlAndName(policy[policyKey]) } - else -> { + else -> { if (firstUrlAndName == null) { // Get at least some data firstUrlAndName = extractUrlAndName(policy[policyKey]) @@ -89,7 +89,7 @@ fun TermPolicies.toLocalizedLoginTerms( // Copy found language data by priority when { - userLanguageUrlAndName != null -> { + userLanguageUrlAndName != null -> { localizedFlowDataLoginTermsLocalizedUrl = userLanguageUrlAndName!!.url localizedFlowDataLoginTermsLocalizedName = userLanguageUrlAndName!!.name } @@ -97,7 +97,7 @@ fun TermPolicies.toLocalizedLoginTerms( localizedFlowDataLoginTermsLocalizedUrl = defaultLanguageUrlAndName!!.url localizedFlowDataLoginTermsLocalizedName = defaultLanguageUrlAndName!!.name } - firstUrlAndName != null -> { + firstUrlAndName != null -> { localizedFlowDataLoginTermsLocalizedUrl = firstUrlAndName!!.url localizedFlowDataLoginTermsLocalizedName = firstUrlAndName!!.name } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt index a0733dda97..773f5a8cc4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/data/SsoIdentityProvider.kt @@ -66,17 +66,17 @@ data class SsoIdentityProvider( private fun toPriority(): Int { return when (brand) { // We are on Android, so user is more likely to have a Google account - BRAND_GOOGLE -> 5 + BRAND_GOOGLE -> 5 // Facebook is also an important SSO provider BRAND_FACEBOOK -> 4 // Twitter is more for professionals - BRAND_TWITTER -> 3 + BRAND_TWITTER -> 3 // Here it's very for techie people BRAND_GITHUB, - BRAND_GITLAB -> 2 + BRAND_GITLAB -> 2 // And finally, if the account has been created with an iPhone... - BRAND_APPLE -> 1 - else -> 0 + BRAND_APPLE -> 1 + else -> 0 } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationFlowResponse.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationFlowResponse.kt index 1252e93b84..98542d2086 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationFlowResponse.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/auth/registration/RegistrationFlowResponse.kt @@ -88,15 +88,15 @@ fun RegistrationFlowResponse.toFlowResult(): FlowResult { val isMandatory = flows?.all { type in it.stages.orEmpty() } == true val stage = when (type) { - LoginFlowTypes.RECAPTCHA -> Stage.ReCaptcha( + LoginFlowTypes.RECAPTCHA -> Stage.ReCaptcha( isMandatory, ((params?.get(type) as? Map<*, *>)?.get("public_key") as? String) ?: "" ) - LoginFlowTypes.DUMMY -> Stage.Dummy(isMandatory) - LoginFlowTypes.TERMS -> Stage.Terms(isMandatory, params?.get(type) as? TermPolicies ?: emptyMap()) + LoginFlowTypes.DUMMY -> Stage.Dummy(isMandatory) + LoginFlowTypes.TERMS -> Stage.Terms(isMandatory, params?.get(type) as? TermPolicies ?: emptyMap()) LoginFlowTypes.EMAIL_IDENTITY -> Stage.Email(isMandatory) - LoginFlowTypes.MSISDN -> Stage.Msisdn(isMandatory) - else -> Stage.Other(isMandatory, type, (params?.get(type) as? Map<*, *>)) + LoginFlowTypes.MSISDN -> Stage.Msisdn(isMandatory) + else -> Stage.Other(isMandatory, type, (params?.get(type) as? Map<*, *>)) } if (type in completedStages.orEmpty()) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/extensions/Strings.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/extensions/Strings.kt index 5e1350e327..a376ede0d4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/extensions/Strings.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/extensions/Strings.kt @@ -19,7 +19,7 @@ package org.matrix.android.sdk.api.extensions fun CharSequence.ensurePrefix(prefix: CharSequence): CharSequence { return when { startsWith(prefix) -> this - else -> "$prefix$this" + else -> "$prefix$this" } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ssl/Fingerprint.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ssl/Fingerprint.kt index 93e93fd292..2fc04013f9 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ssl/Fingerprint.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/network/ssl/Fingerprint.kt @@ -36,7 +36,7 @@ data class Fingerprint( internal fun matchesCert(cert: X509Certificate): Boolean { val o: Fingerprint? = when (hashType) { HashType.SHA256 -> newSha256Fingerprint(cert) - HashType.SHA1 -> newSha1Fingerprint(cert) + HashType.SHA1 -> newSha1Fingerprint(cert) } return equals(o) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keysbackup/KeysBackupLastVersionResult.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keysbackup/KeysBackupLastVersionResult.kt index a7e985cea9..92510bb52e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keysbackup/KeysBackupLastVersionResult.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/crypto/keysbackup/KeysBackupLastVersionResult.kt @@ -24,5 +24,5 @@ sealed interface KeysBackupLastVersionResult { fun KeysBackupLastVersionResult.toKeysVersionResult(): KeysVersionResult? = when (this) { is KeysBackupLastVersionResult.KeysBackup -> keysVersionResult - KeysBackupLastVersionResult.NoKeysBackup -> null + KeysBackupLastVersionResult.NoKeysBackup -> null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt index 7124d8a1a3..f28746ad0c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/Event.kt @@ -212,13 +212,13 @@ data class Event( return when { isReplyRenderedInThread() || isQuote() -> ContentUtils.extractUsefulTextFromReply(text) - isFileMessage() -> "sent a file." - isAudioMessage() -> "sent an audio file." - isImageMessage() -> "sent an image." - isVideoMessage() -> "sent a video." - isSticker() -> "sent a sticker" - isPoll() -> getPollQuestion() ?: "created a poll." - else -> text + isFileMessage() -> "sent a file." + isAudioMessage() -> "sent an audio file." + isImageMessage() -> "sent an image." + isVideoMessage() -> "sent a video." + isSticker() -> "sent a sticker" + isPoll() -> getPollQuestion() ?: "created a poll." + else -> text } } @@ -318,35 +318,35 @@ fun Event.isTextMessage(): Boolean { MessageType.MSGTYPE_TEXT, MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_NOTICE -> true - else -> false + else -> false } } fun Event.isImageMessage(): Boolean { return when (getMsgType()) { MessageType.MSGTYPE_IMAGE -> true - else -> false + else -> false } } fun Event.isVideoMessage(): Boolean { return when (getMsgType()) { MessageType.MSGTYPE_VIDEO -> true - else -> false + else -> false } } fun Event.isAudioMessage(): Boolean { return when (getMsgType()) { MessageType.MSGTYPE_AUDIO -> true - else -> false + else -> false } } fun Event.isFileMessage(): Boolean { return when (getMsgType()) { MessageType.MSGTYPE_FILE -> true - else -> false + else -> false } } @@ -356,14 +356,14 @@ fun Event.isAttachmentMessage(): Boolean { MessageType.MSGTYPE_AUDIO, MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_FILE -> true - else -> false + else -> false } } fun Event.isLocationMessage(): Boolean { return when (getMsgType()) { MessageType.MSGTYPE_LOCATION -> true - else -> false + else -> false } } @@ -378,9 +378,9 @@ fun Event.getRelationContent(): RelationDefaultContent? { content.toModel()?.relatesTo ?: run { // Special cases when there is only a local msgtype for some event types when (getClearType()) { - EventType.STICKER -> getClearContent().toModel()?.relatesTo + EventType.STICKER -> getClearContent().toModel()?.relatesTo in EventType.BEACON_LOCATION_DATA -> getClearContent().toModel()?.relatesTo - else -> null + else -> null } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/content/RoomKeyWithHeldContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/content/RoomKeyWithHeldContent.kt index d58c3614a7..fb8b65c4f2 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/content/RoomKeyWithHeldContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/events/model/content/RoomKeyWithHeldContent.kt @@ -98,12 +98,12 @@ enum class WithHeldCode(val value: String) { companion object { fun fromCode(code: String?): WithHeldCode? { return when (code) { - BLACKLISTED.value -> BLACKLISTED - UNVERIFIED.value -> UNVERIFIED + BLACKLISTED.value -> BLACKLISTED + UNVERIFIED.value -> UNVERIFIED UNAUTHORISED.value -> UNAUTHORISED - UNAVAILABLE.value -> UNAVAILABLE - NO_OLM.value -> NO_OLM - else -> null + UNAVAILABLE.value -> UNAVAILABLE + NO_OLM.value -> NO_OLM + else -> null } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt index 5b06fdacae..c78fb9cf79 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/homeserver/HomeServerCapabilities.kt @@ -81,13 +81,13 @@ data class HomeServerCapabilities( val versionCap = roomVersions.supportedVersion.firstOrNull { it.version == preferred } return when { - versionCap == null -> { + versionCap == null -> { RoomCapabilitySupport.UNKNOWN } versionCap.status == RoomVersionStatus.STABLE -> { RoomCapabilitySupport.SUPPORTED } - else -> { + else -> { RoomCapabilitySupport.SUPPORTED_UNSTABLE } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/ThreePid.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/ThreePid.kt index 42d777849b..6bcf576824 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/ThreePid.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/identity/ThreePid.kt @@ -27,7 +27,7 @@ sealed class ThreePid(open val value: String) { internal fun ThreePid.toMedium(): String { return when (this) { - is ThreePid.Email -> ThirdPartyIdentifier.MEDIUM_EMAIL + is ThreePid.Email -> ThirdPartyIdentifier.MEDIUM_EMAIL is ThreePid.Msisdn -> ThirdPartyIdentifier.MEDIUM_MSISDN } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt index a904e89681..c418b59df4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/MatrixToConverter.kt @@ -38,12 +38,12 @@ object MatrixToConverter { // URL is already a matrix.to uriString.startsWith(PermalinkService.MATRIX_TO_URL_BASE) -> uri // Web or client url - SUPPORTED_PATHS.any { it in uriString } -> { + SUPPORTED_PATHS.any { it in uriString } -> { val path = SUPPORTED_PATHS.first { it in uriString } Uri.parse(PermalinkService.MATRIX_TO_URL_BASE + uriString.substringAfter(path)) } // URL is not supported - else -> null + else -> null } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt index 9d078dc4b2..0168b7ac3a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/permalinks/PermalinkParser.kt @@ -67,10 +67,10 @@ object PermalinkParser { val identifier = params.getOrNull(0) val extraParameter = params.getOrNull(1) return when { - identifier.isNullOrEmpty() -> PermalinkData.FallbackLink(uri) - MatrixPatterns.isUserId(identifier) -> PermalinkData.UserLink(userId = identifier) - MatrixPatterns.isGroupId(identifier) -> PermalinkData.GroupLink(groupId = identifier) - MatrixPatterns.isRoomId(identifier) -> { + identifier.isNullOrEmpty() -> PermalinkData.FallbackLink(uri) + MatrixPatterns.isUserId(identifier) -> PermalinkData.UserLink(userId = identifier) + MatrixPatterns.isGroupId(identifier) -> PermalinkData.GroupLink(groupId = identifier) + MatrixPatterns.isRoomId(identifier) -> { handleRoomIdCase(fragment, identifier, matrixToUri, extraParameter, viaQueryParameters) } MatrixPatterns.isRoomAlias(identifier) -> { @@ -81,7 +81,7 @@ object PermalinkParser { viaParameters = viaQueryParameters ) } - else -> PermalinkData.FallbackLink(uri) + else -> PermalinkData.FallbackLink(uri) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Action.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Action.kt index 2b2930c1ba..6122aae972 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Action.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Action.kt @@ -71,15 +71,15 @@ sealed class Action { fun List.toJson(): List { return map { action -> when (action) { - is Action.Notify -> Action.ACTION_NOTIFY + is Action.Notify -> Action.ACTION_NOTIFY is Action.DoNotNotify -> Action.ACTION_DONT_NOTIFY - is Action.Sound -> { + is Action.Sound -> { mapOf( Action.ACTION_OBJECT_SET_TWEAK_KEY to Action.ACTION_OBJECT_SET_TWEAK_VALUE_SOUND, Action.ACTION_OBJECT_VALUE_KEY to action.sound ) } - is Action.Highlight -> { + is Action.Highlight -> { mapOf( Action.ACTION_OBJECT_SET_TWEAK_KEY to Action.ACTION_OBJECT_SET_TWEAK_VALUE_HIGHLIGHT, Action.ACTION_OBJECT_VALUE_KEY to action.highlight @@ -94,11 +94,11 @@ fun PushRule.getActions(): List { actions.forEach { actionStrOrObj -> when (actionStrOrObj) { - Action.ACTION_NOTIFY -> Action.Notify + Action.ACTION_NOTIFY -> Action.Notify Action.ACTION_DONT_NOTIFY -> Action.DoNotNotify - is Map<*, *> -> { + is Map<*, *> -> { when (actionStrOrObj[Action.ACTION_OBJECT_SET_TWEAK_KEY]) { - Action.ACTION_OBJECT_SET_TWEAK_VALUE_SOUND -> { + Action.ACTION_OBJECT_SET_TWEAK_VALUE_SOUND -> { (actionStrOrObj[Action.ACTION_OBJECT_VALUE_KEY] as? String)?.let { stringValue -> Action.Sound(stringValue) } @@ -112,13 +112,13 @@ fun PushRule.getActions(): List { // When the value is not there, default is true, says the spec ?: Action.Highlight(true) } - else -> { + else -> { Timber.w("Unsupported set_tweak value ${actionStrOrObj[Action.ACTION_OBJECT_SET_TWEAK_KEY]}") null } } } - else -> { + else -> { Timber.w("Unsupported action type $actionStrOrObj") null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/ContainsDisplayNameCondition.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/ContainsDisplayNameCondition.kt index 69dd14ddc2..0bf14345b9 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/ContainsDisplayNameCondition.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/ContainsDisplayNameCondition.kt @@ -39,7 +39,7 @@ class ContainsDisplayNameCondition : Condition { // EventType.ENCRYPTED -> { // event.root.getClearContent()?.toModel() // } - else -> null + else -> null } ?: return false return message.body.caseInsensitiveFind(displayName) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Kind.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Kind.kt index 463f3c2a73..bba6fe6026 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Kind.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/Kind.kt @@ -27,11 +27,11 @@ enum class Kind(val value: String) { fun fromString(value: String): Kind { return when (value) { - "event_match" -> EventMatch - "contains_display_name" -> ContainsDisplayName - "room_member_count" -> RoomMemberCount + "event_match" -> EventMatch + "contains_display_name" -> ContainsDisplayName + "room_member_count" -> RoomMemberCount "sender_notification_permission" -> SenderNotificationPermission - else -> Unrecognised + else -> Unrecognised } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/RoomMemberCountCondition.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/RoomMemberCountCondition.kt index 6973ff1372..db097fd92c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/RoomMemberCountCondition.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/RoomMemberCountCondition.kt @@ -47,8 +47,8 @@ class RoomMemberCountCondition( val numMembers = room.membershipService().getNumberOfJoinedMembers() return when (prefix) { - "<" -> numMembers < count - ">" -> numMembers > count + "<" -> numMembers < count + ">" -> numMembers > count "<=" -> numMembers <= count ">=" -> numMembers >= count else -> numMembers == count diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/rest/PushCondition.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/rest/PushCondition.kt index 1fc8329535..ec0936e4c8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/rest/PushCondition.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/pushrules/rest/PushCondition.kt @@ -61,7 +61,7 @@ data class PushCondition( fun asExecutableCondition(rule: PushRule): Condition? { return when (Kind.fromString(kind)) { - Kind.EventMatch -> { + Kind.EventMatch -> { if (key != null && pattern != null) { EventMatchCondition(key, pattern, rule.ruleId == RuleIds.RULE_ID_CONTAIN_USER_NAME) } else { @@ -69,10 +69,10 @@ data class PushCondition( null } } - Kind.ContainsDisplayName -> { + Kind.ContainsDisplayName -> { ContainsDisplayNameCondition() } - Kind.RoomMemberCount -> { + Kind.RoomMemberCount -> { if (iz.isNullOrEmpty()) { Timber.e("Malformed ROOM_MEMBER_COUNT condition") null @@ -88,7 +88,7 @@ data class PushCondition( SenderNotificationPermissionCondition(key) } } - Kind.Unrecognised -> { + Kind.Unrecognised -> { Timber.e("Unknown kind $kind") null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt index 8ef94b2896..0329828130 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/PowerLevelsContent.kt @@ -95,8 +95,8 @@ data class PowerLevelsContent( // the first implementation was a string value is String -> value.toInt() is Double -> value.toInt() - is Int -> value - else -> Role.Moderator.value + is Int -> value + else -> Role.Moderator.value } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt index ba274325bc..7dd853d75d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomGuestAccessContent.kt @@ -30,9 +30,9 @@ data class RoomGuestAccessContent( @Json(name = "guest_access") val guestAccessStr: String? = null ) { val guestAccess: GuestAccess? = when (guestAccessStr) { - "can_join" -> GuestAccess.CanJoin + "can_join" -> GuestAccess.CanJoin "forbidden" -> GuestAccess.Forbidden - else -> { + else -> { Timber.w("Invalid value for GuestAccess: `$guestAccessStr`") null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomHistoryVisibilityContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomHistoryVisibilityContent.kt index da5c90ff05..39b4722c0c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomHistoryVisibilityContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomHistoryVisibilityContent.kt @@ -26,10 +26,10 @@ data class RoomHistoryVisibilityContent( ) { val historyVisibility: RoomHistoryVisibility? = when (historyVisibilityStr) { "world_readable" -> RoomHistoryVisibility.WORLD_READABLE - "shared" -> RoomHistoryVisibility.SHARED - "invited" -> RoomHistoryVisibility.INVITED - "joined" -> RoomHistoryVisibility.JOINED - else -> { + "shared" -> RoomHistoryVisibility.SHARED + "invited" -> RoomHistoryVisibility.INVITED + "joined" -> RoomHistoryVisibility.JOINED + else -> { Timber.w("Invalid value for RoomHistoryVisibility: `$historyVisibilityStr`") null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomJoinRulesContent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomJoinRulesContent.kt index 3b338a36cd..dbe21b1633 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomJoinRulesContent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/RoomJoinRulesContent.kt @@ -36,12 +36,12 @@ data class RoomJoinRulesContent( @Json(name = "allow") val allowList: List? = null ) { val joinRules: RoomJoinRules? = when (joinRulesStr) { - "public" -> RoomJoinRules.PUBLIC - "invite" -> RoomJoinRules.INVITE - "knock" -> RoomJoinRules.KNOCK - "private" -> RoomJoinRules.PRIVATE + "public" -> RoomJoinRules.PUBLIC + "invite" -> RoomJoinRules.INVITE + "knock" -> RoomJoinRules.KNOCK + "private" -> RoomJoinRules.PRIVATE "restricted" -> RoomJoinRules.RESTRICTED - else -> { + else -> { Timber.w("Invalid value for RoomJoinRules: `$joinRulesStr`") null } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/Role.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/Role.kt index 5fe9bf6993..c5cc573458 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/Role.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/powerlevels/Role.kt @@ -32,11 +32,11 @@ sealed class Role(open val value: Int) : Comparable { // Order matters, default value should be checked after defined roles fun fromValue(value: Int, default: Int): Role { return when (value) { - Admin.value -> Admin + Admin.value -> Admin Moderator.value -> Moderator Default.value, - default -> Default - else -> Custom(value) + default -> Default + else -> Custom(value) } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/UserDraft.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/UserDraft.kt index 4ede1a66fc..e16405b3c0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/UserDraft.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/UserDraft.kt @@ -33,7 +33,7 @@ sealed interface UserDraft { fun isValid(): Boolean { return when (this) { is Regular -> content.isNotBlank() - else -> true + else -> true } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/sender/SenderInfo.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/sender/SenderInfo.kt index 4c308c355a..d629df8b16 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/sender/SenderInfo.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/sender/SenderInfo.kt @@ -29,9 +29,9 @@ data class SenderInfo( ) { val disambiguatedDisplayName: String get() = when { - displayName == null -> userId + displayName == null -> userId displayName.replaceSpaceChars().isBlank() -> "$displayName ($userId)" - isUniqueDisplayName -> displayName - else -> "$displayName ($userId)" + isUniqueDisplayName -> displayName + else -> "$displayName ($userId)" } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt index d4ade9b5b9..9d8c8a13bd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/timeline/TimelineEvent.kt @@ -139,11 +139,11 @@ fun TimelineEvent.getEditedEventId(): String? { */ fun TimelineEvent.getLastMessageContent(): MessageContent? { return when (root.getClearType()) { - EventType.STICKER -> root.getClearContent().toModel() - in EventType.POLL_START -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() + EventType.STICKER -> root.getClearContent().toModel() + in EventType.POLL_START -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() in EventType.STATE_ROOM_BEACON_INFO -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() - in EventType.BEACON_LOCATION_DATA -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() - else -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() + in EventType.BEACON_LOCATION_DATA -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() + else -> (annotations?.editSummary?.latestContent ?: root.getClearContent()).toModel() } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt index ac81be2174..7d4780585f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/sync/job/SyncService.kt @@ -84,7 +84,7 @@ abstract class SyncService : Service() { stopMe() } } - else -> { + else -> { val isInit = initialize(intent) onStart(isInitialSync) if (isInit) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt index ec775d640e..26dd31dc2d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/util/MatrixItem.kt @@ -138,20 +138,20 @@ sealed class MatrixItem( * Return the prefix as defined in the matrix spec (and not extracted from the id). */ private fun getIdPrefix() = when (this) { - is UserItem -> '@' - is EventItem -> '$' + is UserItem -> '@' + is EventItem -> '$' is SpaceItem, is RoomItem, is EveryoneInRoomItem -> '!' - is RoomAliasItem -> '#' - is GroupItem -> '+' + is RoomAliasItem -> '#' + is GroupItem -> '+' } fun firstLetterOfDisplayName(): String { val displayName = when (this) { // use the room display name for the notify everyone item is EveryoneInRoomItem -> roomDisplayName - else -> displayName + else -> displayName } return (displayName?.takeIf { it.isNotBlank() } ?: id) .let { dn -> diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt index 9c3fe72069..858a6448eb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/DefaultAuthenticationService.kt @@ -290,7 +290,7 @@ internal class DefaultAuthenticationService @Inject constructor( getLoginFlowResult(newAuthAPI, versions, wellknownResult.homeServerUrl) } - else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) + else -> throw Failure.OtherServerError("", HttpsURLConnection.HTTP_NOT_FOUND /* 404 */) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt index 28706c7e80..c9311867c8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/login/DirectLoginTask.kt @@ -73,7 +73,7 @@ internal class DefaultDirectLoginTask @Inject constructor( homeServerUrl, throwable.fingerprint ) - else -> throwable + else -> throwable } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/AddThreePidRegistrationParams.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/AddThreePidRegistrationParams.kt index 2f05864d3b..f0cb6ebd6d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/AddThreePidRegistrationParams.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/AddThreePidRegistrationParams.kt @@ -84,7 +84,7 @@ internal data class AddThreePidRegistrationParams( companion object { fun from(params: RegisterAddThreePidTask.Params): AddThreePidRegistrationParams { return when (params.threePid) { - is RegisterThreePid.Email -> AddThreePidRegistrationParams( + is RegisterThreePid.Email -> AddThreePidRegistrationParams( email = params.threePid.email, clientSecret = params.clientSecret, sendAttempt = params.sendAttempt diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt index 9cc73b00b4..a82cfc99bb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/DefaultRegistrationWizard.kt @@ -52,12 +52,12 @@ internal class DefaultRegistrationWizard( override val currentThreePid: String? get() { return when (val threePid = pendingSessionData.currentThreePidData?.threePid) { - is RegisterThreePid.Email -> threePid.email + is RegisterThreePid.Email -> threePid.email is RegisterThreePid.Msisdn -> { // Take formatted msisdn if provided by the server pendingSessionData.currentThreePidData?.addThreePidRegistrationResponse?.formattedMsisdn?.takeIf { it.isNotBlank() } ?: threePid.msisdn } - null -> null + null -> null } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt index 54a8ba0e6c..b84ed61361 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/RegisterAddThreePidTask.kt @@ -41,7 +41,7 @@ internal class DefaultRegisterAddThreePidTask( private fun RegisterThreePid.toPath(): String { return when (this) { - is RegisterThreePid.Email -> "email" + is RegisterThreePid.Email -> "email" is RegisterThreePid.Msisdn -> "msisdn" } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ThreePidData.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ThreePidData.kt index 70615809d8..dde0a44ea0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ThreePidData.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/registration/ThreePidData.kt @@ -46,7 +46,7 @@ internal data class ThreePidData( registrationParams: RegistrationParams ): ThreePidData { return when (threePid) { - is RegisterThreePid.Email -> + is RegisterThreePid.Email -> ThreePidData(threePid.email, "", "", addThreePidRegistrationResponse, registrationParams) is RegisterThreePid.Msisdn -> ThreePidData("", threePid.msisdn, threePid.countryCode, addThreePidRegistrationResponse, registrationParams) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/HomeServerVersion.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/HomeServerVersion.kt index 815f8de2de..9ab6f9d274 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/HomeServerVersion.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/auth/version/HomeServerVersion.kt @@ -33,7 +33,7 @@ internal data class HomeServerVersion( minor < other.minor -> -1 patch > other.patch -> 1 patch < other.patch -> -1 - else -> 0 + else -> 0 } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt index a5afe3f81d..719f366518 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DefaultCryptoService.kt @@ -188,8 +188,8 @@ internal class DefaultCryptoService @Inject constructor( fun onStateEvent(roomId: String, event: Event) { when (event.type) { - EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event) - EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event) + EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event) + EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event) EventType.STATE_ROOM_HISTORY_VISIBILITY -> onRoomHistoryVisibilityEvent(roomId, event) } } @@ -198,8 +198,8 @@ internal class DefaultCryptoService @Inject constructor( // handle state events if (event.isStateEvent()) { when (event.type) { - EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event) - EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event) + EventType.STATE_ROOM_ENCRYPTION -> onRoomEncryptionEvent(roomId, event) + EventType.STATE_ROOM_MEMBER -> onRoomMembershipEvent(roomId, event) EventType.STATE_ROOM_HISTORY_VISIBILITY -> onRoomHistoryVisibilityEvent(roomId, event) } } @@ -620,8 +620,8 @@ internal class DefaultCryptoService @Inject constructor( val alg: IMXEncrypting? = when (algorithm) { MXCRYPTO_ALGORITHM_MEGOLM -> megolmEncryptionFactory.create(roomId) - MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId) - else -> null + MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId) + else -> null } if (alg != null) { @@ -800,10 +800,10 @@ internal class DefaultCryptoService @Inject constructor( // Keys are imported directly, not waiting for end of sync onRoomKeyEvent(event) } - EventType.REQUEST_SECRET -> { + EventType.REQUEST_SECRET -> { secretShareManager.handleSecretRequest(event) } - EventType.ROOM_KEY_REQUEST -> { + EventType.ROOM_KEY_REQUEST -> { event.getClearContent().toModel()?.let { req -> // We'll always get these because we send room key requests to // '*' (ie. 'all devices') which includes the sending device, @@ -815,13 +815,13 @@ internal class DefaultCryptoService @Inject constructor( } } } - EventType.SEND_SECRET -> { + EventType.SEND_SECRET -> { onSecretSendReceived(event) } - EventType.ROOM_KEY_WITHHELD -> { + EventType.ROOM_KEY_WITHHELD -> { onKeyWithHeldReceived(event) } - else -> { + else -> { // ignore } } @@ -888,7 +888,7 @@ internal class DefaultCryptoService @Inject constructor( secretValue: String ): Boolean { return when (secretName) { - MASTER_KEY_SSSS_NAME -> { + MASTER_KEY_SSSS_NAME -> { crossSigningService.onSecretMSKGossip(secretValue) true } @@ -904,7 +904,7 @@ internal class DefaultCryptoService @Inject constructor( keysBackupService.onSecretKeyGossip(secretValue) true } - else -> false + else -> false } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt index 18b815b3d8..4f3900adb9 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/DeviceListManager.kt @@ -231,8 +231,8 @@ internal class DeviceListManager @Inject constructor( for ((k, value) in failures) { val statusCode = when (val status = value["status"]) { is Double -> status.toInt() - is Int -> status.toInt() - else -> 0 + is Int -> status.toInt() + else -> 0 } if (statusCode == 503) { synchronized(notReadyToRetryHS) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/IncomingKeyRequestManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/IncomingKeyRequestManager.kt index f8baab7c06..7f36224dae 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/IncomingKeyRequestManager.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/IncomingKeyRequestManager.kt @@ -135,7 +135,7 @@ internal class IncomingKeyRequestManager @Inject constructor( // just add to the buffer incomingRequestBuffer.add(validMegolmRequest) } - MegolmRequestAction.Cancel -> { + MegolmRequestAction.Cancel -> { // ignore, we can't cancel as it's not known (probably already processed) // still notify app layer if it was passed up previously IncomingRoomKeyRequest.fromRestRequest(senderId, request, clock)?.let { iReq -> @@ -159,7 +159,7 @@ internal class IncomingKeyRequestManager @Inject constructor( MegolmRequestAction.Request -> { // it's already in buffer, nop keep existing } - MegolmRequestAction.Cancel -> { + MegolmRequestAction.Cancel -> { // discard the request in buffer incomingRequestBuffer.remove(existing) outgoingRequestScope.launch(coroutineDispatchers.computation) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXCryptoAlgorithms.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXCryptoAlgorithms.kt index 5a5ee9e696..14b0e8e125 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXCryptoAlgorithms.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/MXCryptoAlgorithms.kt @@ -32,7 +32,7 @@ internal object MXCryptoAlgorithms { return when (algorithm) { MXCRYPTO_ALGORITHM_MEGOLM, MXCRYPTO_ALGORITHM_OLM -> true - else -> false + else -> false } } @@ -47,7 +47,7 @@ internal object MXCryptoAlgorithms { return when (algorithm) { MXCRYPTO_ALGORITHM_MEGOLM, MXCRYPTO_ALGORITHM_OLM -> true - else -> false + else -> false } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingKeyRequestManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingKeyRequestManager.kt index 6e2ff5c22b..6b22cc09d6 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingKeyRequestManager.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OutgoingKeyRequestManager.kt @@ -299,19 +299,19 @@ internal class OutgoingKeyRequestManager @Inject constructor( } knownRequest.forEach { request -> when (request.state) { - OutgoingRoomKeyRequestState.UNSENT -> { + OutgoingRoomKeyRequestState.UNSENT -> { if (request.fromIndex >= localKnownChainIndex) { // we have a good index we can cancel cryptoStore.deleteOutgoingRoomKeyRequest(request.requestId) } } - OutgoingRoomKeyRequestState.SENT -> { + OutgoingRoomKeyRequestState.SENT -> { // It was already sent, and index satisfied we can cancel if (request.fromIndex >= localKnownChainIndex) { cryptoStore.updateOutgoingRoomKeyRequestState(request.requestId, OutgoingRoomKeyRequestState.CANCELLATION_PENDING) } } - OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> { + OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> { // It is already marked to be cancelled } OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> { @@ -320,7 +320,7 @@ internal class OutgoingKeyRequestManager @Inject constructor( cryptoStore.updateOutgoingRoomKeyRequestState(request.requestId, OutgoingRoomKeyRequestState.CANCELLATION_PENDING) } } - OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> { + OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> { // was already canceled // if we need a better index, should we resend? } @@ -351,14 +351,14 @@ internal class OutgoingKeyRequestManager @Inject constructor( val existing = cryptoStore.getOutgoingRoomKeyRequest(requestBody) Timber.tag(loggerTag.value).v("Queueing key request exiting is ${existing?.state}") when (existing?.state) { - null -> { + null -> { // create a new one cryptoStore.getOrAddOutgoingRoomKeyRequest(requestBody, recipients, fromIndex) } - OutgoingRoomKeyRequestState.UNSENT -> { + OutgoingRoomKeyRequestState.UNSENT -> { // nothing it's new or not yet handled } - OutgoingRoomKeyRequestState.SENT -> { + OutgoingRoomKeyRequestState.SENT -> { // it was already requested Timber.tag(loggerTag.value).d("The session ${requestBody.sessionId} is already requested") if (force) { @@ -371,7 +371,7 @@ internal class OutgoingKeyRequestManager @Inject constructor( } } } - OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> { + OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> { // request is canceled only if I got the keys so what to do here... if (force) { cryptoStore.updateOutgoingRoomKeyRequestState(existing.requestId, OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND) @@ -380,7 +380,7 @@ internal class OutgoingKeyRequestManager @Inject constructor( OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> { // It's already going to resend } - OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> { + OutgoingRoomKeyRequestState.SENT_THEN_CANCELED -> { if (force) { cryptoStore.deleteOutgoingRoomKeyRequest(existing.requestId) cryptoStore.getOrAddOutgoingRoomKeyRequest(requestBody, recipients, fromIndex) @@ -401,11 +401,11 @@ internal class OutgoingKeyRequestManager @Inject constructor( measureTimeMillis { toProcess.forEach { when (it.state) { - OutgoingRoomKeyRequestState.UNSENT -> handleUnsentRequest(it) - OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> handleRequestToCancel(it) + OutgoingRoomKeyRequestState.UNSENT -> handleUnsentRequest(it) + OutgoingRoomKeyRequestState.CANCELLATION_PENDING -> handleRequestToCancel(it) OutgoingRoomKeyRequestState.CANCELLATION_PENDING_AND_WILL_RESEND -> handleRequestToCancelWillResend(it) OutgoingRoomKeyRequestState.SENT_THEN_CANCELED, - OutgoingRoomKeyRequestState.SENT -> { + OutgoingRoomKeyRequestState.SENT -> { // these are filtered out } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt index a80bafbe79..d37e60d289 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomDecryptorProvider.kt @@ -85,7 +85,7 @@ internal class RoomDecryptorProvider @Inject constructor( } } } - else -> olmDecryptionFactory.create() + else -> olmDecryptionFactory.create() } if (!roomId.isNullOrEmpty()) { synchronized(roomDecryptors) { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomEncryptorsStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomEncryptorsStore.kt index 1a8c160d9c..9f6714cc45 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomEncryptorsStore.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RoomEncryptorsStore.kt @@ -49,8 +49,8 @@ internal class RoomEncryptorsStore @Inject constructor( } else { val alg: IMXEncrypting? = when (cryptoStore.getRoomAlgorithm(roomId)) { MXCRYPTO_ALGORITHM_MEGOLM -> megolmEncryptionFactory.create(roomId) - MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId) - else -> null + MXCRYPTO_ALGORITHM_OLM -> olmEncryptionFactory.create(roomId) + else -> null } alg?.let { roomEncryptors.put(roomId, it) } return@synchronized alg diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SecretShareManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SecretShareManager.kt index 6fb6914206..a79e1a8901 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SecretShareManager.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/SecretShareManager.kt @@ -150,14 +150,14 @@ internal class SecretShareManager @Inject constructor( // we can share the secret val secretValue = when (secretName) { - MASTER_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.master + MASTER_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.master SELF_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.selfSigned USER_SIGNING_KEY_SSSS_NAME -> cryptoStore.getCrossSigningPrivateKeys()?.user KEYBACKUP_SECRET_SSSS_NAME -> cryptoStore.getKeyBackupRecoveryKeyInfo()?.recoveryKey ?.let { extractCurveKeyFromRecoveryKey(it)?.toBase64NoPadding() } - else -> null + else -> null } if (secretValue == null) { Timber.tag(loggerTag.value) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt index 17a44b19ff..219cadac46 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/algorithms/olm/MXOlmDecryption.kt @@ -191,9 +191,9 @@ internal class MXOlmDecryption( val messageBody = message["body"] as? String ?: return null val messageType = when (val typeAsVoid = message["type"]) { is Double -> typeAsVoid.toInt() - is Int -> typeAsVoid - is Long -> typeAsVoid.toInt() - else -> return null + is Int -> typeAsVoid + is Long -> typeAsVoid.toInt() + else -> return null } // Try each session in turn diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/CrossSigningOlm.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/CrossSigningOlm.kt index 4fa355cd2a..3218b99948 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/CrossSigningOlm.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/CrossSigningOlm.kt @@ -53,13 +53,13 @@ internal class CrossSigningOlm @Inject constructor( fun signObject(type: KeyType, strToSign: String): Map { val myKeys = cryptoStore.getMyCrossSigningInfo() val pubKey = when (type) { - KeyType.SELF -> myKeys?.selfSigningKey() - KeyType.USER -> myKeys?.userKey() + KeyType.SELF -> myKeys?.selfSigningKey() + KeyType.USER -> myKeys?.userKey() KeyType.MASTER -> myKeys?.masterKey() }?.unpaddedBase64PublicKey val pkSigning = when (type) { - KeyType.SELF -> selfSigningPkSigning - KeyType.USER -> userPkSigning + KeyType.SELF -> selfSigningPkSigning + KeyType.USER -> userPkSigning KeyType.MASTER -> masterPkSigning } if (pubKey == null || pkSigning == null) { @@ -76,8 +76,8 @@ internal class CrossSigningOlm @Inject constructor( ?: throw NoSuchElementException("Cross Signing not configured") val myUserID = myKeys.userId val pubKey = when (type) { - KeyType.SELF -> myKeys.selfSigningKey() - KeyType.USER -> myKeys.userKey() + KeyType.SELF -> myKeys.selfSigningKey() + KeyType.USER -> myKeys.userKey() KeyType.MASTER -> myKeys.masterKey() }?.unpaddedBase64PublicKey ?: throw NoSuchElementException("Cross Signing not configured") val signaturesMadeByMyKey = signatures[myUserID] // Signatures made by me diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt index 6e317f049b..f1dc060e10 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/crosssigning/UpdateTrustWorker.kt @@ -149,7 +149,7 @@ internal class UpdateTrustWorker(context: Context, params: WorkerParameters, ses val trusts = otherInfos.mapValues { entry -> when (entry.key) { myUserId -> myTrustResult - else -> { + else -> { crossSigningService.checkOtherMSKTrusted(myCrossSigningInfo, entry.value).also { Timber.v("## CrossSigning - user:${entry.key} result:$it") } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt index e75be11f94..c579930e1a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/keysbackup/DefaultKeysBackupService.kt @@ -328,7 +328,7 @@ internal class DefaultKeysBackupService @Inject constructor( // val hashServer = keysBackupData?.backupLastServerHash return when { - totalNumberOfKeysLocally < totalNumberOfKeysServer -> { + totalNumberOfKeysLocally < totalNumberOfKeysServer -> { // Server contains more keys than this device true } @@ -337,7 +337,7 @@ internal class DefaultKeysBackupService @Inject constructor( // TODO We have not found any algorithm to determine if a restore is recommended here. Return false for the moment false } - else -> false + else -> false } } @@ -935,7 +935,7 @@ internal class DefaultKeysBackupService @Inject constructor( */ fun maybeBackupKeys() { when { - isStucked -> { + isStucked -> { // If not already done, or in error case, check for a valid backup version on the homeserver. // If there is one, maybeBackupKeys will be called again. checkAndStartKeysBackup() @@ -953,7 +953,7 @@ internal class DefaultKeysBackupService @Inject constructor( uiHandler.post { backupKeys() } } } - else -> { + else -> { Timber.v("maybeBackupKeys: Skip it because state: $state") } } @@ -998,7 +998,7 @@ internal class DefaultKeysBackupService @Inject constructor( override fun onSuccess(data: KeysBackupLastVersionResult) { val localBackupVersion = keysBackupVersion?.version when (data) { - KeysBackupLastVersionResult.NoKeysBackup -> { + KeysBackupLastVersionResult.NoKeysBackup -> { if (localBackupVersion == null) { // No backup on the server, and backup is not active callback.onSuccess(true) @@ -1384,7 +1384,7 @@ internal class DefaultKeysBackupService @Inject constructor( // Do not stay in KeysBackupState.WrongBackUpVersion but check what is available on the homeserver checkAndStartKeysBackup() } - else -> + else -> // Come back to the ready state so that we will retry on the next received key keysBackupStateManager.state = KeysBackupState.ReadyToBackUp } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/rest/VerificationMethodValues.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/rest/VerificationMethodValues.kt index c07434f586..afe6191bf7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/rest/VerificationMethodValues.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/rest/VerificationMethodValues.kt @@ -28,7 +28,7 @@ internal const val VERIFICATION_METHOD_RECIPROCATE = "m.reciprocate.v1" internal fun VerificationMethod.toValue(): String { return when (this) { - VerificationMethod.SAS -> VERIFICATION_METHOD_SAS + VerificationMethod.SAS -> VERIFICATION_METHOD_SAS VerificationMethod.QR_CODE_SCAN -> VERIFICATION_METHOD_QR_CODE_SCAN VerificationMethod.QR_CODE_SHOW -> VERIFICATION_METHOD_QR_CODE_SHOW } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt index 51d53d9535..a71af991a7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/secrets/DefaultSharedSecretStorageService.kt @@ -178,7 +178,7 @@ internal class DefaultSharedSecretStorageService @Inject constructor( throw SharedSecretStorageError.UnknownAlgorithm(key.keyInfo.content.algorithm ?: "") } } - is KeyInfoResult.Error -> throw key.error + is KeyInfoResult.Error -> throw key.error } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/migration/MigrateCryptoTo004.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/migration/MigrateCryptoTo004.kt index e5bdd2aa9b..0a986892d9 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/migration/MigrateCryptoTo004.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/migration/MigrateCryptoTo004.kt @@ -104,10 +104,10 @@ internal class MigrateCryptoTo004(realm: DynamicRealm) : RealmMigrator(realm, 4) val trustLevel = realm.createObject("TrustLevelEntity") when (oldDevice.verified) { - MXDeviceInfo.DEVICE_VERIFICATION_UNKNOWN -> { + MXDeviceInfo.DEVICE_VERIFICATION_UNKNOWN -> { obj.setNull(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`) } - MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED -> { + MXDeviceInfo.DEVICE_VERIFICATION_BLOCKED -> { trustLevel.setNull(TrustLevelEntityFields.LOCALLY_VERIFIED) trustLevel.setNull(TrustLevelEntityFields.CROSS_SIGNED_VERIFIED) obj.setBoolean(DeviceInfoEntityFields.IS_BLOCKED, oldDevice.isBlocked) @@ -118,7 +118,7 @@ internal class MigrateCryptoTo004(realm: DynamicRealm) : RealmMigrator(realm, 4) trustLevel.setBoolean(TrustLevelEntityFields.CROSS_SIGNED_VERIFIED, false) obj.setObject(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`, trustLevel) } - MXDeviceInfo.DEVICE_VERIFICATION_VERIFIED -> { + MXDeviceInfo.DEVICE_VERIFICATION_VERIFIED -> { trustLevel.setBoolean(TrustLevelEntityFields.LOCALLY_VERIFIED, true) trustLevel.setBoolean(TrustLevelEntityFields.CROSS_SIGNED_VERIFIED, false) obj.setObject(DeviceInfoEntityFields.TRUST_LEVEL_ENTITY.`$`, trustLevel) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/AuditTrailMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/AuditTrailMapper.kt index 80ae4a8d0d..fe8e9f1db7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/AuditTrailMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/store/db/model/AuditTrailMapper.kt @@ -30,7 +30,7 @@ internal object AuditTrailMapper { fun map(entity: AuditTrailEntity): AuditTrail? { val contentJson = entity.contentJson ?: return null return when (entity.type) { - TrailType.OutgoingKeyForward.name -> { + TrailType.OutgoingKeyForward.name -> { val info = tryOrNull { MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).fromJson(contentJson) } ?: return null @@ -50,7 +50,7 @@ internal object AuditTrailMapper { info = info ) } - TrailType.IncomingKeyRequest.name -> { + TrailType.IncomingKeyRequest.name -> { val info = tryOrNull { MoshiProvider.providesMoshi().adapter(IncomingKeyRequestInfo::class.java).fromJson(contentJson) } ?: return null @@ -60,7 +60,7 @@ internal object AuditTrailMapper { info = info ) } - TrailType.IncomingKeyForward.name -> { + TrailType.IncomingKeyForward.name -> { val info = tryOrNull { MoshiProvider.providesMoshi().adapter(ForwardInfo::class.java).fromJson(contentJson) } ?: return null @@ -70,7 +70,7 @@ internal object AuditTrailMapper { info = info ) } - else -> { + else -> { AuditTrail( ageLocalTs = entity.ageLocalTs ?: 0, type = TrailType.Unknown, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt index a9d5cf1191..6b3bb1e641 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultIncomingSASDefaultVerificationTransaction.kt @@ -60,26 +60,26 @@ internal class DefaultIncomingSASDefaultVerificationTransaction( override val uxState: IncomingSasVerificationTransaction.UxState get() { return when (val immutableState = state) { - is VerificationTxState.OnStarted -> IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT + is VerificationTxState.OnStarted -> IncomingSasVerificationTransaction.UxState.SHOW_ACCEPT is VerificationTxState.SendingAccept, is VerificationTxState.Accepted, is VerificationTxState.OnKeyReceived, is VerificationTxState.SendingKey, - is VerificationTxState.KeySent -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT + is VerificationTxState.KeySent -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT is VerificationTxState.ShortCodeReady -> IncomingSasVerificationTransaction.UxState.SHOW_SAS is VerificationTxState.ShortCodeAccepted, is VerificationTxState.SendingMac, is VerificationTxState.MacSent, - is VerificationTxState.Verifying -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION - is VerificationTxState.Verified -> IncomingSasVerificationTransaction.UxState.VERIFIED - is VerificationTxState.Cancelled -> { + is VerificationTxState.Verifying -> IncomingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION + is VerificationTxState.Verified -> IncomingSasVerificationTransaction.UxState.VERIFIED + is VerificationTxState.Cancelled -> { if (immutableState.byMe) { IncomingSasVerificationTransaction.UxState.CANCELLED_BY_ME } else { IncomingSasVerificationTransaction.UxState.CANCELLED_BY_OTHER } } - else -> IncomingSasVerificationTransaction.UxState.UNKNOWN + else -> IncomingSasVerificationTransaction.UxState.UNKNOWN } } @@ -232,7 +232,7 @@ internal class DefaultIncomingSASDefaultVerificationTransaction( val sasInfo = "MATRIX_KEY_VERIFICATION_SAS|$otherUserId|$otherDeviceId|$otherKey|$userId|$deviceId|${getSAS().publicKey}|$transactionId" return getSAS().generateShortCode(sasInfo, 6) } - else -> { + else -> { // Protocol has been checked earlier throw IllegalArgumentException() } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt index ddb8ed232b..f1cf1b7547 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultOutgoingSASDefaultVerificationTransaction.kt @@ -57,27 +57,27 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction( override val uxState: OutgoingSasVerificationTransaction.UxState get() { return when (val immutableState = state) { - is VerificationTxState.None -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_START + is VerificationTxState.None -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_START is VerificationTxState.SendingStart, is VerificationTxState.Started, is VerificationTxState.OnAccepted, is VerificationTxState.SendingKey, is VerificationTxState.KeySent, - is VerificationTxState.OnKeyReceived -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT + is VerificationTxState.OnKeyReceived -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_KEY_AGREEMENT is VerificationTxState.ShortCodeReady -> OutgoingSasVerificationTransaction.UxState.SHOW_SAS is VerificationTxState.ShortCodeAccepted, is VerificationTxState.SendingMac, is VerificationTxState.MacSent, - is VerificationTxState.Verifying -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION - is VerificationTxState.Verified -> OutgoingSasVerificationTransaction.UxState.VERIFIED - is VerificationTxState.Cancelled -> { + is VerificationTxState.Verifying -> OutgoingSasVerificationTransaction.UxState.WAIT_FOR_VERIFICATION + is VerificationTxState.Verified -> OutgoingSasVerificationTransaction.UxState.VERIFIED + is VerificationTxState.Cancelled -> { if (immutableState.byMe) { OutgoingSasVerificationTransaction.UxState.CANCELLED_BY_OTHER } else { OutgoingSasVerificationTransaction.UxState.CANCELLED_BY_ME } } - else -> OutgoingSasVerificationTransaction.UxState.UNKNOWN + else -> OutgoingSasVerificationTransaction.UxState.UNKNOWN } } @@ -224,7 +224,7 @@ internal class DefaultOutgoingSASDefaultVerificationTransaction( val sasInfo = "MATRIX_KEY_VERIFICATION_SAS|$userId|$deviceId|${getSAS().publicKey}|$otherUserId|$otherDeviceId|$otherKey|$transactionId" return getSAS().generateShortCode(sasInfo, 6) } - else -> { + else -> { // Protocol has been checked earlier throw IllegalArgumentException() } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt index 7d8245da30..1a04ee0302 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/DefaultVerificationService.kt @@ -129,31 +129,31 @@ internal class DefaultVerificationService @Inject constructor( Timber.d("## SAS onToDeviceEvent ${event.getClearType()}") cryptoCoroutineScope.launch(coroutineDispatchers.dmVerif) { when (event.getClearType()) { - EventType.KEY_VERIFICATION_START -> { + EventType.KEY_VERIFICATION_START -> { onStartRequestReceived(event) } - EventType.KEY_VERIFICATION_CANCEL -> { + EventType.KEY_VERIFICATION_CANCEL -> { onCancelReceived(event) } - EventType.KEY_VERIFICATION_ACCEPT -> { + EventType.KEY_VERIFICATION_ACCEPT -> { onAcceptReceived(event) } - EventType.KEY_VERIFICATION_KEY -> { + EventType.KEY_VERIFICATION_KEY -> { onKeyReceived(event) } - EventType.KEY_VERIFICATION_MAC -> { + EventType.KEY_VERIFICATION_MAC -> { onMacReceived(event) } - EventType.KEY_VERIFICATION_READY -> { + EventType.KEY_VERIFICATION_READY -> { onReadyReceived(event) } - EventType.KEY_VERIFICATION_DONE -> { + EventType.KEY_VERIFICATION_DONE -> { onDoneReceived(event) } MessageType.MSGTYPE_VERIFICATION_REQUEST -> { onRequestReceived(event) } - else -> { + else -> { // ignore } } @@ -163,7 +163,7 @@ internal class DefaultVerificationService @Inject constructor( fun onRoomEvent(event: Event) { cryptoCoroutineScope.launch(coroutineDispatchers.dmVerif) { when (event.getClearType()) { - EventType.KEY_VERIFICATION_START -> { + EventType.KEY_VERIFICATION_START -> { onRoomStartRequestReceived(event) } EventType.KEY_VERIFICATION_CANCEL -> { @@ -173,24 +173,24 @@ internal class DefaultVerificationService @Inject constructor( EventType.KEY_VERIFICATION_ACCEPT -> { onRoomAcceptReceived(event) } - EventType.KEY_VERIFICATION_KEY -> { + EventType.KEY_VERIFICATION_KEY -> { onRoomKeyRequestReceived(event) } - EventType.KEY_VERIFICATION_MAC -> { + EventType.KEY_VERIFICATION_MAC -> { onRoomMacReceived(event) } - EventType.KEY_VERIFICATION_READY -> { + EventType.KEY_VERIFICATION_READY -> { onRoomReadyReceived(event) } - EventType.KEY_VERIFICATION_DONE -> { + EventType.KEY_VERIFICATION_DONE -> { onRoomDoneReceived(event) } - EventType.MESSAGE -> { + EventType.MESSAGE -> { if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel()?.msgType) { onRoomRequestReceived(event) } } - else -> { + else -> { // ignore } } @@ -507,9 +507,9 @@ internal class DefaultVerificationService @Inject constructor( } when (startReq) { - is ValidVerificationInfoStart.SasVerificationInfoStart -> { + is ValidVerificationInfoStart.SasVerificationInfoStart -> { when (existing) { - is SasVerificationTransaction -> { + is SasVerificationTransaction -> { // should cancel both! Timber.v("## SAS onStartRequestReceived - Request exist with same id ${startReq.transactionId}") existing.cancel(CancelCode.UnexpectedMessage) @@ -519,7 +519,7 @@ internal class DefaultVerificationService @Inject constructor( is QrCodeVerificationTransaction -> { // Nothing to do? } - null -> { + null -> { getExistingTransactionsForUser(otherUserId) ?.filterIsInstance(SasVerificationTransaction::class.java) ?.takeIf { it.isNotEmpty() } @@ -973,12 +973,12 @@ internal class DefaultVerificationService @Inject constructor( } return when { - userId != otherUserId -> + userId != otherUserId -> createQrCodeDataForDistinctUser(requestId, otherUserId) crossSigningService.isCrossSigningVerified() -> // This is a self verification and I am the old device (Osborne2) createQrCodeDataForVerifiedDevice(requestId, otherDeviceId) - else -> + else -> // This is a self verification and I am the new device (Dynabook) createQrCodeDataForUnVerifiedDevice(requestId) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SASDefaultVerificationTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SASDefaultVerificationTransaction.kt index d68f2c429d..1cbaff059a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SASDefaultVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/SASDefaultVerificationTransaction.kt @@ -333,11 +333,11 @@ internal abstract class SASDefaultVerificationTransaction( if (shortCodeBytes!!.size < 5) return null return getDecimalCodeRepresentation(shortCodeBytes!!) } - SasMode.EMOJI -> { + SasMode.EMOJI -> { if (shortCodeBytes!!.size < 6) return null return getEmojiCodeRepresentation(shortCodeBytes!!).joinToString(" ") { it.emoji } } - else -> return null + else -> return null } } @@ -362,8 +362,8 @@ internal abstract class SASDefaultVerificationTransaction( private fun macUsingAgreedMethod(message: String, info: String): String? { return when (accepted?.messageAuthenticationCode?.lowercase(Locale.ROOT)) { SAS_MAC_SHA256_LONGKDF -> getSAS().calculateMacLongKdf(message, info) - SAS_MAC_SHA256 -> getSAS().calculateMac(message, info) - else -> null + SAS_MAC_SHA256 -> getSAS().calculateMac(message, info) + else -> null } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationEmoji.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationEmoji.kt index eb1819fe6a..cff3591771 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationEmoji.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationEmoji.kt @@ -20,69 +20,69 @@ import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentatio internal fun getEmojiForCode(code: Int): EmojiRepresentation { return when (code % 64) { - 0 -> EmojiRepresentation("🐶", R.string.verification_emoji_dog, R.drawable.ic_verification_dog) - 1 -> EmojiRepresentation("🐱", R.string.verification_emoji_cat, R.drawable.ic_verification_cat) - 2 -> EmojiRepresentation("🦁", R.string.verification_emoji_lion, R.drawable.ic_verification_lion) - 3 -> EmojiRepresentation("🐎", R.string.verification_emoji_horse, R.drawable.ic_verification_horse) - 4 -> EmojiRepresentation("🦄", R.string.verification_emoji_unicorn, R.drawable.ic_verification_unicorn) - 5 -> EmojiRepresentation("🐷", R.string.verification_emoji_pig, R.drawable.ic_verification_pig) - 6 -> EmojiRepresentation("🐘", R.string.verification_emoji_elephant, R.drawable.ic_verification_elephant) - 7 -> EmojiRepresentation("🐰", R.string.verification_emoji_rabbit, R.drawable.ic_verification_rabbit) - 8 -> EmojiRepresentation("🐼", R.string.verification_emoji_panda, R.drawable.ic_verification_panda) - 9 -> EmojiRepresentation("🐓", R.string.verification_emoji_rooster, R.drawable.ic_verification_rooster) - 10 -> EmojiRepresentation("🐧", R.string.verification_emoji_penguin, R.drawable.ic_verification_penguin) - 11 -> EmojiRepresentation("🐢", R.string.verification_emoji_turtle, R.drawable.ic_verification_turtle) - 12 -> EmojiRepresentation("🐟", R.string.verification_emoji_fish, R.drawable.ic_verification_fish) - 13 -> EmojiRepresentation("🐙", R.string.verification_emoji_octopus, R.drawable.ic_verification_octopus) - 14 -> EmojiRepresentation("🦋", R.string.verification_emoji_butterfly, R.drawable.ic_verification_butterfly) - 15 -> EmojiRepresentation("🌷", R.string.verification_emoji_flower, R.drawable.ic_verification_flower) - 16 -> EmojiRepresentation("🌳", R.string.verification_emoji_tree, R.drawable.ic_verification_tree) - 17 -> EmojiRepresentation("🌵", R.string.verification_emoji_cactus, R.drawable.ic_verification_cactus) - 18 -> EmojiRepresentation("🍄", R.string.verification_emoji_mushroom, R.drawable.ic_verification_mushroom) - 19 -> EmojiRepresentation("🌏", R.string.verification_emoji_globe, R.drawable.ic_verification_globe) - 20 -> EmojiRepresentation("🌙", R.string.verification_emoji_moon, R.drawable.ic_verification_moon) - 21 -> EmojiRepresentation("☁️", R.string.verification_emoji_cloud, R.drawable.ic_verification_cloud) - 22 -> EmojiRepresentation("🔥", R.string.verification_emoji_fire, R.drawable.ic_verification_fire) - 23 -> EmojiRepresentation("🍌", R.string.verification_emoji_banana, R.drawable.ic_verification_banana) - 24 -> EmojiRepresentation("🍎", R.string.verification_emoji_apple, R.drawable.ic_verification_apple) - 25 -> EmojiRepresentation("🍓", R.string.verification_emoji_strawberry, R.drawable.ic_verification_strawberry) - 26 -> EmojiRepresentation("🌽", R.string.verification_emoji_corn, R.drawable.ic_verification_corn) - 27 -> EmojiRepresentation("🍕", R.string.verification_emoji_pizza, R.drawable.ic_verification_pizza) - 28 -> EmojiRepresentation("🎂", R.string.verification_emoji_cake, R.drawable.ic_verification_cake) - 29 -> EmojiRepresentation("❤️", R.string.verification_emoji_heart, R.drawable.ic_verification_heart) - 30 -> EmojiRepresentation("🙂", R.string.verification_emoji_smiley, R.drawable.ic_verification_smiley) - 31 -> EmojiRepresentation("🤖", R.string.verification_emoji_robot, R.drawable.ic_verification_robot) - 32 -> EmojiRepresentation("🎩", R.string.verification_emoji_hat, R.drawable.ic_verification_hat) - 33 -> EmojiRepresentation("👓", R.string.verification_emoji_glasses, R.drawable.ic_verification_glasses) - 34 -> EmojiRepresentation("🔧", R.string.verification_emoji_spanner, R.drawable.ic_verification_spanner) - 35 -> EmojiRepresentation("🎅", R.string.verification_emoji_santa, R.drawable.ic_verification_santa) - 36 -> EmojiRepresentation("👍", R.string.verification_emoji_thumbs_up, R.drawable.ic_verification_thumbs_up) - 37 -> EmojiRepresentation("☂️", R.string.verification_emoji_umbrella, R.drawable.ic_verification_umbrella) - 38 -> EmojiRepresentation("⌛", R.string.verification_emoji_hourglass, R.drawable.ic_verification_hourglass) - 39 -> EmojiRepresentation("⏰", R.string.verification_emoji_clock, R.drawable.ic_verification_clock) - 40 -> EmojiRepresentation("🎁", R.string.verification_emoji_gift, R.drawable.ic_verification_gift) - 41 -> EmojiRepresentation("💡", R.string.verification_emoji_light_bulb, R.drawable.ic_verification_light_bulb) - 42 -> EmojiRepresentation("📕", R.string.verification_emoji_book, R.drawable.ic_verification_book) - 43 -> EmojiRepresentation("✏️", R.string.verification_emoji_pencil, R.drawable.ic_verification_pencil) - 44 -> EmojiRepresentation("📎", R.string.verification_emoji_paperclip, R.drawable.ic_verification_paperclip) - 45 -> EmojiRepresentation("✂️", R.string.verification_emoji_scissors, R.drawable.ic_verification_scissors) - 46 -> EmojiRepresentation("🔒", R.string.verification_emoji_lock, R.drawable.ic_verification_lock) - 47 -> EmojiRepresentation("🔑", R.string.verification_emoji_key, R.drawable.ic_verification_key) - 48 -> EmojiRepresentation("🔨", R.string.verification_emoji_hammer, R.drawable.ic_verification_hammer) - 49 -> EmojiRepresentation("☎️", R.string.verification_emoji_telephone, R.drawable.ic_verification_phone) - 50 -> EmojiRepresentation("🏁", R.string.verification_emoji_flag, R.drawable.ic_verification_flag) - 51 -> EmojiRepresentation("🚂", R.string.verification_emoji_train, R.drawable.ic_verification_train) - 52 -> EmojiRepresentation("🚲", R.string.verification_emoji_bicycle, R.drawable.ic_verification_bicycle) - 53 -> EmojiRepresentation("✈️", R.string.verification_emoji_aeroplane, R.drawable.ic_verification_aeroplane) - 54 -> EmojiRepresentation("🚀", R.string.verification_emoji_rocket, R.drawable.ic_verification_rocket) - 55 -> EmojiRepresentation("🏆", R.string.verification_emoji_trophy, R.drawable.ic_verification_trophy) - 56 -> EmojiRepresentation("⚽", R.string.verification_emoji_ball, R.drawable.ic_verification_ball) - 57 -> EmojiRepresentation("🎸", R.string.verification_emoji_guitar, R.drawable.ic_verification_guitar) - 58 -> EmojiRepresentation("🎺", R.string.verification_emoji_trumpet, R.drawable.ic_verification_trumpet) - 59 -> EmojiRepresentation("🔔", R.string.verification_emoji_bell, R.drawable.ic_verification_bell) - 60 -> EmojiRepresentation("⚓", R.string.verification_emoji_anchor, R.drawable.ic_verification_anchor) - 61 -> EmojiRepresentation("🎧", R.string.verification_emoji_headphones, R.drawable.ic_verification_headphones) - 62 -> EmojiRepresentation("📁", R.string.verification_emoji_folder, R.drawable.ic_verification_folder) + 0 -> EmojiRepresentation("🐶", R.string.verification_emoji_dog, R.drawable.ic_verification_dog) + 1 -> EmojiRepresentation("🐱", R.string.verification_emoji_cat, R.drawable.ic_verification_cat) + 2 -> EmojiRepresentation("🦁", R.string.verification_emoji_lion, R.drawable.ic_verification_lion) + 3 -> EmojiRepresentation("🐎", R.string.verification_emoji_horse, R.drawable.ic_verification_horse) + 4 -> EmojiRepresentation("🦄", R.string.verification_emoji_unicorn, R.drawable.ic_verification_unicorn) + 5 -> EmojiRepresentation("🐷", R.string.verification_emoji_pig, R.drawable.ic_verification_pig) + 6 -> EmojiRepresentation("🐘", R.string.verification_emoji_elephant, R.drawable.ic_verification_elephant) + 7 -> EmojiRepresentation("🐰", R.string.verification_emoji_rabbit, R.drawable.ic_verification_rabbit) + 8 -> EmojiRepresentation("🐼", R.string.verification_emoji_panda, R.drawable.ic_verification_panda) + 9 -> EmojiRepresentation("🐓", R.string.verification_emoji_rooster, R.drawable.ic_verification_rooster) + 10 -> EmojiRepresentation("🐧", R.string.verification_emoji_penguin, R.drawable.ic_verification_penguin) + 11 -> EmojiRepresentation("🐢", R.string.verification_emoji_turtle, R.drawable.ic_verification_turtle) + 12 -> EmojiRepresentation("🐟", R.string.verification_emoji_fish, R.drawable.ic_verification_fish) + 13 -> EmojiRepresentation("🐙", R.string.verification_emoji_octopus, R.drawable.ic_verification_octopus) + 14 -> EmojiRepresentation("🦋", R.string.verification_emoji_butterfly, R.drawable.ic_verification_butterfly) + 15 -> EmojiRepresentation("🌷", R.string.verification_emoji_flower, R.drawable.ic_verification_flower) + 16 -> EmojiRepresentation("🌳", R.string.verification_emoji_tree, R.drawable.ic_verification_tree) + 17 -> EmojiRepresentation("🌵", R.string.verification_emoji_cactus, R.drawable.ic_verification_cactus) + 18 -> EmojiRepresentation("🍄", R.string.verification_emoji_mushroom, R.drawable.ic_verification_mushroom) + 19 -> EmojiRepresentation("🌏", R.string.verification_emoji_globe, R.drawable.ic_verification_globe) + 20 -> EmojiRepresentation("🌙", R.string.verification_emoji_moon, R.drawable.ic_verification_moon) + 21 -> EmojiRepresentation("☁️", R.string.verification_emoji_cloud, R.drawable.ic_verification_cloud) + 22 -> EmojiRepresentation("🔥", R.string.verification_emoji_fire, R.drawable.ic_verification_fire) + 23 -> EmojiRepresentation("🍌", R.string.verification_emoji_banana, R.drawable.ic_verification_banana) + 24 -> EmojiRepresentation("🍎", R.string.verification_emoji_apple, R.drawable.ic_verification_apple) + 25 -> EmojiRepresentation("🍓", R.string.verification_emoji_strawberry, R.drawable.ic_verification_strawberry) + 26 -> EmojiRepresentation("🌽", R.string.verification_emoji_corn, R.drawable.ic_verification_corn) + 27 -> EmojiRepresentation("🍕", R.string.verification_emoji_pizza, R.drawable.ic_verification_pizza) + 28 -> EmojiRepresentation("🎂", R.string.verification_emoji_cake, R.drawable.ic_verification_cake) + 29 -> EmojiRepresentation("❤️", R.string.verification_emoji_heart, R.drawable.ic_verification_heart) + 30 -> EmojiRepresentation("🙂", R.string.verification_emoji_smiley, R.drawable.ic_verification_smiley) + 31 -> EmojiRepresentation("🤖", R.string.verification_emoji_robot, R.drawable.ic_verification_robot) + 32 -> EmojiRepresentation("🎩", R.string.verification_emoji_hat, R.drawable.ic_verification_hat) + 33 -> EmojiRepresentation("👓", R.string.verification_emoji_glasses, R.drawable.ic_verification_glasses) + 34 -> EmojiRepresentation("🔧", R.string.verification_emoji_spanner, R.drawable.ic_verification_spanner) + 35 -> EmojiRepresentation("🎅", R.string.verification_emoji_santa, R.drawable.ic_verification_santa) + 36 -> EmojiRepresentation("👍", R.string.verification_emoji_thumbs_up, R.drawable.ic_verification_thumbs_up) + 37 -> EmojiRepresentation("☂️", R.string.verification_emoji_umbrella, R.drawable.ic_verification_umbrella) + 38 -> EmojiRepresentation("⌛", R.string.verification_emoji_hourglass, R.drawable.ic_verification_hourglass) + 39 -> EmojiRepresentation("⏰", R.string.verification_emoji_clock, R.drawable.ic_verification_clock) + 40 -> EmojiRepresentation("🎁", R.string.verification_emoji_gift, R.drawable.ic_verification_gift) + 41 -> EmojiRepresentation("💡", R.string.verification_emoji_light_bulb, R.drawable.ic_verification_light_bulb) + 42 -> EmojiRepresentation("📕", R.string.verification_emoji_book, R.drawable.ic_verification_book) + 43 -> EmojiRepresentation("✏️", R.string.verification_emoji_pencil, R.drawable.ic_verification_pencil) + 44 -> EmojiRepresentation("📎", R.string.verification_emoji_paperclip, R.drawable.ic_verification_paperclip) + 45 -> EmojiRepresentation("✂️", R.string.verification_emoji_scissors, R.drawable.ic_verification_scissors) + 46 -> EmojiRepresentation("🔒", R.string.verification_emoji_lock, R.drawable.ic_verification_lock) + 47 -> EmojiRepresentation("🔑", R.string.verification_emoji_key, R.drawable.ic_verification_key) + 48 -> EmojiRepresentation("🔨", R.string.verification_emoji_hammer, R.drawable.ic_verification_hammer) + 49 -> EmojiRepresentation("☎️", R.string.verification_emoji_telephone, R.drawable.ic_verification_phone) + 50 -> EmojiRepresentation("🏁", R.string.verification_emoji_flag, R.drawable.ic_verification_flag) + 51 -> EmojiRepresentation("🚂", R.string.verification_emoji_train, R.drawable.ic_verification_train) + 52 -> EmojiRepresentation("🚲", R.string.verification_emoji_bicycle, R.drawable.ic_verification_bicycle) + 53 -> EmojiRepresentation("✈️", R.string.verification_emoji_aeroplane, R.drawable.ic_verification_aeroplane) + 54 -> EmojiRepresentation("🚀", R.string.verification_emoji_rocket, R.drawable.ic_verification_rocket) + 55 -> EmojiRepresentation("🏆", R.string.verification_emoji_trophy, R.drawable.ic_verification_trophy) + 56 -> EmojiRepresentation("⚽", R.string.verification_emoji_ball, R.drawable.ic_verification_ball) + 57 -> EmojiRepresentation("🎸", R.string.verification_emoji_guitar, R.drawable.ic_verification_guitar) + 58 -> EmojiRepresentation("🎺", R.string.verification_emoji_trumpet, R.drawable.ic_verification_trumpet) + 59 -> EmojiRepresentation("🔔", R.string.verification_emoji_bell, R.drawable.ic_verification_bell) + 60 -> EmojiRepresentation("⚓", R.string.verification_emoji_anchor, R.drawable.ic_verification_anchor) + 61 -> EmojiRepresentation("🎧", R.string.verification_emoji_headphones, R.drawable.ic_verification_headphones) + 62 -> EmojiRepresentation("📁", R.string.verification_emoji_folder, R.drawable.ic_verification_folder) /* 63 */ else -> EmojiRepresentation("📌", R.string.verification_emoji_pin, R.drawable.ic_verification_pin) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt index 991470a848..66591fe00f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationInfoStart.kt @@ -68,7 +68,7 @@ internal interface VerificationInfoStart : VerificationInfo { + VERIFICATION_METHOD_SAS -> { val validKeyAgreementProtocols = keyAgreementProtocols?.takeIf { it.isNotEmpty() } ?: return null val validHashes = hashes?.takeIf { it.contains("sha256") } ?: return null val validMessageAuthenticationCodes = messageAuthenticationCodes @@ -98,7 +98,7 @@ internal interface VerificationInfoStart : VerificationInfo null + else -> null } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationMessageProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationMessageProcessor.kt index 303b6c5839..9f123f0c08 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationMessageProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/VerificationMessageProcessor.kt @@ -131,7 +131,7 @@ internal class VerificationMessageProcessor @Inject constructor( EventType.KEY_VERIFICATION_DONE -> { verificationService.onRoomEvent(event) } - EventType.MESSAGE -> { + EventType.MESSAGE -> { if (MessageType.MSGTYPE_VERIFICATION_REQUEST == event.getClearContent().toModel()?.msgType) { verificationService.onRoomRequestReceived(event) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt index b1ad4d87b6..690ac12268 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/DefaultQrCodeVerificationTransaction.kt @@ -94,7 +94,7 @@ internal class DefaultQrCodeVerificationTransaction( // Check the other device view of my MSK when (otherQrCodeData) { - is QrCodeData.VerifyingAnotherUser -> { + is QrCodeData.VerifyingAnotherUser -> { // key2 (aka otherUserMasterCrossSigningPublicKey) is what the one displaying the QR code (other user) think my MSK is. // Let's check that it's correct // If not -> Cancel @@ -104,7 +104,7 @@ internal class DefaultQrCodeVerificationTransaction( return } else Unit } - is QrCodeData.SelfVerifyingMasterKeyTrusted -> { + is QrCodeData.SelfVerifyingMasterKeyTrusted -> { // key1 (aka userMasterCrossSigningPublicKey) is the session displaying the QR code view of our MSK. // Let's check that I see the same MSK // If not -> Cancel @@ -135,7 +135,7 @@ internal class DefaultQrCodeVerificationTransaction( // Let's now check the other user/device key material when (otherQrCodeData) { - is QrCodeData.VerifyingAnotherUser -> { + is QrCodeData.VerifyingAnotherUser -> { // key1(aka userMasterCrossSigningPublicKey) is the MSK of the one displaying the QR code (i.e other user) // Let's check that it matches what I think it should be if (otherQrCodeData.userMasterCrossSigningPublicKey @@ -149,7 +149,7 @@ internal class DefaultQrCodeVerificationTransaction( Unit } } - is QrCodeData.SelfVerifyingMasterKeyTrusted -> { + is QrCodeData.SelfVerifyingMasterKeyTrusted -> { // key2 (aka otherDeviceKey) is my current device key in POV of the one displaying the QR code (i.e other device) // Let's check that it's correct if (otherQrCodeData.otherDeviceKey @@ -259,11 +259,11 @@ internal class DefaultQrCodeVerificationTransaction( override fun otherUserScannedMyQrCode() { when (qrCodeData) { - is QrCodeData.VerifyingAnotherUser -> { + is QrCodeData.VerifyingAnotherUser -> { // Alice telling Bob that the code was scanned successfully is sufficient for Bob to trust Alice's key, trust(true, emptyList(), false) } - is QrCodeData.SelfVerifyingMasterKeyTrusted -> { + is QrCodeData.SelfVerifyingMasterKeyTrusted -> { // I now know that I have the correct device key for other session, // and can sign it with the self-signing key and upload the signature trust(false, listOf(otherDeviceId ?: ""), false) @@ -272,7 +272,7 @@ internal class DefaultQrCodeVerificationTransaction( // I now know that i can trust my MSK trust(true, emptyList(), true) } - null -> Unit + null -> Unit } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/Extensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/Extensions.kt index b80c29c244..a0202485d6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/Extensions.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/verification/qrcode/Extensions.kt @@ -36,8 +36,8 @@ internal fun QrCodeData.toEncodedString(): String { // Mode result += when (this) { - is QrCodeData.VerifyingAnotherUser -> 0 - is QrCodeData.SelfVerifyingMasterKeyTrusted -> 1 + is QrCodeData.VerifyingAnotherUser -> 0 + is QrCodeData.SelfVerifyingMasterKeyTrusted -> 1 is QrCodeData.SelfVerifyingMasterKeyNotTrusted -> 2 }.toByte() @@ -119,9 +119,9 @@ internal fun String.toQrCodeData(): QrCodeData? { val secret = byteArray.copyOfRange(cursor, byteArray.size).toBase64NoPadding() return when (mode) { - 0 -> QrCodeData.VerifyingAnotherUser(transactionId, key1, key2, secret) - 1 -> QrCodeData.SelfVerifyingMasterKeyTrusted(transactionId, key1, key2, secret) - 2 -> QrCodeData.SelfVerifyingMasterKeyNotTrusted(transactionId, key1, key2, secret) + 0 -> QrCodeData.VerifyingAnotherUser(transactionId, key1, key2, secret) + 1 -> QrCodeData.SelfVerifyingMasterKeyTrusted(transactionId, key1, key2, secret) + 2 -> QrCodeData.SelfVerifyingMasterKeyNotTrusted(transactionId, key1, key2, secret) else -> null } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt index efcbc9de12..ee9e2403d6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ChunkEntityHelper.kt @@ -201,7 +201,7 @@ private fun handleReadReceipts(realm: Realm, roomId: String, eventEntity: EventE internal fun ChunkEntity.nextDisplayIndex(direction: PaginationDirection): Int { return when (direction) { - PaginationDirection.FORWARDS -> { + PaginationDirection.FORWARDS -> { (timelineEvents.where().max(TimelineEventEntityFields.DISPLAY_INDEX)?.toInt() ?: 0) + 1 } PaginationDirection.BACKWARDS -> { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadSummaryHelper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadSummaryHelper.kt index ebe8de7841..79a99cdfac 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadSummaryHelper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/helper/ThreadSummaryHelper.kt @@ -181,7 +181,7 @@ internal fun ThreadSummaryEntity.Companion.createOrUpdate( roomEntity.addIfNecessary(threadSummary) } - ThreadSummaryUpdateType.ADD -> { + ThreadSummaryUpdateType.ADD -> { val rootThreadEventId = threadEventEntity?.rootThreadEventId ?: return Timber.i("###THREADS ThreadSummaryHelper ADD for root eventId:$rootThreadEventId") diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/DraftMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/DraftMapper.kt index a00a2a8ee1..4cf2ef6723 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/DraftMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/DraftMapper.kt @@ -27,21 +27,21 @@ internal object DraftMapper { fun map(entity: DraftEntity): UserDraft { return when (entity.draftMode) { DraftEntity.MODE_REGULAR -> UserDraft.Regular(entity.content) - DraftEntity.MODE_EDIT -> UserDraft.Edit(entity.linkedEventId, entity.content) - DraftEntity.MODE_QUOTE -> UserDraft.Quote(entity.linkedEventId, entity.content) - DraftEntity.MODE_REPLY -> UserDraft.Reply(entity.linkedEventId, entity.content) - DraftEntity.MODE_VOICE -> UserDraft.Voice(entity.content) - else -> null + DraftEntity.MODE_EDIT -> UserDraft.Edit(entity.linkedEventId, entity.content) + DraftEntity.MODE_QUOTE -> UserDraft.Quote(entity.linkedEventId, entity.content) + DraftEntity.MODE_REPLY -> UserDraft.Reply(entity.linkedEventId, entity.content) + DraftEntity.MODE_VOICE -> UserDraft.Voice(entity.content) + else -> null } ?: UserDraft.Regular("") } fun map(domain: UserDraft): DraftEntity { return when (domain) { is UserDraft.Regular -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_REGULAR, linkedEventId = "") - is UserDraft.Edit -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_EDIT, linkedEventId = domain.linkedEventId) - is UserDraft.Quote -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_QUOTE, linkedEventId = domain.linkedEventId) - is UserDraft.Reply -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_REPLY, linkedEventId = domain.linkedEventId) - is UserDraft.Voice -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_VOICE, linkedEventId = "") + is UserDraft.Edit -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_EDIT, linkedEventId = domain.linkedEventId) + is UserDraft.Quote -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_QUOTE, linkedEventId = domain.linkedEventId) + is UserDraft.Reply -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_REPLY, linkedEventId = domain.linkedEventId) + is UserDraft.Voice -> DraftEntity(content = domain.content, draftMode = DraftEntity.MODE_VOICE, linkedEventId = "") } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt index d704ecac8e..1a4821e80c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/IsUselessResolver.kt @@ -32,7 +32,7 @@ internal object IsUselessResolver { event.content != null && event.content.toContent() == event.resolvedPrevContent()?.toContent() } - else -> false + else -> false } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt index 9952a46f03..735cfe411c 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/mapper/RoomSummaryMapper.kt @@ -111,7 +111,7 @@ internal class RoomSummaryMapper @Inject constructor( // I should probably use #hasEncryptorClassForAlgorithm but it says it supports // OLM which is some legacy? Now only megolm allowed in rooms MXCRYPTO_ALGORITHM_MEGOLM -> RoomEncryptionAlgorithm.Megolm - else -> RoomEncryptionAlgorithm.UnsupportedAlgorithm(alg) + else -> RoomEncryptionAlgorithm.UnsupportedAlgorithm(alg) } ) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt index 6d295cd2ea..0b0f01a67d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/database/query/ReadQueries.kt @@ -41,12 +41,12 @@ internal fun isEventRead( val eventToCheck = TimelineEventEntity.where(realm, roomId, eventId).findFirst() when { // The event doesn't exist locally, let's assume it hasn't been read - eventToCheck == null -> false - eventToCheck.root?.sender == userId -> true + eventToCheck == null -> false + eventToCheck.root?.sender == userId -> true // If new event exists and the latest event is from ourselves we can infer the event is read - latestEventIsFromSelf(realm, roomId, userId) -> true + latestEventIsFromSelf(realm, roomId, userId) -> true eventToCheck.isBeforeLatestReadReceipt(realm, roomId, userId) -> true - else -> false + else -> false } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt index 565111b9ab..fefb7fb5e3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/Request.kt @@ -56,8 +56,8 @@ internal suspend inline fun executeRequest( } catch (throwable: Throwable) { val exception = when (throwable) { is KotlinNullPointerException -> IllegalStateException("The request returned a null body") - is HttpException -> throwable.toFailure(globalErrorReceiver) - else -> throwable + is HttpException -> throwable.toFailure(globalErrorReceiver) + else -> throwable } // Log some details about the request which has failed. @@ -94,11 +94,11 @@ internal suspend inline fun executeRequest( // Try again (loop) } else { throw when (exception) { - is IOException -> Failure.NetworkConnection(exception) + is IOException -> Failure.NetworkConnection(exception) is Failure.ServerError, is Failure.OtherServerError, is CancellationException -> exception - else -> Failure.Unknown(exception) + else -> Failure.Unknown(exception) } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt index 5268ea851d..30f7cdd65b 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/RetrofitExtensions.kt @@ -92,10 +92,10 @@ private fun toFailure(errorBody: ResponseBody?, httpCode: Int, globalErrorReceiv globalErrorReceiver?.handleGlobalError(GlobalError.ConsentNotGivenError(matrixError.consentUri)) } httpCode == HttpURLConnection.HTTP_UNAUTHORIZED && /* 401 */ - matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> { + matrixError.code == MatrixError.M_UNKNOWN_TOKEN -> { globalErrorReceiver?.handleGlobalError(GlobalError.InvalidToken(matrixError.isSoftLogout.orFalse())) } - matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> { + matrixError.code == MatrixError.ORG_MATRIX_EXPIRED_ACCOUNT -> { globalErrorReceiver?.handleGlobalError(GlobalError.ExpiredAccount) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/ForceToBoolean.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/ForceToBoolean.kt index 628486bb5f..b4925429d0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/ForceToBoolean.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/network/parsing/ForceToBoolean.kt @@ -37,9 +37,9 @@ internal class ForceToBooleanJsonAdapter { @ForceToBoolean fun fromJson(reader: JsonReader): Boolean { return when (val token = reader.peek()) { - JsonReader.Token.NUMBER -> reader.nextInt() != 0 + JsonReader.Token.NUMBER -> reader.nextInt() != 0 JsonReader.Token.BOOLEAN -> reader.nextBoolean() - else -> { + else -> { Timber.e("Expecting a boolean or a int but get: $token") reader.skipValue() false diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryRoomOrderProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryRoomOrderProcessor.kt index c5ea2d48ad..8df0482993 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryRoomOrderProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryRoomOrderProcessor.kt @@ -24,10 +24,10 @@ import org.matrix.android.sdk.internal.database.model.RoomSummaryEntityFields internal fun RealmQuery.process(sortOrder: RoomSortOrder): RealmQuery { when (sortOrder) { - RoomSortOrder.NAME -> { + RoomSortOrder.NAME -> { sort(RoomSummaryEntityFields.DISPLAY_NAME, Sort.ASCENDING) } - RoomSortOrder.ACTIVITY -> { + RoomSortOrder.ACTIVITY -> { sort(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, Sort.DESCENDING) } RoomSortOrder.PRIORITY_AND_ACTIVITY -> { @@ -40,7 +40,7 @@ internal fun RealmQuery.process(sortOrder: RoomSortOrder): Re arrayOf(Sort.DESCENDING, Sort.ASCENDING, Sort.DESCENDING) ) } - RoomSortOrder.NONE -> { + RoomSortOrder.NONE -> { } } return this diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt index ba4d05e747..b2ab9879df 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt @@ -31,12 +31,12 @@ internal class QueryStringValueProcessor @Inject constructor( fun RealmQuery.process(field: String, queryStringValue: QueryStringValue): RealmQuery { return when (queryStringValue) { is QueryStringValue.NoCondition -> this - is QueryStringValue.IsNotNull -> isNotNull(field) - is QueryStringValue.IsNull -> isNull(field) - is QueryStringValue.IsEmpty -> isEmpty(field) - is QueryStringValue.IsNotEmpty -> isNotEmpty(field) - is ContentQueryStringValue -> when (queryStringValue) { - is QueryStringValue.Equals -> equalTo(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase()) + is QueryStringValue.IsNotNull -> isNotNull(field) + is QueryStringValue.IsNull -> isNull(field) + is QueryStringValue.IsEmpty -> isEmpty(field) + is QueryStringValue.IsNotEmpty -> isNotEmpty(field) + is ContentQueryStringValue -> when (queryStringValue) { + is QueryStringValue.Equals -> equalTo(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase()) is QueryStringValue.Contains -> contains(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase()) } } @@ -44,7 +44,7 @@ internal class QueryStringValueProcessor @Inject constructor( private fun ContentQueryStringValue.toRealmValue(): String { return when (case) { - QueryStringValue.Case.NORMALIZED -> normalizer.normalize(string) + QueryStringValue.Case.NORMALIZED -> normalizer.normalize(string) QueryStringValue.Case.SENSITIVE, QueryStringValue.Case.INSENSITIVE -> string } @@ -55,6 +55,6 @@ private fun QueryStringValue.Case.toRealmCase(): Case { return when (this) { QueryStringValue.Case.INSENSITIVE -> Case.INSENSITIVE QueryStringValue.Case.SENSITIVE, - QueryStringValue.Case.NORMALIZED -> Case.SENSITIVE + QueryStringValue.Case.NORMALIZED -> Case.SENSITIVE } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt index d0e2534e7a..87adad9063 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/raw/GetUrlTask.kt @@ -42,8 +42,8 @@ internal class DefaultGetUrlTask @Inject constructor( override suspend fun execute(params: GetUrlTask.Params): String { return when (params.cacheStrategy) { - CacheStrategy.NoCache -> doRequest(params.url) - is CacheStrategy.TtlCache -> doRequestWithCache( + CacheStrategy.NoCache -> doRequest(params.url) + is CacheStrategy.TtlCache -> doRequestWithCache( params.url, params.cacheStrategy.validityDurationInMillis, params.cacheStrategy.strict diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultFileService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultFileService.kt index d3c51a7b7b..bbf260a3f1 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultFileService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultFileService.kt @@ -127,7 +127,7 @@ internal class DefaultFileService @Inject constructor( val resolvedUrl = contentUrlResolver.resolveForDownload(url, elementToDecrypt) ?: throw IllegalArgumentException("url is null") val request = when (resolvedUrl) { - is ContentUrlResolver.ResolvedMethod.GET -> { + is ContentUrlResolver.ResolvedMethod.GET -> { Request.Builder() .url(resolvedUrl.url) .header(DOWNLOAD_PROGRESS_INTERCEPTOR_HEADER, url) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt index c4f711a9e6..48a9dfd3da 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/call/CallSignalingHandler.kt @@ -63,25 +63,25 @@ internal class CallSignalingHandler @Inject constructor( fun onCallEvent(event: Event) { when (event.getClearType()) { - EventType.CALL_ANSWER -> { + EventType.CALL_ANSWER -> { handleCallAnswerEvent(event) } - EventType.CALL_INVITE -> { + EventType.CALL_INVITE -> { handleCallInviteEvent(event) } - EventType.CALL_HANGUP -> { + EventType.CALL_HANGUP -> { handleCallHangupEvent(event) } - EventType.CALL_REJECT -> { + EventType.CALL_REJECT -> { handleCallRejectEvent(event) } - EventType.CALL_CANDIDATES -> { + EventType.CALL_CANDIDATES -> { handleCallCandidatesEvent(event) } - EventType.CALL_SELECT_ANSWER -> { + EventType.CALL_SELECT_ANSWER -> { handleCallSelectAnswerEvent(event) } - EventType.CALL_NEGOTIATE -> { + EventType.CALL_NEGOTIATE -> { handleCallNegotiateEvent(event) } EventType.CALL_ASSERTED_IDENTITY, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/ImageCompressor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/ImageCompressor.kt index cca01b4dc7..bc04cac35a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/ImageCompressor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/ImageCompressor.kt @@ -69,20 +69,20 @@ internal class ImageCompressor @Inject constructor( val orientation = exifInfo.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL) val matrix = Matrix() when (orientation) { - ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f) - ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f) - ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f) + ExifInterface.ORIENTATION_ROTATE_270 -> matrix.postRotate(270f) + ExifInterface.ORIENTATION_ROTATE_180 -> matrix.postRotate(180f) + ExifInterface.ORIENTATION_ROTATE_90 -> matrix.postRotate(90f) ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.preScale(-1f, 1f) - ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.preScale(1f, -1f) - ExifInterface.ORIENTATION_TRANSPOSE -> { + ExifInterface.ORIENTATION_FLIP_VERTICAL -> matrix.preScale(1f, -1f) + ExifInterface.ORIENTATION_TRANSPOSE -> { matrix.preRotate(-90f) matrix.preScale(-1f, 1f) } - ExifInterface.ORIENTATION_TRANSVERSE -> { + ExifInterface.ORIENTATION_TRANSVERSE -> { matrix.preRotate(90f) matrix.preScale(-1f, 1f) } - else -> return bitmap + else -> return bitmap } return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt index b62ca2c0f6..1e62b5d7f5 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/UploadContentWorker.kt @@ -192,7 +192,7 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter }) .let { videoCompressionResult -> when (videoCompressionResult) { - is VideoCompressionResult.Success -> { + is VideoCompressionResult.Success -> { val compressedFile = videoCompressionResult.compressedFile var compressedWidth: Int? = null var compressedHeight: Int? = null @@ -411,9 +411,9 @@ internal class UploadContentWorker(val context: Context, params: WorkerParameter val updatedContent = when (messageContent) { is MessageImageContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes) is MessageVideoContent -> messageContent.update(url, encryptedFileInfo, thumbnailUrl, thumbnailEncryptedFileInfo, newAttachmentAttributes) - is MessageFileContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize) + is MessageFileContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize) is MessageAudioContent -> messageContent.update(url, encryptedFileInfo, newAttachmentAttributes.newFileSize) - else -> messageContent + else -> messageContent } event.content = ContentMapper.map(updatedContent.toContent()) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/VideoCompressor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/VideoCompressor.kt index 85f59ab043..5c00927e23 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/VideoCompressor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/content/VideoCompressor.kt @@ -113,7 +113,7 @@ internal class VideoCompressor @Inject constructor( deleteFile(destinationFile) VideoCompressionResult.CompressionNotNeeded } - else -> { + else -> { // Should not happen... // Delete now the temporary file deleteFile(destinationFile) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/db/RealmContentScannerStore.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/db/RealmContentScannerStore.kt index 27729d38c7..72dc15c1bd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/db/RealmContentScannerStore.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/contentscanner/db/RealmContentScannerStore.kt @@ -106,7 +106,7 @@ internal class RealmContentScannerStore @Inject constructor( ScanState.IN_PROGRESS, ScanState.TRUSTED, ScanState.INFECTED -> true - else -> false + else -> false } } return isKnown diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt index e9d5b876a8..63afa1bbbc 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/filter/SaveFilterTask.kt @@ -45,7 +45,7 @@ internal class DefaultSaveFilterTask @Inject constructor( FilterService.FilterPreset.ElementFilter -> { FilterFactory.createElementFilter() } - FilterService.FilterPreset.NoFilter -> { + FilterService.FilterPreset.NoFilter -> { FilterFactory.createDefaultFilter() } } @@ -53,7 +53,7 @@ internal class DefaultSaveFilterTask @Inject constructor( FilterService.FilterPreset.ElementFilter -> { FilterFactory.createElementRoomFilter() } - FilterService.FilterPreset.NoFilter -> { + FilterService.FilterPreset.NoFilter -> { FilterFactory.createDefaultRoomFilter() } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt index 4e0ee3422b..235291d061 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/group/GetGroupDataTask.kt @@ -58,7 +58,7 @@ internal class DefaultGetGroupDataTask @Inject constructor( is GetGroupDataTask.Params.FetchAllActive -> { getActiveGroupIds() } - is GetGroupDataTask.Params.FetchWithIds -> { + is GetGroupDataTask.Params.FetchWithIds -> { params.groupIds } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt index 74838afc65..30c7773a8e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/DefaultIdentityService.kt @@ -283,8 +283,8 @@ internal class DefaultIdentityService @Inject constructor( identityStore.setToken(null) lookUpInternal(false, threePids) } - throwable.isTermsNotSigned() -> throw IdentityServiceError.TermsNotSignedException - else -> throw throwable + throwable.isTermsNotSigned() -> throw IdentityServiceError.TermsNotSignedException + else -> throw throwable } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt index fe12309650..02462387fa 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/identity/IdentityRequestTokenForBindingTask.kt @@ -57,7 +57,7 @@ internal class DefaultIdentityRequestTokenForBindingTask @Inject constructor( val tokenResponse = executeRequest(null) { when (params.threePid) { - is ThreePid.Email -> identityAPI.requestTokenToBindEmail( + is ThreePid.Email -> identityAPI.requestTokenToBindEmail( IdentityRequestTokenForEmailBody( clientSecret = clientSecret, sendAttempt = sendAttempt, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt index 32bcf3f7ca..a31f0d6065 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/media/GetPreviewUrlTask.kt @@ -48,8 +48,8 @@ internal class DefaultGetPreviewUrlTask @Inject constructor( override suspend fun execute(params: GetPreviewUrlTask.Params): PreviewUrlData { return when (params.cacheStrategy) { - CacheStrategy.NoCache -> doRequest(params.url, params.timestamp) - is CacheStrategy.TtlCache -> doRequestWithCache( + CacheStrategy.NoCache -> doRequest(params.url, params.timestamp) + is CacheStrategy.TtlCache -> doRequestWithCache( params.url, params.timestamp, params.cacheStrategy.validityDurationInMillis, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt index f9da7b66f6..8e20199135 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/permalinks/PermalinkFactory.kt @@ -44,15 +44,15 @@ internal class PermalinkFactory @Inject constructor( fun createPermalink(id: String, forceMatrixTo: Boolean): String? { return when { - id.isEmpty() -> null + id.isEmpty() -> null !useClientFormat(forceMatrixTo) -> MATRIX_TO_URL_BASE + escape(id) - else -> { + else -> { buildString { append(matrixConfiguration.clientPermalinkBaseUrl) when { MatrixPatterns.isRoomId(id) || MatrixPatterns.isRoomAlias(id) -> append(ROOM_PATH) - MatrixPatterns.isUserId(id) -> append(USER_PATH) - MatrixPatterns.isGroupId(id) -> append(GROUP_PATH) + MatrixPatterns.isUserId(id) -> append(USER_PATH) + MatrixPatterns.isGroupId(id) -> append(GROUP_PATH) } append(escape(id)) } @@ -94,16 +94,16 @@ internal class PermalinkFactory @Inject constructor( fun getLinkedId(url: String): String? { val clientBaseUrl = matrixConfiguration.clientPermalinkBaseUrl return when { - url.startsWith(MATRIX_TO_URL_BASE) -> url.substring(MATRIX_TO_URL_BASE.length) + url.startsWith(MATRIX_TO_URL_BASE) -> url.substring(MATRIX_TO_URL_BASE.length) clientBaseUrl != null && url.startsWith(clientBaseUrl) -> { when (PermalinkParser.parse(url)) { is PermalinkData.GroupLink -> url.substring(clientBaseUrl.length + GROUP_PATH.length) - is PermalinkData.RoomLink -> url.substring(clientBaseUrl.length + ROOM_PATH.length) - is PermalinkData.UserLink -> url.substring(clientBaseUrl.length + USER_PATH.length) - else -> null + is PermalinkData.RoomLink -> url.substring(clientBaseUrl.length + ROOM_PATH.length) + is PermalinkData.UserLink -> url.substring(clientBaseUrl.length + USER_PATH.length) + else -> null } } - else -> null + else -> null } ?.substringBeforeLast("?") } @@ -111,7 +111,7 @@ internal class PermalinkFactory @Inject constructor( fun createMentionSpanTemplate(type: PermalinkService.SpanTemplateType, forceMatrixTo: Boolean): String { return buildString { when (type) { - HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_BEGIN) + HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_BEGIN) MARKDOWN -> append(MENTION_SPAN_TO_MD_TEMPLATE_BEGIN) } append(baseUrl(forceMatrixTo)) @@ -119,7 +119,7 @@ internal class PermalinkFactory @Inject constructor( append(USER_PATH) } when (type) { - HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_END) + HTML -> append(MENTION_SPAN_TO_HTML_TEMPLATE_END) MARKDOWN -> append(MENTION_SPAN_TO_MD_TEMPLATE_END) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt index f7798dc9e9..4a6cb6c019 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/AddThreePidTask.kt @@ -42,7 +42,7 @@ internal class DefaultAddThreePidTask @Inject constructor( override suspend fun execute(params: Params) { when (params.threePid) { - is ThreePid.Email -> addEmail(params.threePid) + is ThreePid.Email -> addEmail(params.threePid) is ThreePid.Msisdn -> addMsisdn(params.threePid) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt index 9ec296f20b..8a25d870b6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/profile/RefreshUserThreePidsTask.kt @@ -57,9 +57,9 @@ internal class DefaultRefreshUserThreePidsTask @Inject constructor( private fun Any?.toLong(): Long { return when (this) { - null -> 0L - is Long -> this + null -> 0L + is Long -> this is Double -> this.toLong() - else -> 0L + else -> 0L } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt index 0042558027..5fd50f1752 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushers/AddPusherWorker.kt @@ -53,7 +53,7 @@ internal class AddPusherWorker(context: Context, params: WorkerParameters, sessi } catch (exception: Throwable) { when (exception) { is Failure.NetworkConnection -> Result.retry() - else -> Result.failure() + else -> Result.failure() } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt index 60c1194708..09d7d50ecb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/pushrules/ProcessEventForPushTask.kt @@ -62,7 +62,7 @@ internal class DefaultProcessEventForPushTask @Inject constructor( EventType.REDACTION, EventType.ENCRYPTED, EventType.STATE_ROOM_MEMBER -> true - else -> false + else -> false } }.filter { it.senderId != userId diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt index 5a794c6ba3..bb43d90328 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/EventRelationsAggregationProcessor.kt @@ -103,12 +103,12 @@ internal class EventRelationsAggregationProcessor @Inject constructor( } val isLocalEcho = LocalEcho.isLocalEchoId(event.eventId ?: "") when (event.type) { - EventType.REACTION -> { + EventType.REACTION -> { // we got a reaction!! Timber.v("###REACTION in room $roomId , reaction eventID ${event.eventId}") handleReaction(realm, event, roomId, isLocalEcho) } - EventType.MESSAGE -> { + EventType.MESSAGE -> { if (event.unsignedData?.relations?.annotations != null) { Timber.v("###REACTION Aggregation in room $roomId for event ${event.eventId}") handleInitialAggregatedRelations(realm, event, roomId, event.unsignedData.relations.annotations) @@ -134,7 +134,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor( EventType.KEY_VERIFICATION_START, EventType.KEY_VERIFICATION_MAC, EventType.KEY_VERIFICATION_READY, - EventType.KEY_VERIFICATION_KEY -> { + EventType.KEY_VERIFICATION_KEY -> { Timber.v("## SAS REF in room $roomId for event ${event.eventId}") event.content.toModel()?.relatesTo?.let { if (it.type == RelationType.REFERENCE && it.eventId != null) { @@ -143,7 +143,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor( } } - EventType.ENCRYPTED -> { + EventType.ENCRYPTED -> { // Relation type is in clear val encryptedEventContent = event.content.toModel() if (encryptedEventContent?.relatesTo?.type == RelationType.REPLACE || @@ -168,20 +168,20 @@ internal class EventRelationsAggregationProcessor @Inject constructor( EventType.KEY_VERIFICATION_START, EventType.KEY_VERIFICATION_MAC, EventType.KEY_VERIFICATION_READY, - EventType.KEY_VERIFICATION_KEY -> { + EventType.KEY_VERIFICATION_KEY -> { Timber.v("## SAS REF in room $roomId for event ${event.eventId}") encryptedEventContent.relatesTo.eventId?.let { handleVerification(realm, event, roomId, isLocalEcho, it) } } - in EventType.POLL_RESPONSE -> { + in EventType.POLL_RESPONSE -> { event.getClearContent().toModel(catchError = true)?.let { sessionManager.getSessionComponent(sessionId)?.session()?.let { session -> pollAggregationProcessor.handlePollResponseEvent(session, realm, event) } } } - in EventType.POLL_END -> { + in EventType.POLL_END -> { sessionManager.getSessionComponent(sessionId)?.session()?.let { session -> getPowerLevelsHelper(event.roomId)?.let { pollAggregationProcessor.handlePollEndEvent(session, it, realm, event) @@ -211,11 +211,11 @@ internal class EventRelationsAggregationProcessor @Inject constructor( // } // } } - EventType.REDACTION -> { + EventType.REDACTION -> { val eventToPrune = event.redacts?.let { EventEntity.where(realm, eventId = it).findFirst() } ?: return when (eventToPrune.type) { - EventType.MESSAGE -> { + EventType.MESSAGE -> { Timber.d("REDACTION for message ${eventToPrune.eventId}") // val unsignedData = EventMapper.map(eventToPrune).unsignedData // ?: UnsignedData(null, null) @@ -231,7 +231,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor( } } } - in EventType.POLL_START -> { + in EventType.POLL_START -> { val content: MessagePollContent? = event.content.toModel() if (content?.relatesTo?.type == RelationType.REPLACE) { Timber.v("###REPLACE in room $roomId for event ${event.eventId}") @@ -239,14 +239,14 @@ internal class EventRelationsAggregationProcessor @Inject constructor( handleReplace(realm, event, content, roomId, isLocalEcho) } } - in EventType.POLL_RESPONSE -> { + in EventType.POLL_RESPONSE -> { event.content.toModel(catchError = true)?.let { sessionManager.getSessionComponent(sessionId)?.session()?.let { session -> pollAggregationProcessor.handlePollResponseEvent(session, realm, event) } } } - in EventType.POLL_END -> { + in EventType.POLL_END -> { sessionManager.getSessionComponent(sessionId)?.session()?.let { session -> getPowerLevelsHelper(event.roomId)?.let { pollAggregationProcessor.handlePollEndEvent(session, it, realm, event) @@ -258,10 +258,10 @@ internal class EventRelationsAggregationProcessor @Inject constructor( liveLocationAggregationProcessor.handleBeaconInfo(realm, event, it, roomId, isLocalEcho) } } - in EventType.BEACON_LOCATION_DATA -> { + in EventType.BEACON_LOCATION_DATA -> { handleBeaconLocationData(event, realm, roomId, isLocalEcho) } - else -> Timber.v("UnHandled event ${event.eventId}") + else -> Timber.v("UnHandled event ${event.eventId}") } } catch (t: Throwable) { Timber.e(t, "## Should not happen ") @@ -572,7 +572,7 @@ internal class EventRelationsAggregationProcessor @Inject constructor( EventType.KEY_VERIFICATION_ACCEPT, EventType.KEY_VERIFICATION_READY, EventType.KEY_VERIFICATION_KEY, - EventType.KEY_VERIFICATION_MAC -> currentState.toState(VerificationState.WAITING) + EventType.KEY_VERIFICATION_MAC -> currentState.toState(VerificationState.WAITING) EventType.KEY_VERIFICATION_CANCEL -> currentState.toState( if (event.senderId == userId) { VerificationState.CANCELED_BY_ME @@ -580,8 +580,8 @@ internal class EventRelationsAggregationProcessor @Inject constructor( VerificationState.CANCELED_BY_OTHER } ) - EventType.KEY_VERIFICATION_DONE -> currentState.toState(VerificationState.DONE) - else -> VerificationState.REQUEST + EventType.KEY_VERIFICATION_DONE -> currentState.toState(VerificationState.DONE) + else -> VerificationState.REQUEST } data = data.copy(verificationState = newState) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/crypto/DefaultRoomCryptoService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/crypto/DefaultRoomCryptoService.kt index 2546c58cc7..4f0228e6a8 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/crypto/DefaultRoomCryptoService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/crypto/DefaultRoomCryptoService.kt @@ -61,10 +61,10 @@ internal class DefaultRoomCryptoService @AssistedInject constructor( (!force && isEncrypted() && encryptionAlgorithm() == MXCRYPTO_ALGORITHM_MEGOLM) -> { throw IllegalStateException("Encryption is already enabled for this room") } - (!force && algorithm != MXCRYPTO_ALGORITHM_MEGOLM) -> { + (!force && algorithm != MXCRYPTO_ALGORITHM_MEGOLM) -> { throw InvalidParameterException("Only MXCRYPTO_ALGORITHM_MEGOLM algorithm is supported") } - else -> { + else -> { val params = SendStateTask.Params( roomId = roomId, stateKey = "", diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt index d3d1cb856a..15d0889255 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/LoadRoomMembersTask.kt @@ -68,9 +68,9 @@ internal class DefaultLoadRoomMembersTask @Inject constructor( override suspend fun execute(params: LoadRoomMembersTask.Params) { when (getRoomMembersLoadStatus(params.roomId)) { - RoomMembersLoadStatusType.NONE -> doRequest(params) + RoomMembersLoadStatusType.NONE -> doRequest(params) RoomMembersLoadStatusType.LOADING -> waitPreviousRequestToFinish(params) - RoomMembersLoadStatusType.LOADED -> Unit + RoomMembersLoadStatusType.LOADED -> Unit } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomChangeMembershipStateDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomChangeMembershipStateDataSource.kt index 35d8cb08af..c61625b2b1 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomChangeMembershipStateDataSource.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomChangeMembershipStateDataSource.kt @@ -61,8 +61,8 @@ internal class RoomChangeMembershipStateDataSource @Inject constructor() { private fun Membership.toMembershipChangeState(): ChangeMembershipState { return when { this == Membership.JOIN -> ChangeMembershipState.Joined - this.isLeft() -> ChangeMembershipState.Left - else -> ChangeMembershipState.Unknown + this.isLeft() -> ChangeMembershipState.Left + else -> ChangeMembershipState.Unknown } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt index 23d7e0fc51..4645bb05ab 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/RoomDisplayNameResolver.kt @@ -110,32 +110,32 @@ internal class RoomDisplayNameResolver @Inject constructor( } val otherMembersCount = otherMembersSubset.count() name = when (otherMembersCount) { - 0 -> { + 0 -> { // Get left members if any val leftMembersNames = roomMembers.queryLeftRoomMembersEvent() .findAll() .map { displayNameResolver.getBestName(it.toMatrixItem()) } roomDisplayNameFallbackProvider.getNameForEmptyRoom(roomSummary?.isDirect.orFalse(), leftMembersNames) } - 1 -> { + 1 -> { roomDisplayNameFallbackProvider.getNameFor1member( resolveRoomMemberName(otherMembersSubset[0], roomMembers) ) } - 2 -> { + 2 -> { roomDisplayNameFallbackProvider.getNameFor2members( resolveRoomMemberName(otherMembersSubset[0], roomMembers), resolveRoomMemberName(otherMembersSubset[1], roomMembers) ) } - 3 -> { + 3 -> { roomDisplayNameFallbackProvider.getNameFor3members( resolveRoomMemberName(otherMembersSubset[0], roomMembers), resolveRoomMemberName(otherMembersSubset[1], roomMembers), resolveRoomMemberName(otherMembersSubset[2], roomMembers) ) } - 4 -> { + 4 -> { roomDisplayNameFallbackProvider.getNameFor4members( resolveRoomMemberName(otherMembersSubset[0], roomMembers), resolveRoomMemberName(otherMembersSubset[1], roomMembers), diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt index d2c21f3520..b07a77a18f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/membership/admin/MembershipAdminTask.kt @@ -43,9 +43,9 @@ internal class DefaultMembershipAdminTask @Inject constructor(private val roomAP val userIdAndReason = UserIdAndReason(params.userId, params.reason) executeRequest(null) { when (params.type) { - MembershipAdminTask.Type.BAN -> roomAPI.ban(params.roomId, userIdAndReason) + MembershipAdminTask.Type.BAN -> roomAPI.ban(params.roomId, userIdAndReason) MembershipAdminTask.Type.UNBAN -> roomAPI.unban(params.roomId, userIdAndReason) - MembershipAdminTask.Type.KICK -> roomAPI.kick(params.roomId, userIdAndReason) + MembershipAdminTask.Type.KICK -> roomAPI.kick(params.roomId, userIdAndReason) } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/RoomPushRuleMapper.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/RoomPushRuleMapper.kt index a5a5ab58ba..42b069f8fa 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/RoomPushRuleMapper.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/notification/RoomPushRuleMapper.kt @@ -33,10 +33,10 @@ internal fun PushRuleEntity.toRoomPushRule(): RoomPushRule? { RuleSetKey.OVERRIDE -> { PushRulesMapper.map(this) } - RuleSetKey.ROOM -> { + RuleSetKey.ROOM -> { PushRulesMapper.mapRoomRule(this) } - else -> null + else -> null } return if (pushRule == null || kind == null) { null @@ -47,7 +47,7 @@ internal fun PushRuleEntity.toRoomPushRule(): RoomPushRule? { internal fun RoomNotificationState.toRoomPushRule(roomId: String): RoomPushRule? { return when { - this == RoomNotificationState.ALL_MESSAGES -> null + this == RoomNotificationState.ALL_MESSAGES -> null this == RoomNotificationState.ALL_MESSAGES_NOISY -> { val rule = PushRule( actions = listOf(Action.Notify, Action.Sound()).toJson(), @@ -56,7 +56,7 @@ internal fun RoomNotificationState.toRoomPushRule(roomId: String): RoomPushRule? ) return RoomPushRule(RuleSetKey.ROOM, rule) } - else -> { + else -> { val condition = PushCondition( kind = Kind.EventMatch.value, key = "room_id", diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt index 63fc26e9d6..55c7bb1ddf 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/peeking/PeekRoomTask.kt @@ -111,7 +111,7 @@ internal class DefaultPeekRoomTask @Inject constructor( )) }?.chunk?.firstOrNull { it.roomId == roomId } } - else -> { + else -> { // RoomDirectoryVisibility.PRIVATE or null // We cannot resolve this room :/ null diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/prune/RedactionEventProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/prune/RedactionEventProcessor.kt index e926d6a785..e33fbb56b1 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/prune/RedactionEventProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/prune/RedactionEventProcessor.kt @@ -145,10 +145,10 @@ internal class RedactionEventProcessor @Inject constructor() : EventInsertLivePr private fun computeAllowedKeys(type: String): List { // Add filtered content, allowed keys in content depends on the event type return when (type) { - EventType.STATE_ROOM_MEMBER -> listOf("membership") - EventType.STATE_ROOM_CREATE -> listOf("creator") - EventType.STATE_ROOM_JOIN_RULES -> listOf("join_rule") - EventType.STATE_ROOM_POWER_LEVELS -> listOf( + EventType.STATE_ROOM_MEMBER -> listOf("membership") + EventType.STATE_ROOM_CREATE -> listOf("creator") + EventType.STATE_ROOM_JOIN_RULES -> listOf("join_rule") + EventType.STATE_ROOM_POWER_LEVELS -> listOf( "users", "users_default", "events", @@ -159,10 +159,10 @@ internal class RedactionEventProcessor @Inject constructor() : EventInsertLivePr "redact", "invite" ) - EventType.STATE_ROOM_ALIASES -> listOf("aliases") + EventType.STATE_ROOM_ALIASES -> listOf("aliases") EventType.STATE_ROOM_CANONICAL_ALIAS -> listOf("alias") - EventType.FEEDBACK -> listOf("type", "target_event_id") - else -> emptyList() + EventType.FEEDBACK -> listOf("type", "target_event_id") + else -> emptyList() } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt index ffca0204a8..fc78abcfd9 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/DefaultSendService.kt @@ -198,7 +198,7 @@ internal class DefaultSendService @AssistedInject constructor( localEchoRepository.updateSendState(localEcho.eventId, roomId, SendState.UNSENT) internalSendMedia(listOf(localEcho.root), attachmentData, true) } - is MessageFileContent -> { + is MessageFileContent -> { val attachmentData = ContentAttachmentData( size = messageContent.info!!.size, mimeType = messageContent.mimeType, @@ -222,7 +222,7 @@ internal class DefaultSendService @AssistedInject constructor( localEchoRepository.updateSendState(localEcho.eventId, roomId, SendState.UNSENT) internalSendMedia(listOf(localEcho.root), attachmentData, true) } - else -> NoOpCancellable + else -> NoOpCancellable } } return NoOpCancellable diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt index 2bb6f3e04f..3b9ca44d18 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoEventFactory.kt @@ -345,11 +345,11 @@ internal class LocalEchoEventFactory @Inject constructor( rootThreadEventId: String? ): Event { return when (attachment.type) { - ContentAttachmentData.Type.IMAGE -> createImageEvent(roomId, attachment, rootThreadEventId) - ContentAttachmentData.Type.VIDEO -> createVideoEvent(roomId, attachment, rootThreadEventId) - ContentAttachmentData.Type.AUDIO -> createAudioEvent(roomId, attachment, isVoiceMessage = false, rootThreadEventId = rootThreadEventId) + ContentAttachmentData.Type.IMAGE -> createImageEvent(roomId, attachment, rootThreadEventId) + ContentAttachmentData.Type.VIDEO -> createVideoEvent(roomId, attachment, rootThreadEventId) + ContentAttachmentData.Type.AUDIO -> createAudioEvent(roomId, attachment, isVoiceMessage = false, rootThreadEventId = rootThreadEventId) ContentAttachmentData.Type.VOICE_MESSAGE -> createAudioEvent(roomId, attachment, isVoiceMessage = true, rootThreadEventId = rootThreadEventId) - ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment, rootThreadEventId) + ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment, rootThreadEventId) } } @@ -685,7 +685,7 @@ internal class LocalEchoEventFactory @Inject constructor( when (content?.msgType) { MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_TEXT, - MessageType.MSGTYPE_NOTICE -> { + MessageType.MSGTYPE_NOTICE -> { var formattedText: String? = null if (content is MessageContentWithFormattedBody) { formattedText = content.matrixFormattedBody @@ -696,14 +696,14 @@ internal class LocalEchoEventFactory @Inject constructor( TextContent(content.body, formattedText) } } - MessageType.MSGTYPE_FILE -> return TextContent("sent a file.") - MessageType.MSGTYPE_AUDIO -> return TextContent("sent an audio file.") - MessageType.MSGTYPE_IMAGE -> return TextContent("sent an image.") - MessageType.MSGTYPE_VIDEO -> return TextContent("sent a video.") + MessageType.MSGTYPE_FILE -> return TextContent("sent a file.") + MessageType.MSGTYPE_AUDIO -> return TextContent("sent an audio file.") + MessageType.MSGTYPE_IMAGE -> return TextContent("sent an image.") + MessageType.MSGTYPE_VIDEO -> return TextContent("sent a video.") MessageType.MSGTYPE_POLL_START -> { return TextContent((content as? MessagePollContent)?.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "") } - else -> return TextContent(content?.body ?: "") + else -> return TextContent(content?.body ?: "") } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt index bed590fd09..394cb8944f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/LocalEchoRepository.kt @@ -201,7 +201,7 @@ internal class LocalEchoRepository @Inject constructor( // need to resend the attachment true } - else -> { + else -> { Timber.e("Cannot resend message ${event.root.getClearType()} / ${content.msgType}") false } @@ -211,7 +211,7 @@ internal class LocalEchoRepository @Inject constructor( false } } - else -> { + else -> { Timber.e("Unsupported message to resend ${event.root.getClearType()}") false } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt index 1c0da4839a..765c282b65 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/RedactEventWorker.kt @@ -71,7 +71,7 @@ internal class RedactEventWorker(context: Context, params: WorkerParameters, ses { when (it) { is Failure.NetworkConnection -> Result.retry() - else -> { + else -> { // TODO mark as failed to send? // always return success, or the chain will be stuck for ever! Result.success( diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/WaveFormSanitizer.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/WaveFormSanitizer.kt index 78a03f3775..c7ca2e770f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/WaveFormSanitizer.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/WaveFormSanitizer.kt @@ -58,7 +58,7 @@ internal class WaveFormSanitizer @Inject constructor() { } } } - else -> { + else -> { sizeInRangeList.addAll(waveForm) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/MentionLinkSpecComparator.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/MentionLinkSpecComparator.kt index 3d235ec4d6..db5eec7e7e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/MentionLinkSpecComparator.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/MentionLinkSpecComparator.kt @@ -24,9 +24,9 @@ internal class MentionLinkSpecComparator @Inject constructor() : Comparator -1 o1.start > o2.start -> 1 - o1.end < o2.end -> 1 - o1.end > o2.end -> -1 - else -> 0 + o1.end < o2.end -> 1 + o1.end > o2.end -> -1 + else -> 0 } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt index fa2e0052ab..38bddae951 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/pills/TextPillsUtils.kt @@ -90,7 +90,7 @@ internal class TextPillsUtils @Inject constructor( // test if there is an overlap if (b.start in a.start until a.end) { when { - b.end <= a.end -> + b.end <= a.end -> // b is inside a -> b should be removed remove = i + 1 a.end - a.start > b.end - b.start -> diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt index 8ef631ad36..2c7eea1e54 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorCoroutine.kt @@ -150,13 +150,13 @@ internal class EventSenderProcessorCoroutine @Inject constructor( canReachServer.set(false) task.markAsFailedOrRetry(exception, 0) } - (exception.isLimitExceededError()) -> { + (exception.isLimitExceededError()) -> { task.markAsFailedOrRetry(exception, exception.getRetryDelay(3_000)) } - exception is CancellationException -> { + exception is CancellationException -> { Timber.v("## $task has been cancelled, try next task") } - else -> { + else -> { Timber.v("## un-retryable error for $task, try next task") // this task is in error, check next one? task.onTaskFailed() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt index 301f8cb9d6..c5b13043d7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/EventSenderProcessorThread.kt @@ -180,7 +180,7 @@ internal class EventSenderProcessorThread @Inject constructor( waitForNetwork() } } - (exception.isLimitExceededError()) -> { + (exception.isLimitExceededError()) -> { if (task.retryCount.getAndIncrement() >= 3) task.onTaskFailed() Timber.v("## SendThread retryLoop retryable error for $task reason: ${exception.localizedMessage}") // wait a bit @@ -188,17 +188,17 @@ internal class EventSenderProcessorThread @Inject constructor( sleep(3_000) continue@retryLoop } - exception.isTokenError() -> { + exception.isTokenError() -> { Timber.v("## SendThread retryLoop retryable TOKEN error, interrupt") // we can exit the loop task.onTaskFailed() throw InterruptedException() } - exception is CancellationException -> { + exception is CancellationException -> { Timber.v("## SendThread task has been cancelled") break@retryLoop } - else -> { + else -> { Timber.v("## SendThread retryLoop Un-Retryable error, try next task") // this task is in error, check next one? task.onTaskFailed() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt index a00c33f780..0eedd4bd4d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/QueueMemento.kt @@ -76,11 +76,11 @@ internal class QueueMemento @Inject constructor( encrypt = task.encrypt, order = order ) - is RedactQueuedTask -> RedactEventTaskInfo( + is RedactQueuedTask -> RedactEventTaskInfo( redactionLocalEcho = task.redactionLocalEchoId, order = order ) - else -> null + else -> null } } @@ -94,7 +94,7 @@ internal class QueueMemento @Inject constructor( ?.forEach { info -> try { when (info) { - is SendEventTaskInfo -> { + is SendEventTaskInfo -> { localEchoRepository.getUpToDateEcho(info.localEchoId)?.let { if (it.sendState.isSending() && it.eventId != null && it.roomId != null) { localEchoRepository.updateSendState(it.eventId, it.roomId, SendState.UNSENT) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/SendEventQueuedTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/SendEventQueuedTask.kt index 49492e7990..1ba4e09caf 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/SendEventQueuedTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/send/queue/SendEventQueuedTask.kt @@ -45,7 +45,7 @@ internal class SendEventQueuedTask( localEchoRepository.deleteFailedEchoAsync(eventId = event.eventId, roomId = event.roomId ?: "") // TODO update aggregation :/ or it will stay locally } - else -> { + else -> { localEchoRepository.updateSendState(event.eventId!!, event.roomId, SendState.UNDELIVERED) } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt index 8b9300029b..2a980f3286 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/state/DefaultStateService.kt @@ -88,7 +88,7 @@ internal class DefaultStateService @AssistedInject constructor( // Safe treatment for PowerLevelContent return when (eventType) { EventType.STATE_ROOM_POWER_LEVELS -> toSafePowerLevelsContentDict() - else -> this + else -> this } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/GraphUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/GraphUtils.kt index 496bc7097f..f10479d873 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/GraphUtils.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/GraphUtils.kt @@ -101,11 +101,11 @@ internal class Graph { // it's a candidate destination = it.destination } - inPath -> { + inPath -> { // Cycle!! backwardEdges.add(it) } - completed -> { + completed -> { // dead end } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt index a6e7d310c3..b71156a431 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt @@ -285,10 +285,10 @@ internal class RoomSummaryDataSource @Inject constructor( queryParams.roomCategoryFilter?.let { when (it) { - RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true) - RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false) + RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true) + RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false) RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0) - RoomCategoryFilter.ALL -> { + RoomCategoryFilter.ALL -> { // nop } } @@ -312,16 +312,16 @@ internal class RoomSummaryDataSource @Inject constructor( query.equalTo(RoomSummaryEntityFields.ROOM_TYPE, it) } when (queryParams.roomCategoryFilter) { - RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true) - RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false) + RoomCategoryFilter.ONLY_DM -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, true) + RoomCategoryFilter.ONLY_ROOMS -> query.equalTo(RoomSummaryEntityFields.IS_DIRECT, false) RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS -> query.greaterThan(RoomSummaryEntityFields.NOTIFICATION_COUNT, 0) - RoomCategoryFilter.ALL -> Unit // nop - null -> Unit + RoomCategoryFilter.ALL -> Unit // nop + null -> Unit } // Timber.w("VAL: activeSpaceId : ${queryParams.activeSpaceId}") when (queryParams.activeSpaceFilter) { - is ActiveSpaceFilter.ActiveSpace -> { + is ActiveSpaceFilter.ActiveSpace -> { // It's annoying but for now realm java does not support querying in primitive list :/ // https://github.com/realm/realm-java/issues/5361 if (queryParams.activeSpaceFilter.currentSpaceId == null) { @@ -334,7 +334,7 @@ internal class RoomSummaryDataSource @Inject constructor( is ActiveSpaceFilter.ExcludeSpace -> { query.not().contains(RoomSummaryEntityFields.FLATTEN_PARENT_IDS, queryParams.activeSpaceFilter.spaceId) } - else -> { + else -> { // nop } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt index fad21c0918..44a786a95d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/DefaultTimeline.kt @@ -259,8 +259,8 @@ internal class DefaultTimeline( strategy = when { rootThreadEventId != null -> buildStrategy(LoadTimelineStrategy.Mode.Thread(rootThreadEventId)) - eventId == null -> buildStrategy(LoadTimelineStrategy.Mode.Live) - else -> buildStrategy(LoadTimelineStrategy.Mode.Permalink(eventId)) + eventId == null -> buildStrategy(LoadTimelineStrategy.Mode.Live) + else -> buildStrategy(LoadTimelineStrategy.Mode.Permalink(eventId)) } rootThreadEventId?.let { @@ -344,7 +344,7 @@ internal class DefaultTimeline( private fun updateState(direction: Timeline.Direction, update: (Timeline.PaginationState) -> Timeline.PaginationState) { val stateReference = when (direction) { - Timeline.Direction.FORWARDS -> forwardState + Timeline.Direction.FORWARDS -> forwardState Timeline.Direction.BACKWARDS -> backwardState } val currentValue = stateReference.get() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt index 4f65f85ce4..c5d4d346fd 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/LoadTimelineStrategy.kt @@ -267,7 +267,7 @@ internal class LoadTimelineStrategy constructor( private fun getChunkEntity(realm: Realm): RealmResults { return when (mode) { - is Mode.Live -> { + is Mode.Live -> { ChunkEntity.where(realm, roomId) .equalTo(ChunkEntityFields.IS_LAST_FORWARD, true) .findAll() @@ -275,7 +275,7 @@ internal class LoadTimelineStrategy constructor( is Mode.Permalink -> { ChunkEntity.findAllIncludingEvents(realm, listOf(mode.originEventId)) } - is Mode.Thread -> { + is Mode.Thread -> { recreateThreadChunkEntity(realm, mode.rootThreadEventId) ChunkEntity.where(realm, roomId) .equalTo(ChunkEntityFields.ROOT_THREAD_EVENT_ID, mode.rootThreadEventId) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationDirection.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationDirection.kt index 930d01759e..37092de9c4 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationDirection.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/PaginationDirection.kt @@ -31,7 +31,7 @@ internal enum class PaginationDirection(val value: String) { fun reversed(): PaginationDirection { return when (this) { - FORWARDS -> BACKWARDS + FORWARDS -> BACKWARDS BACKWARDS -> FORWARDS } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt index 6a5f9da8a6..1d31e28c07 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TimelineChunk.kt @@ -213,7 +213,7 @@ internal class TimelineChunk( fetchFromServerIfNeeded -> { fetchFromServer(offsetCount, chunkEntity.nextToken, direction) } - else -> { + else -> { LoadMoreResult.SUCCESS } } @@ -231,7 +231,7 @@ internal class TimelineChunk( fetchFromServerIfNeeded -> { fetchFromServer(offsetCount, chunkEntity.prevToken, direction) } - else -> { + else -> { LoadMoreResult.SUCCESS } } @@ -457,7 +457,7 @@ internal class TimelineChunk( return when (this) { TokenChunkEventPersistor.Result.REACHED_END -> LoadMoreResult.REACHED_END TokenChunkEventPersistor.Result.SHOULD_FETCH_MORE, - TokenChunkEventPersistor.Result.SUCCESS -> LoadMoreResult.SUCCESS + TokenChunkEventPersistor.Result.SUCCESS -> LoadMoreResult.SUCCESS } } @@ -465,7 +465,7 @@ internal class TimelineChunk( return when (this) { DefaultFetchThreadTimelineTask.Result.REACHED_END -> LoadMoreResult.REACHED_END DefaultFetchThreadTimelineTask.Result.SHOULD_FETCH_MORE, - DefaultFetchThreadTimelineTask.Result.SUCCESS -> LoadMoreResult.SUCCESS + DefaultFetchThreadTimelineTask.Result.SUCCESS -> LoadMoreResult.SUCCESS } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt index 3c68191521..da73727065 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/TokenChunkEventPersistor.kt @@ -205,7 +205,7 @@ internal class TokenChunkEventPersistor @Inject constructor( existingChunk.nextChunk = currentChunk } } - PaginationDirection.FORWARDS -> { + PaginationDirection.FORWARDS -> { if (currentChunk.prevChunk == existingChunk) { Timber.w("Avoid double link, shouldn't happen in an ideal world") } else { diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/UIEchoManager.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/UIEchoManager.kt index 66bb04400b..04c72b5d6d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/UIEchoManager.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/timeline/UIEchoManager.kt @@ -74,7 +74,7 @@ internal class UIEchoManager( when (timelineEvent.root.getClearType()) { EventType.REDACTION -> { } - EventType.REACTION -> { + EventType.REACTION -> { val content: ReactionContent? = timelineEvent.root.content?.toModel() if (RelationType.ANNOTATION == content?.relatesTo?.type) { val reaction = content.relatesTo.key diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt index 07a5cbe5a0..8b35bd173e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/securestorage/SecretStoringUtils.kt @@ -124,7 +124,7 @@ internal class SecretStoringUtils @Inject constructor( fun securelyStoreString(secret: String, keyAlias: String): ByteArray { return when { buildVersionSdkIntProvider.get() >= Build.VERSION_CODES.M -> encryptStringM(secret, keyAlias) - else -> encryptString(secret, keyAlias) + else -> encryptString(secret, keyAlias) } } @@ -138,8 +138,8 @@ internal class SecretStoringUtils @Inject constructor( // First get the format return when (val format = inputStream.read().toByte()) { FORMAT_API_M -> decryptStringM(inputStream, keyAlias) - FORMAT_1 -> decryptString(inputStream, keyAlias) - else -> throw IllegalArgumentException("Unknown format $format") + FORMAT_1 -> decryptString(inputStream, keyAlias) + else -> throw IllegalArgumentException("Unknown format $format") } } } @@ -148,7 +148,7 @@ internal class SecretStoringUtils @Inject constructor( fun securelyStoreObject(any: Any, keyAlias: String, output: OutputStream) { when { buildVersionSdkIntProvider.get() >= Build.VERSION_CODES.M -> saveSecureObjectM(keyAlias, output, any) - else -> saveSecureObject(keyAlias, output, any) + else -> saveSecureObject(keyAlias, output, any) } } @@ -157,8 +157,8 @@ internal class SecretStoringUtils @Inject constructor( // First get the format return when (val format = inputStream.read().toByte()) { FORMAT_API_M -> loadSecureObjectM(keyAlias, inputStream) - FORMAT_1 -> loadSecureObject(keyAlias, inputStream) - else -> throw IllegalArgumentException("Unknown format $format") + FORMAT_1 -> loadSecureObject(keyAlias, inputStream) + else -> throw IllegalArgumentException("Unknown format $format") } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncPresence.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncPresence.kt index ce41a4568c..9df6d52ad3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncPresence.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/SyncPresence.kt @@ -35,9 +35,9 @@ internal enum class SyncPresence(val value: String) { companion object { fun from(presenceEnum: PresenceEnum): SyncPresence { return when (presenceEnum) { - PresenceEnum.ONLINE -> Online - PresenceEnum.OFFLINE -> Offline - PresenceEnum.BUSY -> Busy + PresenceEnum.ONLINE -> Online + PresenceEnum.OFFLINE -> Offline + PresenceEnum.BUSY -> Busy PresenceEnum.UNAVAILABLE -> Unavailable } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/GroupSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/GroupSyncHandler.kt index 49b28348f4..76fc077ee7 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/GroupSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/GroupSyncHandler.kt @@ -51,7 +51,7 @@ internal class GroupSyncHandler @Inject constructor() { private fun handleGroupSync(realm: Realm, handlingStrategy: HandlingStrategy, reporter: ProgressReporter?) { val groups = when (handlingStrategy) { - is HandlingStrategy.JOINED -> + is HandlingStrategy.JOINED -> handlingStrategy.data.mapWithProgress(reporter, InitSyncStep.ImportingAccountGroups, 0.6f) { handleJoinedGroup(realm, it.key) } @@ -61,7 +61,7 @@ internal class GroupSyncHandler @Inject constructor() { handleInvitedGroup(realm, it.key) } - is HandlingStrategy.LEFT -> + is HandlingStrategy.LEFT -> handlingStrategy.data.mapWithProgress(reporter, InitSyncStep.ImportingAccountGroups, 0.1f) { handleLeftGroup(realm, it.key) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/UserAccountDataSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/UserAccountDataSyncHandler.kt index c213ea4bcf..0f296ded5d 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/UserAccountDataSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/UserAccountDataSyncHandler.kt @@ -84,10 +84,10 @@ internal class UserAccountDataSyncHandler @Inject constructor( // Generic handling, just save in base handleGenericAccountData(realm, event.type, event.content) when (event.type) { - UserAccountDataTypes.TYPE_DIRECT_MESSAGES -> handleDirectChatRooms(realm, event) - UserAccountDataTypes.TYPE_PUSH_RULES -> handlePushRules(realm, event) + UserAccountDataTypes.TYPE_DIRECT_MESSAGES -> handleDirectChatRooms(realm, event) + UserAccountDataTypes.TYPE_PUSH_RULES -> handlePushRules(realm, event) UserAccountDataTypes.TYPE_IGNORED_USER_LIST -> handleIgnoredUsers(realm, event) - UserAccountDataTypes.TYPE_BREADCRUMBS -> handleBreadcrumbs(realm, event) + UserAccountDataTypes.TYPE_BREADCRUMBS -> handleBreadcrumbs(realm, event) } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt index cb4e1db46e..8fef229f97 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/handler/room/RoomSyncHandler.kt @@ -140,7 +140,7 @@ internal class RoomSyncHandler @Inject constructor( } val syncLocalTimeStampMillis = clock.epochMillis() val rooms = when (handlingStrategy) { - is HandlingStrategy.JOINED -> { + is HandlingStrategy.JOINED -> { if (isInitialSync && initialSyncStrategy is InitialSyncStrategy.Optimized) { insertJoinRoomsFromInitSync(realm, handlingStrategy, syncLocalTimeStampMillis, aggregator, reporter) // Rooms are already inserted, return an empty list @@ -156,7 +156,7 @@ internal class RoomSyncHandler @Inject constructor( handleInvitedRoom(realm, it.key, it.value, insertType, syncLocalTimeStampMillis) } - is HandlingStrategy.LEFT -> { + is HandlingStrategy.LEFT -> { handlingStrategy.data.mapWithProgress(reporter, InitSyncStep.ImportingAccountLeftRooms, 0.3f) { handleLeftRoom(realm, it.key, it.value, insertType, syncLocalTimeStampMillis) } @@ -573,12 +573,12 @@ internal class RoomSyncHandler @Inject constructor( readReceiptHandler.handle(realm, roomId, readReceiptContent, isInitialSync, aggregator) } } - EventType.TYPING -> { + EventType.TYPING -> { event.content.toModel()?.let { typingEventContent -> result = result.copy(typingUserIds = typingEventContent.typingUserIds) } } - else -> Timber.w("Ephemeral event type '${event.type}' not yet supported") + else -> Timber.w("Ephemeral event type '${event.type}' not yet supported") } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt index 2d8cdc4e7f..24a60a80da 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/sync/job/SyncThread.kt @@ -180,8 +180,8 @@ internal class SyncThread @Inject constructor( val afterPause = state.let { it is SyncState.Running && it.afterPause } val timeout = when { previousSyncResponseHasToDevice -> 0L /* Force timeout to 0 */ - afterPause -> 0L /* No timeout after a pause */ - else -> DEFAULT_LONG_POOL_TIMEOUT + afterPause -> 0L /* No timeout after a pause */ + else -> DEFAULT_LONG_POOL_TIMEOUT } Timber.tag(loggerTag.value).d("Execute sync request with timeout $timeout") val presence = lightweightSettingsStorage.getSyncPresenceStatus() diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt index 7075a56803..b687f5833a 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/terms/DefaultTermsService.kt @@ -132,7 +132,7 @@ internal class DefaultTermsService @Inject constructor( private fun buildUrl(baseUrl: String, serviceType: TermsService.ServiceType): String { val servicePath = when (serviceType) { TermsService.ServiceType.IntegrationManager -> NetworkConstants.URI_INTEGRATION_MANAGER_PATH - TermsService.ServiceType.IdentityService -> NetworkConstants.URI_IDENTITY_PATH_V2 + TermsService.ServiceType.IdentityService -> NetworkConstants.URI_IDENTITY_PATH_V2 } return "${baseUrl.ensureTrailingSlash()}$servicePath" } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt index 57574a96fa..5e685bd546 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/task/TaskExecutor.kt @@ -57,11 +57,11 @@ internal class TaskExecutor @Inject constructor(private val coroutineDispatchers fun cancelAll() = executorScope.coroutineContext.cancelChildren() private fun TaskThread.toDispatcher() = when (this) { - TaskThread.MAIN -> coroutineDispatchers.main + TaskThread.MAIN -> coroutineDispatchers.main TaskThread.COMPUTATION -> coroutineDispatchers.computation - TaskThread.IO -> coroutineDispatchers.io - TaskThread.CALLER -> EmptyCoroutineContext - TaskThread.CRYPTO -> coroutineDispatchers.crypto - TaskThread.DM_VERIF -> coroutineDispatchers.dmVerif + TaskThread.IO -> coroutineDispatchers.io + TaskThread.CALLER -> EmptyCoroutineContext + TaskThread.CRYPTO -> coroutineDispatchers.crypto + TaskThread.DM_VERIF -> coroutineDispatchers.dmVerif } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/Glob.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/Glob.kt index 60f9609586..a4aae80348 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/Glob.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/Glob.kt @@ -27,9 +27,9 @@ internal fun String.simpleGlobToRegExp(): String { // append("^") string.forEach { char -> when (char) { - '*' -> append(".*") - '?' -> append(".") - '.' -> append("\\.") + '*' -> append(".*") + '?' -> append(".") + '.' -> append("\\.") '\\' -> append("\\\\") else -> append(char) } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt index c50b7fe675..6e6007f491 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/JsonCanonicalizer.kt @@ -58,7 +58,7 @@ internal object JsonCanonicalizer { */ private fun canonicalizeRecursive(any: Any): String { when (any) { - is JSONArray -> { + is JSONArray -> { // Canonicalize each element of the array return (0 until any.length()).joinToString(separator = ",", prefix = "[", postfix = "]") { canonicalizeRecursive(any.get(it)) @@ -88,8 +88,8 @@ internal object JsonCanonicalizer { append("}") } } - is String -> return JSONObject.quote(any) - else -> return any.toString() + is String -> return JSONObject.quote(any) + else -> return any.toString() } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/UrlUtils.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/UrlUtils.kt index fbbec1a100..cbaec586d0 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/UrlUtils.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/util/UrlUtils.kt @@ -32,9 +32,9 @@ internal fun String.isValidUrl(): Boolean { */ internal fun String.ensureProtocol(): String { return when { - isEmpty() -> this + isEmpty() -> this !startsWith("http") -> "https://$this" - else -> this + else -> this } } @@ -43,8 +43,8 @@ internal fun String.ensureProtocol(): String { */ internal fun String.ensureTrailingSlash(): String { return when { - isEmpty() -> this + isEmpty() -> this !endsWith("/") -> "$this/" - else -> this + else -> this } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt index 31549155d3..003bdab9cb 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt @@ -101,25 +101,25 @@ internal class DefaultGetWellknownTask @Inject constructor( } } catch (throwable: Throwable) { when (throwable) { - is UnrecognizedCertificateException -> { + is UnrecognizedCertificateException -> { throw Failure.UnrecognizedCertificateFailure( "https://$domain", throwable.fingerprint ) } - is Failure.NetworkConnection -> { + is Failure.NetworkConnection -> { WellknownResult.Ignore } - is Failure.OtherServerError -> { + is Failure.OtherServerError -> { when (throwable.httpCode) { HttpsURLConnection.HTTP_NOT_FOUND -> WellknownResult.Ignore - else -> WellknownResult.FailPrompt(null, null) + else -> WellknownResult.FailPrompt(null, null) } } is MalformedJsonException, is EOFException -> { WellknownResult.FailPrompt(null, null) } - else -> { + else -> { throw throwable } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt index 497825b450..01c8a595d3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/worker/MatrixWorkerFactory.kt @@ -48,25 +48,25 @@ internal class MatrixWorkerFactory @Inject constructor(private val sessionManage ): ListenableWorker? { Timber.d("MatrixWorkerFactory.createWorker for $workerClassName") return when (workerClassName) { - CheckFactoryWorker::class.java.name -> + CheckFactoryWorker::class.java.name -> CheckFactoryWorker(appContext, workerParameters, true) - AddPusherWorker::class.java.name -> + AddPusherWorker::class.java.name -> AddPusherWorker(appContext, workerParameters, sessionManager) - GetGroupDataWorker::class.java.name -> + GetGroupDataWorker::class.java.name -> GetGroupDataWorker(appContext, workerParameters, sessionManager) MultipleEventSendingDispatcherWorker::class.java.name -> MultipleEventSendingDispatcherWorker(appContext, workerParameters, sessionManager) - RedactEventWorker::class.java.name -> + RedactEventWorker::class.java.name -> RedactEventWorker(appContext, workerParameters, sessionManager) - SendEventWorker::class.java.name -> + SendEventWorker::class.java.name -> SendEventWorker(appContext, workerParameters, sessionManager) - SyncWorker::class.java.name -> + SyncWorker::class.java.name -> SyncWorker(appContext, workerParameters, sessionManager) - UpdateTrustWorker::class.java.name -> + UpdateTrustWorker::class.java.name -> UpdateTrustWorker(appContext, workerParameters, sessionManager) - UploadContentWorker::class.java.name -> + UploadContentWorker::class.java.name -> UploadContentWorker(appContext, workerParameters, sessionManager) - else -> { + else -> { Timber.w("No worker defined on MatrixWorkerFactory for $workerClassName will delegate to default.") // Return null to delegate to the default WorkerFactory. null diff --git a/vector/src/androidTest/java/im/vector/app/EspressoExt.kt b/vector/src/androidTest/java/im/vector/app/EspressoExt.kt index efb28cdff5..2456d7a3f5 100644 --- a/vector/src/androidTest/java/im/vector/app/EspressoExt.kt +++ b/vector/src/androidTest/java/im/vector/app/EspressoExt.kt @@ -202,7 +202,7 @@ fun activityIdlingResource(activityClass: Class<*>): IdlingResource { println("*** [$name] onActivityLifecycleChanged callback: $callback") callback?.onTransitionToIdle() } - else -> { + else -> { // do nothing, we're blocking until the activity resumes } } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt index fb80e292c2..35027843d6 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/ElementRobot.kt @@ -141,7 +141,7 @@ class ElementRobot { // I hereby cheat and write: Thread.sleep(30_000) } - else -> { + else -> { } } } diff --git a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt index 1625b4580d..050e5ab5c0 100644 --- a/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt +++ b/vector/src/androidTest/java/im/vector/app/ui/robot/OnboardingServersRobot.kt @@ -83,7 +83,7 @@ class OnboardingServersRobot { private fun assetMatrixSignInOptions(isSignUp: Boolean) { waitUntilViewVisible(ViewMatchers.withId(R.id.loginTitle)) when (isSignUp) { - true -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Sign up to matrix.org") + true -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Sign up to matrix.org") false -> BaristaVisibilityAssertions.assertDisplayed(R.id.loginTitle, "Connect to matrix.org") } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt b/vector/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt index 02c0aa82af..8665081102 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt @@ -56,7 +56,7 @@ abstract class BooleanFeatureItem : VectorEpoxyModel( onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { when (position) { - 0 -> listener?.onBooleanOptionSelected(option = null, feature) + 0 -> listener?.onBooleanOptionSelected(option = null, feature) else -> listener?.onBooleanOptionSelected(options[position].fromEmoji(), feature) } } @@ -80,7 +80,7 @@ abstract class BooleanFeatureItem : VectorEpoxyModel( private fun Boolean.toEmoji() = if (this) "✅" else "❌" private fun String.fromEmoji() = when (this) { - "✅" -> true - "❌" -> false + "✅" -> true + "❌" -> false else -> error("unexpected input $this") } diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt b/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt index d5b2ec1080..a06147c4f8 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt @@ -52,7 +52,7 @@ abstract class EnumFeatureItem : VectorEpoxyModel() { onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { when (position) { - 0 -> listener?.onEnumOptionSelected(option = null, feature) + 0 -> listener?.onEnumOptionSelected(option = null, feature) else -> feature.onOptionSelected(position - 1) } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt index dfe412117f..59949c6c7b 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt @@ -68,10 +68,10 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor( override fun handle(action: DebugPrivateSettingsViewActions) { when (action) { - is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action) + is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action) is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action) - is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action) - is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action) + is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action) + is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action) } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt index b8f89eaf88..7f510ee5e9 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt @@ -57,7 +57,7 @@ class OverrideDropdownView @JvmOverloads constructor( onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { when (position) { - 0 -> listener.onOverrideSelected(option = null) + 0 -> listener.onOverrideSelected(option = null) else -> listener.onOverrideSelected(feature.options[position - 1]) } } diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt b/vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt index 316e8fb901..5ed0693ef2 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt @@ -20,8 +20,8 @@ sealed interface BooleanHomeserverCapabilitiesOverride : OverrideOption { companion object { fun from(value: Boolean?) = when (value) { - null -> null - true -> ForceEnabled + null -> null + true -> ForceEnabled false -> ForceDisabled } } @@ -36,7 +36,7 @@ sealed interface BooleanHomeserverCapabilitiesOverride : OverrideOption { } fun BooleanHomeserverCapabilitiesOverride?.toBoolean() = when (this) { - null -> null + null -> null BooleanHomeserverCapabilitiesOverride.ForceDisabled -> false - BooleanHomeserverCapabilitiesOverride.ForceEnabled -> true + BooleanHomeserverCapabilitiesOverride.ForceEnabled -> true } diff --git a/vector/src/debug/java/im/vector/app/receivers/DebugReceiver.kt b/vector/src/debug/java/im/vector/app/receivers/DebugReceiver.kt index 0cea9e3d8e..9ec475d6d3 100644 --- a/vector/src/debug/java/im/vector/app/receivers/DebugReceiver.kt +++ b/vector/src/debug/java/im/vector/app/receivers/DebugReceiver.kt @@ -36,8 +36,8 @@ class DebugReceiver : BroadcastReceiver() { intent.action?.let { when { - it.endsWith(DEBUG_ACTION_DUMP_FILESYSTEM) -> lsFiles(context) - it.endsWith(DEBUG_ACTION_DUMP_PREFERENCES) -> dumpPreferences(context) + it.endsWith(DEBUG_ACTION_DUMP_FILESYSTEM) -> lsFiles(context) + it.endsWith(DEBUG_ACTION_DUMP_PREFERENCES) -> dumpPreferences(context) it.endsWith(DEBUG_ACTION_ALTER_SCALAR_TOKEN) -> alterScalarToken(context) } } diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt b/vector/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt index a9b822e37e..5bb52be6e6 100644 --- a/vector/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt +++ b/vector/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt @@ -34,7 +34,7 @@ object BackgroundSyncStarter { if (vectorPreferences.areNotificationEnabledForDevice()) { val activeSession = activeSessionHolder.getSafeActiveSession() ?: return when (vectorPreferences.getFdroidSyncBackgroundMode()) { - BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_BATTERY -> { + BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_FOR_BATTERY -> { // we rely on periodic worker Timber.i("## Sync: Work scheduled to periodically sync in ${vectorPreferences.backgroundSyncDelay()}s") activeSession.startAutomaticBackgroundSync( @@ -52,7 +52,7 @@ object BackgroundSyncStarter { ) Timber.i("## Sync: Alarm scheduled to start syncing") } - BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_DISABLED -> { + BackgroundSyncMode.FDROID_BACKGROUND_SYNC_MODE_DISABLED -> { // we do nothing Timber.i("## Sync: background sync is disabled") } diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt b/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt index 746301018b..ebd8d07540 100644 --- a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt +++ b/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt @@ -38,7 +38,7 @@ class TestBackgroundRestrictions @Inject constructor( if (isActiveNetworkMetered) { // Checks user’s Data Saver settings. when (ConnectivityManagerCompat.getRestrictBackgroundStatus(this)) { - ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_ENABLED -> { + ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_ENABLED -> { // Background data usage is blocked for this app. Wherever possible, // the app should also use less data in the foreground. description = stringProvider.getString( @@ -58,7 +58,7 @@ class TestBackgroundRestrictions @Inject constructor( status = TestStatus.SUCCESS quickFix = null } - ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_DISABLED -> { + ConnectivityManagerCompat.RESTRICT_BACKGROUND_STATUS_DISABLED -> { // Data Saver is disabled. Since the device is connected to a // metered network, the app should use less data wherever possible. description = stringProvider.getString( diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt index 26350a6f67..5a9dc90ec4 100644 --- a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt +++ b/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt @@ -43,13 +43,13 @@ class TestFirebaseToken @Inject constructor( if (!task.isSuccessful) { // Can't find where this constant is (not documented -or deprecated in docs- and all obfuscated) description = when (val errorMsg = task.exception?.localizedMessage ?: "Unknown") { - "SERVICE_NOT_AVAILABLE" -> { + "SERVICE_NOT_AVAILABLE" -> { stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_service_not_available, errorMsg) } "TOO_MANY_REGISTRATIONS" -> { stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_too_many_registration, errorMsg) } - "ACCOUNT_MISSING" -> { + "ACCOUNT_MISSING" -> { quickFix = object : TroubleshootQuickFix(R.string.settings_troubleshoot_test_fcm_failed_account_missing_quick_fix) { override fun doFix() { startAddGoogleAccountIntent(context, activityResultLauncher) @@ -57,7 +57,7 @@ class TestFirebaseToken @Inject constructor( } stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed_account_missing, errorMsg) } - else -> { + else -> { stringProvider.getString(R.string.settings_troubleshoot_test_fcm_failed, errorMsg) } } diff --git a/vector/src/main/java/im/vector/app/AppStateHandler.kt b/vector/src/main/java/im/vector/app/AppStateHandler.kt index 1608d561bc..46c94f3604 100644 --- a/vector/src/main/java/im/vector/app/AppStateHandler.kt +++ b/vector/src/main/java/im/vector/app/AppStateHandler.kt @@ -167,7 +167,7 @@ class AppStateHandler @Inject constructor( coroutineScope.coroutineContext.cancelChildren() val session = activeSessionHolder.getSafeActiveSession() ?: return when (val currentMethod = selectedSpaceDataSource.currentValue?.orNull() ?: RoomGroupingMethod.BySpace(null)) { - is RoomGroupingMethod.BySpace -> { + is RoomGroupingMethod.BySpace -> { uiStateRepository.storeGroupingMethod(true, session.sessionId) uiStateRepository.storeSelectedSpace(currentMethod.spaceSummary?.roomId, session.sessionId) } diff --git a/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt b/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt index b3bd671583..780a3ab705 100644 --- a/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt +++ b/vector/src/main/java/im/vector/app/core/date/VectorDateFormatter.kt @@ -66,20 +66,20 @@ class VectorDateFormatter @Inject constructor( val localDateTime = DateProvider.toLocalDateTime(ts) return when (dateFormatKind) { DateFormatKind.DEFAULT_DATE_AND_TIME -> formatDateAndTime(ts) - DateFormatKind.ROOM_LIST -> formatTimeOrDate( + DateFormatKind.ROOM_LIST -> formatTimeOrDate( date = localDateTime, showTimeIfSameDay = true, abbrev = true, useRelative = true ) - DateFormatKind.TIMELINE_DAY_DIVIDER -> formatTimeOrDate( + DateFormatKind.TIMELINE_DAY_DIVIDER -> formatTimeOrDate( date = localDateTime, alwaysShowYear = true ) - DateFormatKind.MESSAGE_DETAIL -> formatFullDate(localDateTime) - DateFormatKind.MESSAGE_SIMPLE -> formatHour(localDateTime) - DateFormatKind.EDIT_HISTORY_ROW -> formatHour(localDateTime) - DateFormatKind.EDIT_HISTORY_HEADER -> formatTimeOrDate( + DateFormatKind.MESSAGE_DETAIL -> formatFullDate(localDateTime) + DateFormatKind.MESSAGE_SIMPLE -> formatHour(localDateTime) + DateFormatKind.EDIT_HISTORY_ROW -> formatHour(localDateTime) + DateFormatKind.EDIT_HISTORY_HEADER -> formatTimeOrDate( date = localDateTime, abbrev = true, useRelative = true diff --git a/vector/src/main/java/im/vector/app/core/dialogs/ExportKeysDialog.kt b/vector/src/main/java/im/vector/app/core/dialogs/ExportKeysDialog.kt index 024d283c4c..d0de7e6a3f 100644 --- a/vector/src/main/java/im/vector/app/core/dialogs/ExportKeysDialog.kt +++ b/vector/src/main/java/im/vector/app/core/dialogs/ExportKeysDialog.kt @@ -35,7 +35,7 @@ class ExportKeysDialog { val textWatcher = object : SimpleTextWatcher() { override fun afterTextChanged(s: Editable) { when { - views.exportDialogEt.text.isNullOrEmpty() -> { + views.exportDialogEt.text.isNullOrEmpty() -> { views.exportDialogSubmit.isEnabled = false views.exportDialogTilConfirm.error = null } @@ -43,7 +43,7 @@ class ExportKeysDialog { views.exportDialogSubmit.isEnabled = true views.exportDialogTilConfirm.error = null } - else -> { + else -> { views.exportDialogSubmit.isEnabled = false views.exportDialogTilConfirm.error = activity.getString(R.string.passphrase_passphrase_does_not_match) } diff --git a/vector/src/main/java/im/vector/app/core/dialogs/GalleryOrCameraDialogHelper.kt b/vector/src/main/java/im/vector/app/core/dialogs/GalleryOrCameraDialogHelper.kt index a9e223709a..c2af05123b 100644 --- a/vector/src/main/java/im/vector/app/core/dialogs/GalleryOrCameraDialogHelper.kt +++ b/vector/src/main/java/im/vector/app/core/dialogs/GalleryOrCameraDialogHelper.kt @@ -123,7 +123,7 @@ class GalleryOrCameraDialogHelper( private fun onAvatarTypeSelected(type: Type) { when (type) { - Type.Camera -> + Type.Camera -> if (checkPermissions(PERMISSIONS_FOR_TAKING_PHOTO, activity, takePhotoPermissionActivityResultLauncher)) { doOpenCamera() } diff --git a/vector/src/main/java/im/vector/app/core/dialogs/PhotoOrVideoDialog.kt b/vector/src/main/java/im/vector/app/core/dialogs/PhotoOrVideoDialog.kt index 73c936a599..9effa4c489 100644 --- a/vector/src/main/java/im/vector/app/core/dialogs/PhotoOrVideoDialog.kt +++ b/vector/src/main/java/im/vector/app/core/dialogs/PhotoOrVideoDialog.kt @@ -42,7 +42,7 @@ class PhotoOrVideoDialog( VectorPreferences.TAKE_PHOTO_VIDEO_MODE_PHOTO -> listener.takePhoto() VectorPreferences.TAKE_PHOTO_VIDEO_MODE_VIDEO -> listener.takeVideo() /* VectorPreferences.TAKE_PHOTO_VIDEO_MODE_ALWAYS_ASK */ - else -> { + else -> { val dialogLayout = activity.layoutInflater.inflate(R.layout.dialog_photo_or_video, null) val views = DialogPhotoOrVideoBinding.bind(dialogLayout) @@ -113,7 +113,7 @@ class PhotoOrVideoDialog( when { views.dialogPhotoOrVideoPhoto.isChecked -> VectorPreferences.TAKE_PHOTO_VIDEO_MODE_PHOTO views.dialogPhotoOrVideoVideo.isChecked -> VectorPreferences.TAKE_PHOTO_VIDEO_MODE_VIDEO - else -> VectorPreferences.TAKE_PHOTO_VIDEO_MODE_ALWAYS_ASK + else -> VectorPreferences.TAKE_PHOTO_VIDEO_MODE_ALWAYS_ASK } ) } diff --git a/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt b/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt index a6f80a256e..8fbd89a6c1 100644 --- a/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt +++ b/vector/src/main/java/im/vector/app/core/error/ErrorFormatter.kt @@ -42,102 +42,102 @@ class DefaultErrorFormatter @Inject constructor( override fun toHumanReadable(throwable: Throwable?): String { return when (throwable) { - null -> null - is IdentityServiceError -> identityServerError(throwable) - is Failure.NetworkConnection -> { + null -> null + is IdentityServiceError -> identityServerError(throwable) + is Failure.NetworkConnection -> { when (throwable.ioException) { - is SocketTimeoutException -> + is SocketTimeoutException -> stringProvider.getString(R.string.error_network_timeout) is SSLPeerUnverifiedException -> stringProvider.getString(R.string.login_error_ssl_peer_unverified) - is SSLException -> + is SSLException -> stringProvider.getString(R.string.login_error_ssl_other) - else -> + else -> // TODO Check network state, airplane mode, etc. stringProvider.getString(R.string.error_no_network) } } - is Failure.ServerError -> { + is Failure.ServerError -> { when { - throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN -> { + throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN -> { // Special case for terms and conditions stringProvider.getString(R.string.error_terms_not_accepted) } - throwable.isInvalidPassword() -> { + throwable.isInvalidPassword() -> { stringProvider.getString(R.string.auth_invalid_login_param) } - throwable.error.code == MatrixError.M_USER_IN_USE -> { + throwable.error.code == MatrixError.M_USER_IN_USE -> { stringProvider.getString(R.string.login_signup_error_user_in_use) } - throwable.error.code == MatrixError.M_BAD_JSON -> { + throwable.error.code == MatrixError.M_BAD_JSON -> { stringProvider.getString(R.string.login_error_bad_json) } - throwable.error.code == MatrixError.M_NOT_JSON -> { + throwable.error.code == MatrixError.M_NOT_JSON -> { stringProvider.getString(R.string.login_error_not_json) } - throwable.error.code == MatrixError.M_THREEPID_DENIED -> { + throwable.error.code == MatrixError.M_THREEPID_DENIED -> { stringProvider.getString(R.string.login_error_threepid_denied) } - throwable.isLimitExceededError() -> { + throwable.isLimitExceededError() -> { limitExceededError(throwable.error) } - throwable.error.code == MatrixError.M_TOO_LARGE -> { + throwable.error.code == MatrixError.M_TOO_LARGE -> { stringProvider.getString(R.string.error_file_too_big_simple) } - throwable.error.code == MatrixError.M_THREEPID_NOT_FOUND -> { + throwable.error.code == MatrixError.M_THREEPID_NOT_FOUND -> { stringProvider.getString(R.string.login_reset_password_error_not_found) } - throwable.error.code == MatrixError.M_USER_DEACTIVATED -> { + throwable.error.code == MatrixError.M_USER_DEACTIVATED -> { stringProvider.getString(R.string.auth_invalid_login_deactivated_account) } throwable.error.code == MatrixError.M_THREEPID_IN_USE && - throwable.error.message == "Email is already in use" -> { + throwable.error.message == "Email is already in use" -> { stringProvider.getString(R.string.account_email_already_used_error) } throwable.error.code == MatrixError.M_THREEPID_IN_USE && - throwable.error.message == "MSISDN is already in use" -> { + throwable.error.message == "MSISDN is already in use" -> { stringProvider.getString(R.string.account_phone_number_already_used_error) } - throwable.error.code == MatrixError.M_THREEPID_AUTH_FAILED -> { + throwable.error.code == MatrixError.M_THREEPID_AUTH_FAILED -> { stringProvider.getString(R.string.error_threepid_auth_failed) } throwable.error.code == MatrixError.M_UNKNOWN && throwable.error.message == "Not allowed to join this room" -> { stringProvider.getString(R.string.room_error_access_unauthorized) } - else -> { + else -> { throwable.error.message.takeIf { it.isNotEmpty() } ?: throwable.error.code.takeIf { it.isNotEmpty() } } } } - is Failure.OtherServerError -> { + is Failure.OtherServerError -> { when (throwable.httpCode) { - HttpURLConnection.HTTP_NOT_FOUND -> + HttpURLConnection.HTTP_NOT_FOUND -> // homeserver not found stringProvider.getString(R.string.login_error_no_homeserver_found) HttpURLConnection.HTTP_UNAUTHORIZED -> // uia errors? stringProvider.getString(R.string.error_unauthorized) - else -> + else -> throwable.localizedMessage } } is DialPadLookup.Failure.NumberIsYours -> stringProvider.getString(R.string.cannot_call_yourself) - is DialPadLookup.Failure.NoResult -> + is DialPadLookup.Failure.NoResult -> stringProvider.getString(R.string.call_dial_pad_lookup_error) - is MatrixIdFailure.InvalidMatrixId -> + is MatrixIdFailure.InvalidMatrixId -> stringProvider.getString(R.string.login_signin_matrix_id_error_invalid_matrix_id) - is VoiceFailure -> voiceMessageError(throwable) - else -> throwable.localizedMessage + is VoiceFailure -> voiceMessageError(throwable) + else -> throwable.localizedMessage } ?: stringProvider.getString(R.string.unknown_error) } private fun voiceMessageError(throwable: VoiceFailure): String { return when (throwable) { - is VoiceFailure.UnableToPlay -> stringProvider.getString(R.string.error_voice_message_unable_to_play) + is VoiceFailure.UnableToPlay -> stringProvider.getString(R.string.error_voice_message_unable_to_play) is VoiceFailure.UnableToRecord -> stringProvider.getString(R.string.error_voice_message_unable_to_record) } } @@ -157,14 +157,14 @@ class DefaultErrorFormatter @Inject constructor( private fun identityServerError(identityServiceError: IdentityServiceError): String { return stringProvider.getString( when (identityServiceError) { - IdentityServiceError.OutdatedIdentityServer -> R.string.identity_server_error_outdated_identity_server - IdentityServiceError.OutdatedHomeServer -> R.string.identity_server_error_outdated_home_server - IdentityServiceError.NoIdentityServerConfigured -> R.string.identity_server_error_no_identity_server_configured - IdentityServiceError.TermsNotSignedException -> R.string.identity_server_error_terms_not_signed + IdentityServiceError.OutdatedIdentityServer -> R.string.identity_server_error_outdated_identity_server + IdentityServiceError.OutdatedHomeServer -> R.string.identity_server_error_outdated_home_server + IdentityServiceError.NoIdentityServerConfigured -> R.string.identity_server_error_no_identity_server_configured + IdentityServiceError.TermsNotSignedException -> R.string.identity_server_error_terms_not_signed IdentityServiceError.BulkLookupSha256NotSupported -> R.string.identity_server_error_bulk_sha256_not_supported - IdentityServiceError.BindingError -> R.string.identity_server_error_binding_error - IdentityServiceError.NoCurrentBindingError -> R.string.identity_server_error_no_current_binding_error - IdentityServiceError.UserConsentNotProvided -> R.string.identity_server_user_consent_not_provided + IdentityServiceError.BindingError -> R.string.identity_server_error_binding_error + IdentityServiceError.NoCurrentBindingError -> R.string.identity_server_error_no_current_binding_error + IdentityServiceError.UserConsentNotProvided -> R.string.identity_server_user_consent_not_provided } ) } diff --git a/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt b/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt index 205a0f40c4..c5009bd072 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/TextInputLayout.kt @@ -53,7 +53,7 @@ fun TextInputLayout.setOnImeDoneListener(action: () -> Unit) { action() true } - else -> false + else -> false } } } diff --git a/vector/src/main/java/im/vector/app/core/extensions/ThreePid.kt b/vector/src/main/java/im/vector/app/core/extensions/ThreePid.kt index 2e451cfc1e..ea86b39e89 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/ThreePid.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/ThreePid.kt @@ -23,7 +23,7 @@ import org.matrix.android.sdk.api.session.identity.ThreePid fun ThreePid.getFormattedValue(): String { return when (this) { - is ThreePid.Email -> email + is ThreePid.Email -> email is ThreePid.Msisdn -> { tryOrNull(message = "Unable to parse the phone number") { PhoneNumberUtil.getInstance().parse(msisdn.ensurePrefix("+"), null) diff --git a/vector/src/main/java/im/vector/app/core/extensions/ViewPager2.kt b/vector/src/main/java/im/vector/app/core/extensions/ViewPager2.kt index ff3f02e55c..7d3a678af1 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/ViewPager2.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/ViewPager2.kt @@ -40,7 +40,7 @@ fun ViewPager2.setCurrentItem( kotlin.runCatching { when { isRtl -> fakeDragBy(currentPxToDrag) - else -> fakeDragBy(-currentPxToDrag) + else -> fakeDragBy(-currentPxToDrag) } previousValue = currentValue }.onFailure { animator.cancel() } diff --git a/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt b/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt index c833f39063..8af2a19dd4 100644 --- a/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt +++ b/vector/src/main/java/im/vector/app/core/linkify/VectorLinkify.kt @@ -121,7 +121,7 @@ object VectorLinkify { remove = if (a.important) i + 1 else i } else { when { - b.end <= a.end -> + b.end <= a.end -> // b is inside a -> b should be removed remove = i + 1 a.end - a.start > b.end - b.start -> diff --git a/vector/src/main/java/im/vector/app/core/platform/LifecycleAwareLazy.kt b/vector/src/main/java/im/vector/app/core/platform/LifecycleAwareLazy.kt index 54add00459..c4d2a8511a 100644 --- a/vector/src/main/java/im/vector/app/core/platform/LifecycleAwareLazy.kt +++ b/vector/src/main/java/im/vector/app/core/platform/LifecycleAwareLazy.kt @@ -64,7 +64,7 @@ class LifecycleAwareLazy( private fun getLifecycleOwner() = when (owner) { is Fragment -> owner.viewLifecycleOwner - else -> owner + else -> owner } override fun isInitialized(): Boolean = _value !== UninitializedValue diff --git a/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt b/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt index 4b62090d3f..37a0352dc6 100644 --- a/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt +++ b/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt @@ -31,7 +31,7 @@ class ScreenOrientationLocker @Inject constructor( @SuppressLint("SourceLockedOrientationActivity") fun lockPhonesToPortrait(activity: AppCompatActivity) { when (resources.getBoolean(R.bool.is_tablet)) { - true -> { + true -> { // do nothing } false -> { diff --git a/vector/src/main/java/im/vector/app/core/platform/StateView.kt b/vector/src/main/java/im/vector/app/core/platform/StateView.kt index a70bf54aa1..6f36787d0c 100755 --- a/vector/src/main/java/im/vector/app/core/platform/StateView.kt +++ b/vector/src/main/java/im/vector/app/core/platform/StateView.kt @@ -78,7 +78,7 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? when (newState) { is State.Content -> Unit is State.Loading -> Unit - is State.Empty -> { + is State.Empty -> { views.emptyImageView.setImageDrawable(newState.image) views.emptyView.updateConstraintSet { it.constrainPercentHeight(R.id.emptyImageView, if (newState.isBigImage) 0.5f else 0.1f) @@ -86,7 +86,7 @@ class StateView @JvmOverloads constructor(context: Context, attrs: AttributeSet? views.emptyMessageView.text = newState.message views.emptyTitleView.text = newState.title } - is State.Error -> { + is State.Error -> { views.errorMessageView.text = newState.message } } diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index 0c6708af33..571d2d38c0 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -346,7 +346,7 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver // FIXME I cannot use this anymore :/ // finishActivity(PinActivity.PIN_REQUEST_CODE) } - else -> { + else -> { if (pinLocker.getLiveState().value != PinLocker.State.UNLOCKED) { // Remove the task, to be sure that PIN code will be requested when resumed finishAndRemoveTask() diff --git a/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt b/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt index 6101f8a597..8ec9012367 100644 --- a/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt +++ b/vector/src/main/java/im/vector/app/core/preference/KeywordPreference.kt @@ -133,13 +133,13 @@ class KeywordPreference : VectorPreference { keyword.startsWith(".") -> { context.getString(R.string.settings_notification_keyword_contains_dot) } - keyword.contains("\\") -> { + keyword.contains("\\") -> { context.getString(R.string.settings_notification_keyword_contains_invalid_character, "\\") } - keyword.contains("/") -> { + keyword.contains("/") -> { context.getString(R.string.settings_notification_keyword_contains_invalid_character, "/") } - else -> null + else -> null } chipTextInputLayout.isErrorEnabled = errorMessage != null diff --git a/vector/src/main/java/im/vector/app/core/preference/PushRulePreference.kt b/vector/src/main/java/im/vector/app/core/preference/PushRulePreference.kt index bea29195c9..c0ff80a0e7 100644 --- a/vector/src/main/java/im/vector/app/core/preference/PushRulePreference.kt +++ b/vector/src/main/java/im/vector/app/core/preference/PushRulePreference.kt @@ -58,8 +58,8 @@ class PushRulePreference : VectorPreference { private fun refreshSummary() { summary = context.getString( when (index) { - NotificationIndex.OFF -> R.string.notification_off - NotificationIndex.SILENT -> R.string.notification_silent + NotificationIndex.OFF -> R.string.notification_off + NotificationIndex.SILENT -> R.string.notification_silent NotificationIndex.NOISY, null -> R.string.notification_noisy } ) @@ -76,27 +76,27 @@ class PushRulePreference : VectorPreference { radioGroup?.setOnCheckedChangeListener(null) when (index) { - NotificationIndex.OFF -> { + NotificationIndex.OFF -> { radioGroup?.check(R.id.bingPreferenceRadioBingRuleOff) } NotificationIndex.SILENT -> { radioGroup?.check(R.id.bingPreferenceRadioBingRuleSilent) } - NotificationIndex.NOISY -> { + NotificationIndex.NOISY -> { radioGroup?.check(R.id.bingPreferenceRadioBingRuleNoisy) } - null -> Unit + null -> Unit } radioGroup?.setOnCheckedChangeListener { _, checkedId -> when (checkedId) { - R.id.bingPreferenceRadioBingRuleOff -> { + R.id.bingPreferenceRadioBingRuleOff -> { onPreferenceChangeListener?.onPreferenceChange(this, NotificationIndex.OFF) } R.id.bingPreferenceRadioBingRuleSilent -> { onPreferenceChangeListener?.onPreferenceChange(this, NotificationIndex.SILENT) } - R.id.bingPreferenceRadioBingRuleNoisy -> { + R.id.bingPreferenceRadioBingRuleNoisy -> { onPreferenceChangeListener?.onPreferenceChange(this, NotificationIndex.NOISY) } } diff --git a/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt b/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt index d050890509..829fec1652 100644 --- a/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/services/BluetoothHeadsetReceiver.kt @@ -54,9 +54,9 @@ class BluetoothHeadsetReceiver : BroadcastReceiver() { // STATE_DISCONNECTED}, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTING val headsetConnected = when (intent?.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE, -1)) { - BluetoothAdapter.STATE_CONNECTED -> true + BluetoothAdapter.STATE_CONNECTED -> true BluetoothAdapter.STATE_DISCONNECTED -> false - else -> return // ignore intermediate states + else -> return // ignore intermediate states } val device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE) @@ -74,7 +74,7 @@ class BluetoothHeadsetReceiver : BroadcastReceiver() { ) ) } - else -> return + else -> return } } diff --git a/vector/src/main/java/im/vector/app/core/services/CallService.kt b/vector/src/main/java/im/vector/app/core/services/CallService.kt index b7db7b2542..4edc4d6ace 100644 --- a/vector/src/main/java/im/vector/app/core/services/CallService.kt +++ b/vector/src/main/java/im/vector/app/core/services/CallService.kt @@ -120,15 +120,15 @@ class CallService : VectorService() { callRingPlayerOutgoing?.start() displayOutgoingRingingCallNotification(intent) } - ACTION_ONGOING_CALL -> { + ACTION_ONGOING_CALL -> { callRingPlayerIncoming?.stop() callRingPlayerOutgoing?.stop() displayCallInProgressNotification(intent) } - ACTION_CALL_TERMINATED -> { + ACTION_CALL_TERMINATED -> { handleCallTerminated(intent) } - else -> { + else -> { handleUnexpectedState(null) } } diff --git a/vector/src/main/java/im/vector/app/core/services/WiredHeadsetStateReceiver.kt b/vector/src/main/java/im/vector/app/core/services/WiredHeadsetStateReceiver.kt index 0d3ebafb04..a223352095 100644 --- a/vector/src/main/java/im/vector/app/core/services/WiredHeadsetStateReceiver.kt +++ b/vector/src/main/java/im/vector/app/core/services/WiredHeadsetStateReceiver.kt @@ -48,14 +48,14 @@ class WiredHeadsetStateReceiver : BroadcastReceiver() { // microphone 1 if headset has a microphone, 0 otherwise val isPlugged = when (intent?.getIntExtra("state", -1)) { - 0 -> false - 1 -> true + 0 -> false + 1 -> true else -> return Unit.also { Timber.v("## VOIP WiredHeadsetStateReceiver invalid state") } } val hasMicrophone = when (intent.getIntExtra("microphone", -1)) { - 1 -> true + 1 -> true else -> false } diff --git a/vector/src/main/java/im/vector/app/core/ui/list/ItemStyle.kt b/vector/src/main/java/im/vector/app/core/ui/list/ItemStyle.kt index b98d29040d..63e023ecd7 100644 --- a/vector/src/main/java/im/vector/app/core/ui/list/ItemStyle.kt +++ b/vector/src/main/java/im/vector/app/core/ui/list/ItemStyle.kt @@ -34,10 +34,10 @@ enum class ItemStyle { fun toTextSize(): Float { return when (this) { - BIG_TEXT -> 18f + BIG_TEXT -> 18f NORMAL_TEXT -> 14f - TITLE -> 20f - SUBHEADER -> 16f + TITLE -> 20f + SUBHEADER -> 16f } } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/CompatKonfetti.kt b/vector/src/main/java/im/vector/app/core/ui/views/CompatKonfetti.kt index 6b969fe2a5..4e2daef4e0 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/CompatKonfetti.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/CompatKonfetti.kt @@ -34,7 +34,7 @@ class CompatKonfetti @JvmOverloads constructor( override fun onVisibilityChanged(changedView: View, visibility: Int) { when (Build.VERSION.SDK_INT) { Build.VERSION_CODES.LOLLIPOP, Build.VERSION_CODES.LOLLIPOP_MR1 -> safeOnVisibilityChanged(changedView, visibility) - else -> super.onVisibilityChanged(changedView, visibility) + else -> super.onVisibilityChanged(changedView, visibility) } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/CurrentCallsView.kt b/vector/src/main/java/im/vector/app/core/ui/views/CurrentCallsView.kt index 2f7eecc22c..3f129274c4 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/CurrentCallsView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/CurrentCallsView.kt @@ -58,13 +58,13 @@ class CurrentCallsView @JvmOverloads constructor( is CallState.Idle, is CallState.CreateOffer, is CallState.LocalRinging, - is CallState.Dialing -> { + is CallState.Dialing -> { resources.getString(R.string.call_ringing) } is CallState.Answering -> { resources.getString(R.string.call_connecting) } - else -> { + else -> { resources.getString(R.string.call_one_active, formattedDuration) } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt b/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt index 80603aa3bf..e789585b63 100755 --- a/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/KeysBackupBanner.kt @@ -67,28 +67,28 @@ class KeysBackupBanner @JvmOverloads constructor( hideAll() when (newState) { - State.Initial -> renderInitial() - State.Hidden -> renderHidden() - is State.Setup -> renderSetup(newState.numberOfKeys) + State.Initial -> renderInitial() + State.Hidden -> renderHidden() + is State.Setup -> renderSetup(newState.numberOfKeys) is State.Recover -> renderRecover(newState.version) - is State.Update -> renderUpdate(newState.version) - State.BackingUp -> renderBackingUp() + is State.Update -> renderUpdate(newState.version) + State.BackingUp -> renderBackingUp() } } override fun onClick(v: View?) { when (state) { - is State.Setup -> delegate?.setupKeysBackup() + is State.Setup -> delegate?.setupKeysBackup() is State.Update, is State.Recover -> delegate?.recoverKeysBackup() - else -> Unit + else -> Unit } } private fun onCloseClicked() { state.let { when (it) { - is State.Setup -> { + is State.Setup -> { DefaultSharedPreferences.getInstance(context).edit { putBoolean(BANNER_SETUP_DO_NOT_SHOW_AGAIN, true) } @@ -98,12 +98,12 @@ class KeysBackupBanner @JvmOverloads constructor( putString(BANNER_RECOVER_DO_NOT_SHOW_FOR_VERSION, it.version) } } - is State.Update -> { + is State.Update -> { DefaultSharedPreferences.getInstance(context).edit { putString(BANNER_UPDATE_DO_NOT_SHOW_FOR_VERSION, it.version) } } - else -> { + else -> { // Should not happen, close button is not displayed in other cases } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt b/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt index d9624f65e9..b298a6d4d5 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/NotificationAreaView.kt @@ -69,12 +69,12 @@ class NotificationAreaView @JvmOverloads constructor( cleanUp() state = newState when (newState) { - State.Initial -> Unit - is State.Default -> renderDefault() - is State.Hidden -> renderHidden() - is State.NoPermissionToPost -> renderNoPermissionToPost() - is State.UnsupportedAlgorithm -> renderUnsupportedAlgorithm(newState) - is State.Tombstone -> renderTombstone() + State.Initial -> Unit + is State.Default -> renderDefault() + is State.Hidden -> renderHidden() + is State.NoPermissionToPost -> renderNoPermissionToPost() + is State.UnsupportedAlgorithm -> renderUnsupportedAlgorithm(newState) + is State.Tombstone -> renderTombstone() is State.ResourceLimitExceededError -> renderResourceLimitExceededError(newState) } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/PresenceStateImageView.kt b/vector/src/main/java/im/vector/app/core/ui/views/PresenceStateImageView.kt index 6fd8cba94e..0176901bfb 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/PresenceStateImageView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/PresenceStateImageView.kt @@ -37,7 +37,7 @@ class PresenceStateImageView @JvmOverloads constructor( isVisible = showPresence && userPresence != null when (userPresence?.presence) { - PresenceEnum.ONLINE -> { + PresenceEnum.ONLINE -> { setImageResource(R.drawable.ic_presence_online) contentDescription = context.getString(R.string.a11y_presence_online) } @@ -45,15 +45,15 @@ class PresenceStateImageView @JvmOverloads constructor( setImageResource(R.drawable.ic_presence_away) contentDescription = context.getString(R.string.a11y_presence_unavailable) } - PresenceEnum.OFFLINE -> { + PresenceEnum.OFFLINE -> { setImageResource(R.drawable.ic_presence_offline) contentDescription = context.getString(R.string.a11y_presence_offline) } - PresenceEnum.BUSY -> { + PresenceEnum.BUSY -> { setImageResource(R.drawable.ic_presence_busy) contentDescription = context.getString(R.string.a11y_presence_busy) } - null -> Unit + null -> Unit } } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt b/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt index 8477eddeea..97c1dd32b5 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/ReadReceiptsView.kt @@ -86,19 +86,19 @@ class ReadReceiptsView @JvmOverloads constructor( views.receiptMore.visibility = View.GONE } contentDescription = when (readReceipts.size) { - 1 -> + 1 -> if (displayNames.size == 1) { context.getString(R.string.one_user_read, displayNames[0]) } else { context.resources.getQuantityString(R.plurals.fallback_users_read, readReceipts.size) } - 2 -> + 2 -> if (displayNames.size == 2) { context.getString(R.string.two_users_read, displayNames[0], displayNames[1]) } else { context.resources.getQuantityString(R.plurals.fallback_users_read, readReceipts.size) } - 3 -> + 3 -> if (displayNames.size == 3) { context.getString(R.string.three_users_read, displayNames[0], displayNames[1], displayNames[2]) } else { diff --git a/vector/src/main/java/im/vector/app/core/ui/views/SendStateImageView.kt b/vector/src/main/java/im/vector/app/core/ui/views/SendStateImageView.kt index 3d710e2b24..77b0204783 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/SendStateImageView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/SendStateImageView.kt @@ -45,20 +45,20 @@ class SendStateImageView @JvmOverloads constructor( contentDescription = context.getString(R.string.event_status_a11y_sending) false } - SendStateDecoration.SENT -> { + SendStateDecoration.SENT -> { setImageResource(R.drawable.ic_message_sent) imageTintList = ColorStateList.valueOf(ThemeUtils.getColor(context, R.attr.vctr_content_tertiary)) contentDescription = context.getString(R.string.event_status_a11y_sent) false } - SendStateDecoration.FAILED -> { + SendStateDecoration.FAILED -> { setImageResource(R.drawable.ic_sending_message_failed) imageTintList = null contentDescription = context.getString(R.string.event_status_a11y_failed) false } SendStateDecoration.SENDING_MEDIA, - SendStateDecoration.NONE -> { + SendStateDecoration.NONE -> { true } } diff --git a/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt b/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt index a82a9a30b4..4d947f134b 100644 --- a/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt +++ b/vector/src/main/java/im/vector/app/core/ui/views/ShieldImageView.kt @@ -40,21 +40,21 @@ class ShieldImageView @JvmOverloads constructor( isVisible = roomEncryptionTrustLevel != null when (roomEncryptionTrustLevel) { - RoomEncryptionTrustLevel.Default -> { + RoomEncryptionTrustLevel.Default -> { contentDescription = context.getString(R.string.a11y_trust_level_default) setImageResource( if (borderLess) R.drawable.ic_shield_black_no_border else R.drawable.ic_shield_black ) } - RoomEncryptionTrustLevel.Warning -> { + RoomEncryptionTrustLevel.Warning -> { contentDescription = context.getString(R.string.a11y_trust_level_warning) setImageResource( if (borderLess) R.drawable.ic_shield_warning_no_border else R.drawable.ic_shield_warning ) } - RoomEncryptionTrustLevel.Trusted -> { + RoomEncryptionTrustLevel.Trusted -> { contentDescription = context.getString(R.string.a11y_trust_level_trusted) setImageResource( if (borderLess) R.drawable.ic_shield_trusted_no_border @@ -65,7 +65,7 @@ class ShieldImageView @JvmOverloads constructor( contentDescription = context.getString(R.string.a11y_trust_level_trusted) setImageResource(R.drawable.ic_warning_badge) } - null -> Unit + null -> Unit } } } @@ -73,9 +73,9 @@ class ShieldImageView @JvmOverloads constructor( @DrawableRes fun RoomEncryptionTrustLevel.toDrawableRes(): Int { return when (this) { - RoomEncryptionTrustLevel.Default -> R.drawable.ic_shield_black - RoomEncryptionTrustLevel.Warning -> R.drawable.ic_shield_warning - RoomEncryptionTrustLevel.Trusted -> R.drawable.ic_shield_trusted + RoomEncryptionTrustLevel.Default -> R.drawable.ic_shield_black + RoomEncryptionTrustLevel.Warning -> R.drawable.ic_shield_warning + RoomEncryptionTrustLevel.Trusted -> R.drawable.ic_shield_trusted RoomEncryptionTrustLevel.E2EWithUnsupportedAlgorithm -> R.drawable.ic_warning_badge } } diff --git a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt index bb5f7dcf9c..68fe488391 100644 --- a/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt +++ b/vector/src/main/java/im/vector/app/core/utils/ExternalApplicationsUtil.kt @@ -105,8 +105,8 @@ fun openUrlInChromeCustomTab( .setColorScheme( when { ThemeUtils.isSystemTheme(context) -> CustomTabsIntent.COLOR_SCHEME_SYSTEM - ThemeUtils.isLightTheme(context) -> CustomTabsIntent.COLOR_SCHEME_LIGHT - else -> CustomTabsIntent.COLOR_SCHEME_DARK + ThemeUtils.isLightTheme(context) -> CustomTabsIntent.COLOR_SCHEME_LIGHT + else -> CustomTabsIntent.COLOR_SCHEME_DARK } ) // Note: setting close button icon does not work @@ -278,7 +278,7 @@ suspend fun saveMedia( mediaMimeType?.isMimeTypeImage() == true -> MediaStore.Images.Media.EXTERNAL_CONTENT_URI mediaMimeType?.isMimeTypeVideo() == true -> MediaStore.Video.Media.EXTERNAL_CONTENT_URI mediaMimeType?.isMimeTypeAudio() == true -> MediaStore.Audio.Media.EXTERNAL_CONTENT_URI - else -> MediaStore.Downloads.EXTERNAL_CONTENT_URI + else -> MediaStore.Downloads.EXTERNAL_CONTENT_URI } val uri = context.contentResolver.insert(externalContentUri, values) @@ -326,7 +326,7 @@ private fun saveMediaLegacy( mediaMimeType?.isMimeTypeImage() == true -> Environment.DIRECTORY_PICTURES mediaMimeType?.isMimeTypeVideo() == true -> Environment.DIRECTORY_MOVIES mediaMimeType?.isMimeTypeAudio() == true -> Environment.DIRECTORY_MUSIC - else -> Environment.DIRECTORY_DOWNLOADS + else -> Environment.DIRECTORY_DOWNLOADS } val downloadDir = Environment.getExternalStoragePublicDirectory(dest) try { diff --git a/vector/src/main/java/im/vector/app/core/utils/FirstThrottler.kt b/vector/src/main/java/im/vector/app/core/utils/FirstThrottler.kt index 004f500c4e..99300993fb 100644 --- a/vector/src/main/java/im/vector/app/core/utils/FirstThrottler.kt +++ b/vector/src/main/java/im/vector/app/core/utils/FirstThrottler.kt @@ -30,7 +30,7 @@ class FirstThrottler(private val minimumInterval: Long = 800) { fun waitMillis(): Long { return when (this) { - Yes -> 0 + Yes -> 0 is No -> shouldWaitMillis } } diff --git a/vector/src/main/java/im/vector/app/core/utils/TextUtils.kt b/vector/src/main/java/im/vector/app/core/utils/TextUtils.kt index d2f8c4022b..eb6cf8e554 100644 --- a/vector/src/main/java/im/vector/app/core/utils/TextUtils.kt +++ b/vector/src/main/java/im/vector/app/core/utils/TextUtils.kt @@ -60,10 +60,10 @@ object TextUtils { } else { // First convert the size when { - sizeBytes < 1024 -> sizeBytes - sizeBytes < 1024 * 1024 -> sizeBytes * 1000 / 1024 + sizeBytes < 1024 -> sizeBytes + sizeBytes < 1024 * 1024 -> sizeBytes * 1000 / 1024 sizeBytes < 1024 * 1024 * 1024 -> sizeBytes * 1000 / 1024 * 1000 / 1024 - else -> sizeBytes * 1000 / 1024 * 1000 / 1024 * 1000 / 1024 + else -> sizeBytes * 1000 / 1024 * 1000 / 1024 * 1000 / 1024 } } @@ -91,7 +91,7 @@ object TextUtils { val seconds = getSeconds(duration) val builder = StringBuilder() when { - hours > 0 -> { + hours > 0 -> { appendHours(context, builder, hours) if (minutes > 0) { builder.append(" ") @@ -109,7 +109,7 @@ object TextUtils { appendSeconds(context, builder, seconds) } } - else -> { + else -> { appendSeconds(context, builder, seconds) } } diff --git a/vector/src/main/java/im/vector/app/core/utils/UrlUtils.kt b/vector/src/main/java/im/vector/app/core/utils/UrlUtils.kt index 70cda17ae6..3f0421351e 100644 --- a/vector/src/main/java/im/vector/app/core/utils/UrlUtils.kt +++ b/vector/src/main/java/im/vector/app/core/utils/UrlUtils.kt @@ -32,16 +32,16 @@ fun String.isValidUrl(): Boolean { */ fun String.ensureProtocol(): String { return when { - isEmpty() -> this + isEmpty() -> this !startsWith("http") -> "https://$this" - else -> this + else -> this } } fun String.ensureTrailingSlash(): String { return when { - isEmpty() -> this + isEmpty() -> this !endsWith("/") -> "$this/" - else -> this + else -> this } } diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt index 17bf02dc4f..91004a0be4 100644 --- a/vector/src/main/java/im/vector/app/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt @@ -157,7 +157,7 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity startNextActivityAndFinish() } } - args.clearCredentials -> { + args.clearCredentials -> { lifecycleScope.launch { try { session.signOutService().signOut(!args.isUserLoggedOut) @@ -171,7 +171,7 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity startNextActivityAndFinish() } } - args.clearCache -> { + args.clearCache -> { lifecycleScope.launch { session.clearCache() doLocalCleanup(clearPreferences = false, onboardingStore) @@ -229,15 +229,15 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity navigator.openLogin(this, null) null } - args.isSoftLogout -> { + args.isSoftLogout -> { // The homeserver has invalidated the token, with a soft logout navigator.softLogout(this) null } - args.isUserLoggedOut -> + args.isUserLoggedOut -> // the homeserver has invalidated the token (password changed, device deleted, other security reasons) SignedOutActivity.newIntent(this) - sessionHolder.hasActiveSession() -> + sessionHolder.hasActiveSession() -> // We have a session. // Check it can be opened if (sessionHolder.getActiveSession().isOpenable) { @@ -247,7 +247,7 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity navigator.softLogout(this) null } - else -> { + else -> { // First start, or no active session navigator.openLogin(this, null) null diff --git a/vector/src/main/java/im/vector/app/features/analytics/DecryptionFailureTracker.kt b/vector/src/main/java/im/vector/app/features/analytics/DecryptionFailureTracker.kt index e020ec1cf7..d97c46c3cb 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/DecryptionFailureTracker.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/DecryptionFailureTracker.kt @@ -147,10 +147,10 @@ class DecryptionFailureTracker @Inject constructor( val detailed = "$name | mxc_crypto_error_type" val errorName = when (this) { MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID, - MXCryptoError.ErrorType.KEYS_WITHHELD -> Error.Name.OlmKeysNotSentError - MXCryptoError.ErrorType.OLM -> Error.Name.OlmUnspecifiedError + MXCryptoError.ErrorType.KEYS_WITHHELD -> Error.Name.OlmKeysNotSentError + MXCryptoError.ErrorType.OLM -> Error.Name.OlmUnspecifiedError MXCryptoError.ErrorType.UNKNOWN_MESSAGE_INDEX -> Error.Name.OlmIndexError - else -> Error.Name.UnknownError + else -> Error.Name.UnknownError } return DetailedErrorName(detailed, errorName) } diff --git a/vector/src/main/java/im/vector/app/features/analytics/extensions/JoinedRoomExt.kt b/vector/src/main/java/im/vector/app/features/analytics/extensions/JoinedRoomExt.kt index 27ce3e9a23..45f39da2cd 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/extensions/JoinedRoomExt.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/extensions/JoinedRoomExt.kt @@ -25,11 +25,11 @@ import org.matrix.android.sdk.api.session.room.model.roomdirectory.PublicRoom fun Int?.toAnalyticsRoomSize(): JoinedRoom.RoomSize { return when (this) { null, - 2 -> JoinedRoom.RoomSize.Two - in 3..10 -> JoinedRoom.RoomSize.ThreeToTen - in 11..100 -> JoinedRoom.RoomSize.ElevenToOneHundred + 2 -> JoinedRoom.RoomSize.Two + in 3..10 -> JoinedRoom.RoomSize.ThreeToTen + in 11..100 -> JoinedRoom.RoomSize.ElevenToOneHundred in 101..1000 -> JoinedRoom.RoomSize.OneHundredAndOneToAThousand - else -> JoinedRoom.RoomSize.MoreThanAThousand + else -> JoinedRoom.RoomSize.MoreThanAThousand } } diff --git a/vector/src/main/java/im/vector/app/features/analytics/extensions/PerformanceTimerExt.kt b/vector/src/main/java/im/vector/app/features/analytics/extensions/PerformanceTimerExt.kt index 11b4b670d3..e1054b15be 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/extensions/PerformanceTimerExt.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/extensions/PerformanceTimerExt.kt @@ -34,7 +34,7 @@ fun StatisticEvent.toListOfPerformanceTimer(): List { itemCount = nbOfJoinedRooms ) ) - is StatisticEvent.SyncTreatment -> + is StatisticEvent.SyncTreatment -> if (afterPause) { listOf( PerformanceTimer( diff --git a/vector/src/main/java/im/vector/app/features/analytics/extensions/UserPropertiesExt.kt b/vector/src/main/java/im/vector/app/features/analytics/extensions/UserPropertiesExt.kt index 7fad43783b..e5446f438b 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/extensions/UserPropertiesExt.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/extensions/UserPropertiesExt.kt @@ -22,8 +22,8 @@ import im.vector.app.features.onboarding.FtueUseCase fun FtueUseCase.toTrackingValue(): UserProperties.FtueUseCaseSelection { return when (this) { FtueUseCase.FRIENDS_FAMILY -> UserProperties.FtueUseCaseSelection.PersonalMessaging - FtueUseCase.TEAMS -> UserProperties.FtueUseCaseSelection.WorkMessaging - FtueUseCase.COMMUNITIES -> UserProperties.FtueUseCaseSelection.CommunityMessaging - FtueUseCase.SKIP -> UserProperties.FtueUseCaseSelection.Skip + FtueUseCase.TEAMS -> UserProperties.FtueUseCaseSelection.WorkMessaging + FtueUseCase.COMMUNITIES -> UserProperties.FtueUseCaseSelection.CommunityMessaging + FtueUseCase.SKIP -> UserProperties.FtueUseCaseSelection.Skip } } diff --git a/vector/src/main/java/im/vector/app/features/analytics/extensions/ViewRoomExt.kt b/vector/src/main/java/im/vector/app/features/analytics/extensions/ViewRoomExt.kt index ada936a3b5..b259477ebd 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/extensions/ViewRoomExt.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/extensions/ViewRoomExt.kt @@ -26,7 +26,7 @@ fun RoomSummary?.toAnalyticsViewRoom(trigger: ViewRoom.Trigger?, groupingMethod: val activeSpace = groupingMethod?.let { when (it) { is RoomGroupingMethod.BySpace -> it.spaceSummary?.toActiveSpace() ?: ViewRoom.ActiveSpace.Home - else -> null + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt b/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt index 87f0e8c13b..be847dcb7f 100644 --- a/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt +++ b/vector/src/main/java/im/vector/app/features/analytics/impl/DefaultVectorAnalytics.kt @@ -49,7 +49,7 @@ class DefaultVectorAnalytics @Inject constructor( private val posthog: PostHog? = when { analyticsConfig.isEnabled -> postHogFactory.createPosthog() - else -> { + else -> { Timber.tag(analyticsTag.value).w("Analytics is disabled") null } diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt index c2eb5a29a8..c85c3aa6b5 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt @@ -127,12 +127,12 @@ class AttachmentTypeSelectorView( fun setAttachmentVisibility(type: Type, isVisible: Boolean) { when (type) { - Type.CAMERA -> views.attachmentCameraButton - Type.GALLERY -> views.attachmentGalleryButton - Type.FILE -> views.attachmentFileButton - Type.STICKER -> views.attachmentStickersButton - Type.CONTACT -> views.attachmentContactButton - Type.POLL -> views.attachmentPollButton + Type.CAMERA -> views.attachmentCameraButton + Type.GALLERY -> views.attachmentGalleryButton + Type.FILE -> views.attachmentFileButton + Type.STICKER -> views.attachmentStickersButton + Type.CONTACT -> views.attachmentContactButton + Type.POLL -> views.attachmentPollButton Type.LOCATION -> views.attachmentLocationButton }.let { it.isVisible = isVisible diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentsMapper.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentsMapper.kt index 00ed6dd6cc..1f87064165 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentsMapper.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentsMapper.kt @@ -67,7 +67,7 @@ private fun MultiPickerBaseType.mapType(): ContentAttachmentData.Type { mimeType?.isMimeTypeImage() == true -> ContentAttachmentData.Type.IMAGE mimeType?.isMimeTypeVideo() == true -> ContentAttachmentData.Type.VIDEO mimeType?.isMimeTypeAudio() == true -> ContentAttachmentData.Type.AUDIO - else -> ContentAttachmentData.Type.FILE + else -> ContentAttachmentData.Type.FILE } } @@ -76,8 +76,8 @@ fun MultiPickerBaseType.toContentAttachmentData(): ContentAttachmentData { is MultiPickerImageType -> toContentAttachmentData() is MultiPickerVideoType -> toContentAttachmentData() is MultiPickerAudioType -> toContentAttachmentData(isVoiceMessage = false) - is MultiPickerFileType -> toContentAttachmentData() - else -> throw IllegalStateException("Unknown file type") + is MultiPickerFileType -> toContentAttachmentData() + else -> throw IllegalStateException("Unknown file type") } } @@ -85,7 +85,7 @@ fun MultiPickerBaseMediaType.toContentAttachmentData(): ContentAttachmentData { return when (this) { is MultiPickerImageType -> toContentAttachmentData() is MultiPickerVideoType -> toContentAttachmentData() - else -> throw IllegalStateException("Unknown media type") + else -> throw IllegalStateException("Unknown media type") } } diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt index 729ac10d4b..dfe74fa47e 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewFragment.kt @@ -103,11 +103,11 @@ class AttachmentsPreviewFragment @Inject constructor( handleRemoveAction() true } - R.id.attachmentsPreviewEditAction -> { + R.id.attachmentsPreviewEditAction -> { handleEditAction() true } - else -> { + else -> { super.onOptionsItemSelected(item) } } @@ -152,7 +152,7 @@ class AttachmentsPreviewFragment @Inject constructor( return when { nbVideos == 0 -> resources.getQuantityString(R.plurals.send_images_with_original_size, nbImages) nbImages == 0 -> resources.getQuantityString(R.plurals.send_videos_with_original_size, nbVideos) - else -> getString(R.string.send_images_and_video_with_original_size) + else -> getString(R.string.send_images_and_video_with_original_size) } } diff --git a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt index 81f0994899..89d8ef648e 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/preview/AttachmentsPreviewViewModel.kt @@ -24,9 +24,9 @@ class AttachmentsPreviewViewModel(initialState: AttachmentsPreviewViewState) : override fun handle(action: AttachmentsPreviewAction) { when (action) { - is AttachmentsPreviewAction.SetCurrentAttachment -> handleSetCurrentAttachment(action) + is AttachmentsPreviewAction.SetCurrentAttachment -> handleSetCurrentAttachment(action) is AttachmentsPreviewAction.UpdatePathOfCurrentAttachment -> handleUpdatePathOfCurrentAttachment(action) - AttachmentsPreviewAction.RemoveCurrentAttachment -> handleRemoveCurrentAttachment() + AttachmentsPreviewAction.RemoveCurrentAttachment -> handleRemoveCurrentAttachment() } } diff --git a/vector/src/main/java/im/vector/app/features/auth/PromptFragment.kt b/vector/src/main/java/im/vector/app/features/auth/PromptFragment.kt index bd44a5b9cd..38f098612b 100644 --- a/vector/src/main/java/im/vector/app/features/auth/PromptFragment.kt +++ b/vector/src/main/java/im/vector/app/features/auth/PromptFragment.kt @@ -44,7 +44,7 @@ class PromptFragment : VectorBaseFragment() { private fun onButtonClicked() = withState(viewModel) { state -> when (state.flowType) { - LoginFlowTypes.SSO -> { + LoginFlowTypes.SSO -> { viewModel.handle(ReAuthActions.StartSSOFallback) } LoginFlowTypes.PASSWORD -> { @@ -57,7 +57,7 @@ class PromptFragment : VectorBaseFragment() { viewModel.handle(ReAuthActions.ReAuthWithPass(password)) } } - else -> { + else -> { // not supported } } @@ -65,7 +65,7 @@ class PromptFragment : VectorBaseFragment() { override fun invalidate() = withState(viewModel) { when (it.flowType) { - LoginFlowTypes.SSO -> { + LoginFlowTypes.SSO -> { views.passwordFieldTil.isVisible = false views.reAuthConfirmButton.text = getString(R.string.auth_login_sso) } @@ -73,21 +73,21 @@ class PromptFragment : VectorBaseFragment() { views.passwordFieldTil.isVisible = true views.reAuthConfirmButton.text = getString(R.string._continue) } - else -> { + else -> { // This login flow is not supported, you should use web? } } if (it.lastErrorCode != null) { when (it.flowType) { - LoginFlowTypes.SSO -> { + LoginFlowTypes.SSO -> { views.genericErrorText.isVisible = true views.genericErrorText.text = getString(R.string.authentication_error) } LoginFlowTypes.PASSWORD -> { views.passwordFieldTil.error = getString(R.string.authentication_error) } - else -> { + else -> { // nop } } diff --git a/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt b/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt index 1e9ccd7243..3f0b49e9f1 100644 --- a/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt +++ b/vector/src/main/java/im/vector/app/features/auth/ReAuthActivity.kt @@ -86,10 +86,10 @@ class ReAuthActivity : SimpleFragmentActivity() { sharedViewModel.observeViewEvents { when (it) { - is ReAuthEvents.OpenSsoURl -> { + is ReAuthEvents.OpenSsoURl -> { openInCustomTab(it.url) } - ReAuthEvents.Dismiss -> { + ReAuthEvents.Dismiss -> { setResult(RESULT_CANCELED) finish() } @@ -207,10 +207,10 @@ class ReAuthActivity : SimpleFragmentActivity() { LoginFlowTypes.PASSWORD -> { LoginFlowTypes.PASSWORD } - LoginFlowTypes.SSO -> { + LoginFlowTypes.SSO -> { LoginFlowTypes.SSO } - else -> { + else -> { // TODO, support more auth type? null } diff --git a/vector/src/main/java/im/vector/app/features/auth/ReAuthViewModel.kt b/vector/src/main/java/im/vector/app/features/auth/ReAuthViewModel.kt index 0bd26870e5..c504982666 100644 --- a/vector/src/main/java/im/vector/app/features/auth/ReAuthViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/auth/ReAuthViewModel.kt @@ -42,7 +42,7 @@ class ReAuthViewModel @AssistedInject constructor( override fun handle(action: ReAuthActions) = withState { state -> when (action) { - ReAuthActions.StartSSOFallback -> { + ReAuthActions.StartSSOFallback -> { if (state.flowType == LoginFlowTypes.SSO) { setState { copy(ssoFallbackPageWasShown = true) } val ssoURL = session.getUiaSsoFallbackUrl(initialState.session ?: "") @@ -55,7 +55,7 @@ class ReAuthViewModel @AssistedInject constructor( ReAuthActions.FallBackPageClosed -> { // Should we do something here? } - is ReAuthActions.ReAuthWithPass -> { + is ReAuthActions.ReAuthWithPass -> { val safeForIntentCypher = ByteArrayOutputStream().also { it.use { session.secureStorageService().securelyStoreObject(action.password, initialState.resultKeyStoreAlias, it) diff --git a/vector/src/main/java/im/vector/app/features/autocomplete/member/AutocompleteMemberController.kt b/vector/src/main/java/im/vector/app/features/autocomplete/member/AutocompleteMemberController.kt index 2034cee90a..8552851254 100644 --- a/vector/src/main/java/im/vector/app/features/autocomplete/member/AutocompleteMemberController.kt +++ b/vector/src/main/java/im/vector/app/features/autocomplete/member/AutocompleteMemberController.kt @@ -52,9 +52,9 @@ class AutocompleteMemberController @Inject constructor(private val context: Cont } data.forEach { item -> when (item) { - is AutocompleteMemberItem.Header -> buildHeaderItem(item) + is AutocompleteMemberItem.Header -> buildHeaderItem(item) is AutocompleteMemberItem.RoomMember -> buildRoomMemberItem(item) - is AutocompleteMemberItem.Everyone -> buildEveryoneItem(item) + is AutocompleteMemberItem.Everyone -> buildEveryoneItem(item) } } } diff --git a/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt b/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt index f0158fc4d6..fee8739e4c 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallControlsView.kt @@ -103,17 +103,17 @@ class CallControlsView @JvmOverloads constructor( CallState.Idle, is CallState.Connected, is CallState.Dialing, - is CallState.Answering -> { + is CallState.Answering -> { views.ringingControls.isVisible = false views.connectedControls.isVisible = true views.videoToggleIcon.isVisible = state.isVideoCall views.moreIcon.isVisible = callState is CallState.Connected && callState.iceConnectionState == MxPeerConnectionState.CONNECTED } - is CallState.Ended -> { + is CallState.Ended -> { views.ringingControls.isVisible = false views.connectedControls.isVisible = false } - null -> Unit + null -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt b/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt index 649b7fee3e..1d7815b721 100644 --- a/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/call/CallSoundDeviceChooserBottomSheet.kt @@ -45,7 +45,7 @@ class CallSoundDeviceChooserBottomSheet : VectorBaseBottomSheetDialogFragment { render(it.available, it.current) } - else -> { + else -> { } } } @@ -56,7 +56,7 @@ class CallSoundDeviceChooserBottomSheet : VectorBaseBottomSheetDialogFragment val title = when (device) { is CallAudioManager.Device.WirelessHeadset -> device.name ?: getString(device.titleRes) - else -> getString(device.titleRes) + else -> getString(device.titleRes) } BottomSheetActionItem_().apply { id(device.titleRes) diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt index daafecc643..579a5851c6 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallActivity.kt @@ -267,7 +267,7 @@ class VectorCallActivity : VectorBaseActivity(), CallContro is CallState.Idle, is CallState.CreateOffer, is CallState.LocalRinging, - is CallState.Dialing -> { + is CallState.Dialing -> { views.fullscreenRenderer.isVisible = false views.pipRendererWrapper.isVisible = false views.callInfoGroup.isVisible = true @@ -333,14 +333,14 @@ class VectorCallActivity : VectorBaseActivity(), CallContro toolbar?.setSubtitle(R.string.call_connecting) } } - is CallState.Ended -> { + is CallState.Ended -> { views.fullscreenRenderer.isVisible = false views.pipRendererWrapper.isVisible = false views.callInfoGroup.isVisible = true toolbar?.setSubtitle(R.string.call_ended) configureCallInfo(state) } - else -> { + else -> { views.fullscreenRenderer.isVisible = false views.pipRendererWrapper.isVisible = false views.callInfoGroup.isInvisible = true @@ -380,7 +380,7 @@ class VectorCallActivity : VectorBaseActivity(), CallContro views.callInfoGroup.isVisible = false } } - else -> { + else -> { views.fullscreenRenderer.isVisible = false views.callInfoGroup.isVisible = false } @@ -395,13 +395,13 @@ class VectorCallActivity : VectorBaseActivity(), CallContro startActivity(startIntent) } when (callState.reason) { - EndCallReason.USER_BUSY -> { + EndCallReason.USER_BUSY -> { showEndCallDialog(R.string.call_ended_user_busy_title, R.string.call_ended_user_busy_description) } EndCallReason.INVITE_TIMEOUT -> { showEndCallDialog(R.string.call_ended_invite_timeout_title, R.string.call_error_user_not_responding) } - else -> { + else -> { finish() } } @@ -522,22 +522,22 @@ class VectorCallActivity : VectorBaseActivity(), CallContro private fun handleViewEvents(event: VectorCallViewEvents?) { Timber.tag(loggerTag.value).v("handleViewEvents $event") when (event) { - is VectorCallViewEvents.ConnectionTimeout -> { + is VectorCallViewEvents.ConnectionTimeout -> { onErrorTimoutConnect(event.turn) } - is VectorCallViewEvents.ShowDialPad -> { + is VectorCallViewEvents.ShowDialPad -> { CallDialPadBottomSheet.newInstance(false).apply { callback = dialPadCallback }.show(supportFragmentManager, FRAGMENT_DIAL_PAD_TAG) } - is VectorCallViewEvents.ShowCallTransferScreen -> { + is VectorCallViewEvents.ShowCallTransferScreen -> { val callId = withState(callViewModel) { it.callId } navigator.openCallTransfer(this, callTransferActivityResultLauncher, callId) } - is VectorCallViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure)) + is VectorCallViewEvents.FailToTransfer -> showSnackbar(getString(R.string.call_transfer_failure)) is VectorCallViewEvents.ShowScreenSharingPermissionDialog -> handleShowScreenSharingPermissionDialog() - is VectorCallViewEvents.StopScreenSharingService -> handleStopScreenSharingService() - else -> Unit + is VectorCallViewEvents.StopScreenSharingService -> handleStopScreenSharingService() + else -> Unit } } @@ -546,7 +546,7 @@ class VectorCallActivity : VectorBaseActivity(), CallContro Activity.RESULT_CANCELED -> { callViewModel.handle(VectorCallViewActions.CallTransferSelectionCancelled) } - Activity.RESULT_OK -> { + Activity.RESULT_OK -> { CallTransferActivity.getCallTransferResult(activityResult.data) ?.let { callViewModel.handle(VectorCallViewActions.CallTransferSelectionResult(it)) } } diff --git a/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt b/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt index e2cedbe1b0..f5ae6a8597 100644 --- a/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/call/VectorCallViewModel.kt @@ -264,30 +264,30 @@ class VectorCallViewModel @AssistedInject constructor( override fun handle(action: VectorCallViewActions) = withState { state -> when (action) { - VectorCallViewActions.EndCall -> { + VectorCallViewActions.EndCall -> { call?.endCall() _viewEvents.post(VectorCallViewEvents.StopScreenSharingService) } - VectorCallViewActions.AcceptCall -> { + VectorCallViewActions.AcceptCall -> { setState { copy(callState = Loading()) } call?.acceptIncomingCall() } - VectorCallViewActions.DeclineCall -> { + VectorCallViewActions.DeclineCall -> { setState { copy(callState = Loading()) } call?.endCall() } - VectorCallViewActions.ToggleMute -> { + VectorCallViewActions.ToggleMute -> { val muted = state.isAudioMuted call?.muteCall(!muted) setState { copy(isAudioMuted = !muted) } } - VectorCallViewActions.ToggleVideo -> { + VectorCallViewActions.ToggleVideo -> { if (state.isVideoCall) { val videoEnabled = state.isVideoEnabled call?.enableVideo(!videoEnabled) @@ -297,19 +297,19 @@ class VectorCallViewModel @AssistedInject constructor( } Unit } - VectorCallViewActions.ToggleHoldResume -> { + VectorCallViewActions.ToggleHoldResume -> { val isRemoteOnHold = state.isRemoteOnHold call?.updateRemoteOnHold(!isRemoteOnHold) } - is VectorCallViewActions.ChangeAudioDevice -> { + is VectorCallViewActions.ChangeAudioDevice -> { callManager.audioManager.setAudioDevice(action.device) } - VectorCallViewActions.SwitchSoundDevice -> { + VectorCallViewActions.SwitchSoundDevice -> { _viewEvents.post( VectorCallViewEvents.ShowSoundDeviceChooser(state.availableDevices, state.device) ) } - VectorCallViewActions.HeadSetButtonPressed -> { + VectorCallViewActions.HeadSetButtonPressed -> { if (state.callState.invoke() is CallState.LocalRinging) { // accept call call?.acceptIncomingCall() @@ -320,20 +320,20 @@ class VectorCallViewModel @AssistedInject constructor( } Unit } - VectorCallViewActions.ToggleCamera -> { + VectorCallViewActions.ToggleCamera -> { call?.switchCamera() } - VectorCallViewActions.ToggleHDSD -> { + VectorCallViewActions.ToggleHDSD -> { if (!state.isVideoCall) return@withState call?.setCaptureFormat(if (state.isHD) CaptureFormat.SD else CaptureFormat.HD) } - VectorCallViewActions.OpenDialPad -> { + VectorCallViewActions.OpenDialPad -> { _viewEvents.post(VectorCallViewEvents.ShowDialPad) } - is VectorCallViewActions.SendDtmfDigit -> { + is VectorCallViewActions.SendDtmfDigit -> { call?.sendDtmfDigit(action.digit) } - VectorCallViewActions.InitiateCallTransfer -> { + VectorCallViewActions.InitiateCallTransfer -> { call?.updateRemoteOnHold(true) _viewEvents.post( VectorCallViewEvents.ShowCallTransferScreen @@ -345,17 +345,17 @@ class VectorCallViewModel @AssistedInject constructor( is VectorCallViewActions.CallTransferSelectionResult -> { handleCallTransferSelectionResult(action.callTransferResult) } - VectorCallViewActions.TransferCall -> { + VectorCallViewActions.TransferCall -> { handleCallTransfer() } - is VectorCallViewActions.SwitchCall -> { + is VectorCallViewActions.SwitchCall -> { setState { VectorCallViewState(action.callArgs) } setupCallWithCurrentState() } - is VectorCallViewActions.ToggleScreenSharing -> { + is VectorCallViewActions.ToggleScreenSharing -> { handleToggleScreenSharing(state.isSharingScreen) } - is VectorCallViewActions.StartScreenSharing -> { + is VectorCallViewActions.StartScreenSharing -> { call?.startSharingScreen(action.videoCapturer) proximityManager.stop() setState { @@ -394,7 +394,7 @@ class VectorCallViewModel @AssistedInject constructor( private fun handleCallTransferSelectionResult(result: CallTransferResult) { when (result) { - is CallTransferResult.ConnectWithUserId -> connectWithUserId(result) + is CallTransferResult.ConnectWithUserId -> connectWithUserId(result) is CallTransferResult.ConnectWithPhoneNumber -> connectWithPhoneNumber(result) } } diff --git a/vector/src/main/java/im/vector/app/features/call/audio/API23AudioDeviceDetector.kt b/vector/src/main/java/im/vector/app/features/call/audio/API23AudioDeviceDetector.kt index f4e7687d39..0b82de6cbe 100644 --- a/vector/src/main/java/im/vector/app/features/call/audio/API23AudioDeviceDetector.kt +++ b/vector/src/main/java/im/vector/app/features/call/audio/API23AudioDeviceDetector.kt @@ -33,9 +33,9 @@ internal class API23AudioDeviceDetector( val deviceInfos = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS) for (info in deviceInfos) { when (info.type) { - AudioDeviceInfo.TYPE_BLUETOOTH_SCO -> devices.add(CallAudioManager.Device.WirelessHeadset(info.productName.toString())) - AudioDeviceInfo.TYPE_BUILTIN_EARPIECE -> devices.add(CallAudioManager.Device.Phone) - AudioDeviceInfo.TYPE_BUILTIN_SPEAKER -> devices.add(CallAudioManager.Device.Speaker) + AudioDeviceInfo.TYPE_BLUETOOTH_SCO -> devices.add(CallAudioManager.Device.WirelessHeadset(info.productName.toString())) + AudioDeviceInfo.TYPE_BUILTIN_EARPIECE -> devices.add(CallAudioManager.Device.Phone) + AudioDeviceInfo.TYPE_BUILTIN_SPEAKER -> devices.add(CallAudioManager.Device.Speaker) AudioDeviceInfo.TYPE_WIRED_HEADPHONES, AudioDeviceInfo.TYPE_WIRED_HEADSET, TYPE_USB_HEADSET -> devices.add(CallAudioManager.Device.Headset) } diff --git a/vector/src/main/java/im/vector/app/features/call/audio/DefaultAudioDeviceRouter.kt b/vector/src/main/java/im/vector/app/features/call/audio/DefaultAudioDeviceRouter.kt index 8b1c4ded7c..7251c2d423 100644 --- a/vector/src/main/java/im/vector/app/features/call/audio/DefaultAudioDeviceRouter.kt +++ b/vector/src/main/java/im/vector/app/features/call/audio/DefaultAudioDeviceRouter.kt @@ -96,7 +96,7 @@ class DefaultAudioDeviceRouter( override fun onAudioFocusChange(focusChange: Int) { callAudioManager.runInAudioThread { when (focusChange) { - AudioManager.AUDIOFOCUS_GAIN -> { + AudioManager.AUDIOFOCUS_GAIN -> { Timber.d(" Audio focus gained") if (audioFocusLost) { callAudioManager.resetAudioRoute() diff --git a/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt b/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt index 6474825fa2..08612fe573 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/ConferenceEvent.kt @@ -85,10 +85,10 @@ class ConferenceEventObserver( private fun onBroadcastReceived(intent: Intent) { val event = BroadcastEvent(intent) val conferenceEvent = when (event.type) { - BroadcastEvent.Type.CONFERENCE_JOINED -> ConferenceEvent.Joined(event.data) + BroadcastEvent.Type.CONFERENCE_JOINED -> ConferenceEvent.Joined(event.data) BroadcastEvent.Type.CONFERENCE_TERMINATED -> ConferenceEvent.Terminated(event.data) - BroadcastEvent.Type.CONFERENCE_WILL_JOIN -> ConferenceEvent.WillJoin(event.data) - else -> null + BroadcastEvent.Type.CONFERENCE_WILL_JOIN -> ConferenceEvent.WillJoin(event.data) + else -> null } if (conferenceEvent != null) { onBroadcastEvent(conferenceEvent) diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiActiveConferenceHolder.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiActiveConferenceHolder.kt index 179956612d..cdc89959b7 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiActiveConferenceHolder.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiActiveConferenceHolder.kt @@ -37,9 +37,9 @@ class JitsiActiveConferenceHolder @Inject constructor(context: Context) { private fun onBroadcastEvent(conferenceEvent: ConferenceEvent) { when (conferenceEvent) { - is ConferenceEvent.Joined -> activeConference = conferenceEvent.extractConferenceUrl() + is ConferenceEvent.Joined -> activeConference = conferenceEvent.extractConferenceUrl() is ConferenceEvent.Terminated -> activeConference = null - else -> Unit + else -> Unit } } } diff --git a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt index 0ea380734d..2082cdcfef 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/JitsiCallViewModel.kt @@ -99,7 +99,7 @@ class JitsiCallViewModel @AssistedInject constructor( override fun handle(action: JitsiCallViewActions) { when (action) { - is JitsiCallViewActions.SwitchTo -> handleSwitchTo(action) + is JitsiCallViewActions.SwitchTo -> handleSwitchTo(action) JitsiCallViewActions.OnConferenceLeft -> handleOnConferenceLeft() } } diff --git a/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt b/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt index e7659fb3e6..e2574d973c 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/RemoveJitsiWidgetView.kt @@ -53,7 +53,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership views.removeJitsiSlidingContainer.setOnTouchListener { _, event -> val currentState = state return@setOnTouchListener when (event.action) { - MotionEvent.ACTION_DOWN -> { + MotionEvent.ACTION_DOWN -> { if (currentState == State.Idle) { val initialX = views.removeJitsiSlidingContainer.x - event.rawX updateState(State.Sliding(initialX, 0f, false)) @@ -71,7 +71,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership } true } - MotionEvent.ACTION_MOVE -> { + MotionEvent.ACTION_MOVE -> { if (currentState is State.Sliding) { val translationX = (currentState.initialX + event.rawX).coerceAtLeast(0f) val hasReachedActivationThreshold = translationX >= views.root.width / 4 @@ -79,7 +79,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership } true } - else -> false + else -> false } } renderInternalState(state) @@ -119,12 +119,12 @@ import org.matrix.android.sdk.api.session.room.model.Membership private fun renderInternalState(state: State) { isVisible = state != State.Unmount when (state) { - State.Progress -> { + State.Progress -> { isVisible = true views.updateVisibilities(true) views.updateHangupColors(true) } - State.Idle -> { + State.Idle -> { isVisible = true views.updateVisibilities(false) views.removeJitsiSlidingContainer.translationX = 0f @@ -136,7 +136,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership views.removeJitsiSlidingContainer.translationX = state.translationX views.updateHangupColors(state.hasReachedActivationThreshold) } - else -> Unit + else -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt b/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt index be917c61b2..86136eab15 100644 --- a/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/conference/VectorJitsiActivity.kt @@ -73,11 +73,11 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee jitsiViewModel.observeViewEvents { when (it) { - is JitsiCallViewEvents.JoinConference -> configureJitsiView(it) + is JitsiCallViewEvents.JoinConference -> configureJitsiView(it) is JitsiCallViewEvents.ConfirmSwitchingConference -> handleConfirmSwitching(it) - JitsiCallViewEvents.FailJoiningConference -> handleFailJoining() - JitsiCallViewEvents.Finish -> finish() - JitsiCallViewEvents.LeaveConference -> handleLeaveConference() + JitsiCallViewEvents.FailJoiningConference -> handleFailJoining() + JitsiCallViewEvents.Finish -> finish() + JitsiCallViewEvents.LeaveConference -> handleLeaveConference() } } lifecycle.addObserver(ConferenceEventObserver(this, this::onBroadcastEvent)) @@ -157,12 +157,12 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee private fun renderState(viewState: JitsiCallViewState) { when (viewState.widget) { - is Fail -> finish() + is Fail -> finish() is Success -> { views.jitsiProgressLayout.isVisible = false jitsiMeetView?.isVisible = true } - else -> { + else -> { jitsiMeetView?.isVisible = false views.jitsiProgressLayout.isVisible = true } @@ -222,7 +222,7 @@ class VectorJitsiActivity : VectorBaseActivity(), JitsiMee Timber.v("Broadcast received: $event") when (event) { is ConferenceEvent.Terminated -> onConferenceTerminated(event.data) - else -> Unit + else -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/call/lookup/CallProtocolsChecker.kt b/vector/src/main/java/im/vector/app/features/call/lookup/CallProtocolsChecker.kt index 9f6a24fd25..8173ce1400 100644 --- a/vector/src/main/java/im/vector/app/features/call/lookup/CallProtocolsChecker.kt +++ b/vector/src/main/java/im/vector/app/features/call/lookup/CallProtocolsChecker.kt @@ -93,8 +93,8 @@ class CallProtocolsChecker(private val session: Session) { private fun Map.extractPSTN(): String? { return when { containsKey(PROTOCOL_PSTN_PREFIXED) -> PROTOCOL_PSTN_PREFIXED - containsKey(PROTOCOL_PSTN) -> PROTOCOL_PSTN - else -> null + containsKey(PROTOCOL_PSTN) -> PROTOCOL_PSTN + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt b/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt index 81173568b5..25e0273528 100644 --- a/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt @@ -65,7 +65,7 @@ class CallTransferActivity : VectorBaseActivity() { TabLayoutMediator(views.callTransferTabLayout, views.callTransferViewPager) { tab, position -> when (position) { CallTransferPagerAdapter.USER_LIST_INDEX -> tab.text = getString(R.string.call_transfer_users_tab_title) - CallTransferPagerAdapter.DIAL_PAD_INDEX -> tab.text = getString(R.string.call_dial_pad_title) + CallTransferPagerAdapter.DIAL_PAD_INDEX -> tab.text = getString(R.string.call_dial_pad_title) } }.attach() setupToolbar(views.callTransferToolbar) @@ -81,7 +81,7 @@ class CallTransferActivity : VectorBaseActivity() { val result = CallTransferResult.ConnectWithUserId(views.callTransferConsultCheckBox.isChecked, selectedUser) handleComplete(result) } - CallTransferPagerAdapter.DIAL_PAD_INDEX -> { + CallTransferPagerAdapter.DIAL_PAD_INDEX -> { val phoneNumber = sectionsPagerAdapter.dialPadFragment?.getRawInput() ?: return@debouncedClicks val result = CallTransferResult.ConnectWithPhoneNumber(views.callTransferConsultCheckBox.isChecked, phoneNumber) handleComplete(result) diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt index c776951f93..99c26c5ebe 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/PeerConnectionObserver.kt @@ -37,13 +37,13 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio * Every ICE transport used by the connection is either in use (state "connected" or "completed") * or is closed (state "closed"); in addition, at least one transport is either "connected" or "completed" */ - PeerConnection.PeerConnectionState.CONNECTED -> { + PeerConnection.PeerConnectionState.CONNECTED -> { webRtcCall.mxCall.state = CallState.Connected(MxPeerConnectionState.CONNECTED) } /** * One or more of the ICE transports on the connection is in the "failed" state. */ - PeerConnection.PeerConnectionState.FAILED -> { + PeerConnection.PeerConnectionState.FAILED -> { // This can be temporary, e.g when other ice not yet received... // webRtcCall.mxCall.state = CallState.ERROR webRtcCall.mxCall.state = CallState.Connected(MxPeerConnectionState.FAILED) @@ -58,7 +58,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio * One or more of the ICE transports are currently in the process of establishing a connection; * that is, their RTCIceConnectionState is either "checking" or "connected", and no transports are in the "failed" state */ - PeerConnection.PeerConnectionState.CONNECTING -> { + PeerConnection.PeerConnectionState.CONNECTING -> { webRtcCall.mxCall.state = CallState.Connected(MxPeerConnectionState.CONNECTING) } /** @@ -66,7 +66,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio * This value was in the RTCSignalingState enum (and therefore found by reading the value of the signalingState) * property until the May 13, 2016 draft of the specification. */ - PeerConnection.PeerConnectionState.CLOSED -> { + PeerConnection.PeerConnectionState.CLOSED -> { webRtcCall.mxCall.state = CallState.Connected(MxPeerConnectionState.CLOSED) } /** @@ -76,7 +76,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio PeerConnection.PeerConnectionState.DISCONNECTED -> { webRtcCall.mxCall.state = CallState.Connected(MxPeerConnectionState.DISCONNECTED) } - null -> { + null -> { } } } @@ -101,14 +101,14 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio * the ICE agent is gathering addresses or is waiting to be given remote candidates through * calls to RTCPeerConnection.addIceCandidate() (or both). */ - PeerConnection.IceConnectionState.NEW -> { + PeerConnection.IceConnectionState.NEW -> { } /** * The ICE agent has been given one or more remote candidates and is checking pairs of local and remote candidates * against one another to try to find a compatible match, but has not yet found a pair which will allow * the peer connection to be made. It's possible that gathering of candidates is also still underway. */ - PeerConnection.IceConnectionState.CHECKING -> { + PeerConnection.IceConnectionState.CHECKING -> { } /** @@ -117,7 +117,7 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio * It's possible that gathering is still underway, and it's also possible that the ICE agent is still checking * candidates against one another looking for a better connection to use. */ - PeerConnection.IceConnectionState.CONNECTED -> { + PeerConnection.IceConnectionState.CONNECTED -> { } /** * Checks to ensure that components are still connected failed for at least one component of the RTCPeerConnection. @@ -131,18 +131,18 @@ class PeerConnectionObserver(private val webRtcCall: WebRtcCall) : PeerConnectio * compatible matches for all components of the connection. * It is, however, possible that the ICE agent did find compatible connections for some components. */ - PeerConnection.IceConnectionState.FAILED -> { + PeerConnection.IceConnectionState.FAILED -> { webRtcCall.onRenegotiationNeeded(restartIce = true) } /** * The ICE agent has finished gathering candidates, has checked all pairs against one another, and has found a connection for all components. */ - PeerConnection.IceConnectionState.COMPLETED -> { + PeerConnection.IceConnectionState.COMPLETED -> { } /** * The ICE agent for this RTCPeerConnection has shut down and is no longer handling requests. */ - PeerConnection.IceConnectionState.CLOSED -> { + PeerConnection.IceConnectionState.CLOSED -> { } } } diff --git a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt index b92316c292..79c3930c89 100644 --- a/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt +++ b/vector/src/main/java/im/vector/app/features/call/webrtc/WebRtcCall.kt @@ -381,7 +381,7 @@ class WebRtcCall( localSurfaceRenderers.addIfNeeded(localViewRenderer) remoteSurfaceRenderers.addIfNeeded(remoteViewRenderer) when (mode) { - VectorCallActivity.INCOMING_ACCEPT -> { + VectorCallActivity.INCOMING_ACCEPT -> { internalAcceptIncomingCall() } VectorCallActivity.INCOMING_RINGING -> { @@ -391,7 +391,7 @@ class WebRtcCall( VectorCallActivity.OUTGOING_CREATED -> { setupOutgoingCall() } - else -> { + else -> { // sink existing tracks (configuration change, e.g screen rotation) attachViewRenderersInternal() } diff --git a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt index 17b8087601..1378321026 100644 --- a/vector/src/main/java/im/vector/app/features/command/CommandParser.kt +++ b/vector/src/main/java/im/vector/app/features/command/CommandParser.kt @@ -69,14 +69,14 @@ class CommandParser @Inject constructor() { } when { - Command.PLAIN.matches(slashCommand) -> { + Command.PLAIN.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.SendPlainText(message = message) } else { ParsedCommand.ErrorSyntax(Command.PLAIN) } } - Command.CHANGE_DISPLAY_NAME.matches(slashCommand) -> { + Command.CHANGE_DISPLAY_NAME.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.ChangeDisplayName(displayName = message) } else { @@ -90,7 +90,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.CHANGE_DISPLAY_NAME_FOR_ROOM) } } - Command.ROOM_AVATAR.matches(slashCommand) -> { + Command.ROOM_AVATAR.matches(slashCommand) -> { if (messageParts.size == 2) { val url = messageParts[1] @@ -103,7 +103,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.ROOM_AVATAR) } } - Command.CHANGE_AVATAR_FOR_ROOM.matches(slashCommand) -> { + Command.CHANGE_AVATAR_FOR_ROOM.matches(slashCommand) -> { if (messageParts.size == 2) { val url = messageParts[1] @@ -116,35 +116,35 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.CHANGE_AVATAR_FOR_ROOM) } } - Command.TOPIC.matches(slashCommand) -> { + Command.TOPIC.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.ChangeTopic(topic = message) } else { ParsedCommand.ErrorSyntax(Command.TOPIC) } } - Command.EMOTE.matches(slashCommand) -> { + Command.EMOTE.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.SendEmote(message) } else { ParsedCommand.ErrorSyntax(Command.EMOTE) } } - Command.RAINBOW.matches(slashCommand) -> { + Command.RAINBOW.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.SendRainbow(message) } else { ParsedCommand.ErrorSyntax(Command.RAINBOW) } } - Command.RAINBOW_EMOTE.matches(slashCommand) -> { + Command.RAINBOW_EMOTE.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.SendRainbowEmote(message) } else { ParsedCommand.ErrorSyntax(Command.RAINBOW_EMOTE) } } - Command.JOIN_ROOM.matches(slashCommand) -> { + Command.JOIN_ROOM.matches(slashCommand) -> { if (messageParts.size >= 2) { val roomAlias = messageParts[1] @@ -160,21 +160,21 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.JOIN_ROOM) } } - Command.PART.matches(slashCommand) -> { + Command.PART.matches(slashCommand) -> { when (messageParts.size) { - 1 -> ParsedCommand.PartRoom(null) - 2 -> ParsedCommand.PartRoom(messageParts[1]) + 1 -> ParsedCommand.PartRoom(null) + 2 -> ParsedCommand.PartRoom(messageParts[1]) else -> ParsedCommand.ErrorSyntax(Command.PART) } } - Command.ROOM_NAME.matches(slashCommand) -> { + Command.ROOM_NAME.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.ChangeRoomName(name = message) } else { ParsedCommand.ErrorSyntax(Command.ROOM_NAME) } } - Command.INVITE.matches(slashCommand) -> { + Command.INVITE.matches(slashCommand) -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -185,13 +185,13 @@ class CommandParser @Inject constructor() { trimParts(textMessage, messageParts.take(2)) ) } - userId.isEmail() -> { + userId.isEmail() -> { ParsedCommand.Invite3Pid(ThreePid.Email(userId)) } - userId.isMsisdn() -> { + userId.isMsisdn() -> { ParsedCommand.Invite3Pid(ThreePid.Msisdn(userId)) } - else -> { + else -> { ParsedCommand.ErrorSyntax(Command.INVITE) } } @@ -199,7 +199,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.INVITE) } } - Command.REMOVE_USER.matches(slashCommand) -> { + Command.REMOVE_USER.matches(slashCommand) -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -215,7 +215,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.REMOVE_USER) } } - Command.BAN_USER.matches(slashCommand) -> { + Command.BAN_USER.matches(slashCommand) -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -231,7 +231,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.BAN_USER) } } - Command.UNBAN_USER.matches(slashCommand) -> { + Command.UNBAN_USER.matches(slashCommand) -> { if (messageParts.size >= 2) { val userId = messageParts[1] @@ -247,7 +247,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.UNBAN_USER) } } - Command.IGNORE_USER.matches(slashCommand) -> { + Command.IGNORE_USER.matches(slashCommand) -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -260,7 +260,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.IGNORE_USER) } } - Command.UNIGNORE_USER.matches(slashCommand) -> { + Command.UNIGNORE_USER.matches(slashCommand) -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -273,7 +273,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.UNIGNORE_USER) } } - Command.SET_USER_POWER_LEVEL.matches(slashCommand) -> { + Command.SET_USER_POWER_LEVEL.matches(slashCommand) -> { if (messageParts.size == 3) { val userId = messageParts[1] if (MatrixPatterns.isUserId(userId)) { @@ -293,7 +293,7 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.SET_USER_POWER_LEVEL) } } - Command.RESET_USER_POWER_LEVEL.matches(slashCommand) -> { + Command.RESET_USER_POWER_LEVEL.matches(slashCommand) -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -306,45 +306,45 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.SET_USER_POWER_LEVEL) } } - Command.MARKDOWN.matches(slashCommand) -> { + Command.MARKDOWN.matches(slashCommand) -> { if (messageParts.size == 2) { when { - "on".equals(messageParts[1], true) -> ParsedCommand.SetMarkdown(true) + "on".equals(messageParts[1], true) -> ParsedCommand.SetMarkdown(true) "off".equals(messageParts[1], true) -> ParsedCommand.SetMarkdown(false) - else -> ParsedCommand.ErrorSyntax(Command.MARKDOWN) + else -> ParsedCommand.ErrorSyntax(Command.MARKDOWN) } } else { ParsedCommand.ErrorSyntax(Command.MARKDOWN) } } - Command.CLEAR_SCALAR_TOKEN.matches(slashCommand) -> { + Command.CLEAR_SCALAR_TOKEN.matches(slashCommand) -> { if (messageParts.size == 1) { ParsedCommand.ClearScalarToken } else { ParsedCommand.ErrorSyntax(Command.CLEAR_SCALAR_TOKEN) } } - Command.SPOILER.matches(slashCommand) -> { + Command.SPOILER.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.SendSpoiler(message) } else { ParsedCommand.ErrorSyntax(Command.SPOILER) } } - Command.SHRUG.matches(slashCommand) -> { + Command.SHRUG.matches(slashCommand) -> { ParsedCommand.SendShrug(message) } - Command.LENNY.matches(slashCommand) -> { + Command.LENNY.matches(slashCommand) -> { ParsedCommand.SendLenny(message) } - Command.DISCARD_SESSION.matches(slashCommand) -> { + Command.DISCARD_SESSION.matches(slashCommand) -> { if (messageParts.size == 1) { ParsedCommand.DiscardSession } else { ParsedCommand.ErrorSyntax(Command.DISCARD_SESSION) } } - Command.WHOIS.matches(slashCommand) -> { + Command.WHOIS.matches(slashCommand) -> { if (messageParts.size == 2) { val userId = messageParts[1] @@ -357,13 +357,13 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.WHOIS) } } - Command.CONFETTI.matches(slashCommand) -> { + Command.CONFETTI.matches(slashCommand) -> { ParsedCommand.SendChatEffect(ChatEffect.CONFETTI, message) } - Command.SNOWFALL.matches(slashCommand) -> { + Command.SNOWFALL.matches(slashCommand) -> { ParsedCommand.SendChatEffect(ChatEffect.SNOWFALL, message) } - Command.CREATE_SPACE.matches(slashCommand) -> { + Command.CREATE_SPACE.matches(slashCommand) -> { if (messageParts.size >= 2) { ParsedCommand.CreateSpace( messageParts[1], @@ -373,31 +373,31 @@ class CommandParser @Inject constructor() { ParsedCommand.ErrorSyntax(Command.CREATE_SPACE) } } - Command.ADD_TO_SPACE.matches(slashCommand) -> { + Command.ADD_TO_SPACE.matches(slashCommand) -> { if (messageParts.size == 1) { ParsedCommand.AddToSpace(spaceId = message) } else { ParsedCommand.ErrorSyntax(Command.ADD_TO_SPACE) } } - Command.JOIN_SPACE.matches(slashCommand) -> { + Command.JOIN_SPACE.matches(slashCommand) -> { if (messageParts.size == 1) { ParsedCommand.JoinSpace(spaceIdOrAlias = message) } else { ParsedCommand.ErrorSyntax(Command.JOIN_SPACE) } } - Command.LEAVE_ROOM.matches(slashCommand) -> { + Command.LEAVE_ROOM.matches(slashCommand) -> { ParsedCommand.LeaveRoom(roomId = message) } - Command.UPGRADE_ROOM.matches(slashCommand) -> { + Command.UPGRADE_ROOM.matches(slashCommand) -> { if (message.isNotEmpty()) { ParsedCommand.UpgradeRoom(newVersion = message) } else { ParsedCommand.ErrorSyntax(Command.UPGRADE_ROOM) } } - else -> { + else -> { // Unknown command ParsedCommand.ErrorUnknownSlashCommand(slashCommand) } diff --git a/vector/src/main/java/im/vector/app/features/contactsbook/ContactsBookController.kt b/vector/src/main/java/im/vector/app/features/contactsbook/ContactsBookController.kt index 2530e9c867..6113755159 100644 --- a/vector/src/main/java/im/vector/app/features/contactsbook/ContactsBookController.kt +++ b/vector/src/main/java/im/vector/app/features/contactsbook/ContactsBookController.kt @@ -51,9 +51,9 @@ class ContactsBookController @Inject constructor( val currentState = state ?: return when (val asyncMappedContacts = currentState.mappedContacts) { is Uninitialized -> renderEmptyState(false) - is Loading -> renderLoading() - is Success -> renderSuccess(currentState) - is Fail -> renderFailure(asyncMappedContacts.error) + is Loading -> renderLoading() + is Success -> renderSuccess(currentState) + is Fail -> renderFailure(asyncMappedContacts.error) } } diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt index 25fee28123..6292217b67 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt @@ -79,11 +79,11 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { .stream() .onEach { action -> when (action) { - UserListSharedAction.Close -> finish() - UserListSharedAction.GoBack -> onBackPressed() + UserListSharedAction.Close -> finish() + UserListSharedAction.GoBack -> onBackPressed() is UserListSharedAction.OnMenuItemSelected -> onMenuItemSelected(action) - UserListSharedAction.OpenPhoneBook -> openPhoneBook() - UserListSharedAction.AddByQrCode -> openAddByQrCode() + UserListSharedAction.OpenPhoneBook -> openPhoneBook() + UserListSharedAction.AddByQrCode -> openAddByQrCode() } } .launchIn(lifecycleScope) @@ -107,7 +107,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { Toast.makeText(this, R.string.invalid_qr_code_uri, Toast.LENGTH_SHORT).show() finish() } - CreateDirectRoomViewEvents.DmSelf -> { + CreateDirectRoomViewEvents.DmSelf -> { Toast.makeText(this, R.string.cannot_dm_self, Toast.LENGTH_SHORT).show() finish() } @@ -116,14 +116,14 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { qrViewModel.observeViewEvents { when (it) { - is QrCodeScannerEvents.CodeParsed -> { + is QrCodeScannerEvents.CodeParsed -> { viewModel.handle(CreateDirectRoomAction.QrScannedAction(it.result)) } is QrCodeScannerEvents.ParseFailed -> { Toast.makeText(this, R.string.qr_code_not_scanned, Toast.LENGTH_SHORT).show() finish() } - else -> Unit + else -> Unit } } } @@ -169,8 +169,8 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { when (state) { is Loading -> renderCreationLoading() is Success -> renderCreationSuccess(state()) - is Fail -> renderCreationFailure(state.error) - else -> Unit + is Fail -> renderCreationFailure(state.error) + else -> Unit } } @@ -181,7 +181,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { private fun renderCreationFailure(error: Throwable) { hideWaitingView() when (error) { - is CreateRoomFailure.CreatedWithTimeout -> { + is CreateRoomFailure.CreatedWithTimeout -> { finish() } is CreateRoomFailure.CreatedWithFederationFailure -> { @@ -191,7 +191,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { .setPositiveButton(R.string.ok) { _, _ -> finish() } .show() } - else -> { + else -> { val message = if (error is Failure.ServerError && error.httpCode == HttpURLConnection.HTTP_INTERNAL_ERROR /*500*/) { // This error happen if the invited userId does not exist. getString(R.string.create_room_dm_failure) diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt index a507f0d099..8374f9d513 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomViewModel.kt @@ -60,7 +60,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor( override fun handle(action: CreateDirectRoomAction) { when (action) { is CreateDirectRoomAction.CreateRoomAndInviteSelectedUsers -> onSubmitInvitees(action.selections) - is CreateDirectRoomAction.QrScannedAction -> onCodeParsed(action) + is CreateDirectRoomAction.QrScannedAction -> onCodeParsed(action) } } @@ -115,7 +115,7 @@ class CreateDirectRoomViewModel @AssistedInject constructor( .apply { selections.forEach { when (it) { - is PendingSelection.UserPendingSelection -> invitedUserIds.add(it.user.userId) + is PendingSelection.UserPendingSelection -> invitedUserIds.add(it.user.userId) is PendingSelection.ThreePidPendingSelection -> invite3pids.add(it.threePid) } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/keys/KeysExporter.kt b/vector/src/main/java/im/vector/app/features/crypto/keys/KeysExporter.kt index f5346980cb..4b3a657740 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keys/KeysExporter.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keys/KeysExporter.kt @@ -45,7 +45,7 @@ class KeysExporter @Inject constructor( private fun verifyExportedKeysOutputFileSize(uri: Uri, expectedSize: Long) { val output = context.contentResolver.openFileDescriptor(uri, "r", null) when { - output == null -> throw IllegalStateException("Exported file not found") + output == null -> throw IllegalStateException("Exported file not found") output.statSize != expectedSize -> { throw UnexpectedExportKeysFileSizeException( expectedFileSize = expectedSize, diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt index a32cd7caa7..3089481255 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/restore/KeysBackupRestoreActivity.kt @@ -93,16 +93,16 @@ class KeysBackupRestoreActivity : SimpleFragmentActivity() { KeysBackupRestoreSharedViewModel.NAVIGATE_TO_RECOVER_WITH_KEY -> { addFragmentToBackstack(views.container, KeysBackupRestoreFromKeyFragment::class.java, allowStateLoss = true) } - KeysBackupRestoreSharedViewModel.NAVIGATE_TO_SUCCESS -> { + KeysBackupRestoreSharedViewModel.NAVIGATE_TO_SUCCESS -> { viewModel.keyVersionResult.value?.version?.let { KeysBackupBanner.onRecoverDoneForVersion(this, it) } replaceFragment(views.container, KeysBackupRestoreSuccessFragment::class.java, allowStateLoss = true) } - KeysBackupRestoreSharedViewModel.NAVIGATE_TO_4S -> { + KeysBackupRestoreSharedViewModel.NAVIGATE_TO_4S -> { launch4SActivity() } - KeysBackupRestoreSharedViewModel.NAVIGATE_FAILED_TO_LOAD_4S -> { + KeysBackupRestoreSharedViewModel.NAVIGATE_FAILED_TO_LOAD_4S -> { MaterialAlertDialogBuilder(this) .setTitle(R.string.unknown_error) .setMessage(R.string.error_failed_to_import_keys) diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt index e58746193b..aabd05d913 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupManageActivity.kt @@ -71,7 +71,7 @@ class KeysBackupManageActivity : SimpleFragmentActivity() { // Observe the deletion of keys backup viewModel.onEach(KeysBackupSettingViewState::deleteBackupRequest) { asyncDelete -> when (asyncDelete) { - is Fail -> { + is Fail -> { updateWaitingView(null) MaterialAlertDialogBuilder(this) @@ -84,7 +84,7 @@ class KeysBackupManageActivity : SimpleFragmentActivity() { is Loading -> { updateWaitingView(WaitingViewData(getString(R.string.keys_backup_settings_deleting_backup))) } - else -> { + else -> { updateWaitingView(null) } } @@ -92,7 +92,7 @@ class KeysBackupManageActivity : SimpleFragmentActivity() { viewModel.observeViewEvents { when (it) { - KeysBackupViewEvents.OpenLegacyCreateBackup -> { + KeysBackupViewEvents.OpenLegacyCreateBackup -> { startActivity(KeysBackupSetupActivity.intent(this, false)) } is KeysBackupViewEvents.RequestStore4SSecret -> { diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt index d13b97a9ba..477684df8d 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsRecyclerViewController.kt @@ -57,7 +57,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( val keyVersionResult = data.keysBackupVersion when (keyBackupState) { - KeysBackupState.Unknown -> { + KeysBackupState.Unknown -> { errorWithRetryItem { id("summary") text(host.stringProvider.getString(R.string.keys_backup_unable_to_get_keys_backup_data)) @@ -73,7 +73,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( loadingText(host.stringProvider.getString(R.string.keys_backup_settings_checking_backup_state)) } } - KeysBackupState.Disabled -> { + KeysBackupState.Disabled -> { genericItem { id("summary") title(host.stringProvider.getString(R.string.keys_backup_settings_status_not_setup).toEpoxyCharSequence()) @@ -88,7 +88,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( } KeysBackupState.WrongBackUpVersion, KeysBackupState.NotTrusted, - KeysBackupState.Enabling -> { + KeysBackupState.Enabling -> { genericItem { id("summary") title(host.stringProvider.getString(R.string.keys_backup_settings_status_ko).toEpoxyCharSequence()) @@ -103,7 +103,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( isBackupAlreadySetup = true } - KeysBackupState.ReadyToBackUp -> { + KeysBackupState.ReadyToBackUp -> { genericItem { id("summary") title(host.stringProvider.getString(R.string.keys_backup_settings_status_ok).toEpoxyCharSequence()) @@ -119,7 +119,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( isBackupAlreadySetup = true } KeysBackupState.WillBackUp, - KeysBackupState.BackingUp -> { + KeysBackupState.BackingUp -> { genericItem { id("summary") title(host.stringProvider.getString(R.string.keys_backup_settings_status_ok).toEpoxyCharSequence()) @@ -144,7 +144,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( isBackupAlreadySetup = true } - null -> Unit + null -> Unit } if (isBackupAlreadySetup) { @@ -187,12 +187,12 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( val host = this when (keysVersionTrust) { is Uninitialized -> Unit - is Loading -> { + is Loading -> { loadingItem { id("trust") } } - is Success -> { + is Success -> { keysVersionTrust() .signatures .filterIsInstance() @@ -293,7 +293,7 @@ class KeysBackupSettingsRecyclerViewController @Inject constructor( } } // end for each } - is Fail -> { + is Fail -> { errorWithRetryItem { id("trust") text(host.stringProvider.getString(R.string.keys_backup_unable_to_get_trust_info)) diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsViewModel.kt index f9fd1d1cc1..e7ae7c11f2 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/settings/KeysBackupSettingsViewModel.kt @@ -71,14 +71,14 @@ class KeysBackupSettingsViewModel @AssistedInject constructor( override fun handle(action: KeyBackupSettingsAction) { when (action) { - KeyBackupSettingsAction.Init -> init() - KeyBackupSettingsAction.GetKeyBackupTrust -> getKeysBackupTrust() - KeyBackupSettingsAction.DeleteKeyBackup -> deleteCurrentBackup() - KeyBackupSettingsAction.SetUpKeyBackup -> viewModelScope.launch { + KeyBackupSettingsAction.Init -> init() + KeyBackupSettingsAction.GetKeyBackupTrust -> getKeysBackupTrust() + KeyBackupSettingsAction.DeleteKeyBackup -> deleteCurrentBackup() + KeyBackupSettingsAction.SetUpKeyBackup -> viewModelScope.launch { setUpKeyBackup() } KeyBackupSettingsAction.StoreIn4SReset, - KeyBackupSettingsAction.StoreIn4SFailure -> { + KeyBackupSettingsAction.StoreIn4SFailure -> { pendingBackupCreationInfo = null // nothing to do just stay on fragment } diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt index 0db06209fe..7478adb165 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupActivity.kt @@ -78,15 +78,15 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() { viewModel.navigateEvent.observeEvent(this) { uxStateEvent -> when (uxStateEvent) { - KeysBackupSetupSharedViewModel.NAVIGATE_TO_STEP_2 -> { + KeysBackupSetupSharedViewModel.NAVIGATE_TO_STEP_2 -> { supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE) replaceFragment(views.container, KeysBackupSetupStep2Fragment::class.java) } - KeysBackupSetupSharedViewModel.NAVIGATE_TO_STEP_3 -> { + KeysBackupSetupSharedViewModel.NAVIGATE_TO_STEP_3 -> { supportFragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE) replaceFragment(views.container, KeysBackupSetupStep3Fragment::class.java) } - KeysBackupSetupSharedViewModel.NAVIGATE_FINISH -> { + KeysBackupSetupSharedViewModel.NAVIGATE_FINISH -> { val resultIntent = Intent() viewModel.keysVersion.value?.version?.let { resultIntent.putExtra(KEYS_VERSION, it) @@ -105,7 +105,7 @@ class KeysBackupSetupActivity : SimpleFragmentActivity() { } .show() } - KeysBackupSetupSharedViewModel.NAVIGATE_MANUAL_EXPORT -> { + KeysBackupSetupSharedViewModel.NAVIGATE_MANUAL_EXPORT -> { queryExportKeys(session.myUserId, saveStartForActivityResult) } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupStep2Fragment.kt b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupStep2Fragment.kt index 6ccfa0911c..706076dae0 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupStep2Fragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/keysbackup/setup/KeysBackupSetupStep2Fragment.kt @@ -137,16 +137,16 @@ class KeysBackupSetupStep2Fragment @Inject constructor() : VectorBaseFragment { + viewModel.passphrase.value.isNullOrEmpty() -> { viewModel.passphraseError.value = context?.getString(R.string.passphrase_empty_error_message) } viewModel.passphrase.value != viewModel.confirmPassphrase.value -> { viewModel.confirmPassphraseError.value = context?.getString(R.string.passphrase_passphrase_does_not_match) } - viewModel.passwordStrength.value?.score ?: 0 < 4 -> { + viewModel.passwordStrength.value?.score ?: 0 < 4 -> { viewModel.passphraseError.value = context?.getString(R.string.passphrase_passphrase_too_weak) } - else -> { + else -> { viewModel.megolmBackupCreationInfo = null // Ensure passphrase is hidden during the process @@ -168,7 +168,7 @@ class KeysBackupSetupStep2Fragment @Inject constructor() : VectorBaseFragment { + else -> { // User has entered a passphrase but want to skip this step. viewModel.passphraseError.value = context?.getString(R.string.keys_backup_passphrase_not_empty_error_message) } diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt index ed3e6a146b..b39992256d 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt @@ -81,8 +81,8 @@ class SharedSecureStorageActivity : val fragment = when (state.step) { SharedSecureStorageViewState.Step.EnterPassphrase -> SharedSecuredStoragePassphraseFragment::class - SharedSecureStorageViewState.Step.EnterKey -> SharedSecuredStorageKeyFragment::class - SharedSecureStorageViewState.Step.ResetAll -> SharedSecuredStorageResetAllFragment::class + SharedSecureStorageViewState.Step.EnterKey -> SharedSecuredStorageKeyFragment::class + SharedSecureStorageViewState.Step.ResetAll -> SharedSecuredStorageResetAllFragment::class } showFragment(fragment) @@ -90,10 +90,10 @@ class SharedSecureStorageActivity : private fun observeViewEvents(it: SharedSecureStorageViewEvent?) { when (it) { - is SharedSecureStorageViewEvent.Dismiss -> { + is SharedSecureStorageViewEvent.Dismiss -> { finish() } - is SharedSecureStorageViewEvent.Error -> { + is SharedSecureStorageViewEvent.Error -> { MaterialAlertDialogBuilder(this) .setTitle(getString(R.string.dialog_title_error)) .setMessage(it.message) @@ -105,16 +105,16 @@ class SharedSecureStorageActivity : } .show() } - is SharedSecureStorageViewEvent.ShowModalLoading -> { + is SharedSecureStorageViewEvent.ShowModalLoading -> { showWaitingView() } - is SharedSecureStorageViewEvent.HideModalLoading -> { + is SharedSecureStorageViewEvent.HideModalLoading -> { hideWaitingView() } - is SharedSecureStorageViewEvent.UpdateLoadingState -> { + is SharedSecureStorageViewEvent.UpdateLoadingState -> { updateWaitingView(it.waitingData) } - is SharedSecureStorageViewEvent.FinishSuccess -> { + is SharedSecureStorageViewEvent.FinishSuccess -> { val dataResult = Intent() dataResult.putExtra(EXTRA_DATA_RESULT, it.cypherResult) setResult(RESULT_OK, dataResult) @@ -123,7 +123,7 @@ class SharedSecureStorageActivity : is SharedSecureStorageViewEvent.ShowResetBottomSheet -> { navigator.open4SSetup(this, SetupMode.HARD_RESET) } - else -> Unit + else -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt index 6963f7ab49..88aad3277d 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageViewModel.kt @@ -149,13 +149,13 @@ class SharedSecureStorageViewModel @AssistedInject constructor( override fun handle(action: SharedSecureStorageAction) = withState { when (action) { - is SharedSecureStorageAction.Cancel -> handleCancel() + is SharedSecureStorageAction.Cancel -> handleCancel() is SharedSecureStorageAction.SubmitPassphrase -> handleSubmitPassphrase(action) - SharedSecureStorageAction.UseKey -> handleUseKey() - is SharedSecureStorageAction.SubmitKey -> handleSubmitKey(action) - SharedSecureStorageAction.Back -> handleBack() - SharedSecureStorageAction.ForgotResetAll -> handleResetAll() - SharedSecureStorageAction.DoResetAll -> handleDoResetAll() + SharedSecureStorageAction.UseKey -> handleUseKey() + is SharedSecureStorageAction.SubmitKey -> handleSubmitKey(action) + SharedSecureStorageAction.Back -> handleBack() + SharedSecureStorageAction.ForgotResetAll -> handleResetAll() + SharedSecureStorageAction.DoResetAll -> handleDoResetAll() } } @@ -207,7 +207,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor( ) } } - else -> { + else -> { _viewEvents.post(SharedSecureStorageViewEvent.Dismiss) } } @@ -263,7 +263,7 @@ class SharedSecureStorageViewModel @AssistedInject constructor( private suspend fun performRequest(keyInfo: KeyInfo, keySpec: RawBytesKeySpec, decryptedSecretMap: HashMap) { when (val requestType = initialState.requestType) { - is RequestType.ReadSecrets -> { + is RequestType.ReadSecrets -> { requestType.secretsName.forEach { if (session.accountDataService().getUserAccountDataEvent(it) != null) { val res = session.sharedSecretStorageService().getSecret( diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStorageKeyFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStorageKeyFragment.kt index fd660367ae..5a7aba65a5 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStorageKeyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStorageKeyFragment.kt @@ -77,7 +77,7 @@ class SharedSecuredStorageKeyFragment @Inject constructor() : VectorBaseFragment is SharedSecureStorageViewEvent.KeyInlineError -> { views.ssssKeyEnterTil.error = it.message } - else -> Unit + else -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStoragePassphraseFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStoragePassphraseFragment.kt index 41507f2722..5af5480573 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStoragePassphraseFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecuredStoragePassphraseFragment.kt @@ -86,7 +86,7 @@ class SharedSecuredStoragePassphraseFragment @Inject constructor( is SharedSecureStorageViewEvent.InlineError -> { views.ssssPassphraseEnterTil.error = it.message } - else -> Unit + else -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BackupToQuadSMigrationTask.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BackupToQuadSMigrationTask.kt index e620500d70..28dbe2baa2 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BackupToQuadSMigrationTask.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BackupToQuadSMigrationTask.kt @@ -122,7 +122,7 @@ class BackupToQuadSMigrationTask @Inject constructor( } ) } - params.recoveryKey != null -> { + params.recoveryKey != null -> { reportProgress(params, R.string.bootstrap_progress_generating_ssss_recovery) quadS.generateKey( UUID.randomUUID().toString(), @@ -131,7 +131,7 @@ class BackupToQuadSMigrationTask @Inject constructor( EmptyKeySigner() ) } - else -> { + else -> { return Result.IllegalParams } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapBottomSheet.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapBottomSheet.kt index b8d168cca5..be02737ef8 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapBottomSheet.kt @@ -64,14 +64,14 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment if (activityResult.resultCode == Activity.RESULT_OK) { when (activityResult.data?.extras?.getString(ReAuthActivity.RESULT_FLOW_TYPE)) { - LoginFlowTypes.SSO -> { + LoginFlowTypes.SSO -> { viewModel.handle(BootstrapActions.SsoAuthDone) } LoginFlowTypes.PASSWORD -> { val password = activityResult.data?.extras?.getString(ReAuthActivity.RESULT_VALUE) ?: "" viewModel.handle(BootstrapActions.PasswordAuthDone(password)) } - else -> { + else -> { viewModel.handle(BootstrapActions.ReAuthCancelled) } } @@ -84,11 +84,11 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment when (event) { - is BootstrapViewEvents.Dismiss -> { + is BootstrapViewEvents.Dismiss -> { bottomSheetResult = if (event.success) ResultListener.RESULT_OK else ResultListener.RESULT_CANCEL dismiss() } - is BootstrapViewEvents.ModalError -> { + is BootstrapViewEvents.ModalError -> { MaterialAlertDialogBuilder(requireActivity()) .setTitle(R.string.dialog_title_error) .setMessage(event.error) @@ -153,47 +153,47 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment when (state.step) { - is BootstrapStep.CheckingMigration -> { + is BootstrapStep.CheckingMigration -> { views.bootstrapIcon.isVisible = false views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title) showFragment(BootstrapWaitingFragment::class) } - is BootstrapStep.FirstForm -> { + is BootstrapStep.FirstForm -> { views.bootstrapIcon.isVisible = false views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title) showFragment(BootstrapSetupRecoveryKeyFragment::class) } - is BootstrapStep.SetupPassphrase -> { + is BootstrapStep.SetupPassphrase -> { views.bootstrapIcon.isVisible = true views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp)) views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title) showFragment(BootstrapEnterPassphraseFragment::class) } - is BootstrapStep.ConfirmPassphrase -> { + is BootstrapStep.ConfirmPassphrase -> { views.bootstrapIcon.isVisible = true views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp)) views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title) showFragment(BootstrapConfirmPassphraseFragment::class) } - is BootstrapStep.AccountReAuth -> { + is BootstrapStep.AccountReAuth -> { views.bootstrapIcon.isVisible = true views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_user)) views.bootstrapTitleText.text = getString(R.string.re_authentication_activity_title) showFragment(BootstrapReAuthFragment::class) } - is BootstrapStep.Initializing -> { + is BootstrapStep.Initializing -> { views.bootstrapIcon.isVisible = true views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) views.bootstrapTitleText.text = getString(R.string.bootstrap_loading_title) showFragment(BootstrapWaitingFragment::class) } - is BootstrapStep.SaveRecoveryKey -> { + is BootstrapStep.SaveRecoveryKey -> { views.bootstrapIcon.isVisible = true views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) views.bootstrapTitleText.text = getString(R.string.bottom_sheet_save_your_recovery_key_title) showFragment(BootstrapSaveRecoveryKeyFragment::class) } - is BootstrapStep.DoneSuccess -> { + is BootstrapStep.DoneSuccess -> { views.bootstrapIcon.isVisible = true views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) views.bootstrapTitleText.text = getString(R.string.bootstrap_finish_title) diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt index 7920ab3b96..3c8137d087 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt @@ -92,11 +92,11 @@ class BootstrapConfirmPassphraseFragment @Inject constructor() : } val passphrase = views.ssssPassphraseEnterEdittext.text?.toString() when { - passphrase.isNullOrBlank() -> + passphrase.isNullOrBlank() -> views.ssssPassphraseEnterTil.error = getString(R.string.passphrase_empty_error_message) passphrase != state.passphrase -> views.ssssPassphraseEnterTil.error = getString(R.string.passphrase_passphrase_does_not_match) - else -> { + else -> { view?.hideKeyboard() sharedViewModel.handle(BootstrapActions.DoInitialize(passphrase)) } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSharedViewModel.kt index b67970e61f..53ac3ade65 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSharedViewModel.kt @@ -86,7 +86,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( when (initialState.setupMode) { SetupMode.PASSPHRASE_RESET, SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET, - SetupMode.HARD_RESET -> { + SetupMode.HARD_RESET -> { setState { copy(step = BootstrapStep.FirstForm(keyBackUpExist = false, reset = true)) } @@ -97,7 +97,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( copy(step = BootstrapStep.AccountReAuth()) } } - SetupMode.NORMAL -> { + SetupMode.NORMAL -> { // need to check if user have an existing keybackup setState { copy(step = BootstrapStep.CheckingMigration) @@ -149,14 +149,14 @@ class BootstrapSharedViewModel @AssistedInject constructor( override fun handle(action: BootstrapActions) = withState { state -> when (action) { - is BootstrapActions.GoBack -> queryBack() - BootstrapActions.StartKeyBackupMigration -> { + is BootstrapActions.GoBack -> queryBack() + BootstrapActions.StartKeyBackupMigration -> { handleStartMigratingKeyBackup() } - is BootstrapActions.Start -> { + is BootstrapActions.Start -> { handleStart(action) } - is BootstrapActions.UpdateCandidatePassphrase -> { + is BootstrapActions.UpdateCandidatePassphrase -> { val strength = zxcvbn.measure(action.pass) setState { copy( @@ -165,7 +165,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) } } - is BootstrapActions.GoToConfirmPassphrase -> { + is BootstrapActions.GoToConfirmPassphrase -> { setState { copy( passphrase = action.passphrase, @@ -180,7 +180,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) } } - is BootstrapActions.DoInitialize -> { + is BootstrapActions.DoInitialize -> { if (state.passphrase == state.passphraseRepeat) { startInitializeFlow(state) } else { @@ -191,42 +191,42 @@ class BootstrapSharedViewModel @AssistedInject constructor( } } } - is BootstrapActions.DoInitializeGeneratedKey -> { + is BootstrapActions.DoInitializeGeneratedKey -> { startInitializeFlow(state) } - BootstrapActions.RecoveryKeySaved -> { + BootstrapActions.RecoveryKeySaved -> { _viewEvents.post(BootstrapViewEvents.RecoveryKeySaved) setState { copy(step = BootstrapStep.SaveRecoveryKey(true)) } } - BootstrapActions.Completed -> { + BootstrapActions.Completed -> { _viewEvents.post(BootstrapViewEvents.Dismiss(true)) } - BootstrapActions.GoToCompleted -> { + BootstrapActions.GoToCompleted -> { setState { copy(step = BootstrapStep.DoneSuccess) } } - BootstrapActions.SaveReqQueryStarted -> { + BootstrapActions.SaveReqQueryStarted -> { setState { copy(recoverySaveFileProcess = Loading()) } } - is BootstrapActions.SaveKeyToUri -> { + is BootstrapActions.SaveKeyToUri -> { saveRecoveryKeyToUri(action.os) } - BootstrapActions.SaveReqFailed -> { + BootstrapActions.SaveReqFailed -> { setState { copy(recoverySaveFileProcess = Uninitialized) } } - BootstrapActions.GoToEnterAccountPassword -> { + BootstrapActions.GoToEnterAccountPassword -> { setState { copy(step = BootstrapStep.AccountReAuth()) } } - BootstrapActions.HandleForgotBackupPassphrase -> { + BootstrapActions.HandleForgotBackupPassphrase -> { if (state.step is BootstrapStep.GetBackupSecretPassForMigration) { setState { copy(step = BootstrapStep.GetBackupSecretPassForMigration(true)) @@ -236,16 +236,16 @@ class BootstrapSharedViewModel @AssistedInject constructor( // is BootstrapActions.ReAuth -> { // startInitializeFlow(action.pass) // } - is BootstrapActions.DoMigrateWithPassphrase -> { + is BootstrapActions.DoMigrateWithPassphrase -> { startMigrationFlow(state.step, action.passphrase, null) } - is BootstrapActions.DoMigrateWithRecoveryKey -> { + is BootstrapActions.DoMigrateWithRecoveryKey -> { startMigrationFlow(state.step, null, action.recoveryKey) } - BootstrapActions.SsoAuthDone -> { + BootstrapActions.SsoAuthDone -> { uiaContinuation?.resume(DefaultBaseAuth(session = pendingAuth?.session ?: "")) } - is BootstrapActions.PasswordAuthDone -> { + is BootstrapActions.PasswordAuthDone -> { val decryptedPass = session.secureStorageService() .loadSecureSecret(action.password.fromBase64().inputStream(), ReAuthActivity.DEFAULT_RESULT_KEYSTORE_ALIAS) uiaContinuation?.resume( @@ -256,7 +256,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) ) } - BootstrapActions.ReAuthCancelled -> { + BootstrapActions.ReAuthCancelled -> { setState { copy(step = BootstrapStep.AccountReAuth(stringProvider.getString(R.string.authentication_error))) } @@ -386,7 +386,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( } _viewEvents.post(BootstrapViewEvents.RequestReAuth(flowResponse, errCode)) } - LoginFlowTypes.SSO -> { + LoginFlowTypes.SSO -> { pendingAuth = DefaultBaseAuth(flowResponse.session) uiaContinuation = promise setState { @@ -396,7 +396,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( } _viewEvents.post(BootstrapViewEvents.RequestReAuth(flowResponse, errCode)) } - else -> { + else -> { promise.resumeWithException(UnsupportedOperationException()) } } @@ -418,7 +418,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( is BootstrapResult.SuccessCrossSigningOnly -> { _viewEvents.post(BootstrapViewEvents.Dismiss(true)) } - is BootstrapResult.Success -> { + is BootstrapResult.Success -> { setState { copy( recoveryKeyCreationInfo = bootstrapResult.keyInfo, @@ -429,7 +429,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) } } - is BootstrapResult.InvalidPasswordError -> { + is BootstrapResult.InvalidPasswordError -> { // it's a bad password / auth setState { copy( @@ -437,7 +437,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) } } - is BootstrapResult.Failure -> { + is BootstrapResult.Failure -> { if (bootstrapResult is BootstrapResult.GenericError && bootstrapResult.failure is Failure.OtherServerError && bootstrapResult.failure.httpCode == 401) { @@ -486,7 +486,7 @@ class BootstrapSharedViewModel @AssistedInject constructor( } } } - is BootstrapStep.SetupPassphrase -> { + is BootstrapStep.SetupPassphrase -> { setState { copy( step = BootstrapStep.FirstForm(keyBackUpExist = doesKeyBackupExist), @@ -496,35 +496,35 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) } } - is BootstrapStep.ConfirmPassphrase -> { + is BootstrapStep.ConfirmPassphrase -> { setState { copy( step = BootstrapStep.SetupPassphrase ) } } - is BootstrapStep.AccountReAuth -> { + is BootstrapStep.AccountReAuth -> { _viewEvents.post(BootstrapViewEvents.SkipBootstrap(state.passphrase != null)) } - BootstrapStep.Initializing -> { + BootstrapStep.Initializing -> { // do we let you cancel from here? _viewEvents.post(BootstrapViewEvents.SkipBootstrap(state.passphrase != null)) } is BootstrapStep.SaveRecoveryKey, - BootstrapStep.DoneSuccess -> { + BootstrapStep.DoneSuccess -> { // nop } - BootstrapStep.CheckingMigration -> Unit - is BootstrapStep.FirstForm -> { + BootstrapStep.CheckingMigration -> Unit + is BootstrapStep.FirstForm -> { _viewEvents.post( when (state.setupMode) { SetupMode.CROSS_SIGNING_ONLY, SetupMode.NORMAL -> BootstrapViewEvents.SkipBootstrap() - else -> BootstrapViewEvents.Dismiss(success = false) + else -> BootstrapViewEvents.Dismiss(success = false) } ) } - is BootstrapStep.GetBackupSecretForMigration -> { + is BootstrapStep.GetBackupSecretForMigration -> { setState { copy( step = BootstrapStep.FirstForm(keyBackUpExist = doesKeyBackupExist), @@ -542,10 +542,10 @@ class BootstrapSharedViewModel @AssistedInject constructor( private fun BackupToQuadSMigrationTask.Result.Failure.toHumanReadable(): String { return when (this) { is BackupToQuadSMigrationTask.Result.InvalidRecoverySecret -> stringProvider.getString(R.string.keys_backup_passphrase_error_decrypt) - is BackupToQuadSMigrationTask.Result.ErrorFailure -> errorFormatter.toHumanReadable(throwable) + is BackupToQuadSMigrationTask.Result.ErrorFailure -> errorFormatter.toHumanReadable(throwable) // is BackupToQuadSMigrationTask.Result.NoKeyBackupVersion, // is BackupToQuadSMigrationTask.Result.IllegalParams, - else -> stringProvider.getString(R.string.unexpected_error) + else -> stringProvider.getString(R.string.unexpected_error) } } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapStep.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapStep.kt index a4fa31ad03..ed8f5b92d7 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapStep.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapStep.kt @@ -108,6 +108,6 @@ sealed class BootstrapStep { fun BootstrapStep.GetBackupSecretForMigration.useKey(): Boolean { return when (this) { is BootstrapStep.GetBackupSecretPassForMigration -> useKey - else -> true + else -> true } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt index cc566833d8..e0965e69f9 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt @@ -45,7 +45,7 @@ class BootstrapWaitingFragment @Inject constructor() : // bootstrapLoadingStatusText.isVisible = false // bootstrapDescriptionText.isVisible = false // } - else -> { + else -> { // just show the spinner views.bootstrapLoadingStatusText.isVisible = false views.bootstrapDescriptionText.isVisible = false diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheet.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheet.kt index bf2c62a647..eae868eb26 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheet.kt @@ -93,7 +93,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment dismiss() + is VerificationBottomSheetViewEvents.Dismiss -> dismiss() is VerificationBottomSheetViewEvents.AccessSecretStore -> { secretStartForActivityResult.launch( SharedSecureStorageActivity.newReadIntent( @@ -104,7 +104,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment { + is VerificationBottomSheetViewEvents.ModalError -> { MaterialAlertDialogBuilder(requireContext()) .setTitle(getString(R.string.dialog_title_error)) .setMessage(it.errorMessage) @@ -113,7 +113,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment { + VerificationBottomSheetViewEvents.GoToSettings -> { dismiss() (activity as? VectorBaseActivity<*>)?.let { activity -> activity.navigator.openSettings(activity, VectorSettingsActivity.EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY) @@ -242,7 +242,7 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment { + is VerificationTxState.Verified -> { showFragment( VerificationConclusionFragment::class, VerificationConclusionFragment.Args(true, null, state.isMe) @@ -254,14 +254,14 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment Unit + else -> Unit } return@withState } when (state.qrTransactionState) { - is VerificationTxState.QrScannedByOther -> { + is VerificationTxState.QrScannedByOther -> { showFragment(VerificationQrScannedByOtherFragment::class) return@withState } @@ -276,21 +276,21 @@ class VerificationBottomSheet : VectorBaseBottomSheetDialogFragment { + is VerificationTxState.Verified -> { showFragment( VerificationConclusionFragment::class, VerificationConclusionFragment.Args(true, null, state.isMe) ) return@withState } - is VerificationTxState.Cancelled -> { + is VerificationTxState.Cancelled -> { showFragment( VerificationConclusionFragment::class, VerificationConclusionFragment.Args(false, state.qrTransactionState.cancelCode.value, state.isMe) ) return@withState } - else -> Unit + else -> Unit } // At this point there is no SAS transaction for this request diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt index 26480e6770..f5818ce2f4 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/VerificationBottomSheetViewModel.kt @@ -235,7 +235,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( ?: session.roomService().getExistingDirectRoomWithUser(otherUserId) when (action) { - is VerificationAction.RequestVerificationByDM -> { + is VerificationAction.RequestVerificationByDM -> { if (roomId == null) { val localId = LocalEcho.createLocalEchoId() setState { @@ -286,7 +286,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( } Unit } - is VerificationAction.StartSASVerification -> { + is VerificationAction.StartSASVerification -> { val request = session.cryptoService().verificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId) ?: return@withState val otherDevice = if (request.isIncoming) request.requestInfo?.fromDevice else request.readyInfo?.fromDevice @@ -308,7 +308,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( } Unit } - is VerificationAction.RemoteQrCodeScanned -> { + is VerificationAction.RemoteQrCodeScanned -> { val existingTransaction = session.cryptoService().verificationService() .getExistingTransaction(action.otherUserId, action.transactionId) as? QrCodeVerificationTransaction existingTransaction @@ -322,7 +322,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( existingTransaction ?.otherUserScannedMyQrCode() } - is VerificationAction.OtherUserDidNotScanned -> { + is VerificationAction.OtherUserDidNotScanned -> { val transactionId = state.transactionId ?: return@withState val existingTransaction = session.cryptoService().verificationService() @@ -330,31 +330,31 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( existingTransaction ?.otherUserDidNotScannedMyQrCode() } - is VerificationAction.SASMatchAction -> { + is VerificationAction.SASMatchAction -> { (session.cryptoService().verificationService() .getExistingTransaction(action.otherUserId, action.sasTransactionId) as? SasVerificationTransaction)?.userHasVerifiedShortCode() } - is VerificationAction.SASDoNotMatchAction -> { + is VerificationAction.SASDoNotMatchAction -> { (session.cryptoService().verificationService() .getExistingTransaction(action.otherUserId, action.sasTransactionId) as? SasVerificationTransaction) ?.shortCodeDoesNotMatch() } - is VerificationAction.GotItConclusion -> { + is VerificationAction.GotItConclusion -> { _viewEvents.post(VerificationBottomSheetViewEvents.Dismiss) } - is VerificationAction.SkipVerification -> { + is VerificationAction.SkipVerification -> { _viewEvents.post(VerificationBottomSheetViewEvents.Dismiss) } - is VerificationAction.VerifyFromPassphrase -> { + is VerificationAction.VerifyFromPassphrase -> { setState { copy(verifyingFrom4S = true) } _viewEvents.post(VerificationBottomSheetViewEvents.AccessSecretStore) } - is VerificationAction.GotResultFromSsss -> { + is VerificationAction.GotResultFromSsss -> { handleSecretBackFromSSSS(action) } - VerificationAction.SecuredStorageHasBeenReset -> { + VerificationAction.SecuredStorageHasBeenReset -> { if (session.cryptoService().crossSigningService().allPrivateKeysKnown()) { setState { copy(quadSHasBeenReset = true, verifyingFrom4S = false) @@ -362,7 +362,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( } Unit } - VerificationAction.CancelledFromSsss -> { + VerificationAction.CancelledFromSsss -> { setState { copy(verifyingFrom4S = false) } @@ -482,7 +482,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor( } when (tx) { - is SasVerificationTransaction -> { + is SasVerificationTransaction -> { if (tx.transactionId == (state.pendingRequest.invoke()?.transactionId ?: state.transactionId)) { // A SAS tx has been started following this request setState { diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionController.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionController.kt index 7f6678a73c..7cec57c8af 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionController.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionController.kt @@ -49,7 +49,7 @@ class VerificationConclusionController @Inject constructor( val host = this when (state.conclusionState) { - ConclusionState.SUCCESS -> { + ConclusionState.SUCCESS -> { bottomSheetVerificationNoticeItem { id("notice") notice( @@ -68,7 +68,7 @@ class VerificationConclusionController @Inject constructor( bottomDone() } - ConclusionState.WARNING -> { + ConclusionState.WARNING -> { bottomSheetVerificationNoticeItem { id("notice") notice(host.stringProvider.getString(R.string.verification_conclusion_not_secure).toEpoxyCharSequence()) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionViewModel.kt index 0e56a6857b..aff2d807ac 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/conclusion/VerificationConclusionViewModel.kt @@ -51,7 +51,7 @@ class VerificationConclusionViewModel(initialState: VerificationConclusionViewSt CancelCode.MismatchedKeys -> { VerificationConclusionViewState(ConclusionState.WARNING, args.isMe) } - else -> { + else -> { VerificationConclusionViewState( if (args.isSuccessFull) ConclusionState.SUCCESS else ConclusionState.CANCELLED, args.isMe diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeController.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeController.kt index 9f3e8ff690..98b163f4e3 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeController.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeController.kt @@ -81,13 +81,13 @@ class VerificationEmojiCodeController @Inject constructor( buildActions(state) } - is Fail -> { + is Fail -> { errorWithRetryItem { id("error") text(host.errorFormatter.toHumanReadable(emojiDescription.error)) } } - else -> { + else -> { bottomSheetVerificationWaitingItem { id("waiting") title(host.stringProvider.getString(R.string.please_wait)) @@ -112,13 +112,13 @@ class VerificationEmojiCodeController @Inject constructor( buildActions(state) } - is Fail -> { + is Fail -> { errorWithRetryItem { id("error") text(host.errorFormatter.toHumanReadable(decimalDescription.error)) } } - else -> { + else -> { bottomSheetVerificationWaitingItem { id("waiting") title(host.stringProvider.getString(R.string.please_wait)) diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt index 95dd4263f9..db9a8fed4a 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/emoji/VerificationEmojiCodeViewModel.kt @@ -88,7 +88,7 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor( is VerificationTxState.OnAccepted, is VerificationTxState.SendingKey, is VerificationTxState.KeySent, - is VerificationTxState.OnKeyReceived -> { + is VerificationTxState.OnKeyReceived -> { setState { copy( isWaitingFromOther = false, @@ -118,12 +118,12 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor( is VerificationTxState.SendingMac, is VerificationTxState.MacSent, is VerificationTxState.Verifying, - is VerificationTxState.Verified -> { + is VerificationTxState.Verified -> { setState { copy(isWaitingFromOther = true) } } - is VerificationTxState.Cancelled -> { + is VerificationTxState.Cancelled -> { // The fragment should not be rendered in this state, // it should have been replaced by a conclusion fragment setState { @@ -135,7 +135,7 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor( ) } } - null -> { + null -> { setState { copy( isWaitingFromOther = false, @@ -144,7 +144,7 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor( ) } } - else -> Unit + else -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt index 781677433b..8c675ecf3e 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/request/VerificationRequestController.kt @@ -133,13 +133,13 @@ class VerificationRequestController @Inject constructor( listener { host.listener?.onClickOnVerificationStart() } } } - is Loading -> { + is Loading -> { bottomSheetVerificationWaitingItem { id("waiting") title(host.stringProvider.getString(R.string.verification_request_waiting_for, matrixItem.getBestName())) } } - is Success -> { + is Success -> { if (!pr.invoke().isReady) { if (state.isMe) { bottomSheetVerificationWaitingItem { @@ -154,7 +154,7 @@ class VerificationRequestController @Inject constructor( } } } - is Fail -> Unit + is Fail -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt b/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt index f1f6142fa2..6f661c5164 100644 --- a/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt +++ b/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolActivity.kt @@ -69,7 +69,7 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac viewModel.observeViewEvents { when (it) { - DevToolsViewEvents.Dismiss -> finish() + DevToolsViewEvents.Dismiss -> finish() is DevToolsViewEvents.ShowAlertMessage -> { MaterialAlertDialogBuilder(this) .setMessage(it.message) @@ -86,7 +86,7 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac private fun renderState(it: RoomDevToolViewState) { if (it.displayMode != currentDisplayMode) { when (it.displayMode) { - RoomDevToolViewState.Mode.Root -> { + RoomDevToolViewState.Mode.Root -> { val classJava = RoomDevToolFragment::class.java val tag = classJava.name if (supportFragmentManager.findFragmentByTag(tag) == null) { @@ -95,7 +95,7 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac supportFragmentManager.popBackStack() } } - RoomDevToolViewState.Mode.StateEventDetail -> { + RoomDevToolViewState.Mode.StateEventDetail -> { val frag = JSonViewerFragment.newInstance( jsonString = it.selectedEventJson ?: "", initialOpenDepth = -1, @@ -109,11 +109,11 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac val frag = createFragment(RoomDevToolStateEventListFragment::class.java) navigateTo(frag) } - RoomDevToolViewState.Mode.EditEventContent -> { + RoomDevToolViewState.Mode.EditEventContent -> { val frag = createFragment(RoomDevToolEditFragment::class.java) navigateTo(frag) } - is RoomDevToolViewState.Mode.SendEventForm -> { + is RoomDevToolViewState.Mode.SendEventForm -> { val frag = createFragment(RoomDevToolSendFormFragment::class.java) navigateTo(frag) } @@ -123,9 +123,9 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac } when (it.modalLoading) { - is Loading -> showWaitingView() - is Success -> hideWaitingView() - is Fail -> { + is Loading -> showWaitingView() + is Success -> hideWaitingView() + is Fail -> { hideWaitingView() } Uninitialized -> { @@ -184,7 +184,7 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac state.displayMode is RoomDevToolViewState.Mode.EditEventContent || state.displayMode is RoomDevToolViewState.Mode.SendEventForm } - else -> true + else -> true } it.isVisible = isVisible } @@ -206,22 +206,22 @@ class RoomDevToolActivity : SimpleFragmentActivity(), FragmentManager.OnBackStac private fun updateToolBar(state: RoomDevToolViewState) { val title = when (state.displayMode) { - RoomDevToolViewState.Mode.Root -> { + RoomDevToolViewState.Mode.Root -> { getString(getTitleRes()) } - RoomDevToolViewState.Mode.StateEventList -> { + RoomDevToolViewState.Mode.StateEventList -> { getString(R.string.dev_tools_state_event) } - RoomDevToolViewState.Mode.StateEventDetail -> { + RoomDevToolViewState.Mode.StateEventDetail -> { state.selectedEvent?.type } - RoomDevToolViewState.Mode.EditEventContent -> { + RoomDevToolViewState.Mode.EditEventContent -> { getString(R.string.dev_tools_edit_content) } RoomDevToolViewState.Mode.StateEventListByType -> { state.currentStateType ?: "" } - is RoomDevToolViewState.Mode.SendEventForm -> { + is RoomDevToolViewState.Mode.SendEventForm -> { getString( if (state.displayMode.isState) R.string.dev_tools_send_custom_state_event else R.string.dev_tools_send_custom_event diff --git a/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolViewModel.kt b/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolViewModel.kt index fb78f8581a..4d5fafbccc 100644 --- a/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/devtools/RoomDevToolViewModel.kt @@ -67,7 +67,7 @@ class RoomDevToolViewModel @AssistedInject constructor( override fun handle(action: RoomDevToolAction) { when (action) { - RoomDevToolAction.ExploreRoomState -> { + RoomDevToolAction.ExploreRoomState -> { setState { copy( displayMode = RoomDevToolViewState.Mode.StateEventList, @@ -75,7 +75,7 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - is RoomDevToolAction.ShowStateEvent -> { + is RoomDevToolAction.ShowStateEvent -> { val jsonString = MatrixJsonParser.getMoshi() .adapter(Event::class.java) .toJson(action.event) @@ -88,10 +88,10 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - RoomDevToolAction.OnBackPressed -> { + RoomDevToolAction.OnBackPressed -> { handleBack() } - RoomDevToolAction.MenuEdit -> { + RoomDevToolAction.MenuEdit -> { withState { if (it.displayMode == RoomDevToolViewState.Mode.StateEventDetail) { // we want to edit it @@ -105,7 +105,7 @@ class RoomDevToolViewModel @AssistedInject constructor( } } } - is RoomDevToolAction.ShowStateEventType -> { + is RoomDevToolAction.ShowStateEventType -> { setState { copy( displayMode = RoomDevToolViewState.Mode.StateEventListByType, @@ -113,15 +113,15 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - RoomDevToolAction.MenuItemSend -> { + RoomDevToolAction.MenuItemSend -> { handleMenuItemSend() } - is RoomDevToolAction.UpdateContentText -> { + is RoomDevToolAction.UpdateContentText -> { setState { copy(editedContent = action.contentJson) } } - is RoomDevToolAction.SendCustomEvent -> { + is RoomDevToolAction.SendCustomEvent -> { setState { copy( displayMode = RoomDevToolViewState.Mode.SendEventForm(action.isStateEvent), @@ -129,7 +129,7 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - is RoomDevToolAction.CustomEventTypeChange -> { + is RoomDevToolAction.CustomEventTypeChange -> { setState { copy( sendEventDraft = sendEventDraft?.copy(type = action.type) @@ -143,7 +143,7 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - is RoomDevToolAction.CustomEventContentChange -> { + is RoomDevToolAction.CustomEventContentChange -> { setState { copy( sendEventDraft = sendEventDraft?.copy(content = action.content) @@ -157,7 +157,7 @@ class RoomDevToolViewModel @AssistedInject constructor( when (state.displayMode) { RoomDevToolViewState.Mode.EditEventContent -> editEventContent(state) is RoomDevToolViewState.Mode.SendEventForm -> sendEventContent(state, state.displayMode.isState) - else -> Unit + else -> Unit } } @@ -244,10 +244,10 @@ class RoomDevToolViewModel @AssistedInject constructor( private fun handleBack() = withState { when (it.displayMode) { - RoomDevToolViewState.Mode.Root -> { + RoomDevToolViewState.Mode.Root -> { _viewEvents.post(DevToolsViewEvents.Dismiss) } - RoomDevToolViewState.Mode.StateEventList -> { + RoomDevToolViewState.Mode.StateEventList -> { setState { copy( selectedEvent = null, @@ -256,7 +256,7 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - RoomDevToolViewState.Mode.StateEventDetail -> { + RoomDevToolViewState.Mode.StateEventDetail -> { setState { copy( selectedEvent = null, @@ -265,7 +265,7 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - RoomDevToolViewState.Mode.EditEventContent -> { + RoomDevToolViewState.Mode.EditEventContent -> { setState { copy( displayMode = RoomDevToolViewState.Mode.StateEventDetail @@ -280,7 +280,7 @@ class RoomDevToolViewModel @AssistedInject constructor( ) } } - is RoomDevToolViewState.Mode.SendEventForm -> { + is RoomDevToolViewState.Mode.SendEventForm -> { setState { copy( displayMode = RoomDevToolViewState.Mode.Root diff --git a/vector/src/main/java/im/vector/app/features/devtools/RoomStateListController.kt b/vector/src/main/java/im/vector/app/features/devtools/RoomStateListController.kt index 3f05db8ed5..831091883a 100644 --- a/vector/src/main/java/im/vector/app/features/devtools/RoomStateListController.kt +++ b/vector/src/main/java/im/vector/app/features/devtools/RoomStateListController.kt @@ -37,7 +37,7 @@ class RoomStateListController @Inject constructor( override fun buildModels(data: RoomDevToolViewState?) { val host = this when (data?.displayMode) { - RoomDevToolViewState.Mode.StateEventList -> { + RoomDevToolViewState.Mode.StateEventList -> { val stateEventsGroups = data.stateEvents.invoke().orEmpty().groupBy { it.getClearType() } if (stateEventsGroups.isEmpty()) { @@ -98,7 +98,7 @@ class RoomStateListController @Inject constructor( } } } - else -> { + else -> { // nop } } diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt index e7d74e3d38..cb0e1d3e91 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsController.kt @@ -55,7 +55,7 @@ class DiscoverySettingsController @Inject constructor( id("identityServerLoading") } } - is Fail -> { + is Fail -> { settingsInfoItem { id("identityServerError") helperText(data.identityServer.error.message) @@ -70,7 +70,7 @@ class DiscoverySettingsController @Inject constructor( buildMsisdnSection(data.phoneNumbersList) } } - else -> Unit + else -> Unit } } @@ -216,7 +216,7 @@ class DiscoverySettingsController @Inject constructor( id("emailsLoading") } } - is Fail -> { + is Fail -> { settingsInfoItem { id("emailsError") helperText(emails.error.message) @@ -250,7 +250,7 @@ class DiscoverySettingsController @Inject constructor( message(host.stringProvider.getString(R.string.settings_discovery_confirm_mail, pidInfo.threePid.value)) textColor(host.colorProvider.getColor(R.color.vector_info_color)) } - is Fail -> + is Fail -> settingsInformationItem { id("info${pidInfo.threePid.value}") message(host.stringProvider.getString(R.string.settings_discovery_confirm_mail_not_clicked, pidInfo.threePid.value)) @@ -260,7 +260,7 @@ class DiscoverySettingsController @Inject constructor( } when (pidInfo.finalRequest) { is Uninitialized, - is Fail -> + is Fail -> buildContinueCancel(pidInfo.threePid) is Loading -> settingsProgressItem { @@ -285,7 +285,7 @@ class DiscoverySettingsController @Inject constructor( id("msisdnLoading") } } - is Fail -> { + is Fail -> { settingsInfoItem { id("msisdnListError") helperText(msisdns.error.message) @@ -359,7 +359,7 @@ class DiscoverySettingsController @Inject constructor( is Loading -> { buttonIndeterminate(true) } - is Fail -> { + is Fail -> { buttonType(ButtonType.NORMAL) buttonStyle(ButtonStyle.DESTRUCTIVE) buttonTitle(host.stringProvider.getString(R.string.global_retry)) @@ -368,7 +368,7 @@ class DiscoverySettingsController @Inject constructor( } is Success -> when (pidInfo.isShared()) { SharedState.SHARED, - SharedState.NOT_SHARED -> { + SharedState.NOT_SHARED -> { buttonType(ButtonType.SWITCH) checked(pidInfo.isShared() == SharedState.SHARED) switchChangeListener { _, checked -> @@ -383,13 +383,13 @@ class DiscoverySettingsController @Inject constructor( buttonType(ButtonType.NO_BUTTON) when (pidInfo.finalRequest) { is Incomplete -> iconMode(IconMode.INFO) - is Fail -> iconMode(IconMode.ERROR) - else -> iconMode(IconMode.NONE) + is Fail -> iconMode(IconMode.ERROR) + else -> iconMode(IconMode.NONE) } } - null -> Unit + null -> Unit } - else -> Unit + else -> Unit } } } @@ -409,7 +409,7 @@ class DiscoverySettingsController @Inject constructor( id("bottom${threePid.value}") continueOnClick { when (threePid) { - is ThreePid.Email -> { + is ThreePid.Email -> { host.listener?.checkEmailVerification(threePid) } is ThreePid.Msisdn -> { diff --git a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt index 47151223a4..2a975beb58 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/DiscoverySettingsViewModel.kt @@ -101,17 +101,17 @@ class DiscoverySettingsViewModel @AssistedInject constructor( override fun handle(action: DiscoverySettingsAction) { when (action) { - DiscoverySettingsAction.Refresh -> fetchContent() - DiscoverySettingsAction.RetrieveBinding -> retrieveBinding() - DiscoverySettingsAction.DisconnectIdentityServer -> disconnectIdentityServer() + DiscoverySettingsAction.Refresh -> fetchContent() + DiscoverySettingsAction.RetrieveBinding -> retrieveBinding() + DiscoverySettingsAction.DisconnectIdentityServer -> disconnectIdentityServer() is DiscoverySettingsAction.SetPoliciesExpandState -> updatePolicyUrlsExpandedState(action.expanded) - is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action) - is DiscoverySettingsAction.UpdateUserConsent -> handleUpdateUserConsent(action) - is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action) - is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action) - is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action, true) - is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action) - is DiscoverySettingsAction.CancelBinding -> cancelBinding(action) + is DiscoverySettingsAction.ChangeIdentityServer -> changeIdentityServer(action) + is DiscoverySettingsAction.UpdateUserConsent -> handleUpdateUserConsent(action) + is DiscoverySettingsAction.RevokeThreePid -> revokeThreePid(action) + is DiscoverySettingsAction.ShareThreePid -> shareThreePid(action) + is DiscoverySettingsAction.FinalizeBind3pid -> finalizeBind3pid(action, true) + is DiscoverySettingsAction.SubmitMsisdnToken -> submitMsisdnToken(action) + is DiscoverySettingsAction.CancelBinding -> cancelBinding(action) } } @@ -232,7 +232,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor( private fun revokeThreePid(action: DiscoverySettingsAction.RevokeThreePid) { when (action.threePid) { - is ThreePid.Email -> revokeEmail(action.threePid) + is ThreePid.Email -> revokeEmail(action.threePid) is ThreePid.Msisdn -> revokeMsisdn(action.threePid) } } @@ -359,7 +359,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor( private fun finalizeBind3pid(action: DiscoverySettingsAction.FinalizeBind3pid, fromUser: Boolean) = withState { state -> val threePid = when (action.threePid) { - is ThreePid.Email -> { + is ThreePid.Email -> { state.emailList()?.find { it.threePid.value == action.threePid.email }?.threePid ?: return@withState } is ThreePid.Msisdn -> { @@ -389,7 +389,7 @@ class DiscoverySettingsViewModel @AssistedInject constructor( state.emailList()?.forEach { info -> when (info.isShared()) { SharedState.BINDING_IN_PROGRESS -> finalizeBind3pid(DiscoverySettingsAction.FinalizeBind3pid(info.threePid), false) - else -> Unit + else -> Unit } } viewModelScope.launch { diff --git a/vector/src/main/java/im/vector/app/features/discovery/SettingsButtonItem.kt b/vector/src/main/java/im/vector/app/features/discovery/SettingsButtonItem.kt index 5a32616c06..c025779339 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/SettingsButtonItem.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/SettingsButtonItem.kt @@ -56,7 +56,7 @@ abstract class SettingsButtonItem : EpoxyModelWithHolder { + ButtonStyle.POSITIVE -> { holder.button.setTextColor(colorProvider.getColorFromAttribute(R.attr.colorPrimary)) } ButtonStyle.DESTRUCTIVE -> { diff --git a/vector/src/main/java/im/vector/app/features/discovery/SettingsTextButtonSingleLineItem.kt b/vector/src/main/java/im/vector/app/features/discovery/SettingsTextButtonSingleLineItem.kt index 29a44a1d8a..192ee404fb 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/SettingsTextButtonSingleLineItem.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/SettingsTextButtonSingleLineItem.kt @@ -111,11 +111,11 @@ abstract class SettingsTextButtonSingleLineItem : EpoxyModelWithHolder { + ButtonType.NORMAL -> { holder.mainButton.isVisible = true holder.switchButton.isVisible = false when (buttonStyle) { - ButtonStyle.POSITIVE -> { + ButtonStyle.POSITIVE -> { holder.mainButton.setTextColor(colorProvider.getColorFromAttribute(R.attr.colorPrimary)) } ButtonStyle.DESTRUCTIVE -> { @@ -124,7 +124,7 @@ abstract class SettingsTextButtonSingleLineItem : EpoxyModelWithHolder { + ButtonType.SWITCH -> { holder.mainButton.isVisible = false holder.switchButton.isVisible = true // set to null before changing the state @@ -136,10 +136,10 @@ abstract class SettingsTextButtonSingleLineItem : EpoxyModelWithHolder { + IconMode.NONE -> { holder.textView.setCompoundDrawables(null, null, null, null) } - IconMode.INFO -> { + IconMode.INFO -> { val errorColor = colorProvider.getColor(R.color.notification_accent_color) ContextCompat.getDrawable(holder.view.context, R.drawable.ic_notification_privacy_warning)?.apply { ThemeUtils.tintDrawableWithColor(this, errorColor) diff --git a/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerFragment.kt b/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerFragment.kt index fe2be713af..ee36345418 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerFragment.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerFragment.kt @@ -110,10 +110,10 @@ class SetIdentityServerFragment @Inject constructor( viewModel.observeViewEvents { when (it) { - is SetIdentityServerViewEvents.Loading -> showLoading(it.message) - is SetIdentityServerViewEvents.Failure -> handleFailure(it) - is SetIdentityServerViewEvents.OtherFailure -> showFailure(it.failure) - is SetIdentityServerViewEvents.NoTerms -> { + is SetIdentityServerViewEvents.Loading -> showLoading(it.message) + is SetIdentityServerViewEvents.Failure -> handleFailure(it) + is SetIdentityServerViewEvents.OtherFailure -> showFailure(it.failure) + is SetIdentityServerViewEvents.NoTerms -> { MaterialAlertDialogBuilder(requireActivity()) .setTitle(R.string.settings_discovery_no_terms_title) .setMessage(R.string.settings_discovery_no_terms) @@ -125,7 +125,7 @@ class SetIdentityServerFragment @Inject constructor( Unit } is SetIdentityServerViewEvents.TermsAccepted -> processIdentityServerChange() - is SetIdentityServerViewEvents.ShowTerms -> { + is SetIdentityServerViewEvents.ShowTerms -> { navigator.openTerms( requireContext(), termsActivityResultLauncher, diff --git a/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerViewModel.kt b/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerViewModel.kt index c5dc0c17ea..b91feb0b3c 100644 --- a/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/discovery/change/SetIdentityServerViewModel.kt @@ -65,7 +65,7 @@ class SetIdentityServerViewModel @AssistedInject constructor( override fun handle(action: SetIdentityServerAction) { when (action) { - SetIdentityServerAction.UseDefaultIdentityServer -> useDefault() + SetIdentityServerAction.UseDefaultIdentityServer -> useDefault() is SetIdentityServerAction.UseCustomIdentityServer -> usedCustomIdentityServerUrl(action) } } @@ -95,11 +95,11 @@ class SetIdentityServerViewModel @AssistedInject constructor( checkTerms(baseUrl) } catch (failure: Throwable) { when { - failure is IdentityServiceError.OutdatedIdentityServer -> + failure is IdentityServiceError.OutdatedIdentityServer -> _viewEvents.post(SetIdentityServerViewEvents.Failure(R.string.identity_server_error_outdated_identity_server, isDefault)) failure is Failure.NetworkConnection && failure.ioException is UnknownHostException -> _viewEvents.post(SetIdentityServerViewEvents.Failure(R.string.settings_discovery_bad_identity_server, isDefault)) - else -> + else -> _viewEvents.post(SetIdentityServerViewEvents.OtherFailure(failure)) } } diff --git a/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt b/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt index 5023c6bd83..c58b36fc88 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormEditTextItem.kt @@ -133,7 +133,7 @@ abstract class FormEditTextItem : VectorEpoxyModel() { private fun configureInputType(holder: Holder) { val newInputType = inputType ?: when (singleLine) { - true -> InputType.TYPE_CLASS_TEXT + true -> InputType.TYPE_CLASS_TEXT false -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE } @@ -151,7 +151,7 @@ abstract class FormEditTextItem : VectorEpoxyModel() { private fun configureImeOptions(holder: Holder) { holder.textInputEditText.imeOptions = imeOptions ?: when (singleLine) { - true -> EditorInfo.IME_ACTION_NEXT + true -> EditorInfo.IME_ACTION_NEXT false -> EditorInfo.IME_ACTION_NONE } } diff --git a/vector/src/main/java/im/vector/app/features/form/FormEditTextWithDeleteItem.kt b/vector/src/main/java/im/vector/app/features/form/FormEditTextWithDeleteItem.kt index 09ca51cfb1..637955a66c 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormEditTextWithDeleteItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormEditTextWithDeleteItem.kt @@ -85,7 +85,7 @@ abstract class FormEditTextWithDeleteItem : VectorEpoxyModel EditorInfo.IME_ACTION_NEXT + true -> EditorInfo.IME_ACTION_NEXT false -> EditorInfo.IME_ACTION_NONE } diff --git a/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt b/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt index f8749f2978..a25050cad0 100644 --- a/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt +++ b/vector/src/main/java/im/vector/app/features/form/FormEditableSquareAvatarItem.kt @@ -59,7 +59,7 @@ abstract class FormEditableSquareAvatarItem : EpoxyModelWithHolder { + imageUri != null -> { val corner = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 8f, @@ -73,7 +73,7 @@ abstract class FormEditableSquareAvatarItem : EpoxyModelWithHolder { avatarRenderer?.render(matrixItem!!, holder.image) } - else -> { + else -> { avatarRenderer?.clear(holder.image) } } diff --git a/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt b/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt index d02f8f0bd4..4b32f3307f 100644 --- a/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt +++ b/vector/src/main/java/im/vector/app/features/home/AvatarRenderer.kt @@ -164,7 +164,7 @@ class AvatarRenderer @Inject constructor( is MatrixItem.SpaceItem -> { it.transform(MultiTransformation(CenterCrop(), RoundedCorners(dimensionConverter.dpToPx(8)))) } - else -> { + else -> { it.apply(RequestOptions.circleCropTransform()) } } @@ -277,7 +277,7 @@ class AvatarRenderer @Inject constructor( is MatrixItem.SpaceItem -> { it.buildRoundRect(matrixItem.firstLetterOfDisplayName(), avatarColor, dimensionConverter.dpToPx(8)) } - else -> { + else -> { it.buildRound(matrixItem.firstLetterOfDisplayName(), avatarColor) } } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt index 05e36d1fe5..f2d3011471 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivity.kt @@ -197,9 +197,9 @@ class HomeActivity : .stream() .onEach { sharedAction -> when (sharedAction) { - is HomeActivitySharedAction.OpenDrawer -> views.drawerLayout.openDrawer(GravityCompat.START) - is HomeActivitySharedAction.CloseDrawer -> views.drawerLayout.closeDrawer(GravityCompat.START) - is HomeActivitySharedAction.OpenGroup -> { + is HomeActivitySharedAction.OpenDrawer -> views.drawerLayout.openDrawer(GravityCompat.START) + is HomeActivitySharedAction.CloseDrawer -> views.drawerLayout.closeDrawer(GravityCompat.START) + is HomeActivitySharedAction.OpenGroup -> { views.drawerLayout.closeDrawer(GravityCompat.START) // Temporary @@ -213,10 +213,10 @@ class HomeActivity : // we might want to delay that to avoid having the drawer animation lagging // would be probably better to let the drawer do that? in the on closed callback? } - is HomeActivitySharedAction.OpenSpacePreview -> { + is HomeActivitySharedAction.OpenSpacePreview -> { startActivity(SpacePreviewActivity.newIntent(this, sharedAction.spaceId)) } - is HomeActivitySharedAction.AddSpace -> { + is HomeActivitySharedAction.AddSpace -> { createSpaceResultLauncher.launch(SpaceCreationActivity.newIntent(this)) } is HomeActivitySharedAction.ShowSpaceSettings -> { @@ -229,11 +229,11 @@ class HomeActivity : }) .show(supportFragmentManager, "SPACE_SETTINGS") } - is HomeActivitySharedAction.OpenSpaceInvite -> { + is HomeActivitySharedAction.OpenSpaceInvite -> { SpaceInviteBottomSheet.newInstance(sharedAction.spaceId) .show(supportFragmentManager, "SPACE_INVITE") } - HomeActivitySharedAction.SendSpaceFeedBack -> { + HomeActivitySharedAction.SendSpaceFeedBack -> { bugReporter.openBugReportScreen(this, ReportType.SPACE_BETA_FEEDBACK) } } @@ -254,12 +254,12 @@ class HomeActivity : homeActivityViewModel.observeViewEvents { when (it) { is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it) - is HomeActivityViewEvents.OnNewSession -> handleOnNewSession(it) - HomeActivityViewEvents.PromptToEnableSessionPush -> handlePromptToEnablePush() - is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it) - HomeActivityViewEvents.ShowAnalyticsOptIn -> handleShowAnalyticsOptIn() - HomeActivityViewEvents.NotifyUserForThreadsMigration -> handleNotifyUserForThreadsMigration() - is HomeActivityViewEvents.MigrateThreads -> migrateThreadsIfNeeded(it.checkSession) + is HomeActivityViewEvents.OnNewSession -> handleOnNewSession(it) + HomeActivityViewEvents.PromptToEnableSessionPush -> handlePromptToEnablePush() + is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it) + HomeActivityViewEvents.ShowAnalyticsOptIn -> handleShowAnalyticsOptIn() + HomeActivityViewEvents.NotifyUserForThreadsMigration -> handleNotifyUserForThreadsMigration() + is HomeActivityViewEvents.MigrateThreads -> migrateThreadsIfNeeded(it.checkSession) } } homeActivityViewModel.onEach { renderState(it) } @@ -326,12 +326,12 @@ class HomeActivity : when { deepLink.startsWith(USER_LINK_PREFIX) -> deepLink.substring(USER_LINK_PREFIX.length) deepLink.startsWith(ROOM_LINK_PREFIX) -> deepLink.substring(ROOM_LINK_PREFIX.length) - else -> null + else -> null }?.let { permalinkId -> activeSessionHolder.getSafeActiveSession()?.permalinkService()?.createPermalink(permalinkId) } } - else -> deepLink + else -> deepLink } lifecycleScope.launch { @@ -374,7 +374,7 @@ class HomeActivity : } views.waitingView.root.isVisible = true } - else -> { + else -> { // Idle or Incremental sync status views.waitingView.root.isVisible = false } @@ -526,15 +526,15 @@ class HomeActivity : override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { - R.id.menu_home_suggestion -> { + R.id.menu_home_suggestion -> { bugReporter.openBugReportScreen(this, ReportType.SUGGESTION) return true } - R.id.menu_home_report_bug -> { + R.id.menu_home_report_bug -> { bugReporter.openBugReportScreen(this, ReportType.BUG_REPORT) return true } - R.id.menu_home_init_sync_legacy -> { + R.id.menu_home_init_sync_legacy -> { // Configure the SDK initialSyncStrategy = InitialSyncStrategy.Legacy // And clear cache @@ -548,11 +548,11 @@ class HomeActivity : MainActivity.restartApp(this, MainActivityArgs(clearCache = true)) return true } - R.id.menu_home_filter -> { + R.id.menu_home_filter -> { navigator.openRoomsFiltering(this) return true } - R.id.menu_home_setting -> { + R.id.menu_home_setting -> { navigator.openSettings(this) return true } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt index c47ca0880e..32f5a68377 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeActivityViewModel.kt @@ -156,7 +156,7 @@ class HomeActivityViewModel @AssistedInject constructor( vectorPreferences.userNotifiedAboutThreads() } // Migrate users with enabled lab settings - vectorPreferences.shouldNotifyUserAboutThreads() && vectorPreferences.shouldMigrateThreads() -> { + vectorPreferences.shouldNotifyUserAboutThreads() && vectorPreferences.shouldMigrateThreads() -> { Timber.i("----> Migrate threads with enabled labs") // If user had io.element.thread enabled then enable the new thread support, // clear cache to sync messages appropriately @@ -166,7 +166,7 @@ class HomeActivityViewModel @AssistedInject constructor( _viewEvents.post(HomeActivityViewEvents.MigrateThreads(checkSession = false)) } // Enable all users - vectorPreferences.shouldMigrateThreads() && vectorPreferences.areThreadMessagesEnabled() -> { + vectorPreferences.shouldMigrateThreads() && vectorPreferences.areThreadMessagesEnabled() -> { Timber.i("----> Try to migrate threads") _viewEvents.post(HomeActivityViewEvents.MigrateThreads(checkSession = true)) } @@ -184,13 +184,13 @@ class HomeActivityViewModel @AssistedInject constructor( // Schedule a check of the bootstrap when the init sync will be finished checkBootstrap = true } - is SyncStatusService.Status.Idle -> { + is SyncStatusService.Status.Idle -> { if (checkBootstrap) { checkBootstrap = false maybeBootstrapCrossSigningAfterInitialSync() } } - else -> Unit + else -> Unit } setState { @@ -306,7 +306,7 @@ class HomeActivityViewModel @AssistedInject constructor( HomeActivityViewActions.PushPromptHasBeenReviewed -> { vectorPreferences.setDidAskUserToEnableSessionPush() } - HomeActivityViewActions.ViewStarted -> { + HomeActivityViewActions.ViewStarted -> { initialize() } } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt index 2753ba817d..0ed6cc8d9d 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt @@ -133,7 +133,7 @@ class HomeDetailFragment @Inject constructor( is RoomGroupingMethod.ByLegacyGroup -> { onGroupChange(roomGroupingMethod.groupSummary) } - is RoomGroupingMethod.BySpace -> { + is RoomGroupingMethod.BySpace -> { onSpaceChange(roomGroupingMethod.spaceSummary) } } @@ -149,9 +149,9 @@ class HomeDetailFragment @Inject constructor( viewModel.observeViewEvents { viewEvent -> when (viewEvent) { - HomeDetailViewEvents.CallStarted -> handleCallStarted() + HomeDetailViewEvents.CallStarted -> handleCallStarted() is HomeDetailViewEvents.FailToCall -> showFailure(viewEvent.failure) - HomeDetailViewEvents.Loading -> showLoadingDialog() + HomeDetailViewEvents.Loading -> showLoadingDialog() } } @@ -213,7 +213,7 @@ class HomeDetailFragment @Inject constructor( is RoomGroupingMethod.ByLegacyGroup -> { onGroupChange(roomGroupingMethod.groupSummary) } - is RoomGroupingMethod.BySpace -> { + is RoomGroupingMethod.BySpace -> { onSpaceChange(roomGroupingMethod.spaceSummary) } } @@ -299,10 +299,10 @@ class HomeDetailFragment @Inject constructor( serverBackupStatusViewModel .onEach { when (val banState = it.bannerState.invoke()) { - is BannerState.Setup -> views.homeKeysBackupBanner.render(KeysBackupBanner.State.Setup(banState.numberOfKeys), false) + is BannerState.Setup -> views.homeKeysBackupBanner.render(KeysBackupBanner.State.Setup(banState.numberOfKeys), false) BannerState.BackingUp -> views.homeKeysBackupBanner.render(KeysBackupBanner.State.BackingUp, false) null, - BannerState.Hidden -> views.homeKeysBackupBanner.render(KeysBackupBanner.State.Hidden, false) + BannerState.Hidden -> views.homeKeysBackupBanner.render(KeysBackupBanner.State.Hidden, false) } } views.homeKeysBackupBanner.delegate = this @@ -326,7 +326,7 @@ class HomeDetailFragment @Inject constructor( is RoomGroupingMethod.ByLegacyGroup -> { // nothing do far } - is RoomGroupingMethod.BySpace -> { + is RoomGroupingMethod.BySpace -> { it.roomGroupingMethod.spaceSummary?.let { sharedActionViewModel.post(HomeActivitySharedAction.ShowSpaceSettings(it.roomId)) } @@ -340,10 +340,10 @@ class HomeDetailFragment @Inject constructor( views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible = vectorPreferences.labAddNotificationTab() views.bottomNavigationView.setOnItemSelectedListener { val tab = when (it.itemId) { - R.id.bottom_action_people -> HomeTab.RoomList(RoomListDisplayMode.PEOPLE) - R.id.bottom_action_rooms -> HomeTab.RoomList(RoomListDisplayMode.ROOMS) + R.id.bottom_action_people -> HomeTab.RoomList(RoomListDisplayMode.PEOPLE) + R.id.bottom_action_rooms -> HomeTab.RoomList(RoomListDisplayMode.ROOMS) R.id.bottom_action_notification -> HomeTab.RoomList(RoomListDisplayMode.NOTIFICATIONS) - else -> HomeTab.DialPad + else -> HomeTab.DialPad } viewModel.handle(HomeDetailAction.SwitchTab(tab)) true @@ -385,7 +385,7 @@ class HomeDetailFragment @Inject constructor( val params = RoomListParams(tab.displayMode) add(R.id.roomListContainer, RoomListFragment::class.java, params.toMvRxBundle(), fragmentTag) } - is HomeTab.DialPad -> { + is HomeTab.DialPad -> { add(R.id.roomListContainer, createDialPadFragment(), fragmentTag) } } @@ -463,11 +463,11 @@ class HomeDetailFragment @Inject constructor( } private fun HomeTab.toMenuId() = when (this) { - is HomeTab.DialPad -> R.id.bottom_action_dial_pad + is HomeTab.DialPad -> R.id.bottom_action_dial_pad is HomeTab.RoomList -> when (displayMode) { RoomListDisplayMode.PEOPLE -> R.id.bottom_action_people - RoomListDisplayMode.ROOMS -> R.id.bottom_action_rooms - else -> R.id.bottom_action_notification + RoomListDisplayMode.ROOMS -> R.id.bottom_action_rooms + else -> R.id.bottom_action_notification } } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt index a4f1566eff..ced911ee42 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt @@ -125,8 +125,8 @@ class HomeDetailViewModel @AssistedInject constructor( override fun handle(action: HomeDetailAction) { when (action) { - is HomeDetailAction.SwitchTab -> handleSwitchTab(action) - HomeDetailAction.MarkAllRoomsRead -> handleMarkAllRoomsRead() + is HomeDetailAction.SwitchTab -> handleSwitchTab(action) + HomeDetailAction.MarkAllRoomsRead -> handleMarkAllRoomsRead() is HomeDetailAction.StartCallWithPhoneNumber -> handleStartCallWithPhoneNumber(action) } } @@ -232,7 +232,7 @@ class HomeDetailViewModel @AssistedInject constructor( is RoomGroupingMethod.ByLegacyGroup -> { // TODO!! } - is RoomGroupingMethod.BySpace -> { + is RoomGroupingMethod.BySpace -> { val activeSpaceRoomId = groupingMethod.spaceSummary?.roomId var dmInvites = 0 var roomsInvite = 0 @@ -282,7 +282,7 @@ class HomeDetailViewModel @AssistedInject constructor( ) } } - null -> Unit + null -> Unit } } .launchIn(viewModelScope) diff --git a/vector/src/main/java/im/vector/app/features/home/InitSyncStepFormatter.kt b/vector/src/main/java/im/vector/app/features/home/InitSyncStepFormatter.kt index 51ca96341e..d2d414971f 100644 --- a/vector/src/main/java/im/vector/app/features/home/InitSyncStepFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/InitSyncStepFormatter.kt @@ -27,16 +27,16 @@ class InitSyncStepFormatter @Inject constructor( fun format(initSyncStep: InitSyncStep): String { return stringProvider.getString( when (initSyncStep) { - InitSyncStep.ServerComputing -> R.string.initial_sync_start_server_computing - InitSyncStep.Downloading -> R.string.initial_sync_start_downloading - InitSyncStep.ImportingAccount -> R.string.initial_sync_start_importing_account - InitSyncStep.ImportingAccountCrypto -> R.string.initial_sync_start_importing_account_crypto - InitSyncStep.ImportingAccountRoom -> R.string.initial_sync_start_importing_account_rooms - InitSyncStep.ImportingAccountGroups -> R.string.initial_sync_start_importing_account_groups - InitSyncStep.ImportingAccountData -> R.string.initial_sync_start_importing_account_data - InitSyncStep.ImportingAccountJoinedRooms -> R.string.initial_sync_start_importing_account_joined_rooms + InitSyncStep.ServerComputing -> R.string.initial_sync_start_server_computing + InitSyncStep.Downloading -> R.string.initial_sync_start_downloading + InitSyncStep.ImportingAccount -> R.string.initial_sync_start_importing_account + InitSyncStep.ImportingAccountCrypto -> R.string.initial_sync_start_importing_account_crypto + InitSyncStep.ImportingAccountRoom -> R.string.initial_sync_start_importing_account_rooms + InitSyncStep.ImportingAccountGroups -> R.string.initial_sync_start_importing_account_groups + InitSyncStep.ImportingAccountData -> R.string.initial_sync_start_importing_account_data + InitSyncStep.ImportingAccountJoinedRooms -> R.string.initial_sync_start_importing_account_joined_rooms InitSyncStep.ImportingAccountInvitedRooms -> R.string.initial_sync_start_importing_account_invited_rooms - InitSyncStep.ImportingAccountLeftRooms -> R.string.initial_sync_start_importing_account_left_rooms + InitSyncStep.ImportingAccountLeftRooms -> R.string.initial_sync_start_importing_account_left_rooms } ) } diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt index 082d318cc7..23cbe3dfa2 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutCreator.kt @@ -63,7 +63,7 @@ class ShortcutCreator @Inject constructor( val glideRequests = GlideApp.with(context) val matrixItem = roomSummary.toMatrixItem() when (useAdaptiveIcon) { - true -> avatarRenderer.adaptiveShortcutDrawable(glideRequests, matrixItem, iconSize, adaptiveIconSize, adaptiveIconOuterSides.toFloat()) + true -> avatarRenderer.adaptiveShortcutDrawable(glideRequests, matrixItem, iconSize, adaptiveIconSize, adaptiveIconOuterSides.toFloat()) false -> avatarRenderer.shortcutDrawable(glideRequests, matrixItem, iconSize) } } catch (failure: Throwable) { diff --git a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt index 582b10b871..6b70ac4560 100644 --- a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt @@ -129,7 +129,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor( RoomAggregateNotificationCount(0, 0) ) } - is RoomGroupingMethod.BySpace -> { + is RoomGroupingMethod.BySpace -> { val selectedSpace = appStateHandler.safeActiveSpaceId() val inviteCount = if (autoAcceptInvites.hideInvites) { @@ -181,7 +181,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor( ) ) } - null -> { + null -> { CountInfo( RoomAggregateNotificationCount(0, 0), RoomAggregateNotificationCount(0, 0) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt index 65d18105fe..68053ed890 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt @@ -134,12 +134,12 @@ class AutoCompleter @AssistedInject constructor( .with(object : AutocompleteCallback { override fun onPopupItemClicked(editable: Editable, item: AutocompleteMemberItem): Boolean { return when (item) { - is AutocompleteMemberItem.Header -> false // do nothing header is not clickable + is AutocompleteMemberItem.Header -> false // do nothing header is not clickable is AutocompleteMemberItem.RoomMember -> { insertMatrixItem(editText, editable, TRIGGER_AUTO_COMPLETE_MEMBERS, item.roomMemberSummary.toMatrixItem()) true } - is AutocompleteMemberItem.Everyone -> { + is AutocompleteMemberItem.Everyone -> { insertMatrixItem(editText, editable, TRIGGER_AUTO_COMPLETE_MEMBERS, item.roomSummary.toEveryoneInRoomMatrixItem()) true } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/ChatEffectManager.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/ChatEffectManager.kt index fa19e39ae7..69ee6fe4fc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/ChatEffectManager.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/ChatEffectManager.kt @@ -117,17 +117,17 @@ class ChatEffectManager @Inject constructor( MessageType.MSGTYPE_CONFETTI -> ChatEffect.CONFETTI MessageType.MSGTYPE_SNOWFALL -> ChatEffect.SNOWFALL MessageType.MSGTYPE_EMOTE, - MessageType.MSGTYPE_TEXT -> { + MessageType.MSGTYPE_TEXT -> { event.root.getClearContent().toModel()?.body ?.let { text -> when { EMOJIS_FOR_CONFETTI.any { text.contains(it) } -> ChatEffect.CONFETTI EMOJIS_FOR_SNOWFALL.any { text.contains(it) } -> ChatEffect.SNOWFALL - else -> null + else -> null } } } - else -> null + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/JoinReplacementRoomBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/JoinReplacementRoomBottomSheet.kt index ce2903a6fa..ed8135371a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/JoinReplacementRoomBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/JoinReplacementRoomBottomSheet.kt @@ -70,7 +70,7 @@ class JoinReplacementRoomBottomSheet : views.roomUpgradeButton.render(ButtonStateView.State.Loaded) dismiss() } - is Fail -> { + is Fail -> { // display the error message views.descriptionText.text = errorFormatter.toHumanReadable(joinState.error) views.roomUpgradeButton.render(ButtonStateView.State.Error) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/JumpToBottomViewVisibilityManager.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/JumpToBottomViewVisibilityManager.kt index 58da62d503..0f7dc251ae 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/JumpToBottomViewVisibilityManager.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/JumpToBottomViewVisibilityManager.kt @@ -50,7 +50,7 @@ class JumpToBottomViewVisibilityManager( override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { when (newState) { - RecyclerView.SCROLL_STATE_IDLE -> { + RecyclerView.SCROLL_STATE_IDLE -> { maybeShowJumpToBottomViewVisibilityWithDelay() } RecyclerView.SCROLL_STATE_DRAGGING, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt index ac4df411a8..f1e06dd5ef 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailActivity.kt @@ -79,7 +79,7 @@ class RoomDetailActivity : private val playbackActivityListener = AudioMessagePlaybackTracker.ActivityListener { isPlayingOrRecording -> if (lastKnownPlayingOrRecordingState == isPlayingOrRecording) return@ActivityListener when (isPlayingOrRecording) { - true -> keepScreenOn() + true -> keepScreenOn() false -> endKeepScreenOn() } lastKnownPlayingOrRecordingState = isPlayingOrRecording diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/StartCallActionsHandler.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/StartCallActionsHandler.kt index 97cc58e78c..ba691de5d2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/StartCallActionsHandler.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/StartCallActionsHandler.kt @@ -49,7 +49,7 @@ class StartCallActionsHandler( private fun handleCallRequest(isVideoCall: Boolean) = withState(timelineViewModel) { state -> val roomSummary = state.asyncRoomSummary.invoke() ?: return@withState when (roomSummary.joinedMembersCount) { - 1 -> { + 1 -> { val pendingInvite = roomSummary.invitedMembersCount ?: 0 > 0 if (pendingInvite) { // wait for other to join @@ -59,7 +59,7 @@ class StartCallActionsHandler( showDialogWithMessage(fragment.getString(R.string.cannot_call_yourself)) } } - 2 -> { + 2 -> { val currentCall = callManager.getCurrentCall() if (currentCall?.signalingRoomId == roomId) { onTapToReturnToCall() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index b48a06d927..b98d3eced2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -417,10 +417,10 @@ class TimelineFragment @Inject constructor( } when (mode) { is SendMode.Regular -> renderRegularMode(mode.text) - is SendMode.Edit -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, R.string.edit, mode.text) - is SendMode.Quote -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, R.string.action_quote, mode.text) - is SendMode.Reply -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text) - is SendMode.Voice -> renderVoiceMessageMode(mode.text) + is SendMode.Edit -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_edit, R.string.edit, mode.text) + is SendMode.Quote -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_quote, R.string.action_quote, mode.text) + is SendMode.Reply -> renderSpecialMode(mode.timelineEvent, R.drawable.ic_reply, R.string.reply, mode.text) + is SendMode.Voice -> renderVoiceMessageMode(mode.text) } } @@ -439,13 +439,13 @@ class TimelineFragment @Inject constructor( messageComposerViewModel.observeViewEvents { when (it) { - is MessageComposerViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it) + is MessageComposerViewEvents.JoinRoomCommandSuccess -> handleJoinedToAnotherRoom(it) is MessageComposerViewEvents.SlashCommandConfirmationRequest -> handleSlashCommandConfirmationRequest(it) - is MessageComposerViewEvents.SendMessageResult -> renderSendMessageResult(it) - is MessageComposerViewEvents.ShowMessage -> showSnackWithMessage(it.message) - is MessageComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(it) - is MessageComposerViewEvents.AnimateSendButtonVisibility -> handleSendButtonVisibilityChanged(it) - is MessageComposerViewEvents.OpenRoomMemberProfile -> openRoomMemberProfile(it.userId) + is MessageComposerViewEvents.SendMessageResult -> renderSendMessageResult(it) + is MessageComposerViewEvents.ShowMessage -> showSnackWithMessage(it.message) + is MessageComposerViewEvents.ShowRoomUpgradeDialog -> handleShowRoomUpgradeDialog(it) + is MessageComposerViewEvents.AnimateSendButtonVisibility -> handleSendButtonVisibilityChanged(it) + is MessageComposerViewEvents.OpenRoomMemberProfile -> openRoomMemberProfile(it.userId) is MessageComposerViewEvents.VoicePlaybackOrRecordingFailure -> { if (it.throwable is VoiceFailure.UnableToRecord) { onCannotRecord() @@ -457,39 +457,39 @@ class TimelineFragment @Inject constructor( timelineViewModel.observeViewEvents { when (it) { - is RoomDetailViewEvents.Failure -> displayErrorMessage(it) - is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds) - is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it) - is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) - is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message) - is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) - is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) - is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode) - RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager() - is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it) + is RoomDetailViewEvents.Failure -> displayErrorMessage(it) + is RoomDetailViewEvents.OnNewTimelineEvents -> scrollOnNewMessageCallback.addNewTimelineEventIds(it.eventIds) + is RoomDetailViewEvents.ActionSuccess -> displayRoomDetailActionSuccess(it) + is RoomDetailViewEvents.ActionFailure -> displayRoomDetailActionFailure(it) + is RoomDetailViewEvents.ShowMessage -> showSnackWithMessage(it.message) + is RoomDetailViewEvents.NavigateToEvent -> navigateToEvent(it) + is RoomDetailViewEvents.DownloadFileState -> handleDownloadFileState(it) + is RoomDetailViewEvents.ShowE2EErrorMessage -> displayE2eError(it.withHeldCode) + RoomDetailViewEvents.DisplayPromptForIntegrationManager -> displayPromptForIntegrationManager() + is RoomDetailViewEvents.OpenStickerPicker -> openStickerPicker(it) is RoomDetailViewEvents.DisplayEnableIntegrationsWarning -> displayDisabledIntegrationDialog() - is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager() - is RoomDetailViewEvents.OpenFile -> startOpenFileIntent(it) - RoomDetailViewEvents.OpenActiveWidgetBottomSheet -> onViewWidgetsClicked() - is RoomDetailViewEvents.ShowInfoOkDialog -> showDialogWithMessage(it.message) - is RoomDetailViewEvents.JoinJitsiConference -> joinJitsiRoom(it.widget, it.withVideo) - RoomDetailViewEvents.LeaveJitsiConference -> leaveJitsiConference() - RoomDetailViewEvents.ShowWaitingView -> vectorBaseActivity.showWaitingView() - RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView() - is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it) - is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it) - RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), timelineArgs.roomId) - RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show() - RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings(RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS) - RoomDetailViewEvents.OpenRoomProfile -> handleOpenRoomSettings() - is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item -> + is RoomDetailViewEvents.OpenIntegrationManager -> openIntegrationManager() + is RoomDetailViewEvents.OpenFile -> startOpenFileIntent(it) + RoomDetailViewEvents.OpenActiveWidgetBottomSheet -> onViewWidgetsClicked() + is RoomDetailViewEvents.ShowInfoOkDialog -> showDialogWithMessage(it.message) + is RoomDetailViewEvents.JoinJitsiConference -> joinJitsiRoom(it.widget, it.withVideo) + RoomDetailViewEvents.LeaveJitsiConference -> leaveJitsiConference() + RoomDetailViewEvents.ShowWaitingView -> vectorBaseActivity.showWaitingView() + RoomDetailViewEvents.HideWaitingView -> vectorBaseActivity.hideWaitingView() + is RoomDetailViewEvents.RequestNativeWidgetPermission -> requestNativeWidgetPermission(it) + is RoomDetailViewEvents.OpenRoom -> handleOpenRoom(it) + RoomDetailViewEvents.OpenInvitePeople -> navigator.openInviteUsersToRoom(requireContext(), timelineArgs.roomId) + RoomDetailViewEvents.OpenSetRoomAvatarDialog -> galleryOrCameraDialogHelper.show() + RoomDetailViewEvents.OpenRoomSettings -> handleOpenRoomSettings(RoomProfileActivity.EXTRA_DIRECT_ACCESS_ROOM_SETTINGS) + RoomDetailViewEvents.OpenRoomProfile -> handleOpenRoomSettings() + is RoomDetailViewEvents.ShowRoomAvatarFullScreen -> it.matrixItem?.let { item -> navigator.openBigImageViewer(requireActivity(), it.view, item) } - is RoomDetailViewEvents.StartChatEffect -> handleChatEffect(it.type) - RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects() - is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it) - RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement() - is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it) + is RoomDetailViewEvents.StartChatEffect -> handleChatEffect(it.type) + RoomDetailViewEvents.StopChatEffects -> handleStopChatEffects() + is RoomDetailViewEvents.DisplayAndAcceptCall -> acceptIncomingCall(it) + RoomDetailViewEvents.RoomReplacementStarted -> handleRoomReplacement() + is RoomDetailViewEvents.ChangeLocationIndicator -> handleChangeLocationIndicator(it) } } @@ -502,7 +502,7 @@ class TimelineFragment @Inject constructor( private fun handleSlashCommandConfirmationRequest(action: MessageComposerViewEvents.SlashCommandConfirmationRequest) { when (action.parsedCommand) { is ParsedCommand.UnignoreUser -> promptUnignoreUser(action.parsedCommand) - else -> TODO("Add case for ${action.parsedCommand.javaClass.simpleName}") + else -> TODO("Add case for ${action.parsedCommand.javaClass.simpleName}") } lockSendButton = false } @@ -926,14 +926,14 @@ class TimelineFragment @Inject constructor( private fun handleShareData() { when (val sharedData = timelineArgs.sharedData) { - is SharedData.Text -> { + is SharedData.Text -> { messageComposerViewModel.handle(MessageComposerAction.EnterRegularMode(sharedData.text, fromSharing = true)) } is SharedData.Attachments -> { // open share edition onContentAttachmentsReady(sharedData.attachmentData) } - null -> Timber.v("No share data to process") + null -> Timber.v("No share data to process") } } @@ -1076,8 +1076,8 @@ class TimelineFragment @Inject constructor( // Set the visual state of the call buttons (voice/video) to enabled/disabled according to user permissions val hasCallInRoom = callManager.getCallsByRoomId(state.roomId).isNotEmpty() || state.jitsiState.hasJoined val callButtonsEnabled = !hasCallInRoom && when (state.asyncRoomSummary.invoke()?.joinedMembersCount) { - 1 -> false - 2 -> state.isAllowedToStartWebRTCCall + 1 -> false + 2 -> state.isAllowedToStartWebRTCCall else -> state.isAllowedToManageWidgets } setOf(R.id.voice_call, R.id.video_call).forEach { @@ -1111,39 +1111,39 @@ class TimelineFragment @Inject constructor( override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { - R.id.invite -> { + R.id.invite -> { navigator.openInviteUsersToRoom(requireActivity(), timelineArgs.roomId) true } - R.id.timeline_setting -> { + R.id.timeline_setting -> { navigator.openRoomProfile(requireActivity(), timelineArgs.roomId) true } - R.id.open_matrix_apps -> { + R.id.open_matrix_apps -> { timelineViewModel.handle(RoomDetailAction.ManageIntegrations) true } - R.id.voice_call -> { + R.id.voice_call -> { callActionsHandler.onVoiceCallClicked() true } - R.id.video_call -> { + R.id.video_call -> { callActionsHandler.onVideoCallClicked() true } - R.id.menu_timeline_thread_list -> { + R.id.menu_timeline_thread_list -> { navigateToThreadList() true } - R.id.search -> { + R.id.search -> { handleSearchAction() true } - R.id.dev_tools -> { + R.id.dev_tools -> { navigator.openDevTools(requireContext(), timelineArgs.roomId) true } - R.id.menu_thread_timeline_copy_link -> { + R.id.menu_thread_timeline_copy_link -> { getRootThreadEventId()?.let { val permalink = session.permalinkService().createPermalink(timelineArgs.roomId, it) copyToClipboard(requireContext(), permalink, false) @@ -1155,14 +1155,14 @@ class TimelineFragment @Inject constructor( handleViewInRoomAction() true } - R.id.menu_thread_timeline_share -> { + R.id.menu_thread_timeline_share -> { getRootThreadEventId()?.let { val permalink = session.permalinkService().createPermalink(timelineArgs.roomId, it) shareText(requireContext(), permalink) } true } - else -> super.onOptionsItemSelected(item) + else -> super.onOptionsItemSelected(item) } } @@ -1246,8 +1246,8 @@ class TimelineFragment @Inject constructor( val messageContent: MessageContent? = event.getLastMessageContent() val nonFormattedBody = when (messageContent) { is MessageAudioContent -> getAudioContentBodyText(messageContent) - is MessagePollContent -> messageContent.getBestPollCreationInfo()?.question?.getBestQuestion() - else -> messageContent?.body.orEmpty() + is MessagePollContent -> messageContent.getBestPollCreationInfo()?.question?.getBestQuestion() + else -> messageContent?.body.orEmpty() } var formattedBody: CharSequence? = null if (messageContent is MessageTextContent && messageContent.format == MessageFormat.FORMAT_MATRIX_HTML) { @@ -1309,9 +1309,9 @@ class TimelineFragment @Inject constructor( when (roomDetailPendingAction) { is RoomDetailPendingAction.JumpToReadReceipt -> timelineViewModel.handle(RoomDetailAction.JumpToReadReceipt(roomDetailPendingAction.userId)) - is RoomDetailPendingAction.MentionUser -> + is RoomDetailPendingAction.MentionUser -> insertUserDisplayNameInTextEditor(roomDetailPendingAction.userId) - is RoomDetailPendingAction.OpenRoom -> + is RoomDetailPendingAction.OpenRoom -> handleOpenRoom(RoomDetailViewEvents.OpenRoom(roomDetailPendingAction.roomId, roomDetailPendingAction.closeCurrentRoom)) } } @@ -1453,7 +1453,7 @@ class TimelineFragment @Inject constructor( is MessageTextItem -> { return (model as AbsMessageItem).attributes.informationData.sendState == SendState.SYNCED } - else -> false + else -> false } } } @@ -1479,9 +1479,9 @@ class TimelineFragment @Inject constructor( val state = timelineViewModel.awaitState() val showJumpToUnreadBanner = when (state.unreadState) { UnreadState.Unknown, - UnreadState.HasNoUnread -> false + UnreadState.HasNoUnread -> false is UnreadState.ReadMarkerNotLoaded -> true - is UnreadState.HasUnread -> { + is UnreadState.HasUnread -> { if (state.canShowJumpToReadMarker) { val lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition() val positionOfReadMarker = withContext(Dispatchers.Default) { @@ -1636,10 +1636,10 @@ class TimelineFragment @Inject constructor( views.composerLayout.setRoomEncrypted(summary.isEncrypted) // views.composerLayout.alwaysShowSendButton = false when (messageComposerState.canSendMessage) { - CanSendStatus.Allowed -> { + CanSendStatus.Allowed -> { NotificationAreaView.State.Hidden } - CanSendStatus.NoPermission -> { + CanSendStatus.NoPermission -> { NotificationAreaView.State.NoPermissionToPost } is CanSendStatus.UnSupportedE2eAlgorithm -> { @@ -1713,23 +1713,23 @@ class TimelineFragment @Inject constructor( private fun renderSendMessageResult(sendMessageResult: MessageComposerViewEvents.SendMessageResult) { when (sendMessageResult) { - is MessageComposerViewEvents.SlashCommandLoading -> { + is MessageComposerViewEvents.SlashCommandLoading -> { showLoading(null) } - is MessageComposerViewEvents.SlashCommandError -> { + is MessageComposerViewEvents.SlashCommandError -> { displayCommandError(getString(R.string.command_problem_with_parameters, sendMessageResult.command.command)) } - is MessageComposerViewEvents.SlashCommandUnknown -> { + is MessageComposerViewEvents.SlashCommandUnknown -> { displayCommandError(getString(R.string.unrecognized_command, sendMessageResult.command)) } - is MessageComposerViewEvents.SlashCommandResultOk -> { + is MessageComposerViewEvents.SlashCommandResultOk -> { handleSlashCommandResultOk(sendMessageResult.parsedCommand) } - is MessageComposerViewEvents.SlashCommandResultError -> { + is MessageComposerViewEvents.SlashCommandResultError -> { dismissLoadingDialog() displayCommandError(errorFormatter.toHumanReadable(sendMessageResult.throwable)) } - is MessageComposerViewEvents.SlashCommandNotImplemented -> { + is MessageComposerViewEvents.SlashCommandNotImplemented -> { displayCommandError(getString(R.string.not_implemented)) } is MessageComposerViewEvents.SlashCommandNotSupportedInThreads -> { @@ -1747,7 +1747,7 @@ class TimelineFragment @Inject constructor( is ParsedCommand.SetMarkdown -> { showSnackWithMessage(getString(if (parsedCommand.enable) R.string.markdown_has_been_enabled else R.string.markdown_has_been_disabled)) } - else -> Unit + else -> Unit } } @@ -1762,10 +1762,10 @@ class TimelineFragment @Inject constructor( private fun displayE2eError(withHeldCode: WithHeldCode?) { val msgId = when (withHeldCode) { WithHeldCode.BLACKLISTED -> R.string.crypto_error_withheld_blacklisted - WithHeldCode.UNVERIFIED -> R.string.crypto_error_withheld_unverified + WithHeldCode.UNVERIFIED -> R.string.crypto_error_withheld_unverified WithHeldCode.UNAUTHORISED, WithHeldCode.UNAVAILABLE -> R.string.crypto_error_withheld_generic - else -> R.string.notice_crypto_unable_to_decrypt_friendly_desc + else -> R.string.notice_crypto_unable_to_decrypt_friendly_desc } MaterialAlertDialogBuilder(requireActivity()) .setMessage(msgId) @@ -1813,9 +1813,9 @@ class TimelineFragment @Inject constructor( private fun displayRoomDetailActionSuccess(result: RoomDetailViewEvents.ActionSuccess) { when (val data = result.action) { - is RoomDetailAction.ReportContent -> { + is RoomDetailAction.ReportContent -> { when { - data.spam -> { + data.spam -> { MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive) .setTitle(R.string.content_reported_as_spam_title) .setMessage(R.string.content_reported_as_spam_content) @@ -1835,7 +1835,7 @@ class TimelineFragment @Inject constructor( } .show() } - else -> { + else -> { MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_Vector_MaterialAlertDialog_NegativeDestructive) .setTitle(R.string.content_reported_title) .setMessage(R.string.content_reported_content) @@ -1847,7 +1847,7 @@ class TimelineFragment @Inject constructor( } } } - is RoomDetailAction.RequestVerification -> { + is RoomDetailAction.RequestVerification -> { Timber.v("## SAS RequestVerification action") VerificationBottomSheet.withArgs( timelineArgs.roomId, @@ -1862,7 +1862,7 @@ class TimelineFragment @Inject constructor( data.transactionId ).show(parentFragmentManager, "REQ") } - is RoomDetailAction.ResumeVerification -> { + is RoomDetailAction.ResumeVerification -> { val otherUserId = data.otherUserId ?: return VerificationBottomSheet.withArgs( roomId = timelineArgs.roomId, @@ -1870,7 +1870,7 @@ class TimelineFragment @Inject constructor( transactionId = data.transactionId, ).show(parentFragmentManager, "REQ") } - else -> Unit + else -> Unit } } @@ -2009,17 +2009,17 @@ class TimelineFragment @Inject constructor( is MessageVerificationRequestContent -> { timelineViewModel.handle(RoomDetailAction.ResumeVerification(informationData.eventId, null)) } - is MessageWithAttachmentContent -> { + is MessageWithAttachmentContent -> { val action = RoomDetailAction.DownloadOrOpen(informationData.eventId, informationData.senderId, messageContent) timelineViewModel.handle(action) } - is EncryptedEventContent -> { + is EncryptedEventContent -> { timelineViewModel.handle(RoomDetailAction.TapOnFailedToDecrypt(informationData.eventId)) } - is MessageLocationContent -> { + is MessageLocationContent -> { handleShowLocationPreview(messageContent, informationData.senderId) } - else -> { + else -> { val handled = onThreadSummaryClicked(informationData.eventId, isRootThreadEvent) if (!handled) { Timber.d("No click action defined for this message content") @@ -2156,8 +2156,8 @@ class TimelineFragment @Inject constructor( private fun onShareActionClicked(action: EventSharedAction.Share) { when (action.messageContent) { - is MessageTextContent -> shareText(requireContext(), action.messageContent.body) - is MessageLocationContent -> { + is MessageTextContent -> shareText(requireContext(), action.messageContent.body) + is MessageLocationContent -> { action.messageContent.toLocationData()?.let { openLocation(requireActivity(), it.latitude, it.longitude) } @@ -2217,52 +2217,52 @@ class TimelineFragment @Inject constructor( private fun handleActions(action: EventSharedAction) { when (action) { - is EventSharedAction.OpenUserProfile -> { + is EventSharedAction.OpenUserProfile -> { openRoomMemberProfile(action.userId) } - is EventSharedAction.AddReaction -> { + is EventSharedAction.AddReaction -> { openEmojiReactionPicker(action.eventId) } - is EventSharedAction.ViewReactions -> { + is EventSharedAction.ViewReactions -> { ViewReactionsBottomSheet.newInstance(timelineArgs.roomId, action.messageInformationData) .show(requireActivity().supportFragmentManager, "DISPLAY_REACTIONS") } - is EventSharedAction.Copy -> { + is EventSharedAction.Copy -> { // I need info about the current selected message :/ copyToClipboard(requireContext(), action.content, false) showSnackWithMessage(getString(R.string.copied_to_clipboard)) } - is EventSharedAction.Redact -> { + is EventSharedAction.Redact -> { promptConfirmationToRedactEvent(action) } - is EventSharedAction.Share -> { + is EventSharedAction.Share -> { onShareActionClicked(action) } - is EventSharedAction.Save -> { + is EventSharedAction.Save -> { onSaveActionClicked(action) } - is EventSharedAction.ViewEditHistory -> { + is EventSharedAction.ViewEditHistory -> { onEditedDecorationClicked(action.messageInformationData) } - is EventSharedAction.ViewSource -> { + is EventSharedAction.ViewSource -> { JSonViewerDialog.newInstance( action.content, -1, createJSonViewerStyleProvider(colorProvider) ).show(childFragmentManager, "JSON_VIEWER") } - is EventSharedAction.ViewDecryptedSource -> { + is EventSharedAction.ViewDecryptedSource -> { JSonViewerDialog.newInstance( action.content, -1, createJSonViewerStyleProvider(colorProvider) ).show(childFragmentManager, "JSON_VIEWER") } - is EventSharedAction.QuickReact -> { + is EventSharedAction.QuickReact -> { // eventId,ClickedOn,Add timelineViewModel.handle(RoomDetailAction.UpdateQuickReactAction(action.eventId, action.clickedOn, action.add)) } - is EventSharedAction.Edit -> { + is EventSharedAction.Edit -> { if (action.eventType in EventType.POLL_START) { navigator.openCreatePoll(requireContext(), timelineArgs.roomId, action.eventId, PollMode.EDIT) } else if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) { @@ -2271,45 +2271,45 @@ class TimelineFragment @Inject constructor( requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit) } } - is EventSharedAction.Quote -> { + is EventSharedAction.Quote -> { messageComposerViewModel.handle(MessageComposerAction.EnterQuoteMode(action.eventId, views.composerLayout.text.toString())) } - is EventSharedAction.Reply -> { + is EventSharedAction.Reply -> { if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) { messageComposerViewModel.handle(MessageComposerAction.EnterReplyMode(action.eventId, views.composerLayout.text.toString())) } else { requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit) } } - is EventSharedAction.ReplyInThread -> { + is EventSharedAction.ReplyInThread -> { if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) { onReplyInThreadClicked(action) } else { requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit) } } - is EventSharedAction.ViewInRoom -> { + is EventSharedAction.ViewInRoom -> { if (withState(messageComposerViewModel) { it.isVoiceMessageIdle }) { handleViewInRoomAction() } else { requireActivity().toast(R.string.error_voice_message_cannot_reply_or_edit) } } - is EventSharedAction.CopyPermalink -> { + is EventSharedAction.CopyPermalink -> { val permalink = session.permalinkService().createPermalink(timelineArgs.roomId, action.eventId) copyToClipboard(requireContext(), permalink, false) showSnackWithMessage(getString(R.string.copied_to_clipboard)) } - is EventSharedAction.Resend -> { + is EventSharedAction.Resend -> { timelineViewModel.handle(RoomDetailAction.ResendMessage(action.eventId)) } - is EventSharedAction.Remove -> { + is EventSharedAction.Remove -> { timelineViewModel.handle(RoomDetailAction.RemoveFailedEcho(action.eventId)) } - is EventSharedAction.Cancel -> { + is EventSharedAction.Cancel -> { handleCancelSend(action) } - is EventSharedAction.ReportContentSpam -> { + is EventSharedAction.ReportContentSpam -> { timelineViewModel.handle( RoomDetailAction.ReportContent( action.eventId, action.senderId, "This message is spam", spam = true @@ -2323,31 +2323,31 @@ class TimelineFragment @Inject constructor( ) ) } - is EventSharedAction.ReportContentCustom -> { + is EventSharedAction.ReportContentCustom -> { promptReasonToReportContent(action) } - is EventSharedAction.IgnoreUser -> { + is EventSharedAction.IgnoreUser -> { action.senderId?.let { askConfirmationToIgnoreUser(it) } } - is EventSharedAction.OnUrlClicked -> { + is EventSharedAction.OnUrlClicked -> { onUrlClicked(action.url, action.title) } - is EventSharedAction.OnUrlLongClicked -> { + is EventSharedAction.OnUrlLongClicked -> { onUrlLongClicked(action.url) } - is EventSharedAction.ReRequestKey -> { + is EventSharedAction.ReRequestKey -> { timelineViewModel.handle(RoomDetailAction.ReRequestKeys(action.eventId)) } - is EventSharedAction.UseKeyBackup -> { + is EventSharedAction.UseKeyBackup -> { context?.let { startActivity(KeysBackupRestoreActivity.intent(it)) } } - is EventSharedAction.EndPoll -> { + is EventSharedAction.EndPoll -> { askConfirmationToEndPoll(action.eventId) } - is EventSharedAction.ReportContent -> Unit /* Not clickable */ - EventSharedAction.Separator -> Unit /* Not clickable */ + is EventSharedAction.ReportContent -> Unit /* Not clickable */ + EventSharedAction.Separator -> Unit /* Not clickable */ } } @@ -2557,17 +2557,17 @@ class TimelineFragment @Inject constructor( private fun launchAttachmentProcess(type: AttachmentTypeSelectorView.Type) { when (type) { - AttachmentTypeSelectorView.Type.CAMERA -> attachmentsHelper.openCamera( + AttachmentTypeSelectorView.Type.CAMERA -> attachmentsHelper.openCamera( activity = requireActivity(), vectorPreferences = vectorPreferences, cameraActivityResultLauncher = attachmentCameraActivityResultLauncher, cameraVideoActivityResultLauncher = attachmentCameraVideoActivityResultLauncher ) - AttachmentTypeSelectorView.Type.FILE -> attachmentsHelper.selectFile(attachmentFileActivityResultLauncher) - AttachmentTypeSelectorView.Type.GALLERY -> attachmentsHelper.selectGallery(attachmentMediaActivityResultLauncher) - AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact(attachmentContactActivityResultLauncher) - AttachmentTypeSelectorView.Type.STICKER -> timelineViewModel.handle(RoomDetailAction.SelectStickerAttachment) - AttachmentTypeSelectorView.Type.POLL -> navigator.openCreatePoll(requireContext(), timelineArgs.roomId, null, PollMode.CREATE) + AttachmentTypeSelectorView.Type.FILE -> attachmentsHelper.selectFile(attachmentFileActivityResultLauncher) + AttachmentTypeSelectorView.Type.GALLERY -> attachmentsHelper.selectGallery(attachmentMediaActivityResultLauncher) + AttachmentTypeSelectorView.Type.CONTACT -> attachmentsHelper.selectContact(attachmentContactActivityResultLauncher) + AttachmentTypeSelectorView.Type.STICKER -> timelineViewModel.handle(RoomDetailAction.SelectStickerAttachment) + AttachmentTypeSelectorView.Type.POLL -> navigator.openCreatePoll(requireContext(), timelineArgs.roomId, null, PollMode.CREATE) AttachmentTypeSelectorView.Type.LOCATION -> { navigator .openLocationSharing( diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index e81bab3e3e..214d01cb98 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -389,70 +389,70 @@ class TimelineViewModel @AssistedInject constructor( override fun handle(action: RoomDetailAction) { when (action) { - is RoomDetailAction.ComposerFocusChange -> handleComposerFocusChange(action) - is RoomDetailAction.SendMedia -> handleSendMedia(action) - is RoomDetailAction.SendSticker -> handleSendSticker(action) - is RoomDetailAction.TimelineEventTurnsVisible -> handleEventVisible(action) - is RoomDetailAction.TimelineEventTurnsInvisible -> handleEventInvisible(action) - is RoomDetailAction.LoadMoreTimelineEvents -> handleLoadMore(action) - is RoomDetailAction.SendReaction -> handleSendReaction(action) - is RoomDetailAction.AcceptInvite -> handleAcceptInvite() - is RoomDetailAction.RejectInvite -> handleRejectInvite() - is RoomDetailAction.RedactAction -> handleRedactEvent(action) - is RoomDetailAction.UndoReaction -> handleUndoReact(action) - is RoomDetailAction.UpdateQuickReactAction -> handleUpdateQuickReaction(action) - is RoomDetailAction.DownloadOrOpen -> handleOpenOrDownloadFile(action) - is RoomDetailAction.NavigateToEvent -> handleNavigateToEvent(action) - is RoomDetailAction.JoinAndOpenReplacementRoom -> handleJoinAndOpenReplacementRoom() - is RoomDetailAction.OnClickMisconfiguredEncryption -> handleClickMisconfiguredE2E() - is RoomDetailAction.ResendMessage -> handleResendEvent(action) - is RoomDetailAction.RemoveFailedEcho -> handleRemove(action) - is RoomDetailAction.MarkAllAsRead -> handleMarkAllAsRead() - is RoomDetailAction.ReportContent -> handleReportContent(action) - is RoomDetailAction.IgnoreUser -> handleIgnoreUser(action) + is RoomDetailAction.ComposerFocusChange -> handleComposerFocusChange(action) + is RoomDetailAction.SendMedia -> handleSendMedia(action) + is RoomDetailAction.SendSticker -> handleSendSticker(action) + is RoomDetailAction.TimelineEventTurnsVisible -> handleEventVisible(action) + is RoomDetailAction.TimelineEventTurnsInvisible -> handleEventInvisible(action) + is RoomDetailAction.LoadMoreTimelineEvents -> handleLoadMore(action) + is RoomDetailAction.SendReaction -> handleSendReaction(action) + is RoomDetailAction.AcceptInvite -> handleAcceptInvite() + is RoomDetailAction.RejectInvite -> handleRejectInvite() + is RoomDetailAction.RedactAction -> handleRedactEvent(action) + is RoomDetailAction.UndoReaction -> handleUndoReact(action) + is RoomDetailAction.UpdateQuickReactAction -> handleUpdateQuickReaction(action) + is RoomDetailAction.DownloadOrOpen -> handleOpenOrDownloadFile(action) + is RoomDetailAction.NavigateToEvent -> handleNavigateToEvent(action) + is RoomDetailAction.JoinAndOpenReplacementRoom -> handleJoinAndOpenReplacementRoom() + is RoomDetailAction.OnClickMisconfiguredEncryption -> handleClickMisconfiguredE2E() + is RoomDetailAction.ResendMessage -> handleResendEvent(action) + is RoomDetailAction.RemoveFailedEcho -> handleRemove(action) + is RoomDetailAction.MarkAllAsRead -> handleMarkAllAsRead() + is RoomDetailAction.ReportContent -> handleReportContent(action) + is RoomDetailAction.IgnoreUser -> handleIgnoreUser(action) is RoomDetailAction.EnterTrackingUnreadMessagesState -> startTrackingUnreadMessages() - is RoomDetailAction.ExitTrackingUnreadMessagesState -> stopTrackingUnreadMessages() - is RoomDetailAction.VoteToPoll -> handleVoteToPoll(action) - is RoomDetailAction.AcceptVerificationRequest -> handleAcceptVerification(action) - is RoomDetailAction.DeclineVerificationRequest -> handleDeclineVerification(action) - is RoomDetailAction.RequestVerification -> handleRequestVerification(action) - is RoomDetailAction.ResumeVerification -> handleResumeRequestVerification(action) - is RoomDetailAction.ReRequestKeys -> handleReRequestKeys(action) - is RoomDetailAction.TapOnFailedToDecrypt -> handleTapOnFailedToDecrypt(action) - is RoomDetailAction.SelectStickerAttachment -> handleSelectStickerAttachment() - is RoomDetailAction.OpenIntegrationManager -> handleOpenIntegrationManager() - is RoomDetailAction.StartCall -> handleStartCall(action) - is RoomDetailAction.AcceptCall -> handleAcceptCall(action) - is RoomDetailAction.EndCall -> handleEndCall() - is RoomDetailAction.ManageIntegrations -> handleManageIntegrations() - is RoomDetailAction.AddJitsiWidget -> handleAddJitsiConference(action) - is RoomDetailAction.UpdateJoinJitsiCallStatus -> handleJitsiCallJoinStatus(action) - is RoomDetailAction.JoinJitsiCall -> handleJoinJitsiCall() - is RoomDetailAction.LeaveJitsiCall -> handleLeaveJitsiCall() - is RoomDetailAction.RemoveWidget -> handleDeleteWidget(action.widgetId) - is RoomDetailAction.EnsureNativeWidgetAllowed -> handleCheckWidgetAllowed(action) - is RoomDetailAction.CancelSend -> handleCancel(action) - is RoomDetailAction.JumpToReadReceipt -> handleJumpToReadReceipt(action) - RoomDetailAction.QuickActionInvitePeople -> handleInvitePeople() - RoomDetailAction.QuickActionSetAvatar -> handleQuickSetAvatar() - is RoomDetailAction.SetAvatarAction -> handleSetNewAvatar(action) - RoomDetailAction.QuickActionSetTopic -> _viewEvents.post(RoomDetailViewEvents.OpenRoomSettings) - is RoomDetailAction.ShowRoomAvatarFullScreen -> { + is RoomDetailAction.ExitTrackingUnreadMessagesState -> stopTrackingUnreadMessages() + is RoomDetailAction.VoteToPoll -> handleVoteToPoll(action) + is RoomDetailAction.AcceptVerificationRequest -> handleAcceptVerification(action) + is RoomDetailAction.DeclineVerificationRequest -> handleDeclineVerification(action) + is RoomDetailAction.RequestVerification -> handleRequestVerification(action) + is RoomDetailAction.ResumeVerification -> handleResumeRequestVerification(action) + is RoomDetailAction.ReRequestKeys -> handleReRequestKeys(action) + is RoomDetailAction.TapOnFailedToDecrypt -> handleTapOnFailedToDecrypt(action) + is RoomDetailAction.SelectStickerAttachment -> handleSelectStickerAttachment() + is RoomDetailAction.OpenIntegrationManager -> handleOpenIntegrationManager() + is RoomDetailAction.StartCall -> handleStartCall(action) + is RoomDetailAction.AcceptCall -> handleAcceptCall(action) + is RoomDetailAction.EndCall -> handleEndCall() + is RoomDetailAction.ManageIntegrations -> handleManageIntegrations() + is RoomDetailAction.AddJitsiWidget -> handleAddJitsiConference(action) + is RoomDetailAction.UpdateJoinJitsiCallStatus -> handleJitsiCallJoinStatus(action) + is RoomDetailAction.JoinJitsiCall -> handleJoinJitsiCall() + is RoomDetailAction.LeaveJitsiCall -> handleLeaveJitsiCall() + is RoomDetailAction.RemoveWidget -> handleDeleteWidget(action.widgetId) + is RoomDetailAction.EnsureNativeWidgetAllowed -> handleCheckWidgetAllowed(action) + is RoomDetailAction.CancelSend -> handleCancel(action) + is RoomDetailAction.JumpToReadReceipt -> handleJumpToReadReceipt(action) + RoomDetailAction.QuickActionInvitePeople -> handleInvitePeople() + RoomDetailAction.QuickActionSetAvatar -> handleQuickSetAvatar() + is RoomDetailAction.SetAvatarAction -> handleSetNewAvatar(action) + RoomDetailAction.QuickActionSetTopic -> _viewEvents.post(RoomDetailViewEvents.OpenRoomSettings) + is RoomDetailAction.ShowRoomAvatarFullScreen -> { _viewEvents.post( RoomDetailViewEvents.ShowRoomAvatarFullScreen(action.matrixItem, action.transitionView) ) } - is RoomDetailAction.DoNotShowPreviewUrlFor -> handleDoNotShowPreviewUrlFor(action) - RoomDetailAction.RemoveAllFailedMessages -> handleRemoveAllFailedMessages() - RoomDetailAction.ResendAll -> handleResendAll() - is RoomDetailAction.RoomUpgradeSuccess -> { + is RoomDetailAction.DoNotShowPreviewUrlFor -> handleDoNotShowPreviewUrlFor(action) + RoomDetailAction.RemoveAllFailedMessages -> handleRemoveAllFailedMessages() + RoomDetailAction.ResendAll -> handleResendAll() + is RoomDetailAction.RoomUpgradeSuccess -> { setState { copy(joinUpgradedRoomAsync = Success(action.replacementRoomId)) } _viewEvents.post(RoomDetailViewEvents.OpenRoom(action.replacementRoomId, closeCurrentRoom = true)) } - is RoomDetailAction.EndPoll -> handleEndPoll(action.eventId) - RoomDetailAction.StopLiveLocationSharing -> handleStopLiveLocationSharing() + is RoomDetailAction.EndPoll -> handleEndPoll(action.eventId) + RoomDetailAction.StopLiveLocationSharing -> handleStopLiveLocationSharing() } } @@ -469,7 +469,7 @@ class TimelineViewModel @AssistedInject constructor( is ConferenceEvent.Terminated -> { setState { copy(jitsiState = jitsiState.copy(hasJoined = activeConferenceHolder.isJoined(jitsiState.confId))) } } - else -> Unit + else -> Unit } } @@ -604,7 +604,7 @@ class TimelineViewModel @AssistedInject constructor( is Success -> { Success(activeRoomWidgets.invoke().filter { it.widgetId != widgetId }) } - else -> activeRoomWidgets + else -> activeRoomWidgets } ) } @@ -725,21 +725,21 @@ class TimelineViewModel @AssistedInject constructor( R.id.menu_thread_timeline_view_in_room, R.id.menu_thread_timeline_copy_link, R.id.menu_thread_timeline_share -> true - else -> false + else -> false } } else { when (itemId) { - R.id.timeline_setting -> true - R.id.invite -> state.canInvite - R.id.open_matrix_apps -> true - R.id.voice_call -> state.isCallOptionAvailable() - R.id.video_call -> state.isCallOptionAvailable() || state.jitsiState.confId == null || state.jitsiState.hasJoined + R.id.timeline_setting -> true + R.id.invite -> state.canInvite + R.id.open_matrix_apps -> true + R.id.voice_call -> state.isCallOptionAvailable() + R.id.video_call -> state.isCallOptionAvailable() || state.jitsiState.confId == null || state.jitsiState.hasJoined // Show Join conference button only if there is an active conf id not joined. Otherwise fallback to default video disabled. ^ - R.id.join_conference -> !state.isCallOptionAvailable() && state.jitsiState.confId != null && !state.jitsiState.hasJoined - R.id.search -> state.isSearchAvailable() + R.id.join_conference -> !state.isCallOptionAvailable() && state.jitsiState.confId != null && !state.jitsiState.hasJoined + R.id.search -> state.isSearchAvailable() R.id.menu_timeline_thread_list -> vectorPreferences.areThreadMessagesEnabled() - R.id.dev_tools -> vectorPreferences.developerMode() - else -> false + R.id.dev_tools -> vectorPreferences.developerMode() + else -> false } } } @@ -917,9 +917,9 @@ class TimelineViewModel @AssistedInject constructor( return } when { - it.root.isTextMessage() -> room.sendService().resendTextMessage(it) + it.root.isTextMessage() -> room.sendService().resendTextMessage(it) it.root.isAttachmentMessage() -> room.sendService().resendMediaMessage(it) - else -> { + else -> { // TODO } } @@ -1088,7 +1088,7 @@ class TimelineViewModel @AssistedInject constructor( MXCryptoError.ErrorType.KEYS_WITHHELD -> { WithHeldCode.fromCode(it.root.mCryptoErrorReason) } - else -> null + else -> null } _viewEvents.post(RoomDetailViewEvents.ShowE2EErrorMessage(code)) @@ -1154,9 +1154,9 @@ class TimelineViewModel @AssistedInject constructor( when { previous is UnreadState.Unknown || previous is UnreadState.ReadMarkerNotLoaded -> false previous is UnreadState.HasUnread && current is UnreadState.HasUnread && - previous.readMarkerId == current.readMarkerId -> false - current is UnreadState.HasUnread || current is UnreadState.HasNoUnread -> true - else -> false + previous.readMarkerId == current.readMarkerId -> false + current is UnreadState.HasUnread || current is UnreadState.HasNoUnread -> true + else -> false } } .setOnEach { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt index eca5c846ca..53f89603ff 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewModel.kt @@ -96,26 +96,26 @@ class MessageComposerViewModel @AssistedInject constructor( override fun handle(action: MessageComposerAction) { when (action) { - is MessageComposerAction.EnterEditMode -> handleEnterEditMode(action) - is MessageComposerAction.EnterQuoteMode -> handleEnterQuoteMode(action) - is MessageComposerAction.EnterRegularMode -> handleEnterRegularMode(action) - is MessageComposerAction.EnterReplyMode -> handleEnterReplyMode(action) - is MessageComposerAction.SendMessage -> handleSendMessage(action) - is MessageComposerAction.UserIsTyping -> handleUserIsTyping(action) - is MessageComposerAction.OnTextChanged -> handleOnTextChanged(action) + is MessageComposerAction.EnterEditMode -> handleEnterEditMode(action) + is MessageComposerAction.EnterQuoteMode -> handleEnterQuoteMode(action) + is MessageComposerAction.EnterRegularMode -> handleEnterRegularMode(action) + is MessageComposerAction.EnterReplyMode -> handleEnterReplyMode(action) + is MessageComposerAction.SendMessage -> handleSendMessage(action) + is MessageComposerAction.UserIsTyping -> handleUserIsTyping(action) + is MessageComposerAction.OnTextChanged -> handleOnTextChanged(action) is MessageComposerAction.OnVoiceRecordingUiStateChanged -> handleOnVoiceRecordingUiStateChanged(action) - is MessageComposerAction.StartRecordingVoiceMessage -> handleStartRecordingVoiceMessage() - is MessageComposerAction.EndRecordingVoiceMessage -> handleEndRecordingVoiceMessage(action.isCancelled, action.rootThreadEventId) - is MessageComposerAction.PlayOrPauseVoicePlayback -> handlePlayOrPauseVoicePlayback(action) - MessageComposerAction.PauseRecordingVoiceMessage -> handlePauseRecordingVoiceMessage() - MessageComposerAction.PlayOrPauseRecordingPlayback -> handlePlayOrPauseRecordingPlayback() - is MessageComposerAction.EndAllVoiceActions -> handleEndAllVoiceActions(action.deleteRecord) - is MessageComposerAction.InitializeVoiceRecorder -> handleInitializeVoiceRecorder(action.attachmentData) - is MessageComposerAction.OnEntersBackground -> handleEntersBackground(action.composerText) - is MessageComposerAction.VoiceWaveformTouchedUp -> handleVoiceWaveformTouchedUp(action) - is MessageComposerAction.VoiceWaveformMovedTo -> handleVoiceWaveformMovedTo(action) - is MessageComposerAction.AudioSeekBarMovedTo -> handleAudioSeekBarMovedTo(action) - is MessageComposerAction.SlashCommandConfirmed -> handleSlashCommandConfirmed(action) + is MessageComposerAction.StartRecordingVoiceMessage -> handleStartRecordingVoiceMessage() + is MessageComposerAction.EndRecordingVoiceMessage -> handleEndRecordingVoiceMessage(action.isCancelled, action.rootThreadEventId) + is MessageComposerAction.PlayOrPauseVoicePlayback -> handlePlayOrPauseVoicePlayback(action) + MessageComposerAction.PauseRecordingVoiceMessage -> handlePauseRecordingVoiceMessage() + MessageComposerAction.PlayOrPauseRecordingPlayback -> handlePlayOrPauseRecordingPlayback() + is MessageComposerAction.EndAllVoiceActions -> handleEndAllVoiceActions(action.deleteRecord) + is MessageComposerAction.InitializeVoiceRecorder -> handleInitializeVoiceRecorder(action.attachmentData) + is MessageComposerAction.OnEntersBackground -> handleEntersBackground(action.composerText) + is MessageComposerAction.VoiceWaveformTouchedUp -> handleVoiceWaveformTouchedUp(action) + is MessageComposerAction.VoiceWaveformMovedTo -> handleVoiceWaveformMovedTo(action) + is MessageComposerAction.AudioSeekBarMovedTo -> handleAudioSeekBarMovedTo(action) + is MessageComposerAction.SlashCommandConfirmed -> handleSlashCommandConfirmed(action) } } @@ -205,7 +205,7 @@ class MessageComposerViewModel @AssistedInject constructor( textMessage = action.text, isInThreadTimeline = state.isInThreadTimeline() )) { - is ParsedCommand.ErrorNotACommand -> { + is ParsedCommand.ErrorNotACommand -> { // Send the text message to the room if (state.rootThreadEventId != null) { room.relationService().replyInThread( @@ -220,19 +220,19 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.MessageSent) popDraft() } - is ParsedCommand.ErrorSyntax -> { + is ParsedCommand.ErrorSyntax -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandError(parsedCommand.command)) } - is ParsedCommand.ErrorEmptySlashCommand -> { + is ParsedCommand.ErrorEmptySlashCommand -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandUnknown("/")) } - is ParsedCommand.ErrorUnknownSlashCommand -> { + is ParsedCommand.ErrorUnknownSlashCommand -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandUnknown(parsedCommand.slashCommand)) } is ParsedCommand.ErrorCommandNotSupportedInThreads -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandNotSupportedInThreads(parsedCommand.command)) } - is ParsedCommand.SendPlainText -> { + is ParsedCommand.SendPlainText -> { // Send the text message to the room, without markdown if (state.rootThreadEventId != null) { room.relationService().replyInThread( @@ -246,50 +246,50 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.MessageSent) popDraft() } - is ParsedCommand.ChangeRoomName -> { + is ParsedCommand.ChangeRoomName -> { handleChangeRoomNameSlashCommand(parsedCommand) } - is ParsedCommand.Invite -> { + is ParsedCommand.Invite -> { handleInviteSlashCommand(parsedCommand) } - is ParsedCommand.Invite3Pid -> { + is ParsedCommand.Invite3Pid -> { handleInvite3pidSlashCommand(parsedCommand) } - is ParsedCommand.SetUserPowerLevel -> { + is ParsedCommand.SetUserPowerLevel -> { handleSetUserPowerLevel(parsedCommand) } - is ParsedCommand.ClearScalarToken -> { + is ParsedCommand.ClearScalarToken -> { // TODO _viewEvents.post(MessageComposerViewEvents.SlashCommandNotImplemented) } - is ParsedCommand.SetMarkdown -> { + is ParsedCommand.SetMarkdown -> { vectorPreferences.setMarkdownEnabled(parsedCommand.enable) _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.BanUser -> { + is ParsedCommand.BanUser -> { handleBanSlashCommand(parsedCommand) } - is ParsedCommand.UnbanUser -> { + is ParsedCommand.UnbanUser -> { handleUnbanSlashCommand(parsedCommand) } - is ParsedCommand.IgnoreUser -> { + is ParsedCommand.IgnoreUser -> { handleIgnoreSlashCommand(parsedCommand) } - is ParsedCommand.UnignoreUser -> { + is ParsedCommand.UnignoreUser -> { handleUnignoreSlashCommand(parsedCommand) } - is ParsedCommand.RemoveUser -> { + is ParsedCommand.RemoveUser -> { handleRemoveSlashCommand(parsedCommand) } - is ParsedCommand.JoinRoom -> { + is ParsedCommand.JoinRoom -> { handleJoinToAnotherRoomSlashCommand(parsedCommand) popDraft() } - is ParsedCommand.PartRoom -> { + is ParsedCommand.PartRoom -> { handlePartSlashCommand(parsedCommand) } - is ParsedCommand.SendEmote -> { + is ParsedCommand.SendEmote -> { if (state.rootThreadEventId != null) { room.relationService().replyInThread( rootThreadEventId = state.rootThreadEventId, @@ -307,7 +307,7 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.SendRainbow -> { + is ParsedCommand.SendRainbow -> { val message = parsedCommand.message.toString() if (state.rootThreadEventId != null) { room.relationService().replyInThread( @@ -321,7 +321,7 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.SendRainbowEmote -> { + is ParsedCommand.SendRainbowEmote -> { val message = parsedCommand.message.toString() if (state.rootThreadEventId != null) { room.relationService().replyInThread( @@ -337,7 +337,7 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.SendSpoiler -> { + is ParsedCommand.SendSpoiler -> { val text = "[${stringProvider.getString(R.string.spoiler)}](${parsedCommand.message})" val formattedText = "${parsedCommand.message}" if (state.rootThreadEventId != null) { @@ -355,42 +355,42 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.SendShrug -> { + is ParsedCommand.SendShrug -> { sendPrefixedMessage("¯\\_(ツ)_/¯", parsedCommand.message, state.rootThreadEventId) _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.SendLenny -> { + is ParsedCommand.SendLenny -> { sendPrefixedMessage("( ͡° ͜ʖ ͡°)", parsedCommand.message, state.rootThreadEventId) _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.SendChatEffect -> { + is ParsedCommand.SendChatEffect -> { sendChatEffect(parsedCommand) _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) popDraft() } - is ParsedCommand.ChangeTopic -> { + is ParsedCommand.ChangeTopic -> { handleChangeTopicSlashCommand(parsedCommand) } - is ParsedCommand.ChangeDisplayName -> { + is ParsedCommand.ChangeDisplayName -> { handleChangeDisplayNameSlashCommand(parsedCommand) } - is ParsedCommand.ChangeDisplayNameForRoom -> { + is ParsedCommand.ChangeDisplayNameForRoom -> { handleChangeDisplayNameForRoomSlashCommand(parsedCommand) } - is ParsedCommand.ChangeRoomAvatar -> { + is ParsedCommand.ChangeRoomAvatar -> { handleChangeRoomAvatarSlashCommand(parsedCommand) } - is ParsedCommand.ChangeAvatarForRoom -> { + is ParsedCommand.ChangeAvatarForRoom -> { handleChangeAvatarForRoomSlashCommand(parsedCommand) } - is ParsedCommand.ShowUser -> { + is ParsedCommand.ShowUser -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) handleWhoisSlashCommand(parsedCommand) popDraft() } - is ParsedCommand.DiscardSession -> { + is ParsedCommand.DiscardSession -> { if (room.roomCryptoService().isEncrypted()) { session.cryptoService().discardOutboundSession(room.roomId) _viewEvents.post(MessageComposerViewEvents.SlashCommandResultOk(parsedCommand)) @@ -403,7 +403,7 @@ class MessageComposerViewModel @AssistedInject constructor( ) } } - is ParsedCommand.CreateSpace -> { + is ParsedCommand.CreateSpace -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandLoading) viewModelScope.launch(Dispatchers.IO) { try { @@ -427,7 +427,7 @@ class MessageComposerViewModel @AssistedInject constructor( } Unit } - is ParsedCommand.AddToSpace -> { + is ParsedCommand.AddToSpace -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandLoading) viewModelScope.launch(Dispatchers.IO) { try { @@ -446,7 +446,7 @@ class MessageComposerViewModel @AssistedInject constructor( } Unit } - is ParsedCommand.JoinSpace -> { + is ParsedCommand.JoinSpace -> { _viewEvents.post(MessageComposerViewEvents.SlashCommandLoading) viewModelScope.launch(Dispatchers.IO) { try { @@ -459,7 +459,7 @@ class MessageComposerViewModel @AssistedInject constructor( } Unit } - is ParsedCommand.LeaveRoom -> { + is ParsedCommand.LeaveRoom -> { viewModelScope.launch(Dispatchers.IO) { try { session.roomService().leaveRoom(parsedCommand.roomId) @@ -471,7 +471,7 @@ class MessageComposerViewModel @AssistedInject constructor( } Unit } - is ParsedCommand.UpgradeRoom -> { + is ParsedCommand.UpgradeRoom -> { _viewEvents.post( MessageComposerViewEvents.ShowRoomUpgradeDialog( parsedCommand.newVersion, @@ -483,7 +483,7 @@ class MessageComposerViewModel @AssistedInject constructor( } } } - is SendMode.Edit -> { + is SendMode.Edit -> { // is original event a reply? val relationContent = state.sendMode.timelineEvent.getRelationContent() val inReplyTo = if (state.rootThreadEventId != null) { @@ -522,7 +522,7 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.MessageSent) popDraft() } - is SendMode.Quote -> { + is SendMode.Quote -> { room.sendService().sendQuotedTextMessage( quotedEvent = state.sendMode.timelineEvent, text = action.text.toString(), @@ -532,7 +532,7 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.MessageSent) popDraft() } - is SendMode.Reply -> { + is SendMode.Reply -> { val timelineEvent = state.sendMode.timelineEvent val showInThread = state.sendMode.timelineEvent.root.isThread() && state.rootThreadEventId == null // If threads are disabled this will make the fallback replies visible to clients with threads enabled @@ -555,7 +555,7 @@ class MessageComposerViewModel @AssistedInject constructor( _viewEvents.post(MessageComposerViewEvents.MessageSent) popDraft() } - is SendMode.Voice -> { + is SendMode.Voice -> { // do nothing } } @@ -582,23 +582,23 @@ class MessageComposerViewModel @AssistedInject constructor( // Create a sendMode from a draft and retrieve the TimelineEvent sendMode = when (currentDraft) { is UserDraft.Regular -> SendMode.Regular(currentDraft.content, false) - is UserDraft.Quote -> { + is UserDraft.Quote -> { room.getTimelineEvent(currentDraft.linkedEventId)?.let { timelineEvent -> SendMode.Quote(timelineEvent, currentDraft.content) } } - is UserDraft.Reply -> { + is UserDraft.Reply -> { room.getTimelineEvent(currentDraft.linkedEventId)?.let { timelineEvent -> SendMode.Reply(timelineEvent, currentDraft.content) } } - is UserDraft.Edit -> { + is UserDraft.Edit -> { room.getTimelineEvent(currentDraft.linkedEventId)?.let { timelineEvent -> SendMode.Edit(timelineEvent, currentDraft.content) } } - is UserDraft.Voice -> SendMode.Voice(currentDraft.content) - else -> null + is UserDraft.Voice -> SendMode.Voice(currentDraft.content) + else -> null } ?: SendMode.Regular("", fromSharing = false) ) } @@ -790,7 +790,7 @@ class MessageComposerViewModel @AssistedInject constructor( private fun handleSlashCommandConfirmed(action: MessageComposerAction.SlashCommandConfirmed) { when (action.parsedCommand) { is ParsedCommand.UnignoreUser -> handleUnignoreSlashCommandConfirmed(action.parsedCommand) - else -> TODO("Not handled yet") + else -> TODO("Not handled yet") } } @@ -827,15 +827,15 @@ class MessageComposerViewModel @AssistedInject constructor( setState { copy(sendMode = it.sendMode.copy(text = draft)) } room.draftService().saveDraft(UserDraft.Regular(draft)) } - it.sendMode is SendMode.Reply -> { + it.sendMode is SendMode.Reply -> { setState { copy(sendMode = it.sendMode.copy(text = draft)) } room.draftService().saveDraft(UserDraft.Reply(it.sendMode.timelineEvent.root.eventId!!, draft)) } - it.sendMode is SendMode.Quote -> { + it.sendMode is SendMode.Quote -> { setState { copy(sendMode = it.sendMode.copy(text = draft)) } room.draftService().saveDraft(UserDraft.Quote(it.sendMode.timelineEvent.root.eventId!!, draft)) } - it.sendMode is SendMode.Edit -> { + it.sendMode is SendMode.Edit -> { setState { copy(sendMode = it.sendMode.copy(text = draft)) } room.draftService().saveDraft(UserDraft.Edit(it.sendMode.timelineEvent.root.eventId!!, draft)) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewState.kt index 75a6c1e912..5698414ab4 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/MessageComposerViewState.kt @@ -53,8 +53,8 @@ sealed interface CanSendStatus { fun CanSendStatus.boolean(): Boolean { return when (this) { - CanSendStatus.Allowed -> true - CanSendStatus.NoPermission -> false + CanSendStatus.Allowed -> true + CanSendStatus.NoPermission -> false is CanSendStatus.UnSupportedE2eAlgorithm -> false } } @@ -70,7 +70,7 @@ data class MessageComposerViewState( ) : MavericksState { val isVoiceRecording = when (voiceRecordingUiState) { - VoiceMessageRecorderView.RecordingUiState.Idle -> false + VoiceMessageRecorderView.RecordingUiState.Idle -> false is VoiceMessageRecorderView.RecordingUiState.Locked, VoiceMessageRecorderView.RecordingUiState.Draft, is VoiceMessageRecorderView.RecordingUiState.Recording -> true diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/DraggableStateProcessor.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/DraggableStateProcessor.kt index 088070ceb9..1355c89006 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/DraggableStateProcessor.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/DraggableStateProcessor.kt @@ -56,28 +56,28 @@ class DraggableStateProcessor( private fun DraggingState.nextDragState(currentX: Float, currentY: Float, distanceX: Float, distanceY: Float): DraggingState { return when (this) { - DraggingState.Ready -> { + DraggingState.Ready -> { when { isDraggingToCancel(currentX, distanceX, distanceY) -> DraggingState.Cancelling(distanceX) - isDraggingToLock(currentY, distanceX, distanceY) -> DraggingState.Locking(distanceY) - else -> DraggingState.Ready + isDraggingToLock(currentY, distanceX, distanceY) -> DraggingState.Locking(distanceY) + else -> DraggingState.Ready } } is DraggingState.Cancelling -> { when { isDraggingToLock(currentY, distanceX, distanceY) -> DraggingState.Locking(distanceY) - shouldCancelRecording(distanceX) -> DraggingState.Cancel - else -> DraggingState.Cancelling(distanceX) + shouldCancelRecording(distanceX) -> DraggingState.Cancel + else -> DraggingState.Cancelling(distanceX) } } - is DraggingState.Locking -> { + is DraggingState.Locking -> { when { isDraggingToCancel(currentX, distanceX, distanceY) -> DraggingState.Cancelling(distanceX) - shouldLockRecording(distanceY) -> DraggingState.Lock - else -> DraggingState.Locking(distanceY) + shouldLockRecording(distanceY) -> DraggingState.Lock + else -> DraggingState.Locking(distanceY) } } - else -> { + else -> { this } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt index 4350ad6a7d..536a582ec1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageRecorderView.kt @@ -84,12 +84,12 @@ class VoiceMessageRecorderView @JvmOverloads constructor( override fun onRequestRecording() = callback.onVoiceRecordingStarted() override fun onMicButtonReleased() { when (dragState) { - DraggingState.Lock -> { + DraggingState.Lock -> { // do nothing, // onSendVoiceMessage, onDeleteVoiceMessage or onRecordingLimitReached will be triggered instead } DraggingState.Cancel -> callback.onVoiceRecordingCancelled() - else -> callback.onVoiceRecordingEnded() + else -> callback.onVoiceRecordingEnded() } } @@ -99,7 +99,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( when (lastKnownState) { is RecordingUiState.Recording, is RecordingUiState.Locked -> callback.onRecordingWaveformClicked() - else -> Unit + else -> Unit } } @@ -133,7 +133,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( fun render(recordingState: RecordingUiState) { if (lastKnownState == recordingState) return when (recordingState) { - RecordingUiState.Idle -> { + RecordingUiState.Idle -> { reset() } is RecordingUiState.Recording -> { @@ -142,7 +142,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( voiceMessageViews.showRecordingViews() dragState = DraggingState.Ready } - is RecordingUiState.Locked -> { + is RecordingUiState.Locked -> { if (lastKnownState == null) { startRecordingTicker(startFromLocked = true, startAt = recordingState.recordingStartTimestamp) } @@ -151,7 +151,7 @@ class VoiceMessageRecorderView @JvmOverloads constructor( voiceMessageViews.showRecordingLockedViews(recordingState) }, 500) } - RecordingUiState.Draft -> { + RecordingUiState.Draft -> { stopRecordingTicker() voiceMessageViews.showDraftViews() } @@ -169,16 +169,16 @@ class VoiceMessageRecorderView @JvmOverloads constructor( if (currentDragState == newDragState) return when (newDragState) { is DraggingState.Cancelling -> voiceMessageViews.renderCancelling(newDragState.distanceX) - is DraggingState.Locking -> { + is DraggingState.Locking -> { if (currentDragState is DraggingState.Cancelling) { voiceMessageViews.showRecordingViews() } voiceMessageViews.renderLocking(newDragState.distanceY) } - DraggingState.Cancel -> callback.onVoiceRecordingCancelled() - DraggingState.Lock -> callback.onVoiceRecordingLocked() + DraggingState.Cancel -> callback.onVoiceRecordingCancelled() + DraggingState.Lock -> callback.onVoiceRecordingLocked() DraggingState.Ignored, - DraggingState.Ready -> { + DraggingState.Ready -> { // do nothing } } @@ -227,11 +227,11 @@ class VoiceMessageRecorderView @JvmOverloads constructor( is AudioMessagePlaybackTracker.Listener.State.Recording -> { voiceMessageViews.renderRecordingWaveform(state.amplitudeList.toList()) } - is AudioMessagePlaybackTracker.Listener.State.Playing -> { + is AudioMessagePlaybackTracker.Listener.State.Playing -> { voiceMessageViews.renderPlaying(state) } is AudioMessagePlaybackTracker.Listener.State.Paused, - is AudioMessagePlaybackTracker.Listener.State.Idle -> { + is AudioMessagePlaybackTracker.Listener.State.Idle -> { voiceMessageViews.renderIdle() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt index 0a093221a6..1eac3b440a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/composer/voice/VoiceMessageViews.kt @@ -65,7 +65,7 @@ class VoiceMessageViews( MotionEvent.ACTION_DOWN -> { actions.onWaveformClicked() } - MotionEvent.ACTION_UP -> { + MotionEvent.ACTION_UP -> { val percentage = getTouchedPositionPercentage(motionEvent, view) actions.onVoiceWaveformTouchedUp(percentage) } @@ -95,7 +95,7 @@ class VoiceMessageViews( actions.onRequestRecording() true } - MotionEvent.ACTION_UP -> { + MotionEvent.ACTION_UP -> { actions.onMicButtonReleased() true } @@ -103,7 +103,7 @@ class VoiceMessageViews( actions.onMicButtonDrag { currentState -> draggableStateProcessor.process(event, currentState) } true } - else -> false + else -> false } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchFragment.kt index 011258f126..de51adf05a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchFragment.kt @@ -92,7 +92,7 @@ class SearchFragment @Inject constructor( is Loading -> { views.stateView.state = StateView.State.Loading } - is Fail -> { + is Fail -> { views.stateView.state = StateView.State.Error(errorFormatter.toHumanReadable(state.asyncSearchRequest.error)) } is Success -> { @@ -101,7 +101,7 @@ class SearchFragment @Inject constructor( image = ContextCompat.getDrawable(requireContext(), R.drawable.ic_search_no_results) ) } - else -> Unit + else -> Unit } } else { controller.setData(state) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewModel.kt index 561023401f..159915ea90 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewModel.kt @@ -54,8 +54,8 @@ class SearchViewModel @AssistedInject constructor( override fun handle(action: SearchAction) { when (action) { is SearchAction.SearchWith -> handleSearchWith(action) - is SearchAction.LoadMore -> handleLoadMore() - is SearchAction.Retry -> handleRetry() + is SearchAction.LoadMore -> handleLoadMore() + is SearchAction.Retry -> handleRetry() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/MessageColorProvider.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/MessageColorProvider.kt index 8214029a3a..8b03185293 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/MessageColorProvider.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/MessageColorProvider.kt @@ -42,11 +42,11 @@ class MessageColorProvider @Inject constructor( when (sendState) { // SendStates, in the classical order they will occur SendState.UNKNOWN, - SendState.UNSENT -> colorProvider.getColorFromAttribute(R.attr.vctr_sending_message_text_color) - SendState.ENCRYPTING -> colorProvider.getColorFromAttribute(R.attr.vctr_encrypting_message_text_color) - SendState.SENDING -> colorProvider.getColorFromAttribute(R.attr.vctr_sending_message_text_color) + SendState.UNSENT -> colorProvider.getColorFromAttribute(R.attr.vctr_sending_message_text_color) + SendState.ENCRYPTING -> colorProvider.getColorFromAttribute(R.attr.vctr_encrypting_message_text_color) + SendState.SENDING -> colorProvider.getColorFromAttribute(R.attr.vctr_sending_message_text_color) SendState.SENT, - SendState.SYNCED -> colorProvider.getColorFromAttribute(R.attr.vctr_message_text_color) + SendState.SYNCED -> colorProvider.getColorFromAttribute(R.attr.vctr_message_text_color) SendState.UNDELIVERED, SendState.FAILED_UNKNOWN_DEVICES -> colorProvider.getColorFromAttribute(R.attr.vctr_unsent_message_text_color) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt index ade08fdfed..d918703f95 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsEpoxyController.kt @@ -126,7 +126,7 @@ class MessageActionsEpoxyController @Inject constructor( } when (state.informationData.e2eDecoration) { - E2EDecoration.WARN_IN_CLEAR -> { + E2EDecoration.WARN_IN_CLEAR -> { bottomSheetSendStateItem { id("e2e_clear") showProgress(false) @@ -143,7 +143,7 @@ class MessageActionsEpoxyController @Inject constructor( drawableStart(R.drawable.ic_shield_warning_small) } } - else -> { + else -> { // nothing } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt index 6473191669..47f26d3fb1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/action/MessageActionsViewModel.kt @@ -183,7 +183,7 @@ class MessageActionsViewModel @AssistedInject constructor( } else { when (timelineEvent.root.getClearType()) { EventType.MESSAGE, - EventType.STICKER -> { + EventType.STICKER -> { val messageContent: MessageContent? = timelineEvent.getLastMessageContent() if (messageContent is MessageTextContent && messageContent.format == MessageFormat.FORMAT_MATRIX_HTML) { val html = messageContent.formattedBody @@ -209,14 +209,14 @@ class MessageActionsViewModel @AssistedInject constructor( EventType.CALL_INVITE, EventType.CALL_CANDIDATES, EventType.CALL_HANGUP, - EventType.CALL_ANSWER -> { + EventType.CALL_ANSWER -> { noticeEventFormatter.format(timelineEvent, room?.roomSummary()?.isDirect.orFalse()) } in EventType.POLL_START -> { timelineEvent.root.getClearContent().toModel(catchError = true) ?.getBestPollCreationInfo()?.question?.getBestQuestion() ?: "" } - else -> null + else -> null } } } catch (failure: Throwable) { @@ -255,16 +255,16 @@ class MessageActionsViewModel @AssistedInject constructor( return arrayListOf().apply { when { - timelineEvent.root.sendState.hasFailed() -> { + timelineEvent.root.sendState.hasFailed() -> { addActionsForFailedState(timelineEvent, actionPermissions, messageContent, msgType) } - timelineEvent.root.sendState.isSending() -> { + timelineEvent.root.sendState.isSending() -> { addActionsForSendingState(timelineEvent) } timelineEvent.root.sendState == SendState.SYNCED -> { addActionsForSyncedState(timelineEvent, actionPermissions, messageContent, msgType) } - timelineEvent.root.sendState == SendState.SENT -> { + timelineEvent.root.sendState == SendState.SENT -> { addActionsForSentNotSyncedState(timelineEvent) } } @@ -448,7 +448,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_FILE, MessageType.MSGTYPE_POLL_START, MessageType.MSGTYPE_LOCATION -> true - else -> false + else -> false } } @@ -482,7 +482,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_FILE, MessageType.MSGTYPE_POLL_START, MessageType.MSGTYPE_STICKER_LOCAL -> true - else -> false + else -> false } } @@ -510,7 +510,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_FILE, MessageType.MSGTYPE_POLL_START, MessageType.MSGTYPE_STICKER_LOCAL -> event.root.threadDetails?.isRootThread ?: false - else -> false + else -> false } } @@ -525,7 +525,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_LOCATION -> { true } - else -> false + else -> false } } @@ -569,7 +569,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_NOTICE, MessageType.MSGTYPE_EMOTE, MessageType.MSGTYPE_LOCATION -> true - else -> false + else -> false } } @@ -583,7 +583,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_AUDIO, MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_FILE -> true - else -> false + else -> false } } @@ -593,7 +593,7 @@ class MessageActionsViewModel @AssistedInject constructor( MessageType.MSGTYPE_AUDIO, MessageType.MSGTYPE_VIDEO, MessageType.MSGTYPE_FILE -> true - else -> false + else -> false } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryEpoxyController.kt index b92548dd5e..52ecc6d588 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryEpoxyController.kt @@ -63,7 +63,7 @@ class ViewEditHistoryEpoxyController @Inject constructor( id("Spinner") } } - is Fail -> { + is Fail -> { genericFooterItem { id("failure") text(host.stringProvider.getString(R.string.unknown_error).toEpoxyCharSequence()) @@ -127,7 +127,7 @@ class ViewEditHistoryEpoxyController @Inject constructor( textColor = colorProvider.getColor(R.color.palette_element_green) } } - else -> { + else -> { span { text = it.text } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt index 6f955b656b..360dbc3fbe 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt @@ -120,7 +120,7 @@ class CallItemFactory @Inject constructor( reactionsSummaryEvents = params.reactionsSummaryEvents ) } - else -> null + else -> null } return if (callItem == null && showHiddenEvents) { // Fallback to notice item for showing hidden events diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt index ebfb318cc9..4bc68c10aa 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt @@ -91,7 +91,7 @@ class EncryptedItemFactory @Inject constructor( } } } - else -> { + else -> { span { drawableProvider.getDrawable(R.drawable.ic_clock, colorFromAttribute)?.let { image(it, "baseline") @@ -124,7 +124,7 @@ class EncryptedItemFactory @Inject constructor( .message(spannableStr.toEpoxyCharSequence()) .movementMethod(createLinkMovementMethod(params.callback)) } - else -> null + else -> null } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt index 479a742369..8629a3a47b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/LiveLocationShareMessageItemFactory.kt @@ -57,10 +57,10 @@ class LiveLocationShareMessageItemFactory @Inject constructor( ): VectorEpoxyModel<*>? { val liveLocationShareSummaryData = getLiveLocationShareSummaryData(event) val item = when (val currentState = getViewState(liveLocationShareSummaryData)) { - LiveLocationShareViewState.Inactive -> buildInactiveItem(highlight, attributes) - LiveLocationShareViewState.Loading -> buildLoadingItem(highlight, attributes) + LiveLocationShareViewState.Inactive -> buildInactiveItem(highlight, attributes) + LiveLocationShareViewState.Loading -> buildLoadingItem(highlight, attributes) is LiveLocationShareViewState.Running -> buildRunningItem(highlight, attributes, currentState) - LiveLocationShareViewState.Unkwown -> null + LiveLocationShareViewState.Unkwown -> null } item?.layout(attributes.informationData.messageLayout.layoutRes) @@ -126,10 +126,10 @@ class LiveLocationShareMessageItemFactory @Inject constructor( private fun getViewState(liveLocationShareSummaryData: LiveLocationShareSummaryData?): LiveLocationShareViewState { return when { - liveLocationShareSummaryData?.isActive == null -> LiveLocationShareViewState.Unkwown - liveLocationShareSummaryData.isActive.not() || isLiveTimedOut(liveLocationShareSummaryData) -> LiveLocationShareViewState.Inactive + liveLocationShareSummaryData?.isActive == null -> LiveLocationShareViewState.Unkwown + liveLocationShareSummaryData.isActive.not() || isLiveTimedOut(liveLocationShareSummaryData) -> LiveLocationShareViewState.Inactive liveLocationShareSummaryData.isActive && liveLocationShareSummaryData.lastGeoUri.isNullOrEmpty() -> LiveLocationShareViewState.Loading - else -> + else -> LiveLocationShareViewState.Running( liveLocationShareSummaryData.lastGeoUri.orEmpty(), getEndOfLiveDateTime(liveLocationShareSummaryData) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt index e0316017f2..ef8c41975b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/MessageItemFactory.kt @@ -200,24 +200,24 @@ class MessageItemFactory @Inject constructor( // val all = event.root.toContent() // val ev = all.toModel() val messageItem = when (messageContent) { - is MessageEmoteContent -> buildEmoteMessageItem(messageContent, informationData, highlight, callback, attributes) - is MessageTextContent -> buildItemForTextContent(messageContent, informationData, highlight, callback, attributes) - is MessageImageInfoContent -> buildImageMessageItem(messageContent, informationData, highlight, callback, attributes) - is MessageNoticeContent -> buildNoticeMessageItem(messageContent, informationData, highlight, callback, attributes) - is MessageVideoContent -> buildVideoMessageItem(messageContent, informationData, highlight, callback, attributes) - is MessageFileContent -> buildFileMessageItem(messageContent, highlight, attributes) - is MessageAudioContent -> buildAudioContent(params, messageContent, informationData, highlight, attributes) + is MessageEmoteContent -> buildEmoteMessageItem(messageContent, informationData, highlight, callback, attributes) + is MessageTextContent -> buildItemForTextContent(messageContent, informationData, highlight, callback, attributes) + is MessageImageInfoContent -> buildImageMessageItem(messageContent, informationData, highlight, callback, attributes) + is MessageNoticeContent -> buildNoticeMessageItem(messageContent, informationData, highlight, callback, attributes) + is MessageVideoContent -> buildVideoMessageItem(messageContent, informationData, highlight, callback, attributes) + is MessageFileContent -> buildFileMessageItem(messageContent, highlight, attributes) + is MessageAudioContent -> buildAudioContent(params, messageContent, informationData, highlight, attributes) is MessageVerificationRequestContent -> buildVerificationRequestMessageItem(messageContent, informationData, highlight, callback, attributes) - is MessagePollContent -> buildPollItem(messageContent, informationData, highlight, callback, attributes) - is MessageLocationContent -> { + is MessagePollContent -> buildPollItem(messageContent, informationData, highlight, callback, attributes) + is MessageLocationContent -> { if (vectorPreferences.labsRenderLocationsInTimeline()) { buildLocationItem(messageContent, informationData, highlight, attributes) } else { buildMessageTextItem(messageContent.body, false, informationData, highlight, callback, attributes) } } - is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(params.event, highlight, attributes) - else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes) + is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(params.event, highlight, attributes) + else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes) } return messageItem?.apply { layout(informationData.messageLayout.layoutRes) @@ -283,11 +283,11 @@ class MessageItemFactory @Inject constructor( pollResponseSummary: PollResponseData?, pollContent: MessagePollContent, ): PollState = when { - !informationData.sendState.isSent() -> Sending - pollResponseSummary?.isClosed.orFalse() -> Ended + !informationData.sendState.isSent() -> Sending + pollResponseSummary?.isClosed.orFalse() -> Ended pollContent.getBestPollCreationInfo()?.kind == PollType.UNDISCLOSED -> Undisclosed - pollResponseSummary?.myVote?.isNotEmpty().orFalse() -> Voted(pollResponseSummary?.totalVotes ?: 0) - else -> Ready + pollResponseSummary?.myVote?.isNotEmpty().orFalse() -> Voted(pollResponseSummary?.totalVotes ?: 0) + else -> Ready } private fun List.mapToOptions( @@ -305,11 +305,11 @@ class MessageItemFactory @Inject constructor( val isWinner = winnerVoteCount != 0 && voteCount == winnerVoteCount when (pollState) { - Sending -> PollSending(optionId, optionAnswer) - Ready -> PollReady(optionId, optionAnswer) - is Voted -> PollVoted(optionId, optionAnswer, voteCount, votePercentage, isMyVote) + Sending -> PollSending(optionId, optionAnswer) + Ready -> PollReady(optionId, optionAnswer) + is Voted -> PollVoted(optionId, optionAnswer, voteCount, votePercentage, isMyVote) Undisclosed -> PollUndisclosed(optionId, optionAnswer, isMyVote) - Ended -> PollEnded(optionId, optionAnswer, voteCount, votePercentage, isWinner) + Ended -> PollEnded(optionId, optionAnswer, voteCount, votePercentage, isWinner) } } @@ -329,11 +329,11 @@ class MessageItemFactory @Inject constructor( ): String { val votes = pollResponseSummary?.totalVotes ?: 0 return when { - pollState is Ended -> stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, votes, votes) + pollState is Ended -> stringProvider.getQuantityString(R.plurals.poll_total_vote_count_after_ended, votes, votes) pollState is Undisclosed -> "" - pollState is Voted -> stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, votes, votes) - votes == 0 -> stringProvider.getString(R.string.poll_no_votes_cast) - else -> stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_not_voted, votes, votes) + pollState is Voted -> stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_voted, votes, votes) + votes == 0 -> stringProvider.getString(R.string.poll_no_votes_cast) + else -> stringProvider.getQuantityString(R.plurals.poll_total_vote_count_before_ended_and_not_voted, votes, votes) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt index 3f94c161d7..97ae3b634e 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/TimelineItemFactory.kt @@ -79,17 +79,17 @@ class TimelineItemFactory @Inject constructor( EventType.STATE_ROOM_ALIASES, EventType.STATE_SPACE_CHILD, EventType.STATE_SPACE_PARENT, - EventType.STATE_ROOM_POWER_LEVELS -> { + EventType.STATE_ROOM_POWER_LEVELS -> { noticeItemFactory.create(params) } EventType.STATE_ROOM_WIDGET_LEGACY, - EventType.STATE_ROOM_WIDGET -> widgetItemFactory.create(params) - EventType.STATE_ROOM_ENCRYPTION -> encryptionItemFactory.create(params) + EventType.STATE_ROOM_WIDGET -> widgetItemFactory.create(params) + EventType.STATE_ROOM_ENCRYPTION -> encryptionItemFactory.create(params) // State room create - EventType.STATE_ROOM_CREATE -> roomCreateItemFactory.create(params) + EventType.STATE_ROOM_CREATE -> roomCreateItemFactory.create(params) in EventType.STATE_ROOM_BEACON_INFO -> messageItemFactory.create(params) // Unhandled state event types - else -> { + else -> { // Should only happen when shouldShowHiddenEvents() settings is ON Timber.v("State event type ${event.root.type} not handled") defaultItemFactory.create(params) @@ -100,7 +100,7 @@ class TimelineItemFactory @Inject constructor( // Message itemsX EventType.STICKER, in EventType.POLL_START, - EventType.MESSAGE -> messageItemFactory.create(params) + EventType.MESSAGE -> messageItemFactory.create(params) EventType.REDACTION, EventType.KEY_VERIFICATION_ACCEPT, EventType.KEY_VERIFICATION_START, @@ -119,9 +119,9 @@ class TimelineItemFactory @Inject constructor( EventType.CALL_INVITE, EventType.CALL_HANGUP, EventType.CALL_REJECT, - EventType.CALL_ANSWER -> callItemFactory.create(params) + EventType.CALL_ANSWER -> callItemFactory.create(params) // Crypto - EventType.ENCRYPTED -> { + EventType.ENCRYPTED -> { if (event.root.isRedacted()) { // Redacted event, let the MessageItemFactory handle it messageItemFactory.create(params) @@ -130,11 +130,11 @@ class TimelineItemFactory @Inject constructor( } } EventType.KEY_VERIFICATION_CANCEL, - EventType.KEY_VERIFICATION_DONE -> { + EventType.KEY_VERIFICATION_DONE -> { verificationConclusionItemFactory.create(params) } // Unhandled event types - else -> { + else -> { // Should only happen when shouldShowHiddenEvents() settings is ON Timber.v("Type ${event.root.getClearType()} not handled") defaultItemFactory.create(params) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/VerificationItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/VerificationItemFactory.kt index e679b8d059..9a40cb6730 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/VerificationItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/VerificationItemFactory.kt @@ -109,10 +109,10 @@ class VerificationItemFactory @Inject constructor( .highlighted(params.isHighlighted) .leftGuideline(avatarSizeProvider.leftGuideline) } - else -> return ignoredConclusion(params) + else -> return ignoredConclusion(params) } } - EventType.KEY_VERIFICATION_DONE -> { + EventType.KEY_VERIFICATION_DONE -> { // Is the request referenced is actually really completed? if (referenceInformationData.referencesInfoData?.verificationStatus != VerificationState.DONE) { return ignoredConclusion(params) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt index 019028dfd4..e8017efe0b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt @@ -48,7 +48,7 @@ class WidgetItemFactory @Inject constructor( return when (WidgetType.fromString(widgetContent.type ?: previousWidgetContent?.type ?: "")) { WidgetType.Jitsi -> createJitsiItem(params, widgetContent) // There is lot of other widget types we could improve here - else -> noticeItemFactory.create(params) + else -> noticeItemFactory.create(params) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt index aeed9e0a41..7b9bd4530b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/DisplayableEventFormatter.kt @@ -59,10 +59,10 @@ class DisplayableEventFormatter @Inject constructor( val senderName = timelineEvent.senderInfo.disambiguatedDisplayName return when (timelineEvent.root.getClearType()) { - EventType.MESSAGE -> { + EventType.MESSAGE -> { timelineEvent.getLastMessageContent()?.let { messageContent -> when (messageContent.msgType) { - MessageType.MSGTYPE_TEXT -> { + MessageType.MSGTYPE_TEXT -> { val body = messageContent.getTextDisplayableContent() if (messageContent is MessageTextContent && messageContent.matrixFormattedBody.isNullOrBlank().not()) { val localFormattedBody = htmlRenderer.get().parse(body) as Document @@ -75,42 +75,42 @@ class DisplayableEventFormatter @Inject constructor( MessageType.MSGTYPE_VERIFICATION_REQUEST -> { simpleFormat(senderName, stringProvider.getString(R.string.verification_request), appendAuthor) } - MessageType.MSGTYPE_IMAGE -> { + MessageType.MSGTYPE_IMAGE -> { simpleFormat(senderName, stringProvider.getString(R.string.sent_an_image), appendAuthor) } - MessageType.MSGTYPE_AUDIO -> { + MessageType.MSGTYPE_AUDIO -> { if ((messageContent as? MessageAudioContent)?.voiceMessageIndicator != null) { simpleFormat(senderName, stringProvider.getString(R.string.sent_a_voice_message), appendAuthor) } else { simpleFormat(senderName, stringProvider.getString(R.string.sent_an_audio_file), appendAuthor) } } - MessageType.MSGTYPE_VIDEO -> { + MessageType.MSGTYPE_VIDEO -> { simpleFormat(senderName, stringProvider.getString(R.string.sent_a_video), appendAuthor) } - MessageType.MSGTYPE_FILE -> { + MessageType.MSGTYPE_FILE -> { simpleFormat(senderName, stringProvider.getString(R.string.sent_a_file), appendAuthor) } - MessageType.MSGTYPE_LOCATION -> { + MessageType.MSGTYPE_LOCATION -> { simpleFormat(senderName, stringProvider.getString(R.string.sent_location), appendAuthor) } - else -> { + else -> { simpleFormat(senderName, messageContent.body, appendAuthor) } } } ?: span { } } - EventType.STICKER -> { + EventType.STICKER -> { simpleFormat(senderName, stringProvider.getString(R.string.send_a_sticker), appendAuthor) } - EventType.REACTION -> { + EventType.REACTION -> { timelineEvent.root.getClearContent().toModel()?.relatesTo?.let { val emojiSpanned = emojiSpanify.spanify(stringProvider.getString(R.string.sent_a_reaction, it.key)) simpleFormat(senderName, emojiSpanned, appendAuthor) } ?: span { } } EventType.KEY_VERIFICATION_CANCEL, - EventType.KEY_VERIFICATION_DONE -> { + EventType.KEY_VERIFICATION_DONE -> { // cancel and done can appear in timeline, so should have representation simpleFormat(senderName, stringProvider.getString(R.string.sent_verification_conclusion), appendAuthor) } @@ -119,23 +119,23 @@ class DisplayableEventFormatter @Inject constructor( EventType.KEY_VERIFICATION_MAC, EventType.KEY_VERIFICATION_KEY, EventType.KEY_VERIFICATION_READY, - EventType.CALL_CANDIDATES -> { + EventType.CALL_CANDIDATES -> { span { } } - in EventType.POLL_START -> { + in EventType.POLL_START -> { timelineEvent.root.getClearContent().toModel(catchError = true)?.getBestPollCreationInfo()?.question?.getBestQuestion() ?: stringProvider.getString(R.string.sent_a_poll) } - in EventType.POLL_RESPONSE -> { + in EventType.POLL_RESPONSE -> { stringProvider.getString(R.string.poll_response_room_list_preview) } - in EventType.POLL_END -> { + in EventType.POLL_END -> { stringProvider.getString(R.string.poll_end_room_list_preview) } in EventType.STATE_ROOM_BEACON_INFO -> { simpleFormat(senderName, stringProvider.getString(R.string.sent_live_location), appendAuthor) } - else -> { + else -> { span { text = noticeEventFormatter.format(timelineEvent, isDm) ?: "" textStyle = "italic" @@ -171,10 +171,10 @@ class DisplayableEventFormatter @Inject constructor( } return when (event.getClearType()) { - EventType.MESSAGE -> { + EventType.MESSAGE -> { (event.getClearContent().toModel() as? MessageContent)?.let { messageContent -> when (messageContent.msgType) { - MessageType.MSGTYPE_TEXT -> { + MessageType.MSGTYPE_TEXT -> { val body = messageContent.getTextDisplayableContent() if (messageContent is MessageTextContent && messageContent.matrixFormattedBody.isNullOrBlank().not()) { val localFormattedBody = htmlRenderer.get().parse(body) as Document @@ -187,53 +187,53 @@ class DisplayableEventFormatter @Inject constructor( MessageType.MSGTYPE_VERIFICATION_REQUEST -> { stringProvider.getString(R.string.verification_request) } - MessageType.MSGTYPE_IMAGE -> { + MessageType.MSGTYPE_IMAGE -> { stringProvider.getString(R.string.sent_an_image) } - MessageType.MSGTYPE_AUDIO -> { + MessageType.MSGTYPE_AUDIO -> { if ((messageContent as? MessageAudioContent)?.voiceMessageIndicator != null) { stringProvider.getString(R.string.sent_a_voice_message) } else { stringProvider.getString(R.string.sent_an_audio_file) } } - MessageType.MSGTYPE_VIDEO -> { + MessageType.MSGTYPE_VIDEO -> { stringProvider.getString(R.string.sent_a_video) } - MessageType.MSGTYPE_FILE -> { + MessageType.MSGTYPE_FILE -> { stringProvider.getString(R.string.sent_a_file) } - MessageType.MSGTYPE_LOCATION -> { + MessageType.MSGTYPE_LOCATION -> { stringProvider.getString(R.string.sent_location) } - else -> { + else -> { messageContent.body } } } ?: span { } } - EventType.STICKER -> { + EventType.STICKER -> { stringProvider.getString(R.string.send_a_sticker) } - EventType.REACTION -> { + EventType.REACTION -> { event.getClearContent().toModel()?.relatesTo?.let { emojiSpanify.spanify(stringProvider.getString(R.string.sent_a_reaction, it.key)) } ?: span { } } - in EventType.POLL_START -> { + in EventType.POLL_START -> { event.getClearContent().toModel(catchError = true)?.pollCreationInfo?.question?.question ?: stringProvider.getString(R.string.sent_a_poll) } - in EventType.POLL_RESPONSE -> { + in EventType.POLL_RESPONSE -> { stringProvider.getString(R.string.poll_response_room_list_preview) } - in EventType.POLL_END -> { + in EventType.POLL_END -> { stringProvider.getString(R.string.poll_end_room_list_preview) } in EventType.STATE_ROOM_BEACON_INFO -> { stringProvider.getString(R.string.sent_live_location) } - else -> { + else -> { span { } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/EventDetailsFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/EventDetailsFormatter.kt index 4c92ab0e34..2233a53eda 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/EventDetailsFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/EventDetailsFormatter.kt @@ -50,8 +50,8 @@ class EventDetailsFormatter @Inject constructor( event.isImageMessage() -> formatForImageMessage(event) event.isVideoMessage() -> formatForVideoMessage(event) event.isAudioMessage() -> formatForAudioMessage(event) - event.isFileMessage() -> formatForFileMessage(event) - else -> null + event.isFileMessage() -> formatForFileMessage(event) + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt index 918118f854..19f9fc17a3 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/NoticeEventFormatter.kt @@ -67,29 +67,29 @@ class NoticeEventFormatter @Inject constructor( fun format(timelineEvent: TimelineEvent, isDm: Boolean): CharSequence? { return when (val type = timelineEvent.root.getClearType()) { - EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) - EventType.STATE_ROOM_CREATE -> formatRoomCreateEvent(timelineEvent.root, isDm) - EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) - EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) - EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) - EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) + EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) + EventType.STATE_ROOM_CREATE -> formatRoomCreateEvent(timelineEvent.root, isDm) + EventType.STATE_ROOM_NAME -> formatRoomNameEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) EventType.STATE_ROOM_THIRD_PARTY_INVITE -> formatRoomThirdPartyInvite(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) - EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) - EventType.STATE_ROOM_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_ALIASES -> formatRoomAliasesEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_CANONICAL_ALIAS -> formatRoomCanonicalAliasEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) - EventType.STATE_ROOM_SERVER_ACL -> formatRoomServerAclEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) - EventType.STATE_ROOM_GUEST_ACCESS -> formatRoomGuestAccessEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) - EventType.STATE_ROOM_ENCRYPTION -> formatRoomEncryptionEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_SERVER_ACL -> formatRoomServerAclEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_GUEST_ACCESS -> formatRoomGuestAccessEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) + EventType.STATE_ROOM_ENCRYPTION -> formatRoomEncryptionEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.STATE_ROOM_WIDGET, - EventType.STATE_ROOM_WIDGET_LEGACY -> formatWidgetEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) - EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) - EventType.STATE_ROOM_POWER_LEVELS -> formatRoomPowerLevels(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_WIDGET_LEGACY -> formatWidgetEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName, isDm) + EventType.STATE_ROOM_POWER_LEVELS -> formatRoomPowerLevels(timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.CALL_INVITE, EventType.CALL_CANDIDATES, EventType.CALL_HANGUP, EventType.CALL_REJECT, - EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) + EventType.CALL_ANSWER -> formatCallEvent(type, timelineEvent.root, timelineEvent.senderInfo.disambiguatedDisplayName) EventType.CALL_NEGOTIATE, EventType.CALL_SELECT_ANSWER, EventType.CALL_REPLACES, @@ -108,8 +108,8 @@ class NoticeEventFormatter @Inject constructor( EventType.STICKER, in EventType.POLL_RESPONSE, in EventType.POLL_END, - in EventType.BEACON_LOCATION_DATA -> formatDebug(timelineEvent.root) - else -> { + in EventType.BEACON_LOCATION_DATA -> formatDebug(timelineEvent.root) + else -> { Timber.v("Type $type not handled by this formatter") null } @@ -177,19 +177,19 @@ class NoticeEventFormatter @Inject constructor( fun format(event: Event, senderName: String?, isDm: Boolean): CharSequence? { return when (val type = event.getClearType()) { - EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(event, senderName, isDm) - EventType.STATE_ROOM_NAME -> formatRoomNameEvent(event, senderName) - EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(event, senderName) - EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(event, senderName) - EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(event, senderName, isDm) + EventType.STATE_ROOM_JOIN_RULES -> formatJoinRulesEvent(event, senderName, isDm) + EventType.STATE_ROOM_NAME -> formatRoomNameEvent(event, senderName) + EventType.STATE_ROOM_TOPIC -> formatRoomTopicEvent(event, senderName) + EventType.STATE_ROOM_AVATAR -> formatRoomAvatarEvent(event, senderName) + EventType.STATE_ROOM_MEMBER -> formatRoomMemberEvent(event, senderName, isDm) EventType.STATE_ROOM_THIRD_PARTY_INVITE -> formatRoomThirdPartyInvite(event, senderName, isDm) EventType.STATE_ROOM_HISTORY_VISIBILITY -> formatRoomHistoryVisibilityEvent(event, senderName, isDm) EventType.CALL_INVITE, EventType.CALL_HANGUP, EventType.CALL_REJECT, - EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName) - EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, isDm) - else -> { + EventType.CALL_ANSWER -> formatCallEvent(type, event, senderName) + EventType.STATE_ROOM_TOMBSTONE -> formatRoomTombstoneEvent(event, senderName, isDm) + else -> { Timber.v("Type $type not handled by this formatter") null } @@ -312,7 +312,7 @@ class NoticeEventFormatter @Inject constructor( ) } } - content != null -> { + content != null -> { // Invitation case if (event.isSentByCurrentUser()) { sp.getString( @@ -326,13 +326,13 @@ class NoticeEventFormatter @Inject constructor( ) } } - else -> null + else -> null } } private fun formatCallEvent(type: String, event: Event, senderName: String?): CharSequence? { return when (type) { - EventType.CALL_INVITE -> { + EventType.CALL_INVITE -> { val content = event.getClearContent().toModel() ?: return null val isVideoCall = content.isVideo() return if (isVideoCall) { @@ -349,13 +349,13 @@ class NoticeEventFormatter @Inject constructor( } } } - EventType.CALL_ANSWER -> + EventType.CALL_ANSWER -> if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_answered_call_by_you) } else { sp.getString(R.string.notice_answered_call, senderName) } - EventType.CALL_HANGUP -> + EventType.CALL_HANGUP -> if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_ended_call_by_you) } else { @@ -367,13 +367,13 @@ class NoticeEventFormatter @Inject constructor( } else { sp.getString(R.string.notice_call_candidates, senderName) } - EventType.CALL_REJECT -> + EventType.CALL_REJECT -> if (event.isSentByCurrentUser()) { sp.getString(R.string.call_tile_you_declined_this_call) } else { sp.getString(R.string.call_tile_other_declined, senderName) } - else -> null + else -> null } } @@ -403,19 +403,19 @@ class NoticeEventFormatter @Inject constructor( } else { sp.getString(R.string.notice_room_aliases_added_and_removed, senderName, addedAliases.joinToString(), removedAliases.joinToString()) } - addedAliases.isNotEmpty() -> + addedAliases.isNotEmpty() -> if (event.isSentByCurrentUser()) { sp.getQuantityString(R.plurals.notice_room_aliases_added_by_you, addedAliases.size, addedAliases.joinToString()) } else { sp.getQuantityString(R.plurals.notice_room_aliases_added, addedAliases.size, senderName, addedAliases.joinToString()) } - removedAliases.isNotEmpty() -> + removedAliases.isNotEmpty() -> if (event.isSentByCurrentUser()) { sp.getQuantityString(R.plurals.notice_room_aliases_removed_by_you, removedAliases.size, removedAliases.joinToString()) } else { sp.getQuantityString(R.plurals.notice_room_aliases_removed, removedAliases.size, senderName, removedAliases.joinToString()) } - else -> { + else -> { Timber.w("Alias event without any change...") null } @@ -516,7 +516,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_canonical_alias_no_change, senderName) } } - added.isEmpty() && removed.isEmpty() -> { + added.isEmpty() && removed.isEmpty() -> { // Canonical has changed if (canonicalAlias != null) { if (event.isSentByCurrentUser()) { @@ -532,7 +532,7 @@ class NoticeEventFormatter @Inject constructor( } } } - added.isEmpty() && canonicalAlias == prevCanonicalAlias -> { + added.isEmpty() && canonicalAlias == prevCanonicalAlias -> { // Some alternative has been removed if (event.isSentByCurrentUser()) { sp.getQuantityString(R.plurals.notice_room_canonical_alias_alternative_removed_by_you, removed.size, removed.joinToString()) @@ -540,7 +540,7 @@ class NoticeEventFormatter @Inject constructor( sp.getQuantityString(R.plurals.notice_room_canonical_alias_alternative_removed, removed.size, senderName, removed.joinToString()) } } - removed.isEmpty() && canonicalAlias == prevCanonicalAlias -> { + removed.isEmpty() && canonicalAlias == prevCanonicalAlias -> { // Some alternative has been added if (event.isSentByCurrentUser()) { sp.getQuantityString(R.plurals.notice_room_canonical_alias_alternative_added_by_you, added.size, added.joinToString()) @@ -548,7 +548,7 @@ class NoticeEventFormatter @Inject constructor( sp.getQuantityString(R.plurals.notice_room_canonical_alias_alternative_added, added.size, senderName, added.joinToString()) } } - canonicalAlias == prevCanonicalAlias -> { + canonicalAlias == prevCanonicalAlias -> { // Alternative added and removed if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_room_canonical_alias_alternative_changed_by_you) @@ -556,7 +556,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_canonical_alias_alternative_changed, senderName) } } - else -> { + else -> { // Main and removed, or main and added, or main and added and removed if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_room_canonical_alias_main_and_alternative_changed_by_you) @@ -570,7 +570,7 @@ class NoticeEventFormatter @Inject constructor( private fun formatRoomGuestAccessEvent(event: Event, senderName: String?, isDm: Boolean): String? { val eventContent: RoomGuestAccessContent? = event.content.toModel() return when (eventContent?.guestAccess) { - GuestAccess.CanJoin -> + GuestAccess.CanJoin -> if (event.isSentByCurrentUser()) { sp.getString( if (isDm) R.string.notice_direct_room_guest_access_can_join_by_you else R.string.notice_room_guest_access_can_join_by_you @@ -592,7 +592,7 @@ class NoticeEventFormatter @Inject constructor( senderName ) } - else -> null + else -> null } } @@ -608,7 +608,7 @@ class NoticeEventFormatter @Inject constructor( } else { sp.getString(R.string.notice_end_to_end_ok, senderName) } - else -> + else -> if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_end_to_end_unknown_algorithm_by_you, content.algorithm) } else { @@ -628,13 +628,13 @@ class NoticeEventFormatter @Inject constructor( } else { sp.getString(R.string.notice_display_name_set, event.senderId, eventContent?.displayName) } - eventContent?.displayName.isNullOrEmpty() -> + eventContent?.displayName.isNullOrEmpty() -> if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_display_name_removed_by_you, prevEventContent?.displayName) } else { sp.getString(R.string.notice_display_name_removed, event.senderId, prevEventContent?.displayName) } - else -> + else -> if (event.isSentByCurrentUser()) { sp.getString(R.string.notice_display_name_changed_from_by_you, prevEventContent?.displayName, eventContent?.displayName) } else { @@ -696,11 +696,11 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_third_party_registered_invite, userWhoHasAccepted, threePidDisplayName) } } - event.stateKey == currentUserId -> + event.stateKey == currentUserId -> eventContent.safeReason?.let { reason -> sp.getString(R.string.notice_room_invite_you_with_reason, senderDisplayName, reason) } ?: sp.getString(R.string.notice_room_invite_you, senderDisplayName) - event.stateKey.isNullOrEmpty() -> + event.stateKey.isNullOrEmpty() -> if (event.isSentByCurrentUser()) { eventContent.safeReason?.let { reason -> sp.getString(R.string.notice_room_invite_no_invitee_with_reason_by_you, reason) @@ -710,7 +710,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_invite_no_invitee_with_reason, senderDisplayName, reason) } ?: sp.getString(R.string.notice_room_invite_no_invitee, senderDisplayName) } - else -> + else -> if (event.isSentByCurrentUser()) { eventContent.safeReason?.let { reason -> sp.getString(R.string.notice_room_invite_with_reason_by_you, targetDisplayName, reason) @@ -722,7 +722,7 @@ class NoticeEventFormatter @Inject constructor( } } } - Membership.JOIN -> + Membership.JOIN -> eventContent.safeReason?.let { reason -> if (event.isSentByCurrentUser()) { sp.getString( @@ -745,7 +745,7 @@ class NoticeEventFormatter @Inject constructor( ) } } - Membership.LEAVE -> + Membership.LEAVE -> // 2 cases here: this member may have left voluntarily or they may have been "left" by someone else ie. kicked if (event.senderId == event.stateKey) { when (prevEventContent?.membership) { @@ -759,7 +759,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_reject_with_reason, senderDisplayName, reason) } ?: sp.getString(R.string.notice_room_reject, senderDisplayName) } - else -> + else -> eventContent.safeReason?.let { reason -> if (event.isSentByCurrentUser()) { sp.getString( @@ -800,7 +800,7 @@ class NoticeEventFormatter @Inject constructor( } ?: sp.getString(R.string.notice_room_withdraw, senderDisplayName, targetDisplayName) } Membership.LEAVE, - Membership.JOIN -> + Membership.JOIN -> if (event.isSentByCurrentUser()) { eventContent.safeReason?.let { reason -> sp.getString(R.string.notice_room_remove_with_reason_by_you, targetDisplayName, reason) @@ -810,7 +810,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_remove_with_reason, senderDisplayName, targetDisplayName, reason) } ?: sp.getString(R.string.notice_room_remove, senderDisplayName, targetDisplayName) } - Membership.BAN -> + Membership.BAN -> if (event.isSentByCurrentUser()) { eventContent.safeReason?.let { reason -> sp.getString(R.string.notice_room_unban_with_reason_by_you, targetDisplayName, reason) @@ -820,10 +820,10 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_unban_with_reason, senderDisplayName, targetDisplayName, reason) } ?: sp.getString(R.string.notice_room_unban, senderDisplayName, targetDisplayName) } - else -> null + else -> null } } - Membership.BAN -> + Membership.BAN -> if (event.isSentByCurrentUser()) { eventContent.safeReason?.let { sp.getString(R.string.notice_room_ban_with_reason_by_you, targetDisplayName, it) @@ -833,7 +833,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_ban_with_reason, senderDisplayName, targetDisplayName, it) } ?: sp.getString(R.string.notice_room_ban, senderDisplayName, targetDisplayName) } - Membership.KNOCK -> + Membership.KNOCK -> if (event.isSentByCurrentUser()) { eventContent.safeReason?.let { reason -> sp.getString(R.string.notice_room_remove_with_reason_by_you, targetDisplayName, reason) @@ -843,7 +843,7 @@ class NoticeEventFormatter @Inject constructor( sp.getString(R.string.notice_room_remove_with_reason, senderDisplayName, targetDisplayName, reason) } ?: sp.getString(R.string.notice_room_remove, senderDisplayName, targetDisplayName) } - else -> null + else -> null } } @@ -865,7 +865,7 @@ class NoticeEventFormatter @Inject constructor( } else { sp.getString(R.string.room_join_rules_public, senderName) } - else -> null + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt index c1ba085fd7..76b303775a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/format/RoomHistoryVisibilityFormatter.kt @@ -28,9 +28,9 @@ class RoomHistoryVisibilityFormatter @Inject constructor( return stringProvider.getString( when (roomHistoryVisibility) { RoomHistoryVisibility.WORLD_READABLE -> R.string.notice_room_visibility_world_readable - RoomHistoryVisibility.SHARED -> R.string.notice_room_visibility_shared - RoomHistoryVisibility.INVITED -> R.string.notice_room_visibility_invited - RoomHistoryVisibility.JOINED -> R.string.notice_room_visibility_joined + RoomHistoryVisibility.SHARED -> R.string.notice_room_visibility_shared + RoomHistoryVisibility.INVITED -> R.string.notice_room_visibility_invited + RoomHistoryVisibility.JOINED -> R.string.notice_room_visibility_joined } ) } @@ -39,9 +39,9 @@ class RoomHistoryVisibilityFormatter @Inject constructor( return stringProvider.getString( when (roomHistoryVisibility) { RoomHistoryVisibility.WORLD_READABLE -> R.string.room_settings_read_history_entry_anyone - RoomHistoryVisibility.SHARED -> R.string.room_settings_read_history_entry_members_only_option_time_shared - RoomHistoryVisibility.INVITED -> R.string.room_settings_read_history_entry_members_only_invited - RoomHistoryVisibility.JOINED -> R.string.room_settings_read_history_entry_members_only_joined + RoomHistoryVisibility.SHARED -> R.string.room_settings_read_history_entry_members_only_option_time_shared + RoomHistoryVisibility.INVITED -> R.string.room_settings_read_history_entry_members_only_invited + RoomHistoryVisibility.JOINED -> R.string.room_settings_read_history_entry_members_only_joined } ) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt index 44387759c8..6937cd3a46 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/AudioMessagePlaybackTracker.kt @@ -121,18 +121,18 @@ class AudioMessagePlaybackTracker @Inject constructor() { fun getPlaybackTime(id: String): Int { return when (val state = states[id]) { is Listener.State.Playing -> state.playbackTime - is Listener.State.Paused -> state.playbackTime + is Listener.State.Paused -> state.playbackTime /* Listener.State.Idle, */ - else -> 0 + else -> 0 } } private fun getPercentage(id: String): Float { return when (val state = states[id]) { is Listener.State.Playing -> state.percentage - is Listener.State.Paused -> state.percentage + is Listener.State.Paused -> state.percentage /* Listener.State.Idle, */ - else -> 0f + else -> 0f } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentDownloadStateTrackerBinder.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentDownloadStateTrackerBinder.kt index 178007b38a..a4907c1099 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentDownloadStateTrackerBinder.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentDownloadStateTrackerBinder.kt @@ -64,11 +64,11 @@ private class ContentDownloadUpdater(private val holder: MessageFileItem.Holder) override fun onDownloadStateUpdate(state: ContentDownloadStateTracker.State) { when (state) { - ContentDownloadStateTracker.State.Idle -> handleIdle() + ContentDownloadStateTracker.State.Idle -> handleIdle() is ContentDownloadStateTracker.State.Downloading -> handleProgress(state) - ContentDownloadStateTracker.State.Decrypting -> handleDecrypting() - ContentDownloadStateTracker.State.Success -> handleSuccess() - is ContentDownloadStateTracker.State.Failure -> handleFailure() + ContentDownloadStateTracker.State.Decrypting -> handleDecrypting() + ContentDownloadStateTracker.State.Success -> handleSuccess() + is ContentDownloadStateTracker.State.Failure -> handleFailure() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt index 97b2cc6eab..cda4af89ce 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt @@ -82,15 +82,15 @@ private class ContentMediaProgressUpdater( override fun onUpdate(state: ContentUploadStateTracker.State) { when (state) { - is ContentUploadStateTracker.State.Idle -> handleIdle() + is ContentUploadStateTracker.State.Idle -> handleIdle() is ContentUploadStateTracker.State.EncryptingThumbnail -> handleEncryptingThumbnail() - is ContentUploadStateTracker.State.UploadingThumbnail -> handleProgressThumbnail(state) - is ContentUploadStateTracker.State.Encrypting -> handleEncrypting(state) - is ContentUploadStateTracker.State.Uploading -> handleProgress(state) - is ContentUploadStateTracker.State.Failure -> handleFailure(/*state*/) - is ContentUploadStateTracker.State.Success -> handleSuccess() - is ContentUploadStateTracker.State.CompressingImage -> handleCompressingImage() - is ContentUploadStateTracker.State.CompressingVideo -> handleCompressingVideo(state) + is ContentUploadStateTracker.State.UploadingThumbnail -> handleProgressThumbnail(state) + is ContentUploadStateTracker.State.Encrypting -> handleEncrypting(state) + is ContentUploadStateTracker.State.Uploading -> handleProgress(state) + is ContentUploadStateTracker.State.Failure -> handleFailure(/*state*/) + is ContentUploadStateTracker.State.Success -> handleSuccess() + is ContentUploadStateTracker.State.CompressingImage -> handleCompressingImage() + is ContentUploadStateTracker.State.CompressingVideo -> handleCompressingVideo(state) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt index 1c64082f65..e23e003768 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MatrixItemColorProvider.kt @@ -40,7 +40,7 @@ class MatrixItemColorProvider @Inject constructor( colorProvider.getColor( when (matrixItem) { is MatrixItem.UserItem -> getColorFromUserId(matrixItem.id) - else -> getColorFromRoomId(matrixItem.id) + else -> getColorFromRoomId(matrixItem.id) } ) } @@ -96,13 +96,13 @@ class MatrixItemColorProvider @Inject constructor( @ColorRes private fun getUserColorByIndex(index: Int): Int { return when (index % 8) { - 1 -> R.color.element_name_02 - 2 -> R.color.element_name_03 - 3 -> R.color.element_name_04 - 4 -> R.color.element_name_05 - 5 -> R.color.element_name_06 - 6 -> R.color.element_name_07 - 7 -> R.color.element_name_08 + 1 -> R.color.element_name_02 + 2 -> R.color.element_name_03 + 3 -> R.color.element_name_04 + 4 -> R.color.element_name_05 + 5 -> R.color.element_name_06 + 6 -> R.color.element_name_07 + 7 -> R.color.element_name_08 else -> R.color.element_name_01 } } @@ -110,8 +110,8 @@ class MatrixItemColorProvider @Inject constructor( @ColorRes private fun getColorFromRoomId(roomId: String?): Int { return when ((roomId?.toList()?.sumOf { it.code } ?: 0) % 3) { - 1 -> R.color.element_room_02 - 2 -> R.color.element_room_03 + 1 -> R.color.element_room_02 + 2 -> R.color.element_room_03 else -> R.color.element_room_01 } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt index e57f61a543..bcbbfb9ebd 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/MessageInformationDataFactory.kt @@ -161,18 +161,18 @@ class MessageInformationDataFactory @Inject constructor( session.cryptoService().getDeviceInfo(event.root.senderId ?: "", deviceId) } when { - sendingDevice == null -> { + sendingDevice == null -> { // For now do not decorate this with warning // maybe it's a deleted session E2EDecoration.NONE } - sendingDevice.trustLevel == null -> { + sendingDevice.trustLevel == null -> { E2EDecoration.WARN_SENT_BY_UNKNOWN } sendingDevice.trustLevel?.isVerified().orFalse() -> { E2EDecoration.NONE } - else -> { + else -> { E2EDecoration.WARN_SENT_BY_UNVERIFIED } } @@ -199,10 +199,10 @@ class MessageInformationDataFactory @Inject constructor( return when (event?.root?.getClearType()) { EventType.KEY_VERIFICATION_DONE, EventType.KEY_VERIFICATION_CANCEL -> true - EventType.MESSAGE -> { + EventType.MESSAGE -> { event.getLastMessageContent() is MessageVerificationRequestContent } - else -> false + else -> false } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt index 1736b20d44..85ffd7295c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/helper/TimelineDisplayableEvents.kt @@ -71,11 +71,11 @@ fun TimelineEvent.isRoomConfiguration(roomCreatorUserId: String?): Boolean { EventType.STATE_ROOM_CANONICAL_ALIAS, EventType.STATE_ROOM_POWER_LEVELS, EventType.STATE_ROOM_ENCRYPTION -> true - EventType.STATE_ROOM_MEMBER -> { + EventType.STATE_ROOM_MEMBER -> { // Keep only room member events regarding the room creator (when he joined the room), // but exclude events where the room creator invite others, or where others join roomCreatorUserId != null && root.stateKey == roomCreatorUserId } - else -> false + else -> false } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/image/ImageContentRendererFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/image/ImageContentRendererFactory.kt index 26cab4d863..91bbd584e1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/image/ImageContentRendererFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/image/ImageContentRendererFactory.kt @@ -60,6 +60,6 @@ fun TimelineEvent.buildImageContentRendererData(maxHeight: Int): ImageContentRen allowNonMxcUrls = false ) } - else -> null + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsBaseMessageItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsBaseMessageItem.kt index c21cb5319e..e3471b22f8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsBaseMessageItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/AbsBaseMessageItem.kt @@ -80,7 +80,7 @@ abstract class AbsBaseMessageItem : BaseEventItem super.bind(holder) renderReactions(holder, baseAttributes.informationData.reactionsSummary) when (baseAttributes.informationData.e2eDecoration) { - E2EDecoration.NONE -> { + E2EDecoration.NONE -> { holder.e2EDecorationView.render(null) } E2EDecoration.WARN_IN_CLEAR, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt index b56f5264e6..228e0181d2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt @@ -60,11 +60,11 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem renderInvitedStatus(holder) - CallStatus.IN_CALL -> renderInCallStatus(holder) + CallStatus.INVITED -> renderInvitedStatus(holder) + CallStatus.IN_CALL -> renderInCallStatus(holder) CallStatus.REJECTED -> renderRejectedStatus(holder) - CallStatus.ENDED -> renderEndedStatus(holder) - CallStatus.MISSED -> renderMissedStatus(holder) + CallStatus.ENDED -> renderEndedStatus(holder) + CallStatus.MISSED -> renderMissedStatus(holder) } renderSendState(holder.view, null, holder.failedToSendIndicator) } @@ -97,11 +97,11 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { + CallKind.VIDEO -> { val endCallStatus = holder.resources.getString(R.string.call_tile_video_call_has_ended, attributes.formattedDuration) holder.statusView.setStatus(endCallStatus) } - CallKind.AUDIO -> { + CallKind.AUDIO -> { val endCallStatus = holder.resources.getString(R.string.call_tile_voice_call_has_ended, attributes.formattedDuration) holder.statusView.setStatus(endCallStatus) } @@ -148,7 +148,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { + attributes.isStillActive -> { holder.rejectView.isVisible = true holder.rejectView.setText(R.string.call_notification_hangup) holder.rejectView.setLeftDrawable(R.drawable.ic_call_hangup, R.attr.colorOnPrimary) @@ -156,7 +156,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { + else -> { holder.acceptRejectViewGroup.isVisible = false } } @@ -169,7 +169,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { + attributes.callKind == CallKind.CONFERENCE -> { holder.acceptRejectViewGroup.isVisible = true holder.acceptView.onClick { attributes.callback?.onTimelineItemAction(RoomDetailAction.JoinJitsiCall) @@ -200,7 +200,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { + else -> { holder.acceptRejectViewGroup.isVisible = false } } @@ -209,13 +209,13 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { holder.statusView.setStatus(R.string.call_tile_video_active) } - attributes.informationData.sentByMe -> { + attributes.informationData.sentByMe -> { holder.statusView.setStatus(R.string.call_ringing) } - attributes.callKind.isVoiceCall -> { + attributes.callKind.isVoiceCall -> { holder.statusView.setStatus(R.string.call_tile_voice_incoming) } - else -> { + else -> { holder.statusView.setStatus(R.string.call_tile_video_incoming) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt index f574dcfdcb..a3c09960c9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageAudioItem.kt @@ -144,9 +144,9 @@ abstract class MessageAudioItem : AbsMessageItem() { audioMessagePlaybackTracker.track(attributes.informationData.eventId, object : AudioMessagePlaybackTracker.Listener { override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) { when (state) { - is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder) - is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state) - is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state) + is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder) + is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state) + is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state) is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt index 838fbd46de..795bd21cb2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageLiveLocationItem.kt @@ -72,13 +72,13 @@ abstract class MessageLiveLocationItem : AbsMessageLocationItem + messageLayout is TimelineMessageLayout.Bubble -> LocationLiveMessageBannerViewState.Watcher( bottomStartCornerRadiusInDp = messageLayout.cornersRadius.bottomStartRadius, bottomEndCornerRadiusInDp = messageLayout.cornersRadius.bottomEndRadius, formattedLocalTimeOfEndOfLive = getFormattedLocalTimeEndOfLive(), ) - isEmitter -> { + isEmitter -> { val cornerRadius = getBannerCornerRadiusForDefaultLayout(holder) LocationLiveMessageBannerViewState.Emitter( remainingTimeInMillis = getRemainingTimeOfLiveInMillis(), @@ -87,7 +87,7 @@ abstract class MessageLiveLocationItem : AbsMessageLocationItem { + else -> { val cornerRadius = getBannerCornerRadiusForDefaultLayout(holder) LocationLiveMessageBannerViewState.Watcher( bottomStartCornerRadiusInDp = cornerRadius, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt index 82860da886..e8f1762963 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt @@ -111,7 +111,7 @@ abstract class MessageVoiceItem : AbsMessageItem() { holder.voicePlaybackWaveform.setOnTouchListener { view, motionEvent -> when (motionEvent.action) { - MotionEvent.ACTION_UP -> { + MotionEvent.ACTION_UP -> { val percentage = getTouchedPositionPercentage(motionEvent, view) waveformTouchListener?.onWaveformTouchedUp(percentage) } @@ -126,9 +126,9 @@ abstract class MessageVoiceItem : AbsMessageItem() { audioMessagePlaybackTracker.track(attributes.informationData.eventId, object : AudioMessagePlaybackTracker.Listener { override fun onUpdate(state: AudioMessagePlaybackTracker.Listener.State) { when (state) { - is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder, waveformColorIdle, waveformColorPlayed) - is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state, waveformColorIdle, waveformColorPlayed) - is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state, waveformColorIdle, waveformColorPlayed) + is AudioMessagePlaybackTracker.Listener.State.Idle -> renderIdleState(holder, waveformColorIdle, waveformColorPlayed) + is AudioMessagePlaybackTracker.Listener.State.Playing -> renderPlayingState(holder, state, waveformColorIdle, waveformColorPlayed) + is AudioMessagePlaybackTracker.Listener.State.Paused -> renderPausedState(holder, state, waveformColorIdle, waveformColorPlayed) is AudioMessagePlaybackTracker.Listener.State.Recording -> Unit } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/NoticeItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/NoticeItem.kt index 7ca5166542..9d865e6dad 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/NoticeItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/NoticeItem.kt @@ -44,7 +44,7 @@ abstract class NoticeItem : BaseEventItem() { holder.avatarImageView.onClick(attributes.avatarClickListener) when (attributes.informationData.e2eDecoration) { - E2EDecoration.NONE -> { + E2EDecoration.NONE -> { holder.e2EDecorationView.render(null) } E2EDecoration.WARN_IN_CLEAR, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionView.kt index 80daa595b6..b21b1a152d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/PollOptionView.kt @@ -43,10 +43,10 @@ class PollOptionView @JvmOverloads constructor( views.optionNameTextView.text = state.optionAnswer when (state) { - is PollOptionViewState.PollSending -> renderPollSending() - is PollOptionViewState.PollEnded -> renderPollEnded(state) - is PollOptionViewState.PollReady -> renderPollReady() - is PollOptionViewState.PollVoted -> renderPollVoted(state) + is PollOptionViewState.PollSending -> renderPollSending() + is PollOptionViewState.PollEnded -> renderPollEnded(state) + is PollOptionViewState.PollReady -> renderPollReady() + is PollOptionViewState.PollVoted -> renderPollVoted(state) is PollOptionViewState.PollUndisclosed -> renderPollUndisclosed(state) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/StatusTileTimelineItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/StatusTileTimelineItem.kt index 3810f1cb6f..e4c68a7a5b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/StatusTileTimelineItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/StatusTileTimelineItem.kt @@ -56,7 +56,7 @@ abstract class StatusTileTimelineItem : AbsBaseMessageItem R.drawable.ic_shield_trusted ShieldUIState.BLACK -> R.drawable.ic_shield_black - ShieldUIState.RED -> R.drawable.ic_shield_warning + ShieldUIState.RED -> R.drawable.ic_shield_warning ShieldUIState.ERROR -> R.drawable.ic_warning_badge } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/VerificationRequestItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/VerificationRequestItem.kt index fc4c55d1f3..395b5fa308 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/VerificationRequestItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/VerificationRequestItem.kt @@ -78,7 +78,7 @@ abstract class VerificationRequestItem : AbsBaseMessageItem { + null -> { holder.buttonBar.isVisible = !attributes.informationData.sentByMe holder.statusTextView.text = null holder.statusTextView.isVisible = false @@ -89,17 +89,17 @@ abstract class VerificationRequestItem : AbsBaseMessageItem { + VerificationState.CANCELED_BY_ME -> { holder.buttonBar.isVisible = false holder.statusTextView.text = holder.view.context.getString(R.string.verification_request_you_cancelled) holder.statusTextView.isVisible = true } - VerificationState.WAITING -> { + VerificationState.WAITING -> { holder.buttonBar.isVisible = false holder.statusTextView.text = holder.view.context.getString(R.string.verification_request_waiting) holder.statusTextView.isVisible = true } - VerificationState.DONE -> { + VerificationState.DONE -> { holder.buttonBar.isVisible = false holder.statusTextView.text = if (attributes.informationData.sentByMe) { holder.view.context.getString(R.string.verification_request_other_accepted, attributes.otherUserName) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/reactions/ViewReactionsEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/reactions/ViewReactionsEpoxyController.kt index 7554885aec..7f619d3838 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/reactions/ViewReactionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/reactions/ViewReactionsEpoxyController.kt @@ -49,7 +49,7 @@ class ViewReactionsEpoxyController @Inject constructor( id("Spinner") } } - is Fail -> { + is Fail -> { genericFooterItem { id("failure") text(host.stringProvider.getString(R.string.unknown_error).toEpoxyCharSequence()) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt index 80405077e7..580465d1c1 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/style/TimelineMessageLayoutFactory.kt @@ -153,17 +153,17 @@ class TimelineMessageLayoutFactory @Inject constructor( private fun MessageContent?.timestampInsideMessage(): Boolean { return when { - this == null -> false + this == null -> false msgType in MSG_TYPES_WITH_LOCATION_DATA -> vectorPreferences.labsRenderLocationsInTimeline() - else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE + else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE } } private fun MessageContent?.shouldAddMessageOverlay(): Boolean { return when { this == null || msgType == MessageType.MSGTYPE_BEACON_INFO -> false - msgType == MessageType.MSGTYPE_LOCATION -> vectorPreferences.labsRenderLocationsInTimeline() - else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE + msgType == MessageType.MSGTYPE_LOCATION -> vectorPreferences.labsRenderLocationsInTimeline() + else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE } } @@ -214,10 +214,10 @@ class TimelineMessageLayoutFactory @Inject constructor( return when (event?.root?.getClearType()) { EventType.KEY_VERIFICATION_DONE, EventType.KEY_VERIFICATION_CANCEL -> true - EventType.MESSAGE -> { + EventType.MESSAGE -> { event.getLastMessageContent() is MessageVerificationRequestContent } - else -> false + else -> false } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt index 50388246f4..0e2429d45a 100755 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/url/PreviewUrlView.kt @@ -76,10 +76,10 @@ class PreviewUrlView @JvmOverloads constructor( hideAll() when (newState) { PreviewUrlUiState.Unknown, - PreviewUrlUiState.NoUrl -> renderHidden() - PreviewUrlUiState.Loading -> renderLoading() + PreviewUrlUiState.NoUrl -> renderHidden() + PreviewUrlUiState.Loading -> renderLoading() is PreviewUrlUiState.Error -> renderHidden() - is PreviewUrlUiState.Data -> renderData(newState.previewUrlData, imageContentRenderer) + is PreviewUrlUiState.Data -> renderData(newState.previewUrlData, imageContentRenderer) } } @@ -91,7 +91,7 @@ class PreviewUrlView @JvmOverloads constructor( val guidelineBegin = DimensionConverter(resources).dpToPx(8) views.urlPreviewStartGuideline.setGuidelineBegin(guidelineBegin) } - is TimelineMessageLayout.Bubble -> { + is TimelineMessageLayout.Bubble -> { setCardBackgroundColor(Color.TRANSPARENT) rippleColor = ColorStateList.valueOf(Color.TRANSPARENT) views.urlPreviewStartGuideline.setGuidelineBegin(0) @@ -102,7 +102,7 @@ class PreviewUrlView @JvmOverloads constructor( override fun onClick(v: View?) { when (val finalState = state) { is PreviewUrlUiState.Data -> delegate?.onPreviewUrlClicked(finalState.url) - else -> Unit + else -> Unit } } @@ -115,14 +115,14 @@ class PreviewUrlView @JvmOverloads constructor( title = finalState.previewUrlData.title ) } - else -> Unit + else -> Unit } } private fun onCloseClick() { when (val finalState = state) { is PreviewUrlUiState.Data -> delegate?.onPreviewUrlCloseClicked(finalState.eventId, finalState.url) - else -> Unit + else -> Unit } } @@ -154,8 +154,8 @@ class PreviewUrlView @JvmOverloads constructor( views.urlPreviewDescription.setTextOrHide(previewUrlData.description) views.urlPreviewDescription.maxLines = when { previewUrlData.mxcUrl != null -> 2 - previewUrlData.title != null -> 3 - else -> 5 + previewUrlData.title != null -> 3 + else -> 5 } views.urlPreviewSite.setTextOrHide(previewUrlData.siteName.takeIf { it != previewUrlData.title }) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/upgrade/MigrateRoomBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/upgrade/MigrateRoomBottomSheet.kt index 3f89b99e59..31662abd83 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/upgrade/MigrateRoomBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/upgrade/MigrateRoomBottomSheet.kt @@ -92,17 +92,17 @@ class MigrateRoomBottomSheet : when (val result = state.upgradingStatus.invoke()) { is UpgradeRoomViewModelTask.Result.Failure -> { val errorText = when (result) { - is UpgradeRoomViewModelTask.Result.UnknownRoom -> { + is UpgradeRoomViewModelTask.Result.UnknownRoom -> { // should not happen getString(R.string.unknown_error) } - is UpgradeRoomViewModelTask.Result.NotAllowed -> { + is UpgradeRoomViewModelTask.Result.NotAllowed -> { getString(R.string.upgrade_room_no_power_to_manage) } is UpgradeRoomViewModelTask.Result.ErrorFailure -> { errorFormatter.toHumanReadable(result.throwable) } - else -> null + else -> null } views.inlineError.setTextOrHide(errorText) views.button.isVisible = true @@ -116,7 +116,7 @@ class MigrateRoomBottomSheet : } } } - else -> { + else -> { views.button.isVisible = true views.button.text = getString(R.string.upgrade) } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/AlphabeticalRoomComparator.kt b/vector/src/main/java/im/vector/app/features/home/room/list/AlphabeticalRoomComparator.kt index 03b4b24726..2997bbf0eb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/AlphabeticalRoomComparator.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/AlphabeticalRoomComparator.kt @@ -24,8 +24,8 @@ class AlphabeticalRoomComparator @Inject constructor() : Comparator override fun compare(leftRoomSummary: RoomSummary?, rightRoomSummary: RoomSummary?): Int { return when { rightRoomSummary?.displayName == null -> -1 - leftRoomSummary?.displayName == null -> 1 - else -> leftRoomSummary.displayName.compareTo(rightRoomSummary.displayName) + leftRoomSummary?.displayName == null -> 1 + else -> leftRoomSummary.displayName.compareTo(rightRoomSummary.displayName) } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/ChronologicalRoomComparator.kt b/vector/src/main/java/im/vector/app/features/home/room/list/ChronologicalRoomComparator.kt index 06616683bc..4fba8a422d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/ChronologicalRoomComparator.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/ChronologicalRoomComparator.kt @@ -24,8 +24,8 @@ class ChronologicalRoomComparator @Inject constructor() : Comparator -1 - leftRoomSummary?.latestPreviewableEvent?.root == null -> 1 - else -> { + leftRoomSummary?.latestPreviewableEvent?.root == null -> 1 + else -> { val rightTimestamp = rightRoomSummary.latestPreviewableEvent?.root?.originServerTs ?: 0 val leftTimestamp = leftRoomSummary.latestPreviewableEvent?.root?.originServerTs ?: 0 @@ -34,7 +34,7 @@ class ChronologicalRoomComparator @Inject constructor() : Comparator 0 -> 1 deltaTimestamp < 0 -> -1 - else -> 0 + else -> 0 } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFooterController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFooterController.kt index 00d59f4c37..df009e8d6b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFooterController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFooterController.kt @@ -45,7 +45,7 @@ class RoomListFooterController @Inject constructor( inSpace(data.currentRoomGrouping.invoke()?.space() != null) } } - else -> { + else -> { if (userPreferencesProvider.shouldShowLongClickOnRoomHelp()) { helpFooterItem { id("long_click_help") diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index 2be6130a5d..2949425004 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -110,8 +110,8 @@ class RoomListFragment @Inject constructor( super.onCreate(savedInstanceState) analyticsScreenName = when (roomListParams.displayMode) { RoomListDisplayMode.PEOPLE -> MobileScreen.ScreenName.People - RoomListDisplayMode.ROOMS -> MobileScreen.ScreenName.Rooms - else -> null + RoomListDisplayMode.ROOMS -> MobileScreen.ScreenName.Rooms + else -> null } } @@ -124,10 +124,10 @@ class RoomListFragment @Inject constructor( sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java) roomListViewModel.observeViewEvents { when (it) { - is RoomListViewEvents.Loading -> showLoading(it.message) - is RoomListViewEvents.Failure -> showFailure(it.throwable) - is RoomListViewEvents.SelectRoom -> handleSelectRoom(it, it.isInviteAlreadyAccepted) - is RoomListViewEvents.Done -> Unit + is RoomListViewEvents.Loading -> showLoading(it.message) + is RoomListViewEvents.Failure -> showFailure(it.throwable) + is RoomListViewEvents.SelectRoom -> handleSelectRoom(it, it.isInviteAlreadyAccepted) + is RoomListViewEvents.Done -> Unit is RoomListViewEvents.NavigateToMxToBottomSheet -> handleShowMxToLink(it.link) } } @@ -209,9 +209,9 @@ class RoomListFragment @Inject constructor( private fun setupCreateRoomButton() { when (roomListParams.displayMode) { RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.isVisible = true - RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true - RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true - else -> Unit // No button in this mode + RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.isVisible = true + RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.isVisible = true + else -> Unit // No button in this mode } views.createChatRoomButton.debouncedClicks { @@ -228,16 +228,16 @@ class RoomListFragment @Inject constructor( views.createChatFabMenu.removeCallbacks(showFabRunnable) when (newState) { - RecyclerView.SCROLL_STATE_IDLE -> { + RecyclerView.SCROLL_STATE_IDLE -> { views.createChatFabMenu.postDelayed(showFabRunnable, 250) } RecyclerView.SCROLL_STATE_DRAGGING, RecyclerView.SCROLL_STATE_SETTLING -> { when (roomListParams.displayMode) { RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.hide() - RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.hide() - RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.hide() - else -> Unit + RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.hide() + RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.hide() + else -> Unit } } } @@ -293,7 +293,7 @@ class RoomListFragment @Inject constructor( } val contentAdapter = when { - section.livePages != null -> { + section.livePages != null -> { pagedControllerFactory.createRoomSummaryPagedController() .also { controller -> section.livePages.observe(viewLifecycleOwner) { pl -> @@ -343,7 +343,7 @@ class RoomListFragment @Inject constructor( controller.listener = this } } - else -> { + else -> { pagedControllerFactory.createRoomSummaryListController() .also { controller -> section.liveList?.observe(viewLifecycleOwner) { list -> @@ -400,9 +400,9 @@ class RoomListFragment @Inject constructor( if (isAdded) { when (roomListParams.displayMode) { RoomListDisplayMode.NOTIFICATIONS -> views.createChatFabMenu.show() - RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show() - RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show() - else -> Unit + RoomListDisplayMode.PEOPLE -> views.createChatRoomButton.show() + RoomListDisplayMode.ROOMS -> views.createGroupRoomButton.show() + else -> Unit } } } @@ -422,28 +422,28 @@ class RoomListFragment @Inject constructor( private fun handleQuickActions(quickAction: RoomListQuickActionsSharedAction) { when (quickAction) { - is RoomListQuickActionsSharedAction.NotificationsAllNoisy -> { + is RoomListQuickActionsSharedAction.NotificationsAllNoisy -> { roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.ALL_MESSAGES_NOISY)) } - is RoomListQuickActionsSharedAction.NotificationsAll -> { + is RoomListQuickActionsSharedAction.NotificationsAll -> { roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.ALL_MESSAGES)) } is RoomListQuickActionsSharedAction.NotificationsMentionsOnly -> { roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.MENTIONS_ONLY)) } - is RoomListQuickActionsSharedAction.NotificationsMute -> { + is RoomListQuickActionsSharedAction.NotificationsMute -> { roomListViewModel.handle(RoomListAction.ChangeRoomNotificationState(quickAction.roomId, RoomNotificationState.MUTE)) } - is RoomListQuickActionsSharedAction.Settings -> { + is RoomListQuickActionsSharedAction.Settings -> { navigator.openRoomProfile(requireActivity(), quickAction.roomId) } - is RoomListQuickActionsSharedAction.Favorite -> { + is RoomListQuickActionsSharedAction.Favorite -> { roomListViewModel.handle(RoomListAction.ToggleTag(quickAction.roomId, RoomTag.ROOM_TAG_FAVOURITE)) } - is RoomListQuickActionsSharedAction.LowPriority -> { + is RoomListQuickActionsSharedAction.LowPriority -> { roomListViewModel.handle(RoomListAction.ToggleTag(quickAction.roomId, RoomTag.ROOM_TAG_LOW_PRIORITY)) } - is RoomListQuickActionsSharedAction.Leave -> { + is RoomListQuickActionsSharedAction.Leave -> { promptLeaveRoom(quickAction.roomId) } } @@ -484,21 +484,21 @@ class RoomListFragment @Inject constructor( message = getString(R.string.room_list_catchup_empty_body) ) } - RoomListDisplayMode.PEOPLE -> + RoomListDisplayMode.PEOPLE -> StateView.State.Empty( title = getString(R.string.room_list_people_empty_title), image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_dm), isBigImage = true, message = getString(R.string.room_list_people_empty_body) ) - RoomListDisplayMode.ROOMS -> + RoomListDisplayMode.ROOMS -> StateView.State.Empty( title = getString(R.string.room_list_rooms_empty_title), image = ContextCompat.getDrawable(requireContext(), R.drawable.empty_state_room), isBigImage = true, message = getString(R.string.room_list_rooms_empty_body) ) - else -> + else -> // Always display the content in this mode, because if the footer StateView.State.Content } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt index 15c0d4b125..3aeff50516 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt @@ -54,15 +54,15 @@ class RoomListSectionBuilderGroup( val actualGroupId = appStateHandler.safeActiveGroupId() when (mode) { - RoomListDisplayMode.PEOPLE -> { + RoomListDisplayMode.PEOPLE -> { // 4 sections Invites / Fav / Dms / Low Priority buildPeopleSections(sections, activeGroupAwareQueries, actualGroupId) } - RoomListDisplayMode.ROOMS -> { + RoomListDisplayMode.ROOMS -> { // 5 sections invites / Fav / Rooms / Low Priority / Server notice buildRoomsSections(sections, activeGroupAwareQueries, actualGroupId) } - RoomListDisplayMode.FILTERED -> { + RoomListDisplayMode.FILTERED -> { // Used when searching for rooms withQueryParams( { diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt index bef381b2e0..bd3e7bd1f9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt @@ -76,15 +76,15 @@ class RoomListSectionBuilderSpace( val sections = mutableListOf() val activeSpaceAwareQueries = mutableListOf() when (mode) { - RoomListDisplayMode.PEOPLE -> { + RoomListDisplayMode.PEOPLE -> { // 4 sections Invites / Fav / Dms / Low Priority buildDmSections(sections, activeSpaceAwareQueries) } - RoomListDisplayMode.ROOMS -> { + RoomListDisplayMode.ROOMS -> { // 6 sections invites / Fav / Rooms / Low Priority / Server notice / Suggested rooms buildRoomsSections(sections, activeSpaceAwareQueries) } - RoomListDisplayMode.FILTERED -> { + RoomListDisplayMode.FILTERED -> { // Used when searching for rooms buildFilteredSection(sections) } @@ -384,7 +384,7 @@ class RoomListSectionBuilderSpace( } }) } - RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater { override fun updateForSpaceId(roomId: String?) { if (roomId != null) { @@ -400,7 +400,7 @@ class RoomListSectionBuilderSpace( } }) } - RoomListViewModel.SpaceFilterStrategy.NONE -> { + RoomListViewModel.SpaceFilterStrategy.NONE -> { // we ignore current space for this one } } @@ -450,7 +450,7 @@ class RoomListSectionBuilderSpace( activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace) ) } - RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { + RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> { if (currentSpace == null) { copy( activeSpaceFilter = ActiveSpaceFilter.None @@ -461,7 +461,7 @@ class RoomListSectionBuilderSpace( ) } } - RoomListViewModel.SpaceFilterStrategy.NONE -> this + RoomListViewModel.SpaceFilterStrategy.NONE -> this } } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index 73540ac76a..49467c0531 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -156,16 +156,16 @@ class RoomListViewModel @AssistedInject constructor( override fun handle(action: RoomListAction) { when (action) { - is RoomListAction.SelectRoom -> handleSelectRoom(action) - is RoomListAction.AcceptInvitation -> handleAcceptInvitation(action) - is RoomListAction.RejectInvitation -> handleRejectInvitation(action) - is RoomListAction.FilterWith -> handleFilter(action) - is RoomListAction.LeaveRoom -> handleLeaveRoom(action) + is RoomListAction.SelectRoom -> handleSelectRoom(action) + is RoomListAction.AcceptInvitation -> handleAcceptInvitation(action) + is RoomListAction.RejectInvitation -> handleRejectInvitation(action) + is RoomListAction.FilterWith -> handleFilter(action) + is RoomListAction.LeaveRoom -> handleLeaveRoom(action) is RoomListAction.ChangeRoomNotificationState -> handleChangeNotificationMode(action) - is RoomListAction.ToggleTag -> handleToggleTag(action) - is RoomListAction.ToggleSection -> handleToggleSection(action.section) - is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action) - is RoomListAction.ShowRoomDetails -> handleShowRoomDetails(action) + is RoomListAction.ToggleTag -> handleToggleTag(action) + is RoomListAction.ToggleSection -> handleToggleSection(action.section) + is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action) + is RoomListAction.ShowRoomDetails -> handleShowRoomDetails(action) } } @@ -316,9 +316,9 @@ class RoomListViewModel @AssistedInject constructor( private fun String.otherTag(): String? { return when (this) { - RoomTag.ROOM_TAG_FAVOURITE -> RoomTag.ROOM_TAG_LOW_PRIORITY + RoomTag.ROOM_TAG_FAVOURITE -> RoomTag.ROOM_TAG_LOW_PRIORITY RoomTag.ROOM_TAG_LOW_PRIORITY -> RoomTag.ROOM_TAG_FAVOURITE - else -> null + else -> null } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt index 8c37445276..e831d446a5 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomSummaryItemFactory.kt @@ -56,7 +56,7 @@ class RoomSummaryItemFactory @Inject constructor( val changeMembershipState = roomChangeMembershipStates[roomSummary.roomId] ?: ChangeMembershipState.Unknown createInvitationItem(roomSummary, changeMembershipState, listener) } - else -> createRoomItem(roomSummary, selectedRoomIds, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked }) + else -> createRoomItem(roomSummary, selectedRoomIds, listener?.let { it::onRoomClicked }, listener?.let { it::onRoomLongClicked }) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt index a6b1a0de52..b629ca8bac 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt @@ -107,8 +107,8 @@ class RoomListQuickActionsBottomSheet : // Do not dismiss for all the actions when (quickAction) { is RoomListQuickActionsSharedAction.LowPriority -> Unit - is RoomListQuickActionsSharedAction.Favorite -> Unit - else -> dismiss() + is RoomListQuickActionsSharedAction.Favorite -> Unit + else -> dismiss() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt index 7f0de584cf..e1837a32de 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/actions/RoomListQuickActionsEpoxyController.kt @@ -83,9 +83,9 @@ class RoomListQuickActionsEpoxyController @Inject constructor( @StringRes private fun titleForNotificationState(notificationState: RoomNotificationState): Int? = when (notificationState) { RoomNotificationState.ALL_MESSAGES_NOISY -> R.string.room_settings_all_messages - RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only - RoomNotificationState.MUTE -> R.string.room_settings_none - else -> null + RoomNotificationState.MENTIONS_ONLY -> R.string.room_settings_mention_and_keyword_only + RoomNotificationState.MUTE -> R.string.room_settings_none + else -> null } private fun RoomListQuickActionsSharedAction.Leave.toBottomSheetItem() { diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsActivity.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsActivity.kt index 1ddd665ef4..71a24da5ae 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsActivity.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/ThreadsActivity.kt @@ -59,13 +59,13 @@ class ThreadsActivity : VectorBaseActivity() { private fun initFragment() { if (isFirstCreation()) { when (val fragment = fragmentToNavigate()) { - is DisplayFragment.ThreadList -> { + is DisplayFragment.ThreadList -> { initThreadListFragment(fragment.threadListArgs) } is DisplayFragment.ThreadTimeLine -> { initThreadTimelineFragment(fragment.threadTimelineArgs) } - is DisplayFragment.ErrorFragment -> { + is DisplayFragment.ErrorFragment -> { finish() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListItem.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListItem.kt index 385bb226a1..d5a6b72a1b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/model/ThreadListItem.kt @@ -81,7 +81,7 @@ abstract class ThreadListItem : VectorEpoxyModel() { private fun renderNotificationState(holder: Holder) { when (threadNotificationState) { - ThreadNotificationState.NEW_MESSAGE -> { + ThreadNotificationState.NEW_MESSAGE -> { holder.unreadImageView.isVisible = true holder.unreadImageView.setColorFilter(ContextCompat.getColor(holder.view.context, R.color.palette_gray_200)) } @@ -89,7 +89,7 @@ abstract class ThreadListItem : VectorEpoxyModel() { holder.unreadImageView.isVisible = true holder.unreadImageView.setColorFilter(ContextCompat.getColor(holder.view.context, R.color.palette_vermilion)) } - else -> { + else -> { holder.unreadImageView.isVisible = false } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt index d7dd03cbbd..14098fd8b0 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListController.kt @@ -50,7 +50,7 @@ class ThreadListController @Inject constructor( override fun buildModels() = when (session.homeServerCapabilitiesService().getHomeServerCapabilities().canUseThreading) { - true -> buildThreadSummaries() + true -> buildThreadSummaries() false -> buildThreadList() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt index eafad43016..4b7af330fb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt @@ -71,7 +71,7 @@ class ThreadListViewModel @AssistedInject constructor( */ private fun fetchAndObserveThreads() { when (session.homeServerCapabilitiesService().getHomeServerCapabilities().canUseThreading) { - true -> { + true -> { fetchThreadList() observeThreadSummaries() } diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt index 8e762fda96..13bf056301 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt @@ -87,7 +87,7 @@ class ThreadListFragment @Inject constructor( ThreadListBottomSheet().show(childFragmentManager, "Filtering") true } - else -> super.onOptionsItemSelected(item) + else -> super.onOptionsItemSelected(item) } } @@ -97,7 +97,7 @@ class ThreadListFragment @Inject constructor( val filterBadge = filterIcon.findViewById(R.id.threadListFilterBadge) filterBadge.isVisible = state.shouldFilterThreads when (threadListViewModel.canHomeserverUseThreading()) { - true -> menu.findItem(R.id.menu_thread_list_filter).isVisible = !state.threadSummaryList.invoke().isNullOrEmpty() + true -> menu.findItem(R.id.menu_thread_list_filter).isVisible = !state.threadSummaryList.invoke().isNullOrEmpty() false -> menu.findItem(R.id.menu_thread_list_filter).isVisible = !state.rootThreadEventList.invoke().isNullOrEmpty() } } @@ -182,7 +182,7 @@ class ThreadListFragment @Inject constructor( private fun renderEmptyStateIfNeeded(state: ThreadListViewState) { when (threadListViewModel.canHomeserverUseThreading()) { - true -> views.threadListEmptyConstraintLayout.isVisible = state.threadSummaryList.invoke().isNullOrEmpty() + true -> views.threadListEmptyConstraintLayout.isVisible = state.threadSummaryList.invoke().isNullOrEmpty() false -> views.threadListEmptyConstraintLayout.isVisible = state.rootThreadEventList.invoke().isNullOrEmpty() } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/typing/TypingHelper.kt b/vector/src/main/java/im/vector/app/features/home/room/typing/TypingHelper.kt index 6cc72a4045..8f5f57b86b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/typing/TypingHelper.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/typing/TypingHelper.kt @@ -38,7 +38,7 @@ class TypingHelper @Inject constructor(private val stringProvider: StringProvide typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName ) - else -> + else -> stringProvider.getString( R.string.room_many_users_are_typing, typingUsers[0].disambiguatedDisplayName, @@ -55,7 +55,7 @@ class TypingHelper @Inject constructor(private val stringProvider: StringProvide R.string.room_notification_two_users_are_typing, typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName ) - else -> stringProvider.getString( + else -> stringProvider.getString( R.string.room_notification_more_than_two_users_are_typing, typingUsers[0].disambiguatedDisplayName, typingUsers[1].disambiguatedDisplayName ) diff --git a/vector/src/main/java/im/vector/app/features/html/FontTagHandler.kt b/vector/src/main/java/im/vector/app/features/html/FontTagHandler.kt index 5327d70ec9..16f678f098 100644 --- a/vector/src/main/java/im/vector/app/features/html/FontTagHandler.kt +++ b/vector/src/main/java/im/vector/app/features/html/FontTagHandler.kt @@ -51,23 +51,23 @@ class FontTagHandler : SimpleTagHandler() { } catch (e: Exception) { // try other w3c colors? return when (colorName) { - "white" -> Color.WHITE - "yellow" -> Color.YELLOW + "white" -> Color.WHITE + "yellow" -> Color.YELLOW "fuchsia" -> Color.parseColor("#FF00FF") - "red" -> Color.RED - "silver" -> Color.parseColor("#C0C0C0") - "gray" -> Color.GRAY - "olive" -> Color.parseColor("#808000") - "purple" -> Color.parseColor("#800080") - "maroon" -> Color.parseColor("#800000") - "aqua" -> Color.parseColor("#00FFFF") - "lime" -> Color.parseColor("#00FF00") - "teal" -> Color.parseColor("#008080") - "green" -> Color.GREEN - "blue" -> Color.BLUE - "orange" -> Color.parseColor("#FFA500") - "navy" -> Color.parseColor("#000080") - else -> failResult + "red" -> Color.RED + "silver" -> Color.parseColor("#C0C0C0") + "gray" -> Color.GRAY + "olive" -> Color.parseColor("#808000") + "purple" -> Color.parseColor("#800080") + "maroon" -> Color.parseColor("#800000") + "aqua" -> Color.parseColor("#00FFFF") + "lime" -> Color.parseColor("#00FF00") + "teal" -> Color.parseColor("#008080") + "green" -> Color.GREEN + "blue" -> Color.BLUE + "orange" -> Color.parseColor("#FFA500") + "navy" -> Color.parseColor("#000080") + else -> failResult } } } diff --git a/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt b/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt index 72519cd97a..13a33cf30d 100644 --- a/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt +++ b/vector/src/main/java/im/vector/app/features/html/PillsPostProcessor.kt @@ -92,10 +92,10 @@ class PillsPostProcessor @AssistedInject constructor( private fun LinkSpan.createPillSpan(roomId: String?): PillImageSpan? { val matrixItem = when (val permalinkData = PermalinkParser.parse(url)) { - is PermalinkData.UserLink -> permalinkData.toMatrixItem(roomId) - is PermalinkData.RoomLink -> permalinkData.toMatrixItem() + is PermalinkData.UserLink -> permalinkData.toMatrixItem(roomId) + is PermalinkData.RoomLink -> permalinkData.toMatrixItem() is PermalinkData.GroupLink -> permalinkData.toMatrixItem() - else -> null + else -> null } ?: return null return createPillImageSpan(matrixItem) } @@ -112,7 +112,7 @@ class PillsPostProcessor @AssistedInject constructor( val room: RoomSummary? = sessionHolder.getSafeActiveSession()?.getRoomSummary(roomIdOrAlias) when { isRoomAlias -> MatrixItem.RoomAliasItem(roomIdOrAlias, room?.displayName, room?.avatarUrl) - else -> MatrixItem.RoomItem(roomIdOrAlias, room?.displayName, room?.avatarUrl) + else -> MatrixItem.RoomItem(roomIdOrAlias, room?.displayName, room?.avatarUrl) } } else { // Exclude event link (used in reply events, we do not want to pill the "in reply to") diff --git a/vector/src/main/java/im/vector/app/features/invite/InviteButtonStateBinder.kt b/vector/src/main/java/im/vector/app/features/invite/InviteButtonStateBinder.kt index 43763cdf37..024fb5aebb 100644 --- a/vector/src/main/java/im/vector/app/features/invite/InviteButtonStateBinder.kt +++ b/vector/src/main/java/im/vector/app/features/invite/InviteButtonStateBinder.kt @@ -32,9 +32,9 @@ object InviteButtonStateBinder { val requestInProgress = changeMembershipState.isInProgress() || changeMembershipState.isSuccessful() when { - requestInProgress -> acceptView.render(ButtonStateView.State.Loading) + requestInProgress -> acceptView.render(ButtonStateView.State.Loading) changeMembershipState is ChangeMembershipState.FailedJoining -> acceptView.render(ButtonStateView.State.Error) - else -> acceptView.render(ButtonStateView.State.Button) + else -> acceptView.render(ButtonStateView.State.Button) } // ButtonStateView.State.Loaded not used because roomSummary will not be displayed as a room invitation anymore @@ -42,7 +42,7 @@ object InviteButtonStateBinder { when (changeMembershipState) { is ChangeMembershipState.FailedLeaving -> rejectView.render(ButtonStateView.State.Error) - else -> rejectView.render(ButtonStateView.State.Button) + else -> rejectView.render(ButtonStateView.State.Button) } } } diff --git a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt index 7bb6670e96..304ec72ce2 100644 --- a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt @@ -69,12 +69,12 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() { .stream() .onEach { sharedAction -> when (sharedAction) { - UserListSharedAction.Close -> finish() - UserListSharedAction.GoBack -> onBackPressed() + UserListSharedAction.Close -> finish() + UserListSharedAction.GoBack -> onBackPressed() is UserListSharedAction.OnMenuItemSelected -> onMenuItemSelected(sharedAction) - UserListSharedAction.OpenPhoneBook -> openPhoneBook() + UserListSharedAction.OpenPhoneBook -> openPhoneBook() // not exhaustive because it's a sharedAction - else -> Unit + else -> Unit } } .launchIn(lifecycleScope) diff --git a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomViewModel.kt b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomViewModel.kt index 63cf666f30..68b0329a86 100644 --- a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomViewModel.kt @@ -60,18 +60,18 @@ class InviteUsersToRoomViewModel @AssistedInject constructor( selections.asFlow() .map { user -> when (user) { - is PendingSelection.UserPendingSelection -> room.membershipService().invite(user.user.userId, null) + is PendingSelection.UserPendingSelection -> room.membershipService().invite(user.user.userId, null) is PendingSelection.ThreePidPendingSelection -> room.membershipService().invite3pid(user.threePid) } }.onCompletion { error -> if (error != null) return@onCompletion val successMessage = when (selections.size) { - 1 -> stringProvider.getString( + 1 -> stringProvider.getString( R.string.invitation_sent_to_one_user, selections.first().getBestName() ) - 2 -> stringProvider.getString( + 2 -> stringProvider.getString( R.string.invitations_sent_to_two_users, selections.first().getBestName(), selections.last().getBestName() diff --git a/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt b/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt index e453a347f5..32b4bf3f12 100644 --- a/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt +++ b/vector/src/main/java/im/vector/app/features/lifecycle/VectorActivityLifecycleCallbacks.kt @@ -66,7 +66,7 @@ class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager } catch (failure: Throwable) { when (failure) { // The task was not found. We can ignore it. - is IllegalArgumentException -> { + is IllegalArgumentException -> { Timber.e("The task was not found: ${failure.localizedMessage}") false } @@ -74,7 +74,7 @@ class VectorActivityLifecycleCallbacks constructor(private val popupAlertManager Timber.e("Package manager error: ${failure.localizedMessage}") true } - else -> throw failure + else -> throw failure } } diff --git a/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt b/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt index a51491e85b..6de73cb20f 100644 --- a/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt @@ -59,16 +59,16 @@ class LinkHandlerActivity : VectorBaseActivity() { private fun handleIntent() { val uri = intent.data when { - uri == null -> { + uri == null -> { // Should not happen Timber.w("Uri is null") finish() } - uri.getQueryParameter(LoginConfig.CONFIG_HS_PARAMETER) != null -> handleConfigUrl(uri) - uri.toString().startsWith(PermalinkService.MATRIX_TO_URL_BASE) -> handleSupportedHostUrl() - uri.toString().startsWith(PermalinkHandler.MATRIX_TO_CUSTOM_SCHEME_URL_BASE) -> handleSupportedHostUrl() + uri.getQueryParameter(LoginConfig.CONFIG_HS_PARAMETER) != null -> handleConfigUrl(uri) + uri.toString().startsWith(PermalinkService.MATRIX_TO_URL_BASE) -> handleSupportedHostUrl() + uri.toString().startsWith(PermalinkHandler.MATRIX_TO_CUSTOM_SCHEME_URL_BASE) -> handleSupportedHostUrl() resources.getStringArray(R.array.permalink_supported_hosts).contains(uri.host) -> handleSupportedHostUrl() - else -> { + else -> { // Other links are not yet handled, but should not come here (manifest configuration error?) toast(R.string.universal_link_malformed) finish() diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt index 10c271727b..169af4a5a2 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingActivity.kt @@ -57,7 +57,7 @@ class LocationSharingActivity : VectorBaseActivity { + LocationSharingMode.PREVIEW -> { addFragment( views.fragmentContainer, LocationPreviewFragment::class.java, diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index cc5586e7f5..251e7003eb 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -89,9 +89,9 @@ class LocationSharingFragment @Inject constructor( viewModel.observeViewEvents { when (it) { - LocationSharingViewEvents.Close -> locationSharingNavigator.quit() - LocationSharingViewEvents.LocationNotAvailableError -> handleLocationNotAvailableError() - is LocationSharingViewEvents.ZoomToUserLocation -> handleZoomToUserLocationEvent(it) + LocationSharingViewEvents.Close -> locationSharingNavigator.quit() + LocationSharingViewEvents.LocationNotAvailableError -> handleLocationNotAvailableError() + is LocationSharingViewEvents.ZoomToUserLocation -> handleZoomToUserLocationEvent(it) is LocationSharingViewEvents.StartLiveLocationService -> handleStartLiveLocationService(it) } } @@ -254,7 +254,7 @@ class LocationSharingFragment @Inject constructor( private fun updateMap(state: LocationSharingViewState) { // first, update the options view val options: Set = when (state.areTargetAndUserLocationEqual) { - true -> { + true -> { if (vectorPreferences.labsEnableLiveLocation()) { setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE) } else { @@ -262,7 +262,7 @@ class LocationSharingFragment @Inject constructor( } } false -> setOf(LocationSharingOption.PINNED) - else -> emptySet() + else -> emptySet() } views.shareLocationOptionsPicker.render(options) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt index 231de00094..9ca340f098 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingViewModel.kt @@ -118,10 +118,10 @@ class LocationSharingViewModel @AssistedInject constructor( override fun handle(action: LocationSharingAction) { when (action) { - LocationSharingAction.CurrentUserLocationSharing -> handleCurrentUserLocationSharingAction() - is LocationSharingAction.PinnedLocationSharing -> handlePinnedLocationSharingAction(action) - is LocationSharingAction.LocationTargetChange -> handleLocationTargetChangeAction(action) - LocationSharingAction.ZoomToUserLocation -> handleZoomToUserLocationAction() + LocationSharingAction.CurrentUserLocationSharing -> handleCurrentUserLocationSharingAction() + is LocationSharingAction.PinnedLocationSharing -> handlePinnedLocationSharingAction(action) + is LocationSharingAction.LocationTargetChange -> handleLocationTargetChangeAction(action) + LocationSharingAction.ZoomToUserLocation -> handleZoomToUserLocationAction() is LocationSharingAction.StartLiveLocationSharing -> handleStartLiveLocationSharingAction(action.durationMillis) } } diff --git a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt index 4e56e7954c..1913f4202d 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationTracker.kt @@ -129,7 +129,7 @@ class LocationTracker @Inject constructor( LocationManager.GPS_PROVIDER -> { hasGpsProviderLiveLocation = isLive } - else -> { + else -> { if (hasGpsProviderLiveLocation) { // Ignore this update Timber.d("## LocationTracker. ignoring location from ${location.provider}, we have gps live location") diff --git a/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt b/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt index 36165d4524..5cde84a2d9 100644 --- a/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/location/live/duration/ChooseLiveDurationBottomSheet.kt @@ -72,7 +72,7 @@ class ChooseLiveDurationBottomSheet : R.id.liveLocShareChooseDurationOption1 -> DURATION_IN_MS_OPTION_1 R.id.liveLocShareChooseDurationOption2 -> DURATION_IN_MS_OPTION_2 R.id.liveLocShareChooseDurationOption3 -> DURATION_IN_MS_OPTION_3 - else -> DURATION_IN_MS_OPTION_1 + else -> DURATION_IN_MS_OPTION_1 } } diff --git a/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt b/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt index b11e6739eb..9512a518e8 100644 --- a/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/AbstractLoginFragment.kt @@ -65,7 +65,7 @@ abstract class AbstractLoginFragment : VectorBaseFragment( private fun handleLoginViewEvents(loginViewEvents: LoginViewEvents) { when (loginViewEvents) { is LoginViewEvents.Failure -> showFailure(loginViewEvents.throwable) - else -> + else -> // This is handled by the Activity Unit } @@ -140,7 +140,7 @@ abstract class AbstractLoginFragment : VectorBaseFragment( true } - displayCancelDialog && isResetPasswordStarted -> { + displayCancelDialog && isResetPasswordStarted -> { // Ask for confirmation before cancelling the reset password MaterialAlertDialogBuilder(requireActivity()) .setTitle(R.string.login_reset_password_cancel_confirmation_title) @@ -154,7 +154,7 @@ abstract class AbstractLoginFragment : VectorBaseFragment( true } - else -> { + else -> { resetViewModel() // Do not consume the Back event false diff --git a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt index 42a9b18558..15e5efe54c 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginActivity.kt @@ -106,7 +106,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA private fun handleLoginViewEvents(loginViewEvents: LoginViewEvents) { when (loginViewEvents) { - is LoginViewEvents.RegistrationFlowResult -> { + is LoginViewEvents.RegistrationFlowResult -> { // Check that all flows are supported by the application if (loginViewEvents.flowResult.missingStages.any { !it.isSupported() }) { // Display a popup to propose use web fallback @@ -128,7 +128,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA } } } - is LoginViewEvents.OutdatedHomeserver -> { + is LoginViewEvents.OutdatedHomeserver -> { MaterialAlertDialogBuilder(this) .setTitle(R.string.login_error_outdated_homeserver_title) .setMessage(R.string.login_error_outdated_homeserver_warning_content) @@ -136,7 +136,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA .show() Unit } - is LoginViewEvents.OpenServerSelection -> + is LoginViewEvents.OpenServerSelection -> addFragmentToBackstack(views.loginFragmentContainer, LoginServerSelectionFragment::class.java, option = { ft -> @@ -148,22 +148,22 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA // TODO Disabled because it provokes a flickering // ft.setCustomAnimations(enterAnim, exitAnim, popEnterAnim, popExitAnim) }) - is LoginViewEvents.OnServerSelectionDone -> onServerSelectionDone(loginViewEvents) - is LoginViewEvents.OnSignModeSelected -> onSignModeSelected(loginViewEvents) - is LoginViewEvents.OnLoginFlowRetrieved -> + is LoginViewEvents.OnServerSelectionDone -> onServerSelectionDone(loginViewEvents) + is LoginViewEvents.OnSignModeSelected -> onSignModeSelected(loginViewEvents) + is LoginViewEvents.OnLoginFlowRetrieved -> addFragmentToBackstack( views.loginFragmentContainer, LoginSignUpSignInSelectionFragment::class.java, option = commonOption ) - is LoginViewEvents.OnWebLoginError -> onWebLoginError(loginViewEvents) - is LoginViewEvents.OnForgetPasswordClicked -> + is LoginViewEvents.OnWebLoginError -> onWebLoginError(loginViewEvents) + is LoginViewEvents.OnForgetPasswordClicked -> addFragmentToBackstack( views.loginFragmentContainer, LoginResetPasswordFragment::class.java, option = commonOption ) - is LoginViewEvents.OnResetPasswordSendThreePidDone -> { + is LoginViewEvents.OnResetPasswordSendThreePidDone -> { supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) addFragmentToBackstack( views.loginFragmentContainer, @@ -171,7 +171,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA option = commonOption ) } - is LoginViewEvents.OnResetPasswordMailConfirmationSuccess -> { + is LoginViewEvents.OnResetPasswordMailConfirmationSuccess -> { supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) addFragmentToBackstack( views.loginFragmentContainer, @@ -183,7 +183,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA // Go back to the login fragment supportFragmentManager.popBackStack(FRAGMENT_LOGIN_TAG, POP_BACK_STACK_EXCLUSIVE) } - is LoginViewEvents.OnSendEmailSuccess -> { + is LoginViewEvents.OnSendEmailSuccess -> { // Pop the enter email Fragment supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) addFragmentToBackstack( @@ -194,7 +194,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA option = commonOption ) } - is LoginViewEvents.OnSendMsisdnSuccess -> { + is LoginViewEvents.OnSendMsisdnSuccess -> { // Pop the enter Msisdn Fragment supportFragmentManager.popBackStack(FRAGMENT_REGISTRATION_STAGE_TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE) addFragmentToBackstack( @@ -206,7 +206,7 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA ) } is LoginViewEvents.Failure, - is LoginViewEvents.Loading -> + is LoginViewEvents.Loading -> // This is handled by the Fragments Unit } @@ -247,29 +247,29 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA when (loginViewEvents.serverType) { ServerType.MatrixOrg -> Unit // In this case, we wait for the login flow ServerType.EMS, - ServerType.Other -> addFragmentToBackstack( + ServerType.Other -> addFragmentToBackstack( views.loginFragmentContainer, LoginServerUrlFormFragment::class.java, option = commonOption ) - ServerType.Unknown -> Unit /* Should not happen */ + ServerType.Unknown -> Unit /* Should not happen */ } } private fun onSignModeSelected(loginViewEvents: LoginViewEvents.OnSignModeSelected) = withState(loginViewModel) { state -> // state.signMode could not be ready yet. So use value from the ViewEvent when (loginViewEvents.signMode) { - SignMode.Unknown -> error("Sign mode has to be set before calling this method") - SignMode.SignUp -> { + SignMode.Unknown -> error("Sign mode has to be set before calling this method") + SignMode.SignUp -> { // This is managed by the LoginViewEvents } - SignMode.SignIn -> { + SignMode.SignIn -> { // It depends on the LoginMode when (state.loginMode) { LoginMode.Unknown, - is LoginMode.Sso -> error("Developer error") + is LoginMode.Sso -> error("Developer error") is LoginMode.SsoAndPassword, - LoginMode.Password -> addFragmentToBackstack( + LoginMode.Password -> addFragmentToBackstack( views.loginFragmentContainer, LoginFragment::class.java, tag = FRAGMENT_LOGIN_TAG, @@ -361,28 +361,28 @@ open class LoginActivity : VectorBaseActivity(), UnlockedA tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption ) - is Stage.Email -> addFragmentToBackstack( + is Stage.Email -> addFragmentToBackstack( views.loginFragmentContainer, LoginGenericTextInputFormFragment::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetEmail, stage.mandatory), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption ) - is Stage.Msisdn -> addFragmentToBackstack( + is Stage.Msisdn -> addFragmentToBackstack( views.loginFragmentContainer, LoginGenericTextInputFormFragment::class.java, LoginGenericTextInputFormFragmentArgument(TextInputFormFragmentMode.SetMsisdn, stage.mandatory), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption ) - is Stage.Terms -> addFragmentToBackstack( + is Stage.Terms -> addFragmentToBackstack( views.loginFragmentContainer, LoginTermsFragment::class.java, LoginTermsFragmentArgument(stage.policies.toLocalizedLoginTerms(getString(R.string.resources_language))), tag = FRAGMENT_REGISTRATION_STAGE_TAG, option = commonOption ) - else -> Unit // Should not happen + else -> Unit // Should not happen } } diff --git a/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt index e8c0b25027..1d25732ee4 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt @@ -85,8 +85,8 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment= Build.VERSION_CODES.O) { when (state.signMode) { - SignMode.Unknown -> error("developer error") - SignMode.SignUp -> { + SignMode.Unknown -> error("developer error") + SignMode.SignUp -> { views.loginField.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_USERNAME) views.passwordField.setAutofillHints(HintConstants.AUTOFILL_HINT_NEW_PASSWORD) } @@ -101,8 +101,8 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment error("developer error") - SignMode.SignUp -> SocialLoginButtonsView.Mode.MODE_SIGN_UP + SignMode.Unknown -> error("developer error") + SignMode.SignUp -> SocialLoginButtonsView.Mode.MODE_SIGN_UP SignMode.SignIn, SignMode.SignInWithMatrixId -> SocialLoginButtonsView.Mode.MODE_SIGN_IN } @@ -155,9 +155,9 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment error("developer error") - SignMode.SignUp -> R.string.login_signup_username_hint - SignMode.SignIn -> R.string.login_signin_username_hint + SignMode.Unknown -> error("developer error") + SignMode.SignUp -> R.string.login_signup_username_hint + SignMode.SignIn -> R.string.login_signin_username_hint SignMode.SignInWithMatrixId -> R.string.login_signin_matrix_id_hint } ) @@ -170,9 +170,9 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment error("developer error") - SignMode.SignUp -> R.string.login_signup_to - SignMode.SignIn -> R.string.login_connect_to + SignMode.Unknown -> error("developer error") + SignMode.SignUp -> R.string.login_signup_to + SignMode.SignIn -> R.string.login_connect_to SignMode.SignInWithMatrixId -> R.string.login_connect_to } @@ -183,18 +183,18 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment { + ServerType.EMS -> { views.loginServerIcon.isVisible = true views.loginServerIcon.setImageResource(R.drawable.ic_logo_element_matrix_services) views.loginTitle.text = getString(resId, "Element Matrix Services") views.loginNotice.text = getString(R.string.login_server_modular_text) } - ServerType.Other -> { + ServerType.Other -> { views.loginServerIcon.isVisible = false views.loginTitle.text = getString(resId, state.homeServerUrlFromUser.toReducedUrl()) views.loginNotice.text = getString(R.string.login_server_other_text) } - ServerType.Unknown -> Unit /* Should not happen */ + ServerType.Unknown -> Unit /* Should not happen */ } views.loginPasswordNotice.isVisible = false @@ -223,8 +223,8 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment error("developer error") - SignMode.SignUp -> R.string.login_signup_submit + SignMode.Unknown -> error("developer error") + SignMode.SignUp -> R.string.login_signup_submit SignMode.SignIn, SignMode.SignInWithMatrixId -> R.string.login_signin } @@ -279,7 +279,7 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment