Reverts change to when arrow alignment on some classes

This commit is contained in:
ericdecanini 2022-05-05 19:33:45 +02:00
parent 1cb14d6be7
commit 4266c330de
26 changed files with 59 additions and 61 deletions

View file

@ -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")
}

View file

@ -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
}
)

View file

@ -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
}

View file

@ -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")
}
}

View file

@ -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 ?: "")
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)
}
}

View file

@ -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)
}
}

View file

@ -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()
}
}

View file

@ -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) {

View file

@ -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()
}
}

View file

@ -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
}
}

View file

@ -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(

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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,

View file

@ -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> {

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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())

View file

@ -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) {

View file

@ -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()
}

View file

@ -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()
}
}

View file

@ -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 {

View file

@ -150,9 +150,9 @@ class SpacePeopleListController @Inject constructor(
private fun toPowerLevelLabel(categories: RoomMemberListCategories): String? {
return when (categories) {
RoomMemberListCategories.ADMIN -> stringProvider.getString(R.string.power_level_admin)
RoomMemberListCategories.ADMIN -> stringProvider.getString(R.string.power_level_admin)
RoomMemberListCategories.MODERATOR -> stringProvider.getString(R.string.power_level_moderator)
else -> null
else -> null
}
}
}