Skip to content

Commit

Permalink
Merge pull request #69 from ademcan/master
Browse files Browse the repository at this point in the history
Improvements for mobile wallet v2
  • Loading branch information
ademcan authored Jul 11, 2019
2 parents 1b0cc3d 13f180e commit c88ce47
Show file tree
Hide file tree
Showing 46 changed files with 8,195 additions and 6,138 deletions.
179 changes: 123 additions & 56 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@

import React, { Component } from 'react';
import { Button, Text, ImageBackground, ActivityIndicator, AsyncStorage, StatusBar, StyleSheet, View, Image, Linking, Platform } from 'react-native';
import { Button, Text, ImageBackground, ActivityIndicator, AsyncStorage, StatusBar, StyleSheet, View, Image, Linking, Platform, AppState } from 'react-native';
import { DrawerNavigator , StackNavigator, SwitchNavigator, DrawerItems } from 'react-navigation'; // Version can be specified in package.json
// Import the different screens
import BackupWallet from './screens/BackupWallet'
Expand All @@ -19,6 19,10 @@ import TxDetailsView from './screens/TxDetailsView'
import ProvideWalletPin from './screens/ProvideWalletPin'
import OpenExistingWalletModal from './screens/OpenExistingWalletModal'
import ShowQrCodeModal from './screens/ShowQrCodeModal'
import Settings from './screens/Settings'
import DeleteWalletModal from './screens/DeleteWalletModal'
import UnlockAppModal from './screens/UnlockAppModal'
import Reactotron from 'reactotron-react-native'


// Android and Ios native modules
Expand All @@ -27,56 31,112 @@ var IosWallet = NativeModules.refreshWallet;
var AndroidWallet = NativeModules.AndroidWallet;
// import { QRLLIB } from './node_modules/qrllib/build/web-libjsqrl.js'



// AuthLoadingScreen checks if a wallet already exists
// - if yes -> redirects to the app main view
// - if no -> redirects to the CreateWallet view
class AuthLoadingScreen extends React.Component {

constructor(props) {
super(props);
this._bootstrapAsync();
}
constructor(props) {
super(props);
this._bootstrapAsync();
}


// state = {
// appState: AppState.currentState,
// };

// componentDidMount() {
// AppState.addEventListener('change', this._handleAppStateChange);
// }
// componentWillUnmount() {
// AppState.removeEventListener('change', this._handleAppStateChange);
// }

// _handleAppStateChange = (nextAppState) => {
// if ( this.state.appState.match(/inactive|background/) && nextAppState === 'active') {
// console.log('App has come to the foreground!');
// if (global.quitApp){
// this.props.navigation.navigate('App')
// }
// }
// if ( nextAppState.match(/inactive|background/) ){
// global.quitApp = true;
// console.log("HMMMM")
// // this.props.navigation.navigate('TransactionsHistory')
// }
// this.setState({appState: nextAppState});
// };

// Fetch the token from storage then navigate to our appropriate place
_bootstrapAsync = async () => {
// check if a wallet was already created
const walletCreated = await AsyncStorage.getItem('walletcreated');
// This will switch to the App screen or Auth screen and this loading
// screen will be unmounted and thrown away.
const walletCreated = await AsyncStorage.getItem('walletcreated');
const unlockWithPin = await AsyncStorage.getItem('unlockWithPin');
console.log("UNLOCK WITH PIN IS...")
console.log(unlockWithPin)
if (unlockWithPin === null){
AsyncStorage.setItem('unlockWithPin', 'false');
}
// This will switch to the App screen or Auth screen and this loading
// screen will be unmounted and thrown away.

// check which network to connect to: node and port

// check which network to connect to: node and port
// check if a node URL and port is already defined
AsyncStorage.multiGet(["nodeUrl", "nodePort"]).then(storageResponse => {
// get at each store's key/value so you can work with it
let nodeUrl = storageResponse[0][1];
let nodePort = storageResponse[1][1];
// save defaultNode global value
if (nodeUrl != 'testnet-4.automated.theqrl.org'){
global.isDefaultNode = false;
}
else {
global.isDefaultNode = true;
}

Reactotron.log(nodeUrl)
// if not yet defined
if (nodeUrl === '' | nodeUrl === null){
Reactotron.log("SAVING NODE INFO")
fetch('https://ademcan.net/qrlnetwork.html', {
// fetch('https://qrl.foundation/qrlnetwork.html', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {
if (Platform.OS === 'ios'){
IosWallet.saveNodeInformation( responseJson.node, responseJson.port, (error, status)=> {
if (status == "saved"){
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
}
});
}
else {
AndroidWallet.saveNodeInformation(responseJson.node, responseJson.port, (err) => {console.log(err);}, (status)=> {
if (status == "saved"){
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
}
});
}
// this.setState({node: responseJson.node, port: responseJson.port })
})
.catch((error) => { console.error(error); });


method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {

if (Platform.OS === 'ios'){
IosWallet.saveNodeInformation( responseJson.node, responseJson.port, (error, status)=> {

if (status == "saved"){
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
AsyncStorage.setItem("nodeUrl", responseJson.node);
AsyncStorage.setItem("nodePort", responseJson.port);
}
});
}
else {
AndroidWallet.saveNodeInformation(responseJson.node, responseJson.port, (err) => {console.log(err);}, (status)=> {
if (status == "saved"){
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
AsyncStorage.setItem("nodeUrl", responseJson.node);
AsyncStorage.setItem("nodePort", responseJson.port);
}
});
}
// this.setState({node: responseJson.node, port: responseJson.port })
})
.catch((error) => { console.error(error); });
}
else {
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
}
});
};

// Render any loading content that you like here
Expand Down Expand Up @@ -119,7 179,7 @@ const TxStack = StackNavigator(
TxDetailsView : {
path: '/',
screen: TxDetailsView
},
},
},
{
headerMode: 'none',
Expand Down Expand Up @@ -155,21 215,21 @@ const MainDrawerMenu = DrawerNavigator(
path: '/',
screen: CreateNewWallet
},
// TxDetailsView : {
// path: '/',
// screen: TxDetailsView
// },
Settings : {
path: '/',
screen: Settings
},
},
{
// initialRouteName: 'Wallet',
initialRouteName: 'TransactionsHistory',
drawerPosition: 'left',
contentComponent: CustomDrawerContentComponent,
contentOptions: {
labelStyle: {
color: 'white',
}
// initialRouteName: 'Wallet',
initialRouteName: 'TransactionsHistory',
drawerPosition: 'left',
contentComponent: CustomDrawerContentComponent,
contentOptions: {
labelStyle: {
color: 'white',
}
}
}
);

Expand All @@ -178,21 238,28 @@ const RootStack = StackNavigator(
{
MainDrawer: {
screen: MainDrawerMenu,
params: { test: "blaaa"},
},
ProvideWalletPin : {
screen: ProvideWalletPin
screen: ProvideWalletPin
},
OpenExistingWalletModal : {
screen: OpenExistingWalletModal
screen: OpenExistingWalletModal
},
ConfirmTxModal : {
screen: ConfirmTxModal
screen: ConfirmTxModal
},
DeleteWalletModal: {
screen: DeleteWalletModal
},
UnlockAppModal: {
screen: UnlockAppModal
},
// ScanQrModal : {
// screen: ScanQrModal
// },
ShowQrCodeModal : {
screen: ShowQrCodeModal
screen: ShowQrCodeModal
},
},
{
Expand Down
44 changes: 35 additions & 9 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 112,9 @@ def pass = getPassword("abilican","android_keystore")

android {
// compileSdkVersion 27
compileSdkVersion 26
buildToolsVersion "26.0.2"
compileSdkVersion 28
buildToolsVersion "28.0.3"
// buildToolsVersion "26.0.2"

// lintOptions {
// abortOnError false
Expand All @@ -133,7 134,7 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

ndk {
abiFilters "armeabi-v7a", "x86"
abiFilters "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
}

packagingOptions {
Expand Down Expand Up @@ -168,7 169,7 @@ android {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
include "armeabi-v7a", "x86", "x86_64", "arm64-v8a"
}
}
buildTypes {
Expand Down Expand Up @@ -225,7 226,7 @@ android {
buildscript {
repositories {
mavenCentral()
// google()
google()

}
dependencies {
Expand All @@ -244,8 245,8 @@ subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
// compileSdkVersion 26
// buildToolsVersion '26.0.2'
}
}
}
Expand Down Expand Up @@ -293,9 294,30 @@ protobuf {


dependencies {
compile project(':react-native-background-task')
compile project(':react-native-background-timer')
compile project(':react-native-vector-icons')
compile project(':react-native-camera')
compile project(':react-native-device-info')

// compile project(':react-native-camera')
compile (project(':react-native-camera')){
exclude group: "com.android.support"
exclude group: "com.google.android.gms"
}
compile ('com.android.support:exifinterface:26.0.1') {
force = true;
}
compile ('com.google.android.gms:play-services-vision:11.6.0') {
force = true;
}

// compile project(':react-native-device-info')

implementation(project(":react-native-device-info"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.1.0"


compile project(':react-native-udp')
compile project(':react-native-tcp')
compile project(':react-native-os')
Expand All @@ -313,6 335,10 @@ dependencies {
compile "com.facebook.react:react-native: " // From node_modules classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
implementation 'com.google.protobuf:protobuf-lite:3.0.0'





compile 'io.grpc:grpc-okhttp:1.13.1' // CURRENT_GRPC_VERSION
compile 'io.grpc:grpc-protobuf-lite:1.13.1' // CURRENT_GRPC_VERSION
compile 'io.grpc:grpc-stub:1.13.1' // CURRENT_GRPC_VERSION
Expand Down
Loading

0 comments on commit c88ce47

Please sign in to comment.