This commit is contained in:
Marcos Rodriguez Velez 2024-02-21 21:38:31 -04:00
parent bc7cd329b7
commit fff04479a9
No known key found for this signature in database
GPG key ID: 6030B2F48CCE86D7
7 changed files with 63 additions and 113 deletions

View file

@ -1,35 +0,0 @@
import { useContext, useEffect, useCallback } from 'react';
// @ts-ignore: react-native-obscure is not in the type definition
import Obscure from 'react-native-obscure';
import { BlueStorageContext } from '../blue_modules/storage-context';
export const usePrivacy = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
const enableBlur = useCallback(() => {
if (!isPrivacyBlurEnabled) return;
Obscure.activateObscure();
}, [isPrivacyBlurEnabled]);
const disableBlur = useCallback(() => {
Obscure.deactivateObscure();
}, []); // This doesn't depend on the isPrivacyBlurEnabled value
useEffect(() => {
// Automatically activate or deactivate on mount and when isPrivacyBlurEnabled changes
if (isPrivacyBlurEnabled) {
enableBlur();
} else {
disableBlur();
}
// Cleanup function to deactivate obscure when the component unmounts
return () => {
disableBlur();
};
}, [isPrivacyBlurEnabled, enableBlur, disableBlur]);
return { enableBlur, disableBlur };
};
export default usePrivacy;

View file

@ -1,35 +0,0 @@
import { useContext, useEffect, useCallback } from 'react';
// @ts-ignore: react-native-obscure is not in the type definition
import { enabled } from 'react-native-privacy-snapshot';
import { BlueStorageContext } from '../blue_modules/storage-context';
export const usePrivacy = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
const enableBlur = useCallback(() => {
if (!isPrivacyBlurEnabled) return;
enabled(true);
}, [isPrivacyBlurEnabled]);
const disableBlur = useCallback(() => {
enabled(false);
}, []); // This doesn't depend on the isPrivacyBlurEnabled value
useEffect(() => {
// Automatically activate or deactivate on mount and when isPrivacyBlurEnabled changes
if (isPrivacyBlurEnabled) {
enableBlur();
} else {
disableBlur();
}
// Cleanup function to deactivate obscure when the component unmounts
return () => {
disableBlur();
};
}, [isPrivacyBlurEnabled, enableBlur, disableBlur]);
return { enableBlur, disableBlur };
};
export default usePrivacy;

View file

@ -1,7 +1,42 @@
export const usePrivacy = () => {
const enableBlur = () => {};
import { useContext, useEffect } from 'react';
// @ts-ignore: Package is not in the type definition
import { enableSecureView, disableSecureView, forbidAndroidShare, allowAndroidShare } from 'react-native-prevent-screenshot-ios-android';
import { BlueStorageContext } from '../blue_modules/storage-context';
import { Platform } from 'react-native';
const disableBlur = () => {};
export const usePrivacy = () => {
const { isPrivacyBlurEnabled } = useContext(BlueStorageContext);
const enableBlur = () => {
if (!isPrivacyBlurEnabled) return;
if (Platform.OS === 'android') {
forbidAndroidShare();
} else if (Platform.OS === 'ios') {
enableSecureView();
}
};
const disableBlur = () => {
if (Platform.OS === 'android') {
allowAndroidShare();
} else if (Platform.OS === 'ios') {
disableSecureView();
}
};
useEffect(() => {
// Automatically activate or deactivate on mount and when isPrivacyBlurEnabled changes
if (isPrivacyBlurEnabled) {
enableBlur();
} else {
disableBlur();
}
return () => {
disableBlur();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return { enableBlur, disableBlur };
};

View file

@ -91,7 +91,7 @@
B4AB225E2B02AD12001F4328 /* XMLParserDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4AB225C2B02AD12001F4328 /* XMLParserDelegate.swift */; };
B4EE583C226703320003363C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B40D4E35225841ED00428FCC /* Assets.xcassets */; };
C59F90CE0D04D3E4BB39BC5D /* libPods-BlueWalletUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F02C2F7CA3591E4E0B06EBA /* libPods-BlueWalletUITests.a */; };
C978A716948AB7DEC5B6F677 /* (null) in Frameworks */ = {isa = PBXBuildFile; };
C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
E5D4794B26781FC0007838C1 /* fiatUnits.json in Resources */ = {isa = PBXBuildFile; fileRef = 6DD410AD266CAF1F0087DE03 /* fiatUnits.json */; };
E5D4794C26781FC1007838C1 /* fiatUnits.json in Resources */ = {isa = PBXBuildFile; fileRef = 6DD410AD266CAF1F0087DE03 /* fiatUnits.json */; };
/* End PBXBuildFile section */
@ -399,7 +399,7 @@
files = (
782F075B5DD048449E2DECE9 /* libz.tbd in Frameworks */,
764B49B1420D4AEB8109BF62 /* libsqlite3.0.tbd in Frameworks */,
C978A716948AB7DEC5B6F677 /* (null) in Frameworks */,
C978A716948AB7DEC5B6F677 /* BuildFile in Frameworks */,
773E382FE62E836172AAB98B /* libPods-BlueWallet.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -1024,7 +1024,7 @@
);
mainGroup = 83CBB9F61A601CBA00E9B192;
packageReferences = (
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */,
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */,
B41B76832B66B2FF002C48D5 /* XCRemoteSwiftPackageReference "bugsnag-cocoa" */,
);
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
@ -2518,7 +2518,7 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */ = {
6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/EFPrefix/EFQRCode.git";
requirement = {
@ -2539,7 +2539,7 @@
/* Begin XCSwiftPackageProductDependency section */
6DFC806F24EA0B6C007B8700 /* EFQRCode */ = {
isa = XCSwiftPackageProductDependency;
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode" */;
package = 6DFC806E24EA0B6C007B8700 /* XCRemoteSwiftPackageReference "EFQRCode.git" */;
productName = EFQRCode;
};
B41B76842B66B2FF002C48D5 /* Bugsnag */ = {

View file

@ -341,6 +341,9 @@ PODS:
- React-Core
- react-native-ios-context-menu (1.15.3):
- React-Core
- react-native-prevent-screenshot-ios-android (1.1.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- react-native-qrcode-local-image (1.0.4):
- React
- react-native-randombytes (3.6.1):
@ -496,8 +499,6 @@ PODS:
- React-Core
- RNPermissions (4.1.2):
- React-Core
- RNPrivacySnapshot (1.0.0):
- React
- RNQuickAction (0.3.13):
- React
- RNRate (1.2.12):
@ -559,6 +560,7 @@ DEPENDENCIES:
- react-native-idle-timer (from `../node_modules/react-native-idle-timer`)
- react-native-image-picker (from `../node_modules/react-native-image-picker`)
- react-native-ios-context-menu (from `../node_modules/react-native-ios-context-menu`)
- react-native-prevent-screenshot-ios-android (from `../node_modules/react-native-prevent-screenshot-ios-android`)
- "react-native-qrcode-local-image (from `../node_modules/@remobile/react-native-qrcode-local-image`)"
- react-native-randombytes (from `../node_modules/react-native-randombytes`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
@ -597,7 +599,6 @@ DEPENDENCIES:
- 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`)
- RNReactNativeHapticFeedback (from `../node_modules/react-native-haptic-feedback`)
@ -682,6 +683,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-image-picker"
react-native-ios-context-menu:
:path: "../node_modules/react-native-ios-context-menu"
react-native-prevent-screenshot-ios-android:
:path: "../node_modules/react-native-prevent-screenshot-ios-android"
react-native-qrcode-local-image:
:path: "../node_modules/@remobile/react-native-qrcode-local-image"
react-native-randombytes:
@ -758,8 +761,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-localize"
RNPermissions:
:path: "../node_modules/react-native-permissions"
RNPrivacySnapshot:
:path: "../node_modules/react-native-privacy-snapshot"
RNQuickAction:
:path: "../node_modules/react-native-quick-actions"
RNRate:
@ -818,6 +819,7 @@ SPEC CHECKSUMS:
react-native-idle-timer: f7f651542b39dce9b9473e4578cb64a255075f17
react-native-image-picker: 5e076db26cd81660cfb6db5bcf517cfa12054d45
react-native-ios-context-menu: e529171ba760a1af7f2ef0729f5a7f4d226171c5
react-native-prevent-screenshot-ios-android: 8141287c970cb037d86783841fa2eb36d59ad9f9
react-native-qrcode-local-image: 35ccb306e4265bc5545f813e54cc830b5d75bcfc
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-safe-area-context: b97eb6f9e3b7f437806c2ce5983f479f8eb5de4b
@ -856,7 +858,6 @@ SPEC CHECKSUMS:
RNKeychain: f1b48665a4646f61191eb048c4c05c58d9a7596f
RNLocalize: 4222a3756cdbe2dc9a5bdf445765a4d2572107cb
RNPermissions: 0e72b28a9df5e3f0ae9cc122378d4b878ccb4f2f
RNPrivacySnapshot: 71919dde3c6a29dd332115409c2aec564afee8f4
RNQuickAction: 6d404a869dc872cde841ad3147416a670d13fa93
RNRate: ef3bcff84f39bb1d1e41c5593d3eea4aab2bd73a
RNReactNativeHapticFeedback: ec56a5f81c3941206fd85625fa669ffc7b4545f9

39
package-lock.json generated
View file

@ -79,10 +79,9 @@
"react-native-linear-gradient": "2.8.3",
"react-native-localize": "3.0.6",
"react-native-modal": "13.0.1",
"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": "4.1.2",
"react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783",
"react-native-prevent-screenshot-ios-android": "github:BlueWallet/react-native-prevent-screenshot-ios-android",
"react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376",
"react-native-push-notification": "8.1.1",
"react-native-qrcode-svg": "6.2.0",
@ -19777,16 +19776,6 @@
"react-native": ">=0.65.0"
}
},
"node_modules/react-native-obscure": {
"name": "@talaikis/react-native-obscure",
"version": "0.0.3",
"resolved": "git+ssh://git@github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb",
"integrity": "sha512-bmzbnlXII8hW7steqwouzQW9cJ+mdA8HJ8pWkb0KD60jC5dYgJ0e66wgUiSTDNFPrvlEKriE4eEanoJFj7Q9pg==",
"license": "MIT",
"peerDependencies": {
"react-native": "^0.60.5"
}
},
"node_modules/react-native-passcode-auth": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/BlueWallet/react-native-passcode-auth.git#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
@ -19808,14 +19797,16 @@
}
}
},
"node_modules/react-native-privacy-snapshot": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/BlueWallet/react-native-privacy-snapshot.git#529e4627d93f67752a27e82a040ff7b64dca0783",
"integrity": "sha512-bO73UmkI0KpAzk3766z77qBdArwOaBCr58q5H0qDfn0jf5HonYoEkJRDRwHr7SpDxrSu2Nuoz2AokxLyb3/KXw==",
"node_modules/react-native-prevent-screenshot-ios-android": {
"version": "1.1.0",
"resolved": "git+ssh://git@github.com/BlueWallet/react-native-prevent-screenshot-ios-android.git#7f8ad1070aa231ffa075ad76a5552fa348e06d44",
"license": "MIT",
"engines": {
"node": ">= 16.0.0"
},
"peerDependencies": {
"react": "^16.13.1",
"react-native": "^0.62.0"
"react": "*",
"react-native": "*"
}
},
"node_modules/react-native-prompt-android": {
@ -37546,11 +37537,6 @@
"react-native-animatable": "1.3.3"
}
},
"react-native-obscure": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb",
"integrity": "sha512-bmzbnlXII8hW7steqwouzQW9cJ+mdA8HJ8pWkb0KD60jC5dYgJ0e66wgUiSTDNFPrvlEKriE4eEanoJFj7Q9pg==",
"from": "react-native-obscure@https://github.com/BlueWallet/react-native-obscure.git#f4b83b4a261e39b1f5ed4a45ac5bcabc8a59eadb"
},
"react-native-passcode-auth": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-passcode-auth.git#a2ff977ba92b36f8d0a5567f59c05cc608e8bd12",
"integrity": "sha512-8FL4NDMZZVrbHr1f4555dV+GY3PLpmSbJ1wIbdW1r6zSaFe59g9ns4sdLliisjO+RvyDJP7UDPDaeu+2iJ26Bg==",
@ -37561,10 +37547,9 @@
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-4.1.2.tgz",
"integrity": "sha512-dduzHcjYp1o52M8OLYhygQbGb/UnQLD3Gqhu+5cZz6MyWAb/4DQp5yYwKu6a2lY9Cz0QgbRd1Ejkmqn01cQqEg=="
},
"react-native-privacy-snapshot": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-privacy-snapshot.git#529e4627d93f67752a27e82a040ff7b64dca0783",
"integrity": "sha512-bO73UmkI0KpAzk3766z77qBdArwOaBCr58q5H0qDfn0jf5HonYoEkJRDRwHr7SpDxrSu2Nuoz2AokxLyb3/KXw==",
"from": "react-native-privacy-snapshot@https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783"
"react-native-prevent-screenshot-ios-android": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-prevent-screenshot-ios-android.git#7f8ad1070aa231ffa075ad76a5552fa348e06d44",
"from": "react-native-prevent-screenshot-ios-android@github:BlueWallet/react-native-prevent-screenshot-ios-android"
},
"react-native-prompt-android": {
"version": "git+ssh://git@github.com/BlueWallet/react-native-prompt-android.git#ed168d66fed556bc2ed07cf498770f058b78a376",

View file

@ -165,10 +165,9 @@
"react-native-linear-gradient": "2.8.3",
"react-native-localize": "3.0.6",
"react-native-modal": "13.0.1",
"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": "4.1.2",
"react-native-privacy-snapshot": "https://github.com/BlueWallet/react-native-privacy-snapshot#529e4627d93f67752a27e82a040ff7b64dca0783",
"react-native-prevent-screenshot-ios-android": "github:BlueWallet/react-native-prevent-screenshot-ios-android",
"react-native-prompt-android": "https://github.com/BlueWallet/react-native-prompt-android#ed168d66fed556bc2ed07cf498770f058b78a376",
"react-native-push-notification": "8.1.1",
"react-native-qrcode-svg": "6.2.0",