Skip to content

Commit

Permalink
Rewrite in native Android (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjmao authored Dec 3, 2019
1 parent dea685f commit 09ff1ca
Show file tree
Hide file tree
Showing 81 changed files with 3,953 additions and 799 deletions.
23 changes: 0 additions & 23 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,10 @@
image: mysteriumnetwork/mobile-ci:0.1.0

stages:
- install
- test
- deploy

install-packages:
stage: install
script:
- yarn install
cache:
paths:
- node_modules/
artifacts:
when: on_success
paths:
- node_modules/

lint-and-test:
stage: test
dependencies:
- install-packages
script:
- yarn ci

push-beta:
stage: deploy
dependencies:
- install-packages
when: manual
only:
- master
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,4 @@ DEPENDENCIES
fastlane

BUNDLED WITH
1.16.5
2.0.2
167 changes: 46 additions & 121 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,86 +1,11 @@
apply plugin: "com.android.application"
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

import com.android.build.OutputFile

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
* and bundleReleaseJsAndAssets).
* These basically call `react-native bundle` with the correct arguments during the Android build
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
* bundle directly from the development server. Below you can see all the possible configurations
* and their defaults. If you decide to add a configuration block, make sure to add it before the
* `apply from: "../../node_modules/react-native/react.gradle"` line.
*
* project.ext.react = [
* // the name of the generated asset file containing your JS bundle
* bundleAssetName: "index.android.bundle",
*
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
* // whether to bundle JS and assets in release mode
* bundleInRelease: true,
*
* // whether to bundle JS and assets in another build variant (if configured).
* // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
* // The configuration property can be in the following formats
* // 'bundleIn${productFlavor}${buildType}'
* // 'bundleIn${buildType}'
* // bundleInFreeDebug: true,
* // bundleInPaidRelease: true,
* // bundleInBeta: true,
*
* // whether to disable dev mode in custom build variants (by default only disabled in release)
* // for example: to disable dev mode in the staging build type (if configured)
* devDisabledInStaging: true,
* // The configuration property can be in the following formats
* // 'devDisabledIn${productFlavor}${buildType}'
* // 'devDisabledIn${buildType}'
*
* // the root of your project, i.e. where "package.json" lives
* root: "../../",
*
* // where to put the JS bundle asset in debug mode
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
*
* // where to put the JS bundle asset in release mode
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in debug mode
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
*
* // where to put drawable resources / React Native assets, e.g. the ones you use via
* // require('./image.png')), in release mode
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
*
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
* inputExcludes: ["android/**", "ios/**"],
*
* // override which node gets called and with what additional arguments
* nodeExecutableAndArgs: ["node"],
*
* // supply additional arguments to the packager
* extraPackagerArgs: []
* ]
*/

project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"

/**
* Get the version code from command line param
*
Expand Down Expand Up @@ -125,27 +50,6 @@ def enableSeparateBuildPerCPUArchitecture = false
*/
def enableProguardInReleaseBuilds = false

/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);

android {
compileSdkVersion rootProject.ext.compileSdkVersion

Expand All @@ -154,12 +58,23 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests.includeAndroidResources = true
}

defaultConfig {
applicationId "network.mysterium.vpn"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode getVersionCode()
versionName getVersionName()
multiDexEnabled true

javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
splits {
abi {
Expand All @@ -179,7 +94,6 @@ android {
}
buildTypes {
release {
// signingConfig signingConfigs.debug // TODO(am): check if this is needed
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
Expand All @@ -205,28 +119,41 @@ android {
}

dependencies {
implementation project(':react-native-push-notification')
implementation project(':react-native-vector-icons')
def nav_version = "2.1.0"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"

implementation('com.crashlytics.sdk.android:crashlytics:2.9.6@aar') {
transitive = true
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
transitive = true
}
implementation "androidx.appcompat:appcompat:1.0.0"
implementation 'com.facebook.react:react-native:+'
implementation 'cat.ereza:logcatreporter:1.2.0'

// From node_modules
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.google.firebase:firebase-core:17.2.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation 'network.mysterium:mobile-node:0.14.1'
// implementation files('libs/Mysterium.aar')
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.beust:klaxon:5.0.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.50"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
implementation 'androidx.room:room-runtime:2.2.2'
implementation 'androidx.room:room-ktx:2.2.2'
kapt 'androidx.room:room-compiler:2.2.2'

testImplementation 'junit:junit:4.12'

implementation 'network.mysterium:mobile-node:0.15.0'
// Comment network.mysterium:mobile-node and replace with your local path to use local node build.
// compile files('/Users/anjmao/go/src/github.com/mysteriumnetwork/node/build/package/Mysterium.aar')
}

// Run this once to be able to run the application with BUCK
Expand All @@ -241,12 +168,10 @@ gradle.projectsEvaluated {
}

task applyGoogleServicesIfNeeded {
if(project.hasProperty('applyGoogleServices')) {
if (project.hasProperty('applyGoogleServices')) {
apply plugin: 'com.google.gms.google-services'
}
}
repositories {
mavenCentral()
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
54 changes: 54 additions & 0 deletions android/app/schemas/network.mysterium.db.AppDatabase/1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "e51f75311548ddc3e5a322d3d572711d",
"entities": [
{
"tableName": "FavoriteProposal",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "Terms",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`version` TEXT NOT NULL, PRIMARY KEY(`version`))",
"fields": [
{
"fieldPath": "version",
"columnName": "version",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"version"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e51f75311548ddc3e5a322d3d572711d')"
]
}
}
2 changes: 1 addition & 1 deletion android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application tools:replace="android:networkSecurityConfig" android:networkSecurityConfig="@xml/network_security_config_debug" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
<application tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
</manifest>
Loading

0 comments on commit 09ff1ca

Please sign in to comment.