Started the GUI implementation of AudioSettingsView.

This commit is contained in:
Ghazi Triki 2016-12-17 14:43:21 +01:00
parent c8e34b199c
commit 1fd917eec7
11 changed files with 236 additions and 332 deletions

View File

@ -10,6 +10,8 @@ package org.bigbluebutton.air.main.views {
private var _background:Rect; private var _background:Rect;
public function TopToolbarAIR() { public function TopToolbarAIR() {
super();
_background = new Rect(); _background = new Rect();
_background.percentHeight = 100; _background.percentHeight = 100;
_background.percentWidth = 100; _background.percentWidth = 100;

View File

@ -2,9 +2,13 @@ package org.bigbluebutton.air.settings {
import org.bigbluebutton.air.settings.views.SettingsViewMediatorAIR; import org.bigbluebutton.air.settings.views.SettingsViewMediatorAIR;
import org.bigbluebutton.air.settings.views.TopToolbarMediatorSettings; import org.bigbluebutton.air.settings.views.TopToolbarMediatorSettings;
import org.bigbluebutton.air.settings.views.TopToolbarMediatorSubSettings;
import org.bigbluebutton.air.settings.views.TopToolbarSettings; import org.bigbluebutton.air.settings.views.TopToolbarSettings;
import org.bigbluebutton.air.settings.views.TopToolbarSubSettings;
import org.bigbluebutton.air.settings.views.audio.AudioSettingsViewMediatorAIR;
import org.bigbluebutton.lib.main.views.TopToolbarBase; import org.bigbluebutton.lib.main.views.TopToolbarBase;
import org.bigbluebutton.lib.settings.views.SettingsViewBase; import org.bigbluebutton.lib.settings.views.SettingsViewBase;
import org.bigbluebutton.lib.settings.views.audio.AudioSettingsViewBase;
import robotlegs.bender.extensions.matching.TypeMatcher; import robotlegs.bender.extensions.matching.TypeMatcher;
import robotlegs.bender.extensions.mediatorMap.api.IMediatorMap; import robotlegs.bender.extensions.mediatorMap.api.IMediatorMap;
@ -28,7 +32,9 @@ package org.bigbluebutton.air.settings {
*/ */
private function mediators():void { private function mediators():void {
mediatorMap.map(SettingsViewBase).toMediator(SettingsViewMediatorAIR); mediatorMap.map(SettingsViewBase).toMediator(SettingsViewMediatorAIR);
mediatorMap.map(AudioSettingsViewBase).toMediator(AudioSettingsViewMediatorAIR);
mediatorMap.mapMatcher(new TypeMatcher().allOf(TopToolbarBase, TopToolbarSettings)).toMediator(TopToolbarMediatorSettings); mediatorMap.mapMatcher(new TypeMatcher().allOf(TopToolbarBase, TopToolbarSettings)).toMediator(TopToolbarMediatorSettings);
mediatorMap.mapMatcher(new TypeMatcher().allOf(TopToolbarBase, TopToolbarSubSettings)).toMediator(TopToolbarMediatorSubSettings);
} }
} }
} }

View File

@ -0,0 +1,18 @@
package org.bigbluebutton.air.settings.views {
import flash.events.MouseEvent;
import org.bigbluebutton.air.common.PageEnum;
import org.bigbluebutton.air.main.views.TopToolbarMediatorAIR;
public class TopToolbarMediatorSubSettings extends TopToolbarMediatorAIR {
override protected function leftButtonClickHandler(e:MouseEvent):void {
uiSession.pushPage(PageEnum.SETTINGS);
}
override protected function rightButtonClickHandler(e:MouseEvent):void {
// @todo: add save logic
uiSession.pushPage(PageEnum.SETTINGS);
}
}
}

View File

@ -0,0 +1,22 @@
package org.bigbluebutton.air.settings.views {
import mx.core.FlexGlobals;
import org.bigbluebutton.air.main.views.TopToolbarAIR;
public class TopToolbarSubSettings extends TopToolbarAIR {
public function TopToolbarSubSettings() {
super();
leftButton.styleName = "icon-left-arrow topButton topLeftButton";
rightButton.styleName = "topButton topRightButton";
}
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
rightButton.setStyle("iconFont", FlexGlobals.topLevelApplication["getStyle"]("fontFamily"));
rightButton.setStyle("fontFamily", FlexGlobals.topLevelApplication["getStyle"]("fontFamily"));
rightButton.label = "SAVE";
}
}
}

