From ed8734f55d1dbd002342defc194258d06e18d9fd Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 21 Jul 2016 10:49:48 +0200 Subject: [PATCH] Fix layout for SIP addresses in contact editor + fix native contacts with friends being duplicated in UI --- res/layout/chat.xml | 4 ++-- src/org/linphone/ChatFragment.java | 2 +- src/org/linphone/ContactEditorFragment.java | 8 ++++++-- src/org/linphone/ContactsManager.java | 19 ++++++++++++------- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/res/layout/chat.xml b/res/layout/chat.xml index 1964fa8d6..7d8274577 100644 --- a/res/layout/chat.xml +++ b/res/layout/chat.xml @@ -94,9 +94,9 @@ android:textColor="@color/colorB" android:imeOptions="flagNoExtractUi" android:textCursorDrawable="@null" - android:inputType="textMultiLine" + android:inputType="textShortMessage|textMultiLine" android:contentDescription="@string/content_description_message" - android:maxLines="3" + android:maxLines="2" android:padding="5dp" android:layout_margin="5dp" android:layout_weight="1" diff --git a/src/org/linphone/ChatFragment.java b/src/org/linphone/ChatFragment.java index 6c5cdafd8..8585c07f9 100644 --- a/src/org/linphone/ChatFragment.java +++ b/src/org/linphone/ChatFragment.java @@ -61,6 +61,7 @@ import android.os.Parcelable; import android.provider.MediaStore; import android.support.v4.content.CursorLoader; import android.text.Editable; +import android.text.InputType; import android.text.TextWatcher; import android.view.ContextMenu; import android.view.Gravity; @@ -183,7 +184,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC initNewChatConversation(); } - //Manage multiline message = (EditText) view.findViewById(R.id.message); sendImage = (ImageView) view.findViewById(R.id.send_picture); diff --git a/src/org/linphone/ContactEditorFragment.java b/src/org/linphone/ContactEditorFragment.java index 5f6805b9f..829145160 100644 --- a/src/org/linphone/ContactEditorFragment.java +++ b/src/org/linphone/ContactEditorFragment.java @@ -512,7 +512,9 @@ public class ContactEditorFragment extends Fragment { final View view = inflater.inflate(R.layout.contact_edit_row, null); final EditText noa = (EditText) view.findViewById(R.id.numoraddr); - noa.setInputType(isSIP ? InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS : InputType.TYPE_CLASS_PHONE); + if (!isSIP) { + noa.setInputType(InputType.TYPE_CLASS_PHONE); + } noa.setText(numberOrAddress); noa.addTextChangedListener(new TextWatcher() { @Override @@ -558,7 +560,9 @@ public class ContactEditorFragment extends Fragment { final EditText noa = (EditText) view.findViewById(R.id.numoraddr); numbersAndAddresses.add(nounoa); noa.setHint(isSip ? getString(R.string.sip_address) : getString(R.string.phone_number)); - noa.setInputType(isSip ? InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS : InputType.TYPE_CLASS_PHONE); + if (!isSip) { + noa.setInputType(InputType.TYPE_CLASS_PHONE); + } noa.requestFocus(); noa.addTextChangedListener(new TextWatcher() { @Override diff --git a/src/org/linphone/ContactsManager.java b/src/org/linphone/ContactsManager.java index 4ef77b6ea..811fc1e60 100644 --- a/src/org/linphone/ContactsManager.java +++ b/src/org/linphone/ContactsManager.java @@ -250,20 +250,25 @@ public class ContactsManager extends ContentObserver { boolean found = false; for (LinphoneContact contact : contacts) { if (refkey.equals(contact.getAndroidId())) { + // Native matching contact found, link the friend to it contact.setFriend(friend); found = true; break; } } - if (!found && hasContactAccess) { - // If refkey != null but there isn't a native contact with this value, then this contact has been deleted. Let's do the same with the LinphoneFriend - LinphoneManager.getLc().removeFriend(friend); - } else { - LinphoneContact contact = new LinphoneContact(); - contact.setFriend(friend); - contacts.add(contact); + if (!found) { + if (hasContactAccess) { + // If refkey != null and hasContactAccess but there isn't a native contact with this value, then this contact has been deleted. Let's do the same with the LinphoneFriend + LinphoneManager.getLc().removeFriend(friend); + } else { + // Refkey not null but no contact access => can't link it to native contact so display it on is own + LinphoneContact contact = new LinphoneContact(); + contact.setFriend(friend); + contacts.add(contact); + } } } else { + // No refkey so it's a standalone contact LinphoneContact contact = new LinphoneContact(); contact.setFriend(friend); contacts.add(contact);