[imdm] fix listener remove on delivered

This commit is contained in:
Brieuc Viel 2017-03-21 15:05:34 +01:00
parent 69e5cbc98c
commit 76e45f0b0b
4 changed files with 31 additions and 25 deletions

View file

@ -111,11 +111,11 @@
<LinearLayout <LinearLayout
android:id="@+id/imdmLayout" android:id="@+id/imdmLayout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="12dp" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_marginTop="5dp" android:layout_marginTop="2dp"
android:layout_marginBottom="5dp" android:layout_marginBottom="2dp"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_gravity="right" android:layout_gravity="right"
android:gravity="right" android:gravity="right"
@ -127,12 +127,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Displayed" android:text="Displayed"
android:textSize="10dp" android:textSize="10dp"
android:paddingRight="5dp"/> android:paddingRight="3dp"/>
<ImageView <ImageView
android:id="@+id/imdmIcon" android:id="@+id/imdmIcon"
android:layout_width="10dp" android:layout_width="10dp"
android:layout_height="12dp" android:layout_height="10dp"
android:src="@drawable/valid" android:src="@drawable/valid"
android:scaleType="fitCenter"
android:layout_marginTop="2dp"
/> />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -185,7 +185,7 @@
<string name="message_cant_be_decrypted_notif">You are unable to decrypt this message.</string> <string name="message_cant_be_decrypted_notif">You are unable to decrypt this message.</string>
<string name="lime_not_verified">You are trying to send a message using LIME to a contact not verified by ZRTP.\nPlease call this contact and verify his ZRTP key before sending your messages.</string> <string name="lime_not_verified">You are trying to send a message using LIME to a contact not verified by ZRTP.\nPlease call this contact and verify his ZRTP key before sending your messages.</string>
<string name="processing_image">Processing image, can take up to a few seconds depending on the size of the file</string> <string name="processing_image">Processing image, can take up to a few seconds depending on the size of the file</string>
<string name="displayed">Displayed</string> <string name="displayed">Read</string>
<string name="delivered">Delivered</string> <string name="delivered">Delivered</string>
<string name="resend">Resend</string> <string name="resend">Resend</string>

View file