View File

@ -1,41 +1,32 @@
package org.bigbluebutton.air.settings.views.audio { package org.bigbluebutton.air.settings.views.audio {
import spark.components.Button; import spark.layouts.HorizontalAlign;
import spark.components.HSlider; import spark.layouts.VerticalLayout;
import spark.components.ToggleSwitch;
import spark.primitives.Rect;
public class AudioSettingsView extends AudioSettingsViewBase implements IAudioSettingsView { import org.bigbluebutton.air.common.views.NoTabView;
import org.bigbluebutton.air.main.views.TopToolbarAIR;
import org.bigbluebutton.air.settings.views.TopToolbarSubSettings;
import org.bigbluebutton.lib.settings.views.audio.AudioSettingsViewBase;
public class AudioSettingsView extends NoTabView {
private var _settingsView:AudioSettingsViewBase;
public function dispose():void { public function AudioSettingsView() {
super();
var vLayout:VerticalLayout = new VerticalLayout();
vLayout.gap = 0;
vLayout.horizontalAlign = HorizontalAlign.CENTER;
layout = vLayout;
_settingsView = new AudioSettingsViewBase();
_settingsView.percentHeight = 100;
_settingsView.percentWidth = 100;
addElement(_settingsView);
} }
public function get enableMic():ToggleSwitch { override protected function createToolbar():TopToolbarAIR {
return enableMic0; return new TopToolbarSubSettings();
}
public function get enableAudio():ToggleSwitch {
return enableAudio0;
}
public function get enablePushToTalk():ToggleSwitch {
return enablePushToTalk0;
}
public function get continueBtn():Button {
return continueToMeeting;
}
public function get gainSlider():HSlider {
return gainSlider0;
}
public function get micActivity():Rect {
return micActivity0;
}
public function get micActivityMask():Rect {
return micActivityMask0;
} }
} }
} }

View File

