forked from mirrors/linphone-iphone
Disable screenshot in secure room
This commit is contained in:
parent
2b06b47d99
commit
2e0fd1f898
5 changed files with 61 additions and 1 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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: "")
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -144,6 +144,16 @@
|
|||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>DefaultValue</key>
|
||||
<false/>
|
||||
<key>Key</key>
|
||||
<string>screenshot_preference</string>
|
||||
<key>Title</key>
|
||||
<string>Disable UI's secure mode (Screenshot)</string>
|
||||
<key>Type</key>
|
||||
<string>PSToggleSwitchSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>DefaultValue</key>
|
||||
<true/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue