Skip to content

Commit

Permalink
Android app (#8)
Browse files Browse the repository at this point in the history
* add android app

* updated readme and makefile

* update play store link
  • Loading branch information
64bit authored Nov 17, 2023
1 parent ee2eac7 commit 650c644
Show file tree
Hide file tree
Showing 389 changed files with 34,510 additions and 16 deletions.
11 changes: 11 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,14 @@ cat upvpn-packages/upvpn-oss-licenses-rust.html >> upvpn-packages/upvpn-oss-lice
cat upvpn-packages/third-party-licenses.txt >> upvpn-packages/upvpn-oss-licenses.html
cat upvpn-packages/upvpn-oss-licenses-footer.hbs >> upvpn-packages/upvpn-oss-licenses.html
'''



[tasks.android-init]
workspace = false
script = '''
git clone git@github.com:WireGuard/wireguard-tools.git upvpn-android/app/tunnel/wireguard-tools
cd upvpn-android/app/tunnel/wireguard-tools && git checkout b4f6b4f229d291daf7c35c6f1e7f4841cc6d69bc && cd -
git clone git@github.com:termux/termux-elf-cleaner.git upvpn-android/app/tunnel/elf-cleaner
cd upvpn-android/app/tunnel/elf-cleaner && git checkout 7efc05090675ec6161b7def862728086a26c3b1f && cd -
'''
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# upvpn

upvpn (pronounced Up VPN) app is WireGuard VPN client for Linux, macOS, Windows, and Android (coming soon).
upvpn (pronounced Up VPN) app is WireGuard VPN client for Linux, macOS, Windows, and Android.
For more information please visit https://upvpn.app

upvpn desktop app is made up of UI, CLI and background Daemon.
Expand All @@ -18,10 +18,10 @@ upvpn desktop app is made up of UI, CLI and background Daemon.

upvpn uses Serverless computing model, where a Linux based WireGuard server is provisioned on public cloud providers when app requests to connect to VPN. And server is deprovisioned when app requests to disconnect from VPN.

All of it happens with a single click on the UI, or a single command on terminal.
All of it happens with a single click or tap on the UI, or a single command on terminal.

# Install
Installer for Linux, macOS, and Windows is available for download on [Github Releases](https://github.com/upvpn/upvpn-app/releases) or on website at https://upvpn.app/download
App for Linux, macOS, Windows, and Android is available for download on [Github Releases](https://github.com/upvpn/upvpn-app/releases) or on website at https://upvpn.app/download


# Code
Expand All @@ -30,34 +30,30 @@ Installer for Linux, macOS, and Windows is available for download on [Github Rel

| Crate or Directory | Description |
| --- | --- |
| upvpn-cli | Code for `upvpn` cli |
| upvpn-android | Standalone app for Android. |
| upvpn-cli | Code for `upvpn` cli. |
| upvpn-config | Configuration read from env vars, `upvpn.conf.toml` are merged at runtime in `upvpn-config` and is source of runtime configuration for `upvpn-cli`, `upvpn-daemon`, and `upvpn-ui`. |
| upvpn-controller | Defines GRPC protobuf for APIs exposed by `upvpn-daemon` to be consumed by `upvpn-cli` and `upvpn-ui`. |
| upvpn-daemon | Daemon is responsible for orchestrating a VPN session. It takes input from upvpn-cli or upvpn-ui via GRPC (defined in `upvpn-controller`) and make calls to backend server via separate GRPC (defined in `upvpn-server`). When backend informs that a server is ready daemon configures network tunnel, see [NetworkDependency.md](./NetworkDependency.md) for more info. |
| upvpn-entity | Defines data models used by upvpn-daemon to persist data on disk in sqlite database. |
| upvpn-migration | Defines database migration from which `upvpn-entity` is generated |
| upvpn-packages| Contains resources to package binaries for distribution on macOS (pkg), Linux (rpm & deb), and Windows (msi) |
|upvpn-server| Contains GRPC protobuf definitions and code for communication with backend server |
| upvpn-types | Defines common Rust types for data types used in various crates. These are also used to generate Typescript types for upvpn-ui for seamless serialization and deserialization across language boundaries |
|upvpn-ui| A Tauri based desktop app. GPRC communication with daemon is done in Rust. Typescript code interact with Rust code via Tauri commands |
| upvpn-migration | Defines database migration from which `upvpn-entity` is generated. |
| upvpn-packages| Contains resources to package binaries for distribution on macOS (pkg), Linux (rpm & deb), and Windows (msi). |
|upvpn-server| Contains GRPC protobuf definitions and code for communication with backend server. |
| upvpn-types | Defines common Rust types for data types used in various crates. These are also used to generate Typescript types for upvpn-ui for seamless serialization and deserialization across language boundaries. |
|upvpn-ui| A Tauri based desktop app. GPRC communication with daemon is done in Rust. Typescript code interact with Rust code via Tauri commands. |



## Network Dependency

For networking code, please see [NetworkDependency.md](./NetworkDependency.md)

## Building Desktop Apps

Please see [Build.md](./Build.md)

## Building Android App

Coming soon.
Please see [upvpn-android/README.md](./upvpn-android/README.md)

# License

All Rust crates in this repository are [licensed under GPL version 3](./LICENSE).
Android app, and all Rust crates in this repository are [licensed under GPL version 3](./LICENSE).

Copyright (C) 2023 upvpn LLC

Expand Down
14 changes: 14 additions & 0 deletions upvpn-android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
.idea/*
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
!data

keystore.properties
app/release/
25 changes: 25 additions & 0 deletions upvpn-android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
### Intro

`upvpn-android` is an Android Studio project.

UpVPN Android app is built using modern Android framework based on Jetpack Compose, Room, etc. in Kotlin.

### Downloads

Download UpVPN Android app using one of the following options:
- [Play Store](https://play.google.com/store/apps/details?id=app.upvpn.upvpn)
- [F-Droid (coming soon)]()
- APK from [Github Releases](https://github.com/upvpn/upvpn-app/releases)

### Dev Setup

Install:
- Android Studio
- CMake


Before building app in Android Studio run following from root of this Git repo

```
cargo make android-init
```
3 changes: 3 additions & 0 deletions upvpn-android/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
wireguard-tools
elf-cleaner
172 changes: 172 additions & 0 deletions upvpn-android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties
import java.io.FileInputStream
import java.util.Properties

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.10"
id("com.google.devtools.ksp") version "1.9.10-1.0.13"
id("kotlin-parcelize")
}

val keystorePropertiesFile: File = rootProject.file("keystore.properties")
val keystoreProperties = Properties()

if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

android {
namespace = "app.upvpn.upvpn"
compileSdk = 34

defaultConfig {
applicationId = "app.upvpn.upvpn"
minSdk = 24
targetSdk = 34
versionCode = 4
versionName = "u1-beta"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

externalNativeBuild {
cmake {
path("tunnel/CMakeLists.txt")
}
}

if (keystorePropertiesFile.exists()) {
signingConfigs {
create("release") {
storeFile =
file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
}
}
}

buildTypes {

all {
externalNativeBuild {
cmake {
targets("libwg-go.so")
arguments("-DGRADLE_USER_HOME=${project.gradle.gradleUserHomeDir}")
}
}
}

debug {
isMinifyEnabled = false
versionNameSuffix = ".debug"
val baseUrl = gradleLocalProperties(rootDir).getProperty("baseUrl")
buildConfigField(
"String",
"UPVPN_BASE_URL",
baseUrl
)

externalNativeBuild {
cmake {
arguments("-DANDROID_PACKAGE_NAME=${namespace}")
}
}
}
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
buildConfigField("String", "UPVPN_BASE_URL", "\"https://upvpn.app\"")

signingConfig = signingConfigs.getByName("release")

externalNativeBuild {
cmake {
arguments("-DANDROID_PACKAGE_NAME=${namespace}")
}
}
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.3"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {
val navVersion = "2.7.5"
val roomVersion = "2.6.0"
val sandwichVersion = "1.3.9"

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.2")
implementation("androidx.activity:activity-compose:1.8.0")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui:1.5.4")
implementation("androidx.compose.ui:ui-graphics:1.5.4")
implementation("androidx.compose.ui:ui-tooling-preview:1.5.4")
implementation("androidx.compose.material3:material3:1.1.2")
implementation("androidx.compose.material3:material3-window-size-class:1.1.2")
implementation("androidx.compose.material:material-icons-extended:1.5.4")
implementation("androidx.navigation:navigation-compose:$navVersion")
implementation("com.google.accompanist:accompanist-adaptive:0.32.0")

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:1.0.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

implementation("com.michael-bull.kotlin-result:kotlin-result:1.1.18")

implementation("androidx.room:room-runtime:$roomVersion")
annotationProcessor("androidx.room:room-compiler:$roomVersion")

// To use Kotlin Symbol Processing (KSP)
ksp("androidx.room:room-compiler:$roomVersion")

// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:$roomVersion")

// Network response
implementation("com.github.skydoves:sandwich:$sandwichVersion")

// for java.time
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")

compileOnly("com.google.code.findbugs:jsr305:3.0.2")

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
21 changes: 21 additions & 0 deletions upvpn-android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package app.upvpn.upvpn

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("app.upvpn.upvpn", appContext.packageName)
}
}
3 changes: 3 additions & 0 deletions upvpn-android/app/src/debug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">UpVPN ㅎ</string>
</resources>
Loading

0 comments on commit 650c644

Please sign in to comment.