diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m
index f112dc742..e65f73216 100644
--- a/Classes/LinphoneCoreSettingsStore.m
+++ b/Classes/LinphoneCoreSettingsStore.m
@@ -537,6 +537,7 @@
[self setBool:ANIMATED forKey:@"animations_preference"];
[self setBool:[lm lpConfigBoolForKey:@"backgroundmode_preference"] forKey:@"backgroundmode_preference"];
[self setBool:[lm lpConfigBoolForKey:@"start_at_boot_preference"] forKey:@"start_at_boot_preference"];
+ [self setBool:[lm lpConfigBoolForKey:@"screenshot_preference" withDefault:NO] forKey:@"screenshot_preference"];
[self setBool:[lm lpConfigBoolForKey:@"autoanswer_notif_preference"] forKey:@"autoanswer_notif_preference"];
[self setBool:[lm lpConfigBoolForKey:@"show_msg_in_notif" withDefault:YES] forKey:@"show_msg_in_notif"];
[self setBool:[lm lpConfigBoolForKey:@"use_rls_presence" withDefault:YES] forKey:@"use_rls_presence"];
@@ -1110,6 +1111,9 @@
// advanced section
BOOL animations = [self boolForKey:@"animations_preference"];
[lm lpConfigSetInt:animations forKey:@"animations_preference"];
+
+ BOOL screenshot = [self boolForKey:@"screenshot_preference"];
+ [lm lpConfigSetInt:screenshot forKey:@"screenshot_preference"];
UIDevice *device = [UIDevice currentDevice];
BOOL backgroundSupported = [device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported];
diff --git a/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift b/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift
index 6ee4a7896..46c98dabd 100644
--- a/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift
+++ b/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift
@@ -49,6 +49,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
var friend: Friend? = nil
var friendDelegate: FriendDelegate? = nil
+ let field = UITextField()
+
var collectionViewMedia: UICollectionView = {
let top_bar_height = 66.0
let width = UIScreen.main.bounds.width * 0.9
@@ -150,6 +152,23 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
setupViews()
markAsRead = true
+ UIApplication.shared.keyWindow?.makeSecure(field: field)
+
+ NotificationCenter.default.addObserver(forName: UIApplication.userDidTakeScreenshotNotification, object: nil, queue: OperationQueue.main) { notification in
+ if (ConfigManager.instance().lpConfigBoolForKey(key: "screenshot_preference") == false && self.floatingButton.isHidden == false) {
+ let popupView = UIAlertController(title: VoipTexts.screenshot_restrictions, message: nil, preferredStyle: .alert)
+
+ let defaultAction = UIAlertAction(
+ title: NSLocalizedString("Ok", comment: ""),
+ style: .default)
+ popupView.addAction(defaultAction)
+ self.present(popupView, animated: true, completion:{
+ popupView.view.superview?.isUserInteractionEnabled = true
+ popupView.view.superview?.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissOnTapOutsideOrCancel)))
+ })
+ }
+ }
+
ChatConversationViewModel.sharedModel.isComposing.observe { compose in
if((compose! && self.isComposingView.isHidden)||(!compose! && !self.isComposingView.isHidden)){
self.setComposingVisible(compose!, withDelay: 0.3)
@@ -224,7 +243,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
}
let notificationCenter = NotificationCenter.default
- notificationCenter.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil) }
+ notificationCenter.addObserver(self, selector: #selector(appMovedToForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
+ }
@objc func appMovedToForeground() {
if(PhoneMainView.instance().currentView == ChatConversationViewSwift.compositeViewDescription()){
@@ -280,6 +300,12 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
handlePendingTransferIfAny()
configureMessageField()
ChatConversationViewModel.sharedModel.shareFile()
+
+ if ConfigManager.instance().lpConfigBoolForKey(key: "screenshot_preference") == false && floatingButton.isHidden == false {
+ UIApplication.shared.keyWindow?.changeSecure(field: field, isSecure: true)
+ }else{
+ UIApplication.shared.keyWindow?.changeSecure(field: field, isSecure: false)
+ }
}
override func viewWillDisappear(_ animated: Bool) {
@@ -287,6 +313,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
friend?.removeDelegate(delegate: friendDelegate!)
}
AvatarBridge.removeAllObserver()
+
+ UIApplication.shared.keyWindow?.changeSecure(field: field, isSecure: false)
}
override func viewDidDisappear(_ animated: Bool) {
@@ -1525,3 +1553,20 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
PhoneMainView.instance().updateApplicationBadgeNumber()
}
}
+
+extension UIView {
+ func makeSecure(field: UITextField) {
+ DispatchQueue.main.async {
+ field.isSecureTextEntry = false
+ self.addSubview(field)
+ field.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
+ field.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
+ self.layer.superlayer?.addSublayer(field.layer)
+ field.layer.sublayers?.first?.addSublayer(self.layer)
+ }
+ }
+
+ func changeSecure(field: UITextField, isSecure: Bool){
+ field.isSecureTextEntry = isSecure
+ }
+}
diff --git a/Classes/Swift/Voip/Theme/VoipTexts.swift b/Classes/Swift/Voip/Theme/VoipTexts.swift
index 91209360a..f9e78eb10 100644
--- a/Classes/Swift/Voip/Theme/VoipTexts.swift
+++ b/Classes/Swift/Voip/Theme/VoipTexts.swift
@@ -223,4 +223,5 @@ import UIKit
static let ok = NSLocalizedString("ok",comment:"")
static let conference_info_confirm_removal_delete = NSLocalizedString("DELETE",comment:"")
static let conference_unable_to_share_via_calendar = NSLocalizedString("Unable to add event to calendar. Check permissions",comment:"")
+ static let screenshot_restrictions = NSLocalizedString("Can't take a screenshot due to app restrictions", comment: "")
}
diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings
index 20120f171..a39914a89 100644
Binary files a/Resources/fr.lproj/Localizable.strings and b/Resources/fr.lproj/Localizable.strings differ
diff --git a/Settings/InAppSettings.bundle/Advanced.plist b/Settings/InAppSettings.bundle/Advanced.plist
index e9146974e..5c2c5b8f3 100644
--- a/Settings/InAppSettings.bundle/Advanced.plist
+++ b/Settings/InAppSettings.bundle/Advanced.plist
@@ -144,6 +144,16 @@
Type
PSToggleSwitchSpecifier
+
+ DefaultValue
+
+ Key
+ screenshot_preference
+ Title
+ Disable UI's secure mode (Screenshot)
+ Type
+ PSToggleSwitchSpecifier
+
DefaultValue