Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformats project based on editorconfig #5953

Merged
merged 4 commits into from
May 6, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ internal class SendGossipRequestWorker(context: Context, params: WorkerParameter
val eventType: String
val requestId: String
when {
params.keyShareRequest != null -> {
params.keyShareRequest != null -> {
eventType = EventType.ROOM_KEY_REQUEST
requestId = params.keyShareRequest.requestId
val toDeviceContent = RoomKeyShareRequest(
@@ -120,7 +120,7 @@ internal class SendGossipRequestWorker(context: Context, params: WorkerParameter
}
}
}
else -> {
else -> {
return buildErrorResult(params, "Unknown empty gossiping request").also {
Timber.e("Unknown empty gossiping request: $params")
}
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@ internal class DefaultLegacySessionImporter @Inject constructor(
bytes = it.bytes,
hashType = when (it.type) {
LegacyFingerprint.HashType.SHA1,
null -> Fingerprint.HashType.SHA1
null -> Fingerprint.HashType.SHA1
LegacyFingerprint.HashType.SHA256 -> Fingerprint.HashType.SHA256
}
)
Original file line number Diff line number Diff line change
@@ -60,10 +60,10 @@ internal class DefaultDeactivateAccountTask @Inject constructor(
execute(params.copy(userAuthParam = authUpdate))
}
)) {
UiaResult.SUCCESS -> {
UiaResult.SUCCESS -> {
false
}
UiaResult.FAILURE -> {
UiaResult.FAILURE -> {
Timber.d("## UIA: propagate failure")
throw throwable
}
Original file line number Diff line number Diff line change
@@ -165,8 +165,8 @@ internal class DefaultProfileService @Inject constructor(private val taskExecuto

private fun UserThreePidEntity.asDomain(): ThreePid {
return when (medium) {
ThirdPartyIdentifier.MEDIUM_EMAIL -> ThreePid.Email(address)
ThirdPartyIdentifier.MEDIUM_EMAIL -> ThreePid.Email(address)
ThirdPartyIdentifier.MEDIUM_MSISDN -> ThreePid.Msisdn(address)
else -> error("Invalid medium type")
else -> error("Invalid medium type")
}
}
Original file line number Diff line number Diff line change
@@ -260,17 +260,15 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver

private fun handleGlobalError(globalError: GlobalError) {
when (globalError) {
is GlobalError.InvalidToken ->
is GlobalError.InvalidToken ->
handleInvalidToken(globalError)
is GlobalError.ConsentNotGivenError ->
consentNotGivenHelper.displayDialog(
globalError.consentUri,
activeSessionHolder.getActiveSession().sessionParams.homeServerHost ?: ""
)
is GlobalError.CertificateError ->
consentNotGivenHelper.displayDialog(globalError.consentUri,
activeSessionHolder.getActiveSession().sessionParams.homeServerHost ?: "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this change in the "revert" commit is not expected. Can you double check that this file is properly formatted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again caused by long line wrapping. Extracted it out into a private function to make it work with formatting and just generally look cleaner

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not clear: there should be a line break after (, and another one before )

is GlobalError.CertificateError ->
handleCertificateError(globalError)
GlobalError.ExpiredAccount -> Unit // TODO Handle account expiration
is GlobalError.InitialSyncRequest -> handleInitialSyncRequest(globalError)
GlobalError.ExpiredAccount -> Unit // TODO Handle account expiration
is GlobalError.InitialSyncRequest -> handleInitialSyncRequest(globalError)
}
}

Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ class ContactsBookFragment @Inject constructor(
.allowBack(useCross = true)
contactsBookViewModel.observeViewEvents {
when (it) {
is ContactsBookViewEvents.Failure -> showFailure(it.throwable)
is ContactsBookViewEvents.Failure -> showFailure(it.throwable)
is ContactsBookViewEvents.OnPoliciesRetrieved -> showConsentDialog(it)
}
}
Original file line number Diff line number Diff line change
@@ -160,10 +160,10 @@ class ContactsBookViewModel @AssistedInject constructor(

override fun handle(action: ContactsBookAction) {
when (action) {
is ContactsBookAction.FilterWith -> handleFilterWith(action)
is ContactsBookAction.FilterWith -> handleFilterWith(action)
is ContactsBookAction.OnlyBoundContacts -> handleOnlyBoundContacts(action)
ContactsBookAction.UserConsentGranted -> handleUserConsentGranted()
ContactsBookAction.UserConsentRequest -> handleUserConsentRequest()
ContactsBookAction.UserConsentGranted -> handleUserConsentGranted()
ContactsBookAction.UserConsentRequest -> handleUserConsentRequest()
}
}

Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ class KeysBackupRestoreSharedViewModel @Inject constructor(
val progressObserver = object : StepProgressListener {
override fun onStepProgress(step: StepProgressListener.Step) {
when (step) {
is StepProgressListener.Step.ComputingKey -> {
is StepProgressListener.Step.ComputingKey -> {
loadingEvent.postValue(
WaitingViewData(
stringProvider.getString(R.string.keys_backup_restoring_waiting_message) +
@@ -102,7 +102,7 @@ class KeysBackupRestoreSharedViewModel @Inject constructor(
)
)
}
is StepProgressListener.Step.ImportingKey -> {
is StepProgressListener.Step.ImportingKey -> {
Timber.d("backupKeys.ImportingKey.progress: ${step.progress}")
// Progress 0 can take a while, display an indeterminate progress in this case
if (step.progress == 0) {
Original file line number Diff line number Diff line change
@@ -134,13 +134,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()
}
}

Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
// TODO maybe check also if
val uid = "kvr_${tx.transactionId}"
when (tx.state) {
is VerificationTxState.OnStarted -> {
is VerificationTxState.OnStarted -> {
// Add a notification for every incoming request
val user = session?.userService()?.getUser(tx.otherUserId)
val name = user?.toMatrixItem()?.getBestName() ?: tx.otherUserId
@@ -116,7 +116,7 @@ class IncomingVerificationRequestHandler @Inject constructor(
// cancel related notification
popupAlertManager.cancelAlert(uid)
}
else -> Unit
else -> Unit
}
}

Original file line number Diff line number Diff line change
@@ -127,9 +127,9 @@ class MergedHeaderItemFactory @Inject constructor(private val activeSessionHolde
}
val mergeId = mergedEventIds.joinToString(separator = "_") { it.toString() }
val summaryTitleResId = when (event.root.getClearType()) {
EventType.STATE_ROOM_MEMBER -> R.plurals.membership_changes
EventType.STATE_ROOM_MEMBER -> R.plurals.membership_changes
EventType.STATE_ROOM_SERVER_ACL -> R.plurals.notice_room_server_acl_changes
else -> null
else -> null
}
summaryTitleResId?.let { summaryTitle ->
val attributes = MergedSimilarEventsItem.Attributes(
Original file line number Diff line number Diff line change
@@ -78,10 +78,10 @@ abstract class AbstractLoginFragment<VB : ViewBinding> : VectorBaseFragment<VB>(
}

when (throwable) {
is CancellationException ->
is CancellationException ->
/* Ignore this error, user has cancelled the action */
Unit
is Failure.ServerError ->
is Failure.ServerError ->
if (throwable.error.code == MatrixError.M_FORBIDDEN &&
throwable.httpCode == HttpsURLConnection.HTTP_FORBIDDEN /* 403 */) {
MaterialAlertDialogBuilder(requireActivity())
@@ -94,7 +94,7 @@ abstract class AbstractLoginFragment<VB : ViewBinding> : VectorBaseFragment<VB>(
}
is Failure.UnrecognizedCertificateFailure ->
showUnrecognizedCertificateFailure(throwable)
else ->
else ->
onError(throwable)
}
}
Original file line number Diff line number Diff line change
@@ -76,12 +76,12 @@ abstract class AbstractLoginFragment2<VB : ViewBinding> : VectorBaseFragment<VB>
}

when (throwable) {
is CancellationException ->
is CancellationException ->
/* Ignore this error, user has cancelled the action */
Unit
is Failure.UnrecognizedCertificateFailure ->
showUnrecognizedCertificateFailure(throwable)
else ->
else ->
onError(throwable)
}
}
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ class RoomGroupMessageCreator @Inject constructor(
private fun createRoomMessagesGroupSummaryLine(events: List<NotifiableMessageEvent>, roomName: String, roomIsDirect: Boolean): CharSequence {
return try {
when (events.size) {
1 -> createFirstMessageSummaryLine(events.first(), roomName, roomIsDirect)
1 -> createFirstMessageSummaryLine(events.first(), roomName, roomIsDirect)
else -> {
stringProvider.getQuantityString(
R.plurals.notification_compat_summary_line_for_room,
Original file line number Diff line number Diff line change
@@ -43,9 +43,9 @@ class DirectLoginUseCase @Inject constructor(
}

private suspend fun createSessionFor(data: WellknownResult, action: LoginOrRegister, config: HomeServerConnectionConfig?) = when (data) {
is WellknownResult.Prompt -> loginDirect(action, data, config)
is WellknownResult.Prompt -> loginDirect(action, data, config)
is WellknownResult.FailPrompt -> handleFailPrompt(data, action, config)
else -> onWellKnownError()
else -> onWellKnownError()
}

private suspend fun handleFailPrompt(data: WellknownResult.FailPrompt, action: LoginOrRegister, config: HomeServerConnectionConfig?): Result<Session> {
Original file line number Diff line number Diff line change
@@ -80,11 +80,11 @@ abstract class AbstractFtueAuthFragment<VB : ViewBinding> : VectorBaseFragment<V
}

when (throwable) {
is CancellationException ->
is CancellationException ->
/* Ignore this error, user has cancelled the action */
Unit
is Failure.UnrecognizedCertificateFailure -> showUnrecognizedCertificateFailure(throwable)
else -> onError(throwable)
else -> onError(throwable)
}
}

Original file line number Diff line number Diff line change
@@ -138,26 +138,26 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
// Trick to display the error without text.
views.createAccountInput.error = " "
when {
throwable.isUsernameInUse() || throwable.isInvalidUsername() -> {
throwable.isUsernameInUse() || throwable.isInvalidUsername() -> {
views.createAccountInput.error = errorFormatter.toHumanReadable(throwable)
}
throwable.isLoginEmailUnknown() -> {
throwable.isLoginEmailUnknown() -> {
views.createAccountInput.error = getString(R.string.login_login_with_email_error)
}
throwable.isInvalidPassword() && views.createAccountPasswordInput.hasSurroundingSpaces() -> {
views.createAccountPasswordInput.error = getString(R.string.auth_invalid_login_param_space_in_password)
}
throwable.isWeakPassword() || throwable.isInvalidPassword() -> {
throwable.isWeakPassword() || throwable.isInvalidPassword() -> {
views.createAccountPasswordInput.error = errorFormatter.toHumanReadable(throwable)
}
throwable.isRegistrationDisabled() -> {
throwable.isRegistrationDisabled() -> {
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.dialog_title_error)
.setMessage(getString(R.string.login_registration_disabled))
.setPositiveButton(R.string.ok, null)
.show()
}
else -> {
else -> {
super.onError(throwable)
}
}
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ class FtueAuthUseCaseFragment @Inject constructor(
private fun createIcon(@ColorRes tint: Int, icon: Int, isLightMode: Boolean): Drawable {
val context = requireContext()
val alpha = when (isLightMode) {
true -> LIGHT_MODE_ICON_BACKGROUND_ALPHA
true -> LIGHT_MODE_ICON_BACKGROUND_ALPHA
false -> DARK_MODE_ICON_BACKGROUND_ALPHA
}
val iconBackground = context.getResTintedDrawable(R.drawable.bg_feature_icon, tint, alpha = alpha)
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ class CreateRoomController @Inject constructor(
}

when (viewState.roomJoinRules) {
RoomJoinRules.INVITE -> {
RoomJoinRules.INVITE -> {
buildProfileAction(
id = "joinRule",
title = stringProvider.getString(R.string.room_settings_room_access_private_title),
@@ -104,7 +104,7 @@ class CreateRoomController @Inject constructor(
action = { host.listener?.selectVisibility() }
)
}
RoomJoinRules.PUBLIC -> {
RoomJoinRules.PUBLIC -> {
buildProfileAction(
id = "joinRule",
title = stringProvider.getString(R.string.room_settings_room_access_public_title),
@@ -124,7 +124,7 @@ class CreateRoomController @Inject constructor(
action = { host.listener?.selectVisibility() }
)
}
else -> {
else -> {
// not yet supported
}
}
Original file line number Diff line number Diff line change
@@ -112,7 +112,7 @@ class CreateSubSpaceController @Inject constructor(
}

when (data.roomJoinRules) {
RoomJoinRules.INVITE -> {
RoomJoinRules.INVITE -> {
buildProfileAction(
id = "joinRule",
title = stringProvider.getString(R.string.room_settings_room_access_private_title),
@@ -122,7 +122,7 @@ class CreateSubSpaceController @Inject constructor(
action = { host.listener?.selectVisibility() }
)
}
RoomJoinRules.PUBLIC -> {
RoomJoinRules.PUBLIC -> {
buildProfileAction(
id = "joinRule",
title = stringProvider.getString(R.string.room_settings_room_access_public_title),
@@ -142,7 +142,7 @@ class CreateSubSpaceController @Inject constructor(
action = { host.listener?.selectVisibility() }
)
}
else -> {
else -> {
// not yet supported
}
}
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ class RoomDirectoryPickerController @Inject constructor(
}
when (data.addServerAsync) {
Uninitialized,
is Fail -> settingsContinueCancelItem {
is Fail -> settingsContinueCancelItem {
id("continueCancel")
continueText(host.stringProvider.getString(R.string.ok))
canContinue(data.enteredServer.isNotEmpty())
Original file line number Diff line number Diff line change
@@ -276,7 +276,7 @@ class RoomMemberProfileController @Inject constructor(

if (canKick) {
when (membership) {
Membership.JOIN -> {
Membership.JOIN -> {
buildProfileAction(
id = "kick",
editable = false,
@@ -296,7 +296,7 @@ class RoomMemberProfileController @Inject constructor(
action = { callback?.onCancelInviteClicked() }
)
}
else -> Unit
else -> Unit
}
}
if (canBan) {
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ class RoomMemberListFragment @Inject constructor(
object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
when (newState) {
RecyclerView.SCROLL_STATE_IDLE -> {
RecyclerView.SCROLL_STATE_IDLE -> {
if (withState(viewModel) { it.actionsPermissions.canInvite }) {
views.inviteUsersButton.show()
}
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ class RoomPermissionsViewModel @AssistedInject constructor(@Assisted initialStat

override fun handle(action: RoomPermissionsAction) {
when (action) {
is RoomPermissionsAction.UpdatePermission -> updatePermission(action)
is RoomPermissionsAction.UpdatePermission -> updatePermission(action)
RoomPermissionsAction.ToggleShowAllPermissions -> toggleShowAllPermissions()
}
}
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ class SpaceInviteBottomSheetViewModel @AssistedInject constructor(

override fun handle(action: SpaceInviteBottomSheetAction) {
when (action) {
SpaceInviteBottomSheetAction.DoJoin -> {
SpaceInviteBottomSheetAction.DoJoin -> {
setState { copy(joinActionState = Loading()) }
session.coroutineScope.launch(Dispatchers.IO) {
try {
Loading