Fixes missing buttons and call timer start when call is answered through global shortcut or auto-answer.

Orders buttons used in CallPanel.
cusax-fix
Damian Minkov 15 years ago
parent 3285adc53c
commit 6485119bee

@ -35,6 +35,24 @@
/**
* 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 @@ private void init()
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 void stateChanged(ChangeEvent e)
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 void stateChanged(ChangeEvent e)
chatButton.setToolTipText(
GuiActivator.getResources().getI18NString("service.gui.CHAT"));
chatButton.addActionListener(this);
chatButton.setIndex(19);
localLevel = new InputVolumeControlButton(
call,
@ -367,12 +393,16 @@ public void stateChanged(ChangeEvent e)
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 void stateChanged(ChangeEvent e)
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 void stateChanged(ChangeEvent e)
GuiActivator.getResources().getI18NString(
"service.gui.PRESS_FOR_CALL_INFO"));
infoButton.addActionListener(this);
infoButton.setIndex(20);
settingsPanel.add(infoButton);
}
@ -1224,7 +1256,10 @@ public void addRemoteVideoSpecificComponents(CallPeer callPeer)
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 @@ private void addOneToOneSpecificComponents()
{
CallPeer callPeer = callPeers.next();
if (callPeer.getState() == CallPeerState.CONNECTED)
{
enableButtons(true);
return;
}
settingsPanel.add(transferCallButton);
Contact peerContact = callPeer.getContact();
@ -1342,6 +1371,15 @@ private void addOneToOneSpecificComponents()
OperationSetVideoTelephony.class) != null)
settingsPanel.add(videoButton);
}
if (callPeer.getState() == CallPeerState.CONNECTED)
{
if(!isCallTimerStarted())
startCallTimer();
enableButtons(true);
return;
}
}
enableButtons(false);
}
@ -1361,6 +1399,9 @@ private void addConferenceSpecificComponents()
{
if (callPeers.next().getState() == CallPeerState.CONNECTED)
{
if(!isCallTimerStarted())
startCallTimer();
enableButtons(true);
return;
}

@ -293,6 +293,7 @@ boolean preCallCheck(Request invite,
catch (Throwable ex)
{
logger.error("Error while trying to send a request", ex);
return false;
}
return true;

@ -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();
}

@ -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);
}
}

@ -22,6 +22,7 @@
*/
public class SIPCommButton
extends JButton
implements OrderedComponent
{
/**
* Serial version UID.
@ -40,6 +41,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.
*/
@ -346,6 +352,24 @@ public void setIconImage(Image iconImage)
this.iconImage = iconImage;
}
/**
* 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.

@ -22,6 +22,7 @@
*/
public class SIPCommToggleButton
extends JToggleButton
implements OrderedComponent
{
/**
* Serial version UID.
@ -53,6 +54,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>.
*/
@ -323,6 +329,24 @@ public void setPressedImage(Image pressedImage)
this.repaint();
}
/**
* 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.

Loading…
Cancel
Save