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

Commit

Permalink
Merge Upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
davehlong committed Jul 18, 2019
2 parents cfe8379 + dfea4a3 commit 350d649
Show file tree
Hide file tree
Showing 88 changed files with 3,691 additions and 5,616 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

171 changes: 15 additions & 156 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,98 +2,19 @@

![Screenshot](https://i.imgur.com/F5LMYKl.png)

## Setup
### Initial Setup

Note: Make sure you use yarn instead of npm. Since there is no package-lock.json, only a yarn.lock, using npm will get you the wrong packages.
* cd TonChan
* yarn install

* Clone the repo:
### Running

`git clone https://github.com/turtlecoin/turtlecoin-mobile-wallet.git`

`cd turtlecoin-mobile-wallet`

* Install React Native CLI

`npm install -g react-native-cli`

* Install yarn if you don't have it already:

`npm install -g yarn`

* Install the dependencies:

`yarn install`

* Next, we need to setup the Android JDK and development environment.

First we need to install the Android JDK (Version 8!).

* Ubuntu - `sudo apt-get install default-jdk`
* Arch Linux - `pacman -S jdk-openjdk`
* OSX - `brew tap AdoptOpenJDK/openjdk` & `brew cask install adoptopenjdk8`

Next, lets install Android Studio.

* Ubuntu - `https://askubuntu.com/a/941222/764667`
* Arch Linux - `pacaur -S android-studio` (It's in the AUR, feel free to use your favourite package manager or install manually.)

Next, we need to run the android studio setup, and set some path variables. This is a bit complicated, so I'm going to hand off to the facebook guide here: https://facebook.github.io/react-native/docs/getting-started#1-install-android-studio

Skip the 'Creating a new application' header, and continue on to 'Preparing the Android Device'. Run `android-studio .` in this directory to import the project.

Once you have your virtual device setup, you can launch the app itself.

* Run the program:

`yarn start` (or `yarn start-release`)

If you get an error about 'Unsupported major.minor version', you may need to set JAVA_HOME to point to the correct jdk.

For example, `export JAVA_HOME=/usr/lib/jvm/java-8-openjdk/jre/`

If you get an error about duplicate resources, run `rm -r android/app/src/main/res/drawable-*`

## Developing
* node --max-old-space-size=8192 node_modules/react-native/local-cli/cli.js start
* react-native run-android

### Logging

You probably want to run `react-native log-android` so you can read the console output, and have an easier log of what's going on as you're developing. Errors will get printed to the device, but console.log won't, and it's a little hard to read.


### Live Reloading

You probably also want to enable live reloading. Hit "Ctrl-M" in your emulator, or type `adb shell input keyevent 82` to open the developer menu, and enable `Live Reload`. You probably don't want to use Hot Reloading, it's pretty buggy.

### Native Code

If you need to update the native code, you may find this article helpful: https://thebhwgroup.com/blog/react-native-jni

To get the updated class signatures, rebuild the Java code (i.e., run `react-native run-android`, then run

```
javap -classpath android/app/build/intermediates/classes/debug/ -s com.tonchan.ClassName
```

Where `ClassName` is the class you want to query. For example, to get the signatures for `WalletBlockInfo`:

```
javap -classpath android/app/build/intermediates/classes/debug/ -s com.tonchan.WalletBlockInfo
```

Then the constructor signature is this section:

```
public com.tonchan.WalletBlockInfo(com.tonchan.RawTransaction, com.tonchan.RawTransaction[]);
Signature: (Lcom/tonchan/RawTransaction;[Lcom/tonchan/RawTransaction;)V
```

Specifically, `(Lcom/tonchan/RawTransaction;[Lcom/tonchan/RawTransaction;)V`

### Flowcharts

There is a flow chart describing screen navigation in the `flowcharts` folder.

There is also an xml file that you can import into [draw.io](https://draw.io) if you want to modify the flowchart.
`react-native log-android`

### Creating a release

Expand All @@ -103,6 +24,14 @@ You need to bump the version number in:
* `android/app/build.gradle` - `versionCode` and `versionName`
* `package.json` - `version` - Not strictly required

Then
`cd android`
`./gradlew bundleRelease`
Optionally
`./gradlew installRelease`

or `yarn deploy-android`

### Integrating QR Codes or URIs

TonChan supports two kinds of QR codes.
Expand All @@ -128,73 +57,3 @@ turtlecoin://TRTLv2Fyavy8CXG8BPEbNeCHFZ1fuDCYCZ3vW5H5LXN4K2M2MHUpTENip9bbavpHvvP
This would send `100 TRTL` (10000 in atomic units) to the address `TRTLv2Fyavy8CXG8BPEbNeCHFZ1fuDCYCZ3vW5H5LXN4K2M2MHUpTENip9bbavpHvvPwb4NDkBWrNgURAd5DB38FHXWZyoBh4wW`, using the name `Starbucks Coffee` (Note the URI encoding), and using a payment ID of `f13adc8ac78eb22ffcee3f82e0e9ffb251dc7dc0600ef599087a89b623ca1402`

You can also just display the URI as a hyperlink. If a user clicks the link, it will open the app, and jump to the confirm screen, just as a QR code would function. (Provided all the fields are given)

## Running natively on your Android device

Follow [this](https://facebook.github.io/react-native/docs/running-on-device.html) guide.

## Building an APK

Follow [this](https://facebook.github.io/react-native/docs/signed-apk-android.html) guide.

Once you have finished, compile the APK:

`yarn build-android`

Install the APK on your device:

`yarn deploy-android`

If it all works, you can then upload to the play store.

Note that you need to close the emulator to get the `yarn deploy-android` to install on your mobile.

## Forking

Start by cloning the latest tagged release. If it's not in a release, it has not been fully tested, and may have bugs.

#### Modifying icon

Replace `assets/img/icon.png` with your icon image. Make sure it is 1024x1024.

Run `npm install -g yo generator-rn-toolbox` (You may need to run this with sudo)

Run `yo rn-toolbox:assets --icon assets/img/icon.png --force`

When it asks for the name of your react-native project, enter `TonChan`

#### Renaming app

There is a tool that does this, `react-native-rename`. However, the native code, (`android/app/src/main/jni/TurtleCoin.cpp`) needs the name of the class to find the Java/C++ interface.

If you use this tool, you will probably need to update that code.

Run `npm install -g react-native-rename` (You may need to run this with sudo)

Run `react-native-rename your-new-project-name` from this directory. (Obviously, replace with the desired name)

This might confuse the build system. You probably should do this before installing.

#### Building an APK

You will need to set up your signing key, and keystore file. See https://facebook.github.io/react-native/docs/signed-apk-android.html#generating-a-signing-key

#### Config

Edit `src/Config.js`. The fields should be self explanatory. Make sure to recompile.

#### Sentry

Sentry is a tool to report crashes in the application. *Please* configure this, or disable it, so we do not get reported errors for your application.

Remove the two files `android/sentry.properties` and `ios/sentry.properties`, and then run `react-native link`.

This will run the sentry setup wizard, to setup error reporting for your app.

Then, copy the line of code `Sentry.config('https://8ecf138e1d1e4d558178be3f2b5e1925@sentry.io/1411753').install();` that is shown on the configuration page, and replace with our line in `src/Sentry.js`.

Your API key will be different, don't just copy the one here.

Finally, replace `Config.coinName === 'TurtleCoin'` in `src/Sentry.js` with the coin name defined in the config.

Once you've done that, you can test sentry is working by adding something like `throw new Error('Hello, sentry');` in the mainscreen constructor.
102 changes: 67 additions & 35 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import com.android.build.OutputFile
* // the entry file for bundle generation
* entryFile: "index.android.js",
*
* // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
* bundleCommand: "ram-bundle",
*
* // whether to bundle JS and assets in debug mode
* bundleInDebug: false,
*
Expand Down Expand Up @@ -74,15 +77,11 @@ import com.android.build.OutputFile

project.ext.react = [
entryFile: "index.js",
bundleAssetName: "index.android.bundle",
bundleInAlpha: true,
bundleInBeta: true,
jsBundleDirRelease: "$buildDir/intermediates/merged_assets/release/mergeReleaseAssets/out"
enableHermes: false, // clean and rebuild if changing
nodeExecutableAndArgs: ["node", "--max-old-space-size=8192"]
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-sentry/sentry.gradle"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
* Set this to true to create two separate APKs instead of one:
Expand All @@ -97,7 +96,29 @@ def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = 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 @@ -111,15 +132,14 @@ android {
applicationId "com.tonchan"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 11
versionName "v0.1.1"
missingDimensionStrategy 'react-native-camera', 'general'
versionCode 100
versionName "v1.0.0"
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
moduleName "TurtleCoin_jni"
ldLibs "log"
stl "stlport_static"
}
missingDimensionStrategy 'react-native-camera', 'general'
}
externalNativeBuild {
ndkBuild {
Expand All @@ -135,63 +155,73 @@ android {
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
universalApk true // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
debug {
manifestPlaceholders = [usesCleartextTraffic:"true"]
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
manifestPlaceholders = [usesCleartextTraffic:"false"]
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a":3, "x86_64": 4]
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}

}
}

packagingOptions {
pickFirst '**/armeabi-v7a/libc++_shared.so'
pickFirst '**/x86/libc++_shared.so'
pickFirst '**/arm64-v8a/libc++_shared.so'
pickFirst '**/x86_64/libc++_shared.so'
pickFirst '**/x86/libjsc.so'
pickFirst '**/armeabi-v7a/libjsc.so'
}
}

dependencies {
implementation project(':@react-native-community_netinfo')
implementation project(':@react-native-community_async-storage')
compile project(':react-native-screens')
compile project(':react-native-sentry')
compile project(':react-native-exit-app')
compile project(':react-native-push-notification')
compile project(':react-native-background-fetch')
compile project(':react-native-camera')
compile project(':react-native-svg')
compile project(':react-native-keychain')
compile project(':react-native-vector-icons')
compile project(':react-native-tcp')
compile project(':realm')
compile project(':react-native-udp')
compile project(':react-native-randombytes')
compile project(':react-native-gesture-handler')
implementation project(':react-native-background-fetch')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.android.gms:play-services-safetynet:15.0.1'
implementation project(':react-native-sqlite-storage')
implementation 'com.google.android.gms:play-services-safetynet:+'
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

if (enableHermes) {
def hermesPath = "../../node_modules/hermesvm/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}

// Run this once to be able to run the application with BUCK
Expand All @@ -200,3 +230,5 @@ task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Binary file added android/app/debug.keystore
Binary file not shown.
7 changes: 0 additions & 7 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,3 @@
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 *;
#}
Loading

0 comments on commit 350d649

Please sign in to comment.