Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
feat: improved api performance (#43)
Browse files Browse the repository at this point in the history
Changed from using the lib countries API to the NymVPN api.

Fixed bug where lib was shutting down the VPN due to a WiFi to mobile data change causing the UI to lose sync.

Fixed bug where quick tile state was not updating properly.

Added application shortcuts to NymVPN.

Improved UI bug where primary button text labels were not scaling.

Improved UI bug where Icons on the settings screen were slightly a different size.

Updated support URL
  • Loading branch information
zaneschepke authored May 3, 2024
1 parent 5ebc19f commit 03b8975
Show file tree
Hide file tree
Showing 71 changed files with 806 additions and 462 deletions.
1 change: 0 additions & 1 deletion .github/workflows/cd-pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# name of the workflow
name: Android CI Tag Deployment - Pre-release

on:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/cd-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# name of the workflow
name: Android CI Tag Deployment - Release

on:
Expand Down
27 changes: 26 additions & 1 deletion .github/workflows/ci-android-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ name: Android Lib SmokeTest

on:
workflow_dispatch:
inputs:
libRunId:
description: 'Library Release Run Id'
required: true


jobs:
build:

runs-on: mac-m1
steps:
- uses: actions/checkout@v4
- name: Checkout project
uses: actions/checkout@v4
with:
submodules: true
- name: Set up JDK 17
Expand All @@ -20,6 +27,24 @@ jobs:
uses: nttld/setup-ndk@v1
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Get aarch64-linux-lib
uses: actions/download-artifact@v4
with:
pattern: nym-vpn-lib_*_aarch64-linux-android.tar.gz
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: nymtech/nym-vpn-client
run-id: ${{ github.event.inputs.libRunId }}
path: ${{ github.workspace }}/nym_vpn_client/src/main/jniLibs/arm64-v8a
- name: Extract lib
run: |
(cd ${{ github.workspace }}/nym_vpn_client/src/main/jniLibs/arm64-v8a && tar --strip-components=1 -xvf *.gz)
- name: Get wg-go_aarch64-linux-android
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: nymtech/nym-vpn-client
run-id: ${{ github.event.inputs.libRunId }}
path: ${{ github.workspace }}/nym_vpn_client/src/main/jniLibs/arm64-v8a
- name: Run SmokeTest
run: |
./gradlew app:connectedFdroidAndroidTest
9 changes: 3 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,13 @@ dependencies {
// splash
implementation(libs.androidx.core.splashscreen)

// coroutines
detektPlugins(libs.detekt.rules.compose)

// moshi/retrofit
implementation(libs.retrofit)
implementation(libs.converter.moshi)

// moshi
implementation(libs.moshi)
implementation(libs.moshi.kotlin)

// warning here https://github.com/square/moshi/discussions/1752
ksp(libs.moshi.kotlin.codegen)

detektPlugins(libs.detekt.rules.compose)
}
28 changes: 26 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="net.nymtech.nymvpn.VPN_CONTROL" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<!--start vpn on boot permission-->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".NymVpn"
android:allowBackup="true"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -29,6 +31,9 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity
android:name=".ui.MainActivity"
Expand All @@ -41,6 +46,12 @@
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>
</activity>
<activity
android:name=".ui.ShortcutActivity"
android:enabled="true"
android:exported="true"
android:finishOnTaskLaunch="true"
android:theme="@android:style/Theme.NoDisplay" />
<service
android:name=".service.tile.VpnQuickTile"
android:exported="true"
Expand Down Expand Up @@ -71,7 +82,20 @@
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.AlarmPermissionReceiver" />
<receiver android:name=".receiver.AlarmPermissionReceiver"
android:exported="false" android:enabled="true">
<intent-filter>
<action android:name="android.app.action.SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED" />
</intent-filter>
</receiver>
<!-- will make exported false for now, potentially enable later for user automation integration -->
<receiver android:name=".receiver.VpnControlReceiver" android:exported="false" android:enabled="true"
android:permission="net.nymtech.nymvpn.VPN_CONTROL">
<intent-filter>
<action android:name="net.nymtech.nymvpn.START" />
<action android:name="net.nymtech.nymvpn.STOP" />
</intent-filter>
</receiver>
<service
android:name=".service.AlwaysOnVpnService"
android:enabled="true"
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/net/nymtech/nymvpn/NymVpn.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package net.nymtech.nymvpn
import android.app.Application
import android.content.ComponentName
import android.os.StrictMode
import android.os.StrictMode.ThreadPolicy
import android.service.quicksettings.TileService
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
Expand All @@ -24,7 +25,14 @@ class NymVpn : Application() {
instance = this
if (BuildConfig.DEBUG) {
Timber.plant(DebugTree())
StrictMode.enableDefaults()
StrictMode.setThreadPolicy(
ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build(),
)
} else {
Timber.plant(ReleaseTree())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package net.nymtech.nymvpn.data

import kotlinx.coroutines.flow.Flow
import net.nymtech.nymvpn.data.model.Gateways
import net.nymtech.nymvpn.data.domain.Gateways
import net.nymtech.vpn.model.Country

interface GatewayRepository {

suspend fun getLowLatencyCountry(): Country?
suspend fun getLowLatencyEntryCountry(): Country?

suspend fun setLowLatencyCountry(country: Country)
suspend fun setLowLatencyEntryCountry(country: Country)

suspend fun setEntryCountries(countries: Set<Country>)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.nymtech.nymvpn.data

import kotlinx.coroutines.flow.Flow
import net.nymtech.nymvpn.data.model.Settings
import net.nymtech.nymvpn.data.domain.Settings
import net.nymtech.nymvpn.ui.theme.Theme
import net.nymtech.vpn.model.Country
import net.nymtech.vpn.model.VpnMode
Expand Down Expand Up @@ -45,5 +45,9 @@ interface SettingsRepository {

suspend fun setAnalyticsShown(shown: Boolean)

suspend fun isApplicationShortcutsEnabled(): Boolean

suspend fun setApplicationShortcuts(enabled: Boolean)

val settingsFlow: Flow<Settings>
}
14 changes: 0 additions & 14 deletions app/src/main/java/net/nymtech/nymvpn/data/SharedStateRepository.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ import androidx.datastore.preferences.core.stringPreferencesKey
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import net.nymtech.nymvpn.data.GatewayRepository
import net.nymtech.nymvpn.data.model.Gateways
import net.nymtech.nymvpn.data.domain.Gateways
import net.nymtech.vpn.model.Country
import timber.log.Timber

class DataStoreGatewayRepository(private val dataStoreManager: DataStoreManager) :
GatewayRepository {
companion object {
val LOW_LATENCY_COUNTRY = stringPreferencesKey("LOW_LATENCY_COUNTRY")
val LOW_LATENCY_ENTRY_COUNTRY = stringPreferencesKey("LOW_LATENCY_ENTRY_COUNTRY")
val ENTRY_COUNTRIES = stringPreferencesKey("ENTRY_COUNTRIES")
val EXIT_COUNTRIES = stringPreferencesKey("EXIT_COUNTRIES")
}

override suspend fun getLowLatencyCountry(): Country? {
val country = dataStoreManager.getFromStore(LOW_LATENCY_COUNTRY)
override suspend fun getLowLatencyEntryCountry(): Country? {
val country = dataStoreManager.getFromStore(LOW_LATENCY_ENTRY_COUNTRY)
return Country.from(country)
}

override suspend fun setLowLatencyCountry(country: Country) {
dataStoreManager.saveToDataStore(LOW_LATENCY_COUNTRY, country.toString())
override suspend fun setLowLatencyEntryCountry(country: Country) {
dataStoreManager.saveToDataStore(LOW_LATENCY_ENTRY_COUNTRY, country.copy(isLowLatency = true).toString())
}

override suspend fun setEntryCountries(countries: Set<Country>) {
Expand All @@ -48,7 +48,7 @@ class DataStoreGatewayRepository(private val dataStoreManager: DataStoreManager)
prefs?.let { pref ->
try {
Gateways(
lowLatencyCountry = Country.from(pref[LOW_LATENCY_COUNTRY]),
lowLatencyEntryCountry = Country.from(pref[LOW_LATENCY_ENTRY_COUNTRY]),
exitCountries = Country.fromCollectionString(pref[EXIT_COUNTRIES]),
entryCountries = Country.fromCollectionString(pref[ENTRY_COUNTRIES]),
)
Expand Down
Loading

0 comments on commit 03b8975

Please sign in to comment.