Update etebase dep and adjust code accordingly

pull/131/head
Tom Hacohen 4 years ago
parent 20a2c1b445
commit b637f25f4a

@ -134,7 +134,7 @@ dependencies {
implementation "org.jetbrains.anko:anko-commons:0.10.4"
implementation "com.etesync:journalmanager:1.1.1"
def etebaseVersion = '0.1.3-SNAPSHOT'
def etebaseVersion = '0.1.4-SNAPSHOT'
implementation "com.etebase:client:$etebaseVersion"
def acraVersion = '5.3.0'

@ -19,6 +19,7 @@ import android.provider.ContactsContract.CommonDataKinds.GroupMembership
import android.provider.ContactsContract.Groups
import android.provider.ContactsContract.RawContacts
import at.bitfire.vcard4android.*
import com.etebase.client.CollectionAccessLevel
import com.etesync.syncadapter.App
import com.etesync.syncadapter.CachedCollection
import com.etesync.syncadapter.log.Logger
@ -98,7 +99,7 @@ class LocalAddressBook(
values.put(ContactsContract.Settings.SHOULD_SYNC, 1)
values.put(ContactsContract.Settings.UNGROUPED_VISIBLE, 1)
addressBook.settings = values
addressBook.readOnly = col.accessLevel == "ro"
addressBook.readOnly = col.accessLevel == CollectionAccessLevel.ReadOnly
return addressBook
}
@ -250,7 +251,7 @@ class LocalAddressBook(
account = future.result
}
readOnly = col.accessLevel == "ro"
readOnly = col.accessLevel == CollectionAccessLevel.ReadOnly
Logger.log.info("Address book write permission? = ${!readOnly}")
// make sure it will still be synchronized when contacts are updated

@ -18,6 +18,7 @@ import android.os.RemoteException
import android.provider.CalendarContract
import android.provider.CalendarContract.*
import at.bitfire.ical4android.*
import com.etebase.client.CollectionAccessLevel
import com.etesync.syncadapter.CachedCollection
import com.etesync.syncadapter.log.Logger
import com.etesync.syncadapter.model.JournalEntity
@ -128,7 +129,7 @@ class LocalCalendar private constructor(
if (withColor)
values.put(Calendars.CALENDAR_COLOR, parseColor(meta.color))
if (col.accessLevel == "ro")
if (col.accessLevel == CollectionAccessLevel.ReadOnly)
values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_READ)
else {
values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER)

@ -756,7 +756,7 @@ constructor(protected val context: Context, protected val account: Account, prot
val localList = localCollection!!.findDeleted()
val ret = ArrayList<T>(localList.size)
val readOnly = (isLegacy && journalEntity.isReadOnly) || (!isLegacy && (cachedCollection.col.accessLevel == "ro"))
val readOnly = (isLegacy && journalEntity.isReadOnly) || (!isLegacy && (cachedCollection.col.accessLevel == CollectionAccessLevel.ReadOnly))
if (readOnly) {
for (local in localList) {
Logger.log.info("Restoring locally deleted resource on a read only collection: ${local.uuid}")
@ -789,7 +789,7 @@ constructor(protected val context: Context, protected val account: Account, prot
@Throws(CalendarStorageException::class, ContactsStorageException::class)
protected open fun prepareDirty() {
val readOnly = (isLegacy && journalEntity.isReadOnly) || (!isLegacy && (cachedCollection.col.accessLevel == "ro"))
val readOnly = (isLegacy && journalEntity.isReadOnly) || (!isLegacy && (cachedCollection.col.accessLevel == CollectionAccessLevel.ReadOnly))
if (readOnly) {
for (local in localDirty) {
Logger.log.info("Restoring locally modified resource on a read only collection: ${local.uuid}")

@ -27,6 +27,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import at.bitfire.ical4android.TaskProvider.Companion.OPENTASK_PROVIDERS
import at.bitfire.vcard4android.ContactsStorageException
import com.etebase.client.CollectionAccessLevel
import com.etebase.client.CollectionManager
import com.etebase.client.Utils
import com.etebase.client.exceptions.EtebaseException
@ -394,8 +395,8 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
}
val accessLevel = it.col.accessLevel
val isReadOnly = accessLevel == "ro"
val isAdmin = accessLevel == "adm"
val isReadOnly = accessLevel == CollectionAccessLevel.ReadOnly
val isAdmin = accessLevel == CollectionAccessLevel.Admin
val metaColor = meta.color
val color = if (!metaColor.isNullOrBlank()) LocalCalendar.parseColor(metaColor) else null

@ -13,6 +13,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import com.etebase.client.CollectionAccessLevel
import com.etebase.client.Utils
import com.etebase.client.exceptions.EtebaseException
import com.etebase.client.exceptions.NotFoundException
@ -81,7 +82,7 @@ class CollectionMembersFragment : Fragment() {
val username = view.findViewById<EditText>(R.id.username).text.toString()
val readOnly = view.findViewById<CheckBox>(R.id.read_only).isChecked
val frag = AddMemberFragment(model.value!!, collectionModel.value!!, username, if (readOnly) "ro" else "rw")
val frag = AddMemberFragment(model.value!!, collectionModel.value!!, username, if (readOnly) CollectionAccessLevel.ReadOnly else CollectionAccessLevel.ReadWrite)
frag.show(childFragmentManager, null)
}
.setNegativeButton(android.R.string.no) { _, _ -> }
@ -90,7 +91,7 @@ class CollectionMembersFragment : Fragment() {
}
}
class AddMemberFragment(private val accountHolder: AccountHolder, private val cachedCollection: CachedCollection, private val username: String, private val accessLevel: String) : DialogFragment() {
class AddMemberFragment(private val accountHolder: AccountHolder, private val cachedCollection: CachedCollection, private val username: String, private val accessLevel: CollectionAccessLevel) : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val progress = ProgressDialog(context)
progress.setTitle(R.string.collection_members_adding)

@ -16,6 +16,7 @@ import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.observe
import com.etebase.client.CollectionAccessLevel
import com.etebase.client.CollectionMember
import com.etebase.client.FetchOptions
import com.etesync.syncadapter.CachedCollection
@ -78,7 +79,7 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
val member = listAdapter?.getItem(position) as CollectionMember
if (member.accessLevel == "adm") {
if (member.accessLevel == CollectionAccessLevel.Admin) {
AlertDialog.Builder(requireActivity())
.setIcon(R.drawable.ic_error_dark)
.setTitle(R.string.collection_members_remove_title)
@ -111,7 +112,7 @@ class CollectionMembersListFragment : ListFragment(), AdapterView.OnItemClickLis
// FIXME: Also mark admins
val readOnly = v.findViewById<View>(R.id.read_only)
readOnly.visibility = if (member.accessLevel == "ro") View.VISIBLE else View.GONE
readOnly.visibility = if (member.accessLevel == CollectionAccessLevel.ReadOnly) View.VISIBLE else View.GONE
return v
}

@ -8,6 +8,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.commit
import com.etebase.client.CollectionAccessLevel
import com.etesync.syncadapter.CachedCollection
import com.etesync.syncadapter.Constants
import com.etesync.syncadapter.R
@ -63,7 +64,7 @@ class ViewCollectionFragment : Fragment() {
val col = cachedCollection.col
val meta = cachedCollection.meta
val isAdmin = col.accessLevel == "adm"
val isAdmin = col.accessLevel == CollectionAccessLevel.Admin
val colorSquare = container.findViewById<View>(R.id.color)
val color = LocalCalendar.parseColor(meta.color)
@ -111,7 +112,7 @@ class ViewCollectionFragment : Fragment() {
when (item.itemId) {
R.id.on_edit -> {
if (cachedCollection.col.accessLevel == "adm") {
if (cachedCollection.col.accessLevel == CollectionAccessLevel.Admin) {
parentFragmentManager.commit {
replace(R.id.fragment_container, EditCollectionFragment(cachedCollection))
addToBackStack(EditCollectionFragment::class.java.name)
@ -126,7 +127,7 @@ class ViewCollectionFragment : Fragment() {
}
}
R.id.on_manage_members -> {
if (cachedCollection.col.accessLevel == "adm") {
if (cachedCollection.col.accessLevel == CollectionAccessLevel.Admin) {
parentFragmentManager.commit {
replace(R.id.fragment_container, CollectionMembersFragment())
addToBackStack(null)
@ -140,7 +141,7 @@ class ViewCollectionFragment : Fragment() {
dialog.show()
} }
R.id.on_import -> {
if (cachedCollection.col.accessLevel != "ro") {
if (cachedCollection.col.accessLevel != CollectionAccessLevel.ReadOnly) {
parentFragmentManager.commit {
replace(R.id.fragment_container, ImportCollectionFragment())
addToBackStack(null)

Loading…
Cancel
Save