Fix #267 include message in notification
authorDa Risk <darisk972@gmail.com>
Sun, 26 Dec 2010 17:51:12 +0100
changeset 833 8005cd552571
parent 826 2116f901307e
child 834 84cc7ee4b067
Fix #267 include message in notification
src/com/beem/project/beem/service/BeemChatManager.java
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Wed Dec 15 20:09:56 2010 +0100
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Sun Dec 26 17:51:12 2010 +0100
@@ -271,7 +271,7 @@
 	 * Set a notification of a new chat.
 	 * @param chat The chat to access by the notification
 	 */
-	private void notifyNewChat(IChat chat) {
+	private void notifyNewChat(IChat chat, String msgBody) {
 	    SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService);
 	    try {
 		CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID())
@@ -279,8 +279,7 @@
 		Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System
 		    .currentTimeMillis());
 		notification.flags = Notification.FLAG_AUTO_CANCEL;
-		notification.setLatestEventInfo(mService, tickerText, mService
-		    .getString(R.string.BeemChatManagerNewMessage), makeChatIntent(chat));
+		notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(chat));
 		mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification);
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());
@@ -293,11 +292,12 @@
 	@Override
 	public void processMessage(final IChat chat, Message message) {
 	    try {
-		if (!chat.isOpen() && message.getBody() != null) {
+		String body = message.getBody();
+		if (!chat.isOpen() && body != null) {
 		    if (chat instanceof ChatAdapter) {
 			mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat);
 		    }
-		    notifyNewChat(chat);
+		    notifyNewChat(chat, body);
 		}
 	    } catch (RemoteException e) {
 		Log.e(TAG, e.getMessage());