mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +03:00
Navigate to rename session screen from current session menu
This commit is contained in:
parent
bbc756136c
commit
540758d66b
6 changed files with 61 additions and 19 deletions
|
@ -145,6 +145,10 @@ class VectorSettingsDevicesFragment :
|
||||||
private fun initCurrentSessionHeaderView() {
|
private fun initCurrentSessionHeaderView() {
|
||||||
views.deviceListHeaderCurrentSession.setOnMenuItemClickListener { menuItem ->
|
views.deviceListHeaderCurrentSession.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
|
R.id.currentSessionHeaderRename -> {
|
||||||
|
navigateToRenameCurrentSession()
|
||||||
|
true
|
||||||
|
}
|
||||||
R.id.currentSessionHeaderSignoutOtherSessions -> {
|
R.id.currentSessionHeaderSignoutOtherSessions -> {
|
||||||
confirmMultiSignoutOtherSessions()
|
confirmMultiSignoutOtherSessions()
|
||||||
true
|
true
|
||||||
|
@ -154,6 +158,16 @@ class VectorSettingsDevicesFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun navigateToRenameCurrentSession() = withState(viewModel) { state ->
|
||||||
|
val currentDeviceId = state.currentSessionCrossSigningInfo.deviceId
|
||||||
|
if (currentDeviceId.isNotEmpty()) {
|
||||||
|
viewNavigator.navigateToRenameSession(
|
||||||
|
context = requireActivity(),
|
||||||
|
deviceId = currentDeviceId,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initCurrentSessionListView() {
|
private fun initCurrentSessionListView() {
|
||||||
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
||||||
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context
|
||||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||||
import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsActivity
|
import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsActivity
|
||||||
import im.vector.app.features.settings.devices.v2.overview.SessionOverviewActivity
|
import im.vector.app.features.settings.devices.v2.overview.SessionOverviewActivity
|
||||||
|
import im.vector.app.features.settings.devices.v2.rename.RenameSessionActivity
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class VectorSettingsDevicesViewNavigator @Inject constructor() {
|
class VectorSettingsDevicesViewNavigator @Inject constructor() {
|
||||||
|
@ -38,4 +39,8 @@ class VectorSettingsDevicesViewNavigator @Inject constructor() {
|
||||||
OtherSessionsActivity.newIntent(context, titleResourceId, defaultFilter, excludeCurrentDevice)
|
OtherSessionsActivity.newIntent(context, titleResourceId, defaultFilter, excludeCurrentDevice)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun navigateToRenameSession(context: Context, deviceId: String) {
|
||||||
|
context.startActivity(RenameSessionActivity.newIntent(context, deviceId))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Intent
|
||||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||||
import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsActivity
|
import im.vector.app.features.settings.devices.v2.othersessions.OtherSessionsActivity
|
||||||
import im.vector.app.features.settings.devices.v2.overview.SessionOverviewActivity
|
import im.vector.app.features.settings.devices.v2.overview.SessionOverviewActivity
|
||||||
|
import im.vector.app.features.settings.devices.v2.rename.RenameSessionActivity
|
||||||
import im.vector.app.test.fakes.FakeContext
|
import im.vector.app.test.fakes.FakeContext
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
@ -43,6 +44,7 @@ class VectorSettingsDevicesViewNavigatorTest {
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
mockkObject(SessionOverviewActivity.Companion)
|
mockkObject(SessionOverviewActivity.Companion)
|
||||||
mockkObject(OtherSessionsActivity.Companion)
|
mockkObject(OtherSessionsActivity.Companion)
|
||||||
|
mockkObject(RenameSessionActivity.Companion)
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
@ -52,26 +54,41 @@ class VectorSettingsDevicesViewNavigatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a session id when navigating to overview then it starts the correct activity`() {
|
fun `given a session id when navigating to overview then it starts the correct activity`() {
|
||||||
|
// Given
|
||||||
val intent = givenIntentForSessionOverview(A_SESSION_ID)
|
val intent = givenIntentForSessionOverview(A_SESSION_ID)
|
||||||
context.givenStartActivity(intent)
|
context.givenStartActivity(intent)
|
||||||
|
|
||||||
|
// When
|
||||||
vectorSettingsDevicesViewNavigator.navigateToSessionOverview(context.instance, A_SESSION_ID)
|
vectorSettingsDevicesViewNavigator.navigateToSessionOverview(context.instance, A_SESSION_ID)
|
||||||
|
|
||||||
verify {
|
// Then
|
||||||
context.instance.startActivity(intent)
|
context.verifyStartActivity(intent)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
||||||
val intent = givenIntentForOtherSessions(A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true)
|
val intent = givenIntentForOtherSessions(A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true)
|
||||||
context.givenStartActivity(intent)
|
context.givenStartActivity(intent)
|
||||||
|
|
||||||
|
// When
|
||||||
vectorSettingsDevicesViewNavigator.navigateToOtherSessions(context.instance, A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true)
|
vectorSettingsDevicesViewNavigator.navigateToOtherSessions(context.instance, A_TITLE_RESOURCE_ID, A_DEFAULT_FILTER, true)
|
||||||
|
|
||||||
verify {
|
// Then
|
||||||
context.instance.startActivity(intent)
|
context.verifyStartActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `given an intent when navigating to rename session screen then it starts the correct activity`() {
|
||||||
|
// Given
|
||||||
|
val intent = givenIntentForRenameSession(A_SESSION_ID)
|
||||||
|
context.givenStartActivity(intent)
|
||||||
|
|
||||||
|
// When
|
||||||
|
vectorSettingsDevicesViewNavigator.navigateToRenameSession(context.instance, A_SESSION_ID)
|
||||||
|
|
||||||
|
// Then
|
||||||
|
context.verifyStartActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun givenIntentForSessionOverview(sessionId: String): Intent {
|
private fun givenIntentForSessionOverview(sessionId: String): Intent {
|
||||||
|
@ -85,4 +102,10 @@ class VectorSettingsDevicesViewNavigatorTest {
|
||||||
every { OtherSessionsActivity.newIntent(context.instance, titleResourceId, defaultFilter, excludeCurrentDevice) } returns intent
|
every { OtherSessionsActivity.newIntent(context.instance, titleResourceId, defaultFilter, excludeCurrentDevice) } returns intent
|
||||||
return intent
|
return intent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun givenIntentForRenameSession(sessionId: String): Intent {
|
||||||
|
val intent = mockk<Intent>()
|
||||||
|
every { RenameSessionActivity.newIntent(context.instance, sessionId) } returns intent
|
||||||
|
return intent
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.mockkObject
|
import io.mockk.mockkObject
|
||||||
import io.mockk.unmockkAll
|
import io.mockk.unmockkAll
|
||||||
import io.mockk.verify
|
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
@ -47,14 +46,15 @@ class OtherSessionsViewNavigatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a device id when navigating to overview then it starts the correct activity`() {
|
fun `given a device id when navigating to overview then it starts the correct activity`() {
|
||||||
|
// Given
|
||||||
val intent = givenIntentForDeviceOverview(A_DEVICE_ID)
|
val intent = givenIntentForDeviceOverview(A_DEVICE_ID)
|
||||||
context.givenStartActivity(intent)
|
context.givenStartActivity(intent)
|
||||||
|
|
||||||
|
// When
|
||||||
otherSessionsViewNavigator.navigateToSessionOverview(context.instance, A_DEVICE_ID)
|
otherSessionsViewNavigator.navigateToSessionOverview(context.instance, A_DEVICE_ID)
|
||||||
|
|
||||||
verify {
|
// Then
|
||||||
context.instance.startActivity(intent)
|
context.verifyStartActivity(intent)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun givenIntentForDeviceOverview(deviceId: String): Intent {
|
private fun givenIntentForDeviceOverview(deviceId: String): Intent {
|
||||||
|
|
|
@ -60,9 +60,7 @@ class SessionOverviewViewNavigatorTest {
|
||||||
sessionOverviewViewNavigator.goToSessionDetails(context.instance, A_SESSION_ID)
|
sessionOverviewViewNavigator.goToSessionDetails(context.instance, A_SESSION_ID)
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
verify {
|
context.verifyStartActivity(intent)
|
||||||
context.instance.startActivity(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -75,9 +73,7 @@ class SessionOverviewViewNavigatorTest {
|
||||||
sessionOverviewViewNavigator.goToRenameSession(context.instance, A_SESSION_ID)
|
sessionOverviewViewNavigator.goToRenameSession(context.instance, A_SESSION_ID)
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
verify {
|
context.verifyStartActivity(intent)
|
||||||
context.instance.startActivity(intent)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,9 +24,9 @@ import android.net.ConnectivityManager
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.ParcelFileDescriptor
|
import android.os.ParcelFileDescriptor
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.just
|
import io.mockk.justRun
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.runs
|
import io.mockk.verify
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
|
||||||
class FakeContext(
|
class FakeContext(
|
||||||
|
@ -73,7 +73,11 @@ class FakeContext(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun givenStartActivity(intent: Intent) {
|
fun givenStartActivity(intent: Intent) {
|
||||||
every { instance.startActivity(intent) } just runs
|
justRun { instance.startActivity(intent) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun verifyStartActivity(intent: Intent) {
|
||||||
|
verify { instance.startActivity(intent) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun givenClipboardManager(): FakeClipboardManager {
|
fun givenClipboardManager(): FakeClipboardManager {
|
||||||
|
|
Loading…
Reference in a new issue