Add parameter for linphone tag and fix chat dispaly
This commit is contained in:
parent
8bfcafa9a3
commit
688dcebe42
4 changed files with 34 additions and 24 deletions
|
@ -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="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="enable_linphone_friends">false</bool>
|
||||||
|
<bool name="use_linphone_tag">true</bool>
|
||||||
|
|
||||||
<bool name="display_call_stats">true</bool>
|
<bool name="display_call_stats">true</bool>
|
||||||
<bool name="show_current_calls_above_video">false</bool>
|
<bool name="show_current_calls_above_video">false</bool>
|
||||||
|
|
|
@ -425,10 +425,12 @@ public class ContactsManager {
|
||||||
|
|
||||||
contact.refresh(contentResolver);
|
contact.refresh(contentResolver);
|
||||||
//Add tag to Linphone contact if it not existed
|
//Add tag to Linphone contact if it not existed
|
||||||
if(!isContactHasLinphoneTag(contact,contentResolver)){
|
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
Compatibility.createLinphoneContactTag(context,contentResolver,contact,
|
if (!isContactHasLinphoneTag(contact, contentResolver)) {
|
||||||
|
Compatibility.createLinphoneContactTag(context, contentResolver, contact,
|
||||||
findRawContactID(contentResolver, String.valueOf(contact.getID())));
|
findRawContactID(contentResolver, String.valueOf(contact.getID())));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sipContactList.add(contact);
|
sipContactList.add(contact);
|
||||||
}
|
}
|
||||||
|
@ -441,10 +443,11 @@ public class ContactsManager {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Remove linphone contact tag if the contact has no sip address
|
//Remove linphone contact tag if the contact has no sip address
|
||||||
if(removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact,contentResolver)){
|
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
|
if (removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact, contentResolver)) {
|
||||||
removeLinphoneContactTag(contact);
|
removeLinphoneContactTag(contact);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (Contact c : sipContactList) {
|
for (Contact c : sipContactList) {
|
||||||
if (c != null && c.getID().equals(contact.getID())) {
|
if (c != null && c.getID().equals(contact.getID())) {
|
||||||
contact = c;
|
contact = c;
|
||||||
|
|
|
@ -466,7 +466,9 @@ public class EditContactFragment extends Fragment {
|
||||||
} else {
|
} else {
|
||||||
Compatibility.deleteSipAddressFromContact(ops, oldNumberOrAddress, String.valueOf(contactID));
|
Compatibility.deleteSipAddressFromContact(ops, oldNumberOrAddress, String.valueOf(contactID));
|
||||||
}
|
}
|
||||||
|
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
Compatibility.deleteLinphoneContactTag(ops, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
Compatibility.deleteLinphoneContactTag(ops, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
||||||
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' 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.addSipAddressToContact(getActivity(), ops, newNumberOrAddress, rawContactId);
|
||||||
|
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
Compatibility.addLinphoneContactTag(getActivity(), ops, newNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
|
||||||
.withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId)
|
.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.updateSipAddressForContact(ops, oldNumberOrAddress, newNumberOrAddress, String.valueOf(contactID));
|
||||||
|
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
Compatibility.updateLinphoneContactTag(getActivity(), ops, newNumberOrAddress, oldNumberOrAddress, contactsManager.findRawLinphoneContactID(String.valueOf(contactID)));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
String select = ContactsContract.Data.CONTACT_ID + "=? AND "
|
||||||
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "
|
+ ContactsContract.Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE + "' AND "
|
||||||
|
|
|
@ -149,7 +149,9 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
|
ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
|
||||||
|
}
|
||||||
|
|
||||||
if(!LinphonePreferences.instance().isContactsMigrationDone()){
|
if(!LinphonePreferences.instance().isContactsMigrationDone()){
|
||||||
ContactsManager.getInstance().migrateContacts();
|
ContactsManager.getInstance().migrateContacts();
|
||||||
|
@ -613,8 +615,7 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
String displayName = contact != null ? contact.getName() : null;
|
String displayName = contact != null ? contact.getName() : null;
|
||||||
String pictureUri = contact != null && contact.getPhotoUri() != null ? contact.getPhotoUri().toString() : null;
|
String pictureUri = contact != null && contact.getPhotoUri() != null ? contact.getPhotoUri().toString() : null;
|
||||||
|
|
||||||
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT) {
|
if (isTablet() && (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT)) {
|
||||||
if (isTablet()) {
|
|
||||||
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
|
||||||
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
|
if (fragment2 != null && fragment2.isVisible() && currentFragment == FragmentsAvailable.CHAT) {
|
||||||
ChatFragment chatFragment = (ChatFragment) fragment2;
|
ChatFragment chatFragment = (ChatFragment) fragment2;
|
||||||
|
@ -628,7 +629,6 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(this, ChatActivity.class);
|
Intent intent = new Intent(this, ChatActivity.class);
|
||||||
intent.putExtra("SipUri", sipUri);
|
intent.putExtra("SipUri", sipUri);
|
||||||
|
|
Loading…
Reference in a new issue