Browse Source

Merge branch 'todayext' into experimental

experimental
Marcos Rodriguez 5 years ago
parent
commit
8b866ca78e
  1. 29
      App.js
  2. 2
      BlueApp.js
  3. 2
      MainBottomTabs.js
  4. 5
      class/app-storage.js
  5. 28
      class/quickActions.js
  6. 2
      ios/BlueWallet.xcodeproj/project.pbxproj
  7. 5
      ios/BlueWallet/AppDelegate.m
  8. 6
      ios/Podfile.lock
  9. 5
      package-lock.json
  10. 1
      package.json
  11. 8
      screen/wallets/list.js

29
App.js

@ -1,5 +1,5 @@
import React from 'react';
import { Linking, AppState, Clipboard, StyleSheet, KeyboardAvoidingView, Platform, View } from 'react-native';
import { Linking, DeviceEventEmitter, AppState, Clipboard, StyleSheet, KeyboardAvoidingView, Platform, View } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import Modal from 'react-native-modal';
import { NavigationActions } from 'react-navigation';
@ -10,8 +10,10 @@ import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import url from 'url';
import { AppStorage, LightningCustodianWallet } from './class';
import { Chain } from './models/bitcoinUnits';
import QuickActions from 'react-native-quick-actions';
import * as Sentry from '@sentry/react-native';
import WalletGradient from './class/walletGradient';
import OnAppLaunch from './class/onAppLaunch';
if (process.env.NODE_ENV !== 'development') {
Sentry.init({
@ -36,7 +38,7 @@ export default class App extends React.Component {
clipboardContent: '',
};
componentDidMount() {
async componentDidMount() {
Linking.getInitialURL()
.then(url => {
if (this.hasSchema(url)) {
@ -46,8 +48,29 @@ export default class App extends React.Component {
.catch(console.error);
Linking.addEventListener('url', this.handleOpenURL);
AppState.addEventListener('change', this._handleAppStateChange);
QuickActions.popInitialAction().then(this.walletQuickActions);
DeviceEventEmitter.addListener('quickActionShortcut', this.walletQuickActions);
const isViewAllWalletsEnabled = await OnAppLaunch.isViewAllWalletsEnabled();
if (!isViewAllWalletsEnabled) {
const selectedDefaultWallet = await OnAppLaunch.getSelectedDefaultWallet();
const walletIndex = this.state.wallets.findIndex(wallet => wallet.getID() === selectedDefaultWallet.getID());
this.handleClick(walletIndex);
}
}
walletQuickActions = data => {
const wallet = BlueApp.getWallets().find(wallet => wallet.getID() === data.userInfo.url.split('wallet/')[1])
this.navigator.dispatch(
NavigationActions.navigate({
routeName: 'WalletTransactions',
params: {
wallet,
headerColor: WalletGradient.headerColorFor(wallet.type),
},
}),
);
};
componentWillUnmount() {
Linking.removeEventListener('url', this.handleOpenURL);
AppState.removeEventListener('change', this._handleAppStateChange);

2
BlueApp.js

@ -2,6 +2,7 @@
* @exports {AppStorage}
*/
import { AppStorage } from './class';
import DeviceQuickActions from './class/quickActions';
let prompt = require('./prompt');
let EV = require('./events');
let currency = require('./currency');
@ -19,6 +20,7 @@ async function startAndDecrypt(retry) {
}
let password = false;
if (await BlueApp.storageIsEncrypted()) {
DeviceQuickActions.clearShortcutItems();
do {
password = await prompt((retry && loc._.bad_password) || loc._.enter_password, loc._.storage_is_encrypted, false);
} while (!password);

2
MainBottomTabs.js

@ -64,6 +64,8 @@ const WalletsStackNavigator = createStackNavigator(
},
WalletTransactions: {
screen: WalletTransactions,
path: 'WalletTransactions',
routeName: 'WalletTransactions',
},
TransactionStatus: {
screen: TransactionStatus,

5
class/app-storage.js

@ -12,6 +12,7 @@ import {
} from './';
import { LightningCustodianWallet } from './lightning-custodian-wallet';
import WatchConnectivity from '../WatchConnectivity';
import DeviceQuickActions from './quickActions';
const encryption = require('../encryption');
export class AppStorage {
@ -137,6 +138,7 @@ export class AppStorage {
this.cachedPassword = password;
await this.setItem('data', data);
await this.setItem(AppStorage.FLAG_ENCRYPTED, '1');
DeviceQuickActions.clearShortcutItems();
}
/**
@ -320,6 +322,7 @@ export class AppStorage {
}
WatchConnectivity.init();
WatchConnectivity.shared && WatchConnectivity.shared.sendWalletsToWatch();
DeviceQuickActions.setQuickActions(this.wallets);
return this.setItem('data', JSON.stringify(data));
}
@ -455,4 +458,4 @@ export class AppStorage {
async sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
}
}

28
class/quickActions.js

@ -0,0 +1,28 @@
import QuickActions from 'react-native-quick-actions';
const loc = require('../loc/index');
export default class DeviceQuickActions {
static setQuickActions(wallets) {
QuickActions.isSupported((error, supported) => {
if (supported && error === null) {
let shortcutItems = [];
for (const wallet of wallets) {
shortcutItems.push({
type: 'Wallets', // Required
title: wallet.getLabel(), // Optional, if empty, `type` will be used instead
subtitle: `${loc.formatBalance(Number(wallet.getBalance()), wallet.getPreferredBalanceUnit(), true)}`,
userInfo: {
url: `bluewallet://wallet/${wallet.getID()}`, // Provide any custom data like deep linking URL
},
});
}
QuickActions.setShortcutItems(shortcutItems);
}
});
}
static clearShortcutItems() {
QuickActions.clearShortcutItems();
}
}

2
ios/BlueWallet.xcodeproj/project.pbxproj

@ -1688,6 +1688,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = "BlueWalletWatch Extension/BlueWalletWatch Extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
DEBUG_INFORMATION_FORMAT = dwarf;
@ -1721,6 +1722,7 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = "BlueWalletWatch Extension/BlueWalletWatch Extension.entitlements";
CODE_SIGN_IDENTITY = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;

5
ios/BlueWallet/AppDelegate.m

@ -10,6 +10,7 @@
#import <React/RCTLinkingManager.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import "RNQuickActionManager.h"
#import <AppCenterReactNativeShared/AppCenterReactNativeShared.h>
#import <AppCenterReactNative.h>
#import <AppCenterReactNativeAnalytics.h>
@ -49,4 +50,8 @@
return NO;
}
- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler {
[RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];
}
@end

6
ios/Podfile.lock

@ -145,6 +145,8 @@ PODS:
- React
- RNHandoff (0.0.3):
- React
- RNQuickAction (0.3.12):
- React
- RNRate (1.0.1):
- React
- RNSecureKeyStore (1.0.0):
@ -212,6 +214,7 @@ DEPENDENCIES:
- RNFS (from `../node_modules/react-native-fs`)
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNHandoff (from `../node_modules/react-native-handoff`)
- RNQuickAction (from `../node_modules/react-native-quick-actions`)
- RNRate (from `../node_modules/react-native-rate/ios`)
- RNSecureKeyStore (from `../node_modules/react-native-secure-key-store/ios`)
- "RNSentry (from `../node_modules/@sentry/react-native`)"
@ -317,6 +320,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-gesture-handler"
RNHandoff:
:path: "../node_modules/react-native-handoff"
RNQuickAction:
:path: "../node_modules/react-native-quick-actions"
RNRate:
:path: "../node_modules/react-native-rate/ios"
RNSecureKeyStore:
@ -384,6 +389,7 @@ SPEC CHECKSUMS:
RNFS: c9bbde46b0d59619f8e7b735991c60e0f73d22c1
RNGestureHandler: 5329a942fce3d41c68b84c2c2276ce06a696d8b0
RNHandoff: d3b0754cca3a6bcd9b25f544f733f7f033ccf5fa
RNQuickAction: eca9a5dd04b5cdf8a0dd32d8be8844dc33aba2bd
RNRate: 29be49c24b314c4e8ec09d848c3965f61cb0be47
RNSecureKeyStore: f1ad870e53806453039f650720d2845c678d89c8
RNSentry: 2803ba8c8129dcf26b79e9b4d8c80168be6e4390

5
package-lock.json

@ -12333,6 +12333,11 @@
"qrcode": "^1.2.0"
}
},
"react-native-quick-actions": {
"version": "0.3.12",
"resolved": "https://registry.npmjs.org/react-native-quick-actions/-/react-native-quick-actions-0.3.12.tgz",
"integrity": "sha512-jQkzbA6L1/+FIqvHnPenHUe2IrBihh48KOMTOa0QbOaxWzsejSB8kkWpSQOjYxjGu7k+3DVgosQ8wGJTB/l4JA=="
},
"react-native-randombytes": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/react-native-randombytes/-/react-native-randombytes-3.5.3.tgz",

1
package.json

@ -107,6 +107,7 @@
"react-native-privacy-snapshot": "git+https://github.com/BlueWallet/react-native-privacy-snapshot.git",
"react-native-prompt-android": "git+https://github.com/marcosrdz/react-native-prompt-android.git",
"react-native-qrcode-svg": "5.1.2",
"react-native-quick-actions": "0.3.12",
"react-native-randombytes": "3.5.3",
"react-native-rate": "1.1.7",
"react-native-secure-key-store": "git+https://github.com/marcosrdz/react-native-secure-key-store.git",

8
screen/wallets/list.js

@ -6,7 +6,6 @@ import { NavigationEvents } from 'react-navigation';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import PropTypes from 'prop-types';
import WalletGradient from '../../class/walletGradient';
import OnAppLaunch from '../../class/onAppLaunch';
let EV = require('../../events');
let A = require('../../analytics');
/** @type {AppStorage} */
@ -51,13 +50,6 @@ export default class WalletsList extends Component {
// the idea is that upon wallet launch we will refresh
// all balances and all transactions here:
InteractionManager.runAfterInteractions(async () => {
const isViewAllWalletsEnabled = await OnAppLaunch.isViewAllWalletsEnabled();
if (!isViewAllWalletsEnabled) {
const selectedDefaultWallet = await OnAppLaunch.getSelectedDefaultWallet();
const walletIndex = this.state.wallets.findIndex(wallet => wallet.getID() === selectedDefaultWallet.getID());
this.handleClick(walletIndex);
}
let noErr = true;
try {
await BlueElectrum.waitTillConnected();

Loading…
Cancel
Save