Skip to content

Commit

Permalink
[FEAT] Screenshot Warning (#4670)
Browse files Browse the repository at this point in the history
* Add react-native-detector

* Move styles to another file

* Move styles to another file

* (WIP) Refactor RevealPrivateCredential

* (WIP) Refactor RevealPrivateCredential

* (WIP) Refactor RevealPrivateCredential

* (WIP) Refactor RevealPrivateCredential

* (WIP) Refactor RevealPrivateCredential

* (WIP) Refactor RevealPrivateCredential

* Downgrade react-native-detector to 0.2.1

* Downgrade react-native-detector to 0.2.1

* Add alert message

* Add alert to screenshot

* Update name

* Update en.json

* Refactor component

* Add link to screenshot warning

* Add analytics

* Update testing

* Update event

* Remove linter disabler

* Update cancel method name

* Update mock

* Move screenshot warning logic to hook

* Solve biometrics bug

* Update snapshots

* Remove screenshot dependency

* Add iOS screenshot detection

* Delete custom modules

* Custom iOS screenshot detection module

* Rename custom module

* Update Podfile

* Update screenshot hook

* Add iOS specification

* Fix recordSRPRevealTimestamp undefined error

* Ignore vulns

* Update iyarc

* Add native screenshot module to QA project

* Lint

* Update copy

* Fix wrong password logic

* Fix wrong message in backup flow

* new build

* new new test build

* Improve state management in useScreenshotWarning hook

* Move style to new file

* Remove styles from component file

* Move propTypes

* Refactor ManualBackupStep2 from class to functional component

* Move methods to util file

* Update screen

* Add unit tests

* Move styles to new file

* Sort imports

* Relocate propTypes

* Refactor component from class o functional

* Fix screenshot issue in ImportFromSeed

* Add ScreenshotDeterrent component

* Refactor solution in ImportFromSeed

* Refactor solution in ManualBackupStep1

* Add ScreenshotDeterrent to ManualBackupStep2

* Lint

* Fix multiple Alerts bug

* Revert app version

* Revert project.pbxproj

* Revert project.pbxproj

* Update title

* Update version and build number

* Ignore audits

* Revert version and build numbers

* Fix translations issue

Co-authored-by: Curtis David <Curtis.David7@gmail.com>
Co-authored-by: Owen Craston <owengc12@gmail.com>
  • Loading branch information
3 people authored Dec 21, 2022
1 parent 7c56575 commit 1880962
Show file tree
Hide file tree
Showing 17 changed files with 1,048 additions and 889 deletions.
2 changes: 1 addition & 1 deletion .iyarc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# improved-yarn-audit advisory exclusions
1085140, 1085135
1085140, 1085135, 1084899, 1081848, 1084901, 1075625
64 changes: 64 additions & 0 deletions app/components/UI/ScreenshotDeterrent/ScreenshotDeterrent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React, { useState, useEffect, useCallback } from 'react';
import { View, Alert, Linking } from 'react-native';
import AnalyticsV2 from '../../../util/analyticsV2';
import useScreenshotWarning from '../../hooks/useScreenshotWarning';
import { SRP_GUIDE_URL } from '../../../constants/urls';
import { strings } from '../../../../locales/i18n';

const ScreenshotDeterrent = ({
enabled,
isSRP,
}: {
enabled: boolean;
isSRP: boolean;
}) => {
const [alertPresent, setAlertPresent] = useState<boolean>(false);

const openSRPGuide = () => {
setAlertPresent(false);
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SCREENSHOT_WARNING, {});
Linking.openURL(SRP_GUIDE_URL);
};

const showScreenshotAlert = useCallback(() => {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SCREENSHOT_WARNING, {});
setAlertPresent(true);

Alert.alert(
strings('screenshot_deterrent.title'),
strings('screenshot_deterrent.description', {
credentialName: isSRP
? strings('screenshot_deterrent.srp_text')
: strings('screenshot_deterrent.priv_key_text'),
}),
[
{
text: strings('reveal_credential.learn_more'),
onPress: openSRPGuide,
style: 'cancel',
},
{
text: strings('reveal_credential.got_it'),
onPress: () => {
setAlertPresent(false);
AnalyticsV2.trackEvent(
AnalyticsV2.ANALYTICS_EVENTS.SCREENSHOT_OK,
{},
);
},
},
],
);
}, [isSRP]);

const [enableScreenshotWarning] = useScreenshotWarning(showScreenshotAlert);

useEffect(
() => enableScreenshotWarning(enabled && !alertPresent),
[alertPresent, enableScreenshotWarning, enabled],
);

return <View />;
};

export default ScreenshotDeterrent;
4 changes: 4 additions & 0 deletions app/components/UI/ScreenshotDeterrent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ScreenshotDeterrent from './ScreenshotDeterrent';

// eslint-disable-next-line import/prefer-default-export
export { ScreenshotDeterrent };
2 changes: 2 additions & 0 deletions app/components/Views/ImportFromSeed/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import TermsAndConditions from '../TermsAndConditions';
import { getOnboardingNavbarOptions } from '../../UI/Navbar';
import StyledButton from '../../UI/StyledButton';
import { LoginOptionsSwitch } from '../../UI/LoginOptionsSwitch';
import { ScreenshotDeterrent } from '../../UI/ScreenshotDeterrent';
import {
SEED_PHRASE_HINTS,
BIOMETRY_CHOICE_DISABLED,
Expand Down Expand Up @@ -599,6 +600,7 @@ const ImportFromSeed = ({
action={strings('import_from_seed.import_button')}
/>
</View>
<ScreenshotDeterrent enabled isSRP />
</SafeAreaView>
);
};
Expand Down
Loading

0 comments on commit 1880962

Please sign in to comment.