Fix contact editor

This commit is contained in:
Sylvain Berfini 2012-11-29 18:03:14 +01:00
parent c24b603b29
commit 07bf1bb900
3 changed files with 19 additions and 13 deletions

View file

@ -33,6 +33,7 @@ public class EditContactFragment extends Fragment {
private View deleteContact;
private boolean isNewContact = true;
private Contact contact;
private int contactID;
private List<NewOrUpdatedNumberOrAddress> numbersAndAddresses;
private ArrayList<ContentProviderOperation> ops;
@ -41,7 +42,7 @@ public class EditContactFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
this.inflater = inflater;
Contact contact = null;
contact = null;
if (getArguments() != null && getArguments().getSerializable("Contact") != null) {
contact = (Contact) getArguments().getSerializable("Contact");
isNewContact = false;
@ -147,6 +148,7 @@ public class EditContactFragment extends Fragment {
lastName.setText(ln);
} else {
lastName.setText(contact.getName());
firstName.setText("");
}
}
@ -317,7 +319,8 @@ public class EditContactFragment extends Fragment {
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, contactID)
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, getDisplayName())
.withValue(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, firstName.getText().toString())
.withValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, lastName.getText().toString())
.build()
);
}
@ -331,7 +334,8 @@ public class EditContactFragment extends Fragment {
ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)
.withSelection(select, args)
.withValue(ContactsContract.Data.MIMETYPE, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, getDisplayName())
.withValue(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, firstName.getText().toString())
.withValue(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, lastName.getText().toString())
.build()
);
}
@ -383,8 +387,8 @@ public class EditContactFragment extends Fragment {
private String findContactFirstName(String contactID) {
Cursor c = getActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
new String[]{ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME},
RawContacts.CONTACT_ID + "=?",
new String[]{contactID}, null);
ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?",
new String[]{contactID, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE}, null);
if (c != null) {
String result = null;
if (c.moveToFirst()) {
@ -399,8 +403,8 @@ public class EditContactFragment extends Fragment {
private String findContactLastName(String contactID) {
Cursor c = getActivity().getContentResolver().query(ContactsContract.Data.CONTENT_URI,
new String[]{ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME},
RawContacts.CONTACT_ID + "=?",
new String[]{contactID}, null);
ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "=?",
new String[]{contactID, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE}, null);
if (c != null) {
String result = null;
if (c.moveToFirst()) {

View file

@ -542,13 +542,12 @@ public final class LinphoneManager implements LinphoneCoreListener {
}
void initMediaEncryption(){
String pref = getPrefString(R.string.pref_media_encryption_key,
R.string.pref_media_encryption_key_none);
String pref = getPrefString(R.string.pref_media_encryption_key, R.string.pref_media_encryption_key_none);
MediaEncryption me=MediaEncryption.None;
if (pref.equals(getString(R.string.pref_media_encryption_key_srtp)))
me=MediaEncryption.SRTP;
me = MediaEncryption.SRTP;
else if (pref.equals(getString(R.string.pref_media_encryption_key_zrtp)))
me=MediaEncryption.ZRTP;
me = MediaEncryption.ZRTP;
Log.i("Media encryption set to "+pref);
mLc.setMediaEncryption(me);
}
@ -585,7 +584,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
lDefaultProxyConfig.setDialPrefix(lPrefix);
}
//escape +
lDefaultProxyConfig.setDialEscapePlus(getPrefBoolean(R.string.pref_escape_plus_key,false));
lDefaultProxyConfig.setDialEscapePlus(getPrefBoolean(R.string.pref_escape_plus_key, false));
}
}

View file

@ -394,7 +394,10 @@ public class PreferencesFragment extends PreferencesListFragment implements EcCa
}
private void initializeMediaEncryptionPreferences() {
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
LinphoneCore lc = null;
try {
lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
} catch (Exception e) {}
List<CharSequence> mencEntries=new ArrayList<CharSequence>();
List<CharSequence> mencEntryValues=new ArrayList<CharSequence>();