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;
|
||||
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) {
|
||||
|
|
|
@ -235,12 +235,6 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(AsyncContactsData data) {
|
||||
|
||||
for (ContactsUpdatedListener listener :
|
||||
ContactsManager.getInstance().getContactsListeners()) {
|
||||
listener.onContactsUpdated();
|
||||
}
|
||||
|
||||
for (LinphoneContact contact : data.contacts) {
|
||||
contact.createOrUpdateFriendFromNativeContact();
|
||||
}
|
||||
|
@ -255,6 +249,11 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
|
|||
|
||||
ContactsManager.getInstance().setContacts(data.contacts);
|
||||
ContactsManager.getInstance().setSipContacts(data.sipContacts);
|
||||
|
||||
for (ContactsUpdatedListener listener :
|
||||
ContactsManager.getInstance().getContactsListeners()) {
|
||||
listener.onContactsUpdated();
|
||||
}
|
||||
Log.i("[Contacts Manager] Synchronization finished");
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,8 @@ import org.linphone.settings.LinphonePreferences;
|
|||
import org.linphone.utils.ImageUtils;
|
||||
import org.linphone.utils.LinphoneUtils;
|
||||
|
||||
public class ContactDetailsFragment extends Fragment implements OnClickListener {
|
||||
public class ContactDetailsFragment extends Fragment
|
||||
implements OnClickListener, ContactsUpdatedListener {
|
||||
private LinphoneContact mContact;
|
||||
private ImageView mEditContact, mDeleteContact, mBack;
|
||||
private TextView mOrganization;
|
||||
|
@ -180,14 +181,6 @@ public class ContactDetailsFragment extends Fragment implements OnClickListener
|
|||
return mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mChatRoom != null) {
|
||||
mChatRoom.removeListener(mChatRoomCreationListener);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public void changeDisplayedContact(LinphoneContact newContact) {
|
||||
mContact = newContact;
|
||||
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
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
ContactsManager.getInstance().addContactsListener(this);
|
||||
if (LinphoneActivity.isInstanciated()) {
|
||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT_DETAIL);
|
||||
}
|
||||
// mContact.refresh();
|
||||
displayContact(mInflater, mView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if (mChatRoom != null) {
|
||||
mChatRoom.removeListener(mChatRoomCreationListener);
|
||||
}
|
||||
ContactsManager.getInstance().removeContactsListener(this);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
|
|
|
@ -360,8 +360,9 @@ public class ContactsFragment extends Fragment
|
|||
@Override
|
||||
public void onContactsUpdated() {
|
||||
if (!LinphoneActivity.isInstanciated()
|
||||
|| LinphoneActivity.instance().getCurrentFragment()
|
||||
!= FragmentsAvailable.CONTACTS_LIST) return;
|
||||
|| (LinphoneActivity.instance().getCurrentFragment()
|
||||
!= FragmentsAvailable.CONTACTS_LIST
|
||||
&& !LinphoneActivity.instance().isTablet())) return;
|
||||
if (mContactAdapter != null) {
|
||||
mContactAdapter.updateDataSet(
|
||||
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) {
|
||||
if (address == null) return null;
|
||||
Core lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||
|
@ -480,10 +491,10 @@ public class ContactsManager extends ContentObserver implements FriendListListen
|
|||
Collections.sort(mSipContacts);
|
||||
Collections.sort(mGroupChatContacts);
|
||||
Collections.sort(mLimeX3dhContacts);
|
||||
}
|
||||
|
||||
for (ContactsUpdatedListener listener : mContactsUpdatedListeners) {
|
||||
listener.onContactsUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue