Minor changes + add no ask again switch in Devices List alertController

This commit is contained in:
Benoit Martins 2022-12-19 15:32:28 +01:00 committed by QuentinArguillere
parent f3532e7124
commit 4e96033d04
4 changed files with 49 additions and 56 deletions

View file

@ -42,6 +42,8 @@ import DropDown
var address: String? = nil var address: String? = nil
var notifications_on: Bool = true var notifications_on: Bool = true
var activeAlertController = CustomAlertController()
let menu: DropDown = { let menu: DropDown = {
let menu = DropDown() let menu = DropDown()
menu.dataSource = [""] menu.dataSource = [""]
@ -101,11 +103,11 @@ import DropDown
action2: { action2: {
self.tapChooseMenuItem(self.action2Button) self.tapChooseMenuItem(self.action2Button)
}, },
action3: {
self.alertActionGoToDevicesList()
},
title: address ?? "Error" title: address ?? "Error"
//title:"benoit.martins.test1"
//title:"Coin à champis de François"
) )
//view.backgroundColor = VoipTheme.backgroundColor3.get()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
@ -197,7 +199,6 @@ import DropDown
let isOneToOneChat = chatRoom!.hasCapability(mask: Int(LinphoneChatRoomCapabilitiesOneToOne.rawValue)) let isOneToOneChat = chatRoom!.hasCapability(mask: Int(LinphoneChatRoomCapabilitiesOneToOne.rawValue))
if (!isOneToOneChat) { if (!isOneToOneChat) {
//ConferenceViewModelBridge.startGroupCall(cChatRoom: cChatRoom!)
alertActionConferenceCall(cChatRoom: cChatRoom) alertActionConferenceCall(cChatRoom: cChatRoom)
} else { } else {
LinphoneManager.instance().call(addr) LinphoneManager.instance().call(addr)
@ -215,6 +216,8 @@ import DropDown
alertController.addButtonsAlertController(alertController: alertController, buttonsViewHeightV: 60, buttonsAlertHeightV: 40) alertController.addButtonsAlertController(alertController: alertController, buttonsViewHeightV: 60, buttonsAlertHeightV: 40)
activeAlertController = alertController
self.present(alertController, animated: true, completion:{ self.present(alertController, animated: true, completion:{
alertController.view.superview?.isUserInteractionEnabled = true alertController.view.superview?.isUserInteractionEnabled = true
alertController.view.superview?.subviews[0].addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissOnTapOutsideOrCancel))) alertController.view.superview?.subviews[0].addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissOnTapOutsideOrCancel)))
@ -225,15 +228,51 @@ import DropDown
} }
func alertActionGoToDevicesList() {
let notAskAgain = ConfigManager.instance().lpConfigBoolForKey(key: "confirmation_dialog_before_sas_call_not_ask_again");
if(!notAskAgain){
let alertController = CustomAlertController(title: VoipTexts.alert_dialog_secure_badge_button_chat_conversation_title, message: nil, preferredStyle: .alert)
alertController.setBackgroundColor(color: .darkGray)
alertController.setTitle(font: nil, color: .white)
alertController.setTint(color: .white)
alertController.setMaxWidth(alert: alertController)
alertController.addButtonsAlertController(alertController: alertController, buttonsViewHeightV: 60, checkboxViewHeightV: 50, buttonsAlertHeightV: 40)
activeAlertController = alertController
self.present(alertController, animated: true, completion:{
alertController.view.superview?.isUserInteractionEnabled = true
alertController.view.superview?.subviews[0].addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissOnTapOutsideOrCancel)))
})
alertController.ok_button_alert.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.onTapOkGoToDevicesList)))
}else{
let view: DevicesListView = self.VIEW(DevicesListView.compositeViewDescription())
view.room = chatRoom?.getCobject
PhoneMainView.instance().changeCurrentView(view.compositeViewDescription())
}
}
@objc func onTapOkStartGroupCall(){ @objc func onTapOkStartGroupCall(){
self.dismiss(animated: true, completion: nil) self.dismiss(animated: true, completion: nil)
ConferenceViewModelBridge.startGroupCall(cChatRoom: (chatRoom?.getCobject)!) ConferenceViewModelBridge.startGroupCall(cChatRoom: (chatRoom?.getCobject)!)
} }
@objc override func onTapOk() { @objc func onTapOkGoToDevicesList() {
self.dismiss(animated: true, completion: nil) self.dismiss(animated: true, completion: nil)
if(activeAlertController.isChecked){
ConfigManager.instance().lpConfigSetBool(value: activeAlertController.isChecked, key: "confirmation_dialog_before_sas_call_not_ask_again")
}
let view: DevicesListView = self.VIEW(DevicesListView.compositeViewDescription()) let view: DevicesListView = self.VIEW(DevicesListView.compositeViewDescription())
view.room = chatRoom?.getCobject view.room = chatRoom?.getCobject
PhoneMainView.instance().changeCurrentView(view.compositeViewDescription()) PhoneMainView.instance().changeCurrentView(view.compositeViewDescription())
} }
@objc func dismissOnTapOutsideOrCancel(){
self.dismiss(animated: true, completion: nil)
}
} }

