Merge pull request #6258 from BlueWallet/biounknown

ADD: Re-enable biometrics to unlock
This commit is contained in:
GLaDOS 2024-03-13 21:28:32 +00:00 committed by GitHub
commit 3160ffa39f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 9 deletions

View File

@ -66,7 +66,7 @@ import PsbtMultisigQRCode from './screen/send/psbtMultisigQRCode';
import PsbtWithHardwareWallet from './screen/send/psbtWithHardwareWallet';
import Success from './screen/send/success';
import UnlockWith from './UnlockWith';
import UnlockWith from './screen/UnlockWith';
import { isDesktop, isHandset, isTablet } from './blue_modules/environment';
import navigationStyle from './components/navigationStyle';
import { useTheme } from './components/themes';

View File

@ -230,6 +230,7 @@
"about_sm_twitter": "Follow us on Twitter",
"advanced_options": "Advanced Options",
"biometrics": "Biometrics",
"biometrics_no_longer_available": "Your device settings have changed and no longer match the selected security settings in the app. Please re-enable biometrics or passcode, then restart the app to apply these changes.",
"biom_10times": "You have attempted to enter your password 10 times. Would you like to reset your storage? This will remove all wallets and decrypt your storage.",
"biom_conf_identity": "Please confirm your identity.",
"biom_no_passcode": "Your device does not have a passcode. In order to proceed, please configure a passcode in the Settings app.",

View File

@ -1,15 +1,18 @@
import React, { useCallback, useContext, useEffect, useReducer, useRef } from 'react';
import { View, Image, TouchableOpacity, ActivityIndicator, useColorScheme, NativeModules, StyleSheet } from 'react-native';
import { Icon } from 'react-native-elements';
import Biometric, { BiometricType } from './class/biometrics';
import { BlueStorageContext } from './blue_modules/storage-context';
import triggerHapticFeedback, { HapticFeedbackTypes } from './blue_modules/hapticFeedback';
import SafeArea from './components/SafeArea';
import Biometric, { BiometricType } from '../class/biometrics';
import { BlueStorageContext } from '../blue_modules/storage-context';
import triggerHapticFeedback, { HapticFeedbackTypes } from '../blue_modules/hapticFeedback';
import SafeArea from '../components/SafeArea';
import { BlueTextCentered } from '../BlueComponents';
import loc from '../loc';
enum AuthType {
Encrypted,
Biometrics,
None,
BiometricsUnavailable,
}
type State = {
@ -95,6 +98,7 @@ const UnlockWith: React.FC = () => {
const storageIsEncrypted = await isStorageEncrypted();
const isBiometricUseCapableAndEnabled = await Biometric.isBiometricUseCapableAndEnabled();
const biometricType = isBiometricUseCapableAndEnabled ? await Biometric.biometricType() : undefined;
const biometricsUseEnabled = await Biometric.isBiometricUseEnabled();
if (storageIsEncrypted) {
dispatch({ type: SET_AUTH, payload: { type: AuthType.Encrypted, detail: undefined } });
@ -102,6 +106,8 @@ const UnlockWith: React.FC = () => {
} else if (isBiometricUseCapableAndEnabled) {
dispatch({ type: SET_AUTH, payload: { type: AuthType.Biometrics, detail: biometricType } });
unlockWithBiometrics();
} else if (biometricsUseEnabled && biometricType === undefined) {
dispatch({ type: SET_AUTH, payload: { type: AuthType.BiometricsUnavailable, detail: undefined } });
} else {
dispatch({ type: SET_AUTH, payload: { type: AuthType.None, detail: undefined } });
unlockWithKey();
@ -129,7 +135,7 @@ const UnlockWith: React.FC = () => {
return (
<TouchableOpacity accessibilityRole="button" disabled={state.isAuthenticating} onPress={unlockWithBiometrics}>
<Image
source={colorScheme === 'dark' ? require('./img/faceid-default.png') : require('./img/faceid-dark.png')}
source={colorScheme === 'dark' ? require('../img/faceid-default.png') : require('../img/faceid-dark.png')}
style={styles.icon}
/>
</TouchableOpacity>
@ -142,6 +148,8 @@ const UnlockWith: React.FC = () => {
<Icon name="lock" size={64} type="font-awesome5" color={color} />
</TouchableOpacity>
);
case AuthType.BiometricsUnavailable:
return <BlueTextCentered>{loc.settings.biometrics_no_longer_available}</BlueTextCentered>;
default:
return null;
}
@ -151,7 +159,7 @@ const UnlockWith: React.FC = () => {
return (
<SafeArea style={styles.root}>
<View style={styles.container}>
<Image source={require('./img/icon.png')} style={styles.logoImage} resizeMode="contain" />
<Image source={require('../img/icon.png')} style={styles.logoImage} resizeMode="contain" />
</View>
<View style={styles.biometricRow}>{renderUnlockOptions()}</View>
</SafeArea>
@ -171,10 +179,11 @@ const styles = StyleSheet.create({
biometricRow: {
justifyContent: 'center',
flexDirection: 'row',
width: 64,
height: 64,
minWidth: 64,
minHeight: 64,
alignSelf: 'center',
marginBottom: 20,
paddingHorizontal: 20,
},
icon: {
width: 64,