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>
Godwin Asuquo committed
May 17, 2023 at 18:34 UTC
1e868f876e9eed4feea3f49545e0bece5a2e0409
4 files changed
+40
-27
cw_core/lib/set_app_secure_native.dart
+3
-2
@@ -2,5 +2,6 @@ import 'package:flutter/services.dart';
2
3
const utils = const MethodChannel('com.cake_wallet/native_utils');
4
5
-void setIsAppSecureNative(bool isAppSecure) =>
6
- utils.invokeMethod<Uint8List>('setIsAppSecure', {'isAppSecure': isAppSecure});
5
+void setIsAppSecureNative(bool isAppSecure) {
6
+ utils.invokeMethod<Uint8List>('setIsAppSecure', {'isAppSecure': isAppSecure});
7
+}
\ No newline at end of file
ios/Runner/AppDelegate.swift
+29
-10
@@ -15,6 +15,8 @@ import UnstoppableDomainsResolution
15
if #available(iOS 10.0, *) {
16
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
17
}
18
+
19
+ makeSecure()
20
21
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
22
let legacyMigrationChannel = FlutterMethodChannel(
@@ -96,22 +98,39 @@ import UnstoppableDomainsResolution
98
99
result(address)
100
}
99
-
101
+ case "setIsAppSecure":
102
+ guard let args = call.arguments as? Dictionary<String, Bool>,
103
+ let isAppSecure = args["isAppSecure"] else {
104
+ result(nil)
105
+ return
106
+ }
107
+
108
+ if isAppSecure {
109
+ self?.textField.isSecureTextEntry = true
110
+ } else {
111
+ self?.textField.isSecureTextEntry = false
112
+ }
113
+
114
+ result(nil)
115
default:
116
result(FlutterMethodNotImplemented)
117
}
118
})
104
-
119
+
120
GeneratedPluginRegistrant.register(with: self)
121
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
122
}
123
+
124
+ private var textField = UITextField()
125
+
126
+ private func makeSecure() {
127
+ if (!self.window.subviews.contains(textField)) {
128
+ self.window.addSubview(textField)
129
+ textField.centerYAnchor.constraint(equalTo: self.window.centerYAnchor).isActive = true
130
+ textField.centerXAnchor.constraint(equalTo: self.window.centerXAnchor).isActive = true
131
+ self.window.layer.superlayer?.addSublayer(textField.layer)
132
+ textField.layer.sublayers?.first?.addSublayer(self.window.layer)
133
+ }
134
+ }
135
109
- override func applicationWillResignActive(_: UIApplication ) {
110
- self.window?.rootViewController?.view.endEditing(true)
111
- self.window?.isHidden = true;
112
- }
113
-
114
- override func applicationDidBecomeActive(_: UIApplication) {
115
- self.window?.isHidden = false;
116
- }
136
}
lib/src/screens/settings/privacy_page.dart
+6
-8
@@ -8,7 +8,6 @@ import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
8
import 'package:cake_wallet/view_model/settings/privacy_settings_view_model.dart';
9
import 'package:flutter/material.dart';
10
import 'package:flutter_mobx/flutter_mobx.dart';
11
-import 'dart:io' show Platform;
11
12
class PrivacyPage extends BasePage {
13
PrivacyPage(this._privacySettingsViewModel);
@@ -49,13 +48,12 @@ class PrivacyPage extends BasePage {
48
onValueChange: (BuildContext _, bool value) {
49
_privacySettingsViewModel.setShouldSaveRecipientAddress(value);
50
}),
52
- if (Platform.isAndroid)
53
- SettingsSwitcherCell(
54
- title: S.current.prevent_screenshots,
55
- value: _privacySettingsViewModel.isAppSecure,
56
- onValueChange: (BuildContext _, bool value) {
57
- _privacySettingsViewModel.setIsAppSecure(value);
58
- }),
51
+ SettingsSwitcherCell(
52
+ title: S.current.prevent_screenshots,
53
+ value: _privacySettingsViewModel.isAppSecure,
54
+ onValueChange: (BuildContext _, bool value) {
55
+ _privacySettingsViewModel.setIsAppSecure(value);
56
+ }),
57
SettingsSwitcherCell(
58
title: S.current.disable_buy,
59
value: _privacySettingsViewModel.disableBuy,
lib/store/settings_store.dart
+2
-7
@@ -23,7 +23,6 @@ import 'package:cake_wallet/monero/monero.dart';
23
import 'package:cake_wallet/entities/action_list_display_mode.dart';
24
import 'package:cake_wallet/entities/fiat_api_mode.dart';
25
import 'package:cw_core/set_app_secure_native.dart';
26
-import 'dart:io' show Platform;
26
27
part 'settings_store.g.dart';
28
@@ -136,11 +135,11 @@ abstract class SettingsStoreBase with Store {
135
(bool shouldSaveRecipientAddress) => sharedPreferences.setBool(
136
PreferencesKey.shouldSaveRecipientAddressKey, shouldSaveRecipientAddress));
137
138
+ setIsAppSecureNative(isAppSecure);
139
+
140
reaction((_) => isAppSecure, (bool isAppSecure) {
141
sharedPreferences.setBool(PreferencesKey.isAppSecureKey, isAppSecure);
141
- if (Platform.isAndroid) {
142
setIsAppSecureNative(isAppSecure);
143
- }
143
});
144
145
reaction(
@@ -153,10 +152,6 @@ abstract class SettingsStoreBase with Store {
152
(bool disableSell) => sharedPreferences.setBool(
153
PreferencesKey.disableSellKey, disableSell));
154
156
- if (Platform.isAndroid) {
157
- setIsAppSecureNative(isAppSecure);
158
- }
159
-
155
reaction(
156
(_) => fiatApiMode,
157
(FiatApiMode mode) =>