Allow multiple SIP addresses in in-app contact editor

This commit is contained in:
Sylvain Berfini 2012-11-13 14:59:46 +01:00
parent 4196b5c28b
commit 019e494a53
4 changed files with 21 additions and 14 deletions

View file

@ -23,6 +23,7 @@
<bool name="use_first_login_activity">true</bool> <bool name="use_first_login_activity">true</bool>
<bool name="use_android_native_contact_edit_interface">false</bool> <bool name="use_android_native_contact_edit_interface">false</bool>
<!-- The following settings are only usefull if use_android_native_contact_edit_interface = false -->
<bool name="hide_phone_numbers_in_editor">false</bool> <bool name="hide_phone_numbers_in_editor">false</bool>
<bool name="hide_sip_addresses_in_editor">false</bool> <bool name="hide_sip_addresses_in_editor">false</bool>
<bool name="forbid_empty_new_contact_in_editor">false</bool> <bool name="forbid_empty_new_contact_in_editor">false</bool>

View file

@ -216,8 +216,11 @@ public class ChatStorage {
Cursor c = db.query(TABLE_NAME, null, null, null, "remoteContact", null, "id DESC"); Cursor c = db.query(TABLE_NAME, null, null, null, "remoteContact", null, "id DESC");
while (c != null && c.moveToNext()) { while (c != null && c.moveToNext()) {
String remoteContact = c.getString(c.getColumnIndex("remoteContact")); try {
chatList.add(remoteContact); String remoteContact = c.getString(c.getColumnIndex("remoteContact"));
chatList.add(remoteContact);
} catch (IllegalStateException ise) {
}
} }
c.close(); c.close();

View file

@ -176,7 +176,6 @@ public class EditContactFragment extends Fragment {
if (firstSipAddressIndex == -1) { if (firstSipAddressIndex == -1) {
firstSipAddressIndex = controls.getChildCount(); firstSipAddressIndex = controls.getChildCount();
} }
numberOrAddress = numberOrAddress.replace("sip:", ""); numberOrAddress = numberOrAddress.replace("sip:", "");
} }
if ((getResources().getBoolean(R.bool.hide_phone_numbers_in_editor) && !isSip) || (getResources().getBoolean(R.bool.hide_sip_addresses_in_editor) && isSip)) { if ((getResources().getBoolean(R.bool.hide_phone_numbers_in_editor) && !isSip) || (getResources().getBoolean(R.bool.hide_sip_addresses_in_editor) && isSip)) {
@ -212,8 +211,6 @@ public class EditContactFragment extends Fragment {
nounoa.delete(); nounoa.delete();
numbersAndAddresses.remove(nounoa); numbersAndAddresses.remove(nounoa);
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
if (isSip) // Add back the add SIP row
addEmptyRowToAllowNewNumberOrAddress(controls, true);
} }
}); });
@ -240,10 +237,8 @@ public class EditContactFragment extends Fragment {
} }
if (!getResources().getBoolean(R.bool.hide_sip_addresses_in_editor)) { if (!getResources().getBoolean(R.bool.hide_sip_addresses_in_editor)) {
if (firstSipAddressIndex == -1) { // Only add new SIP address field if there is no SIP address yet firstSipAddressIndex = controls.getChildCount() - 2; // Update the value to always display phone numbers before SIP accounts
firstSipAddressIndex = controls.getChildCount() - 2; // Update the value to alwas display phone numbers before SIP accounts addEmptyRowToAllowNewNumberOrAddress(controls, true);
addEmptyRowToAllowNewNumberOrAddress(controls, true);
}
} }
} }
@ -277,18 +272,20 @@ public class EditContactFragment extends Fragment {
public void onClick(View v) { public void onClick(View v) {
// Add a line, and change add button for a delete button // Add a line, and change add button for a delete button
add.setImageResource(R.drawable.list_delete); add.setImageResource(R.drawable.list_delete);
add.setOnClickListener(new OnClickListener() { ImageView delete = add;
delete.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
nounoa.delete();
numbersAndAddresses.remove(nounoa); numbersAndAddresses.remove(nounoa);
view.setVisibility(View.GONE); view.setVisibility(View.GONE);
if (isSip) // Add back the add SIP row
addEmptyRowToAllowNewNumberOrAddress(controls, true);
} }
}); });
if (!isSip) { // Only 1 SIP address / contact if (!isSip) {
firstSipAddressIndex++; firstSipAddressIndex++;
addEmptyRowToAllowNewNumberOrAddress(controls, false); addEmptyRowToAllowNewNumberOrAddress(controls, false);
} else {
addEmptyRowToAllowNewNumberOrAddress(controls, true);
} }
} }
}); });
@ -474,6 +471,8 @@ public class EditContactFragment extends Fragment {
private void addNewNumber() { private void addNewNumber() {
if (isNewContact) { if (isNewContact) {
if (isSipAddress) { if (isSipAddress) {
if (newNumberOrAddress.startsWith("sip:"))
newNumberOrAddress = newNumberOrAddress.substring(4);
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress); Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress);
} else { } else {
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
@ -489,6 +488,8 @@ public class EditContactFragment extends Fragment {
String rawContactId = findRawContactID(String.valueOf(contactID)); String rawContactId = findRawContactID(String.valueOf(contactID));
if (isSipAddress) { if (isSipAddress) {
if (newNumberOrAddress.startsWith("sip:"))
newNumberOrAddress = newNumberOrAddress.substring(4);
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId); Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId);
} else { } else {
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI) ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
@ -505,6 +506,8 @@ public class EditContactFragment extends Fragment {
private void updateNumber() { private void updateNumber() {
if (isSipAddress) { if (isSipAddress) {
if (newNumberOrAddress.startsWith("sip:"))
newNumberOrAddress = newNumberOrAddress.substring(4);
Compatibility.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID)); Compatibility.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID));
} else { } else {
String select = ContactsContract.Data.CONTACT_ID + "=? AND " String select = ContactsContract.Data.CONTACT_ID + "=? AND "

View file

@ -131,7 +131,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
private void answer() { private void answer() {
LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters(); LinphoneCallParams params = LinphoneManager.getLc().createDefaultCallParameters();
if (mCall != null && mCall.getRemoteParams().getVideoEnabled() && LinphoneManager.getInstance().isAutoAcceptCamera()) { if (mCall != null && mCall.getRemoteParams() != null && mCall.getRemoteParams().getVideoEnabled() && LinphoneManager.isInstanciated() && LinphoneManager.getInstance().isAutoAcceptCamera()) {
params.setVideoEnabled(true); params.setVideoEnabled(true);
} else { } else {
params.setVideoEnabled(false); params.setVideoEnabled(false);