@ -1,125 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<views:NoTabView xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:views="org.bigbluebutton.air.common.views.*"
styleName="audioSettings">
<s:Scroller width="100%"
height="100%">
<s:VGroup width="100%"
height="100%"
horizontalAlign="center">
<s:Line width="90%">
<s:stroke>
<s:SolidColorStroke color="{getStyle('lineColor')}"
weight="{getStyle('lineWeight')}" />
</s:stroke>
</s:Line>
<s:HGroup width="90%"
height="7%"
verticalAlign="middle"
horizontalAlign="right">
<s:Label width="100%"
text="{resourceManager.getString('resources', 'audioSettings.enableAudio')}" />
<s:ToggleSwitch id="enableAudio0" />
</s:HGroup>
<s:Line width="90%">
<s:stroke>
<s:SolidColorStroke color="{getStyle('lineColor')}"
weight="{getStyle('lineWeight')}" />
</s:stroke>
</s:Line>
<s:HGroup width="90%"
height="7%"
verticalAlign="middle"
horizontalAlign="right">
<s:Label width="100%"
text="{resourceManager.getString('resources', 'audioSettings.enableMic')}" />
<s:ToggleSwitch id="enableMic0" />
</s:HGroup>
<s:Line width="90%">
<s:stroke>
<s:SolidColorStroke color="{getStyle('lineColor')}"
weight="{getStyle('lineWeight')}" />
</s:stroke>
</s:Line>
<s:HGroup width="90%"
height="7%"
verticalAlign="middle"
horizontalAlign="right">
<s:Label width="100%"
text="{resourceManager.getString('resources', 'audioSettings.pushToTalk')}" />
<s:ToggleSwitch id="enablePushToTalk0" />
</s:HGroup>
<s:Line width="90%">
<s:stroke>
<s:SolidColorStroke color="{getStyle('lineColor')}"
weight="{getStyle('lineWeight')}" />
</s:stroke>
</s:Line>
<s:HGroup width="90%"
height="7%"
verticalAlign="middle"
horizontalAlign="right">
<s:Label width="100%"
text="{resourceManager.getString('resources', 'audioSettings.micGain')}" />
<s:Rect id="micActivity0"
height="{gainSlider0.height/2}"
width="{gainSlider0.width}"
includeInLayout="false"
x="{gainSlider0.x}"
y="{gainSlider0.y + micActivity0.height/2}">
<s:fill>
<s:LinearGradient>
<s:GradientEntry color="{getStyle('greenColor')}"
ratio="0.00" />
<s:GradientEntry color="{getStyle('yellowColor')}"
ratio="0.8" />
<s:GradientEntry color="{getStyle('redColor')}"
ratio="1" />
</s:LinearGradient>
</s:fill>
</s:Rect>
<s:Rect id="micActivityMask0"
height="{micActivity0.height}"
width="{micActivity0.width}"
includeInLayout="false"
x="{micActivity0.x}"
y="{micActivity0.y}">
<s:fill>
<s:SolidColor color="#FFFFFF" />
</s:fill>
</s:Rect>
<s:HSlider id="gainSlider0"
width="90%"
value="5"
skinClass="spark.skins.android4.HSliderSkin" />
</s:HGroup>
<s:Line width="90%">
<s:stroke>
<s:SolidColorStroke color="{getStyle('lineColor')}"
weight="{getStyle('lineWeight')}" />
</s:stroke>
</s:Line>
<s:Spacer height="10%" />
<s:Button id="continueToMeeting"
width="90%"
label="{resourceManager.getString('resources', 'audioSettings.continue')}"
styleName="userSettingsButton logoutButton contentFontSize" />
</s:VGroup>
</s:Scroller>
</views:NoTabView>

View File

@ -1,156 +0,0 @@
package org.bigbluebutton.air.settings.views.audio {
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.core.FlexGlobals;
import mx.resources.ResourceManager;
import org.bigbluebutton.air.main.models.IUISession;
import org.bigbluebutton.lib.common.models.ISaveData;
import org.bigbluebutton.lib.main.models.IUserSession;
import org.bigbluebutton.lib.user.models.User;
import org.bigbluebutton.lib.user.models.UserList;
import org.bigbluebutton.lib.voice.commands.ShareMicrophoneSignal;
import robotlegs.bender.bundles.mvcs.Mediator;
public class AudioSettingsViewMediator extends Mediator {
[Inject]
public var view:IAudioSettingsView;
[Inject]
public var userSession:IUserSession;
[Inject]
public var userUISession:IUISession;
[Inject]
public var saveData:ISaveData;
[Inject]
public var shareMicrophoneSignal:ShareMicrophoneSignal;
private var micActivityTimer:Timer = null;
override public function initialize():void {
userSession.userList.userChangeSignal.add(userChangeHandler);
FlexGlobals.topLevelApplication.topActionBar.pageName.text = ResourceManager.getInstance().getString('resources', 'audioSettings.title');
var userMe:User = userSession.userList.me;
view.continueBtn.addEventListener(MouseEvent.CLICK, onContinueClick);
view.enableAudio.addEventListener(Event.CHANGE, onEnableAudioClick);
view.enableMic.addEventListener(Event.CHANGE, onEnableMicClick);
view.enablePushToTalk.addEventListener(Event.CHANGE, onEnablePushToTalkClick);
view.gainSlider.addEventListener(Event.CHANGE, gainChange);
userSession.lockSettings.disableMicSignal.add(disableMic);
disableMic(userSession.lockSettings.disableMic && userMe.role != User.MODERATOR && !userMe.presenter && userMe.locked);
view.enableAudio.selected = (userMe.voiceJoined || userMe.listenOnly);
view.enablePushToTalk.enabled = view.enableMic.selected = userMe.voiceJoined;
view.enablePushToTalk.selected = (userSession.pushToTalk || userSession.phoneOptions.autoJoin);
FlexGlobals.topLevelApplication.topActionBar.backBtn.visible = true;
FlexGlobals.topLevelApplication.topActionBar.profileBtn.visible = false;
loadMicGain();
micActivityTimer = new Timer(100);
micActivityTimer.addEventListener(TimerEvent.TIMER, micActivity);
micActivityTimer.start();
view.continueBtn.visible = userSession.phoneOptions.autoJoin;
}
private function loadMicGain():void {
var gain:Number = saveData.read("micGain") as Number;
if (!isNaN(gain)) {
view.gainSlider.value = gain / 10;
}
}
private function setMicGain(gain:Number):void {
if (userSession.voiceStreamManager) {
userSession.voiceStreamManager.setDefaultMicGain(gain);
if (!userSession.pushToTalk && userSession.voiceStreamManager.mic) {
userSession.voiceStreamManager.mic.gain = gain;
}
}
}
private function gainChange(e:Event):void {
var gain:Number = e.target.value * 10
saveData.save("micGain", gain);
setMicGain(gain);
}
private function micActivity(e:TimerEvent):void {
if (userSession.voiceStreamManager && userSession.voiceStreamManager.mic) {
view.micActivityMask.width = view.gainSlider.width - (view.gainSlider.width * userSession.voiceStreamManager.mic.activityLevel / 100);
view.micActivityMask.x = view.micActivity.x + view.micActivity.width - view.micActivityMask.width;
}
}
private function disableMic(disable:Boolean):void {
if (disable) {
view.enableMic.enabled = false;
view.enableMic.selected = false;
} else {
view.enableMic.enabled = true;
}
}
private function onContinueClick(event:Event):void {
userUISession.popPage();
}
private function onEnableAudioClick(event:Event):void {
if (!view.enableAudio.selected) {
view.enableMic.selected = false;
view.enablePushToTalk.enabled = false;
userSession.pushToTalk = false;
}
var audioOptions:Object = new Object();
audioOptions.shareMic = userSession.userList.me.voiceJoined = view.enableMic.selected && view.enableAudio.selected;
audioOptions.listenOnly = userSession.userList.me.listenOnly = !view.enableMic.selected && view.enableAudio.selected;
shareMicrophoneSignal.dispatch(audioOptions);
}
private function onEnableMicClick(event:Event):void {
view.enablePushToTalk.enabled = view.enableMic.selected;
if (view.enableMic.selected) {
view.enableAudio.selected = true;
}
userSession.pushToTalk = (view.enablePushToTalk.selected && view.enablePushToTalk.enabled);
var audioOptions:Object = new Object();
audioOptions.shareMic = userSession.userList.me.voiceJoined = view.enableMic.selected && view.enableAudio.selected;
audioOptions.listenOnly = userSession.userList.me.listenOnly = !view.enableMic.selected && view.enableAudio.selected;
shareMicrophoneSignal.dispatch(audioOptions);
}
private function onEnablePushToTalkClick(event:Event):void {
userSession.pushToTalk = view.enablePushToTalk.selected;
}
private function userChangeHandler(user:User, type:int):void {
if (user.me) {
if (type == UserList.LISTEN_ONLY) {
view.enableAudio.selected = user.voiceJoined || user.listenOnly;
view.enableMic.selected = user.voiceJoined;
}
}
}
override public function destroy():void {
super.destroy();
userSession.lockSettings.disableMicSignal.remove(disableMic);
view.continueBtn.removeEventListener(MouseEvent.CLICK, onContinueClick);
view.enableAudio.removeEventListener(Event.CHANGE, onEnableAudioClick);
view.enableMic.removeEventListener(Event.CHANGE, onEnableMicClick);
if (micActivityTimer) {
micActivityTimer.removeEventListener(TimerEvent.TIMER, micActivity);
}
view.enablePushToTalk.removeEventListener(Event.CHANGE, onEnablePushToTalkClick);
view.gainSlider.removeEventListener(Event.CHANGE, gainChange);
userSession.userList.userChangeSignal.remove(userChangeHandler);
userSession.phoneOptions.autoJoin = false;
}
}
}

