Skip to content

Commit e6736fc

Browse files
AlexanderTalledoMargeBot
authored andcommitted
chore(TV): show re-connect toast the first time that custom DNS settings change
1 parent 9915f99 commit e6736fc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

app/src/main/java/com/protonvpn/android/tv/settings/customdns/TvSettingsCustomDnsActivity.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package com.protonvpn.android.tv.settings.customdns
2222
import android.content.DialogInterface
2323
import android.content.Intent
2424
import android.os.Bundle
25+
import android.widget.Toast
2526
import androidx.activity.compose.BackHandler
2627
import androidx.activity.compose.setContent
2728
import androidx.compose.foundation.Image
@@ -37,7 +38,11 @@ import androidx.compose.foundation.layout.width
3738
import androidx.compose.foundation.layout.widthIn
3839
import androidx.compose.runtime.Composable
3940
import androidx.compose.runtime.LaunchedEffect
41+
import androidx.compose.runtime.getValue
42+
import androidx.compose.runtime.mutableStateOf
4043
import androidx.compose.runtime.remember
44+
import androidx.compose.runtime.saveable.rememberSaveable
45+
import androidx.compose.runtime.setValue
4146
import androidx.compose.ui.Alignment
4247
import androidx.compose.ui.ExperimentalComposeUiApi
4348
import androidx.compose.ui.Modifier
@@ -49,6 +54,7 @@ import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.
4954
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component4
5055
import androidx.compose.ui.focus.focusProperties
5156
import androidx.compose.ui.focus.focusRequester
57+
import androidx.compose.ui.platform.LocalContext
5258
import androidx.compose.ui.res.painterResource
5359
import androidx.compose.ui.res.stringResource
5460
import androidx.compose.ui.text.style.TextAlign
@@ -89,11 +95,25 @@ class TvSettingsCustomDnsActivity : BaseTvActivity() {
8995
val viewModel = hiltViewModel<TvSettingsCustomDnsViewModel>()
9096
val viewState = viewModel.viewStateFlow.collectAsStateWithLifecycle().value
9197
val dialogState = viewModel.dialogStateFlow.collectAsStateWithLifecycle().value
98+
val context = LocalContext.current
99+
var isSettingsChangedToastShown by rememberSaveable { mutableStateOf(value = false) }
92100

93101
BackHandler(enabled = viewState?.areCustomDnsSettingsChanged == true) {
94102
viewModel.onShowReconnectNowDialog(vpnUiDelegate = getVpnUiDelegate())
95103
}
96104

105+
LaunchedEffect(key1 = viewState?.areCustomDnsSettingsChanged) {
106+
if (viewState?.areCustomDnsSettingsChanged == true && !isSettingsChangedToastShown) {
107+
isSettingsChangedToastShown = true
108+
109+
Toast.makeText(
110+
context,
111+
context.getString(R.string.settings_changes_apply_on_reconnect_toast),
112+
Toast.LENGTH_SHORT,
113+
).show()
114+
}
115+
}
116+
97117
viewModel.eventChannelReceiver.receiveAsFlow().collectAsEffect { event ->
98118
when (event) {
99119
TvSettingsCustomDnsViewModel.Event.OnClose -> finish()

0 commit comments

Comments
 (0)