forked from mirrors/linphone-iphone
Add item to dropdown menu with images
This commit is contained in:
parent
a6a811b059
commit
fe3bf1035f
6 changed files with 182 additions and 57 deletions
|
|
@ -235,7 +235,7 @@ static int sorted_history_comparison(LinphoneChatRoom *to_insert, LinphoneChatRo
|
|||
return;
|
||||
|
||||
LinphoneChatRoom *chatRoom = (LinphoneChatRoom *)bctbx_list_nth_data(_data, (int)[indexPath row]);
|
||||
[PhoneMainView.instance goToChatRoom:chatRoom];
|
||||
[PhoneMainView.instance goToChatRoomSwift:chatRoom];
|
||||
}
|
||||
|
||||
void deletion_chat_room_state_changed(LinphoneChatRoom *cr, LinphoneChatRoomState newState) {
|
||||
|
|
|
|||
|
|
@ -926,24 +926,13 @@ static RootViewManager *rootViewManagerInstance = nil;
|
|||
|
||||
|
||||
- (void)goToChatRoomSwift:(LinphoneChatRoom *)cr {
|
||||
/*
|
||||
_waitView.hidden = YES;
|
||||
_waitView = NULL;
|
||||
ChatConversationViewSwift *view = VIEW(ChatConversationViewSwift);
|
||||
if (view.chatRoom && view.chatRoomCbs)
|
||||
linphone_chat_room_remove_callbacks(view.chatRoom, view.chatRoomCbs);
|
||||
|
||||
view.chatRoomCbs = NULL;
|
||||
if (view.chatRoom != cr)
|
||||
[view clearMessageView];
|
||||
view.chatRoom = cr;
|
||||
view.peerAddress = linphone_address_as_string(linphone_chat_room_get_peer_address(cr));
|
||||
self.currentRoom = view.chatRoom;
|
||||
if (PhoneMainView.instance.currentView == view.compositeViewDescription)
|
||||
[view configureForRoom:FALSE];
|
||||
else
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
*/
|
||||
|
||||
[view initChatRoomWithCChatRoom:cr];
|
||||
|
||||
[PhoneMainView.instance changeCurrentView:view.compositeViewDescription];
|
||||
}
|
||||
|
||||
void main_view_chat_room_conference_joined(LinphoneChatRoom *cr, const LinphoneEventLog *event_log) {
|
||||
|
|
|
|||
|
|
@ -33,41 +33,85 @@ import DropDown
|
|||
|
||||
func compositeViewDescription() -> UICompositeViewDescription! { return type(of: self).compositeDescription }
|
||||
|
||||
let APP_GROUP_ID = "group.belledonne-communications.linphone.widget"
|
||||
var debugEnabled = false
|
||||
|
||||
|
||||
var chatRoom: ChatRoom? = nil
|
||||
var chatRoomDelegate: ChatRoomDelegate? = nil
|
||||
var address: String? = nil
|
||||
var notifications_on: Bool = true
|
||||
|
||||
let menu: DropDown = {
|
||||
let menu = DropDown()
|
||||
menu.dataSource = [
|
||||
"Item 1",
|
||||
"Item 2",
|
||||
"Item 3",
|
||||
"Item 4",
|
||||
"Item 5"
|
||||
menu.dataSource = [""]
|
||||
var images = [
|
||||
"contact_add_default.png",
|
||||
"contacts_all_default.png",
|
||||
"menu_voip_meeting_schedule",
|
||||
"menu_security_default.png",
|
||||
"ephemeral_messages_default.png",
|
||||
"menu_notifications_off.png",
|
||||
"menu_notifications_on.png",
|
||||
"delete_default.png",
|
||||
"chat_group_informations.png"
|
||||
]
|
||||
menu.cellNib = UINib(nibName: "DropDownCell", bundle: nil)
|
||||
menu.customCellConfiguration = { index, title, cell in
|
||||
guard let cell = cell as? MyCell else {
|
||||
return
|
||||
}
|
||||
cell.myImageView.image = UIImage(named: "security_2_indicator.png")
|
||||
if(index < images.count){
|
||||
switch menu.dataSource[index] {
|
||||
case VoipTexts.dropdown_menu_chat_conversation_add_to_contact:
|
||||
cell.myImageView.image = UIImage(named: images[0])
|
||||
case VoipTexts.dropdown_menu_chat_conversation_go_to_contact:
|
||||
cell.myImageView.image = UIImage(named: images[1])
|
||||
case VoipTexts.conference_schedule_start:
|
||||
cell.myImageView.image = UIImage(named: images[2])
|
||||
case VoipTexts.dropdown_menu_chat_conversation_conversation_device:
|
||||
cell.myImageView.image = UIImage(named: images[3])
|
||||
case VoipTexts.dropdown_menu_chat_conversation_ephemeral_messages:
|
||||
cell.myImageView.image = UIImage(named: images[4])
|
||||
case VoipTexts.dropdown_menu_chat_conversation_mute_notifications:
|
||||
cell.myImageView.image = UIImage(named: images[5])
|
||||
case VoipTexts.dropdown_menu_chat_conversation_unmute_notifications:
|
||||
cell.myImageView.image = UIImage(named: images[6])
|
||||
case VoipTexts.dropdown_menu_chat_conversation_delete_messages:
|
||||
cell.myImageView.image = UIImage(named: images[7])
|
||||
default:
|
||||
cell.myImageView.image = UIImage(named: images[8])
|
||||
}
|
||||
}
|
||||
}
|
||||
return menu
|
||||
}()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad(
|
||||
backAction: {
|
||||
self.goBackChatListView()
|
||||
},
|
||||
action1: {
|
||||
backAction: {
|
||||
self.goBackChatListView()
|
||||
},
|
||||
action1: {
|
||||
|
||||
},
|
||||
action2: {
|
||||
},
|
||||
action1Bis: {
|
||||
|
||||
},
|
||||
action2: {
|
||||
self.tapChooseMenuItem(self.action2Button)
|
||||
},
|
||||
title:"benoit.martins.test1"
|
||||
},
|
||||
title: address ?? "Error"
|
||||
//title:"benoit.martins.test1"
|
||||
//title:"Coin à champis de François"
|
||||
)
|
||||
//view.backgroundColor = VoipTheme.backgroundColor3.get()
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
topBar.backgroundColor = VoipTheme.voipToolbarBackgroundColor.get()
|
||||
}
|
||||
|
||||
func goBackChatListView() {
|
||||
PhoneMainView.instance().pop(toView: ChatsListView.compositeViewDescription())
|
||||
|
|
@ -77,9 +121,72 @@ import DropDown
|
|||
menu.anchorView = sender
|
||||
menu.bottomOffset = CGPoint(x: -UIScreen.main.bounds.width * 0.6, y: sender.frame.size.height)
|
||||
menu.show()
|
||||
|
||||
menu.selectionAction = { index, title in
|
||||
print("index \(index) and \(title)")
|
||||
}
|
||||
}
|
||||
|
||||
func initDataSource(groupeChat: Bool, secureLevel: Bool, cChatRoom: OpaquePointer) {
|
||||
menu.dataSource.removeAll()
|
||||
|
||||
let config = Config.newForSharedCore(appGroupId: APP_GROUP_ID, configFilename: "linphonerc", factoryConfigFilename: "")
|
||||
let debugLevel = config?.getInt(section: "app", key: "debugenable_preference", defaultValue: LogLevel.Debug.rawValue)
|
||||
debugEnabled = (debugLevel! >= LogLevel.Debug.rawValue && debugLevel! < LogLevel.Error.rawValue)
|
||||
|
||||
print(debugEnabled)
|
||||
|
||||
if(groupeChat){
|
||||
menu.dataSource.append(VoipTexts.conference_schedule_start)
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_group_infos)
|
||||
}else{
|
||||
var contact: Contact? = nil
|
||||
let firstParticipant = chatRoom?.participants.first
|
||||
let addr = (firstParticipant != nil) ? linphone_participant_get_address(firstParticipant?.getCobject) : linphone_chat_room_get_peer_address(cChatRoom)
|
||||
|
||||
contact = FastAddressBook.getContactWith(addr)
|
||||
|
||||
if (contact == nil) {
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_add_to_contact)
|
||||
} else {
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_go_to_contact)
|
||||
}
|
||||
}
|
||||
if(secureLevel){
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_conversation_device)
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_ephemeral_messages)
|
||||
}
|
||||
if(notifications_on){
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_mute_notifications)
|
||||
}else{
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_unmute_notifications)
|
||||
}
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_delete_messages)
|
||||
menu.dataSource.append(VoipTexts.dropdown_menu_chat_conversation_debug_infos)
|
||||
}
|
||||
|
||||
@objc func initChatRoom(cChatRoom:OpaquePointer) {
|
||||
chatRoom = ChatRoom.getSwiftObject(cObject: cChatRoom)
|
||||
PhoneMainView.instance().currentRoom = cChatRoom
|
||||
address = chatRoom?.peerAddress?.asString()
|
||||
var changeIcon = false
|
||||
let isOneToOneChat = chatRoom!.hasCapability(mask: Int(LinphoneChatRoomCapabilitiesOneToOne.rawValue))
|
||||
|
||||
if (isOneToOneChat) {
|
||||
|
||||
let firstParticipant = chatRoom?.participants.first
|
||||
let addr = (firstParticipant != nil) ? linphone_participant_get_address(firstParticipant?.getCobject) : linphone_chat_room_get_peer_address(cChatRoom);
|
||||
address = FastAddressBook.displayName(for: addr) ?? "unknow"
|
||||
changeIcon = false
|
||||
|
||||
} else {
|
||||
address = chatRoom?.subject
|
||||
changeIcon = true
|
||||
|
||||
|
||||
}
|
||||
|
||||
changeTitle(titleString: address ?? "Error")
|
||||
changeCallIcon(groupeChat: changeIcon)
|
||||
|
||||
let secureLevel = FastAddressBook.image(for: linphone_chat_room_get_security_level(cChatRoom))
|
||||
changeSecureLevel(secureLevel: secureLevel != nil, imageBadge: secureLevel)
|
||||
initDataSource(groupeChat: !isOneToOneChat, secureLevel: secureLevel != nil, cChatRoom: cChatRoom)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class ConferenceSchedulingViewModel {
|
|||
private var hour: Int = 0
|
||||
private var minutes: Int = 0
|
||||
|
||||
private var chatRooomDelegate : ChatRoomDelegate? = nil
|
||||
private var chatRoomDelegate : ChatRoomDelegate? = nil
|
||||
private var conferenceSchedulerDelegate : ConferenceSchedulerDelegateStub? = nil
|
||||
|
||||
var existingConfInfo:MutableLiveData<ConferenceInfo?> = MutableLiveData()
|
||||
|
|
@ -110,14 +110,14 @@ class ConferenceSchedulingViewModel {
|
|||
}
|
||||
)
|
||||
|
||||
chatRooomDelegate = ChatRoomDelegateStub(
|
||||
chatRoomDelegate = ChatRoomDelegateStub(
|
||||
onStateChanged : { (room: ChatRoom, state: ChatRoom.State) -> Void in
|
||||
if (state == ChatRoom.State.Created) {
|
||||
Log.i("[Conference Creation] Chat room created")
|
||||
room.removeDelegate(delegate: self.chatRooomDelegate!)
|
||||
room.removeDelegate(delegate: self.chatRoomDelegate!)
|
||||
} else if (state == ChatRoom.State.CreationFailed) {
|
||||
Log.e("[Conference Creation] Group chat room creation has failed !")
|
||||
room.removeDelegate(delegate: self.chatRooomDelegate!)
|
||||
room.removeDelegate(delegate: self.chatRoomDelegate!)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import linphonesw
|
|||
|
||||
let backButton = CallControlButton(buttonTheme:VoipTheme.nav_button("back_default"))
|
||||
let action1Button = CallControlButton(buttonTheme:VoipTheme.nav_button("call_audio_start_default"))
|
||||
let action1BisButton = CallControlButton(buttonTheme:VoipTheme.nav_button("voip_conference_new"))
|
||||
let action2Button = CallControlButton(buttonTheme:VoipTheme.nav_button("more_menu_default"))
|
||||
|
||||
let cancel_button_alert = UIButton()
|
||||
|
|
@ -56,13 +57,14 @@ import linphonesw
|
|||
var isChecked = false
|
||||
let checkBoxText = UILabel()
|
||||
|
||||
let isSecure : Bool = false
|
||||
var isSecure : Bool = false
|
||||
let isGroupChat : Bool = false
|
||||
let levelMaxSecure : Bool = false
|
||||
let floatingButton = CallControlButton(buttonTheme:VoipTheme.nav_button(""))
|
||||
|
||||
func viewDidLoad(backAction : @escaping () -> Void,
|
||||
action1 : @escaping () -> Void,
|
||||
action1Bis : @escaping () -> Void,
|
||||
action2 : @escaping () -> Void,
|
||||
title:String) {
|
||||
self.backAction = backAction
|
||||
|
|
@ -79,18 +81,16 @@ import linphonesw
|
|||
topBar.addSubview(action2Button)
|
||||
action2Button.alignParentRight(withMargin: side_buttons_margin).matchParentHeight().done()
|
||||
action2Button.onClickAction = action2
|
||||
|
||||
if(isGroupChat){
|
||||
action1Button.setImage(UIImage(named:"voip_conference_new.png"), for: .normal)
|
||||
action1Button.setImage(UIImage(named:"voip_conference_new_selected.png"), for: .highlighted)
|
||||
}
|
||||
|
||||
topBar.addSubview(action1Button)
|
||||
topBar.addSubview(action1BisButton)
|
||||
action1Button.toLeftOf(action2Button, withRightMargin: 20).matchParentHeight().done()
|
||||
if(!isGroupChat){
|
||||
action1Button.size(w: 35, h: 35).done()
|
||||
}
|
||||
action1BisButton.toLeftOf(action2Button, withRightMargin: 20).matchParentHeight().done()
|
||||
|
||||
action1Button.onClickAction = action1
|
||||
action1BisButton.onClickAction = action1Bis
|
||||
|
||||
action1BisButton.isHidden = true
|
||||
|
||||
topBar.addSubview(titleLabel)
|
||||
titleLabel.toRightOf(backButton, withLeftMargin: 10).matchParentHeight().done()
|
||||
|
|
@ -107,15 +107,12 @@ import linphonesw
|
|||
view.addSubview(messageView)
|
||||
messageView.alignParentBottom().height(top_bar_height).matchParentSideBorders().done()
|
||||
|
||||
|
||||
if(isSecure){
|
||||
view.addSubview(floatingButton)
|
||||
floatingButton.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -5).isActive = true
|
||||
floatingButton.topAnchor.constraint(equalTo: self.view.layoutMarginsGuide.topAnchor, constant: top_bar_height + 5).isActive = true
|
||||
levelMaxSecure ? floatingButton.setImage(UIImage(named:"security_2_indicator.png"), for: .normal) : floatingButton.setImage(UIImage(named:"security_1_indicator.png"), for: .normal)
|
||||
floatingButton.imageEdgeInsets = UIEdgeInsets(top: 45, left: 45, bottom: 45, right: 45)
|
||||
floatingButton.onClickAction = alertAction
|
||||
}
|
||||
view.addSubview(floatingButton)
|
||||
floatingButton.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -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.imageEdgeInsets = UIEdgeInsets(top: 45, left: 45, bottom: 45, right: 45)
|
||||
floatingButton.onClickAction = alertAction
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -208,6 +205,29 @@ import linphonesw
|
|||
|
||||
|
||||
|
||||
}
|
||||
|
||||
func changeTitle(titleString: String){
|
||||
titleLabel.text = titleString
|
||||
}
|
||||
|
||||
func changeSecureLevel(secureLevel: Bool, imageBadge: UIImage?){
|
||||
isSecure = secureLevel
|
||||
if(isSecure){
|
||||
floatingButton.isHidden = false
|
||||
floatingButton.setImage(imageBadge, for: .normal)
|
||||
}else{
|
||||
floatingButton.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
func changeCallIcon(groupeChat: Bool){
|
||||
if(groupeChat){
|
||||
action1Button.isHidden = true
|
||||
action1BisButton.isHidden = false
|
||||
}else{
|
||||
action1Button.isHidden = false
|
||||
action1BisButton.isHidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,15 @@ import UIKit
|
|||
@objc static let image_picker_view_alert_action_document = NSLocalizedString("Document",comment:"")
|
||||
@objc static let alert_dialog_secure_badge_button_chat_conversation_title = NSLocalizedString("Instant messages are end-to-end encrypted in secured conversations. It is possible to upgrade the security level of a conversation by authenticating participants. To do so, call the contact and follow the authentification process.",comment:"")
|
||||
@objc static let alert_dialog_secure_badge_button_chat_conversation_checkboxtext = NSLocalizedString("Do not show again",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_go_to_contact = NSLocalizedString("Go to contact",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_add_to_contact = NSLocalizedString("Add to contacts",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_group_infos = NSLocalizedString("Group infos",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_conversation_device = NSLocalizedString("Conversation's devices",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_ephemeral_messages = NSLocalizedString("Ephemeral messages",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_mute_notifications = NSLocalizedString("Mute notifications",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_unmute_notifications = NSLocalizedString("Un-mute notifications",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_delete_messages = NSLocalizedString("Delete messages",comment:"")
|
||||
@objc static let dropdown_menu_chat_conversation_debug_infos = NSLocalizedString("Debug infos",comment:"")
|
||||
|
||||
// FROM ANDROID END
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue