Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
6
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
DAVx⁵
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
2
Merge Requests
2
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
bitfire web engineering
DAVx⁵
Commits
c9dab310
Commit
c9dab310
authored
Jan 24, 2020
by
Ricki Hirner
🐑
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Webcal calendars: use UrlUtils.equals to find matching calendar; update dependencies
parent
ac3e9fb8
Pipeline
#112139014
passed with stages
in 13 minutes and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
11 deletions
+14
-11
app/build.gradle
app/build.gradle
+5
-5
app/src/main/java/at/bitfire/davdroid/ui/account/WebcalFragment.kt
...ain/java/at/bitfire/davdroid/ui/account/WebcalFragment.kt
+9
-6
No files found.
app/build.gradle
View file @
c9dab310
...
...
@@ -112,21 +112,21 @@ dependencies {
implementation
'androidx.appcompat:appcompat:1.1.0'
implementation
'androidx.cardview:cardview:1.0.0'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
implementation
'androidx.fragment:fragment-ktx:1.
1
.0'
implementation
'androidx.lifecycle:lifecycle-extensions:2.
1
.0'
implementation
'androidx.lifecycle:lifecycle-viewmodel-ktx:2.
1
.0'
implementation
'androidx.fragment:fragment-ktx:1.
2
.0'
implementation
'androidx.lifecycle:lifecycle-extensions:2.
2
.0'
implementation
'androidx.lifecycle:lifecycle-viewmodel-ktx:2.
2
.0'
implementation
'androidx.paging:paging-runtime-ktx:2.1.1'
implementation
'androidx.preference:preference:1.1.0'
implementation
'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03'
implementation
'com.google.android:flexbox:1.1.0'
implementation
'com.google.android.material:material:1.2.0-alpha0
3
'
implementation
'com.google.android.material:material:1.2.0-alpha0
4
'
def
room_version
=
'2.2.3'
implementation
"androidx.room:room-runtime:$room_version"
implementation
"androidx.room:room-ktx:$room_version"
kapt
"androidx.room:room-compiler:$room_version"
implementation
'com.gitlab.bitfireAT:dav4jvm:1.0'
implementation
'com.gitlab.bitfireAT:dav4jvm:1.0
.1
'
implementation
'com.jaredrummler:colorpicker:1.1.0'
implementation
(
'com.mikepenz:aboutlibraries:7.1.0'
)
implementation
"com.squareup.okhttp3:okhttp:${versions.okhttp}"
...
...
app/src/main/java/at/bitfire/davdroid/ui/account/WebcalFragment.kt
View file @
c9dab310
...
...
@@ -192,7 +192,7 @@ class WebcalFragment: CollectionsFragment() {
value
=
null
}
}
val
subscribedUrls
=
object
:
MediatorLiveData
<
MutableMap
<
HttpUrl
,
Long
>>()
{
val
subscribedUrls
=
object
:
MediatorLiveData
<
MutableMap
<
Long
,
HttpUrl
>>()
{
var
provider
:
ContentProviderClient
?
=
null
var
observer
:
ContentObserver
?
=
null
...
...
@@ -244,19 +244,19 @@ class WebcalFragment: CollectionsFragment() {
@Transaction
private
fun
queryCalendars
(
provider
:
ContentProviderClient
)
{
// query subscribed URLs from Android calendar list
val
subscriptions
=
mutableMapOf
<
HttpUrl
,
Long
>()
val
subscriptions
=
mutableMapOf
<
Long
,
HttpUrl
>()
provider
.
query
(
Calendars
.
CONTENT_URI
,
arrayOf
(
Calendars
.
_ID
,
Calendars
.
NAME
),
null
,
null
,
null
)
?.
use
{
cursor
->
while
(
cursor
.
moveToNext
())
cursor
.
getString
(
1
)
?.
let
{
rawName
->
HttpUrl
.
parse
(
rawName
)
?.
let
{
url
->
subscriptions
[
url
]
=
cursor
.
getLong
(
0
)
subscriptions
[
cursor
.
getLong
(
0
)]
=
url
}
}
}
// update "sync" field in database accordingly (will update UI)
db
.
collectionDao
().
getByServiceAndType
(
serviceId
,
Collection
.
TYPE_WEBCAL
).
forEach
{
webcal
->
val
newSync
=
subscriptions
.
key
s
val
newSync
=
subscriptions
.
value
s
.
any
{
webcal
.
source
?.
let
{
source
->
UrlUtils
.
equals
(
source
,
it
)
}
?:
false
}
if
(
newSync
!=
webcal
.
sync
)
db
.
collectionDao
().
update
(
webcal
.
copy
(
sync
=
newSync
))
...
...
@@ -278,8 +278,11 @@ class WebcalFragment: CollectionsFragment() {
fun
unsubscribe
(
webcal
:
Collection
)
{
workerHandler
.
post
{
subscribedUrls
.
value
?.
get
(
webcal
.
source
)
?.
let
{
id
->
// delete subscription from Android calendar list
// find first matching source (Webcal) URL
subscribedUrls
.
value
?.
entries
?.
firstOrNull
{
(
id
,
source
)
->
UrlUtils
.
equals
(
source
,
webcal
.
source
!!
)
}
?.
key
?.
let
{
id
->
// delete first matching subscription from Android calendar list
calendarProvider
.
value
?.
delete
(
Calendars
.
CONTENT_URI
,
"${Calendars._ID}=?"
,
arrayOf
(
id
.
toString
()))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment