mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
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:
parent
43e062d1ac
commit
1e868f876e
4 changed files with 40 additions and 27 deletions
|
@ -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});
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) =>
|
||||
|
|
Loading…
Reference in a new issue