Skip to content

Commit d3f1c22

Browse files
Updated jtx contract v9 (#110)
* Fixed failing tests * Updated contract added constants to access the view content uri and a convenience method to build the uri
1 parent 9c48db4 commit d3f1c22

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

lib/src/androidTest/kotlin/at/bitfire/ical4android/JtxCollectionTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package at.bitfire.ical4android
99
import android.accounts.Account
1010
import android.content.ContentProviderClient
1111
import android.content.ContentValues
12-
import android.provider.CalendarContract
1312
import androidx.test.platform.app.InstrumentationRegistry
1413
import at.bitfire.ical4android.impl.TestJtxCollection
1514
import at.bitfire.ical4android.impl.testProdId
@@ -35,7 +34,7 @@ class JtxCollectionTest {
3534
val context = InstrumentationRegistry.getInstrumentation().targetContext
3635
private lateinit var client: ContentProviderClient
3736

38-
private val testAccount = Account(javaClass.name, CalendarContract.ACCOUNT_TYPE_LOCAL)
37+
private val testAccount = Account(javaClass.name, JtxContract.JtxCollection.TEST_ACCOUNT_TYPE)
3938

4039
private val url = "https://jtx.techbee.at"
4140
private val displayname = "jtx"

lib/src/androidTest/kotlin/at/bitfire/ical4android/JtxICalObjectTest.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import android.content.ContentProviderClient
1111
import android.content.ContentValues
1212
import android.database.DatabaseUtils
1313
import android.os.ParcelFileDescriptor
14-
import android.provider.CalendarContract
1514
import androidx.core.content.pm.PackageInfoCompat
1615
import androidx.test.platform.app.InstrumentationRegistry
1716
import at.bitfire.ical4android.impl.TestJtxCollection
@@ -45,7 +44,7 @@ class JtxICalObjectTest {
4544
val context = InstrumentationRegistry.getInstrumentation().targetContext
4645
private lateinit var client: ContentProviderClient
4746

48-
private val testAccount = Account(javaClass.name, CalendarContract.ACCOUNT_TYPE_LOCAL)
47+
private val testAccount = Account(javaClass.name, JtxContract.JtxCollection.TEST_ACCOUNT_TYPE)
4948
private var collection: JtxCollection<at.bitfire.ical4android.JtxICalObject>? = null
5049
private var sample: at.bitfire.ical4android.JtxICalObject? = null
5150

lib/src/main/kotlin/at/techbee/jtx/JtxContract.kt

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ package at.techbee.jtx
1111
import android.accounts.Account
1212
import android.net.Uri
1313
import android.provider.BaseColumns
14+
import androidx.core.net.toUri
15+
import at.techbee.jtx.JtxContract.JtxAlarm.ACTION
16+
import at.techbee.jtx.JtxContract.JtxAlarm.TRIGGER_RELATIVE_TO
17+
import at.techbee.jtx.JtxContract.JtxAlarm.TRIGGER_TIME
18+
import at.techbee.jtx.JtxContract.JtxICalObject.COMPLETED
19+
import at.techbee.jtx.JtxContract.JtxICalObject.COMPLETED_TIMEZONE
20+
import at.techbee.jtx.JtxContract.JtxICalObject.DTEND
21+
import at.techbee.jtx.JtxContract.JtxICalObject.DTEND_TIMEZONE
22+
import at.techbee.jtx.JtxContract.JtxICalObject.DTSTART
23+
import at.techbee.jtx.JtxContract.JtxICalObject.DTSTART_TIMEZONE
24+
import at.techbee.jtx.JtxContract.JtxICalObject.DUE
25+
import at.techbee.jtx.JtxContract.JtxICalObject.DUE_TIMEZONE
26+
import at.techbee.jtx.JtxContract.JtxICalObject.GEO_LAT
27+
import at.techbee.jtx.JtxContract.JtxICalObject.GEO_LONG
28+
import at.techbee.jtx.JtxContract.JtxICalObject.TZ_ALLDAY
1429
import net.fortuna.ical4j.model.ParameterList
1530
import net.fortuna.ical4j.model.Property
1631
import net.fortuna.ical4j.model.PropertyList
@@ -46,7 +61,7 @@ object JtxContract {
4661
const val AUTHORITY = "at.techbee.jtx.provider"
4762

4863
/** The version of this SyncContentProviderContract */
49-
const val VERSION = 8
64+
const val VERSION = 9
5065

5166
/** Constructs an Uri for the Jtx Sync Adapter with the given Account
5267
* @param [account] The account that should be appended to the Base Uri
@@ -181,10 +196,21 @@ object JtxContract {
181196
/** The name of the the content URI for IcalObjects.
182197
* This is a general purpose table containing general columns
183198
* for Journals, Notes and Todos */
184-
private const val CONTENT_URI_PATH = "icalobject"
199+
const val CONTENT_URI_PATH = "icalobject"
185200

186201
/** The content uri of the ICalObject table */
187-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
202+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
203+
204+
/** The host under which an Intent can be called to open an ICalObject */
205+
const val VIEW_INTENT_HOST = "at.techbee.jtx"
206+
207+
/* The Intent Uri to open an ICalObject, append the ICalObjectId as lastPathSegment to open a specific entry */
208+
val VIEW_INTENT_URI: Uri by lazy { "content://$VIEW_INTENT_HOST/$CONTENT_URI_PATH".toUri() }
209+
210+
/* Convenience function to directly build the content URI to view a specific ICalObject in jtx Board by its ID */
211+
fun getViewIntentUriFor(iCalObjectId: Long): Uri = Uri.withAppendedPath(VIEW_INTENT_URI, iCalObjectId.toString())
212+
213+
188214

189215
/** Constant to define all day values (for dtstart, due, completed timezone fields */
190216
const val TZ_ALLDAY = "ALLDAY"
@@ -630,7 +656,7 @@ object JtxContract {
630656
private const val CONTENT_URI_PATH = "attendee"
631657

632658
/** The content uri of the Attendee table */
633-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
659+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
634660

635661

636662
/** The name of the ID column.
@@ -801,7 +827,7 @@ object JtxContract {
801827
private const val CONTENT_URI_PATH = "category"
802828

803829
/** The content uri of the Category table */
804-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
830+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
805831

806832

807833
/** The name of the ID column for categories.
@@ -851,7 +877,7 @@ object JtxContract {
851877
private const val CONTENT_URI_PATH = "comment"
852878

853879
/** The content uri of the Comment table */
854-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
880+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
855881

856882

857883
/** The name of the ID column for comments.
@@ -909,7 +935,7 @@ object JtxContract {
909935
private const val CONTENT_URI_PATH = "organizer"
910936

911937
/** The content uri of the Organizer table */
912-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
938+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
913939

914940

915941
/** The name of the ID column for the organizer.
@@ -989,7 +1015,7 @@ object JtxContract {
9891015
private const val CONTENT_URI_PATH = "relatedto"
9901016

9911017
/** The content uri of the relatedto table */
992-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
1018+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
9931019

9941020

9951021
/** The name of the ID column for the related-to.
@@ -1057,7 +1083,7 @@ object JtxContract {
10571083
private const val CONTENT_URI_PATH = "resource"
10581084

10591085
/** The content uri of the resources table */
1060-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
1086+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
10611087

10621088

10631089
/** The name of the ID column for resources.
@@ -1108,7 +1134,7 @@ object JtxContract {
11081134
private const val CONTENT_URI_PATH = "collection"
11091135

11101136
/** The content uri of the collections table */
1111-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
1137+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
11121138

11131139
/**
11141140
* Account type used for testing. This account type must be used for integrated testing.
@@ -1231,7 +1257,7 @@ object JtxContract {
12311257
private const val CONTENT_URI_PATH = "attachment"
12321258

12331259
/** The content uri of the resources table */
1234-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
1260+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
12351261

12361262

12371263
/** The name of the ID column for attachments.
@@ -1295,7 +1321,7 @@ object JtxContract {
12951321
private const val CONTENT_URI_PATH = "alarm"
12961322

12971323
/** The content uri of the resources table */
1298-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
1324+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
12991325

13001326

13011327
/** The name of the ID column for attachments.
@@ -1441,7 +1467,7 @@ object JtxContract {
14411467
private const val CONTENT_URI_PATH = "unknown"
14421468

14431469
/** The content uri of the resources table */
1444-
val CONTENT_URI: Uri by lazy { Uri.parse("content://$AUTHORITY/$CONTENT_URI_PATH") }
1470+
val CONTENT_URI: Uri by lazy { "content://$AUTHORITY/$CONTENT_URI_PATH".toUri() }
14451471

14461472

14471473
/** The name of the ID column for attachments.

0 commit comments

Comments
 (0)