Merge branch 'master' into ccfix

This commit is contained in:
marcosrdz 2021-01-25 11:08:54 -05:00
commit 25787d6639
25 changed files with 100 additions and 85 deletions

View File

@ -1,12 +0,0 @@
import Obscure from 'react-native-obscure';
import { Platform } from 'react-native';
import { enabled } from 'react-native-privacy-snapshot';
export default class Privacy {
static enableBlur() {
Platform.OS === 'android' ? Obscure.activateObscure() : enabled(true);
}
static disableBlur() {
Platform.OS === 'android' ? Obscure.deactivateObscure() : enabled(false);
}
}

View File

@ -0,0 +1,10 @@
import Obscure from 'react-native-obscure';
export default class Privacy {
static enableBlur() {
Obscure.activateObscure();
}
static disableBlur() {
Obscure.deactivateObscure();
}
}

View File

@ -0,0 +1,10 @@
import { enabled } from 'react-native-privacy-snapshot';
export default class Privacy {
static enableBlur() {
enabled(true);
}
static disableBlur() {
enabled(false);
}
}

5
blue_modules/Privacy.js Normal file
View File

@ -0,0 +1,5 @@
export default class Privacy {
static enableBlur() {}
static disableBlur() {}
}

View File

@ -18,6 +18,12 @@ export const BlueStorageProvider = ({ children }) => {
const getPreferredCurrencyAsyncStorage = useAsyncStorage(AppStorage.PREFERRED_CURRENCY).getItem;
const getLanguageAsyncStorage = useAsyncStorage(AppStorage.LANG).getItem;
const [newWalletAdded, setNewWalletAdded] = useState(false);
const [isHandOffUseEnabled, setIsHandOffUseEnabled] = useState(false);
const setIsHandOffUseEnabledAsyncStorage = value => {
setIsHandOffUseEnabled(value);
return BlueApp.setItem(AppStorage.HANDOFF_STORAGE_KEY, value === true ? '1' : '');
};
const saveToDisk = async () => {
BlueApp.tx_metadata = txMetadata;
await BlueApp.saveToDisk();
@ -29,6 +35,18 @@ export const BlueStorageProvider = ({ children }) => {
setWallets(BlueApp.getWallets());
}, []);
useEffect(() => {
(async () => {
try {
const enabledHandoff = await BlueApp.getItem(AppStorage.HANDOFF_STORAGE_KEY);
setIsHandOffUseEnabled(!!enabledHandoff);
} catch (_e) {
setIsHandOffUseEnabledAsyncStorage(false);
setIsHandOffUseEnabled(false);
}
})();
}, []);
const getPreferredCurrency = async () => {
const item = await getPreferredCurrencyAsyncStorage();
_setPreferredFiatCurrency(item);
@ -187,6 +205,8 @@ export const BlueStorageProvider = ({ children }) => {
preferredFiatCurrency,
setLanguage,
language,
isHandOffUseEnabled,
setIsHandOffUseEnabledAsyncStorage,
}}
>
{children}

View File

@ -35,6 +35,7 @@ export class AppStorage {
static HODL_HODL_API_KEY = 'HODL_HODL_API_KEY';
static HODL_HODL_SIGNATURE_KEY = 'HODL_HODL_SIGNATURE_KEY';
static HODL_HODL_CONTRACTS = 'HODL_HODL_CONTRACTS';
static HANDOFF_STORAGE_KEY = 'HandOff';
constructor() {
/** {Array.<AbstractWallet>} */

View File

@ -1,24 +0,0 @@
import { Platform } from 'react-native';
const BlueApp = require('../BlueApp');
export default class HandoffSettings {
static STORAGEKEY = 'HandOff';
static async isHandoffUseEnabled() {
if (Platform.OS !== 'ios') {
return false;
}
try {
const enabledHandoff = await BlueApp.getItem(HandoffSettings.STORAGEKEY);
return !!enabledHandoff;
} catch (_e) {
await BlueApp.setItem(HandoffSettings.STORAGEKEY, '');
return false;
}
}
static async setHandoffUseEnabled(value) {
await BlueApp.setItem(HandoffSettings.STORAGEKEY, value === true && Platform.OS === 'ios' ? '1' : '');
}
}

15
components/handoff.ios.js Normal file
View File

@ -0,0 +1,15 @@
import React, { useContext } from 'react';
import Handoff from 'react-native-handoff';
import { BlueStorageContext } from '../blue_modules/storage-context';
import PropTypes from 'prop-types';
const HandoffComponent = props => {
const { isHandOffUseEnabled } = useContext(BlueStorageContext);
return isHandOffUseEnabled && props && props.url ? <Handoff {...props} /> : null;
};
export default HandoffComponent;
HandoffComponent.propTypes = {
url: PropTypes.string,
};

5
components/handoff.js Normal file
View File

@ -0,0 +1,5 @@
const HandoffComponent = () => {
return null;
};
export default HandoffComponent;

View File

@ -177,6 +177,7 @@
"details_adv_full_sure": "Etes-vous sûr de vouloir utiliser la totalité de votre solde pour cette transaction ?",
"details_adv_import": "Importer une transaction",
"details_amount_field_is_not_valid": "Champ montant invalide",
"details_amount_field_is_less_than_minimum_amount_sat": "Le montant spécifié est trop petit. Veuillez entrer un montant supérieur à 500 sats.",
"details_create": "Créer la requête",
"details_error_decode": "Erreur : impossible de décoder l'adresse Bitcoin",
"details_fee_field_is_not_valid": "Champ frais invalide",

View File

@ -11,6 +11,7 @@
"babel-eslint": "^10.1.0",
"babel-jest": "^26.1.0",
"babel-preset-flow": "^6.23.0",
"detox-recorder": "^1.0.149",
"eslint": "^7.5.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.22.0",

View File

@ -13,7 +13,6 @@ import {
import QRCode from 'react-native-qrcode-svg';
import { useNavigation, useRoute, useTheme, useFocusEffect } from '@react-navigation/native';
import Share from 'react-native-share';
import Handoff from 'react-native-handoff';
import {
BlueLoading,
@ -29,9 +28,9 @@ import {
} from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import BottomModal from '../../components/BottomModal';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import { Chain, BitcoinUnit } from '../../models/bitcoinUnits';
import HandoffSettings from '../../class/handoff';
import HandoffComponent from '../../components/handoff';
import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
@ -42,7 +41,6 @@ const ReceiveDetails = () => {
const { walletID } = useRoute().params;
const { wallets, saveToDisk, sleep } = useContext(BlueStorageContext);
const wallet = wallets.find(w => w.getID() === walletID);
const [isHandOffUseEnabled, setIsHandOffUseEnabled] = useState(false);
const [address, setAddress] = useState('');
const [customLabel, setCustomLabel] = useState();
const [customAmount, setCustomAmount] = useState(0);
@ -172,7 +170,6 @@ const ReceiveDetails = () => {
};
const obtainWalletAddress = useCallback(async () => {
HandoffSettings.isHandoffUseEnabled().then(setIsHandOffUseEnabled);
Privacy.enableBlur();
console.log('receive/details - componentDidMount');
wallet.setUserHasSavedExport(true);
@ -344,8 +341,8 @@ const ReceiveDetails = () => {
return (
<View style={styles.root}>
<StatusBar barStyle="light-content" />
{isHandOffUseEnabled && address !== undefined && showAddress && (
<Handoff
{address !== undefined && showAddress && (
<HandoffComponent
title={`Bitcoin Transaction ${address}`}
type="io.bluewallet.bluewallet"
url={`https://blockstream.info/address/${address}`}

View File

@ -24,7 +24,7 @@ import isCatalyst from 'react-native-is-catalyst';
import { SafeBlueArea, BlueCard, BlueText } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import loc from '../../loc';
import { BlueCurrentTheme } from '../../components/themes';

View File

@ -4,7 +4,6 @@ import { ScrollView, Platform, TouchableWithoutFeedback, TouchableOpacity, Style
import navigationStyle from '../../components/navigationStyle';
import { BlueLoading, BlueText, BlueSpacing20, BlueListItem, BlueCard } from '../../BlueComponents';
import { useNavigation, useTheme } from '@react-navigation/native';
import HandoffSettings from '../../class/handoff';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
@ -15,10 +14,11 @@ const styles = StyleSheet.create({
});
const GeneralSettings = () => {
const { isAdancedModeEnabled, setIsAdancedModeEnabled, wallets } = useContext(BlueStorageContext);
const { isAdancedModeEnabled, setIsAdancedModeEnabled, wallets, isHandOffUseEnabled, setIsHandOffUseEnabledAsyncStorage } = useContext(
BlueStorageContext,
);
const [isLoading, setIsLoading] = useState(true);
const [isAdancedModeSwitchEnabled, setIsAdancedModeSwitchEnabled] = useState(false);
const [isHandoffUseEnabled, setIsHandoffUseEnabled] = useState(false);
const { navigate } = useNavigation();
const { colors } = useTheme();
const onAdvancedModeSwitch = async value => {
@ -26,15 +26,9 @@ const GeneralSettings = () => {
setIsAdancedModeSwitchEnabled(value);
};
const onHandOffEnabledSwitch = async value => {
await HandoffSettings.setHandoffUseEnabled(value);
setIsHandoffUseEnabled(value);
};
useEffect(() => {
(async () => {
setIsAdancedModeSwitchEnabled(await isAdancedModeEnabled());
setIsHandoffUseEnabled(await HandoffSettings.isHandoffUseEnabled());
setIsLoading(false);
})();
});
@ -69,7 +63,7 @@ const GeneralSettings = () => {
hideChevron
title={loc.settings.general_continuity}
Component={TouchableWithoutFeedback}
switch={{ onValueChange: onHandOffEnabledSwitch, value: isHandoffUseEnabled }}
switch={{ onValueChange: setIsHandOffUseEnabledAsyncStorage, value: isHandOffUseEnabled }}
/>
<BlueCard>
<BlueText>{loc.settings.general_continuity_e}</BlueText>

View File

@ -2,10 +2,9 @@
import React, { useContext, useEffect, useState } from 'react';
import { View, ScrollView, TouchableOpacity, Text, TextInput, Linking, StatusBar, StyleSheet, Keyboard } from 'react-native';
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import Handoff from 'react-native-handoff';
import { BlueCard, BlueCopyToClipboardButton, BlueLoading, BlueSpacing20, BlueText, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import HandoffSettings from '../../class/handoff';
import HandoffComponent from '../../components/handoff';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
const dayjs = require('dayjs');
@ -28,7 +27,6 @@ const TransactionsDetails = () => {
const { setOptions } = useNavigation();
const { hash } = useRoute().params;
const { saveToDisk, txMetadata, wallets, getTransactions } = useContext(BlueStorageContext);
const [isHandOffUseEnabled, setIsHandOffUseEnabled] = useState(false);
const [from, setFrom] = useState();
const [to, setTo] = useState();
const [isLoading, setIsLoading] = useState(true);
@ -110,11 +108,6 @@ const TransactionsDetails = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hash, wallets]);
useEffect(() => {
HandoffSettings.isHandoffUseEnabled().then(setIsHandOffUseEnabled);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const handleOnSaveButtonTapped = () => {
Keyboard.dismiss();
txMetadata[tx.hash] = { memo };
@ -136,9 +129,11 @@ const TransactionsDetails = () => {
return (
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={styles.root}>
{isHandOffUseEnabled && (
<Handoff title={`Bitcoin Transaction ${tx.hash}`} type="io.bluewallet.bluewallet" url={`https://blockstream.info/tx/${tx.hash}`} />
)}
<HandoffComponent
title={`Bitcoin Transaction ${tx.hash}`}
type="io.bluewallet.bluewallet"
url={`https://blockstream.info/tx/${tx.hash}`}
/>
<StatusBar barStyle="default" />
<ScrollView style={styles.scroll}>
<BlueCard>

View File

@ -1,7 +1,6 @@
import React, { useContext, useEffect, useRef, useState } from 'react';
import { View, ActivityIndicator, Text, TouchableOpacity, StyleSheet, StatusBar } from 'react-native';
import { Icon } from 'react-native-elements';
import Handoff from 'react-native-handoff';
import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import {
@ -19,7 +18,7 @@ import {
import navigationStyle from '../../components/navigationStyle';
import { HDSegwitBech32Transaction } from '../../class';
import { BitcoinUnit } from '../../models/bitcoinUnits';
import HandoffSettings from '../../class/handoff';
import HandoffComponent from '../../components/handoff';
import loc, { formatBalanceWithoutSuffix } from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
@ -31,7 +30,6 @@ const buttonStatus = Object.freeze({
const TransactionsStatus = () => {
const { setSelectedWallet, wallets, txMetadata, getTransactions } = useContext(BlueStorageContext);
const [isHandOffUseEnabled, setIsHandOffUseEnabled] = useState(false);
const { hash } = useRoute().params;
const { navigate, setOptions } = useNavigation();
const { colors } = useTheme();
@ -127,7 +125,6 @@ const TransactionsStatus = () => {
useEffect(() => {
console.log('transactions/details - useEffect');
HandoffSettings.isHandoffUseEnabled().then(setIsHandOffUseEnabled);
}, []);
const checkPossibilityOfCPFP = async () => {
@ -282,9 +279,12 @@ const TransactionsStatus = () => {
}
return (
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={[styles.root, stylesHook.root]}>
{isHandOffUseEnabled && (
<Handoff title={`Bitcoin Transaction ${tx.hash}`} type="io.bluewallet.bluewallet" url={`https://blockstream.info/tx/${tx.hash}`} />
)}
<HandoffComponent
title={`Bitcoin Transaction ${tx.hash}`}
type="io.bluewallet.bluewallet"
url={`https://blockstream.info/tx/${tx.hash}`}
/>
<StatusBar barStyle="default" />
<View style={styles.container}>
<BlueCard>

View File

@ -5,7 +5,7 @@ import { useTheme, useNavigation, useFocusEffect, useRoute } from '@react-naviga
import { BlueSpacing20, SafeBlueArea, BlueText, BlueCopyTextToClipboard, BlueCard } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import Biometric from '../../class/biometrics';
import { LegacyWallet, LightningCustodianWallet, SegwitBech32Wallet, SegwitP2SHWallet, WatchOnlyWallet } from '../../class';
import loc from '../../loc';

View File

@ -5,7 +5,7 @@ import { useFocusEffect, useNavigation, useRoute, useTheme } from '@react-naviga
import { BlueSpacing20, BlueText, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import { DynamicQRCode } from '../../components/DynamicQRCode';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import Biometric from '../../class/biometrics';
import loc from '../../loc';
import { SquareButton } from '../../components/SquareButton';

View File

@ -15,7 +15,7 @@ import {
BlueSpacing20,
} from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import WalletImport from '../../class/wallet-import';
import loc from '../../loc';
const isDesktop = getSystemName() === 'Mac OS X';

View File

@ -4,7 +4,7 @@ import { useNavigation, useRoute, useTheme } from '@react-navigation/native';
import { BlueSpacing20, SafeBlueArea, BlueText, BlueButton } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';

View File

@ -6,7 +6,7 @@ import { ScrollView } from 'react-native-gesture-handler';
import { BlueButton, BlueCopyTextToClipboard, BlueSpacing20, BlueText, BlueTextCentered, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { LightningCustodianWallet } from '../../class';

View File

@ -21,7 +21,6 @@ import {
import { launchImageLibrary } from 'react-native-image-picker';
import Clipboard from '@react-native-community/clipboard';
import { Icon } from 'react-native-elements';
import Handoff from 'react-native-handoff';
import { useRoute, useNavigation, useTheme, useFocusEffect } from '@react-navigation/native';
import isCatalyst from 'react-native-is-catalyst';
@ -30,7 +29,7 @@ import { BlueTransactionListItem, BlueWalletNavigationHeader, BlueAlertWalletExp
import WalletGradient from '../../class/wallet-gradient';
import navigationStyle from '../../components/navigationStyle';
import { LightningCustodianWallet, MultisigHDWallet, WatchOnlyWallet } from '../../class';
import HandoffSettings from '../../class/handoff';
import HandoffComponent from '../../components/handoff';
import ActionSheet from '../ActionSheet';
import loc from '../../loc';
import { FContainer, FButton } from '../../components/FloatButtons';
@ -50,7 +49,6 @@ const buttonFontSize =
const WalletTransactions = () => {
const { wallets, saveToDisk, setSelectedWallet } = useContext(BlueStorageContext);
const [isHandOffUseEnabled, setIsHandOffUseEnabled] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const [isManageFundsModalVisible, setIsManageFundsModalVisible] = useState(false);
const { walletID } = useRoute().params;
@ -107,7 +105,6 @@ const WalletTransactions = () => {
};
useEffect(() => {
HandoffSettings.isHandoffUseEnabled().then(setIsHandOffUseEnabled);
const interval = setInterval(() => setTimeElapsed(prev => prev + 1), 60000);
return () => {
clearInterval(interval);
@ -590,8 +587,8 @@ const WalletTransactions = () => {
return (
<View style={styles.flex}>
<StatusBar barStyle="light-content" backgroundColor={WalletGradient.headerColorFor(wallet.current.type)} />
{wallet.current.chain === Chain.ONCHAIN && wallet.current.type !== MultisigHDWallet.type && isHandOffUseEnabled && (
<Handoff
{wallet.current.chain === Chain.ONCHAIN && wallet.current.type !== MultisigHDWallet.type && (
<HandoffComponent
title={`Bitcoin Wallet ${wallet.current.getLabel()}`}
type="io.bluewallet.bluewallet"
url={`https://blockpath.com/search/addr?q=${wallet.current.getXpub()}`}

View File

@ -36,7 +36,7 @@ import MultipleStepsListItem, {
MultipleStepsListItemButtohType,
MultipleStepsListItemDashType,
} from '../../components/MultipleStepsListItem';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import Biometric from '../../class/biometrics';
import QRCode from 'react-native-qrcode-svg';
import { SquareButton } from '../../components/SquareButton';

View File

@ -5,7 +5,7 @@ import { useFocusEffect, useRoute, useNavigation, useTheme } from '@react-naviga
import navigationStyle from '../../components/navigationStyle';
import { BlueSpacing20, SafeBlueArea, BlueText, BlueCopyTextToClipboard } from '../../BlueComponents';
import Privacy from '../../Privacy';
import Privacy from '../../blue_modules/Privacy';
import Biometric from '../../class/biometrics';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';