REF: Always check for clipboard privacy preferences when using shortcuts

This commit is contained in:
marcosrdz 2021-02-28 12:50:14 -05:00
parent b0e6c8674c
commit 2098cbcd5f
3 changed files with 9 additions and 9 deletions

View File

@ -7,8 +7,8 @@ import DocumentPicker from 'react-native-document-picker';
import isCatalyst from 'react-native-is-catalyst';
import { launchCamera, launchImageLibrary } from 'react-native-image-picker';
import { presentCameraNotAuthorizedAlert } from '../class/camera';
import Clipboard from '@react-native-community/clipboard';
import ActionSheet from '../screen/ActionSheet';
import BlueClipboard from './clipboard';
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
const writeFileAndExport = async function (filename, contents) {
@ -194,7 +194,7 @@ const showFilePickerAndReadFile = async function () {
// Intended for macOS Catalina. Not for long press shortcut
const showActionSheet = async props => {
const isClipboardEmpty = (await Clipboard.getString()).replace(' ', '').length === 0;
const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
let copyFromClipboardIndex;
const options = [loc._.cancel, loc.wallets.take_photo, loc.wallets.list_long_choose];
if (!isClipboardEmpty) {
@ -214,7 +214,7 @@ const showActionSheet = async props => {
.then(resolve)
.catch(error => alert(error.message));
} else if (buttonIndex === copyFromClipboardIndex) {
const clipboard = await Clipboard.getString();
const clipboard = await BlueClipboard.getClipboardContent();
resolve(clipboard);
} else if (importFileButtonIndex) {
const { data } = await showFilePickerAndReadFile();

View File

@ -22,13 +22,13 @@ import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { PlaceholderWallet } from '../../class';
import WalletImport from '../../class/wallet-import';
import ActionSheet from '../ActionSheet';
import Clipboard from '@react-native-community/clipboard';
import loc from '../../loc';
import { FContainer, FButton } from '../../components/FloatButtons';
import { isTablet } from 'react-native-device-info';
import { useFocusEffect, useNavigation, useRoute, useTheme } from '@react-navigation/native';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { isCatalyst, isMacCatalina } from '../../blue_modules/environment';
import BlueClipboard from '../../blue_modules/clipboard';
const A = require('../../blue_modules/analytics');
const fs = require('../../blue_modules/fs');
@ -361,11 +361,11 @@ const WalletsList = () => {
};
const copyFromClipboard = async () => {
onBarScanned(await Clipboard.getString());
onBarScanned(await BlueClipboard.getClipboardContent());
};
const sendButtonLongPress = async () => {
const isClipboardEmpty = (await Clipboard.getString()).replace(' ', '').length === 0;
const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
if (Platform.OS === 'ios') {
if (isMacCatalina) {
fs.showActionSheet({ anchor: findNodeHandle(walletActionButtonsRef.current) }).then(onBarScanned);

View File

@ -20,7 +20,6 @@ import {
View,
} from 'react-native';
import { launchImageLibrary } from 'react-native-image-picker';
import Clipboard from '@react-native-community/clipboard';
import { Icon } from 'react-native-elements';
import { useRoute, useNavigation, useTheme, useFocusEffect } from '@react-navigation/native';
import { Chain } from '../../models/bitcoinUnits';
@ -36,6 +35,7 @@ import BottomModal from '../../components/BottomModal';
import BuyBitcoin from './buyBitcoin';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { isCatalyst, isMacCatalina } from '../../blue_modules/environment';
import BlueClipboard from '../../blue_modules/clipboard';
const fs = require('../../blue_modules/fs');
const BlueElectrum = require('../../blue_modules/BlueElectrum');
@ -477,7 +477,7 @@ const WalletTransactions = () => {
};
const copyFromClipboard = async () => {
onBarCodeRead({ data: await Clipboard.getString() });
onBarCodeRead({ data: await BlueClipboard.getClipboardContent() });
};
const sendButtonPress = () => {
@ -517,7 +517,7 @@ const WalletTransactions = () => {
if (isMacCatalina) {
fs.showActionSheet({ anchor: walletActionButtonsRef.current }).then(onBarCodeRead);
} else {
const isClipboardEmpty = (await Clipboard.getString()).replace(' ', '').length === 0;
const isClipboardEmpty = (await BlueClipboard.getClipboardContent()).trim().length === 0;
if (Platform.OS === 'ios') {
const options = [loc._.cancel, loc.wallets.list_long_choose, loc.wallets.list_long_scan];
if (!isClipboardEmpty) {