CW-352 add enable disable screenshot feature to i os (#931)

* Disable ios screen recording

* Minor Enhancements

---------

Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
Godwin Asuquo
2023-05-17 18:34:41 +03:00
committed by GitHub
co-authored by OmarHatem
parent 43e062d1ac
commit 1e868f876e
4 changed files with 40 additions and 27 deletions
+3 -2
View File
@@ -2,5 +2,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});
void setIsAppSecureNative(bool isAppSecure) {
utils.invokeMethod<Uint8List>('setIsAppSecure', {'isAppSecure': isAppSecure});
}
+29 -10
View File
@@ -15,6 +15,8 @@ import UnstoppableDomainsResolution
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
makeSecure()
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
let legacyMigrationChannel = FlutterMethodChannel(
@@ -96,22 +98,39 @@ import UnstoppableDomainsResolution
result(address)
}
case "setIsAppSecure":
guard let args = call.arguments as? Dictionary<String, Bool>,
let isAppSecure = args["isAppSecure"] else {
result(nil)
return
}
if isAppSecure {
self?.textField.isSecureTextEntry = true
} else {
self?.textField.isSecureTextEntry = false
}
result(nil)
default:
result(FlutterMethodNotImplemented)
}
})
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
private var textField = UITextField()
private func makeSecure() {
if (!self.window.subviews.contains(textField)) {
self.window.addSubview(textField)
textField.centerYAnchor.constraint(equalTo: self.window.centerYAnchor).isActive = true
textField.centerXAnchor.constraint(equalTo: self.window.centerXAnchor).isActive = true
self.window.layer.superlayer?.addSublayer(textField.layer)
textField.layer.sublayers?.first?.addSublayer(self.window.layer)
}
}
override func applicationWillResignActive(_: UIApplication ) {
self.window?.rootViewController?.view.endEditing(true)
self.window?.isHidden = true;
}
override func applicationDidBecomeActive(_: UIApplication) {
self.window?.isHidden = false;
}
}
+6 -8
View File
@@ -8,7 +8,6 @@ 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);
@@ -49,13 +48,12 @@ 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);
}),
SettingsSwitcherCell(
title: S.current.prevent_screenshots,
value: _privacySettingsViewModel.isAppSecure,
onValueChange: (BuildContext _, bool value) {
_privacySettingsViewModel.setIsAppSecure(value);
}),
SettingsSwitcherCell(
title: S.current.disable_buy,
value: _privacySettingsViewModel.disableBuy,
+2 -7
View File
@@ -23,7 +23,6 @@ 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';
@@ -136,11 +135,11 @@ abstract class SettingsStoreBase with Store {
(bool shouldSaveRecipientAddress) => sharedPreferences.setBool(
PreferencesKey.shouldSaveRecipientAddressKey, shouldSaveRecipientAddress));
setIsAppSecureNative(isAppSecure);
reaction((_) => isAppSecure, (bool isAppSecure) {
sharedPreferences.setBool(PreferencesKey.isAppSecureKey, isAppSecure);
if (Platform.isAndroid) {
setIsAppSecureNative(isAppSecure);
}
});
reaction(
@@ -153,10 +152,6 @@ abstract class SettingsStoreBase with Store {
(bool disableSell) => sharedPreferences.setBool(
PreferencesKey.disableSellKey, disableSell));
if (Platform.isAndroid) {
setIsAppSecureNative(isAppSecure);
}
reaction(
(_) => fiatApiMode,
(FiatApiMode mode) =>