# HG changeset patch # User Vincent V. # Date 1336567103 -7200 # Node ID 257fbd2fcf7950eb6391dca04d579bfd827aec6d # Parent 511216e1269eb15cad60667df72f638be7c9a53c Colored Beem-Icon according to status Feature #289 diff -r 511216e1269e -r 257fbd2fcf79 project.properties --- a/project.properties Tue May 08 18:41:02 2012 +0200 +++ b/project.properties Wed May 09 14:38:23 2012 +0200 @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-15 +target=android-7 diff -r 511216e1269e -r 257fbd2fcf79 res/drawable/beem_status_icon_available.png Binary file res/drawable/beem_status_icon_available.png has changed diff -r 511216e1269e -r 257fbd2fcf79 res/drawable/beem_status_icon_away.png Binary file res/drawable/beem_status_icon_away.png has changed diff -r 511216e1269e -r 257fbd2fcf79 res/drawable/beem_status_icon_busy.png Binary file res/drawable/beem_status_icon_busy.png has changed diff -r 511216e1269e -r 257fbd2fcf79 res/drawable/beem_status_icon_gray.png Binary file res/drawable/beem_status_icon_gray.png has changed diff -r 511216e1269e -r 257fbd2fcf79 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Tue May 08 18:41:02 2012 +0200 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Wed May 09 14:38:23 2012 +0200 @@ -328,7 +328,7 @@ mPreviousPriority = p; pres.setPriority(p); mAdaptee.sendPacket(pres); - updateNotification(m); + updateNotification(Status.getStatusFromPresence(pres), m); } /** @@ -368,10 +368,9 @@ * Update the notification for the Beem status. * @param text the text to display. */ - private void updateNotification(String text) { + private void updateNotification(int status, String text) { Notification mStatusNotification; - mStatusNotification = new Notification(com.beem.project.beem.R.drawable.beem_status_icon, text, System - .currentTimeMillis()); + mStatusNotification = new Notification(Status.getIconBarFromStatus(status), text, System.currentTimeMillis()); mStatusNotification.defaults = Notification.DEFAULT_LIGHTS; mStatusNotification.flags = Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; @@ -684,6 +683,8 @@ intent, PendingIntent.FLAG_ONE_SHOT)); int id = packet.hashCode(); mService.sendNotification(id, notif); + Presence p = (Presence) packet; + updateNotification(Status.getStatusFromPresence(p), p.getStatus()); } }, filter); diff -r 511216e1269e -r 257fbd2fcf79 src/com/beem/project/beem/utils/Status.java --- a/src/com/beem/project/beem/utils/Status.java Tue May 08 18:41:02 2012 +0200 +++ b/src/com/beem/project/beem/utils/Status.java Wed May 09 14:38:23 2012 +0200 @@ -46,6 +46,8 @@ import org.jivesoftware.smack.packet.Presence; import org.jivesoftware.smack.packet.Presence.Mode; +import com.beem.project.beem.R; + /** * Utility class to deal with status and presence value. * @author marseille @@ -153,4 +155,27 @@ return status != Status.CONTACT_STATUS_DISCONNECT; } + public static int getIconBarFromStatus(final int status) { + int icon = R.drawable.beem_status_icon; + switch (status) { + case Status.CONTACT_STATUS_AVAILABLE: + icon = R.drawable.beem_status_icon_available; + break; + case Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT: + icon = R.drawable.beem_status_icon_available; + break; + case Status.CONTACT_STATUS_AWAY: + icon = R.drawable.beem_status_icon_away; + break; + case Status.CONTACT_STATUS_BUSY: + icon = R.drawable.beem_status_icon_busy; + break; + case Status.CONTACT_STATUS_UNAVAILABLE: + icon = R.drawable.beem_status_icon_gray; + break; + default: + icon = R.drawable.beem_status_icon; + } + return icon; + } }