CW-351-Add-option-in-Privacy-settings-to-enable-disable-screenshots (#885)

* add prevent screenshots option

* fix prevent screen recording

* update localization

* Update strings_ja.arb
This commit is contained in:
Serhii
2023-04-20 11:59:59 +02:00
committed by GitHub
parent 7b91b0e938
commit f26815efb8
31 changed files with 113 additions and 37 deletions
+6
View File
@@ -209,6 +209,7 @@ class BackupService {
final currentBalanceDisplayMode = data[PreferencesKey.currentBalanceDisplayModeKey] as int?;
final currentFiatCurrency = data[PreferencesKey.currentFiatCurrencyKey] as String?;
final shouldSaveRecipientAddress = data[PreferencesKey.shouldSaveRecipientAddressKey] as bool?;
final isAppSecure = data[PreferencesKey.isAppSecureKey] as bool?;
final currentTransactionPriorityKeyLegacy = data[PreferencesKey.currentTransactionPriorityKeyLegacy] as int?;
final allowBiometricalAuthentication = data[PreferencesKey.allowBiometricalAuthenticationKey] as bool?;
final currentBitcoinElectrumSererId = data[PreferencesKey.currentBitcoinElectrumSererIdKey] as int?;
@@ -245,6 +246,11 @@ class BackupService {
PreferencesKey.shouldSaveRecipientAddressKey,
shouldSaveRecipientAddress);
if (isAppSecure != null)
await _sharedPreferences.setBool(
PreferencesKey.isAppSecureKey,
isAppSecure);
if (currentTransactionPriorityKeyLegacy != null)
await _sharedPreferences.setInt(
PreferencesKey.currentTransactionPriorityKeyLegacy,
+1
View File
@@ -9,6 +9,7 @@ class PreferencesKey {
static const currentTransactionPriorityKeyLegacy = 'current_fee_priority';
static const currentBalanceDisplayModeKey = 'current_balance_display_mode';
static const shouldSaveRecipientAddressKey = 'save_recipient_address';
static const isAppSecureKey = 'is_app_secure';
static const currentFiatApiModeKey = 'current_fiat_api_mode';
static const allowBiometricalAuthenticationKey =
'allow_biometrical_authentication';
@@ -8,6 +8,7 @@ import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
import 'package:cake_wallet/view_model/settings/privacy_settings_view_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'dart:io' show Platform;
class PrivacyPage extends BasePage {
PrivacyPage(this._privacySettingsViewModel);
@@ -48,6 +49,13 @@ class PrivacyPage extends BasePage {
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setShouldSaveRecipientAddress(value);
}),
if (Platform.isAndroid)
SettingsSwitcherCell(
title: S.current.prevent_screenshots,
value: _privacySettingsViewModel.isAppSecure,
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setIsAppSecure(value);
}),
],
);
}),
+24 -1
View File
@@ -19,6 +19,8 @@ import 'package:cw_core/node.dart';
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/entities/action_list_display_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cw_core/set_app_secure_native.dart';
import 'dart:io' show Platform;
part 'settings_store.g.dart';
@@ -31,6 +33,7 @@ abstract class SettingsStoreBase with Store {
required FiatCurrency initialFiatCurrency,
required BalanceDisplayMode initialBalanceDisplayMode,
required bool initialSaveRecipientAddress,
required bool initialAppSecure,
required FiatApiMode initialFiatMode,
required bool initialAllowBiometricalAuthentication,
required ExchangeApiMode initialExchangeStatus,
@@ -53,6 +56,7 @@ abstract class SettingsStoreBase with Store {
fiatCurrency = initialFiatCurrency,
balanceDisplayMode = initialBalanceDisplayMode,
shouldSaveRecipientAddress = initialSaveRecipientAddress,
isAppSecure = initialAppSecure,
fiatApiMode = initialFiatMode,
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
shouldShowMarketPlaceInDashboard = initialShouldShowMarketPlaceInDashboard,
@@ -119,6 +123,17 @@ abstract class SettingsStoreBase with Store {
PreferencesKey.shouldSaveRecipientAddressKey,
shouldSaveRecipientAddress));
reaction((_) => isAppSecure, (bool isAppSecure) {
sharedPreferences.setBool(PreferencesKey.isAppSecureKey, isAppSecure);
if (Platform.isAndroid) {
setIsAppSecureNative(isAppSecure);
}
});
if (Platform.isAndroid) {
setIsAppSecureNative(isAppSecure);
}
reaction(
(_) => fiatApiMode,
(FiatApiMode mode) => sharedPreferences.setInt(
@@ -199,6 +214,9 @@ abstract class SettingsStoreBase with Store {
@observable
bool shouldSaveRecipientAddress;
@observable
bool isAppSecure;
@observable
bool allowBiometricalAuthentication;
@@ -289,6 +307,8 @@ abstract class SettingsStoreBase with Store {
// FIX-ME: Check for which default value we should have here
final shouldSaveRecipientAddress =
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? false;
final isAppSecure =
sharedPreferences.getBool(PreferencesKey.isAppSecureKey) ?? false;
final currentFiatApiMode = FiatApiMode.deserialize(
raw: sharedPreferences
.getInt(PreferencesKey.currentFiatApiModeKey) ?? FiatApiMode.enabled.raw);
@@ -316,7 +336,7 @@ abstract class SettingsStoreBase with Store {
final pinCodeTimeOutDuration = timeOutDuration != null
? PinCodeRequiredDuration.deserialize(raw: timeOutDuration)
: defaultPinCodeTimeOutDuration;
// If no value
if (pinLength == null || pinLength == 0) {
pinLength = defaultPinLength;
@@ -367,6 +387,7 @@ abstract class SettingsStoreBase with Store {
initialFiatCurrency: currentFiatCurrency,
initialBalanceDisplayMode: currentBalanceDisplayMode,
initialSaveRecipientAddress: shouldSaveRecipientAddress,
initialAppSecure: isAppSecure,
initialFiatMode: currentFiatApiMode,
initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
initialExchangeStatus: exchangeStatus,
@@ -412,6 +433,8 @@ abstract class SettingsStoreBase with Store {
.getInt(PreferencesKey.currentBalanceDisplayModeKey)!);
shouldSaveRecipientAddress =
sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey) ?? shouldSaveRecipientAddress;
isAppSecure =
sharedPreferences.getBool(PreferencesKey.isAppSecureKey) ?? isAppSecure;
allowBiometricalAuthentication = sharedPreferences
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
allowBiometricalAuthentication;
@@ -21,6 +21,9 @@ abstract class PrivacySettingsViewModelBase with Store {
@computed
FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
@computed
bool get isAppSecure => _settingsStore.isAppSecure;
@action
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
@@ -30,4 +33,7 @@ abstract class PrivacySettingsViewModelBase with Store {
@action
void setFiatMode(FiatApiMode fiatApiMode) => _settingsStore.fiatApiMode = fiatApiMode;
@action
void setIsAppSecure(bool value) => _settingsStore.isAppSecure = value;
}