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 12:59:59 +03:00 committed by GitHub
parent 7b91b0e938
commit f26815efb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 113 additions and 37 deletions

View file

@ -24,6 +24,7 @@ import java.security.SecureRandom;
public class MainActivity extends FlutterFragmentActivity {
final String UTILS_CHANNEL = "com.cake_wallet/native_utils";
final int UNSTOPPABLE_DOMAIN_MIN_VERSION_SDK = 24;
boolean isAppSecure = false;
@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
@ -56,6 +57,14 @@ public class MainActivity extends FlutterFragmentActivity {
handler.post(() -> result.success(""));
}
break;
case "setIsAppSecure":
isAppSecure = call.argument("isAppSecure");
if (isAppSecure) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
} else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
break;
default:
handler.post(() -> result.notImplemented());
}
@ -80,10 +89,4 @@ public class MainActivity extends FlutterFragmentActivity {
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
}

View file

@ -0,0 +1,6 @@
import 'package:flutter/services.dart';
const utils = const MethodChannel('com.cake_wallet/native_utils');
void setIsAppSecureNative(bool isAppSecure) =>
utils.invokeMethod<Uint8List>('setIsAppSecure', {'isAppSecure': isAppSecure});

View file

@ -115,10 +115,10 @@ packages:
dependency: transitive
description:
name: ffi
sha256: "13a6ccf6a459a125b3fcdb6ec73bd5ff90822e071207c663bfd1f70062d51d18"
sha256: a38574032c5f1dd06c4aee541789906c12ccaab8ba01446e800d9c5b79c4a978
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "2.0.1"
file:
dependency: transitive
description:
@ -277,10 +277,10 @@ packages:
dependency: transitive
description:
name: path_provider_windows
sha256: a34ecd7fb548f8e57321fd8e50d865d266941b54e6c3b7758cf8f37c24116905
sha256: f53720498d5a543f9607db4b0e997c4b5438884de25b0f73098cc2671a51b130
url: "https://pub.dev"
source: hosted
version: "2.0.7"
version: "2.1.5"
platform:
dependency: transitive
description:
@ -386,10 +386,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: c0e3a4f7be7dae51d8f152230b86627e3397c1ba8c3fa58e63d44a9f3edc9cef
sha256: a6f0236dbda0f63aa9a25ad1ff9a9d8a4eaaa5012da0dc59d21afdb1dc361ca4
url: "https://pub.dev"
source: hosted
version: "2.6.1"
version: "3.1.4"
xdg_directories:
dependency: transitive
description:
@ -399,5 +399,5 @@ packages:
source: hosted
version: "0.2.0+3"
sdks:
dart: ">=2.18.1 <3.0.0"
dart: ">=2.18.1 <4.0.0"
flutter: ">=3.0.0"

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,

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';

View file

@ -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);
}),
],
);
}),

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);
@ -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;

View file

@ -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;
}

View file

@ -699,5 +699,6 @@
"sell_monero_com_alert_content": "بيع Monero غير مدعوم حتى الآن",
"error_text_input_below_minimum_limit":" المبلغ أقل من الحد الأدنى",
"error_text_input_above_maximum_limit":"المبلغ أكبر من الحد الأقصى",
"show_market_place": "إظهار السوق"
"show_market_place": "إظهار السوق",
"prevent_screenshots": "منع لقطات الشاشة وتسجيل الشاشة"
}

View file

@ -700,5 +700,6 @@
"sell_monero_com_alert_content": "Продажбата на Monero все още не се поддържа",
"error_text_input_below_minimum_limit" : "Сумата е по-малко от минималната",
"error_text_input_above_maximum_limit" : "Сумата надвишава максималната",
"show_market_place":"Покажи пазар"
"show_market_place":"Покажи пазар",
"prevent_screenshots": "Предотвратете екранни снимки и запис на екрана"
}

View file

@ -700,5 +700,6 @@
"sell_monero_com_alert_content": "Prodej Monero zatím není podporován",
"error_text_input_below_minimum_limit" : "Částka je menší než minimální hodnota",
"error_text_input_above_maximum_limit" : "Částka je větší než maximální hodnota",
"show_market_place": "Zobrazit trh"
"show_market_place": "Zobrazit trh",
"prevent_screenshots": "Zabránit vytváření snímků obrazovky a nahrávání obrazovky"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Der Verkauf von Monero wird noch nicht unterstützt",
"error_text_input_below_minimum_limit" : "Menge ist unter dem Minimum",
"error_text_input_above_maximum_limit" : "Menge ist über dem Maximum",
"show_market_place": "Marktplatz anzeigen"
"show_market_place": "Marktplatz anzeigen",
"prevent_screenshots": "Verhindern Sie Screenshots und Bildschirmaufzeichnungen"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Selling Monero is not supported yet",
"error_text_input_below_minimum_limit" : "Amount is less than the minimum",
"error_text_input_above_maximum_limit" : "Amount is more than the maximum",
"show_market_place" :"Show Marketplace"
"show_market_place" :"Show Marketplace",
"prevent_screenshots": "Prevent screenshots and screen recording"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Aún no se admite la venta de Monero",
"error_text_input_below_minimum_limit" : "La cantidad es menos que mínima",
"error_text_input_above_maximum_limit" : "La cantidad es más que el máximo",
"show_market_place": "Mostrar mercado"
"show_market_place": "Mostrar mercado",
"prevent_screenshots": "Evitar capturas de pantalla y grabación de pantalla"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "La vente de Monero n'est pas encore prise en charge",
"error_text_input_below_minimum_limit" : "Le montant est inférieur au minimum",
"error_text_input_above_maximum_limit" : "Le montant est supérieur au maximum",
"show_market_place" :"Afficher la place de marché"
"show_market_place" :"Afficher la place de marché",
"prevent_screenshots": "Empêcher les captures d'écran et l'enregistrement d'écran"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "मोनेरो बेचना अभी तक समर्थित नहीं है",
"error_text_input_below_minimum_limit" : "राशि न्यूनतम से कम है",
"error_text_input_above_maximum_limit" : "राशि अधिकतम से अधिक है",
"show_market_place":"बाज़ार दिखाएँ"
"show_market_place":"बाज़ार दिखाएँ",
"prevent_screenshots": "स्क्रीनशॉट और स्क्रीन रिकॉर्डिंग रोकें"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Prodaja Monera još nije podržana",
"error_text_input_below_minimum_limit" : "Iznos je manji od minimalnog",
"error_text_input_above_maximum_limit" : "Iznos je veći od maskimalnog",
"show_market_place" : "Prikaži tržište"
"show_market_place" : "Prikaži tržište",
"prevent_screenshots": "Spriječite snimke zaslona i snimanje zaslona"
}

View file

@ -682,5 +682,6 @@
"sell_monero_com_alert_content": "Menjual Monero belum didukung",
"error_text_input_below_minimum_limit" : "Jumlah kurang dari minimal",
"error_text_input_above_maximum_limit" : "Jumlah lebih dari maksimal",
"show_market_place": "Tampilkan Pasar"
"show_market_place": "Tampilkan Pasar",
"prevent_screenshots": "Cegah tangkapan layar dan perekaman layar"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "La vendita di Monero non è ancora supportata",
"error_text_input_below_minimum_limit" : "L'ammontare è inferiore al minimo",
"error_text_input_above_maximum_limit" : "L'ammontare è superiore al massimo",
"show_market_place":"Mostra mercato"
"show_market_place":"Mostra mercato",
"prevent_screenshots": "Impedisci screenshot e registrazione dello schermo"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "モネロの販売はまだサポートされていません",
"error_text_input_below_minimum_limit" : "金額は最小額より少ない",
"error_text_input_above_maximum_limit" : "金額は最大値を超えています",
"show_market_place":"マーケットプレイスを表示"
"show_market_place":"マーケットプレイスを表示",
"prevent_screenshots": "スクリーンショットと画面録画を防止する"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "지원되지 않습니다.",
"error_text_input_below_minimum_limit" : "금액이 최소보다 적습니다.",
"error_text_input_above_maximum_limit" : "금액이 최대 값보다 많습니다.",
"show_market_place":"마켓플레이스 표시"
"show_market_place":"마켓플레이스 표시",
"prevent_screenshots": "스크린샷 및 화면 녹화 방지"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Monero ရောင်းချခြင်းကို မပံ့ပိုးရသေးပါ။",
"error_text_input_below_minimum_limit" : "ပမာဏသည် အနိမ့်ဆုံးထက်နည်းသည်။",
"error_text_input_above_maximum_limit" : "ပမာဏသည် အများဆုံးထက် ပိုများသည်။",
"show_market_place":"စျေးကွက်ကိုပြသပါ။"
"show_market_place":"စျေးကွက်ကိုပြသပါ။",
"prevent_screenshots": "ဖန်သားပြင်ဓာတ်ပုံများနှင့် မျက်နှာပြင်ရိုက်ကူးခြင်းကို တားဆီးပါ။"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Het verkopen van Monero wordt nog niet ondersteund",
"error_text_input_below_minimum_limit" : "Bedrag is minder dan minimaal",
"error_text_input_above_maximum_limit" : "Bedrag is meer dan maximaal",
"show_market_place":"Toon Marktplaats"
"show_market_place":"Toon Marktplaats",
"prevent_screenshots": "Voorkom screenshots en schermopname"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Sprzedaż Monero nie jest jeszcze obsługiwana",
"error_text_input_below_minimum_limit" : "Kwota jest mniejsza niż minimalna",
"error_text_input_above_maximum_limit" : "Kwota jest większa niż maksymalna",
"show_market_place" : "Pokaż rynek"
"show_market_place" : "Pokaż rynek",
"prevent_screenshots": "Zapobiegaj zrzutom ekranu i nagrywaniu ekranu"
}

View file

@ -700,5 +700,6 @@
"sell_monero_com_alert_content": "A venda de Monero ainda não é suportada",
"error_text_input_below_minimum_limit" : "O valor é menor que o mínimo",
"error_text_input_above_maximum_limit" : "O valor é superior ao máximo",
"show_market_place":"Mostrar mercado"
"show_market_place":"Mostrar mercado",
"prevent_screenshots": "Evite capturas de tela e gravação de tela"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Продажа Monero пока не поддерживается",
"error_text_input_below_minimum_limit" : "Сумма меньше минимальной",
"error_text_input_above_maximum_limit" : "Сумма больше максимальной",
"show_market_place":"Показать торговую площадку"
"show_market_place":"Показать торговую площадку",
"prevent_screenshots": "Предотвратить скриншоты и запись экрана"
}

View file

@ -699,5 +699,6 @@
"sell_monero_com_alert_content": "ยังไม่รองรับการขาย Monero",
"error_text_input_below_minimum_limit" : "จำนวนเงินน้อยกว่าขั้นต่ำ",
"error_text_input_above_maximum_limit" : "จำนวนเงินสูงกว่าค่าสูงสุด",
"show_market_place":"แสดงตลาดกลาง"
"show_market_place":"แสดงตลาดกลาง",
"prevent_screenshots": "ป้องกันภาพหน้าจอและการบันทึกหน้าจอ"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Monero satışı henüz desteklenmiyor",
"error_text_input_below_minimum_limit" : "Miktar minimumdan daha azdır",
"error_text_input_above_maximum_limit" : "Miktar maksimumdan daha fazla",
"show_market_place":"Pazar Yerini Göster"
"show_market_place":"Pazar Yerini Göster",
"prevent_screenshots": "Ekran görüntülerini ve ekran kaydını önleyin"
}

View file

@ -700,5 +700,6 @@
"sell_monero_com_alert_content": "Продаж Monero ще не підтримується",
"error_text_input_below_minimum_limit" : "Сума менша мінімальної",
"error_text_input_above_maximum_limit" : "Сума більше максимальної",
"show_market_place":"Шоу Ринок"
"show_market_place":"Відображати маркетплейс",
"prevent_screenshots": "Запобігати знімкам екрана та запису екрана"
}

View file

@ -701,5 +701,6 @@
"sell_monero_com_alert_content": "Monero فروخت کرنا ابھی تک تعاون یافتہ نہیں ہے۔",
"error_text_input_below_minimum_limit" : "رقم کم از کم سے کم ہے۔",
"error_text_input_above_maximum_limit" : "رقم زیادہ سے زیادہ سے زیادہ ہے۔",
"show_market_place":"بازار دکھائیں۔"
"show_market_place":"بازار دکھائیں۔",
"prevent_screenshots": "اسکرین شاٹس اور اسکرین ریکارڈنگ کو روکیں۔"
}

View file

@ -700,5 +700,6 @@
"sell_monero_com_alert_content": "尚不支持出售门罗币",
"error_text_input_below_minimum_limit" : "金额小于最小值",
"error_text_input_above_maximum_limit" : "金额大于最大值",
"show_market_place" :"显示市场"
"show_market_place" :"显示市场",
"prevent_screenshots": "防止截屏和录屏"
}