mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-03 12:06:21 +01:00
ADD: If Camera not authorized on Desktop, show Alert.
This commit is contained in:
parent
54924e0090
commit
6c31e7d478
5 changed files with 45 additions and 7 deletions
|
@ -46,6 +46,7 @@ import { BlueCurrentTheme } from './components/themes';
|
|||
import loc, { formatBalance, formatBalanceWithoutSuffix, formatBalancePlain, removeTrailingZeros, transactionTimeToReadable } from './loc';
|
||||
import AsyncStorage from '@react-native-community/async-storage';
|
||||
import Lnurl from './class/lnurl';
|
||||
import ScanQRCode from './screen/send/ScanQRCode';
|
||||
/** @type {AppStorage} */
|
||||
const BlueApp = require('./BlueApp');
|
||||
const { height, width } = Dimensions.get('window');
|
||||
|
@ -2095,6 +2096,8 @@ export class BlueAddressInput extends Component {
|
|||
alert(loc.send.qr_error_no_qrcode);
|
||||
}
|
||||
});
|
||||
} else if (response.error) {
|
||||
ScanQRCode.presentCameraNotAuthorizedAlert(response.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
@ -2105,7 +2108,7 @@ export class BlueAddressInput extends Component {
|
|||
};
|
||||
|
||||
showActionSheet = async () => {
|
||||
const isClipboardEmpty = (await Clipboard.getString()).replace(' ', '').length === 0;
|
||||
const isClipboardEmpty = (await Clipboard.getString()).trim().length === 0;
|
||||
let copyFromClipboardIndex;
|
||||
if (Platform.OS === 'ios') {
|
||||
const options = [loc._.cancel, loc.wallets.list_long_choose, isDesktop ? loc.wallets.take_photo : loc.wallets.list_long_scan];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* global alert */
|
||||
import React, { useState } from 'react';
|
||||
import { Image, View, TouchableOpacity, StatusBar, Platform, StyleSheet, Linking } from 'react-native';
|
||||
import { Image, View, TouchableOpacity, StatusBar, Platform, StyleSheet, Linking, Alert } from 'react-native';
|
||||
import { RNCamera } from 'react-native-camera';
|
||||
import { Icon } from 'react-native-elements';
|
||||
import ImagePicker from 'react-native-image-picker';
|
||||
|
@ -9,8 +9,10 @@ import DocumentPicker from 'react-native-document-picker';
|
|||
import RNFS from 'react-native-fs';
|
||||
import loc from '../../loc';
|
||||
import { BlueLoadingHook, BlueTextHooks, BlueButtonHook, BlueSpacing40 } from '../../BlueComponents';
|
||||
import { getSystemName } from 'react-native-device-info';
|
||||
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
||||
const createHash = require('create-hash');
|
||||
const isDesktop = getSystemName() === 'Mac OS X';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
|
@ -169,10 +171,6 @@ const ScanQRCode = () => {
|
|||
setCameraStatus(event.cameraStatus);
|
||||
};
|
||||
|
||||
const handleOpenSettingsTapped = () => {
|
||||
Linking.openSettings();
|
||||
};
|
||||
|
||||
return isLoading ? (
|
||||
<View style={styles.root}>
|
||||
<BlueLoadingHook />
|
||||
|
@ -199,7 +197,7 @@ const ScanQRCode = () => {
|
|||
<View style={[styles.openSettingsContainer, stylesHook.openSettingsContainer]}>
|
||||
<BlueTextHooks>{loc.send.permission_camera_message}</BlueTextHooks>
|
||||
<BlueSpacing40 />
|
||||
<BlueButtonHook title={loc.send.open_settings} onPress={handleOpenSettingsTapped} />
|
||||
<BlueButtonHook title={loc.send.open_settings} onPress={ScanQRCode.openPrivacyDesktopSettings} />
|
||||
</View>
|
||||
)}
|
||||
<TouchableOpacity style={styles.closeTouch} onPress={dismiss}>
|
||||
|
@ -217,6 +215,34 @@ const ScanQRCode = () => {
|
|||
);
|
||||
};
|
||||
|
||||
ScanQRCode.openPrivacyDesktopSettings = () => {
|
||||
if (isDesktop) {
|
||||
Linking.openURL('x-apple.systempreferences:com.apple.preference.security?Privacy_Camera');
|
||||
} else {
|
||||
Linking.openSettings();
|
||||
}
|
||||
};
|
||||
|
||||
ScanQRCode.presentCameraNotAuthorizedAlert = error => {
|
||||
Alert.alert(
|
||||
loc.errors.error,
|
||||
error,
|
||||
[
|
||||
{
|
||||
text: loc.send.open_settings,
|
||||
onPress: ScanQRCode.openPrivacyDesktopSettings,
|
||||
style: 'default',
|
||||
},
|
||||
{
|
||||
text: loc._.ok,
|
||||
onPress: () => {},
|
||||
style: 'cancel',
|
||||
},
|
||||
],
|
||||
{ cancelable: true },
|
||||
);
|
||||
};
|
||||
|
||||
ScanQRCode.navigationOptions = {
|
||||
headerShown: false,
|
||||
};
|
||||
|
|
|
@ -36,6 +36,7 @@ import DocumentPicker from 'react-native-document-picker';
|
|||
import { decodeUR, extractSingleWorkload } from 'bc-ur/dist';
|
||||
import loc from '../../loc';
|
||||
import { BlueCurrentTheme } from '../../components/themes';
|
||||
import ScanQRCode from './ScanQRCode';
|
||||
const EV = require('../../blue_modules/events');
|
||||
const BlueElectrum = require('../../blue_modules/BlueElectrum');
|
||||
/** @type {AppStorage} */
|
||||
|
@ -356,6 +357,8 @@ export default class PsbtWithHardwareWallet extends Component {
|
|||
alert(loc.send.qr_error_no_qrcode);
|
||||
}
|
||||
});
|
||||
} else if (response.error) {
|
||||
ScanQRCode.presentCameraNotAuthorizedAlert(response.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -23,6 +23,7 @@ import loc from '../../loc';
|
|||
import { getSystemName } from 'react-native-device-info';
|
||||
import RNFS from 'react-native-fs';
|
||||
import DocumentPicker from 'react-native-document-picker';
|
||||
import ScanQRCode from '../send/ScanQRCode';
|
||||
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
||||
const { width } = Dimensions.get('window');
|
||||
const isDesktop = getSystemName() === 'Mac OS X';
|
||||
|
@ -147,6 +148,8 @@ const WalletsImport = () => {
|
|||
alert(loc.send.qr_error_no_qrcode);
|
||||
}
|
||||
});
|
||||
} else if (response.error) {
|
||||
ScanQRCode.presentCameraNotAuthorizedAlert(response.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
@ -25,6 +25,7 @@ import * as NavigationService from '../../NavigationService';
|
|||
import loc from '../../loc';
|
||||
import { BlueCurrentTheme } from '../../components/themes';
|
||||
import { getSystemName } from 'react-native-device-info';
|
||||
import ScanQRCode from '../send/ScanQRCode';
|
||||
const EV = require('../../blue_modules/events');
|
||||
const A = require('../../blue_modules/analytics');
|
||||
const BlueApp: AppStorage = require('../../BlueApp');
|
||||
|
@ -479,6 +480,8 @@ export default class WalletsList extends Component {
|
|||
alert(loc.send.qr_error_no_qrcode);
|
||||
}
|
||||
});
|
||||
} else if (response.error) {
|
||||
ScanQRCode.presentCameraNotAuthorizedAlert(response.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue