Merge branch 'riadvice-chat-tabs'

This commit is contained in:
Richard Alam 2017-11-15 14:04:03 -08:00
commit 06640a445b
11 changed files with 312 additions and 227 deletions

View File

@ -581,7 +581,7 @@ views|ClientStatusItemRenderer {
//------------------------------
*/
chat|AddChatTabBox {
chat|ChatOptionsTab {
verticalGap : 20;
paddingLeft : 20;
paddingRight : 20;

View File

@ -349,7 +349,11 @@ 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 Group 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

View File

@ -30,6 +30,7 @@
uri="rtmp://HOST/bigbluebutton"
dependsOn="UsersModule"
privateEnabled="true"
groupEnabled="true"
fontSize="14"
baseTabIndex="801"
colorPickerIsVisible="false"

View File

@ -25,6 +25,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";

View File

@ -36,35 +36,35 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import com.asfusion.mate.events.Dispatcher;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.events.CloseEvent;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.EventConstants;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.events.CoreEvent;
import org.bigbluebutton.core.events.LockControlEvent;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.main.events.UserJoinedEvent;
import org.bigbluebutton.main.events.UserLeftEvent;
import org.bigbluebutton.main.model.users.events.ChangeMyRole;
import org.bigbluebutton.modules.chat.events.ChatNoiseEnabledEvent;
import org.bigbluebutton.modules.chat.events.ChatOptionsEvent;
import org.bigbluebutton.modules.chat.events.ChatToolbarButtonEvent;
import org.bigbluebutton.modules.chat.events.CreateGroupChatReqEvent;
import org.bigbluebutton.modules.chat.model.ChatOptions;
import org.bigbluebutton.modules.chat.model.GroupChat;
import org.bigbluebutton.modules.chat.views.model.ChatUser;
import org.bigbluebutton.util.i18n.ResourceUtil;
import org.as3commons.lang.StringUtils;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
import org.bigbluebutton.core.events.LockControlEvent;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.main.events.UserJoinedEvent;
import org.bigbluebutton.main.events.UserLeftEvent;
import org.bigbluebutton.main.model.users.events.ChangeMyRole;
import org.bigbluebutton.modules.chat.events.ChatNoiseEnabledEvent;
import org.bigbluebutton.modules.chat.events.ChatOptionsEvent;
import org.bigbluebutton.modules.chat.events.ChatToolbarButtonEvent;
import org.bigbluebutton.modules.chat.events.CreateGroupChatReqEvent;
import org.bigbluebutton.modules.chat.model.ChatOptions;
import org.bigbluebutton.modules.chat.model.GroupChat;
import org.bigbluebutton.modules.chat.views.model.ChatUser;
import org.bigbluebutton.util.i18n.ResourceUtil;
private static const LOGGER:ILogger = getClassLogger(AddChatTabBox);
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'];
@ -103,8 +103,10 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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) {
@ -141,28 +143,40 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
dispatchEvent(new ChatNoiseEnabledEvent(chatNoiseCheckBox.selected));
}
protected function openPrivateChat(event:Event):void{
if (usersList.selectedIndex == -1) return;
protected function openPrivateChat(event:Event):void {
if (usersList.selectedIndex == -1)
return;
if (!usersList.visible || !usersList.enabled) return;
if (!usersList.visible || !usersList.enabled)
return;
var chatWithIntId:String = usersList.selectedItem.userId;
var chatWithIntId:String = usersList.selectedItem.userId;
// Don't want to be chatting with ourself.
if (UsersUtil.isMe(chatWithIntId)) return;
// Don't want to be chatting with ourself.
if (UsersUtil.isMe(chatWithIntId))
return;
usersList.selectedIndex = -1;
usersList.selectedIndex = -1;
var testChatName:String = "Test Private Chat";
var access:String = GroupChat.PRIVATE;
var users:Array = new Array();
users.push(chatWithIntId);
// @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);
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.
@ -218,6 +232,17 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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 = "";
}
]]>
</fx:Script>
@ -225,18 +250,33 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<common:TabIndexer id="tabIndexer" startIndex="1" tabIndices="{[usersList, cmbFontSize, chatNoiseCheckBox, saveBtn, copyBtn, clearBtn]}"/>
</fx:Declarations>
<mx:HBox width="100%" verticalAlign="middle" visible="{chatOptions.groupEnabled}" includeInLayout="{chatOptions.groupEnabled}">
<mx:Label text="{ResourceUtil.getInstance().getString('bbb.chat.newChat.label')}"/>
<mx:TextInput id="newChatNameInput" width="100%"/>
<mx:Button id="createChatGroupBtn" label="{ResourceUtil.getInstance().getString('bbb.chat.newChat.create')}"
styleName="mainActionButton" height="30"
enabled="{!StringUtils.isEmpty(newChatNameInput.text)}" click="onCreateChatBtnClick()" />
</mx:HBox>
<mx:Label id="lblSelect" styleName="chatOptionsLabel"
text="{ResourceUtil.getInstance().getString('bbb.chat.privateChatSelect')}"
visible="{chatOptions.privateEnabled}" includeInLayout="{chatOptions.privateEnabled}"/>
<mx:List id="usersList" height="50%" width="100%" dataProvider="{users}" dragEnabled="false"
<mx:List id="usersList" width="100%" dataProvider="{users}" dragEnabled="false"
visible="{chatOptions.privateEnabled}" includeInLayout="{chatOptions.privateEnabled}"
itemRenderer="org.bigbluebutton.modules.chat.views.UserRenderer"
labelField="name"
itemClick="openPrivateChat(event)"
keyDown="onUserListKeyDown(event)"
toolTip="{ResourceUtil.getInstance().getString('bbb.chat.usersList.toolTip')}"
accessibilityName="{ResourceUtil.getInstance().getString('bbb.chat.usersList.accessibilityName')}"/>
<mx:List id="groupChatList" width="100%" dataProvider="{groupChats}" dragEnabled="false"
visible="{chatOptions.groupEnabled}" includeInLayout="{chatOptions.groupEnabled}"
labelField="name"
itemClick="openGroupChat(event)"
keyDown="onGroupChatListKeyDown(event)"
toolTip="{ResourceUtil.getInstance().getString('bbb.chat.groupChatList.toolTip')}"
accessibilityName="{ResourceUtil.getInstance().getString('bbb.chat.groupChatList.accessibilityName')}"/>
<mx:Label styleName="chatOptionsLabel" text="{ResourceUtil.getInstance().getString('bbb.chat.chatOptions')}" />
<mx:HBox width="100%">
<mx:Label styleName="chatOptionsLabel" text="{ResourceUtil.getInstance().getString('bbb.chat.fontSize')}" width="100%"/>
<mx:ComboBox width="60" id="cmbFontSize" dataProvider="{fontSizes}" change="changeFontSize()"

View File

@ -50,9 +50,13 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import flash.events.TextEvent;
import mx.binding.utils.BindingUtils;
import flashx.textLayout.formats.Direction;
import org.as3commons.lang.StringUtils;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
@ -82,7 +86,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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;

View File

@ -45,13 +45,17 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import flash.events.Event;
import flash.events.FocusEvent;
import flash.media.Sound;
import mx.controls.Button;
import mx.core.INavigatorContent;
import flexlib.controls.tabBarClasses.SuperTab;
import flexlib.events.SuperTabEvent;
import org.bigbluebutton.core.EventConstants;
import org.bigbluebutton.core.Options;
import org.bigbluebutton.core.UsersUtil;
@ -75,8 +79,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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 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();
@ -111,7 +115,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
makePublicChatUncloseable();
if (openTabBox) {
createAddTabBox();
addChatOptionsTab();
makeAddPrivateChatUncloseable();
}
@ -125,17 +129,17 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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 == "") {
@ -167,14 +171,14 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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;
}
}
@ -253,11 +257,11 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
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);
}
@ -270,7 +274,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
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";
@ -279,7 +283,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
// 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);
}
@ -302,13 +306,13 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
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 {
@ -317,7 +321,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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 {
@ -325,8 +329,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
}
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;
@ -337,7 +341,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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) {
@ -356,22 +360,22 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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():AddChatTabBox {
tabBox = new AddChatTabBox();
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;
}
@ -428,12 +432,12 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
}
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));
}
@ -454,7 +458,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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);
}
}

View File

@ -40,24 +40,22 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<fx:Script>
<![CDATA[
import com.asfusion.mate.events.Dispatcher;
import com.asfusion.mate.events.Dispatcher;
import org.bigbluebutton.common.IBbbModuleWindow;
import org.bigbluebutton.common.events.LocaleChangeEvent;
import org.bigbluebutton.core.KeyboardUtil;
import org.bigbluebutton.core.model.LiveMeeting;
import org.bigbluebutton.main.events.ShortcutEvent;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.chat.events.CreateGroupChatReqEvent;
import org.bigbluebutton.modules.chat.model.ChatModel;
import org.bigbluebutton.modules.chat.model.ChatOptions;
import org.bigbluebutton.modules.chat.model.GroupChat;
import org.bigbluebutton.util.i18n.ResourceUtil;
import org.bigbluebutton.common.IBbbModuleWindow;
import org.bigbluebutton.common.events.LocaleChangeEvent;
import org.bigbluebutton.core.KeyboardUtil;
import org.bigbluebutton.main.events.ShortcutEvent;
import org.bigbluebutton.main.views.MainCanvas;
import org.bigbluebutton.modules.chat.model.ChatModel;
import org.bigbluebutton.modules.chat.model.ChatOptions;
import org.bigbluebutton.util.i18n.ResourceUtil;
private var _xPosition:int;
private var _yPosition:int;
private var keyCombos:Object;
private var disp:Dispatcher = new Dispatcher();
[Bindable] public var chatOptions:ChatOptions;
[Bindable] private var _windowId: String;
@ -155,7 +153,9 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
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 <http://www.gnu.org/licenses/>.
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);
}
]]>
</fx:Script>
<mx:VBox width="100%" height="100%">
<mx:Button id="createGCBtn" label="Create" height="20" click="onCreateGCBtnClick()"
includeInLayout="{_mainChatId == ChatModel.MAIN_PUBLIC_CHAT}"/>
<views:ChatView id="chatView" chatOptions="{chatOptions}" mainChatId="{_mainChatId}"
windowId="{_windowId}"
openTabBox="{_openAddTabBox}" includeInLayout="true"/>

View File

@ -1,72 +1,117 @@
package org.bigbluebutton.modules.chat.views
{
import mx.collections.ArrayCollection;
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;
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();
public class ChatWindowEventHandler {
[Bindable]
public var users:ArrayCollection = new ArrayCollection();
public function ChatWindowEventHandler()
{
users.refresh();
}
[Bindable]
public var groupChats:ArrayCollection = new ArrayCollection();
public function populateAllUsers():void {
getAllWebUsers();
}
public function ChatWindowEventHandler() {
users.refresh();
groupChats.refresh();
}
private function getAllWebUsers():void {
var userIds: Array = LiveMeeting.inst().users.getUserIds();
public function populateAllUsers():void {
getAllWebUsers();
}
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);
}
public function populateAllGroupChats():void {
getAllGroupChats();
}
users.refresh();
}
private function getAllWebUsers():void {
var userIds:Array = LiveMeeting.inst().users.getUserIds();
public function handleUserJoinedEvent(event: UserJoinedEvent):void {
var user: User2x = UsersUtil.getUser(event.userID);
if (user != null) {
addUser(users, user);
users.refresh();
}
}
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);
}
private function addUser(users: ArrayCollection, user: User2x):void {
var buser: ChatUser = new ChatUser();
buser.userId = user.intId;
buser.name = user.name;
users.refresh();
}
// We want to remove the user if it's already in the collection and re-add it.
removeUser(user.intId, users);
public function handleUserJoinedEvent(event:UserJoinedEvent):void {
var user:User2x = UsersUtil.getUser(event.userID);
if (user != null) {
addUser(users, user);
users.refresh();
}
}
users.addItem(buser);
}
private function addUser(users:ArrayCollection, user:User2x):void {
var buser:ChatUser = new ChatUser();
buser.userId = user.intId;
buser.name = user.name;
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;
}
}
}
// We want to remove the user if it's already in the collection and re-add it.
removeUser(user.intId, users);
public function handleUserLeftEvent(userId: String):void {
removeUser(userId, 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();
}
}
}

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
Copyright (c) 2012 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 <http://www.gnu.org/licenses/>.
-->
<mx:HBox xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:fx="http://ns.adobe.com/mxml/2009"
verticalScrollPolicy="off" horizontalScrollPolicy="off">
<!-- No 'me' property on the User2x class -->
<!--
<mx:Label id="nameLabel" textAlign="left" text="{data.name} {data.me ? '(' + ResourceUtil.getInstance().getString('bbb.users.usersGrid.nameItemRenderer.youIdentifier') + ')' : ''}"
fontWeight="{data.me ? 'bold' : 'normal'}"
color="{data.me ? 0x003399 : 0x000000}"/>
-->
<mx:Label id="nameLabel" textAlign="left" text="{data.name}"
fontWeight="{'normal'}"/>
</mx:HBox>

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.modules.chat.views.model {
public class GroupChatData {
[Bindable]
public var chatId:String;
[Bindable]
public var name:String;
}
}