Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/2024.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
octol committed Nov 20, 2024
2 parents 155ea75 + 715b412 commit 9222dc1
Show file tree
Hide file tree
Showing 54 changed files with 857 additions and 488 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import net.nymtech.nymvpn.R
import net.nymtech.nymvpn.data.GatewayRepository
import net.nymtech.nymvpn.data.SettingsRepository
import net.nymtech.nymvpn.service.country.CountryCacheService
import net.nymtech.nymvpn.service.gateway.NymApiService
import net.nymtech.nymvpn.service.tunnel.TunnelManager
import net.nymtech.nymvpn.ui.common.navigation.NavBarState
import net.nymtech.nymvpn.ui.common.snackbar.SnackbarController
import net.nymtech.nymvpn.util.Constants
import net.nymtech.nymvpn.util.StringValue
import net.nymtech.vpn.backend.Backend
import net.nymtech.vpn.backend.Tunnel
import net.nymtech.vpn.model.Country
import nym_vpn_lib.SystemMessage
import timber.log.Timber
Expand Down Expand Up @@ -67,8 +71,12 @@ constructor(

fun logout() = viewModelScope.launch {
runCatching {
tunnelManager.removeMnemonic()
}.onFailure { Timber.w("Not logged in") }
if (tunnelManager.getState() == Tunnel.State.Down) {
tunnelManager.removeMnemonic()
} else {
SnackbarController.showMessage(StringValue.StringResource(R.string.action_requires_tunnel_down))
}
}.onFailure { Timber.e(it) }
}

fun onErrorReportingSelected() = viewModelScope.launch {
Expand All @@ -86,11 +94,13 @@ constructor(
}

private suspend fun checkSystemMessages() {
val env = settingsRepository.getEnvironment()
val messages = nymApiService.getSystemMessages(env)
messages.firstOrNull()?.let {
_systemMessage.emit(it)
}
runCatching {
val env = settingsRepository.getEnvironment()
val messages = nymApiService.getSystemMessages(env)
messages.firstOrNull()?.let {
_systemMessage.emit(it)
}
}.onFailure { Timber.e(it) }
}

fun onAppStartup() = viewModelScope.launch {
Expand Down
6 changes: 3 additions & 3 deletions nym-vpn-android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ detektRulesCompose = "1.4.0"
ipaddress = "5.5.1"
jna = "5.15.0"
kotlin = "2.0.21"
ksp = "2.0.21-1.0.27"
ksp = "2.0.21-1.0.28"
coreKtx = "1.15.0"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
lottieCompose = "6.6.0"
materialIconsExtended = "1.7.5"
navigationCompose = "2.8.3"
navigationCompose = "2.8.4"
hiltNavigationCompose = "1.2.0"
lifecycle-compose = "2.8.7"
activityCompose = "1.9.3"
composeBom = "2024.10.01"
composeBom = "2024.11.00"
datastorePreferences = "1.1.1"
relinker = "1.4.5"
securityCrypto = "1.1.0-alpha06"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class NymApi(
private val ioDispatcher: CoroutineDispatcher,
private val userAgent: UserAgent,
) {

suspend fun getGatewayCountries(type: GatewayType): Set<Country> {
return withContext(ioDispatcher) {
getGatewayCountries(type, userAgent, null).map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ import nym_vpn_lib.TunnelStatusListener
import nym_vpn_lib.VpnConfig
import nym_vpn_lib.VpnException
import nym_vpn_lib.fetchAccountLinks
import nym_vpn_lib.forgetAccount
import nym_vpn_lib.initEnvironment
import nym_vpn_lib.isAccountMnemonicStored
import nym_vpn_lib.removeAccountMnemonic
import nym_vpn_lib.startVpn
import nym_vpn_lib.stopVpn
import nym_vpn_lib.storeAccountMnemonic
Expand Down Expand Up @@ -125,7 +125,7 @@ class NymBackend private constructor(val context: Context) : Backend, TunnelStat
}

private fun getCurrentLocaleCountryCode(): String {
// disable for now
// TODO disable for now
// return try {
// context.resources.configuration.locales.get(0).country.lowercase()
// } catch (_: Exception) {
Expand All @@ -146,7 +146,7 @@ class NymBackend private constructor(val context: Context) : Backend, TunnelStat

@Throws(VpnException::class)
override suspend fun removeMnemonic() {
removeAccountMnemonic(storagePath)
forgetAccount(storagePath)
}

@Throws(NymVpnInitializeException::class)
Expand Down
2 changes: 1 addition & 1 deletion nym-vpn-app/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" class="text-[14px] tracking-wide">
<html lang="en" class="text-[14px] antialiased font-rendering tracking-wide">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/nym.svg" />
Expand Down
Loading

0 comments on commit 9222dc1

Please sign in to comment.