mirror of
https://github.com/element-hq/element-android
synced 2024-09-06 17:05:20 +00:00
Persist user preference of ip address visibility.
This commit is contained in:
parent
0868869fe3
commit
f6bc28f3bf
|
@ -209,6 +209,9 @@ class VectorPreferences @Inject constructor(
|
|||
private const val SETTINGS_SECURITY_USE_GRACE_PERIOD_FLAG = "SETTINGS_SECURITY_USE_GRACE_PERIOD_FLAG"
|
||||
const val SETTINGS_SECURITY_USE_COMPLETE_NOTIFICATIONS_FLAG = "SETTINGS_SECURITY_USE_COMPLETE_NOTIFICATIONS_FLAG"
|
||||
|
||||
// New Session Manager
|
||||
const val SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS = "SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS"
|
||||
|
||||
// other
|
||||
const val SETTINGS_MEDIA_SAVING_PERIOD_KEY = "SETTINGS_MEDIA_SAVING_PERIOD_KEY"
|
||||
private const val SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY = "SETTINGS_MEDIA_SAVING_PERIOD_SELECTED_KEY"
|
||||
|
|
|
@ -16,15 +16,19 @@
|
|||
|
||||
package im.vector.app.features.settings.devices.v2
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.Success
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.features.auth.PendingAuthHandler
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.devices.v2.filter.DeviceManagerFilterType
|
||||
import im.vector.app.features.settings.devices.v2.signout.InterceptSignoutFlowResponseUseCase
|
||||
import im.vector.app.features.settings.devices.v2.signout.SignoutSessionResult
|
||||
|
@ -53,6 +57,8 @@ class DevicesViewModel @AssistedInject constructor(
|
|||
private val interceptSignoutFlowResponseUseCase: InterceptSignoutFlowResponseUseCase,
|
||||
private val pendingAuthHandler: PendingAuthHandler,
|
||||
refreshDevicesUseCase: RefreshDevicesUseCase,
|
||||
@DefaultPreferences
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) : VectorSessionsListViewModel<DevicesViewState, DevicesAction, DevicesViewEvent>(initialState, activeSessionHolder, refreshDevicesUseCase) {
|
||||
|
||||
@AssistedFactory
|
||||
|
@ -67,6 +73,14 @@ class DevicesViewModel @AssistedInject constructor(
|
|||
observeDevices()
|
||||
refreshDevicesOnCryptoDevicesChange()
|
||||
refreshDeviceList()
|
||||
refreshIpAddressVisibility()
|
||||
}
|
||||
|
||||
private fun refreshIpAddressVisibility() {
|
||||
val shouldShowIpAddress = sharedPreferences.getBoolean(VectorPreferences.SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, false)
|
||||
setState {
|
||||
copy(isShowingIpAddress = shouldShowIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeCurrentSessionCrossSigningInfo() {
|
||||
|
@ -122,7 +136,12 @@ class DevicesViewModel @AssistedInject constructor(
|
|||
|
||||
private fun handleToggleIpAddressVisibility() = withState { state ->
|
||||
val isShowingIpAddress = state.isShowingIpAddress
|
||||
setState { copy(isShowingIpAddress = !isShowingIpAddress) }
|
||||
setState {
|
||||
copy(isShowingIpAddress = !isShowingIpAddress)
|
||||
}
|
||||
sharedPreferences.edit {
|
||||
putBoolean(VectorPreferences.SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, !isShowingIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleVerifyCurrentSessionAction() {
|
||||
|
|
|
@ -16,15 +16,19 @@
|
|||
|
||||
package im.vector.app.features.settings.devices.v2.othersessions
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.Success
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.features.auth.PendingAuthHandler
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.devices.v2.GetDeviceFullInfoListUseCase
|
||||
import im.vector.app.features.settings.devices.v2.RefreshDevicesUseCase
|
||||
import im.vector.app.features.settings.devices.v2.VectorSessionsListViewModel
|
||||
|
@ -48,7 +52,9 @@ class OtherSessionsViewModel @AssistedInject constructor(
|
|||
private val signoutSessionsUseCase: SignoutSessionsUseCase,
|
||||
private val interceptSignoutFlowResponseUseCase: InterceptSignoutFlowResponseUseCase,
|
||||
private val pendingAuthHandler: PendingAuthHandler,
|
||||
refreshDevicesUseCase: RefreshDevicesUseCase
|
||||
refreshDevicesUseCase: RefreshDevicesUseCase,
|
||||
@DefaultPreferences
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) : VectorSessionsListViewModel<OtherSessionsViewState, OtherSessionsAction, OtherSessionsViewEvents>(
|
||||
initialState, activeSessionHolder, refreshDevicesUseCase
|
||||
) {
|
||||
|
@ -64,6 +70,14 @@ class OtherSessionsViewModel @AssistedInject constructor(
|
|||
|
||||
init {
|
||||
observeDevices(initialState.currentFilter)
|
||||
refreshIpAddressVisibility()
|
||||
}
|
||||
|
||||
private fun refreshIpAddressVisibility() {
|
||||
val shouldShowIpAddress = sharedPreferences.getBoolean(VectorPreferences.SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, false)
|
||||
setState {
|
||||
copy(isShowingIpAddress = shouldShowIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeDevices(currentFilter: DeviceManagerFilterType) {
|
||||
|
@ -100,6 +114,9 @@ class OtherSessionsViewModel @AssistedInject constructor(
|
|||
setState {
|
||||
copy(isShowingIpAddress = !isShowingIpAddress)
|
||||
}
|
||||
sharedPreferences.edit {
|
||||
putBoolean(VectorPreferences.SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, !isShowingIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleFilterDevices(action: OtherSessionsAction.FilterDevices) {
|
||||
|
|
|
@ -16,15 +16,19 @@
|
|||
|
||||
package im.vector.app.features.settings.devices.v2.overview
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
import com.airbnb.mvrx.Success
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.features.auth.PendingAuthHandler
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.devices.v2.RefreshDevicesUseCase
|
||||
import im.vector.app.features.settings.devices.v2.VectorSessionsListViewModel
|
||||
import im.vector.app.features.settings.devices.v2.notification.GetNotificationsStatusUseCase
|
||||
|
@ -58,6 +62,8 @@ class SessionOverviewViewModel @AssistedInject constructor(
|
|||
private val togglePushNotificationUseCase: TogglePushNotificationUseCase,
|
||||
private val getNotificationsStatusUseCase: GetNotificationsStatusUseCase,
|
||||
refreshDevicesUseCase: RefreshDevicesUseCase,
|
||||
@DefaultPreferences
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) : VectorSessionsListViewModel<SessionOverviewViewState, SessionOverviewAction, SessionOverviewViewEvent>(
|
||||
initialState, activeSessionHolder, refreshDevicesUseCase
|
||||
) {
|
||||
|
@ -74,6 +80,14 @@ class SessionOverviewViewModel @AssistedInject constructor(
|
|||
observeSessionInfo(initialState.deviceId)
|
||||
observeCurrentSessionInfo()
|
||||
observeNotificationsStatus(initialState.deviceId)
|
||||
refreshIpAddressVisibility()
|
||||
}
|
||||
|
||||
private fun refreshIpAddressVisibility() {
|
||||
val shouldShowIpAddress = sharedPreferences.getBoolean(VectorPreferences.SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, false)
|
||||
setState {
|
||||
copy(isShowingIpAddress = shouldShowIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refreshPushers() {
|
||||
|
@ -122,6 +136,9 @@ class SessionOverviewViewModel @AssistedInject constructor(
|
|||
setState {
|
||||
copy(isShowingIpAddress = !isShowingIpAddress)
|
||||
}
|
||||
sharedPreferences.edit {
|
||||
putBoolean(VectorPreferences.SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, !isShowingIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleVerifySessionAction() = withState { viewState ->
|
||||
|
|
Loading…
Reference in a new issue