mirror of
https://github.com/etesync/android
synced 2025-01-22 21:51:04 +00:00
Update etebase dep and adjust code accordingly.
This commit is contained in:
parent
edb1579fe0
commit
73c1d1ee0b
@ -138,7 +138,7 @@ dependencies {
|
||||
implementation "org.jetbrains.anko:anko-commons:0.10.4"
|
||||
|
||||
implementation "com.etesync:journalmanager:1.1.1"
|
||||
def etebaseVersion = '2.0.1-SNAPSHOT'
|
||||
def etebaseVersion = '2.2.0'
|
||||
implementation "com.etebase:client:$etebaseVersion"
|
||||
|
||||
def acraVersion = '5.3.0'
|
||||
|
@ -48,4 +48,9 @@ public class Constants {
|
||||
public final static String ETEBASE_TYPE_ADDRESS_BOOK = "etebase.vcard";
|
||||
public final static String ETEBASE_TYPE_CALENDAR = "etebase.vevent";
|
||||
public final static String ETEBASE_TYPE_TASKS = "etebase.vtodo";
|
||||
public final static String[] COLLECTION_TYPES = new String[] {
|
||||
ETEBASE_TYPE_ADDRESS_BOOK,
|
||||
ETEBASE_TYPE_CALENDAR,
|
||||
ETEBASE_TYPE_TASKS
|
||||
};
|
||||
}
|
||||
|
@ -44,13 +44,13 @@ class EtebaseLocalCache private constructor(context: Context, username: String)
|
||||
return fsCache._unstable_collectionList(colMgr).filter {
|
||||
withDeleted || !it.isDeleted
|
||||
}.map{
|
||||
CachedCollection(it, it.meta)
|
||||
CachedCollection(it, it.meta, it.collectionType)
|
||||
}
|
||||
}
|
||||
|
||||
fun collectionGet(colMgr: CollectionManager, colUid: String): CachedCollection {
|
||||
return fsCache.collectionGet(colMgr, colUid).let {
|
||||
CachedCollection(it, it.meta)
|
||||
CachedCollection(it, it.meta, it.collectionType)
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,6 +124,6 @@ class EtebaseLocalCache private constructor(context: Context, username: String)
|
||||
}
|
||||
}
|
||||
|
||||
data class CachedCollection(val col: Collection, val meta: CollectionMetadata)
|
||||
data class CachedCollection(val col: Collection, val meta: ItemMetadata, val collectionType: String)
|
||||
|
||||
data class CachedItem(val item: Item, val meta: ItemMetadata, val content: String)
|
@ -77,7 +77,7 @@ class AddressBooksSyncAdapterService : SyncAdapterService() {
|
||||
val etebase = EtebaseLocalCache.getEtebase(context, httpClient.okHttpClient, settings)
|
||||
val colMgr = etebase.collectionManager
|
||||
|
||||
collections = etebaseLocalCache.collectionList(colMgr).filter { it.meta.collectionType == Constants.ETEBASE_TYPE_ADDRESS_BOOK }
|
||||
collections = etebaseLocalCache.collectionList(colMgr).filter { it.collectionType == Constants.ETEBASE_TYPE_ADDRESS_BOOK }
|
||||
}
|
||||
|
||||
for (collection in collections) {
|
||||
|
@ -63,7 +63,7 @@ class CalendarsSyncAdapterService : SyncAdapterService() {
|
||||
val etebase = EtebaseLocalCache.getEtebase(context, httpClient.okHttpClient, settings)
|
||||
val colMgr = etebase.collectionManager
|
||||
|
||||
collections = etebaseLocalCache.collectionList(colMgr).filter { it.meta.collectionType == Constants.ETEBASE_TYPE_CALENDAR }
|
||||
collections = etebaseLocalCache.collectionList(colMgr).filter { it.collectionType == Constants.ETEBASE_TYPE_CALENDAR }
|
||||
}
|
||||
|
||||
for (collection in collections) {
|
||||
|
@ -26,10 +26,11 @@ import com.etebase.client.FetchOptions
|
||||
import com.etebase.client.exceptions.ConnectionException
|
||||
import com.etebase.client.exceptions.TemporaryServerErrorException
|
||||
import com.etebase.client.exceptions.UnauthorizedException
|
||||
import com.etesync.syncadapter.*
|
||||
import com.etesync.journalmanager.Crypto
|
||||
import com.etesync.journalmanager.Exceptions
|
||||
import com.etesync.journalmanager.JournalManager
|
||||
import com.etesync.syncadapter.*
|
||||
import com.etesync.syncadapter.Constants.COLLECTION_TYPES
|
||||
import com.etesync.syncadapter.log.Logger
|
||||
import com.etesync.syncadapter.model.CollectionInfo
|
||||
import com.etesync.syncadapter.model.JournalEntity
|
||||
@ -243,7 +244,6 @@ abstract class SyncAdapterService : Service() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
val etebaseLocalCache = EtebaseLocalCache.getInstance(context, account.name)
|
||||
synchronized(etebaseLocalCache) {
|
||||
val cacheAge = 5 * 1000 // 5 seconds - it's just a hack for burst fetching
|
||||
@ -259,7 +259,7 @@ abstract class SyncAdapterService : Service() {
|
||||
var stoken = etebaseLocalCache.loadStoken()
|
||||
var done = false
|
||||
while (!done) {
|
||||
val colList = colMgr.list(FetchOptions().stoken(stoken))
|
||||
val colList = colMgr.list(COLLECTION_TYPES, FetchOptions().stoken(stoken))
|
||||
for (col in colList.data) {
|
||||
etebaseLocalCache.collectionSet(colMgr, col)
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ class TasksSyncAdapterService: SyncAdapterService() {
|
||||
val etebase = EtebaseLocalCache.getEtebase(context, httpClient.okHttpClient, settings)
|
||||
val colMgr = etebase.collectionManager
|
||||
|
||||
collections = etebaseLocalCache.collectionList(colMgr).filter { it.meta.collectionType == Constants.ETEBASE_TYPE_TASKS }
|
||||
collections = etebaseLocalCache.collectionList(colMgr).filter { it.collectionType == Constants.ETEBASE_TYPE_TASKS }
|
||||
}
|
||||
|
||||
for (collection in collections) {
|
||||
|
@ -398,8 +398,9 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
||||
synchronized(etebaseLocalCache) {
|
||||
return etebaseLocalCache.collectionList(colMgr).map {
|
||||
val meta = it.meta
|
||||
val collectionType = it.collectionType
|
||||
|
||||
if (strType != meta.collectionType) {
|
||||
if (strType != collectionType) {
|
||||
return@map null
|
||||
}
|
||||
|
||||
@ -409,7 +410,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
||||
|
||||
val metaColor = meta.color
|
||||
val color = if (!metaColor.isNullOrBlank()) LocalCalendar.parseColor(metaColor) else null
|
||||
CollectionListItemInfo(it.col.uid, type, meta.name, meta.description
|
||||
CollectionListItemInfo(it.col.uid, type, meta.name!!, meta.description
|
||||
?: "", color, isReadOnly, isAdmin, null)
|
||||
}.filterNotNull()
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.observe
|
||||
import com.etebase.client.CollectionManager
|
||||
import com.etebase.client.CollectionMetadata
|
||||
import com.etebase.client.ItemMetadata
|
||||
import com.etesync.syncadapter.*
|
||||
import com.etesync.syncadapter.ui.BaseActivity
|
||||
import org.jetbrains.anko.doAsync
|
||||
@ -47,8 +47,9 @@ class CollectionActivity() : BaseActivity() {
|
||||
} else if (colType != null) {
|
||||
model.observe(this) {
|
||||
doAsync {
|
||||
val meta = CollectionMetadata(colType, "")
|
||||
val cachedCollection = CachedCollection(it.colMgr.create(meta, ""), meta)
|
||||
val meta = ItemMetadata()
|
||||
meta.name = ""
|
||||
val cachedCollection = CachedCollection(it.colMgr.create(colType, meta, ""), meta, colType)
|
||||
uiThread {
|
||||
supportFragmentManager.commit {
|
||||
replace(R.id.fragment_container, EditCollectionFragment(cachedCollection, true))
|
||||
|
@ -101,7 +101,7 @@ class CollectionItemFragment(private val cachedItem: CachedItem) : Fragment() {
|
||||
val context = requireContext()
|
||||
val account = accountHolder.account
|
||||
val cachedCol = collectionModel.value!!
|
||||
when (cachedCol.meta.collectionType) {
|
||||
when (cachedCol.collectionType) {
|
||||
Constants.ETEBASE_TYPE_CALENDAR -> {
|
||||
val provider = context.contentResolver.acquireContentProviderClient(CalendarContract.CONTENT_URI)!!
|
||||
val localCalendar = LocalCalendar.findByName(account, provider, LocalCalendar.Factory, cachedCol.col.uid)!!
|
||||
@ -205,7 +205,7 @@ class PrettyFragment(private val mainFragment: CollectionItemFragment, private v
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
var v: View? = null
|
||||
|
||||
when (cachedCollection.meta.collectionType) {
|
||||
when (cachedCollection.collectionType) {
|
||||
Constants.ETEBASE_TYPE_ADDRESS_BOOK -> {
|
||||
v = inflater.inflate(R.layout.contact_info, container, false)
|
||||
asyncTask = loadContactTask(v)
|
||||
|
@ -54,9 +54,10 @@ class CollectionMembersFragment : Fragment() {
|
||||
|
||||
private fun initUi(inflater: LayoutInflater, v: View, cachedCollection: CachedCollection) {
|
||||
val meta = cachedCollection.meta
|
||||
val collectionType = cachedCollection.collectionType
|
||||
val colorSquare = v.findViewById<View>(R.id.color)
|
||||
val color = LocalCalendar.parseColor(meta.color)
|
||||
when (meta.collectionType) {
|
||||
when (collectionType) {
|
||||
Constants.ETEBASE_TYPE_CALENDAR -> {
|
||||
colorSquare.setBackgroundColor(color)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class EditCollectionFragment(private val cachedCollection: CachedCollection, pri
|
||||
cachedCollection.let {
|
||||
var titleId: Int = R.string.create_calendar
|
||||
if (isCreating) {
|
||||
when (cachedCollection.meta.collectionType) {
|
||||
when (cachedCollection.collectionType) {
|
||||
Constants.ETEBASE_TYPE_CALENDAR -> {
|
||||
titleId = R.string.create_calendar
|
||||
}
|
||||
@ -75,7 +75,7 @@ class EditCollectionFragment(private val cachedCollection: CachedCollection, pri
|
||||
desc.setText(meta.description)
|
||||
|
||||
val colorSquare = v.findViewById<View>(R.id.color)
|
||||
when (cachedCollection.meta.collectionType) {
|
||||
when (cachedCollection.collectionType) {
|
||||
Constants.ETEBASE_TYPE_CALENDAR -> {
|
||||
title.setHint(R.string.create_calendar_display_name_hint)
|
||||
|
||||
@ -200,7 +200,7 @@ class EditCollectionFragment(private val cachedCollection: CachedCollection, pri
|
||||
meta.mtime = System.currentTimeMillis()
|
||||
|
||||
if (ok) {
|
||||
when (meta.collectionType) {
|
||||
when (cachedCollection.collectionType) {
|
||||
Constants.ETEBASE_TYPE_CALENDAR, Constants.ETEBASE_TYPE_TASKS -> {
|
||||
val view = v.findViewById<View>(R.id.color)
|
||||
val color = (view.background as ColorDrawable).color
|
||||
|
@ -57,12 +57,12 @@ class ImportCollectionFragment : Fragment() {
|
||||
img.setImageResource(R.drawable.ic_account_circle_white)
|
||||
text.setText(R.string.import_button_local)
|
||||
card.setOnClickListener {
|
||||
if (cachedCollection.meta.collectionType == Constants.ETEBASE_TYPE_CALENDAR) {
|
||||
if (cachedCollection.collectionType == Constants.ETEBASE_TYPE_CALENDAR) {
|
||||
parentFragmentManager.commit {
|
||||
replace(R.id.fragment_container, LocalCalendarImportFragment(accountHolder.account, cachedCollection.col.uid))
|
||||
addToBackStack(null)
|
||||
}
|
||||
} else if (cachedCollection.meta.collectionType == Constants.ETEBASE_TYPE_ADDRESS_BOOK) {
|
||||
} else if (cachedCollection.collectionType == Constants.ETEBASE_TYPE_ADDRESS_BOOK) {
|
||||
parentFragmentManager.commit {
|
||||
replace(R.id.fragment_container, LocalContactImportFragment(accountHolder.account, cachedCollection.col.uid))
|
||||
addToBackStack(null)
|
||||
@ -72,7 +72,7 @@ class ImportCollectionFragment : Fragment() {
|
||||
(activity as? BaseActivity?)?.supportActionBar?.setTitle(R.string.import_select_account)
|
||||
}
|
||||
|
||||
if (collectionModel.value!!.meta.collectionType == Constants.ETEBASE_TYPE_TASKS) {
|
||||
if (collectionModel.value!!.collectionType == Constants.ETEBASE_TYPE_TASKS) {
|
||||
card.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ class ItemRevisionsListFragment(private val cachedCollection: CachedCollection,
|
||||
|
||||
val item = getItem(position)
|
||||
|
||||
setItemView(v, cachedCollection.meta.collectionType, item)
|
||||
setItemView(v, cachedCollection.collectionType, item)
|
||||
|
||||
/* FIXME: handle entry error:
|
||||
val entryError = data.select(EntryErrorEntity::class.java).where(EntryErrorEntity.ENTRY.eq(entryEntity)).limit(1).get().firstOrNull()
|
||||
|
@ -85,7 +85,7 @@ class ListEntriesFragment : ListFragment(), AdapterView.OnItemClickListener {
|
||||
|
||||
val item = getItem(position)
|
||||
|
||||
setItemView(v, cachedCollection.meta.collectionType, item)
|
||||
setItemView(v, cachedCollection.collectionType, item)
|
||||
|
||||
/* FIXME: handle entry error:
|
||||
val entryError = data.select(EntryErrorEntity::class.java).where(EntryErrorEntity.ENTRY.eq(entryEntity)).limit(1).get().firstOrNull()
|
||||
|
@ -16,8 +16,8 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.fragment.app.commit
|
||||
import androidx.fragment.app.viewModels
|
||||
import com.etebase.client.Collection
|
||||
import com.etebase.client.CollectionMetadata
|
||||
import com.etebase.client.FetchOptions
|
||||
import com.etebase.client.ItemMetadata
|
||||
import com.etebase.client.exceptions.EtebaseException
|
||||
import com.etesync.syncadapter.Constants.*
|
||||
import com.etesync.syncadapter.R
|
||||
@ -107,7 +107,7 @@ class WizardCheckFragment : Fragment() {
|
||||
loadingModel.setLoading(true)
|
||||
doAsync {
|
||||
try {
|
||||
val collections = colMgr.list(FetchOptions().limit(1))
|
||||
val collections = colMgr.list(COLLECTION_TYPES, FetchOptions().limit(1))
|
||||
uiThread {
|
||||
if (collections.data.size > 0) {
|
||||
activity?.finish()
|
||||
@ -182,10 +182,11 @@ class WizardFragment : Fragment() {
|
||||
)
|
||||
|
||||
baseMeta.forEach {
|
||||
val meta = CollectionMetadata(it.first, it.second)
|
||||
val meta = ItemMetadata()
|
||||
meta.name = it.second
|
||||
meta.mtime = System.currentTimeMillis()
|
||||
|
||||
val col = colMgr.create(meta, "")
|
||||
val col = colMgr.create(it.first, meta, "")
|
||||
uploadCollection(accountHolder, col)
|
||||
}
|
||||
requestSync(requireContext(), accountHolder.account)
|
||||
|
@ -68,7 +68,7 @@ class ViewCollectionFragment : Fragment() {
|
||||
|
||||
val colorSquare = container.findViewById<View>(R.id.color)
|
||||
val color = LocalCalendar.parseColor(meta.color)
|
||||
when (meta.collectionType) {
|
||||
when (cachedCollection.collectionType) {
|
||||
Constants.ETEBASE_TYPE_CALENDAR -> {
|
||||
colorSquare.setBackgroundColor(color)
|
||||
}
|
||||
|
@ -436,7 +436,7 @@ class ImportFragment(private val account: Account, private val uid: String, priv
|
||||
}
|
||||
|
||||
fun newInstance(account: Account, cachedCollection: CachedCollection): ImportFragment {
|
||||
val enumType = when (cachedCollection.meta.collectionType) {
|
||||
val enumType = when (cachedCollection.collectionType) {
|
||||
ETEBASE_TYPE_CALENDAR -> CollectionInfo.Type.CALENDAR
|
||||
ETEBASE_TYPE_TASKS -> CollectionInfo.Type.TASKS
|
||||
ETEBASE_TYPE_ADDRESS_BOOK -> CollectionInfo.Type.ADDRESS_BOOK
|
||||
|
Loading…
Reference in New Issue
Block a user