Skip to content

Commit

Permalink
KDoc, shouldBeReadOnly
Browse files Browse the repository at this point in the history
  • Loading branch information
rfc2822 committed Nov 12, 2024
1 parent 8cbfe1d commit 72aef60
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ open class LocalAddressBook @AssistedInject constructor(
?: throw IllegalStateException("Address book has no URL")
set(url) = AccountManager.get(context).setAndVerifyUserData(addressBookAccount, USER_DATA_URL, url)

/**
* Read-only flag for the address book itself.
*
* Setting this flag:
*
* - stores the new value in [USER_DATA_READ_ONLY] and
* - sets the read-only flag for all contacts and groups in the address book in the content provider, which will
* prevent non-sync-adapter apps from modifying them. However new entries can still be created, so the address book
* is not really read-only.
*
* Reading this flag returns the stored value from [USER_DATA_READ_ONLY].
*/
override var readOnly: Boolean
get() = AccountManager.get(context).getUserData(addressBookAccount, USER_DATA_READ_ONLY) != null
set(readOnly) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class LocalAddressBookStore @Inject constructor(
// update settings
addressBook.updateSyncFrameworkSettings()
addressBook.settings = contactsProviderSettings
addressBook.readOnly = forceAllReadOnly || fromCollection.readOnly()
addressBook.readOnly = shouldBeReadOnly(fromCollection, forceAllReadOnly)

return addressBook
}
Expand Down Expand Up @@ -163,7 +163,6 @@ class LocalAddressBookStore @Inject constructor(
localCollection.readOnly = nowReadOnly
}


// make sure it will still be synchronized when contacts are updated
localCollection.updateSyncFrameworkSettings()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ interface LocalDataStore<T: LocalCollection<*>> {
*/
fun create(provider: ContentProviderClient, fromCollection: Collection): T?

/**
* Returns all local collections of the data store.
*
* @param account the account that the data store is associated with
* @param provider the content provider client
*
* @return a list of all local collections
*/
fun getAll(account: Account, provider: ContentProviderClient): List<T>

/**
Expand Down

0 comments on commit 72aef60

Please sign in to comment.