diff options
6 files changed, 193 insertions, 7 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java index 6ca52d0..45d4682 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java @@ -35,6 +35,24 @@ import net.java.sip.communicator.util.swing.border.*; /** * The dialog created for a given call. * + * Ordered buttons we are adding/removing, numbers are the index we have set. + * And the order that will be kept. + * 0 dialButton + * 1 conferenceButton + * 2 holdButton + * 3 recordButton + * 4 mergeButton + * 5 transferCallButton + * 6 localLevel + * 7 remoteLevel + * 8 desktopSharingButton + * 9 resizeVideoButton + * 10 fullScreenButton + * 11 videoButton + * 12 showHideVideoButton + * 19 chatButton + * 20 infoButton + * * @author Yana Stamcheva * @author Adam Netocny */ @@ -106,7 +124,7 @@ public class CallPanel /** * The panel containing call settings. */ - private final TransparentPanel settingsPanel = new TransparentPanel(); + private final TransparentPanel settingsPanel = new OrderedTransparentPanel(); /** * The panel representing the call. For conference calls this would be an @@ -322,6 +340,10 @@ public class CallPanel recordButton = new RecordButton(call); videoButton = new LocalVideoButton(call); showHideVideoButton = new ShowHideVideoButton(call); + holdButton.setIndex(2); + recordButton.setIndex(3); + videoButton.setIndex(11); + showHideVideoButton.setIndex(12); showHideVideoButton.setPeerRenderer(((CallRenderer) callPanel) .getCallPeerRenderer(call.getCallPeers().next())); @@ -351,6 +373,9 @@ public class CallPanel desktopSharingButton = new DesktopSharingButton(call); transferCallButton = new TransferCallButton(call); fullScreenButton = new FullScreenButton(this); + desktopSharingButton.setIndex(8); + transferCallButton.setIndex(5); + fullScreenButton.setIndex(10); chatButton = new SIPCommButton( ImageLoader.getImage(ImageLoader.CALL_SETTING_BUTTON_BG), @@ -359,6 +384,7 @@ public class CallPanel chatButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CHAT")); chatButton.addActionListener(this); + chatButton.setIndex(19); localLevel = new InputVolumeControlButton( call, @@ -367,12 +393,16 @@ public class CallPanel false, true, false); remoteLevel = new OutputVolumeControlButton( ImageLoader.VOLUME_CONTROL_BUTTON, false, true); + localLevel.setIndex(6); + remoteLevel.setIndex(7); + dialButton.setIndex(0); dialButton.setName(DIAL_BUTTON); dialButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.DIALPAD")); dialButton.addActionListener(this); + conferenceButton.setIndex(1); conferenceButton.setName(CONFERENCE_BUTTON); conferenceButton.setToolTipText( GuiActivator.getResources().getI18NString( @@ -384,6 +414,7 @@ public class CallPanel GuiActivator.getResources().getI18NString("service.gui.HANG_UP")); hangupButton.addActionListener(this); + mergeButton.setIndex(4); mergeButton.setName(MERGE_BUTTON); mergeButton.setToolTipText( GuiActivator.getResources().getI18NString( @@ -446,6 +477,7 @@ public class CallPanel GuiActivator.getResources().getI18NString( "service.gui.PRESS_FOR_CALL_INFO")); infoButton.addActionListener(this); + infoButton.setIndex(20); settingsPanel.add(infoButton); } @@ -1224,7 +1256,10 @@ public class CallPanel if(CallManager.isVideoQualityPresetSupported(callPeer)) { if(resizeVideoButton == null) + { resizeVideoButton = new ResizeVideoButton(call); + resizeVideoButton.setIndex(9); + } if(resizeVideoButton.countAvailableOptions() > 1) settingsPanel.add(resizeVideoButton); @@ -1304,12 +1339,6 @@ public class CallPanel { CallPeer callPeer = callPeers.next(); - if (callPeer.getState() == CallPeerState.CONNECTED) - { - enableButtons(true); - return; - } - settingsPanel.add(transferCallButton); Contact peerContact = callPeer.getContact(); @@ -1342,6 +1371,15 @@ public class CallPanel OperationSetVideoTelephony.class) != null) settingsPanel.add(videoButton); } + + if (callPeer.getState() == CallPeerState.CONNECTED) + { + if(!isCallTimerStarted()) + startCallTimer(); + + enableButtons(true); + return; + } } enableButtons(false); } @@ -1361,6 +1399,9 @@ public class CallPanel { if (callPeers.next().getState() == CallPeerState.CONNECTED) { + if(!isCallTimerStarted()) + startCallTimer(); + enableButtons(true); return; } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java index 0503a58..a8bc35f 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetAutoAnswerSipImpl.java @@ -293,6 +293,7 @@ public class OperationSetAutoAnswerSipImpl catch (Throwable ex) { logger.error("Error while trying to send a request", ex); + return false; } return true; diff --git a/src/net/java/sip/communicator/util/swing/OrderedComponent.java b/src/net/java/sip/communicator/util/swing/OrderedComponent.java new file mode 100644 index 0000000..d907c27 --- /dev/null +++ b/src/net/java/sip/communicator/util/swing/OrderedComponent.java @@ -0,0 +1,28 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.util.swing; + +/** + * Components (like buttons) implement this interface to be able to + * order them in a Ordered Transparent Panels. + * + * @author Damian Minkov + */ +public interface OrderedComponent +{ + /** + * Change component index when we want to order it. + * @param index the button index. + */ + public void setIndex(int index); + + /** + * Returns the current component index we have set, or -1 if none used. + * @return + */ + public int getIndex(); +} diff --git a/src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java b/src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java new file mode 100644 index 0000000..9cc9367 --- /dev/null +++ b/src/net/java/sip/communicator/util/swing/OrderedTransparentPanel.java @@ -0,0 +1,68 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.util.swing; + +import java.awt.*; + +/** + * Ordered transparent panel. Components added to the panel + * must implement OrderedComponent to be able to order them or + * will leave the parent to add them as usual. + * @author Damian Minkov + */ +public class OrderedTransparentPanel + extends TransparentPanel +{ + private static final long serialVersionUID = 0L; + + public Component add(Component comp) + { + if(comp instanceof OrderedComponent) + { + return addOrdered(comp); + } + else + return super.add(comp); + } + + /** + * Method to order add OrderedComponents. + * @param comp the component to order. + * @return the component argument + */ + private Component addOrdered(Component comp) + { + int orederIndex = ((OrderedComponent)comp).getIndex(); + + Component[] cs = getComponents(); + + // don't add a component if already added or it will be removed + // and added at the end + for(int i = 0; i < cs.length; i++) + { + if(cs[i].equals(comp)) + return comp; + } + + for(int i = 0; i < cs.length; i++) + { + Component c = cs[i]; + int cIx; + if(c instanceof OrderedComponent) + { + cIx = ((OrderedComponent)c).getIndex(); + + if(orederIndex < cIx) + { + return super.add(comp, i); + } + } + } + + return super.add(comp); + } +} diff --git a/src/net/java/sip/communicator/util/swing/SIPCommButton.java b/src/net/java/sip/communicator/util/swing/SIPCommButton.java index cf37c6b..cbdea52 100755 --- a/src/net/java/sip/communicator/util/swing/SIPCommButton.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommButton.java @@ -22,6 +22,7 @@ import org.jvnet.lafwidget.animation.*; */ public class SIPCommButton extends JButton + implements OrderedComponent { /** * Serial version UID. @@ -41,6 +42,11 @@ public class SIPCommButton private Image iconImage; /** + * The index of the button, used when we want to order our buttons. + */ + private int index = -1; + + /** * Creates a button. */ public SIPCommButton() @@ -347,6 +353,24 @@ public class SIPCommButton } /** + * Change buttons index when we want to order it. + * @param index the button index. + */ + public void setIndex(int index) + { + this.index = index; + } + + /** + * Returns the current button index we have set, or -1 if none used. + * @return + */ + public int getIndex() + { + return this.index; + } + + /** * The <tt>ButtonRepaintCallback</tt> is charged to repaint this button * when the fade animation is performed. */ diff --git a/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java b/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java index c8d6544..6a1ca46 100644 --- a/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java +++ b/src/net/java/sip/communicator/util/swing/SIPCommToggleButton.java @@ -22,6 +22,7 @@ import org.jvnet.lafwidget.animation.*; */ public class SIPCommToggleButton extends JToggleButton + implements OrderedComponent { /** * Serial version UID. @@ -54,6 +55,11 @@ public class SIPCommToggleButton private Image pressedIconImage; /** + * The index of the button, used when we want to order our buttons. + */ + private int index = -1; + + /** * Creates an instance of <tt>SIPCommToggleButton</tt>. */ public SIPCommToggleButton() @@ -324,6 +330,24 @@ public class SIPCommToggleButton } /** + * Change buttons index when we want to order it. + * @param index the button index. + */ + public void setIndex(int index) + { + this.index = index; + } + + /** + * Returns the current button index we have set, or -1 if none used. + * @return + */ + public int getIndex() + { + return this.index; + } + + /** * The <tt>ButtonRepaintCallback</tt> is charged to repaint this button * when the fade animation is performed. */ |