Fixes & improvements for contacts, most of them for tablets
This commit is contained in:
parent
81905e853a
commit
4c394c9f1b
5 changed files with 43 additions and 34 deletions
|
@ -113,19 +113,6 @@ class AndroidContact implements Serializable {
|
||||||
mAndroidRawId = rawId;
|
mAndroidRawId = rawId;
|
||||||
isAndroidRawIdLinphone = true;
|
isAndroidRawIdLinphone = true;
|
||||||
}
|
}
|
||||||
/*if (rawId.equals(mAndroidRawId)) {
|
|
||||||
Log.i("[Contact] Contact with RAW ID " + rawId + " updated");
|
|
||||||
} else {
|
|
||||||
if (mAndroidRawId != null && isAndroidRawIdLinphone) {
|
|
||||||
Log.w(
|
|
||||||
"[Contact] Linphone RAW ID "
|
|
||||||
+ rawId
|
|
||||||
+ " doesn't match existing RAW ID "
|
|
||||||
+ mAndroidRawId);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -235,12 +235,6 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(AsyncContactsData data) {
|
protected void onPostExecute(AsyncContactsData data) {
|
||||||
|
|
||||||
for (ContactsUpdatedListener listener :
|
|
||||||
ContactsManager.getInstance().getContactsListeners()) {
|
|
||||||
listener.onContactsUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (LinphoneContact contact : data.contacts) {
|
for (LinphoneContact contact : data.contacts) {
|
||||||
contact.createOrUpdateFriendFromNativeContact();
|
contact.createOrUpdateFriendFromNativeContact();
|
||||||
}
|
}
|
||||||
|
@ -255,6 +249,11 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
|
||||||
|
|
||||||
ContactsManager.getInstance().setContacts(data.contacts);
|
ContactsManager.getInstance().setContacts(data.contacts);
|
||||||
ContactsManager.getInstance().setSipContacts(data.sipContacts);
|
ContactsManager.getInstance().setSipContacts(data.sipContacts);
|
||||||
|
|
||||||
|
for (ContactsUpdatedListener listener :
|
||||||
|
ContactsManager.getInstance().getContactsListeners()) {
|
||||||
|
listener.onContactsUpdated();
|
||||||
|
}
|
||||||
Log.i("[Contacts Manager] Synchronization finished");
|
Log.i("[Contacts Manager] Synchronization finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ import org.linphone.settings.LinphonePreferences;
|
||||||
import org.linphone.utils.ImageUtils;
|
import org.linphone.utils.ImageUtils;
|
||||||
import org.linphone.utils.LinphoneUtils;
|
import org.linphone.utils.LinphoneUtils;
|
||||||
|
|
||||||
public class ContactDetailsFragment extends Fragment implements OnClickListener {
|
public class ContactDetailsFragment extends Fragment
|
||||||
|
implements OnClickListener, ContactsUpdatedListener {
|
||||||
private LinphoneContact mContact;
|
private LinphoneContact mContact;
|
||||||
private ImageView mEditContact, mDeleteContact, mBack;
|
private ImageView mEditContact, mDeleteContact, mBack;
|
||||||
private TextView mOrganization;
|
private TextView mOrganization;
|
||||||
|
@ -180,14 +181,6 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
return mView;
|
return mView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
if (mChatRoom != null) {
|
|
||||||
mChatRoom.removeListener(mChatRoomCreationListener);
|
|
||||||
}
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeDisplayedContact(LinphoneContact newContact) {
|
public void changeDisplayedContact(LinphoneContact newContact) {
|
||||||
mContact = newContact;
|
mContact = newContact;
|
||||||
displayContact(mInflater, mView);
|
displayContact(mInflater, mView);
|
||||||
|
@ -317,17 +310,35 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContactsUpdated() {
|
||||||
|
LinphoneContact contact =
|
||||||
|
ContactsManager.getInstance().findContactFromAndroidId(mContact.getAndroidId());
|
||||||
|
if (contact != null) {
|
||||||
|
changeDisplayedContact(contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
ContactsManager.getInstance().addContactsListener(this);
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
||||||
}
|
}
|
||||||
// mContact.refresh();
|
|
||||||
displayContact(mInflater, mView);
|
displayContact(mInflater, mView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
if (mChatRoom != null) {
|
||||||
|
mChatRoom.removeListener(mChatRoomCreationListener);
|
||||||
|
}
|
||||||
|
ContactsManager.getInstance().removeContactsListener(this);
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
|
|
|
@ -360,8 +360,9 @@ public class ContactsFragment extends Fragment
|
||||||
@Override
|
@Override
|
||||||
public void onContactsUpdated() {
|
public void onContactsUpdated() {
|
||||||
if (!LinphoneActivity.isInstanciated()
|
if (!LinphoneActivity.isInstanciated()
|
||||||
|| LinphoneActivity.instance().getCurrentFragment()
|
|| (LinphoneActivity.instance().getCurrentFragment()
|
||||||
!= FragmentsAvailable.CONTACTS_LIST) return;
|
!= FragmentsAvailable.CONTACTS_LIST
|
||||||
|
&& !LinphoneActivity.instance().isTablet())) return;
|
||||||
if (mContactAdapter != null) {
|
if (mContactAdapter != null) {
|
||||||
mContactAdapter.updateDataSet(
|
mContactAdapter.updateDataSet(
|
||||||
mOnlyDisplayLinphoneContacts
|
mOnlyDisplayLinphoneContacts
|
||||||
|
|
|
@ -335,6 +335,17 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized LinphoneContact findContactFromAndroidId(String androidId) {
|
||||||
|
if (androidId == null) return null;
|
||||||
|
|
||||||
|
for (LinphoneContact c : getContacts()) {
|
||||||
|
if (c.getAndroidId() != null && c.getAndroidId().equals(androidId)) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized LinphoneContact findContactFromAddress(Address address) {
|
public synchronized LinphoneContact findContactFromAddress(Address address) {
|
||||||
if (address == null) return null;
|
if (address == null) return null;
|
||||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
@ -480,10 +491,10 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
||||||
Collections.sort(mSipContacts);
|
Collections.sort(mSipContacts);
|
||||||
Collections.sort(mGroupChatContacts);
|
Collections.sort(mGroupChatContacts);
|
||||||
Collections.sort(mLimeX3dhContacts);
|
Collections.sort(mLimeX3dhContacts);
|
||||||
|
}
|
||||||
|
|
||||||
for (ContactsUpdatedListener listener : mContactsUpdatedListeners) {
|
for (ContactsUpdatedListener listener : mContactsUpdatedListeners) {
|
||||||
listener.onContactsUpdated();
|
listener.onContactsUpdated();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue