Reformats after merging

This commit is contained in:
ericdecanini 2022-06-08 13:01:26 +02:00
parent 6df88fba59
commit 87053f2c70
8 changed files with 83 additions and 83 deletions

View file

@ -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, InitialSyncStep.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, InitialSyncStep.ImportingAccountGroups, 0.1f) {
handleLeftGroup(realm, it.key)
}

View file

@ -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, InitialSyncStep.ImportingAccountLeftRooms, 0.3f) {
handleLeftRoom(realm, it.key, it.value, insertType, syncLocalTimeStampMillis)
}
@ -578,12 +578,12 @@ internal class RoomSyncHandler @Inject constructor(
readReceiptHandler.handle(realm, roomId, readReceiptContent, isInitialSync, aggregator)
}
}
EventType.TYPING -> {
EventType.TYPING -> {
event.content.toModel<TypingEventContent>()?.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")
}
}

View file

@ -199,15 +199,15 @@ 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 -> openGroup(sharedAction.shouldClearFragment)
is HomeActivitySharedAction.OpenSpacePreview -> startActivity(SpacePreviewActivity.newIntent(this, sharedAction.spaceId))
is HomeActivitySharedAction.AddSpace -> createSpaceResultLauncher.launch(SpaceCreationActivity.newIntent(this))
is HomeActivitySharedAction.OpenDrawer -> views.drawerLayout.openDrawer(GravityCompat.START)
is HomeActivitySharedAction.CloseDrawer -> views.drawerLayout.closeDrawer(GravityCompat.START)
is HomeActivitySharedAction.OpenGroup -> openGroup(sharedAction.shouldClearFragment)
is HomeActivitySharedAction.OpenSpacePreview -> startActivity(SpacePreviewActivity.newIntent(this, sharedAction.spaceId))
is HomeActivitySharedAction.AddSpace -> createSpaceResultLauncher.launch(SpaceCreationActivity.newIntent(this))
is HomeActivitySharedAction.ShowSpaceSettings -> showSpaceSettings(sharedAction.spaceId)
is HomeActivitySharedAction.OpenSpaceInvite -> openSpaceInvite(sharedAction.spaceId)
HomeActivitySharedAction.SendSpaceFeedBack -> bugReporter.openBugReportScreen(this, ReportType.SPACE_BETA_FEEDBACK)
HomeActivitySharedAction.CloseGroup -> closeGroup()
is HomeActivitySharedAction.OpenSpaceInvite -> openSpaceInvite(sharedAction.spaceId)
HomeActivitySharedAction.SendSpaceFeedBack -> bugReporter.openBugReportScreen(this, ReportType.SPACE_BETA_FEEDBACK)
HomeActivitySharedAction.CloseGroup -> closeGroup()
}
}
.launchIn(lifecycleScope)
@ -226,20 +226,20 @@ class HomeActivity :
homeActivityViewModel.observeViewEvents {
when (it) {
is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it)
is HomeActivityViewEvents.OnNewSession -> handleOnNewSession(it)
HomeActivityViewEvents.PromptToEnableSessionPush -> handlePromptToEnablePush()
HomeActivityViewEvents.StartRecoverySetupFlow -> handleStartRecoverySetup()
is HomeActivityViewEvents.ForceVerification -> {
is HomeActivityViewEvents.OnNewSession -> handleOnNewSession(it)
HomeActivityViewEvents.PromptToEnableSessionPush -> handlePromptToEnablePush()
HomeActivityViewEvents.StartRecoverySetupFlow -> handleStartRecoverySetup()
is HomeActivityViewEvents.ForceVerification -> {
if (it.sendRequest) {
navigator.requestSelfSessionVerification(this)
} else {
navigator.waitSessionVerification(this)
}
}
is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it)
HomeActivityViewEvents.ShowAnalyticsOptIn -> handleShowAnalyticsOptIn()
HomeActivityViewEvents.NotifyUserForThreadsMigration -> handleNotifyUserForThreadsMigration()
is HomeActivityViewEvents.MigrateThreads -> migrateThreadsIfNeeded(it.checkSession)
is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it)
HomeActivityViewEvents.ShowAnalyticsOptIn -> handleShowAnalyticsOptIn()
HomeActivityViewEvents.NotifyUserForThreadsMigration -> handleNotifyUserForThreadsMigration()
is HomeActivityViewEvents.MigrateThreads -> migrateThreadsIfNeeded(it.checkSession)
}
}
homeActivityViewModel.onEach { renderState(it) }
@ -337,12 +337,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 {
@ -392,7 +392,7 @@ class HomeActivity :
}
views.waitingView.root.isVisible = true
}
else -> {
else -> {
// Idle or Incremental sync status
views.waitingView.root.isVisible = false
}
@ -544,15 +544,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
@ -566,11 +566,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
}

View file

@ -131,10 +131,10 @@ class HomeActivityViewModel @AssistedInject constructor(
}
}
}
AuthenticationDescription.Login -> {
AuthenticationDescription.Login -> {
// do nothing
}
null -> {
null -> {
// do nothing
}
}
@ -198,7 +198,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
@ -208,7 +208,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))
}
@ -225,7 +225,7 @@ class HomeActivityViewModel @AssistedInject constructor(
is SyncRequestState.Idle -> {
maybeVerifyOrBootstrapCrossSigning()
}
else -> Unit
else -> Unit
}
setState {
@ -426,7 +426,7 @@ class HomeActivityViewModel @AssistedInject constructor(
HomeActivityViewActions.PushPromptHasBeenReviewed -> {
vectorPreferences.setDidAskUserToEnableSessionPush()
}
HomeActivityViewActions.ViewStarted -> {
HomeActivityViewActions.ViewStarted -> {
initialize()
}
}

View file

@ -27,16 +27,16 @@ class InitSyncStepFormatter @Inject constructor(
fun format(initialSyncStep: InitialSyncStep): String {
return stringProvider.getString(
when (initialSyncStep) {
InitialSyncStep.ServerComputing -> R.string.initial_sync_start_server_computing
InitialSyncStep.Downloading -> R.string.initial_sync_start_downloading
InitialSyncStep.ImportingAccount -> R.string.initial_sync_start_importing_account
InitialSyncStep.ImportingAccountCrypto -> R.string.initial_sync_start_importing_account_crypto
InitialSyncStep.ImportingAccountRoom -> R.string.initial_sync_start_importing_account_rooms
InitialSyncStep.ImportingAccountGroups -> R.string.initial_sync_start_importing_account_groups
InitialSyncStep.ImportingAccountData -> R.string.initial_sync_start_importing_account_data
InitialSyncStep.ImportingAccountJoinedRooms -> R.string.initial_sync_start_importing_account_joined_rooms
InitialSyncStep.ServerComputing -> R.string.initial_sync_start_server_computing
InitialSyncStep.Downloading -> R.string.initial_sync_start_downloading
InitialSyncStep.ImportingAccount -> R.string.initial_sync_start_importing_account
InitialSyncStep.ImportingAccountCrypto -> R.string.initial_sync_start_importing_account_crypto
InitialSyncStep.ImportingAccountRoom -> R.string.initial_sync_start_importing_account_rooms
InitialSyncStep.ImportingAccountGroups -> R.string.initial_sync_start_importing_account_groups
InitialSyncStep.ImportingAccountData -> R.string.initial_sync_start_importing_account_data
InitialSyncStep.ImportingAccountJoinedRooms -> R.string.initial_sync_start_importing_account_joined_rooms
InitialSyncStep.ImportingAccountInvitedRooms -> R.string.initial_sync_start_importing_account_invited_rooms
InitialSyncStep.ImportingAccountLeftRooms -> R.string.initial_sync_start_importing_account_left_rooms
InitialSyncStep.ImportingAccountLeftRooms -> R.string.initial_sync_start_importing_account_left_rooms
}
)
}

View file

@ -200,18 +200,18 @@ class MessageItemFactory @Inject constructor(
// val all = event.root.toContent()
// val ev = all.toModel<Event>()
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 -> buildLocationItem(messageContent, informationData, highlight, attributes)
is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(params.event, highlight, attributes)
else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes)
is MessagePollContent -> buildPollItem(messageContent, informationData, highlight, callback, attributes)
is MessageLocationContent -> buildLocationItem(messageContent, informationData, highlight, attributes)
is MessageBeaconInfoContent -> liveLocationShareMessageItemFactory.create(params.event, highlight, attributes)
else -> buildNotHandledMessageItem(messageContent, informationData, highlight, callback, attributes)
}
return messageItem?.apply {
layout(informationData.messageLayout.layoutRes)
@ -277,11 +277,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<PollAnswer>.mapToOptions(
@ -299,11 +299,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)
}
}
@ -323,11 +323,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)
}
}

View file

@ -151,15 +151,15 @@ class TimelineMessageLayoutFactory @Inject constructor(
private fun MessageContent?.timestampInsideMessage(): Boolean {
return when {
this == null -> false
else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE
this == null -> false
else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE
}
}
private fun MessageContent?.shouldAddMessageOverlay(): Boolean {
return when {
this == null || msgType == MessageType.MSGTYPE_BEACON_INFO -> false
else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE
else -> msgType in MSG_TYPES_WITH_TIMESTAMP_INSIDE_MESSAGE
}
}
@ -210,10 +210,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
}
}
}

View file

@ -66,23 +66,23 @@ class SyncStateView @JvmOverloads constructor(context: Context, attrs: Attribute
private fun SyncState.toHumanReadable(): String {
return when (this) {
SyncState.Idle -> "Idle"
SyncState.Idle -> "Idle"
SyncState.InvalidToken -> "InvalidToken"
SyncState.Killed -> "Killed"
SyncState.Killing -> "Killing"
SyncState.NoNetwork -> "NoNetwork"
SyncState.Paused -> "Paused"
is SyncState.Running -> "$this"
SyncState.Killed -> "Killed"
SyncState.Killing -> "Killing"
SyncState.NoNetwork -> "NoNetwork"
SyncState.Paused -> "Paused"
is SyncState.Running -> "$this"
}
}
private fun SyncRequestState.IncrementalSyncRequestState.toHumanReadable(): String {
return when (this) {
SyncRequestState.IncrementalSyncIdle -> "Idle"
SyncRequestState.IncrementalSyncIdle -> "Idle"
is SyncRequestState.IncrementalSyncParsing -> "Parsing ${this.rooms} room(s) ${this.toDevice} toDevice(s)"
SyncRequestState.IncrementalSyncError -> "Error"
SyncRequestState.IncrementalSyncDone -> "Done"
else -> "?"
SyncRequestState.IncrementalSyncError -> "Error"
SyncRequestState.IncrementalSyncDone -> "Done"
else -> "?"
}
}
}