From 2f07c4a67aeb48b54e6afb16c4bca963075b1a12 Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Wed, 15 Nov 2017 20:30:05 +0100 Subject: [PATCH 1/3] Move create group chat button to chat options tab. --- .../branding/default/style/css/V2Theme.css | 2 +- .../locale/en_US/bbbResources.properties | 2 + .../modules/chat/views/ChatBox.mxml | 4 ++ ...AddChatTabBox.mxml => ChatOptionsTab.mxml} | 71 ++++++++++++------- .../modules/chat/views/ChatView.mxml | 10 ++- .../modules/chat/views/ChatWindow.mxml | 40 ++++------- 6 files changed, 73 insertions(+), 56 deletions(-) rename bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/{AddChatTabBox.mxml => ChatOptionsTab.mxml} (82%) diff --git a/bigbluebutton-client/branding/default/style/css/V2Theme.css b/bigbluebutton-client/branding/default/style/css/V2Theme.css index dcd031b33f..d6f0435d38 100755 --- a/bigbluebutton-client/branding/default/style/css/V2Theme.css +++ b/bigbluebutton-client/branding/default/style/css/V2Theme.css @@ -581,7 +581,7 @@ views|ClientStatusItemRenderer { //------------------------------ */ -chat|AddChatTabBox { +chat|ChatOptionsTab { verticalGap : 20; paddingLeft : 20; paddingRight : 20; diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index dad8577ec9..78286a728a 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -350,6 +350,8 @@ bbb.chat.private.closeMessage = You can close this tab by using the key combinat bbb.chat.usersList.toolTip = Select User To Open Private Chat bbb.chat.usersList.accessibilityName = Select user to open private chat. Use the arrow keys to navigate. bbb.chat.chatOptions = Chat Options +bbb.chat.newChat.label = New Public Chat +bbb.chat.newChat.create = Create bbb.chat.fontSize = Chat Message Font Size bbb.chat.cmbFontSize.toolTip = Select Chat Message Font Size bbb.chat.messageList = Chat Messages diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml index 4639b1f70e..fccd7f2227 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml @@ -50,9 +50,13 @@ with BigBlueButton; if not, see . . . globalDispatcher.dispatchEvent(clearEvent); } } + + public function onCreateChatBtnClick():void { + var newChatName:String = newChatNameInput.text; + var access:String = GroupChat.PUBLIC; + var users:Array = new Array(); + + var createEvent:CreateGroupChatReqEvent = new CreateGroupChatReqEvent(newChatName, access, users); + globalDispatcher.dispatchEvent(createEvent); + + newChatNameInput.text = ""; + } ]]> @@ -225,6 +235,14 @@ with BigBlueButton; if not, see . + + + + + + @@ -237,6 +255,7 @@ with BigBlueButton; if not, see . toolTip="{ResourceUtil.getInstance().getString('bbb.chat.usersList.toolTip')}" accessibilityName="{ResourceUtil.getInstance().getString('bbb.chat.usersList.accessibilityName')}"/> + . . private var PUBLIC_CHAT_USERNAME:String = ResourceUtil.getInstance().getString("bbb.chat.publicChatUsername"); private var OPTION_TAB_ID:String = ResourceUtil.getInstance().getString("bbb.chat.optionsTabName"); - private var tabBox:AddChatTabBox; + private var tabBox:ChatOptionsTab; private var publicBox:ChatBox; private var focus:Boolean = true; private var focusSwitchTimer:Timer; @@ -361,8 +365,8 @@ with BigBlueButton; if not, see . return chatBox; } - private function createAddTabBox():AddChatTabBox { - tabBox = new AddChatTabBox(); + private function createAddTabBox():ChatOptionsTab { + tabBox = new ChatOptionsTab(); tabBox.chatView = this; tabBox.id = OPTION_TAB_ID; tabBox.label = OPTION_TAB_ID; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindow.mxml index 8cdcf44441..754a7341ef 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindow.mxml @@ -40,24 +40,22 @@ with BigBlueButton; if not, see . . override protected function resourcesChanged():void{ super.resourcesChanged(); - this.title = ResourceUtil.getInstance().getString("bbb.chat.title"); + if (_mainChatId == ChatModel.MAIN_PUBLIC_CHAT) { + this.title = ResourceUtil.getInstance().getString("bbb.chat.title"); + } if (titleBarOverlay != null) { titleBarOverlay.accessibilityName = ResourceUtil.getInstance().getString('bbb.chat.titleBar'); @@ -202,21 +202,9 @@ with BigBlueButton; if not, see . this.resizable = value; } - public function onCreateGCBtnClick():void { - var testChatName:String = "New Public Chat"; - var access:String = GroupChat.PUBLIC; - var users:Array = new Array(); - - var createEvent:CreateGroupChatReqEvent = - new CreateGroupChatReqEvent(testChatName, access, users); - disp.dispatchEvent(createEvent); - } - ]]> - From 929be96030008017e7a8472642adb9cf03854e3b Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Wed, 15 Nov 2017 20:59:14 +0100 Subject: [PATCH 2/3] Rename ChatBox to ChatTab. --- .../chat/views/{ChatBox.mxml => ChatTab.mxml} | 2 +- .../modules/chat/views/ChatView.mxml | 80 +++++++++---------- 2 files changed, 41 insertions(+), 41 deletions(-) rename bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/{ChatBox.mxml => ChatTab.mxml} (97%) diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatTab.mxml similarity index 97% rename from bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml rename to bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatTab.mxml index fccd7f2227..1e4b1c0bb5 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatBox.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatTab.mxml @@ -86,7 +86,7 @@ with BigBlueButton; if not, see . import org.bigbluebutton.modules.polling.events.StartCustomPollEvent; import org.bigbluebutton.util.i18n.ResourceUtil; - private static const LOGGER:ILogger = getClassLogger(ChatBox); + private static const LOGGER:ILogger = getClassLogger(ChatTab); public var chatWithUserID:String; public var chatWithUsername:String public var chatId: String = null; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml index 1a861eedd0..aa46530bbb 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatView.mxml @@ -79,8 +79,8 @@ with BigBlueButton; if not, see . private var PUBLIC_CHAT_USERNAME:String = ResourceUtil.getInstance().getString("bbb.chat.publicChatUsername"); private var OPTION_TAB_ID:String = ResourceUtil.getInstance().getString("bbb.chat.optionsTabName"); - private var tabBox:ChatOptionsTab; - private var publicBox:ChatBox; + private var chatOptionsTab:ChatOptionsTab; + private var publicChatTab:ChatTab; private var focus:Boolean = true; private var focusSwitchTimer:Timer; private var globalDispatcher:Dispatcher = new Dispatcher(); @@ -115,7 +115,7 @@ with BigBlueButton; if not, see . makePublicChatUncloseable(); if (openTabBox) { - createAddTabBox(); + addChatOptionsTab(); makeAddPrivateChatUncloseable(); } @@ -129,17 +129,17 @@ with BigBlueButton; if not, see . systemManager.stage.addEventListener(Event.DEACTIVATE, deactivate); } - private function getVisibleChatBox():ChatBox { - var chatBox:ChatBox = chatTabs.getChildAt(chatTabs.selectedIndex) as ChatBox; + private function getVisibleChatBox():ChatTab { + var chatBox:ChatTab = chatTabs.getChildAt(chatTabs.selectedIndex) as ChatTab; return chatBox; } - private function getPublicChatBox():ChatBox { - return publicBox; + private function getPublicChatBox():ChatTab { + return publicChatTab; } private function dispatchSaveChatEvent(e:Event):void { - var chatBox:ChatBox = getPublicChatBox(); + var chatBox:ChatTab = getPublicChatBox(); var saveEvent:ChatSaveEvent = new ChatSaveEvent(ChatSaveEvent.SAVE_CHAT_EVENT); if (chatBox.chatWithUsername == null || chatBox.chatWithUsername == "") { @@ -171,14 +171,14 @@ with BigBlueButton; if not, see . PUBLIC_CHAT_USERNAME = ResourceUtil.getInstance().getString("bbb.chat.publicChatUsername"); OPTION_TAB_ID = ResourceUtil.getInstance().getString("bbb.chat.optionsTabName"); - if (tabBox != null) { - tabBox.id = OPTION_TAB_ID; - tabBox.label = OPTION_TAB_ID; - tabBox.name = OPTION_TAB_ID; + if (chatOptionsTab != null) { + chatOptionsTab.id = OPTION_TAB_ID; + chatOptionsTab.label = OPTION_TAB_ID; + chatOptionsTab.name = OPTION_TAB_ID; } - if (publicBox != null) { - publicBox.label = PUBLIC_CHAT_USERNAME; + if (publicChatTab != null) { + publicChatTab.label = PUBLIC_CHAT_USERNAME; } } @@ -257,11 +257,11 @@ with BigBlueButton; if not, see . } private function calledOnTheNextScreenRefreshToMakeTabUncloseable():void { - chatTabs.setClosePolicyForTab(chatTabs.getChildIndex(tabBox), SuperTab.CLOSE_NEVER); + chatTabs.setClosePolicyForTab(chatTabs.getChildIndex(chatOptionsTab), SuperTab.CLOSE_NEVER); } private function calledOnTheNextScreenRefreshToMakePublicChatUncloseable():void { - var chatBox:ChatBox = getChatBoxForUser(mainChatId); + var chatBox:ChatTab = getChatBoxForUser(mainChatId); var chatIndex:int = getTabIndexFor(chatBox); chatTabs.setClosePolicyForTab(chatIndex, SuperTab.CLOSE_NEVER); } @@ -274,7 +274,7 @@ with BigBlueButton; if not, see . } private function notifyParticipantOfUnreadMessageFrom(chatId:String):void { - var chatBox:ChatBox = getChatBoxForUser(chatId); + var chatBox:ChatTab = getChatBoxForUser(chatId); var tabIndex:int = getTabIndexFor(chatBox); var tab:Button = chatTabs.getTabAt(tabIndex); tab.styleName = "highlightedTabStyle"; @@ -283,7 +283,7 @@ with BigBlueButton; if not, see . // However, the SuperTabNavigator does not cooperate with changes to it's accessibility properties. } - private function getTabIndexFor(chatBox:ChatBox):int { + private function getTabIndexFor(chatBox:ChatTab):int { return chatTabs.getChildIndex(chatBox); } @@ -306,13 +306,13 @@ with BigBlueButton; if not, see . } private function userHasChatBox(chatId:String):Boolean { - var chatBox:ChatBox = chatTabs.getChildByName(chatId) as ChatBox; + var chatBox:ChatTab = chatTabs.getChildByName(chatId) as ChatTab; if (chatBox != null) return true; return false; } - private function getChatBoxForUser(chatId:String):ChatBox { - return chatTabs.getChildByName(chatId) as ChatBox; + private function getChatBoxForUser(chatId:String):ChatTab { + return chatTabs.getChildByName(chatId) as ChatTab; } private function handleStartPrivateChatMessageEvent(event:CoreEvent):void { @@ -321,7 +321,7 @@ with BigBlueButton; if not, see . chatTabs.selectedIndex = tabIndex; } - public function openChatBoxFor(groupChatId:String, publicChat:Boolean=false):ChatBox { + public function openChatBoxFor(groupChatId:String, publicChat:Boolean=false):ChatTab { if (userHasChatBox(groupChatId)) { return getChatBoxForUser(groupChatId); } else { @@ -329,8 +329,8 @@ with BigBlueButton; if not, see . } } - private function createChatBoxFor(groupChatId:String, publicChat:Boolean = false):ChatBox { - var chatBox:ChatBox = new ChatBox(); + private function createChatBoxFor(groupChatId:String, publicChat:Boolean = false):ChatTab { + var chatBox:ChatTab = new ChatTab(); chatBox.name = groupChatId; chatBox.chatWithUserID = groupChatId; @@ -341,7 +341,7 @@ with BigBlueButton; if not, see . chatBox.chatId = groupChatId; chatBox.label = PUBLIC_CHAT_USERNAME chatBox.publicChat = true; - publicBox = chatBox; // keep a reference to the public chat box + publicChatTab = chatBox; // keep a reference to the public chat box } else { var gc:GroupChat = LiveMeeting.inst().chats.getGroupChat(groupChatId); if (gc != null) { @@ -360,22 +360,22 @@ with BigBlueButton; if not, see . chatTabs.addChild(chatBox); } // set the font size on tab opening - if (tabBox) - chatBox.setStyle("fontSize", int(tabBox.cmbFontSize.selectedItem)); + if (chatOptionsTab) + chatBox.setStyle("fontSize", int(chatOptionsTab.cmbFontSize.selectedItem)); return chatBox; } - private function createAddTabBox():ChatOptionsTab { - tabBox = new ChatOptionsTab(); - tabBox.chatView = this; - tabBox.id = OPTION_TAB_ID; - tabBox.label = OPTION_TAB_ID; - tabBox.name = OPTION_TAB_ID; - tabBox.chatOptions = chatOptions; - tabBox.tabIndexer.startIndex = tabIndexer.startIndex + 10; - chatTabs.addChild(tabBox); + private function addChatOptionsTab():ChatOptionsTab { + chatOptionsTab = new ChatOptionsTab(); + chatOptionsTab.chatView = this; + chatOptionsTab.id = OPTION_TAB_ID; + chatOptionsTab.label = OPTION_TAB_ID; + chatOptionsTab.name = OPTION_TAB_ID; + chatOptionsTab.chatOptions = chatOptions; + chatOptionsTab.tabIndexer.startIndex = tabIndexer.startIndex + 10; + chatTabs.addChild(chatOptionsTab); - return tabBox; + return chatOptionsTab; } @@ -432,12 +432,12 @@ with BigBlueButton; if not, see . } private function onTabClose(e:SuperTabEvent):void{ - var chatBox:ChatBox = chatTabs.getChildAt(e.tabIndex) as ChatBox; + var chatBox:ChatTab = chatTabs.getChildAt(e.tabIndex) as ChatTab; dispatchEvent(e); } private function onUserClosedTab(e:SuperTabEvent):void{ - var chatBox:ChatBox = chatTabs.getChildAt(e.tabIndex) as ChatBox; + var chatBox:ChatTab = chatTabs.getChildAt(e.tabIndex) as ChatTab; globalDispatcher.dispatchEvent(new GroupChatBoxClosedEvent(chatBox.chatId, chatBox.parentWindowId)); } @@ -458,7 +458,7 @@ with BigBlueButton; if not, see . private function remoteClosePrivate(e:ShortcutEvent):void { var selectedTab:INavigatorContent = chatTabs.selectedChild; - if (selectedTab is ChatBox && !(selectedTab as ChatBox).publicChat) { + if (selectedTab is ChatTab && !(selectedTab as ChatTab).publicChat) { chatTabs.removeChild(selectedTab as DisplayObject); } } From 7124d8b12fe09d2f65757cb8c72ddacd80efe895 Mon Sep 17 00:00:00 2001 From: Ghazi Triki Date: Wed, 15 Nov 2017 21:51:46 +0100 Subject: [PATCH 3/3] Show group chat in options tab. --- .../locale/en_US/bbbResources.properties | 4 +- .../resources/config.xml.template | 1 + .../modules/chat/model/ChatOptions.as | 3 + .../modules/chat/views/ChatOptionsTab.mxml | 81 +++++--- .../chat/views/ChatWindowEventHandler.as | 187 +++++++++++------- .../modules/chat/views/UserRenderer.mxml | 33 ---- .../modules/chat/views/model/GroupChatData.as | 29 +++ 7 files changed, 203 insertions(+), 135 deletions(-) mode change 100755 => 100644 bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindowEventHandler.as delete mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/UserRenderer.mxml create mode 100644 bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/model/GroupChatData.as diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index 78286a728a..4c20dc8c94 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -349,8 +349,10 @@ bbb.chat.private.userJoined = The user has joined. bbb.chat.private.closeMessage = You can close this tab by using the key combination {0}. bbb.chat.usersList.toolTip = Select User To Open Private Chat bbb.chat.usersList.accessibilityName = Select user to open private chat. Use the arrow keys to navigate. +bbb.chat.groupChatList.toolTip = Select a group chat to open +bbb.chat.groupChatList.accessibilityName = Select a group chat to open. Use the arrow keys to navigate. bbb.chat.chatOptions = Chat Options -bbb.chat.newChat.label = New Public Chat +bbb.chat.newChat.label = New Group Chat bbb.chat.newChat.create = Create bbb.chat.fontSize = Chat Message Font Size bbb.chat.cmbFontSize.toolTip = Select Chat Message Font Size diff --git a/bigbluebutton-client/resources/config.xml.template b/bigbluebutton-client/resources/config.xml.template index 210cbf0010..9335235916 100755 --- a/bigbluebutton-client/resources/config.xml.template +++ b/bigbluebutton-client/resources/config.xml.template @@ -30,6 +30,7 @@ uri="rtmp://HOST/bigbluebutton" dependsOn="UsersModule" privateEnabled="true" + groupEnabled="true" fontSize="14" baseTabIndex="801" colorPickerIsVisible="false" diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as index e2500e0cc8..279e9e4c7d 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/model/ChatOptions.as @@ -24,6 +24,9 @@ package org.bigbluebutton.modules.chat.model { [Bindable] public var privateEnabled:Boolean = true; + + [Bindable] + public var groupEnabled:Boolean = true; [Bindable] public var fontSize:String = "14"; diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatOptionsTab.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatOptionsTab.mxml index 97c3f707e6..aa99ff516d 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatOptionsTab.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatOptionsTab.mxml @@ -30,7 +30,7 @@ with BigBlueButton; if not, see . - + @@ -63,7 +63,8 @@ with BigBlueButton; if not, see . private static const LOGGER:ILogger = getClassLogger(ChatOptionsTab); - [Bindable] public var users:ArrayCollection; + [Bindable] public var users:ArrayCollection; + [Bindable] public var groupChats:ArrayCollection; [Bindable] public var chatView:ChatView; [Bindable] private var fontSizes:Array = ['8', '10', '12', '14', '16', '18']; @@ -102,8 +103,10 @@ with BigBlueButton; if not, see . private function onCreationComplete():void{ clrBtnVisible = UsersUtil.amIModerator(); - handler.populateAllUsers() + handler.populateAllUsers() + handler.populateAllGroupChats() users = removeMe(handler.users); + groupChats = handler.groupChats; chatOptions = Options.getOptions(ChatOptions) as ChatOptions; if (!chatOptions.privateEnabled) { @@ -139,30 +142,42 @@ with BigBlueButton; if not, see . LOGGER.debug("changing chat noise, active=" + chatNoiseCheckBox.selected); dispatchEvent(new ChatNoiseEnabledEvent(chatNoiseCheckBox.selected)); } - - protected function openPrivateChat(event:Event):void{ - if (usersList.selectedIndex == -1) return; - - if (!usersList.visible || !usersList.enabled) return; - - var chatWithIntId:String = usersList.selectedItem.userId; - - // Don't want to be chatting with ourself. - if (UsersUtil.isMe(chatWithIntId)) return; - - usersList.selectedIndex = -1; - - var testChatName:String = "Test Private Chat"; - var access:String = GroupChat.PRIVATE; - var users:Array = new Array(); - users.push(chatWithIntId); - - var createEvent:CreateGroupChatReqEvent = - new CreateGroupChatReqEvent(testChatName, access, users); - globalDispatcher.dispatchEvent(createEvent); - - } - + + protected function openPrivateChat(event:Event):void { + if (usersList.selectedIndex == -1) + return; + + if (!usersList.visible || !usersList.enabled) + return; + + var chatWithIntId:String = usersList.selectedItem.userId; + + // Don't want to be chatting with ourself. + if (UsersUtil.isMe(chatWithIntId)) + return; + + usersList.selectedIndex = -1; + + // @fixme : need to use a better chat name + var testChatName:String = "Test Private Chat"; + var access:String = GroupChat.PRIVATE; + var users:Array = new Array(); + users.push(chatWithIntId); + + var createEvent:CreateGroupChatReqEvent = new CreateGroupChatReqEvent(testChatName, access, users); + globalDispatcher.dispatchEvent(createEvent); + } + + protected function openGroupChat(event:Event):void { + + } + + public function onGroupChatListKeyDown(event:KeyboardEvent):void{ + if (event.keyCode == 32){ + // openGroupChat(event); + } + } + /** * For the Options tab focus the users list instead of the text area. **/ @@ -235,7 +250,7 @@ with BigBlueButton; if not, see . - + . - + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindowEventHandler.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindowEventHandler.as old mode 100755 new mode 100644 index a00e298ced..d0cae72ae6 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindowEventHandler.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/ChatWindowEventHandler.as @@ -1,72 +1,117 @@ -package org.bigbluebutton.modules.chat.views -{ - import mx.collections.ArrayCollection; - - import org.bigbluebutton.core.UsersUtil; - import org.bigbluebutton.core.model.LiveMeeting; - import org.bigbluebutton.core.model.users.User2x; - import org.bigbluebutton.main.events.UserJoinedEvent; - import org.bigbluebutton.modules.chat.views.model.ChatUser; +package org.bigbluebutton.modules.chat.views { + import mx.collections.ArrayCollection; - public class ChatWindowEventHandler - { - [Bindable] public var users:ArrayCollection = new ArrayCollection(); - - - public function ChatWindowEventHandler() - { - users.refresh(); - } - - public function populateAllUsers():void { - getAllWebUsers(); - } - - private function getAllWebUsers():void { - var userIds: Array = LiveMeeting.inst().users.getUserIds(); - - for (var i:int = 0; i < userIds.length; i++) { - var userId: String = userIds[i] as String; - var user: User2x = UsersUtil.getUser2x(userId); - addUser(users, user); - } - - users.refresh(); - } - - public function handleUserJoinedEvent(event: UserJoinedEvent):void { - var user: User2x = UsersUtil.getUser(event.userID); - if (user != null) { - addUser(users, user); - users.refresh(); - } - } - - private function addUser(users: ArrayCollection, user: User2x):void { - var buser: ChatUser = new ChatUser(); - buser.userId = user.intId; - buser.name = user.name; - - // We want to remove the user if it's already in the collection and re-add it. - removeUser(user.intId, users); - - users.addItem(buser); - } - - private function removeUser(userId:String, users: ArrayCollection):void { - for (var i:int = 0; i < users.length; i++) { - var user:ChatUser = users.getItemAt(i) as ChatUser; - if (user.userId == userId) { - users.removeItemAt(i); - users.refresh(); - return; - } - } - } - - public function handleUserLeftEvent(userId: String):void { - removeUser(userId, users); - } - - } -} \ No newline at end of file + import org.bigbluebutton.core.UsersUtil; + import org.bigbluebutton.core.model.LiveMeeting; + import org.bigbluebutton.core.model.users.User2x; + import org.bigbluebutton.main.events.UserJoinedEvent; + import org.bigbluebutton.modules.chat.model.ChatModel; + import org.bigbluebutton.modules.chat.model.GroupChat; + import org.bigbluebutton.modules.chat.views.model.ChatUser; + import org.bigbluebutton.modules.chat.views.model.GroupChatData; + + public class ChatWindowEventHandler { + + [Bindable] + public var users:ArrayCollection = new ArrayCollection(); + + [Bindable] + public var groupChats:ArrayCollection = new ArrayCollection(); + + public function ChatWindowEventHandler() { + users.refresh(); + groupChats.refresh(); + } + + public function populateAllUsers():void { + getAllWebUsers(); + } + + public function populateAllGroupChats():void { + getAllGroupChats(); + } + + private function getAllWebUsers():void { + var userIds:Array = LiveMeeting.inst().users.getUserIds(); + + for (var i:int = 0; i < userIds.length; i++) { + var userId:String = userIds[i] as String; + var user:User2x = UsersUtil.getUser2x(userId); + addUser(users, user); + } + + users.refresh(); + } + + public function handleUserJoinedEvent(event:UserJoinedEvent):void { + var user:User2x = UsersUtil.getUser(event.userID); + if (user != null) { + addUser(users, user); + users.refresh(); + } + } + + private function addUser(users:ArrayCollection, user:User2x):void { + var buser:ChatUser = new ChatUser(); + buser.userId = user.intId; + buser.name = user.name; + + // We want to remove the user if it's already in the collection and re-add it. + removeUser(user.intId, users); + + users.addItem(buser); + } + + private function addGroupChat(groupChats:ArrayCollection, groupChat:GroupChat):void { + var chatData:GroupChatData = new GroupChatData(); + chatData.chatId = groupChat.id; + chatData.name = groupChat.name; + + // We want to remove the group chat if it's already in the collection and re-add it. + removeGroupChat(groupChat.id, groupChats); + + groupChats.addItem(chatData); + } + + private function removeUser(userId:String, users:ArrayCollection):void { + for (var i:int = 0; i < users.length; i++) { + var user:ChatUser = users.getItemAt(i) as ChatUser; + if (user.userId == userId) { + users.removeItemAt(i); + users.refresh(); + return; + } + } + } + + private function removeGroupChat(chatId:String, groupChats:ArrayCollection):void { + for (var i:int = 0; i < groupChats.length; i++) { + var groupChat:GroupChatData = groupChats.getItemAt(i) as GroupChatData; + if (groupChat.chatId == chatId) { + groupChats.removeItemAt(i); + groupChats.refresh(); + return; + } + } + } + + public function handleUserLeftEvent(userId:String):void { + removeUser(userId, users); + } + + public function getAllGroupChats():void { + var chatIds:Array = LiveMeeting.inst().chats.getGroupChatIds(); + + for (var i:int = 0; i < chatIds.length; i++) { + var chatId:String = chatIds[i] as String; + if (chatId != ChatModel.MAIN_PUBLIC_CHAT) { + var groupChat:GroupChat = LiveMeeting.inst().chats.getGroupChat(chatId); + addGroupChat(groupChats, groupChat); + } + } + + groupChats.refresh(); + } + + } +} diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/UserRenderer.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/UserRenderer.mxml deleted file mode 100755 index 40c031278d..0000000000 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/UserRenderer.mxml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/model/GroupChatData.as b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/model/GroupChatData.as new file mode 100644 index 0000000000..f6bc035eb9 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/chat/views/model/GroupChatData.as @@ -0,0 +1,29 @@ +/** + * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ + * + * Copyright (c) 2017 BigBlueButton Inc. and by respective authors (see below). + * + * This program is free software; you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3.0 of the License, or (at your option) any later + * version. + * + * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with BigBlueButton; if not, see . + * + */ +package org.bigbluebutton.modules.chat.views.model { + + public class GroupChatData { + + [Bindable] + public var chatId:String; + + [Bindable] + public var name:String; + } +}