mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-10-14 15:29:16 +00:00
Some minor fixes
This commit is contained in:
parent
797bb78d20
commit
4be6a25eb6
|
@ -56,5 +56,6 @@ class PlainTextFormatter private constructor(
|
|||
private fun shortClassName(className: String) = className
|
||||
.replace("at.bitfire.davdroid.", "")
|
||||
.replace("at.bitfire.", "")
|
||||
.replace(Regex("\\$.*$"), "")
|
||||
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class LocalGroup: AndroidGroup, LocalResource {
|
|||
}
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
||||
// workaround for Android 7 which sets DIRTY flag when only meta-data is changed
|
||||
changeContactIDs
|
||||
.map { LocalContact(addressBook, it, null, null) }
|
||||
|
|
|
@ -62,7 +62,7 @@ class CalendarsSyncAdapterService: SyncAdapterService() {
|
|||
fun getService() =
|
||||
db.query(ServiceDB.Services._TABLE, arrayOf(ServiceDB.Services.ID),
|
||||
"${ServiceDB.Services.ACCOUNT_NAME}=? AND ${ServiceDB.Services.SERVICE}=?",
|
||||
arrayOf(account.name, ServiceDB.Services.SERVICE_CARDDAV), null, null, null)?.use { c ->
|
||||
arrayOf(account.name, ServiceDB.Services.SERVICE_CALDAV), null, null, null)?.use { c ->
|
||||
if (c.moveToNext())
|
||||
c.getLong(0)
|
||||
else
|
||||
|
|
|
@ -165,7 +165,7 @@ class ContactsSyncManager(
|
|||
App.log.fine("Looking for changed group memberships of contact ${contact.fileName}")
|
||||
val cachedGroups = contact.getCachedGroupMemberships()
|
||||
val currentGroups = contact.getGroupMemberships()
|
||||
for (groupID in cachedGroups.minus(currentGroups)) {
|
||||
for (groupID in cachedGroups disjunct currentGroups) {
|
||||
App.log.fine("Marking group as dirty: $groupID")
|
||||
batch.enqueue(BatchOperation.Operation(
|
||||
ContentProviderOperation.newUpdate(localAddressBook.syncAdapterURI(ContentUris.withAppendedId(Groups.CONTENT_URI, groupID)))
|
||||
|
|
|
@ -89,6 +89,11 @@ abstract class SyncManager(
|
|||
protected val toDownload = mutableSetOf<DavResource>()
|
||||
|
||||
|
||||
companion object {
|
||||
infix fun <T> Set<T>.disjunct(other: Set<T>) = (this - other) union (other - this)
|
||||
}
|
||||
|
||||
|
||||
protected abstract fun notificationId(): Int
|
||||
protected abstract fun getSyncErrorTitle(): String
|
||||
|
||||
|
|
|
@ -675,7 +675,7 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
|||
|
||||
protected static void requestSync(Account account) {
|
||||
String authorities[] = {
|
||||
App.addressBookAccountType,
|
||||
App.addressBooksAuthority,
|
||||
CalendarContract.AUTHORITY,
|
||||
TaskProvider.ProviderName.OpenTasks.getAuthority()
|
||||
};
|
||||
|
|
|
@ -112,7 +112,7 @@ public class CreateCalendarActivity extends AppCompatActivity implements LoaderM
|
|||
}
|
||||
|
||||
edit = (EditText)findViewById(R.id.description);
|
||||
info.setDisplayName(StringUtils.trimToNull(edit.getText().toString()));
|
||||
info.setDescription(StringUtils.trimToNull(edit.getText().toString()));
|
||||
|
||||
View view = findViewById(R.id.color);
|
||||
info.setColor(((ColorDrawable)view.getBackground()).getColor());
|
||||
|
|
|
@ -137,7 +137,7 @@ public class AccountDetailsFragment extends Fragment {
|
|||
String groupMethodName = getResources().getStringArray(R.array.settings_contact_group_method_values)[idx];
|
||||
settings.setGroupMethod(GroupMethod.valueOf(groupMethodName));
|
||||
|
||||
// contact sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_contacts.xml
|
||||
// contact sync is automatically enabled by isAlwaysSyncable="true" in res/xml/sync_address_books.xml
|
||||
settings.setSyncInterval(App.addressBooksAuthority, Constants.DEFAULT_SYNC_INTERVAL);
|
||||
} else
|
||||
ContentResolver.setIsSyncable(account, App.addressBooksAuthority, 0);
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright © Ricki Hirner (bitfire web engineering).
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Public License v3.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*/
|
||||
|
||||
package at.bitfire.davdroid.syncadapter;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import at.bitfire.davdroid.DavUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class SyncManagerTest {
|
||||
|
||||
@Test
|
||||
public void testUnion() {
|
||||
Set<Integer> A = new HashSet<>(Arrays.asList(new Integer[] { 1,2,3 }));
|
||||
Set<Integer> B = new HashSet<>(Arrays.asList(new Integer[] { 1,4,5 }));
|
||||
|
||||
assertEquals(new HashSet<>(Arrays.asList(new Integer[] { 2,3,4,5 })), SyncManager.Companion.disjunct(A, B));
|
||||
assertEquals(new HashSet<>(Arrays.asList(new Integer[] { 2,3,4,5 })), SyncManager.Companion.disjunct(B, A));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue