Adds status of contact to chat message button in call panel.

cusax-fix
Damian Minkov 12 years ago
parent ff12a2c690
commit 18109ff141

@ -151,6 +151,12 @@ service.gui.buttons.CHAT_BUTTON_SMALL=resources/images/impl/gui/buttons/chatSmal
service.gui.buttons.CHAT_BUTTON_SMALL_PRESSED=resources/images/impl/gui/buttons/chatSmallPressed.png
service.gui.buttons.CHAT_BUTTON_SMALL_ROLLOVER=resources/images/impl/gui/buttons/chatSmallRollover.png
service.gui.buttons.CHAT_BUTTON_SMALL_WHITE=resources/images/impl/gui/buttons/chatSmallWhite.png
service.gui.buttons.CHAT_BUTTON_ONLINE_ICON=resources/images/impl/gui/buttons/chatSmallOnline.png
service.gui.buttons.CHAT_BUTTON_OFFLINE_ICON=resources/images/impl/gui/buttons/chatSmallOffline.png
service.gui.buttons.CHAT_BUTTON_AWAY_ICON=resources/images/impl/gui/buttons/chatSmallAway.png
service.gui.buttons.CHAT_BUTTON_DND_ICON=resources/images/impl/gui/buttons/chatSmallDND.png
service.gui.buttons.CHAT_BUTTON_FFC_ICON=resources/images/impl/gui/buttons/chatSmallFree.png
service.gui.buttons.CHAT_BUTTON_ON_THE_PHONE_ICON=resources/images/impl/gui/buttons/chatSmallPhone.png
service.gui.buttons.ADD_CONTACT_BUTTON_SMALL=resources/images/impl/gui/buttons/addContactSmall.png
service.gui.buttons.ADD_CONTACT_BUTTON_SMALL_PRESSED=resources/images/impl/gui/buttons/addContactSmallPressed.png
service.gui.buttons.ADD_CONTACT_BUTTON_SMALL_ROLLOVER=resources/images/impl/gui/buttons/addContactSmallRollover.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

@ -20,6 +20,7 @@
import net.java.sip.communicator.impl.gui.event.*;
import net.java.sip.communicator.impl.gui.main.call.conference.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.impl.gui.utils.Constants;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.gui.*;
@ -67,7 +68,8 @@ public class CallPanel
implements ActionListener,
PluginComponentListener,
Skinnable,
ConferencePeerViewListener
ConferencePeerViewListener,
ContactPresenceStatusListener
{
/**
* The chat button name.
@ -685,6 +687,17 @@ void dispose()
((CallRenderer) callPanel).dispose();
}
// clears the contact status listener
List<Contact> imContacts = getIMCapableCallPeers(1);
if(imContacts.size() == 1)
{
Contact contact = imContacts.get(0);
OperationSetPresence operationSetPresence =
contact.getProtocolProvider()
.getOperationSet(OperationSetPresence.class);
if(operationSetPresence != null)
operationSetPresence.removeContactPresenceStatusListener(this);
}
}
/**
@ -746,8 +759,22 @@ private void doUpdateSettingsPanelInEventDispatchThread(
* telephony conference at this time so we do not want the chatButton
* visible in such a scenario.
*/
List<Contact> imContacts = getIMCapableCallPeers(1);
chatButton.setVisible(
!isConference && (getIMCapableCallPeers(1).size() == 1));
!isConference && (imContacts.size() == 1));
if(chatButton.isVisible())
{
Contact contact = imContacts.get(0);
OperationSetPresence operationSetPresence =
contact.getProtocolProvider()
.getOperationSet(OperationSetPresence.class);
if(operationSetPresence != null)
operationSetPresence.addContactPresenceStatusListener(this);
chatButton.setIconImage(
Constants.getMessageStatusIcon(contact.getPresenceStatus()));
chatButton.repaint();
}
updateHoldButtonState();
updateMergeButtonState();
@ -2173,6 +2200,24 @@ private void updateViewFromModelInEventDispatchThread()
}
}
/**
* Listens for contact status changes and updates the image of the
* chat message button.
* @param evt the ContactPresenceStatusChangeEvent describing the status
*/
@Override
public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt)
{
Contact contact = getIMCapableCallPeers(1).get(0);
if(contact.equals(evt.getSourceContact()))
{
chatButton.setIconImage(
Constants.getMessageStatusIcon(contact.getPresenceStatus()));
chatButton.repaint();
}
}
/**
* Implements the listener which listens to events fired by the
* <tt>CallConference</tt> depicted by this instance, the <tt>Call</tt>s

@ -307,6 +307,63 @@ else if(connectivity < PresenceStatus.MAX_STATUS_VALUE)
}
}
/**
* Returns the image corresponding to the given presence status.
* @param status The presence status.
* @return the image corresponding to the given presence status.
*/
public static BufferedImage getMessageStatusIcon(PresenceStatus status)
{
if(status != null)
{
int connectivity = status.getStatus();
if(connectivity < PresenceStatus.ONLINE_THRESHOLD)
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_OFFLINE_ICON);
}
else if(connectivity < PresenceStatus.AWAY_THRESHOLD)
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_DND_ICON);
}
else if(connectivity == PresenceStatus.AWAY_THRESHOLD)
{
// the special status On The Phone is state
// between DND and AWAY states.
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_ON_THE_PHONE_ICON);
}
else if(connectivity < PresenceStatus.AVAILABLE_THRESHOLD)
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_AWAY_ICON);
}
else if(connectivity
< PresenceStatus.EAGER_TO_COMMUNICATE_THRESHOLD)
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_ONLINE_ICON);
}
else if(connectivity < PresenceStatus.MAX_STATUS_VALUE)
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_FFC_ICON);
}
else
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_OFFLINE_ICON);
}
}
else
{
return ImageLoader
.getImage(ImageLoader.CHAT_BUTTON_SMALL_WHITE);
}
}
/**
* Loads a chat window style.
*/

@ -1306,6 +1306,42 @@ public class ImageLoader
public static final ImageID USER_USER_ON_THE_PHONE_ICON
= new ImageID("service.gui.statusicons.USER_ON_THE_PHONE_ICON");
/**
* Chat button "online" icon.
*/
public static final ImageID CHAT_BUTTON_ONLINE_ICON
= new ImageID("service.gui.buttons.CHAT_BUTTON_ONLINE_ICON");
/**
* Chat button "offline" icon.
*/
public static final ImageID CHAT_BUTTON_OFFLINE_ICON
= new ImageID("service.gui.buttons.CHAT_BUTTON_OFFLINE_ICON");
/**
* Chat button "away" icon.
*/
public static final ImageID CHAT_BUTTON_AWAY_ICON
= new ImageID("service.gui.buttons.CHAT_BUTTON_AWAY_ICON");
/**
* Chat button "free for chat" icon.
*/
public static final ImageID CHAT_BUTTON_FFC_ICON
= new ImageID("service.gui.buttons.CHAT_BUTTON_FFC_ICON");
/**
* Chat button "do not disturb" icon.
*/
public static final ImageID CHAT_BUTTON_DND_ICON
= new ImageID("service.gui.buttons.CHAT_BUTTON_DND_ICON");
/**
* Chat button "on the phone" icon.
*/
public static final ImageID CHAT_BUTTON_ON_THE_PHONE_ICON
= new ImageID("service.gui.buttons.CHAT_BUTTON_ON_THE_PHONE_ICON");
/**
* Owner chatroom member.
*/

Loading…
Cancel
Save