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

Unverified Commit 76d8d5ac authored by Ricki Hirner's avatar Ricki Hirner Committed by GitHub
Browse files

Sync davx5 / davx5-ose repos (#1575)

* Add custom certs UI build config field and use it in HttpClient; sync CollectionDao

* Backport max accounts setting
parent dd294a4b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ android {
        minSdk = 24        // Android 7.0
        targetSdk = 36     // Android 16

        buildConfigField("boolean", "customCertsUI", "true")

        testInstrumentationRunner = "at.bitfire.davdroid.HiltTestRunner"
    }

+4 −0
Original line number Diff line number Diff line
@@ -38,6 +38,10 @@ interface CollectionDao {
    @Query("SELECT * FROM collection WHERE pushTopic=:topic AND sync")
    suspend fun getSyncableByPushTopic(topic: String): Collection?

    @Suppress("unused")     // for build variant
    @Query("SELECT * FROM collection WHERE sync")
    fun getSyncCollections(): List<Collection>

    @Query("SELECT pushVapidKey FROM collection WHERE serviceId=:serviceId AND pushVapidKey IS NOT NULL LIMIT 1")
    suspend fun getFirstVapidKey(serviceId: Long): String?

+2 −1
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import androidx.annotation.WorkerThread
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.dav4jvm.BasicDigestAuthHandler
import at.bitfire.dav4jvm.UrlUtils
import at.bitfire.davdroid.BuildConfig
import at.bitfire.davdroid.di.IoDispatcher
import at.bitfire.davdroid.settings.AccountSettings
import at.bitfire.davdroid.settings.Credentials
@@ -266,7 +267,7 @@ class HttpClient(
            val certManager = CustomCertManager(
                context = context,
                trustSystemCerts = !settingsManager.getBoolean(Settings.DISTRUST_SYSTEM_CERTIFICATES),
                appInForeground = if (/* davx5-ose */ true)
                appInForeground = if (BuildConfig.customCertsUI)
                    ForegroundTracker.inForeground  // interactive mode
                else
                    null                            // non-interactive mode
+6 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
package at.bitfire.davdroid.settings

import androidx.appcompat.app.AppCompatDelegate
import at.bitfire.davdroid.settings.Settings.PRESELECT_COLLECTIONS_EXCLUDED

object Settings {

@@ -61,4 +62,8 @@ object Settings {
    /** whether all address books are forced to be read-only */
    const val FORCE_READ_ONLY_ADDRESSBOOKS = "force_read_only_addressbooks"


    /** max. number of accounts */
    const val MAX_ACCOUNTS = "max_accounts"
    
}
 No newline at end of file
+9 −2
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import androidx.work.WorkQuery
import at.bitfire.davdroid.db.AppDatabase
import at.bitfire.davdroid.repository.AccountRepository
import at.bitfire.davdroid.servicedetection.RefreshCollectionsWorker
import at.bitfire.davdroid.settings.Settings
import at.bitfire.davdroid.settings.SettingsManager
import at.bitfire.davdroid.sync.SyncDataType
import at.bitfire.davdroid.sync.SyncFrameworkIntegration
import at.bitfire.davdroid.sync.worker.BaseSyncWorker
@@ -62,6 +64,7 @@ class AccountsModel @AssistedInject constructor(
    private val db: AppDatabase,
    introPageFactory: IntroPageFactory,
    private val logger: Logger,
    private val settings: SettingsManager,
    private val syncWorkerManager: SyncWorkerManager,
    private val syncFrameWork: SyncFrameworkIntegration
): ViewModel() {
@@ -85,8 +88,12 @@ class AccountsModel @AssistedInject constructor(
    )

    private val accounts = accountRepository.getAllFlow()
    val showAddAccount: Flow<FABStyle> = accounts.map {
        if (it.isEmpty())

    private val maxAccounts = settings.getIntFlow(Settings.MAX_ACCOUNTS)
    val showAddAccount: Flow<FABStyle> = combine(accounts, maxAccounts) { accounts, maxAccounts ->
        if (maxAccounts != null && accounts.size >= maxAccounts)
            FABStyle.None
        else if (accounts.isEmpty())
            FABStyle.WithText
        else
            FABStyle.Standard
Loading