Display last message in chat list + fix push notif setting
This commit is contained in:
parent
d34f98b91f
commit
3ca83c62ab
3 changed files with 50 additions and 9 deletions
|
@ -45,15 +45,33 @@
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp" />
|
android:layout_marginRight="5dp" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/sipUri"
|
|
||||||
android:lines="1"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:layout_centerVertical="true"
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:layout_toLeftOf="@id/draft"
|
android:layout_toLeftOf="@id/draft"
|
||||||
android:layout_marginLeft="10dp" />
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sipUri"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="none"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:layout_marginLeft="10dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/lastMessage"
|
||||||
|
android:lines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:layout_marginLeft="5dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -21,6 +21,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
|
import org.linphone.core.Log;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -237,6 +238,27 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
LinphoneAddress address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
|
LinphoneAddress address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
|
||||||
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver());
|
LinphoneUtils.findUriPictureOfContactAndSetDisplayName(address, view.getContext().getContentResolver());
|
||||||
|
|
||||||
|
List<ChatMessage> 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);
|
TextView sipUri = (TextView) view.findViewById(R.id.sipUri);
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && address.getDisplayName() != null && LinphoneUtils.isSipAddress(address.getDisplayName())) {
|
if (getResources().getBoolean(R.bool.only_display_username_if_unknown) && address.getDisplayName() != null && LinphoneUtils.isSipAddress(address.getDisplayName())) {
|
||||||
|
@ -250,6 +272,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
view.findViewById(R.id.draft).setVisibility(View.VISIBLE);
|
view.findViewById(R.id.draft).setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ImageView delete = (ImageView) view.findViewById(R.id.delete);
|
ImageView delete = (ImageView) view.findViewById(R.id.delete);
|
||||||
TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages);
|
TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages);
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
// Add parameters for push notifications
|
// Add parameters for push notifications
|
||||||
String regId = getPrefString(R.string.push_reg_id_key, null);
|
String regId = getPrefString(R.string.push_reg_id_key, null);
|
||||||
String appId = getString(R.string.push_sender_id);
|
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;";
|
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);
|
proxycon.setContactParameters(contactInfos);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue