Using "Other sessions" title everytime

This commit is contained in:
Maxime NATUREL 2022-12-16 17:22:40 +01:00
parent 913fb1e5dc
commit 62f742bf66
6 changed files with 10 additions and 19 deletions

View File

@ -223,7 +223,6 @@ class VectorSettingsDevicesFragment :
override fun onViewAllClicked() { override fun onViewAllClicked() {
viewNavigator.navigateToOtherSessions( viewNavigator.navigateToOtherSessions(
requireActivity(), requireActivity(),
R.string.device_manager_header_section_security_recommendations_title,
DeviceManagerFilterType.UNVERIFIED, DeviceManagerFilterType.UNVERIFIED,
excludeCurrentDevice = true excludeCurrentDevice = true
) )
@ -233,7 +232,6 @@ class VectorSettingsDevicesFragment :
override fun onViewAllClicked() { override fun onViewAllClicked() {
viewNavigator.navigateToOtherSessions( viewNavigator.navigateToOtherSessions(
requireActivity(), requireActivity(),
R.string.device_manager_header_section_security_recommendations_title,
DeviceManagerFilterType.INACTIVE, DeviceManagerFilterType.INACTIVE,
excludeCurrentDevice = true excludeCurrentDevice = true
) )
@ -447,7 +445,6 @@ class VectorSettingsDevicesFragment :
override fun onViewAllOtherSessionsClicked() { override fun onViewAllOtherSessionsClicked() {
viewNavigator.navigateToOtherSessions( viewNavigator.navigateToOtherSessions(
context = requireActivity(), context = requireActivity(),
titleResourceId = R.string.device_manager_sessions_other_title,
defaultFilter = DeviceManagerFilterType.ALL_SESSIONS, defaultFilter = DeviceManagerFilterType.ALL_SESSIONS,
excludeCurrentDevice = true excludeCurrentDevice = true
) )

View File

@ -31,12 +31,11 @@ class VectorSettingsDevicesViewNavigator @Inject constructor() {
fun navigateToOtherSessions( fun navigateToOtherSessions(
context: Context, context: Context,
titleResourceId: Int,
defaultFilter: DeviceManagerFilterType, defaultFilter: DeviceManagerFilterType,
excludeCurrentDevice: Boolean, excludeCurrentDevice: Boolean,
) { ) {
context.startActivity( context.startActivity(
OtherSessionsActivity.newIntent(context, titleResourceId, defaultFilter, excludeCurrentDevice) OtherSessionsActivity.newIntent(context, defaultFilter, excludeCurrentDevice)
) )
} }

View File

@ -20,7 +20,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.annotation.StringRes
import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.Mavericks
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
@ -48,13 +47,11 @@ class OtherSessionsActivity : SimpleFragmentActivity() {
companion object { companion object {
fun newIntent( fun newIntent(
context: Context, context: Context,
@StringRes
titleResourceId: Int,
defaultFilter: DeviceManagerFilterType, defaultFilter: DeviceManagerFilterType,
excludeCurrentDevice: 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, excludeCurrentDevice)) putExtra(Mavericks.KEY_ARG, OtherSessionsArgs(defaultFilter, excludeCurrentDevice))
} }
} }
} }

View File

@ -17,14 +17,11 @@
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 defaultFilter: DeviceManagerFilterType, val defaultFilter: DeviceManagerFilterType,
val excludeCurrentDevice: Boolean, val excludeCurrentDevice: Boolean,
) : Parcelable ) : Parcelable

View File

@ -182,7 +182,9 @@ class OtherSessionsFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setupToolbar(views.otherSessionsToolbar).setTitle(args.titleResourceId).allowBack() setupToolbar(views.otherSessionsToolbar)
.setTitle(R.string.device_manager_sessions_other_title)
.allowBack()
observeViewEvents() observeViewEvents()
initFilterView() initFilterView()
} }
@ -246,7 +248,7 @@ class OtherSessionsFragment :
val selection = devices.count { it.isSelected } val selection = devices.count { it.isSelected }
stringProvider.getQuantityString(R.plurals.x_selected, selection, selection) stringProvider.getQuantityString(R.plurals.x_selected, selection, selection)
} else { } else {
getString(args.titleResourceId) getString(R.string.device_manager_sessions_other_title)
} }
toolbar?.title = title toolbar?.title = title
} }

View File

@ -31,7 +31,6 @@ import org.junit.Before
import org.junit.Test import org.junit.Test
private const val A_SESSION_ID = "session_id" private const val A_SESSION_ID = "session_id"
private const val A_TITLE_RESOURCE_ID = 1234
private val A_DEFAULT_FILTER = DeviceManagerFilterType.INACTIVE private val A_DEFAULT_FILTER = DeviceManagerFilterType.INACTIVE
class VectorSettingsDevicesViewNavigatorTest { class VectorSettingsDevicesViewNavigatorTest {
@ -67,11 +66,11 @@ class VectorSettingsDevicesViewNavigatorTest {
@Test @Test
fun `given an intent when navigating to other sessions list then it starts the correct activity`() { fun `given an intent when navigating to other sessions list then it starts the correct activity`() {
// Given // Given
val intent = givenIntentForOtherSessions(A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true) val intent = givenIntentForOtherSessions(A_DEFAULT_FILTER, true)
context.givenStartActivity(intent) context.givenStartActivity(intent)
// When // When
vectorSettingsDevicesViewNavigator.navigateToOtherSessions(context.instance, A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true) vectorSettingsDevicesViewNavigator.navigateToOtherSessions(context.instance, A_DEFAULT_FILTER, true)
// Then // Then
context.verifyStartActivity(intent) context.verifyStartActivity(intent)
@ -96,9 +95,9 @@ class VectorSettingsDevicesViewNavigatorTest {
return intent return intent
} }
private fun givenIntentForOtherSessions(titleResourceId: Int, defaultFilter: DeviceManagerFilterType, excludeCurrentDevice: Boolean): Intent { private fun givenIntentForOtherSessions(defaultFilter: DeviceManagerFilterType, excludeCurrentDevice: Boolean): Intent {
val intent = mockk<Intent>() val intent = mockk<Intent>()
every { OtherSessionsActivity.newIntent(context.instance, titleResourceId, defaultFilter, excludeCurrentDevice) } returns intent every { OtherSessionsActivity.newIntent(context.instance, defaultFilter, excludeCurrentDevice) } returns intent
return intent return intent
} }