View file

@ -26,7 +26,6 @@ import UniformTypeIdentifiers
class MessageView: UIView, PHPickerViewControllerDelegate, UIDocumentPickerDelegate { class MessageView: UIView, PHPickerViewControllerDelegate, UIDocumentPickerDelegate {
let top_bar_height = 66.0
let side_buttons_margin = 10 let side_buttons_margin = 10
var action1 : (() -> Void)? = nil var action1 : (() -> Void)? = nil

View file

@ -25,17 +25,9 @@ import linphonesw
@objc class BackActionsNavigationView: UIViewController { @objc class BackActionsNavigationView: UIViewController {
// layout constants
let top_bar_height = 66.0 let top_bar_height = 66.0
let navigation_buttons_padding = 18.0
let side_buttons_margin = 5 let side_buttons_margin = 5
// User by subviews
let form_margin = 10.0
let form_input_height = 40.0
let schdule_for_later_height = 80.0
let description_height = 150.0
let titleLabel = StyledLabel(VoipTheme.calls_list_header_font) let titleLabel = StyledLabel(VoipTheme.calls_list_header_font)
let topBar = UIView() let topBar = UIView()
@ -51,21 +43,15 @@ import linphonesw
let action1BisButton = CallControlButton(buttonTheme:VoipTheme.nav_button("voip_conference_new")) let action1BisButton = CallControlButton(buttonTheme:VoipTheme.nav_button("voip_conference_new"))
let action2Button = CallControlButton(buttonTheme:VoipTheme.nav_button("more_menu_default")) let action2Button = CallControlButton(buttonTheme:VoipTheme.nav_button("more_menu_default"))
let cancel_button_alert = UIButton()
let ok_button_alert = UIButton()
let checkBoxButton = CallControlButton(buttonTheme:VoipTheme.nav_button("checkbox_unchecked"))
var isChecked = false
let checkBoxText = UILabel()
var isSecure : Bool = false var isSecure : Bool = false
let isGroupChat : Bool = false
let levelMaxSecure : Bool = false
let floatingButton = CallControlButton(buttonTheme:VoipTheme.nav_button("")) let floatingButton = CallControlButton(buttonTheme:VoipTheme.nav_button(""))
func viewDidLoad(backAction : @escaping () -> Void, func viewDidLoad(backAction : @escaping () -> Void,
action1 : @escaping () -> Void, action1 : @escaping () -> Void,
action1Bis : @escaping () -> Void, action1Bis : @escaping () -> Void,
action2 : @escaping () -> Void, action2 : @escaping () -> Void,
action3 : @escaping () -> Void,
title:String) { title:String) {
self.backAction = backAction self.backAction = backAction
self.action1 = action1 self.action1 = action1
@ -102,7 +88,7 @@ import linphonesw
view.addSubview(scrollView) view.addSubview(scrollView)
scrollView.alignUnder(view: topBar).alignParentBottom().matchParentSideBorders().done() scrollView.alignUnder(view: topBar).alignParentBottom().matchParentSideBorders().done()
scrollView.addSubview(contentView) scrollView.addSubview(contentView)
contentView.matchBordersOf(view: view).alignParentBottom().alignParentTop().done() // don't forget a bottom constraint b/w last element of contentview and contentview contentView.matchBordersOf(view: view).alignParentBottom().alignParentTop().done()
view.addSubview(messageView) view.addSubview(messageView)
messageView.alignParentBottom().height(top_bar_height).matchParentSideBorders().done() messageView.alignParentBottom().height(top_bar_height).matchParentSideBorders().done()
@ -112,7 +98,7 @@ import linphonesw
floatingButton.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor, constant: top_bar_height + 5).isActive = true floatingButton.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor, constant: top_bar_height + 5).isActive = true
floatingButton.setImage(UIImage(named:"security_alert_indicator.png"), for: .normal) floatingButton.setImage(UIImage(named:"security_alert_indicator.png"), for: .normal)
floatingButton.imageEdgeInsets = UIEdgeInsets(top: 45, left: 45, bottom: 45, right: 45) floatingButton.imageEdgeInsets = UIEdgeInsets(top: 45, left: 45, bottom: 45, right: 45)
floatingButton.onClickAction = alertAction floatingButton.onClickAction = action3
} }
@ -123,25 +109,6 @@ import linphonesw
} }
func alertAction() {
let alertController = CustomAlertController(title: VoipTexts.alert_dialog_secure_badge_button_chat_conversation_title, message: nil, preferredStyle: .alert)
alertController.setBackgroundColor(color: .darkGray)
alertController.setTitle(font: nil, color: .white)
alertController.setTint(color: .white)
alertController.setMaxWidth(alert: alertController)
alertController.addButtonsAlertController(alertController: alertController, buttonsViewHeightV: 60, checkboxViewHeightV: 50, buttonsAlertHeightV: 40)
self.present(alertController, animated: true, completion:{
alertController.view.superview?.isUserInteractionEnabled = true
alertController.view.superview?.subviews[0].addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissOnTapOutsideOrCancel)))
})
alertController.ok_button_alert.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.onTapOk)))
}
func changeTitle(titleString: String){ func changeTitle(titleString: String){
titleLabel.text = titleString titleLabel.text = titleString
} }
@ -165,12 +132,4 @@ import linphonesw
action1BisButton.isHidden = true action1BisButton.isHidden = true
} }
} }
@objc func dismissOnTapOutsideOrCancel(){
self.dismiss(animated: true, completion: nil)
}
@objc func onTapOk(){
self.dismiss(animated: true, completion: nil)
}
} }

View file

@ -27,10 +27,6 @@ class CustomAlertController: UIAlertController {
var isChecked = false var isChecked = false
let checkBoxText = UILabel() let checkBoxText = UILabel()
var isSecure : Bool = false
let isGroupChat : Bool = false
let levelMaxSecure : Bool = false
@objc func dismissOnTapOutsideOrCancel(){ @objc func dismissOnTapOutsideOrCancel(){
self.dismiss(animated: true, completion: nil) self.dismiss(animated: true, completion: nil)
} }
@ -39,7 +35,7 @@ class CustomAlertController: UIAlertController {
self.dismiss(animated: true, completion: nil) self.dismiss(animated: true, completion: nil)
} }
@objc func switchCheckedValue(){ @objc func changeCheckValue(){
isChecked = !isChecked isChecked = !isChecked
checkBoxButton.isSelected = isChecked checkBoxButton.isSelected = isChecked
} }
@ -87,7 +83,7 @@ class CustomAlertController: UIAlertController {
checkBoxButton.setImage(UIImage(named:"checkbox_unchecked.png"), for: .normal) checkBoxButton.setImage(UIImage(named:"checkbox_unchecked.png"), for: .normal)
checkBoxButton.setImage(UIImage(named:"checkbox_checked.png"), for: .selected) checkBoxButton.setImage(UIImage(named:"checkbox_checked.png"), for: .selected)
checkBoxButton.addTarget(self, action: #selector(switchCheckedValue), for: .touchUpInside) checkBoxButton.addTarget(self, action: #selector(changeCheckValue), for: .touchUpInside)
checkboxView.addSubview(checkBoxButton) checkboxView.addSubview(checkBoxButton)
checkBoxText.text = VoipTexts.alert_dialog_secure_badge_button_chat_conversation_checkboxtext checkBoxText.text = VoipTexts.alert_dialog_secure_badge_button_chat_conversation_checkboxtext