Fix layout for SIP addresses in contact editor + fix native contacts with friends being duplicated in UI

This commit is contained in:
Sylvain Berfini 2016-07-21 10:49:48 +02:00
parent 3244418765
commit ed8734f55d
4 changed files with 21 additions and 12 deletions

View file

@ -94,9 +94,9 @@
android:textColor="@color/colorB" android:textColor="@color/colorB"
android:imeOptions="flagNoExtractUi" android:imeOptions="flagNoExtractUi"
android:textCursorDrawable="@null" android:textCursorDrawable="@null"
android:inputType="textMultiLine" android:inputType="textShortMessage|textMultiLine"
android:contentDescription="@string/content_description_message" android:contentDescription="@string/content_description_message"
android:maxLines="3" android:maxLines="2"
android:padding="5dp" android:padding="5dp"
android:layout_margin="5dp" android:layout_margin="5dp"
android:layout_weight="1" android:layout_weight="1"

View file

@ -61,6 +61,7 @@ import android.os.Parcelable;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.v4.content.CursorLoader; import android.support.v4.content.CursorLoader;
import android.text.Editable; import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.Gravity; import android.view.Gravity;
@ -183,7 +184,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
initNewChatConversation(); initNewChatConversation();
} }
//Manage multiline
message = (EditText) view.findViewById(R.id.message); message = (EditText) view.findViewById(R.id.message);
sendImage = (ImageView) view.findViewById(R.id.send_picture); sendImage = (ImageView) view.findViewById(R.id.send_picture);

View file

@ -512,7 +512,9 @@ public class ContactEditorFragment extends Fragment {
final View view = inflater.inflate(R.layout.contact_edit_row, null); final View view = inflater.inflate(R.layout.contact_edit_row, null);
final EditText noa = (EditText) view.findViewById(R.id.numoraddr); 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.setText(numberOrAddress);
noa.addTextChangedListener(new TextWatcher() { noa.addTextChangedListener(new TextWatcher() {
@Override @Override
@ -558,7 +560,9 @@ public class ContactEditorFragment extends Fragment {
final EditText noa = (EditText) view.findViewById(R.id.numoraddr); final EditText noa = (EditText) view.findViewById(R.id.numoraddr);
numbersAndAddresses.add(nounoa); numbersAndAddresses.add(nounoa);
noa.setHint(isSip ? getString(R.string.sip_address) : getString(R.string.phone_number)); 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.requestFocus();
noa.addTextChangedListener(new TextWatcher() { noa.addTextChangedListener(new TextWatcher() {
@Override @Override

View file

@ -250,20 +250,25 @@ public class ContactsManager extends ContentObserver {
boolean found = false; boolean found = false;
for (LinphoneContact contact : contacts) { for (LinphoneContact contact : contacts) {
if (refkey.equals(contact.getAndroidId())) { if (refkey.equals(contact.getAndroidId())) {
// Native matching contact found, link the friend to it
contact.setFriend(friend); contact.setFriend(friend);
found = true; found = true;
break; break;
} }
} }
if (!found && hasContactAccess) { if (!found) {
// 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 if (hasContactAccess) {
LinphoneManager.getLc().removeFriend(friend); // 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
} else { LinphoneManager.getLc().removeFriend(friend);
LinphoneContact contact = new LinphoneContact(); } else {
contact.setFriend(friend); // Refkey not null but no contact access => can't link it to native contact so display it on is own
contacts.add(contact); LinphoneContact contact = new LinphoneContact();
contact.setFriend(friend);
contacts.add(contact);
}
} }
} else { } else {
// No refkey so it's a standalone contact
LinphoneContact contact = new LinphoneContact(); LinphoneContact contact = new LinphoneContact();
contact.setFriend(friend); contact.setFriend(friend);
contacts.add(contact); contacts.add(contact);