summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/NotificationSettingsUiStatePreviewParameterProvider.kt14
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NotificationSettingsScreen.kt98
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt15
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/NotificationSettingsUiState.kt3
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt3
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/Android16UpdateWarningReceiver.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/ScheduleNotificationBootCompletedReceiver.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepository.kt1
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt56
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/inappnotification/Android16UpdateWarningUseCase.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/NotificationSettingsViewModel.kt40
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt2
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplashViewModel.kt2
-rw-r--r--android/app/src/main/proto/user_prefs.proto11
18 files changed, 183 insertions, 76 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/NotificationSettingsUiStatePreviewParameterProvider.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/NotificationSettingsUiStatePreviewParameterProvider.kt
new file mode 100644
index 0000000000..a7a5586625
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/preview/NotificationSettingsUiStatePreviewParameterProvider.kt
@@ -0,0 +1,14 @@
+package net.mullvad.mullvadvpn.compose.preview
+
+import androidx.compose.ui.tooling.preview.PreviewParameterProvider
+import net.mullvad.mullvadvpn.compose.state.NotificationSettingsUiState
+import net.mullvad.mullvadvpn.util.Lc
+
+class NotificationSettingsUiStatePreviewParameterProvider :
+ PreviewParameterProvider<Lc<Unit, NotificationSettingsUiState>> {
+ override val values: Sequence<Lc<Unit, NotificationSettingsUiState>> =
+ sequenceOf(
+ Lc.Loading(Unit),
+ Lc.Content(NotificationSettingsUiState(locationInNotificationEnabled = true)),
+ )
+}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NotificationSettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NotificationSettingsScreen.kt
new file mode 100644
index 0000000000..dcf6913968
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/NotificationSettingsScreen.kt
@@ -0,0 +1,98 @@
+package net.mullvad.mullvadvpn.compose.screen
+
+import androidx.compose.animation.ExperimentalSharedTransitionApi
+import androidx.compose.foundation.layout.Column
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.getValue
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.tooling.preview.Preview
+import androidx.compose.ui.tooling.preview.PreviewParameter
+import androidx.lifecycle.compose.collectAsStateWithLifecycle
+import com.ramcosta.composedestinations.annotation.Destination
+import com.ramcosta.composedestinations.annotation.RootGraph
+import com.ramcosta.composedestinations.navigation.DestinationsNavigator
+import net.mullvad.mullvadvpn.R
+import net.mullvad.mullvadvpn.compose.cell.HeaderSwitchComposeCell
+import net.mullvad.mullvadvpn.compose.component.MullvadCircularProgressIndicatorLarge
+import net.mullvad.mullvadvpn.compose.component.NavigateBackIconButton
+import net.mullvad.mullvadvpn.compose.component.ScaffoldWithMediumTopBar
+import net.mullvad.mullvadvpn.compose.preview.NotificationSettingsUiStatePreviewParameterProvider
+import net.mullvad.mullvadvpn.compose.state.NotificationSettingsUiState
+import net.mullvad.mullvadvpn.compose.transitions.SlideInFromRightTransition
+import net.mullvad.mullvadvpn.lib.theme.AppTheme
+import net.mullvad.mullvadvpn.util.Lc
+import net.mullvad.mullvadvpn.viewmodel.NotificationSettingsViewModel
+import org.koin.androidx.compose.koinViewModel
+
+@Preview("Loading|Normal")
+@Composable
+private fun PreviewNotificationSettingsScreen(
+ @PreviewParameter(NotificationSettingsUiStatePreviewParameterProvider::class)
+ state: Lc<Unit, NotificationSettingsUiState>
+) {
+ AppTheme {
+ NotificationSettingsScreen(
+ state = state,
+ onBackClick = {},
+ onToggleLocationInNotifications = {},
+ )
+ }
+}
+
+@OptIn(ExperimentalSharedTransitionApi::class)
+@Destination<RootGraph>(style = SlideInFromRightTransition::class)
+@Composable
+fun NotificationSettings(navigator: DestinationsNavigator) {
+ val vm = koinViewModel<NotificationSettingsViewModel>()
+ val state by vm.uiState.collectAsStateWithLifecycle()
+
+ NotificationSettingsScreen(
+ state = state,
+ onBackClick = { navigator.navigateUp() },
+ onToggleLocationInNotifications = vm::onToggleLocationInNotifications,
+ )
+}
+
+@Composable
+fun NotificationSettingsScreen(
+ state: Lc<Unit, NotificationSettingsUiState>,
+ onBackClick: () -> Unit,
+ onToggleLocationInNotifications: (Boolean) -> Unit,
+) {
+ ScaffoldWithMediumTopBar(
+ appBarTitle = stringResource(id = R.string.settings_notifications),
+ navigationIcon = { NavigateBackIconButton { onBackClick() } },
+ ) { modifier ->
+ Column(horizontalAlignment = Alignment.CenterHorizontally, modifier = modifier) {
+ when (state) {
+ is Lc.Loading -> Loading()
+ is Lc.Content -> {
+ NotificationSettingsContent(
+ state = state.value,
+ onToggleLocationInNotifications = onToggleLocationInNotifications,
+ )
+ }
+ }
+ }
+ }
+}
+
+@Composable
+private fun NotificationSettingsContent(
+ state: NotificationSettingsUiState,
+ onToggleLocationInNotifications: (Boolean) -> Unit,
+) {
+ Column(horizontalAlignment = Alignment.CenterHorizontally) {
+ HeaderSwitchComposeCell(
+ title = stringResource(R.string.enable_location_in_notification),
+ isToggled = state.locationInNotificationEnabled,
+ onCellClicked = onToggleLocationInNotifications,
+ )
+ }
+}
+
+@Composable
+private fun Loading() {
+ MullvadCircularProgressIndicatorLarge()
+}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt
index f70148a48c..d146c7f1ab 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/SettingsScreen.kt
@@ -30,6 +30,7 @@ import com.ramcosta.composedestinations.generated.destinations.ApiAccessListDest
import com.ramcosta.composedestinations.generated.destinations.AppInfoDestination
import com.ramcosta.composedestinations.generated.destinations.DaitaDestination
import com.ramcosta.composedestinations.generated.destinations.MultihopDestination
+import com.ramcosta.composedestinations.generated.destinations.NotificationSettingsDestination
import com.ramcosta.composedestinations.generated.destinations.ReportProblemDestination
import com.ramcosta.composedestinations.generated.destinations.SplitTunnelingDestination
import com.ramcosta.composedestinations.generated.destinations.VpnSettingsDestination
@@ -74,6 +75,7 @@ private fun PreviewSettingsScreen(
onMultihopClick = {},
onDaitaClick = {},
onBackClick = {},
+ onNotificationSettingsCellClick = {},
)
}
}
@@ -96,6 +98,8 @@ fun Settings(navigator: DestinationsNavigator) {
onMultihopClick = dropUnlessResumed { navigator.navigate(MultihopDestination()) },
onDaitaClick = dropUnlessResumed { navigator.navigate(DaitaDestination()) },
onBackClick = dropUnlessResumed { navigator.navigateUp() },
+ onNotificationSettingsCellClick =
+ dropUnlessResumed { navigator.navigate(NotificationSettingsDestination()) },
)
}
@@ -110,6 +114,7 @@ fun SettingsScreen(
onMultihopClick: () -> Unit,
onDaitaClick: () -> Unit,
onBackClick: () -> Unit,
+ onNotificationSettingsCellClick: () -> Unit,
) {
ScaffoldWithMediumTopBar(
appBarTitle = stringResource(id = R.string.settings),
@@ -132,6 +137,7 @@ fun SettingsScreen(
onApiAccessClick = onApiAccessClick,
onMultihopClick = onMultihopClick,
onDaitaClick = onDaitaClick,
+ onNotificationSettingsCellClick = onNotificationSettingsCellClick,
)
}
}
@@ -148,6 +154,7 @@ private fun LazyListScope.content(
onApiAccessClick: () -> Unit,
onMultihopClick: () -> Unit,
onDaitaClick: () -> Unit,
+ onNotificationSettingsCellClick: () -> Unit,
) {
if (state.isLoggedIn) {
itemWithDivider {
@@ -177,8 +184,16 @@ private fun LazyListScope.content(
onClick = onApiAccessClick,
)
}
+
item { Spacer(modifier = Modifier.height(Dimens.cellVerticalSpacing)) }
+ itemWithDivider {
+ NavigationComposeCell(
+ title = stringResource(id = R.string.settings_notifications),
+ onClick = onNotificationSettingsCellClick,
+ )
+ }
+
item { AppInfo(onAppInfoClick, state) }
item { Spacer(modifier = Modifier.height(Dimens.cellVerticalSpacing)) }
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/NotificationSettingsUiState.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/NotificationSettingsUiState.kt
new file mode 100644
index 0000000000..73cc0e8186
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/state/NotificationSettingsUiState.kt
@@ -0,0 +1,3 @@
+package net.mullvad.mullvadvpn.compose.state
+
+data class NotificationSettingsUiState(val locationInNotificationEnabled: Boolean)
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt
index 05c5e6d92a..ef3fafbe5d 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/AppModule.kt
@@ -21,9 +21,9 @@ import net.mullvad.mullvadvpn.lib.shared.DeviceRepository
import net.mullvad.mullvadvpn.lib.shared.LocaleRepository
import net.mullvad.mullvadvpn.lib.shared.PrepareVpnUseCase
import net.mullvad.mullvadvpn.lib.shared.RelayLocationTranslationRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.repository.UserPreferences
import net.mullvad.mullvadvpn.repository.UserPreferencesMigration
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
import net.mullvad.mullvadvpn.repository.UserPreferencesSerializer
import net.mullvad.mullvadvpn.service.notifications.NotificationChannelFactory
import net.mullvad.mullvadvpn.service.notifications.NotificationManager
@@ -80,6 +80,7 @@ val appModule = module {
get(),
get(),
get(),
+ get(),
get<NotificationChannel.TunnelUpdates>().id,
MainScope(),
)
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
index ffe1d078ed..c4d185759c 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/di/UiModule.kt
@@ -87,6 +87,7 @@ import net.mullvad.mullvadvpn.viewmodel.ManageDevicesViewModel
import net.mullvad.mullvadvpn.viewmodel.MtuDialogViewModel
import net.mullvad.mullvadvpn.viewmodel.MullvadAppViewModel
import net.mullvad.mullvadvpn.viewmodel.MultihopViewModel
+import net.mullvad.mullvadvpn.viewmodel.NotificationSettingsViewModel
import net.mullvad.mullvadvpn.viewmodel.OutOfTimeViewModel
import net.mullvad.mullvadvpn.viewmodel.PrivacyDisclaimerViewModel
import net.mullvad.mullvadvpn.viewmodel.ReportProblemViewModel
@@ -290,6 +291,7 @@ val uiModule = module {
viewModel { ShadowsocksSettingsViewModel(get()) }
viewModel { ShadowsocksCustomPortDialogViewModel(get()) }
viewModel { MultihopViewModel(get(), get()) }
+ viewModel { NotificationSettingsViewModel(get()) }
viewModel {
SearchLocationViewModel(
get(),
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/Android16UpdateWarningReceiver.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/Android16UpdateWarningReceiver.kt
index f24a73e8e9..79cf6724a8 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/Android16UpdateWarningReceiver.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/Android16UpdateWarningReceiver.kt
@@ -4,7 +4,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import kotlin.getValue
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.util.goAsync
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/ScheduleNotificationBootCompletedReceiver.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/ScheduleNotificationBootCompletedReceiver.kt
index e972a55b93..38d6805272 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/ScheduleNotificationBootCompletedReceiver.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/receiver/ScheduleNotificationBootCompletedReceiver.kt
@@ -4,7 +4,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import co.touchlab.kermit.Logger
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.usecase.ScheduleNotificationAlarmUseCase
import net.mullvad.mullvadvpn.util.goAsync
import org.koin.core.component.KoinComponent
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepository.kt
index 020a9c23d3..ca7228d007 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepository.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/ChangelogRepository.kt
@@ -8,6 +8,7 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import net.mullvad.mullvadvpn.lib.model.BuildVersion
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.util.IChangelogDataProvider
import net.mullvad.mullvadvpn.util.trimAll
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt
deleted file mode 100644
index e262cba161..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/repository/UserPreferencesRepository.kt
+++ /dev/null
@@ -1,56 +0,0 @@
-package net.mullvad.mullvadvpn.repository
-
-import androidx.datastore.core.DataStore
-import java.time.Instant
-import java.time.ZoneId
-import java.time.ZonedDateTime
-import kotlinx.coroutines.flow.Flow
-import kotlinx.coroutines.flow.first
-import net.mullvad.mullvadvpn.lib.model.BuildVersion
-
-class UserPreferencesRepository(
- private val userPreferencesStore: DataStore<UserPreferences>,
- private val buildVersion: BuildVersion,
-) {
- fun preferencesFlow(): Flow<UserPreferences> = userPreferencesStore.data
-
- suspend fun preferences(): UserPreferences = userPreferencesStore.data.first()
-
- suspend fun setPrivacyDisclosureAccepted() {
- userPreferencesStore.updateData { prefs ->
- prefs.toBuilder().setIsPrivacyDisclosureAccepted(true).build()
- }
- }
-
- suspend fun setHasDisplayedChangelogNotification() {
- userPreferencesStore.updateData { prefs ->
- prefs.toBuilder().setLastShownChangelogVersionCode(buildVersion.code).build()
- }
- }
-
- suspend fun setAccountExpiry(expiry: ZonedDateTime) {
- userPreferencesStore.updateData { prefs ->
- prefs.toBuilder().setAccountExpiryUnixTimeSeconds(expiry.toEpochSecond()).build()
- }
- }
-
- suspend fun clearAccountExpiry() {
- userPreferencesStore.updateData { prefs ->
- prefs.toBuilder().setAccountExpiryUnixTimeSeconds(0).build()
- }
- }
-
- // Returns the account expiry time or null if there is no account expiry (e.g. the user
- // is not logged in on an account).
- suspend fun accountExpiry(): ZonedDateTime? =
- preferences().let { prefs ->
- val expiryTime = prefs.accountExpiryUnixTimeSeconds
- if (expiryTime == 0L) return null
- Instant.ofEpochSecond(expiryTime).atZone(ZoneId.systemDefault())
- }
-
- suspend fun setShowAndroid16ConnectWarning(show: Boolean) =
- userPreferencesStore.updateData { prefs ->
- prefs.toBuilder().setShowAndroid16ConnectWarning(show).build()
- }
-}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt
index de4fc2d046..00b55633a8 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt
@@ -33,9 +33,9 @@ import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointFromIntentHolder
import net.mullvad.mullvadvpn.lib.endpoint.getApiEndpointConfigurationExtras
import net.mullvad.mullvadvpn.lib.model.PrepareError
import net.mullvad.mullvadvpn.lib.model.Prepared
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.lib.theme.AppTheme
import net.mullvad.mullvadvpn.repository.SplashCompleteRepository
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionManager
import net.mullvad.mullvadvpn.ui.serviceconnection.ServiceConnectionState
import net.mullvad.mullvadvpn.viewmodel.MullvadAppViewModel
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt
index 41045beb36..dfdc392abe 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/ScheduleNotificationAlarmUseCase.kt
@@ -7,8 +7,8 @@ import android.content.Intent
import co.touchlab.kermit.Logger
import java.time.ZoneOffset
import java.time.ZonedDateTime
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.receiver.NotificationAlarmReceiver
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
import net.mullvad.mullvadvpn.service.notifications.accountexpiry.accountExpiryNotificationTriggerAt
class ScheduleNotificationAlarmUseCase(
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/inappnotification/Android16UpdateWarningUseCase.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/inappnotification/Android16UpdateWarningUseCase.kt
index 8f131b2bfd..779cdcff8f 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/inappnotification/Android16UpdateWarningUseCase.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/usecase/inappnotification/Android16UpdateWarningUseCase.kt
@@ -12,7 +12,7 @@ import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService
import net.mullvad.mullvadvpn.lib.model.ActionAfterDisconnect
import net.mullvad.mullvadvpn.lib.model.InAppNotification
import net.mullvad.mullvadvpn.lib.model.TunnelState
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
class Android16UpdateWarningUseCase(
private val userPreferencesRepository: UserPreferencesRepository,
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt
index d10feff8ca..36b320cb6e 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ConnectViewModel.kt
@@ -31,10 +31,10 @@ import net.mullvad.mullvadvpn.lib.model.WebsiteAuthToken
import net.mullvad.mullvadvpn.lib.shared.AccountRepository
import net.mullvad.mullvadvpn.lib.shared.ConnectionProxy
import net.mullvad.mullvadvpn.lib.shared.DeviceRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.repository.ChangelogRepository
import net.mullvad.mullvadvpn.repository.InAppNotificationController
import net.mullvad.mullvadvpn.repository.NewDeviceRepository
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
import net.mullvad.mullvadvpn.usecase.LastKnownLocationUseCase
import net.mullvad.mullvadvpn.usecase.OutOfTimeUseCase
import net.mullvad.mullvadvpn.usecase.PaymentUseCase
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/NotificationSettingsViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/NotificationSettingsViewModel.kt
new file mode 100644
index 0000000000..43f717c9b5
--- /dev/null
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/NotificationSettingsViewModel.kt
@@ -0,0 +1,40 @@
+package net.mullvad.mullvadvpn.viewmodel
+
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.WhileSubscribed
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.stateIn
+import kotlinx.coroutines.launch
+import net.mullvad.mullvadvpn.compose.state.NotificationSettingsUiState
+import net.mullvad.mullvadvpn.constant.VIEW_MODEL_STOP_TIMEOUT
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
+import net.mullvad.mullvadvpn.util.Lc
+import net.mullvad.mullvadvpn.util.toLc
+
+class NotificationSettingsViewModel(
+ private val userPreferencesRepository: UserPreferencesRepository
+) : ViewModel() {
+
+ val uiState =
+ userPreferencesRepository
+ .preferencesFlow()
+ .map { settings ->
+ NotificationSettingsUiState(
+ locationInNotificationEnabled = settings.showLocationInSystemNotification
+ )
+ .toLc<Unit, NotificationSettingsUiState>()
+ }
+ .stateIn(
+ scope = viewModelScope,
+ started = SharingStarted.WhileSubscribed(VIEW_MODEL_STOP_TIMEOUT),
+ initialValue = Lc.Loading(Unit),
+ )
+
+ fun onToggleLocationInNotifications(enabled: Boolean) {
+ viewModelScope.launch {
+ userPreferencesRepository.setLocationInNotificationEnabled(enabled)
+ }
+ }
+}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt
index ea23e7e34f..3018827a16 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/PrivacyDisclaimerViewModel.kt
@@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import net.mullvad.mullvadvpn.constant.VIEW_MODEL_STOP_TIMEOUT
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
data class PrivacyDisclaimerViewState(val isStartingService: Boolean, val isPlayBuild: Boolean)
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplashViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplashViewModel.kt
index fe0acd83c1..490a80b858 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplashViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/SplashViewModel.kt
@@ -17,8 +17,8 @@ import net.mullvad.mullvadvpn.lib.common.util.isBeforeNowInstant
import net.mullvad.mullvadvpn.lib.model.DeviceState
import net.mullvad.mullvadvpn.lib.shared.AccountRepository
import net.mullvad.mullvadvpn.lib.shared.DeviceRepository
+import net.mullvad.mullvadvpn.lib.shared.UserPreferencesRepository
import net.mullvad.mullvadvpn.repository.SplashCompleteRepository
-import net.mullvad.mullvadvpn.repository.UserPreferencesRepository
data class SplashScreenState(val splashComplete: Boolean = false)
diff --git a/android/app/src/main/proto/user_prefs.proto b/android/app/src/main/proto/user_prefs.proto
deleted file mode 100644
index c61ac08acc..0000000000
--- a/android/app/src/main/proto/user_prefs.proto
+++ /dev/null
@@ -1,11 +0,0 @@
-syntax = "proto3";
-
-option java_package = "net.mullvad.mullvadvpn.repository";
-option java_multiple_files = true;
-
-message UserPreferences {
- bool is_privacy_disclosure_accepted = 1;
- int32 last_shown_changelog_version_code = 2;
- int64 account_expiry_unix_time_seconds = 3;
- bool show_android_16_connect_warning = 4;
-}