Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more clear with connection state #7401

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class ConnectScreenTest {
)

// Assert
onNodeWithText("DISCONNECTED").assertExists()
onNodeWithText("DISCONNECTING...").assertExists()
onNodeWithText(mockLocationName).assertExists()
onNodeWithText("Disconnect").assertExists()
}
Expand Down Expand Up @@ -226,7 +226,7 @@ class ConnectScreenTest {
// Assert
onNodeWithText("BLOCKED CONNECTION").assertExists()
onNodeWithText(mockLocationName).assertExists()
onNodeWithText("Disconnect").assertExists()
onNodeWithText("Unblock").assertExists()
onNodeWithText("BLOCKING INTERNET").assertExists()
}
}
Expand Down Expand Up @@ -310,7 +310,7 @@ class ConnectScreenTest {
)

// Assert
onNodeWithText("CONNECTED").assertExists()
onNodeWithText("BLOCKING...").assertExists()
onNodeWithText(mockLocationName).assertExists()
onNodeWithText("Disconnect").assertExists()
onNodeWithText("BLOCKING INTERNET").assertExists()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fun ConnectionButton(
is TunnelState.Connected -> R.string.disconnect
is TunnelState.Error -> {
if (state.errorState.isBlocking) {
R.string.disconnect
R.string.unblock
} else {
R.string.dismiss
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private fun TunnelState.text() =
is TunnelState.Disconnected -> textResource(id = R.string.disconnected)
is TunnelState.Disconnecting ->
when (actionAfterDisconnect) {
ActionAfterDisconnect.Nothing -> textResource(id = R.string.disconnected)
ActionAfterDisconnect.Block -> textResource(id = R.string.connected)
ActionAfterDisconnect.Nothing -> textResource(id = R.string.disconnecting)
ActionAfterDisconnect.Block -> textResource(id = R.string.blocking)
ActionAfterDisconnect.Reconnect -> textResource(id = R.string.connecting)
}
is TunnelState.Error ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -87,7 +86,7 @@ class ConnectViewModel(
tunnelState = tunnelState,
showLocation =
when (tunnelState) {
is TunnelState.Disconnected -> true
is TunnelState.Disconnected -> tunnelState.location != null
is TunnelState.Disconnecting -> {
when (tunnelState.actionAfterDisconnect) {
ActionAfterDisconnect.Nothing -> false
Expand All @@ -105,7 +104,6 @@ class ConnectViewModel(
isPlayBuild = isPlayBuild,
)
}
.debounce(UI_STATE_DEBOUNCE_DURATION_MILLIS)
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), ConnectUiState.INITIAL)

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,11 @@ class ConnectViewModelTest {
fun `given RelayListUseCase returns new selectedRelayItem uiState should emit new selectedRelayItem`() =
runTest {
val selectedRelayItemTitle = "Item"
selectedRelayItemFlow.value = selectedRelayItemTitle

viewModel.uiState.test {
assertEquals(ConnectUiState.INITIAL, awaitItem())
val result = awaitItem()
assertEquals(selectedRelayItemTitle, result.selectedRelayItemTitle)

selectedRelayItemFlow.value = selectedRelayItemTitle
assertEquals(selectedRelayItemTitle, awaitItem().selectedRelayItemTitle)
}
}

Expand All @@ -196,7 +195,6 @@ class ConnectViewModelTest {

// Act, Assert
viewModel.uiState.test {
assertEquals(ConnectUiState.INITIAL, awaitItem())
tunnelState.emit(TunnelState.Disconnected(null))

// Start of with no location
Expand All @@ -215,12 +213,7 @@ class ConnectViewModelTest {
val locationTestItem = null

// Act, Assert
viewModel.uiState.test {
assertEquals(ConnectUiState.INITIAL, awaitItem())
expectNoEvents()
val result = awaitItem()
assertEquals(locationTestItem, result.location)
}
viewModel.uiState.test { assertEquals(locationTestItem, awaitItem().location) }
}

@Test
Expand Down Expand Up @@ -278,15 +271,12 @@ class ConnectViewModelTest {
val mockErrorState: ErrorState = mockk()
val expectedConnectNotificationState =
InAppNotification.TunnelStateError(mockErrorState)
val tunnelStateError = TunnelState.Error(mockErrorState)
notifications.value = listOf(expectedConnectNotificationState)

// Act, Assert
viewModel.uiState.test {
assertEquals(ConnectUiState.INITIAL, awaitItem())
tunnelState.emit(tunnelStateError)
val result = awaitItem()
assertEquals(expectedConnectNotificationState, result.inAppNotification)
notifications.value = listOf(expectedConnectNotificationState)
assertEquals(expectedConnectNotificationState, awaitItem().inAppNotification)
}
}

Expand Down Expand Up @@ -315,7 +305,6 @@ class ConnectViewModelTest {
viewModel.uiState.test {
awaitItem()
outOfTimeViewFlow.value = true
awaitItem()
}

// Assert
Expand All @@ -328,12 +317,13 @@ class ConnectViewModelTest {
// Arrange
val tunnel = TunnelState.Error(mockk(relaxed = true))
val lastKnownLocation: GeoIpLocation = mockk(relaxed = true)
lastKnownLocationFlow.emit(lastKnownLocation)
tunnelState.emit(tunnel)

// Act, Assert
viewModel.uiState.test {
assertEquals(ConnectUiState.INITIAL, awaitItem())
lastKnownLocationFlow.emit(lastKnownLocation)
tunnelState.emit(tunnel)
awaitItem()
val result = awaitItem()
assertEquals(lastKnownLocation, result.location)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ sealed interface NotificationAction {

data object Disconnect : Tunnel

data object Unblock : Tunnel

data object Cancel : Tunnel

data object Dismiss : Tunnel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ sealed interface NotificationTunnelState {

data object Connected : NotificationTunnelState

data object Reconnecting : NotificationTunnelState
data object Blocking : NotificationTunnelState

data object Disconnecting : NotificationTunnelState

sealed interface Error : NotificationTunnelState {
data object DeviceOffline : Error

data object Blocking : Error
data object Blocked : Error

data object VpnPermissionDenied : Error

Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Type</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Hvilken TCP-port UDP-over-TCP tilsløringsprotokollen skal forbinde til på VPN-serveren.</string>
<string name="unblock">Fjern blokering</string>
<string name="undo">Fortryd</string>
<string name="unsupported_version">IKKE-UNDERSTØTTET VERSION</string>
<string name="unsupported_version_description">Dit privatliv kan være i fare med denne ikke-understøttede appversion. Opdater den straks.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Typ</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Mit welchem TCP-Port sich das UDP-über-TCP-Verschleierungsprotokoll auf dem VPN-Server verbinden soll.</string>
<string name="unblock">Entsperren</string>
<string name="undo">Rückgängig</string>
<string name="unsupported_version">NICHT UNTERSTÜTZTE VERSION</string>
<string name="unsupported_version_description">Ihre Privatsphäre könnte mit dieser nicht unterstützen Version der App gefährdet sein. Bitte aktualisieren Sie sie.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Tipo</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">El puerto TCP al que se conectará el protocolo de ofuscación de UDP sobre TCP en el servidor VPN.</string>
<string name="unblock">Desbloquear</string>
<string name="undo">Deshacer</string>
<string name="unsupported_version">VERSIÓN NO ADMITIDA</string>
<string name="unsupported_version_description">Al usar esta versión obsoleta de la aplicación, es posible que su privacidad esté en riesgo. Actualice ahora.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Tyyppi</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Määrittää, mihin VPN-palvelimen TCP-porttiin \"UDP TCP:n kautta\" -hämäysteknologia-protokollan tulee muodostaa yhteys.</string>
<string name="unblock">Poista esto</string>
<string name="undo">Kumoa</string>
<string name="unsupported_version">EI-TUETTU VERSIO</string>
<string name="unsupported_version_description">Yksityisyytesi saattaa olla vaarassa tämän sovellusversion, jota ei tueta, vuoksi. Päivitä versio heti.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Type</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Le port TCP auquel le protocole de dissimulation UDP sur TCP doit se connecter sur le serveur VPN.</string>
<string name="unblock">Débloquer</string>
<string name="undo">Annuler</string>
<string name="unsupported_version">VERSION NON PRISE EN CHARGE</string>
<string name="unsupported_version_description">Votre confidentialité peut être en danger avec cette version non prise en charge de l\'application. Veuillez la mettre à jour maintenant.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Tipo</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">A quale porta TCP deve connettersi il protocollo di offuscamento UDP-over-TCP sul server VPN.</string>
<string name="unblock">Sblocca</string>
<string name="undo">Annulla</string>
<string name="unsupported_version">VERSIONE NON SUPPORTATA</string>
<string name="unsupported_version_description">La tua privacy potrebbe essere a rischio con questa versione dell\'app non supportata. Aggiornala subito.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">種類</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">UDP-over-TCP難読化プロトコルで接続する必要のあるVPNサーバーのTCPポートです。</string>
<string name="unblock">ブロックを解除</string>
<string name="undo">元に戻す</string>
<string name="unsupported_version">未対応のバージョン</string>
<string name="unsupported_version_description">このアプリバージョンはサポートされていないため、プライバシーが危険にさらされる可能性があります。今すぐアップデートしてください。</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-ko/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">유형</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">UDP-over-TCP 난독 처리 프로토콜이 VPN 서버에서 연결해야 하는 TCP 포트입니다.</string>
<string name="unblock">차단 해제</string>
<string name="undo">실행 취소</string>
<string name="unsupported_version">지원되지 않는 버전</string>
<string name="unsupported_version_description">지원되지 않는 이 앱 버전으로 인해 개인 정보가 위험할 수 있습니다. 지금 업데이트하세요.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-my/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">အမျိုးအစား</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">VPN ဆာဗာကို ဖွင့်ရန် ၎င်း TCP ပေါ့တ် UDP-over-TCP Obfuscation ပရိုတိုကောလ်နှင့် ချိတ်ဆက်ထားသင့်ပါသည်။</string>
<string name="unblock">ပိတ်ဆို့မှုမှ ဖယ်ရန်</string>
<string name="undo">မလုပ်တော့ပါ</string>
<string name="unsupported_version">တွဲဖက်မလုပ်ဆောင်နိုင်သည့် ဗားရှင်း</string>
<string name="unsupported_version_description">တွဲဖက်မလုပ်ဆောင်နိုင်သည့် ဤအက်ပ်ဗားရှင်းကြောင့် သင့်ကိုယ်ရေးအချက်အလက်များ အန္တရာယ် ရှိနိုင်ပါသည်။ ယခုပင် အပ်ဒိတ်လုပ်ပေးပါ။</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Type</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">TCP-porten som UDP-over-TCP-tilsløringen skal koble til på VPN-serveren.</string>
<string name="unblock">Fjern blokkering</string>
<string name="undo">Angre</string>
<string name="unsupported_version">VERSJON UTEN STØTTE</string>
<string name="unsupported_version_description">Personvernet ditt kan være i fare med denne appversjonen som ikke støttes. Oppdater nå.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Type</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Met welke TCP-poort moet het UDP-over-TCP-obfuscatieprotocol verbinding maken op de VPN-server.</string>
<string name="unblock">Deblokkeren</string>
<string name="undo">Ongedaan maken</string>
<string name="unsupported_version">NIET-ONDERSTEUNDE VERSIE</string>
<string name="unsupported_version_description">Uw privacy kan risico lopen met deze niet-ondersteunde appversie. Werk de app nu bij.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Typ</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Port TCP, z którym powinien łączyć się protokół zaciemniania UDP-przez-TCP na serwerze VPN.</string>
<string name="unblock">Odblokuj</string>
<string name="undo">Cofnij</string>
<string name="unsupported_version">WERSJA NIEOBSŁUGIWANA</string>
<string name="unsupported_version_description">W tej nieobsługiwanej wersji aplikacji prywatność może być zagrożona. Zaktualizuj już teraz.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Tipo</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">A que porta TCP o protocolo de ofuscação UDP sobre TCP deve ligar-se no servidor VPN.</string>
<string name="unblock">Desbloquear</string>
<string name="undo">Anular</string>
<string name="unsupported_version">VERSÃO NÃO SUPORTADA</string>
<string name="unsupported_version_description">A sua privacidade pode estar comprometida com uma versão não suportada da aplicação. Por favor efetue a atualização agora.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Тип</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">TCP-порт, к которому должен подключаться протокол обфускации UDP через TCP на VPN-сервере.</string>
<string name="unblock">Разблокировать</string>
<string name="undo">Отменить</string>
<string name="unsupported_version">НЕПОДДЕРЖИВАЕМАЯ ВЕРСИЯ</string>
<string name="unsupported_version_description">Эта версия приложения не поддерживается, что может угрожать неприкосновенности ваших данных. Обновите приложение.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-sv/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Typ</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">Vilken TCP-port som UDP-över-TCP-obfuskeringsprotokoll bör ansluta till på VPN-servern.</string>
<string name="unblock">Avblockera</string>
<string name="undo">Ångra</string>
<string name="unsupported_version">VERSION UTAN STÖD</string>
<string name="unsupported_version_description">Din sekretess kan vara utsatt för risk med den här appversionen som inte stöds. Uppdatera nu.</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-th/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">ประเภท</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">พอร์ต TCP ใดที่โพรโทคอลการทำให้ข้อมูลยุ่งเหยิง UDP-ผ่าน-TCP ควรเชื่อมต่อบนเซิร์ฟเวอร์ VPN</string>
<string name="unblock">ปลดบล็อก</string>
<string name="undo">เลิกทำ</string>
<string name="unsupported_version">เวอร์ชันที่ไม่รองรับ</string>
<string name="unsupported_version_description">ความเป็นส่วนตัวของคุณอาจมีความเสี่ยง ในขณะที่ใช้งานเวอร์ชันแอปที่ไม่ได้รับการสนับสนุนนี้ โปรดอัปเดตตอนนี้เลย</string>
Expand Down
1 change: 1 addition & 0 deletions android/lib/resource/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">Tür</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">TCP üzerinden UDP gizleme protokolünün VPN sunucusunda hangi TCP portuna bağlanması gerekiyor.</string>
<string name="unblock">Engeli kaldır</string>
<string name="undo">Geri al</string>
<string name="unsupported_version">DESTEKLENMEYEN SÜRÜM</string>
<string name="unsupported_version_description">Bu desteklenmeyen uygulama sürümüyle gizliliğiniz risk altında olabilir. Lütfen hemen güncelleyin.</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">类型</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">UDP-over-TCP 混淆协议应连接到 VPN 服务器上的哪个 TCP 端口。</string>
<string name="unblock">解除阻止</string>
<string name="undo">撤消</string>
<string name="unsupported_version">不受支持的版本</string>
<string name="unsupported_version_description">此应用版本不受支持,因此您的隐私可能存在风险。请立即更新。</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@
<string name="type">類型</string>
<string name="udp">UDP</string>
<string name="udp_over_tcp_port_info">UDP-over-TCP 混淆通訊協定應連線到 VPN 伺服器上的哪個 TCP 連接埠。</string>
<string name="unblock">解除封鎖</string>
<string name="undo">復原</string>
<string name="unsupported_version">不支援的版本</string>
<string name="unsupported_version_description">此應用程式版本不受支援,因此您的隱私可能存在風險。請立即更新。</string>
Expand Down
Loading
Loading