Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdec5455 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Use live paged data for AccountActivity

parent 6af50dbc
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -99,7 +99,6 @@ class DavService: android.app.Service() {

    interface RefreshingStatusListener {
        fun onDavRefreshStatusChanged(id: Long, refreshing: Boolean)
        fun onDavRefreshFinished(id: Long)
    }

    private val binder = InfoBinder()
@@ -147,13 +146,12 @@ class DavService: android.app.Service() {
        val service = db.serviceDao().getById(serviceId) ?: throw IllegalArgumentException("Service not found")
        val account = Account(service.accountName, getString(R.string.account_type))

        val oldHomeSets = homeSetDao.getByService(serviceId)
        val oldCollections = collectionDao.getByService(serviceId)

        val homeSets = oldHomeSets.toMutableList()
        val homeSets = homeSetDao.getByService(serviceId)
                .map { it.url }
                .toMutableSet()

        val collections = mutableMapOf<HttpUrl, Collection>()
        oldCollections.forEach {
        collectionDao.getByService(serviceId).forEach {
            collections[it.url] = it
        }

@@ -205,7 +203,7 @@ class DavService: android.app.Service() {
                            response[AddressbookHomeSet::class.java]?.let { homeSet ->
                                for (href in homeSet.hrefs)
                                    dav.location.resolve(href)?.let {
                                        homeSets += HomeSet(0, serviceId, UrlUtils.withTrailingSlash(it))
                                        homeSets += UrlUtils.withTrailingSlash(it)
                                    }
                            }

@@ -224,7 +222,7 @@ class DavService: android.app.Service() {
                            response[CalendarHomeSet::class.java]?.let { homeSet ->
                                for (href in homeSet.hrefs)
                                    dav.location.resolve(href)?.let {
                                        homeSets += HomeSet(0, serviceId, UrlUtils.withTrailingSlash(it))
                                        homeSets += UrlUtils.withTrailingSlash(it)
                                    }
                            }

@@ -247,7 +245,7 @@ class DavService: android.app.Service() {
        @Transaction
        fun saveResults() {
            homeSetDao.deleteByService(serviceId)
            homeSetDao.insert(homeSets.onEach { it.serviceId = serviceId })
            homeSetDao.insert(homeSets.map { HomeSet(0, serviceId, it) })

            collectionDao.deleteByService(serviceId)
            val records = collections.values.toList()
@@ -283,7 +281,7 @@ class DavService: android.app.Service() {
                // now refresh collections (taken from home sets)
                val itHomeSets = homeSets.iterator()
                while (itHomeSets.hasNext()) {
                    val homeSetUrl = itHomeSets.next().url
                    val homeSetUrl = itHomeSets.next()
                    Logger.log.fine("Listing home set $homeSetUrl")

                    try {
@@ -364,7 +362,6 @@ class DavService: android.app.Service() {
            runningRefresh.remove(serviceId)
            refreshingStatusListeners.mapNotNull { it.get() }.forEach {
                it.onDavRefreshStatusChanged(serviceId, false)
                it.onDavRefreshFinished(serviceId)
            }
        }

+3 −3
Original line number Diff line number Diff line
@@ -189,10 +189,10 @@ class HttpClient private constructor(
                certificateAlias?.let { alias ->
                    val context = requireNotNull(context)

                    // get client certificate and private key
                    // get provider certificate and private key
                    val certs = KeyChain.getCertificateChain(context, alias) ?: return@let
                    val key = KeyChain.getPrivateKey(context, alias) ?: return@let
                    logger.fine("Using client certificate $alias for authentication (chain length: ${certs.size})")
                    logger.fine("Using provider certificate $alias for authentication (chain length: ${certs.size})")

                    // create Android KeyStore (performs key operations without revealing secret data to DAVx5)
                    val keyStore = KeyStore.getInstance("AndroidKeyStore")
@@ -217,7 +217,7 @@ class HttpClient private constructor(
                    }
                }
            } catch (e: Exception) {
                logger.log(Level.SEVERE, "Couldn't set up client certificate authentication", e)
                logger.log(Level.SEVERE, "Couldn't set up provider certificate authentication", e)
            }

            orig.sslSocketFactory(CertTlsSocketFactory(keyManager, trustManager), trustManager)
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ abstract class AppDatabase: RoomDatabase() {
        fun getInstance(context: Context): AppDatabase {
            INSTANCE?.let { return it }

            val db = Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, "services.db")
            val db = Room.databaseBuilder(context.applicationContext, AppDatabase::class.java, "services.database")
                    .fallbackToDestructiveMigrationFrom(1, 2)
                    .fallbackToDestructiveMigrationOnDowngrade()
                    .addMigrations(Migration5_6)
+0 −3
Original line number Diff line number Diff line
@@ -140,9 +140,6 @@ data class Collection(
    @Ignore
    var confirmed: Boolean = false

    @Ignore
    var uiEnabled: Boolean = true


    fun title() = displayName ?: DavUtils.lastSegmentOfUrl(url)

+4 −0
Original line number Diff line number Diff line
package at.bitfire.davdroid.model

import androidx.lifecycle.LiveData
import androidx.room.*

@Dao
@@ -11,6 +12,9 @@ interface CollectionDao {
    @Query("SELECT * FROM collection WHERE serviceId=:serviceId")
    fun getByService(serviceId: Long): List<Collection>

    @Query("SELECT * FROM collection WHERE serviceId=:serviceId AND type=:type")
    fun observeByServiceAndType(serviceId: Long, type: String): LiveData<List<Collection>>

    @Query("SELECT * FROM collection WHERE serviceId=:serviceId AND supportsVEVENT AND sync")
    fun getSyncCalendars(serviceId: Long): List<Collection>

Loading