Improvements on package name use (since we had .debug to it sometimes) + fixed disapearing SIP contacts if they only have presence and no real SIP URI

This commit is contained in:
Sylvain Berfini 2018-12-06 15:44:34 +01:00
parent 54e7760fdd
commit 9d66458f36
8 changed files with 35 additions and 37 deletions

View file

@ -52,6 +52,7 @@ android {
versionName "4.1"
applicationId getPackageName()
multiDexEnabled true
manifestPlaceholders = [absolutePackageName:getPackageName()]
}
applicationVariants.all { variant ->

View file

@ -190,35 +190,32 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
for (LinphoneContact contact : androidContactsCache.values()) {
if (isCancelled()) return data;
boolean hideContactsWithoutPresence =
mContext.getResources().getBoolean(R.bool.hide_sip_contacts_without_presence);
if (contact.hasAddress()) {
if (contact.getFullName() == null) {
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
if (noa.isSIPAddress()) {
contact.setFullName(
LinphoneUtils.getAddressDisplayName(noa.getValue()));
Log.w(
"[Contacts Manager] Couldn't find a display name for contact "
+ contact.getFullName()
+ ", used SIP address display name / username instead...");
break;
}
if (contact.getFullName() == null) {
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
if (noa.isSIPAddress()) {
contact.setFullName(LinphoneUtils.getAddressDisplayName(noa.getValue()));
Log.w(
"[Contacts Manager] Couldn't find a display name for contact "
+ contact.getFullName()
+ ", used SIP address display name / username instead...");
break;
}
}
if (hideContactsWithoutPresence) {
if (contact.getFriend() != null) {
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
PresenceModel pm =
contact.getFriend().getPresenceModelForUriOrTel(noa.getValue());
if (pm != null
&& pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
data.sipContacts.add(contact);
break;
}
}
}
if (contact.getFriend() != null) {
for (LinphoneNumberOrAddress noa : contact.getNumbersOrAddresses()) {
PresenceModel pm =
contact.getFriend().getPresenceModelForUriOrTel(noa.getValue());
if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
data.sipContacts.add(contact);
break;
}
} else {
}
}
if (!mContext.getResources().getBoolean(R.bool.hide_sip_contacts_without_presence)) {
if (contact.hasAddress() && !data.sipContacts.contains(contact)) {
data.sipContacts.add(contact);
}
}

View file

@ -267,17 +267,18 @@ public class ContactsManager extends ContentObserver implements FriendListListen
AccountManager accountManager =
(AccountManager) activity.getSystemService(Context.ACCOUNT_SERVICE);
Account[] accounts = accountManager.getAccountsByType(activity.getPackageName());
Account[] accounts =
accountManager.getAccountsByType(mContext.getString(R.string.sync_account_type));
if (accounts != null && accounts.length == 0) {
Account newAccount =
new Account(
mContext.getString(R.string.sync_account_name),
activity.getPackageName());
mContext.getString(R.string.sync_account_type));
try {
accountManager.addAccountExplicitly(newAccount, null, null);
} catch (Exception e) {
Log.e("[Contacts Manager] " + e);
Log.e("[Contacts Manager] Couldn't initialize sync account: " + e);
}
}
}

View file

@ -776,10 +776,10 @@ public class LinphoneContact implements Serializable, Comparable<LinphoneContact
&& ContactsManager.getInstance().hasContactsAccess()
&& mChangesToCommit.size() > 0) {
try {
createLinphoneTagIfNeeded();
LinphoneService.instance()
.getContentResolver()
.applyBatch(ContactsContract.AUTHORITY, mChangesToCommit);
createLinphoneTagIfNeeded();
} catch (Exception e) {
Log.e(e);
} finally {

View file

@ -4,9 +4,9 @@
<!-- Global -->
<string name="default_domain">sip.linphone.org</string><!-- Set the default domain used for account creation/addresses -->
<string name="default_conference_factory_uri">sip:conference-factory@sip.linphone.org</string>
<string name="file_provider">org.linphone.provider</string>
<string name="sync_account_type">${applicationId}</string>
<string name="sync_mimetype">vnd.android.cursor.item/${applicationId}.profile</string>
<string name="file_provider">${absolutePackageName}.provider</string>
<string name="sync_account_type">${absolutePackageName}</string>
<string name="sync_mimetype">vnd.android.cursor.item/${absolutePackageName}.profile</string>
<string name="rls_uri">sip:rls@sip.linphone.org</string>
<string name="user_agent">LinphoneAndroid</string>
<bool name="orientation_portrait_only">false</bool>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<account-authenticator xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="@string/sync_account_type"
android:accountType="${absolutePackageName}"
android:icon="@drawable/linphone_logo"
android:label="@string/app_name"
android:smallIcon="@drawable/linphone_logo" />

View file

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android">
<ContactsDataKind
android:detailColumn="data3"
android:detailSocialSummary="true"
android:icon="@drawable/linphone_logo"
android:mimeType="vnd.android.cursor.item/${applicationId}.profile"
android:mimeType="vnd.android.cursor.item/${absolutePackageName}.profile"
android:summaryColumn="data2" />
</ContactsSource>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<sync-adapter xmlns:android="http://schemas.android.com/apk/res/android"
android:accountType="@string/sync_account_type"
android:accountType="${absolutePackageName}"
android:contentAuthority="com.android.contacts"
android:supportsUploading="false"
android:userVisible="false" />