From 3ca83c62abc8501f7b0fb3b2ea23d1001a2a13d1 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 20 Nov 2012 17:10:16 +0100 Subject: [PATCH] Display last message in chat list + fix push notif setting --- res/layout/chatlist_cell.xml | 34 ++++++++++++++++++++------ src/org/linphone/ChatListFragment.java | 23 +++++++++++++++++ src/org/linphone/LinphoneManager.java | 2 +- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/res/layout/chatlist_cell.xml b/res/layout/chatlist_cell.xml index a3dddc2be..71d31d311 100644 --- a/res/layout/chatlist_cell.xml +++ b/res/layout/chatlist_cell.xml @@ -44,16 +44,34 @@ android:text="@string/draft" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" /> - - + android:orientation="horizontal"> + + + + + + \ No newline at end of file diff --git a/src/org/linphone/ChatListFragment.java b/src/org/linphone/ChatListFragment.java index 4e76f4843..8182bcafa 100644 --- a/src/org/linphone/ChatListFragment.java +++ b/src/org/linphone/ChatListFragment.java @@ -21,6 +21,7 @@ import java.util.List; import org.linphone.core.LinphoneAddress; import org.linphone.core.LinphoneCoreFactory; +import org.linphone.core.Log; import android.os.Bundle; import android.os.Handler; @@ -236,6 +237,27 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte LinphoneAddress address = LinphoneCoreFactory.instance().createLinphoneAddress(contact); LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver()); + + List messages = LinphoneActivity.instance().getChatMessages(contact); + if (messages != null && messages.size() > 0) { + int iterator = messages.size() - 1; + ChatMessage lastMessage = null; + + while (iterator >= 0) { + lastMessage = messages.get(iterator); + if (lastMessage.getMessage() == null) { + iterator--; + } else { + iterator = -1; + } + } + + String message = ""; + message = (lastMessage == null || lastMessage.getMessage() == null) ? "" : lastMessage.getMessage(); + Log.e("Last message = " + message); + TextView lastMessageView = (TextView) view.findViewById(R.id.lastMessage); + lastMessageView.setText(message); + } TextView sipUri = (TextView) view.findViewById(R.id.sipUri); @@ -250,6 +272,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte view.findViewById(R.id.draft).setVisibility(View.VISIBLE); } + ImageView delete = (ImageView) view.findViewById(R.id.delete); TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages); diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java index 65f990cef..074ce5bbf 100644 --- a/src/org/linphone/LinphoneManager.java +++ b/src/org/linphone/LinphoneManager.java @@ -613,7 +613,7 @@ public final class LinphoneManager implements LinphoneCoreListener { // Add parameters for push notifications String regId = getPrefString(R.string.push_reg_id_key, null); String appId = getString(R.string.push_sender_id); - if (regId != null && getPrefBoolean(R.string.pref_push_notification_key, true)) { + if (regId != null && getPrefBoolean(R.string.pref_push_notification_key, mR.getBoolean(R.bool.pref_push_notification_default))) { String contactInfos = "app-id=" + appId + ";pn-type=google;pn-tok=" + regId + ";pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf;"; proxycon.setContactParameters(contactInfos); }