View File

@ -0,0 +1,145 @@
package org.bigbluebutton.air.settings.views.audio {
import flash.utils.Timer;
import org.bigbluebutton.air.main.models.IUISession;
import org.bigbluebutton.lib.common.models.ISaveData;
import org.bigbluebutton.lib.main.models.IUserSession;
import org.bigbluebutton.lib.settings.views.audio.AudioSettingsViewMediator;
import org.bigbluebutton.lib.voice.commands.ShareMicrophoneSignal;
public class AudioSettingsViewMediatorAIR extends AudioSettingsViewMediator {
[Inject]
public var userSession:IUserSession;
[Inject]
public var userUISession:IUISession;
[Inject]
public var saveData:ISaveData;
[Inject]
public var shareMicrophoneSignal:ShareMicrophoneSignal;
private var micActivityTimer:Timer = null;
override public function initialize():void {
/* userSession.userList.userChangeSignal.add(userChangeHandler);
FlexGlobals.topLevelApplication.topActionBar.pageName.text = ResourceManager.getInstance().getString('resources', 'audioSettings.title');
var userMe:User = userSession.userList.me;
view.continueBtn.addEventListener(MouseEvent.CLICK, onContinueClick);
view.enableAudio.addEventListener(Event.CHANGE, onEnableAudioClick);
view.enableMic.addEventListener(Event.CHANGE, onEnableMicClick);
view.enablePushToTalk.addEventListener(Event.CHANGE, onEnablePushToTalkClick);
view.gainSlider.addEventListener(Event.CHANGE, gainChange);
userSession.lockSettings.disableMicSignal.add(disableMic);
disableMic(userSession.lockSettings.disableMic && userMe.role != User.MODERATOR && !userMe.presenter && userMe.locked);
view.enableAudio.selected = (userMe.voiceJoined || userMe.listenOnly);
view.enablePushToTalk.enabled = view.enableMic.selected = userMe.voiceJoined;
view.enablePushToTalk.selected = (userSession.pushToTalk || userSession.phoneOptions.autoJoin);
FlexGlobals.topLevelApplication.topActionBar.backBtn.visible = true;
FlexGlobals.topLevelApplication.topActionBar.profileBtn.visible = false;
loadMicGain();
micActivityTimer = new Timer(100);
micActivityTimer.addEventListener(TimerEvent.TIMER, micActivity);
micActivityTimer.start();
view.continueBtn.visible = userSession.phoneOptions.autoJoin;
*/
}
/*
private function loadMicGain():void {
var gain:Number = saveData.read("micGain") as Number;
if (!isNaN(gain)) {
view.gainSlider.value = gain / 10;
}
}
private function setMicGain(gain:Number):void {
if (userSession.voiceStreamManager) {
userSession.voiceStreamManager.setDefaultMicGain(gain);
if (!userSession.pushToTalk && userSession.voiceStreamManager.mic) {
userSession.voiceStreamManager.mic.gain = gain;
}
}
}
private function gainChange(e:Event):void {
var gain:Number = e.target.value * 10
saveData.save("micGain", gain);
setMicGain(gain);
}
private function micActivity(e:TimerEvent):void {
if (userSession.voiceStreamManager && userSession.voiceStreamManager.mic) {
view.micActivityMask.width = view.gainSlider.width - (view.gainSlider.width * userSession.voiceStreamManager.mic.activityLevel / 100);
view.micActivityMask.x = view.micActivity.x + view.micActivity.width - view.micActivityMask.width;
}
}
private function disableMic(disable:Boolean):void {
if (disable) {
view.enableMic.enabled = false;
view.enableMic.selected = false;
} else {
view.enableMic.enabled = true;
}
}
private function onContinueClick(event:Event):void {
userUISession.popPage();
}
private function onEnableAudioClick(event:Event):void {
if (!view.enableAudio.selected) {
view.enableMic.selected = false;
view.enablePushToTalk.enabled = false;
userSession.pushToTalk = false;
}
var audioOptions:Object = new Object();
audioOptions.shareMic = userSession.userList.me.voiceJoined = view.enableMic.selected && view.enableAudio.selected;
audioOptions.listenOnly = userSession.userList.me.listenOnly = !view.enableMic.selected && view.enableAudio.selected;
shareMicrophoneSignal.dispatch(audioOptions);
}
private function onEnableMicClick(event:Event):void {
view.enablePushToTalk.enabled = view.enableMic.selected;
if (view.enableMic.selected) {
view.enableAudio.selected = true;
}
userSession.pushToTalk = (view.enablePushToTalk.selected && view.enablePushToTalk.enabled);
var audioOptions:Object = new Object();
audioOptions.shareMic = userSession.userList.me.voiceJoined = view.enableMic.selected && view.enableAudio.selected;
audioOptions.listenOnly = userSession.userList.me.listenOnly = !view.enableMic.selected && view.enableAudio.selected;
shareMicrophoneSignal.dispatch(audioOptions);
}
private function onEnablePushToTalkClick(event:Event):void {
userSession.pushToTalk = view.enablePushToTalk.selected;
}
private function userChangeHandler(user:User, type:int):void {
if (user.me) {
if (type == UserList.LISTEN_ONLY) {
view.enableAudio.selected = user.voiceJoined || user.listenOnly;
view.enableMic.selected = user.voiceJoined;
}
}
}
override public function destroy():void {
super.destroy();
userSession.lockSettings.disableMicSignal.remove(disableMic);
view.continueBtn.removeEventListener(MouseEvent.CLICK, onContinueClick);
view.enableAudio.removeEventListener(Event.CHANGE, onEnableAudioClick);
view.enableMic.removeEventListener(Event.CHANGE, onEnableMicClick);
if (micActivityTimer) {
micActivityTimer.removeEventListener(TimerEvent.TIMER, micActivity);
}
view.enablePushToTalk.removeEventListener(Event.CHANGE, onEnablePushToTalkClick);
view.gainSlider.removeEventListener(Event.CHANGE, gainChange);
userSession.userList.userChangeSignal.remove(userChangeHandler);
userSession.phoneOptions.autoJoin = false;
}
*/
}
}

View File

@ -1,19 +0,0 @@
package org.bigbluebutton.air.settings.views.audio {
import org.bigbluebutton.air.common.views.IView;
import spark.components.Button;
import spark.components.HSlider;
import spark.components.ToggleSwitch;
import spark.primitives.Rect;
public interface IAudioSettingsView extends IView {
function get enableMic():ToggleSwitch;
function get enableAudio():ToggleSwitch;
function get enablePushToTalk():ToggleSwitch;
function get continueBtn():Button;
function get gainSlider():HSlider;
function get micActivityMask():Rect;
function get micActivity():Rect;
}
}

View File

@ -0,0 +1,10 @@
package org.bigbluebutton.lib.settings.views.audio {
import spark.components.Group;
public class AudioSettingsViewBase extends Group {
public function AudioSettingsViewBase() {
super();
}
}
}

View File

@ -0,0 +1,10 @@
package org.bigbluebutton.lib.settings.views.audio {
import robotlegs.bender.bundles.mvcs.Mediator;
public class AudioSettingsViewMediator extends Mediator {
[Inject]
public var view:AudioSettingsViewBase;
}
}