Add parameter for linphone tag and fix chat dispaly

This commit is contained in:
Margaux Clerc 2015-04-15 16:38:55 +02:00
parent 8bfcafa9a3
commit 688dcebe42
4 changed files with 34 additions and 24 deletions

View file

@ -50,6 +50,7 @@
<bool name="display_time_aside">false</bool> <!-- if display_messages_time = true, display time on the side of the message instead of below -->
<bool name="enable_linphone_friends">false</bool>
<bool name="use_linphone_tag">true</bool>
<bool name="display_call_stats">true</bool>
<bool name="show_current_calls_above_video">false</bool>

View file

@ -425,9 +425,11 @@ public class ContactsManager {
contact.refresh(contentResolver);
//Add tag to Linphone contact if it not existed
if(!isContactHasLinphoneTag(contact,contentResolver)){
Compatibility.createLinphoneContactTag(context,contentResolver,contact,
findRawContactID(contentResolver, String.valueOf(contact.getID())));
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
if (!isContactHasLinphoneTag(contact, contentResolver)) {
Compatibility.createLinphoneContactTag(context, contentResolver, contact,
findRawContactID(contentResolver, String.valueOf(contact.getID())));
}
}
sipContactList.add(contact);
@ -441,10 +443,11 @@ public class ContactsManager {
continue;
//Remove linphone contact tag if the contact has no sip address
if(removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact,contentResolver)){
removeLinphoneContactTag(contact);
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
if (removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact, contentResolver)) {
removeLinphoneContactTag(contact);
}
}
for (Contact c : sipContactList) {
if (c != null && c.getID().equals(contact.getID())) {
contact = c;

View file

@ -466,7 +466,9 @@ public class EditContactFragment extends Fragment {
} else {
Compatibility.deleteSipAddressFromContact(ops, oldNumberOrAddress, String.valueOf(contactID));
}
Compatibility.deleteLinphoneContactTag(ops, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
Compatibility.deleteLinphoneContactTag(ops, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
}
} else {
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "
@ -525,7 +527,9 @@ public class EditContactFragment extends Fragment {
}
Compatibility.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId);
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
}
} else {
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId)
@ -557,7 +561,9 @@ public class EditContactFragment extends Fragment {
}
}
Compatibility.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID));
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
}
} else {
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "

View file

@ -149,7 +149,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
}
}
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
}
if(!LinphonePreferences.instance().isContactsMigrationDone()){
ContactsManager.getInstance().migrateContacts();
@ -613,21 +615,19 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
String displayName = contact != null ? contact.getName() : null;
String pictureUri = contact != null && contact.getPhotoUri() != null ? contact.getPhotoUri().toString() : null;
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT) {
if (isTablet()) {
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
ChatFragment chatFragment = (ChatFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
} else {
Bundle extras = new Bundle();
extras.putString("SipUri", sipUri);
if (lAddress.getDisplayName() != null) {
extras.putString("DisplayName", displayName);
extras.putString("PictureUri", pictureUri);
}
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
if (isTablet() && (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT)) {
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
ChatFragment chatFragment = (ChatFragment) fragment2;
chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
} else {
Bundle extras = new Bundle();
extras.putString("SipUri", sipUri);
if (lAddress.getDisplayName() != null) {
extras.putString("DisplayName", displayName);
extras.putString("PictureUri", pictureUri);
}
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
}
} else {
Intent intent = new Intent(this, ChatActivity.class);