Commit ab88020c authored by Ricki Hirner's avatar Ricki Hirner 🐑

Sync logic fix, theming, ProGuard

parent e27c6fde
......@@ -18,7 +18,7 @@ android {
defaultConfig {
applicationId "at.bitfire.davdroid"
versionCode 205
versionCode 209
buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
buildConfigField "boolean", "customCerts", "true"
......@@ -33,10 +33,9 @@ android {
productFlavors {
standard {
versionName "1.10.1.1-ose"
versionName "1.11-beta1-ose"
buildConfigField "boolean", "customCerts", "true"
buildConfigField "boolean", "customCertsUI", "true"
}
}
......
......@@ -19,7 +19,7 @@
-dontwarn ezvcard.io.json.** # JSON serializer (for jCards) not used
-dontwarn freemarker.** # freemarker templating library (for creating hCards) not used
-dontwarn org.jsoup.** # jsoup library (for hCard parsing) not used
-keep class ezvcard.property.** { *; } # keep all VCard properties (created at runtime)
-keep class ezvcard.property.** { *; } # keep all vCard properties (created at runtime)
# ical4j: ignore unused dynamic libraries
-dontwarn aQute.**
......@@ -35,6 +35,7 @@
-dontwarn okio.**
-dontwarn javax.annotation.Nullable
-dontwarn javax.annotation.ParametersAreNonnullByDefault
-dontwarn org.conscrypt.**
# dnsjava
-dontwarn sun.net.spi.nameservice.** # not available on Android
......
......@@ -135,13 +135,15 @@ class LocalCalendar private constructor(
override fun markNotDirty(flags: Int): Int {
val values = ContentValues(1)
values.put(LocalEvent.COLUMN_FLAGS, flags)
return provider.update(eventsSyncURI(), values, "${Events.DIRTY}=0 AND ${Events.ORIGINAL_ID} IS NULL", null)
return provider.update(eventsSyncURI(), values,
"${Events.CALENDAR_ID}=? AND ${Events.DIRTY}=0 AND ${Events.ORIGINAL_ID} IS NULL",
arrayOf(id.toString()))
}
override fun removeNotDirtyMarked(flags: Int) =
provider.delete(eventsSyncURI(),
"${Events.DIRTY}=0 AND ${Events.ORIGINAL_ID} IS NULL AND ${LocalEvent.COLUMN_FLAGS}=?",
arrayOf(flags.toString()))
"${Events.CALENDAR_ID}=? AND ${Events.DIRTY}=0 AND ${Events.ORIGINAL_ID} IS NULL AND ${LocalEvent.COLUMN_FLAGS}=?",
arrayOf(id.toString(), flags.toString()))
fun processDirtyExceptions() {
......@@ -150,7 +152,8 @@ class LocalCalendar private constructor(
provider.query(
syncAdapterURI(Events.CONTENT_URI),
arrayOf(Events._ID, Events.ORIGINAL_ID, LocalEvent.COLUMN_SEQUENCE),
"${Events.DELETED}!=0 AND ${Events.ORIGINAL_ID} IS NOT NULL", null, null)?.use { cursor ->
"${Events.CALENDAR_ID}=? AND ${Events.DELETED}!=0 AND ${Events.ORIGINAL_ID} IS NOT NULL",
arrayOf(id.toString()), null)?.use { cursor ->
while (cursor.moveToNext()) {
Logger.log.fine("Found deleted exception, removing; then re-scheduling original event")
val id = cursor.getLong(0) // can't be null (by definition)
......@@ -186,7 +189,8 @@ class LocalCalendar private constructor(
provider.query(
syncAdapterURI(Events.CONTENT_URI),
arrayOf(Events._ID, Events.ORIGINAL_ID, LocalEvent.COLUMN_SEQUENCE),
"${Events.DIRTY}!=0 AND ${Events.ORIGINAL_ID} IS NOT NULL", null, null)?.use { cursor ->
"${Events.CALENDAR_ID}=? AND ${Events.DIRTY}!=0 AND ${Events.ORIGINAL_ID} IS NOT NULL",
arrayOf(id.toString()), null)?.use { cursor ->
while (cursor.moveToNext()) {
Logger.log.fine("Found dirty exception, increasing SEQUENCE to re-schedule")
val id = cursor.getLong(0) // can't be null (by definition)
......
......@@ -138,13 +138,15 @@ class LocalTaskList private constructor(
override fun markNotDirty(flags: Int): Int {
val values = ContentValues(1)
values.put(LocalTask.COLUMN_FLAGS, flags)
return provider.client.update(tasksSyncUri(), values, "${Tasks._DIRTY}=0", null)
return provider.client.update(tasksSyncUri(), values,
"${Tasks.LIST_ID}=? AND ${Tasks._DIRTY}=0",
arrayOf(id.toString()))
}
override fun removeNotDirtyMarked(flags: Int) =
provider.client.delete(tasksSyncUri(),
"${Tasks._DIRTY}=0 AND ${LocalTask.COLUMN_FLAGS}=?",
arrayOf(flags.toString()))
"${Tasks.LIST_ID}=? AND ${Tasks._DIRTY}=0 AND ${LocalTask.COLUMN_FLAGS}=?",
arrayOf(id.toString(), flags.toString()))
object Factory: AndroidTaskListFactory<LocalTaskList> {
......
......@@ -155,7 +155,7 @@ abstract class BaseDavSyncManager<ResourceType: LocalResource, out CollectionTyp
override fun syncRequired(): Boolean {
val localState = localCollection.lastSyncState
val remoteState = syncState(true)
val remoteState = syncState(false)
Logger.log.info("Local sync state = $localState, remote sync state = $remoteState")
return when {
remoteState?.type == SyncState.Type.SYNC_TOKEN -> {
......
......@@ -184,8 +184,35 @@ abstract class SyncManager<out ResourceType: LocalResource, out CollectionType:
protected abstract fun processLocallyDeleted(): Boolean
protected abstract fun uploadDirty(): Boolean
/**
* Determines whether a sync is required because there were changes on the server.
* For instance, this method can check the collection's CTag/sync-token.
*
* When local changes have been uploaded ([processLocallyDeleted] and/or
* [uploadDirty] were true), a sync is always required and this method
* will not be evaluated.
*
* @return whether data has been changed on the server = whether running the
* sync algorithm is required
*/
protected abstract fun syncRequired(): Boolean
/**
* Determines which sync algorithm to use.
* @return
* - [SyncAlgorithm.PROPFIND_REPORT]: list all resources (with plain WebDAV
* PROPFIND or specific REPORT requests), then compare and synchronize
* - [SyncAlgorithm.COLLECTION_SYNC]: use incremental collection synchronization (RFC 6578)
*/
protected abstract fun syncAlgorithm(): SyncAlgorithm
/**
* Returns the current sync state of the remote resource. Keep in mind that
* WebDAV operations are atomic and the sync state might already be obsolete when used.
*
* @param forceRefresh false: result may be taken from a previous request, for instance
* from the [prepare] phase; true: sends a request to determine the current sync state
*/
protected abstract fun syncState(forceRefresh: Boolean): SyncState?
/**
......
......@@ -25,6 +25,7 @@ import android.support.v4.content.Loader
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import at.bitfire.davdroid.*
import at.bitfire.davdroid.log.Logger
import at.bitfire.davdroid.model.ServiceDB.*
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......@@ -10,7 +10,6 @@
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......@@ -14,7 +14,6 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include layout="@layout/accounts_content"/>
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2015 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
~ 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
......
......@@ -8,11 +8,10 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowEnterTransition">@android:transition/slide_right</item>
<item name="android:windowExitTransition">@android:transition/slide_left</item>
</style>
</resources>
......@@ -25,9 +25,7 @@
<!-- app theme -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light"/>
<style name="AppTheme" parent="AppBaseTheme">
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primaryColor</item>
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
<item name="colorAccent">@color/secondaryColor</item>
......@@ -35,21 +33,23 @@
<item name="android:textColorPrimary">@drawable/text_color</item>
<item name="android:textColorSecondary">@color/secondaryTextColor</item>
<item name="alertDialogTheme">@style/AppTheme.Dialog.Alert</item>
<item name="alertDialogTheme">@style/AppBaseTheme.Dialog.Alert</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
<color name="actionBarButton">#8a000000</color>
<style name="AppBaseTheme.Dialog.Alert" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/secondaryColor</item>
</style>
<style name="AppTheme" parent="AppBaseTheme" />
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.Dialog.Alert" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/secondaryColor</item>
</style>
<!-- preference-v14 uses this color for categories text on API <21 -->
<color name="preference_fallback_accent_color">@color/secondaryColor</color>
......
Subproject commit 6372af797e2072824afbf4721bd6e2311690c490
Subproject commit 675241e901d62d051200f8c6e5028fab39c87391
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment