REF: Camera Authorization Request

This commit is contained in:
Marcos Rodriguez Velez 2023-10-17 09:35:10 -04:00
parent 7343c37021
commit 889689a3af
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
19 changed files with 229 additions and 150 deletions

View File

@ -7,6 +7,7 @@ import { useTheme } from '@react-navigation/native';
import loc from '../loc';
import * as NavigationService from '../NavigationService';
import { requestCameraAuthorization } from '../helpers/scan-qr';
const fs = require('../blue_modules/fs');
const isDesktop = getSystemName() === 'Mac OS X';
@ -75,13 +76,15 @@ const AddressInput = ({
if (isDesktop) {
fs.showActionSheet({ anchor: findNodeHandle(scanButtonRef.current) }).then(onBarScanned);
} else {
NavigationService.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy,
onBarScanned,
onBarScannerDismissWithoutData,
},
requestCameraAuthorization().then(() => {
NavigationService.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy,
onBarScanned,
onBarScannerDismissWithoutData,
},
});
});
}
}}

View File

@ -1,3 +1,6 @@
import { Platform } from 'react-native';
import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions';
/**
* Helper function that navigates to ScanQR screen, and returns promise that will resolve with the result of a scan,
* and then navigates back. If QRCode scan was closed, promise resolves to null.
@ -8,32 +11,43 @@
*
* @return {Promise<string>}
*/
module.exports = function scanQrHelper(
function scanQrHelper(
navigateFunc: (scr: string, params?: any) => void,
currentScreenName: string,
showFileImportButton = true,
): Promise<string | null> {
return new Promise(resolve => {
const params = {
showFileImportButton: Boolean(showFileImportButton),
onBarScanned: (data: any) => {},
onDismiss: () => {},
};
return requestCameraAuthorization().then(() => {
return new Promise(resolve => {
const params = {
showFileImportButton: Boolean(showFileImportButton),
onBarScanned: (data: any) => {},
onDismiss: () => {},
};
params.onBarScanned = function (data: any) {
setTimeout(() => resolve(data.data || data), 1);
navigateFunc(currentScreenName);
};
params.onBarScanned = function (data: any) {
setTimeout(() => resolve(data.data || data), 1);
navigateFunc(currentScreenName);
};
params.onDismiss = function () {
setTimeout(() => resolve(null), 1);
};
params.onDismiss = function () {
setTimeout(() => resolve(null), 1);
};
navigateFunc('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params,
});
});
navigateFunc('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params,
});
})}
);
}
const isCameraAuthorizationStatusGranted = async () => {
const status = await check(Platform.OS === 'android' ? PERMISSIONS.ANDROID.CAMERA : PERMISSIONS.IOS.CAMERA);
return status === RESULTS.GRANTED;
};
export {};
const requestCameraAuthorization = () => {
return request(Platform.OS === 'android' ? PERMISSIONS.ANDROID.CAMERA : PERMISSIONS.IOS.CAMERA);
};
export { scanQrHelper, isCameraAuthorizationStatusGranted, requestCameraAuthorization };

View File

@ -1,10 +1,22 @@
def node_require(script)
# Resolve script with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
"require.resolve(
'#{script}',
{paths: [process.argv[1]]},
)", __dir__]).strip
end
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
workspace 'BlueWallet'
platform :ios, '13.0'
prepare_react_native_project!
setup_permissions(['Camera'])
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
@ -53,6 +65,7 @@ target 'BlueWallet' do
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => true
)
pod 'Bugsnag'
plugin 'cocoapods-bugsnag'
installer.pods_project.targets.each do |target|

View File

@ -416,6 +416,8 @@ PODS:
- React-Core
- RNLocalize (3.0.2):
- React-Core
- RNPermissions (3.10.0):
- React-Core
- RNPrivacySnapshot (1.0.0):
- React
- RNQuickAction (0.3.13):
@ -533,6 +535,7 @@ DEPENDENCIES:
- RNHandoff (from `../node_modules/react-native-handoff`)
- RNKeychain (from `../node_modules/react-native-keychain`)
- RNLocalize (from `../node_modules/react-native-localize`)
- RNPermissions (from `../node_modules/react-native-permissions`)
- RNPrivacySnapshot (from `../node_modules/react-native-privacy-snapshot`)
- RNQuickAction (from `../node_modules/react-native-quick-actions`)
- RNRate (from `../node_modules/react-native-rate`)
@ -682,6 +685,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-keychain"
RNLocalize:
:path: "../node_modules/react-native-localize"
RNPermissions:
:path: "../node_modules/react-native-permissions"
RNPrivacySnapshot:
:path: "../node_modules/react-native-privacy-snapshot"
RNQuickAction:
@ -774,6 +779,7 @@ SPEC CHECKSUMS:
RNHandoff: d3b0754cca3a6bcd9b25f544f733f7f033ccf5fa
RNKeychain: a65256b6ca6ba6976132cc4124b238a5b13b3d9c
RNLocalize: dbea38dcb344bf80ff18a1757b1becf11f70cae4
RNPermissions: eae8b97d8ab0587f082966ee608f47c97b2a349b
RNPrivacySnapshot: 71919dde3c6a29dd332115409c2aec564afee8f4
RNQuickAction: 6d404a869dc872cde841ad3147416a670d13fa93
RNRate: ef3bcff84f39bb1d1e41c5593d3eea4aab2bd73a
@ -786,6 +792,6 @@ SPEC CHECKSUMS:
RNWatch: fd30ca40a5b5ef58dcbc195638e68219bc455236
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9
PODFILE CHECKSUM: 8e9e7955e2b1beadc75774b0b7f8eb52f7299757
PODFILE CHECKSUM: 23bb5c319ccbedd7e109c44fe4273afce6efb48a
COCOAPODS: 1.11.3

21
package-lock.json generated
View File

@ -82,6 +82,7 @@
"react-native-navigation-bar-color": "https://github.com/BlueWallet/react-native-navigation-bar-color#3b2894ae62fbce99a3bd24105f0921cebaef5c94",
"react-native-obscure": "https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb",
"react-native-passcode-auth": "https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"react-native-permissions": "^3.10.0",
"react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783",
"react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376",
"react-native-push-notification": "8.1.1",
@ -18348,6 +18349,21 @@
"integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==",
"license": "ISC"
},
"node_modules/react-native-permissions": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-3.10.0.tgz",
"integrity": "sha512-6SB6JInfC0u54Wco8M1QsRoOGThnVjrhaks5IDWyYgwfi6JpXfTIi+F9fZZmRycyyPCgU8vGtht/5gF4VWEB/A==",
"peerDependencies": {
"react": ">=16.13.1",
"react-native": ">=0.63.3",
"react-native-windows": ">=0.62.0"
},
"peerDependenciesMeta": {
"react-native-windows": {
"optional": true
}
}
},
"node_modules/react-native-privacy-snapshot": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/BlueWallet/react-native-privacy-snapshot.git#529e4627d93f67752a27e82a040ff7b64dca0783",
@ -34285,6 +34301,11 @@
"integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==",
"from": "react-native-passcode-auth@https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12"
},
"react-native-permissions": {
"version": "3.10.0",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-3.10.0.tgz",
"integrity": "sha512-6SB6JInfC0u54Wco8M1QsRoOGThnVjrhaks5IDWyYgwfi6JpXfTIi+F9fZZmRycyyPCgU8vGtht/5gF4VWEB/A=="
},
"react-native-privacy-snapshot": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-privacy-snapshot.git#529e4627d93f67752a27e82a040ff7b64dca0783",
"integrity": "sha512-bO73UmkI0KpAzk3766z77qBdArwOaBCr58q5H0qDfn0jf5HonYoEkJRDRwHr7SpDxrSu2Nuoz2AokxLyb3/KXw==",

View File

@ -167,6 +167,7 @@
"react-native-navigation-bar-color": "https://github.com/BlueWallet/react-native-navigation-bar-color#3b2894ae62fbce99a3bd24105f0921cebaef5c94",
"react-native-obscure": "https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb",
"react-native-passcode-auth": "https://github.com/BlueWallet/react-native-passcode-auth#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"react-native-permissions": "^3.10.0",
"react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783",
"react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376",
"react-native-push-notification": "8.1.1",

View File

@ -29,6 +29,7 @@ import { BlueStorageContext } from '../../blue_modules/storage-context';
import Notifications from '../../blue_modules/notifications';
import alert from '../../components/Alert';
import { parse } from 'url'; // eslint-disable-line n/no-deprecated-api
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const currency = require('../../blue_modules/currency');
const torrific = require('../../blue_modules/torrific');
@ -340,6 +341,7 @@ const LNDCreateInvoice = () => {
};
const navigateToScanQRCode = () => {
requestCameraAuthorization().then(() => {
NavigationService.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
@ -348,7 +350,7 @@ const LNDCreateInvoice = () => {
},
});
Keyboard.dismiss();
};
});
const renderScanClickable = () => {
return (

View File

@ -1,13 +1,15 @@
import React, { useEffect, useState } from 'react';
import { Image, View, TouchableOpacity, StatusBar, Platform, StyleSheet, TextInput, Alert, PermissionsAndroid } from 'react-native';
import { Image, View, TouchableOpacity, StatusBar, Platform, StyleSheet, TextInput, Alert } from 'react-native';
import { CameraScreen } from 'react-native-camera-kit';
import { Icon } from 'react-native-elements';
import { launchImageLibrary } from 'react-native-image-picker';
import { decodeUR, extractSingleWorkload, BlueURDecoder } from '../../blue_modules/ur';
import { useNavigation, useRoute, useIsFocused, useTheme } from '@react-navigation/native';
import loc from '../../loc';
import { BlueLoading, BlueText, BlueButton } from '../../BlueComponents';
import { BlueLoading, BlueText, BlueButton, BlueSpacing40 } from '../../BlueComponents';
import alert from '../../components/Alert';
import { openPrivacyDesktopSettings } from '../../class/camera';
import { isCameraAuthorizationStatusGranted } from '../../helpers/scan-qr';
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
const createHash = require('create-hash');
@ -93,7 +95,7 @@ const ScanQRCode = () => {
const [backdoorText, setBackdoorText] = useState('');
const [backdoorVisible, setBackdoorVisible] = useState(false);
const [animatedQRCodeData, setAnimatedQRCodeData] = useState({});
const [cameraStatus, setCameraStatus] = useState(false);
const [cameraStatusGranted, setCameraStatusGranted] = useState(false);
const stylesHook = StyleSheet.create({
openSettingsContainer: {
backgroundColor: colors.brandingColor,
@ -108,30 +110,7 @@ const ScanQRCode = () => {
});
useEffect(() => {
(async () => {
try {
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
setCameraStatus(true);
return;
}
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA, {
title: '',
message: loc.send.permission_camera_message,
buttonNeutral: loc.send.permission_storage_later,
buttonNegative: loc._.no,
buttonPositive: loc._.yes,
});
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('You can use the camera');
setCameraStatus(true);
} else {
console.log('Camera permission denied');
setCameraStatus(false);
}
} catch (err) {
console.warn(err);
}
})();
isCameraAuthorizationStatusGranted().then(setCameraStatusGranted);
}, []);
const HashIt = function (s) {
@ -331,14 +310,17 @@ const ScanQRCode = () => {
if (onDismiss) onDismiss();
};
return isLoading ? (
<View style={styles.root}>
<BlueLoading />
</View>
const render = isLoading ? (
<BlueLoading />
) : (
<View style={styles.root}>
<StatusBar hidden />
{isFocused && cameraStatus ? (
<>
{!cameraStatusGranted ? (
<View style={[styles.openSettingsContainer, stylesHook.openSettingsContainer]}>
<BlueText>{loc.send.permission_camera_message}</BlueText>
<BlueSpacing40 />
<BlueButton title={loc.send.open_settings} onPress={openPrivacyDesktopSettings} />
</View>
) : isFocused && cameraStatusGranted ? (
<CameraScreen scanBarcode onReadCode={event => onBarCodeRead({ data: event?.nativeEvent?.codeStringValue })} showFrame={false} />
) : null}
<TouchableOpacity accessibilityRole="button" accessibilityLabel={loc._.close} style={styles.closeTouch} onPress={dismiss}>
@ -413,6 +395,13 @@ const ScanQRCode = () => {
setBackdoorVisible(true);
}}
/>
</>
);
return (
<View style={styles.root}>
<StatusBar hidden />
{render}
</View>
);
};

View File

@ -602,7 +602,7 @@ const SendDetails = () => {
}
setOptionsVisible(false);
requestCameraAuthorization().then(() => {
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
@ -610,7 +610,7 @@ const SendDetails = () => {
showFileImportButton: false,
},
});
};
});
const importQrTransactionOnBarScanned = ret => {
navigation.dangerouslyGetParent().pop();
@ -765,6 +765,7 @@ const SendDetails = () => {
const importTransactionMultisigScanQr = () => {
setOptionsVisible(false);
requestCameraAuthorization().then(() => {
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
@ -772,7 +773,7 @@ const SendDetails = () => {
showFileImportButton: true,
},
});
};
});
const handleAddRecipient = async () => {
setAddresses(addrs => [...addrs, { address: '', key: String(Math.random()) }]);

View File

@ -6,6 +6,7 @@ import loc from '../../loc';
import { BlueButton, BlueButtonLink, BlueCard, BlueSpacing10, BlueSpacing20, BlueText, SafeBlueArea } from '../../BlueComponents';
import navigationStyle from '../../components/navigationStyle';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const IsItMyAddress = () => {
/** @type {AbstractWallet[]} */
@ -54,6 +55,7 @@ const IsItMyAddress = () => {
};
const importScan = () => {
requestCameraAuthorization().then(() => {
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
@ -62,7 +64,7 @@ const IsItMyAddress = () => {
showFileImportButton: true,
},
});
};
});
const clearAddressInput = () => {
setAddress('');

View File

@ -10,6 +10,7 @@ import { SquareButton } from '../../components/SquareButton';
import loc from '../../loc';
import alert from '../../components/Alert';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const bitcoin = require('bitcoinjs-lib');
const fs = require('../../blue_modules/fs');
@ -64,13 +65,15 @@ const PsbtMultisigQRCode = () => {
if (isDesktop) {
fs.showActionSheet({ anchor: findNodeHandle(openScannerButton.current) }).then(data => onBarScanned({ data }));
} else {
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
onBarScanned,
showFileImportButton: true,
},
});
requestCameraAuthorization().then(() =>
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
onBarScanned,
showFileImportButton: true,
},
}),
);
}
};

View File

@ -14,6 +14,7 @@ import { BlueStorageContext } from '../../blue_modules/storage-context';
import Notifications from '../../blue_modules/notifications';
import { DynamicQRCode } from '../../components/DynamicQRCode';
import alert from '../../components/Alert';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const BlueElectrum = require('../../blue_modules/BlueElectrum');
const bitcoin = require('bitcoinjs-lib');
const fs = require('../../blue_modules/fs');
@ -208,13 +209,15 @@ const PsbtWithHardwareWallet = () => {
};
const openScanner = () => {
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
showFileImportButton: false,
onBarScanned,
},
requestCameraAuthorization().then(() => {
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
showFileImportButton: false,
onBarScanned,
},
});
});
};

View File

@ -37,6 +37,7 @@ import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import WidgetCommunication from '../../blue_modules/WidgetCommunication';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import alert from '../../components/Alert';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const BlueElectrum = require('../../blue_modules/BlueElectrum');
@ -234,14 +235,17 @@ export default class ElectrumSettings extends Component {
};
importScan = () => {
this.props.navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: this.props.route.name,
onBarScanned: this.onBarScanned,
showFileImportButton: true,
},
});
() =>
requestCameraAuthorization().then(() =>
this.props.navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: this.props.route.name,
onBarScanned: this.onBarScanned,
showFileImportButton: true,
},
}),
);
};
useSSLPortToggled = value => {

View File

@ -12,6 +12,7 @@ import { useTheme } from '../../components/themes';
import DeeplinkSchemaMatch from '../../class/deeplink-schema-match';
import { isTorCapable } from '../../blue_modules/environment';
import alert from '../../components/Alert';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const BlueApp = require('../../BlueApp');
const AppStorage = BlueApp.AppStorage;
@ -116,14 +117,16 @@ const LightningSettings: React.FC & { navigationOptions: NavigationOptionsGetter
}, [URI]);
const importScan = () => {
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned: setLndhubURI,
showFileImportButton: true,
},
});
requestCameraAuthorization().then(() =>
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned: setLndhubURI,
showFileImportButton: true,
},
}),
);
};
return (

View File

@ -42,6 +42,7 @@ import { encodeUR } from '../../blue_modules/ur';
import QRCodeComponent from '../../components/QRCodeComponent';
import alert from '../../components/Alert';
import confirm from '../../helpers/confirm';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const prompt = require('../../helpers/prompt');
const A = require('../../blue_modules/analytics');
@ -466,16 +467,18 @@ const WalletsAddMultisigStep2 = () => {
fs.showActionSheet({ anchor: findNodeHandle(openScannerButton.current) }).then(onBarScanned);
} else {
setIsProvideMnemonicsModalVisible(false);
setTimeout(
() =>
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
onBarScanned,
showFileImportButton: true,
},
}),
650,
setTimeout(() =>
requestCameraAuthorization().then(
() =>
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
onBarScanned,
showFileImportButton: true,
},
}),
650,
),
);
}
};

View File

@ -16,6 +16,7 @@ import navigationStyle from '../../components/navigationStyle';
import Privacy from '../../blue_modules/Privacy';
import loc from '../../loc';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const WalletsImport = () => {
const navigation = useNavigation();
@ -92,14 +93,16 @@ const WalletsImport = () => {
};
const importScan = () => {
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned,
showFileImportButton: true,
},
});
requestCameraAuthorization().then(() =>
navigation.navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned,
showFileImportButton: true,
},
}),
);
};
const speedBackdoorTap = () => {

View File

@ -27,8 +27,8 @@ import { isDesktop, isTablet } from '../../blue_modules/environment';
import BlueClipboard from '../../blue_modules/clipboard';
import navigationStyle from '../../components/navigationStyle';
import { TransactionListItem } from '../../components/TransactionListItem';
import { scanQrHelper } from '../../helpers/scan-qr';
const scanqrHelper = require('../../helpers/scan-qr');
const A = require('../../blue_modules/analytics');
const fs = require('../../blue_modules/fs');
const WalletsListSections = { CAROUSEL: 'CAROUSEL', TRANSACTIONS: 'TRANSACTIONS' };
@ -287,7 +287,7 @@ const WalletsList = () => {
};
const onScanButtonPressed = () => {
scanqrHelper(navigate, routeName, false).then(onBarScanned);
scanQrHelper(navigate, routeName, false).then(onBarScanned);
};
const onBarScanned = value => {
@ -315,7 +315,7 @@ const WalletsList = () => {
if (buttonIndex === 1) {
fs.showImagePickerAndReadImage().then(onBarScanned);
} else if (buttonIndex === 2) {
scanqrHelper(navigate, routeName, false).then(onBarScanned);
scanQrHelper(navigate, routeName, false).then(onBarScanned);
} else if (buttonIndex === 3) {
copyFromClipboard();
}
@ -334,7 +334,7 @@ const WalletsList = () => {
},
{
text: loc.wallets.list_long_scan,
onPress: () => scanqrHelper(navigate, routeName, false).then(onBarScanned),
onPress: () => scanQrHelper(navigate, routeName, false).then(onBarScanned),
},
];
if (!isClipboardEmpty) {

View File

@ -34,6 +34,7 @@ import TransactionsNavigationHeader, { actionKeys } from '../../components/Trans
import { TransactionListItem } from '../../components/TransactionListItem';
import alert from '../../components/Alert';
import PropTypes from 'prop-types';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const fs = require('../../blue_modules/fs');
const BlueElectrum = require('../../blue_modules/BlueElectrum');
@ -416,14 +417,16 @@ const WalletTransactions = ({ navigation }) => {
if (buttonIndex === 1) {
choosePhoto();
} else if (buttonIndex === 2) {
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: name,
onBarScanned: onBarCodeRead,
showFileImportButton: false,
},
});
requestCameraAuthorization().then(() =>
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: name,
onBarScanned: onBarCodeRead,
showFileImportButton: false,
},
}),
);
} else if (buttonIndex === 3) {
copyFromClipboard();
}
@ -443,13 +446,15 @@ const WalletTransactions = ({ navigation }) => {
{
text: loc.wallets.list_long_scan,
onPress: () =>
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: name,
onBarScanned: onBarCodeRead,
showFileImportButton: false,
},
requestCameraAuthorization().then(() => {
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: name,
onBarScanned: onBarCodeRead,
showFileImportButton: false,
},
});
}),
},
];

View File

@ -43,6 +43,7 @@ import { SquareButton } from '../../components/SquareButton';
import { encodeUR } from '../../blue_modules/ur';
import QRCodeComponent from '../../components/QRCodeComponent';
import alert from '../../components/Alert';
import { requestCameraAuthorization } from '../../helpers/scan-qr';
const fs = require('../../blue_modules/fs');
const prompt = require('../../helpers/prompt');
@ -436,22 +437,24 @@ const ViewEditMultisigCosigners = () => {
const scanOrOpenFile = () => {
setIsProvideMnemonicsModalVisible(false);
setTimeout(
() =>
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned: result => {
// Triggers FlatList re-render
setImportText(result);
//
_handleUseMnemonicPhrase(result);
setTimeout(() =>
requestCameraAuthorization().then(
() =>
navigate('ScanQRCodeRoot', {
screen: 'ScanQRCode',
params: {
launchedBy: route.name,
onBarScanned: result => {
// Triggers FlatList re-render
setImportText(result);
//
_handleUseMnemonicPhrase(result);
},
showFileImportButton: true,
},
showFileImportButton: true,
},
}),
650,
}),
650,
),
);
};