@ -229,7 +229,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) { public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
LinphoneAddress from = cr.getPeerAddress(); LinphoneAddress from = cr.getPeerAddress();
if (from.asStringUriOnly().equals(sipUri)) { if (from.asStringUriOnly().equals(sipUri)) {
LinphoneService.instance().removeMessageNotification(); //LinphoneService.instance().removeMessageNotification();
cr.markAsRead(); cr.markAsRead();
LinphoneActivity.instance().updateMissedChatCount(); LinphoneActivity.instance().updateMissedChatCount();
adapter.addMessage(message); adapter.addMessage(message);
@ -376,6 +376,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if (adapter != null) { if (adapter != null) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
//messagesList.invalidateViews();
} }
private void displayMessageList() { private void displayMessageList() {
@ -1047,7 +1048,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
@Override @Override
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) { public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
Log.e(" /////////====>> onLinphoneChatMessageStateChanged - state = "+state.toString());
} }
@Override @Override
@ -1094,6 +1095,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
messagesList.setSelection(getCount() - 1); messagesList.setSelection(getCount() - 1);
} }
public void refreshMessageCell(LinphoneChatMessage msg){
}
@Override @Override
public int getCount() { public int getCount() {
return history.size(); return history.size();
@ -1119,13 +1124,14 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if (convertView != null) { if (convertView != null) {
view = convertView; view = convertView;
holder = (ViewHolder) view.getTag(); holder = (ViewHolder) view.getTag();
LinphoneManager.removeListener(holder); //LinphoneManager.removeListener(holder);
} else { } else {
view = LayoutInflater.from(context).inflate(R.layout.chat_bubble, null); view = LayoutInflater.from(context).inflate(R.layout.chat_bubble, null);
holder = new ViewHolder(view); holder = new ViewHolder(view);
view.setTag(holder); view.setTag(holder);
} }
LinphoneManager.addListener(holder);
if (holder.id == message.getStorageId()) { if (holder.id == message.getStorageId()) {
// Horrible workaround to not reload image on edit chat list // Horrible workaround to not reload image on edit chat list
if (holder.messageImage.getTag() != null if (holder.messageImage.getTag() != null
@ -1184,10 +1190,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
} }
holder.contactName.setText(timestampToHumanDate(context, message.getTime()) + " - " + displayName); holder.contactName.setText(timestampToHumanDate(context, message.getTime()) + " - " + displayName);
/*if (status == LinphoneChatMessage.State.NotDelivered) {
holder.messageStatus.setVisibility(View.VISIBLE);
holder.messageStatus.setImageResource(R.drawable.chat_message_not_delivered);
} else*/
if (status == LinphoneChatMessage.State.InProgress) { if (status == LinphoneChatMessage.State.InProgress) {
holder.messageSendingInProgress.setVisibility(View.VISIBLE); holder.messageSendingInProgress.setVisibility(View.VISIBLE);
} else if (!message.isSecured() && !message.isOutgoing() && } else if (!message.isSecured() && !message.isOutgoing() &&
@ -1195,24 +1197,25 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
holder.messageStatus.setVisibility(View.VISIBLE); holder.messageStatus.setVisibility(View.VISIBLE);
holder.messageStatus.setImageResource(R.drawable.lime_ko); holder.messageStatus.setImageResource(R.drawable.lime_ko);
} }
else if(status == State.DeliveredToUser && message.isOutgoing()){ if(status == State.DeliveredToUser && message.isOutgoing()){
holder.imdmLayout.setVisibility(View.VISIBLE); holder.imdmLayout.setVisibility(View.VISIBLE);
holder.imdmIcon.setImageResource(R.drawable.valid_disabled); holder.imdmIcon.setImageResource(R.drawable.chat_delivered);
holder.imdmLabel.setText(R.string.delivered); holder.imdmLabel.setText(R.string.delivered);
holder.imdmLabel.setTextColor(getResources().getColor(R.color.colorA)); holder.imdmLabel.setTextColor(getResources().getColor(R.color.colorD));
} }
else if(status == State.Displayed && message.isOutgoing()){ else if(status == State.Displayed && message.isOutgoing()){
holder.imdmLayout.setVisibility(View.VISIBLE); holder.imdmLayout.setVisibility(View.VISIBLE);
holder.imdmIcon.setImageResource(R.drawable.valid); holder.imdmIcon.setImageResource(R.drawable.chat_read);
holder.imdmLabel.setText(R.string.displayed); holder.imdmLabel.setText(R.string.displayed);
holder.imdmLabel.setTextColor(getResources().getColor(R.color.colorA)); holder.imdmLabel.setTextColor(getResources().getColor(R.color.colorK));
} }
else if(status == State.NotDelivered && message.isOutgoing()){ else if(status == State.NotDelivered && message.isOutgoing()){
holder.imdmLayout.setVisibility(View.VISIBLE); holder.imdmLayout.setVisibility(View.VISIBLE);
holder.imdmIcon.setImageResource(R.drawable.chat_message_not_delivered); holder.imdmIcon.setImageResource(R.drawable.chat_error);
holder.imdmLabel.setText(R.string.resend); holder.imdmLabel.setText(R.string.resend);
holder.imdmLabel.setTextColor(getResources().getColor(R.color.colorI)); holder.imdmLabel.setTextColor(getResources().getColor(R.color.colorI));
} }else
holder.imdmLayout.setVisibility(View.INVISIBLE);
if(!message.isOutgoing()){ if(!message.isOutgoing()){
holder.imdmLayout.setVisibility(View.INVISIBLE); holder.imdmLayout.setVisibility(View.INVISIBLE);
} }
@ -1230,7 +1233,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
if (LinphoneManager.getInstance().getMessageUploadPending() != null && LinphoneManager.getInstance().getMessageUploadPending().getStorageId() == message.getStorageId()) { if (LinphoneManager.getInstance().getMessageUploadPending() != null && LinphoneManager.getInstance().getMessageUploadPending().getStorageId() == message.getStorageId()) {
holder.messageSendingInProgress.setVisibility(View.GONE); holder.messageSendingInProgress.setVisibility(View.GONE);
holder.fileTransferLayout.setVisibility(View.VISIBLE); holder.fileTransferLayout.setVisibility(View.VISIBLE);
LinphoneManager.addListener(holder); //LinphoneManager.addListener(holder);
} }
} else { } else {
if (appData != null && !LinphoneManager.getInstance().isMessagePending(message) && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0])) { if (appData != null && !LinphoneManager.getInstance().isMessagePending(message) && appData.contains(context.getString(R.string.temp_photo_name_with_date).split("%s")[0])) {
@ -1238,15 +1241,15 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
} }
if (appData == null) { if (appData == null) {
LinphoneManager.addListener(holder); //LinphoneManager.addListener(holder);
holder.fileTransferLayout.setVisibility(View.VISIBLE); holder.fileTransferLayout.setVisibility(View.VISIBLE);
} else { } else {
if (LinphoneManager.getInstance().isMessagePending(message)) { if (LinphoneManager.getInstance().isMessagePending(message)) {
LinphoneManager.addListener(holder); //LinphoneManager.addListener(holder);
holder.fileTransferAction.setEnabled(false); holder.fileTransferAction.setEnabled(false);
holder.fileTransferLayout.setVisibility(View.VISIBLE); holder.fileTransferLayout.setVisibility(View.VISIBLE);
} else { } else {
LinphoneManager.removeListener(holder); //LinphoneManager.removeListener(holder);
holder.fileTransferLayout.setVisibility(View.GONE); holder.fileTransferLayout.setVisibility(View.GONE);
holder.messageImage.setVisibility(View.VISIBLE); holder.messageImage.setVisibility(View.VISIBLE);
if (!sameMessage) { if (!sameMessage) {
@ -1631,6 +1634,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
//LinphoneChatMessage Listener //LinphoneChatMessage Listener
@Override @Override
public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) { public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
Log.e(" =======>>>>>>> onLinphoneChatMessageStateChanged - state = "+state.toString());
redrawMessageList(); redrawMessageList();
} }

@ -1 +1 @@
Subproject commit a570c27e172ea65166d2ef815fda4db40f24ee65 Subproject commit f74e37becfc6377bd7124b72aca129310dff8e15