Code review fixes.

This commit is contained in:
Onuray Sahin 2022-09-21 14:30:24 +03:00
parent 4ab798f88d
commit 8de9ef8c7d
8 changed files with 15 additions and 15 deletions

View File

@ -135,7 +135,7 @@ class VectorSettingsDevicesFragment :
requireActivity(), requireActivity(),
R.string.device_manager_header_section_security_recommendations_title, R.string.device_manager_header_section_security_recommendations_title,
DeviceManagerFilterType.UNVERIFIED, DeviceManagerFilterType.UNVERIFIED,
includeCurrentSession = true excludeCurrentDevice = false
) )
} }
} }
@ -145,7 +145,7 @@ class VectorSettingsDevicesFragment :
requireActivity(), requireActivity(),
R.string.device_manager_header_section_security_recommendations_title, R.string.device_manager_header_section_security_recommendations_title,
DeviceManagerFilterType.INACTIVE, DeviceManagerFilterType.INACTIVE,
includeCurrentSession = true excludeCurrentDevice = false
) )
} }
} }
@ -290,7 +290,7 @@ class VectorSettingsDevicesFragment :
context = requireActivity(), context = requireActivity(),
titleResourceId = R.string.device_manager_sessions_other_title, titleResourceId = R.string.device_manager_sessions_other_title,
defaultFilter = DeviceManagerFilterType.ALL_SESSIONS, defaultFilter = DeviceManagerFilterType.ALL_SESSIONS,
includeCurrentSession = false excludeCurrentDevice = true
) )
} }
} }

View File

@ -32,10 +32,10 @@ class VectorSettingsDevicesViewNavigator @Inject constructor() {
context: Context, context: Context,
titleResourceId: Int, titleResourceId: Int,
defaultFilter: DeviceManagerFilterType, defaultFilter: DeviceManagerFilterType,
includeCurrentSession: Boolean, excludeCurrentDevice: Boolean,
) { ) {
context.startActivity( context.startActivity(
OtherSessionsActivity.newIntent(context, titleResourceId, defaultFilter, includeCurrentSession) OtherSessionsActivity.newIntent(context, titleResourceId, defaultFilter, excludeCurrentDevice)
) )
} }
} }

View File

@ -50,10 +50,10 @@ class OtherSessionsActivity : SimpleFragmentActivity() {
@StringRes @StringRes
titleResourceId: Int, titleResourceId: Int,
defaultFilter: DeviceManagerFilterType, defaultFilter: DeviceManagerFilterType,
includeCurrentSession: Boolean, excludeCurrentDevice: Boolean,
): Intent { ): Intent {
return Intent(context, OtherSessionsActivity::class.java).apply { return Intent(context, OtherSessionsActivity::class.java).apply {
putExtra(Mavericks.KEY_ARG, OtherSessionsArgs(titleResourceId, defaultFilter, includeCurrentSession)) putExtra(Mavericks.KEY_ARG, OtherSessionsArgs(titleResourceId, defaultFilter, excludeCurrentDevice))
} }
} }
} }

View File

@ -17,12 +17,14 @@
package im.vector.app.features.settings.devices.v2.othersessions package im.vector.app.features.settings.devices.v2.othersessions
import android.os.Parcelable import android.os.Parcelable
import androidx.annotation.StringRes
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
@Parcelize @Parcelize
data class OtherSessionsArgs( data class OtherSessionsArgs(
@StringRes
val titleResourceId: Int, val titleResourceId: Int,
val defaultFilter: DeviceManagerFilterType, val defaultFilter: DeviceManagerFilterType,
val includeCurrentSession: Boolean, val excludeCurrentDevice: Boolean,
) : Parcelable ) : Parcelable

View File

@ -55,7 +55,7 @@ class OtherSessionsViewModel @AssistedInject constructor(
observeDevicesJob?.cancel() observeDevicesJob?.cancel()
observeDevicesJob = getDeviceFullInfoListUseCase.execute( observeDevicesJob = getDeviceFullInfoListUseCase.execute(
filterType = currentFilter, filterType = currentFilter,
excludeCurrentDevice = !initialState.includeCurrentSession excludeCurrentDevice = initialState.excludeCurrentDevice
) )
.execute { async -> .execute { async ->
copy( copy(

View File

@ -25,8 +25,8 @@ import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
data class OtherSessionsViewState( data class OtherSessionsViewState(
val devices: Async<List<DeviceFullInfo>> = Uninitialized, val devices: Async<List<DeviceFullInfo>> = Uninitialized,
val currentFilter: DeviceManagerFilterType = DeviceManagerFilterType.ALL_SESSIONS, val currentFilter: DeviceManagerFilterType = DeviceManagerFilterType.ALL_SESSIONS,
val includeCurrentSession: Boolean = false, val excludeCurrentDevice: Boolean = false,
) : MavericksState { ) : MavericksState {
constructor(args: OtherSessionsArgs) : this(includeCurrentSession = args.includeCurrentSession) constructor(args: OtherSessionsArgs) : this(excludeCurrentDevice = args.excludeCurrentDevice)
} }

View File

@ -180,10 +180,8 @@ class DevicesViewModelTest {
*/ */
private fun givenDeviceFullInfoList(): List<DeviceFullInfo> { private fun givenDeviceFullInfoList(): List<DeviceFullInfo> {
val verifiedCryptoDeviceInfo = mockk<CryptoDeviceInfo>() val verifiedCryptoDeviceInfo = mockk<CryptoDeviceInfo>()
every { verifiedCryptoDeviceInfo.isVerified } returns true
every { verifiedCryptoDeviceInfo.trustLevel } returns DeviceTrustLevel(crossSigningVerified = true, locallyVerified = true) every { verifiedCryptoDeviceInfo.trustLevel } returns DeviceTrustLevel(crossSigningVerified = true, locallyVerified = true)
val unverifiedCryptoDeviceInfo = mockk<CryptoDeviceInfo>() val unverifiedCryptoDeviceInfo = mockk<CryptoDeviceInfo>()
every { unverifiedCryptoDeviceInfo.isVerified } returns false
every { unverifiedCryptoDeviceInfo.trustLevel } returns DeviceTrustLevel(crossSigningVerified = false, locallyVerified = false) every { unverifiedCryptoDeviceInfo.trustLevel } returns DeviceTrustLevel(crossSigningVerified = false, locallyVerified = false)
val deviceFullInfo1 = DeviceFullInfo( val deviceFullInfo1 = DeviceFullInfo(

View File

@ -80,9 +80,9 @@ class VectorSettingsDevicesViewNavigatorTest {
return intent return intent
} }
private fun givenIntentForOtherSessions(titleResourceId: Int, defaultFilter: DeviceManagerFilterType, includeCurrentSession: Boolean): Intent { private fun givenIntentForOtherSessions(titleResourceId: Int, defaultFilter: DeviceManagerFilterType, excludeCurrentDevice: Boolean): Intent {
val intent = mockk<Intent>() val intent = mockk<Intent>()
every { OtherSessionsActivity.newIntent(context.instance, titleResourceId, defaultFilter, includeCurrentSession) } returns intent every { OtherSessionsActivity.newIntent(context.instance, titleResourceId, defaultFilter, excludeCurrentDevice) } returns intent
return intent return intent
} }
} }