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

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

Dark theme, animation for WelcomeFragment

parent 9ce481b3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2013 – 2015 Ricki Hirner (bitfire web engineering).
  ~ Copyright (c) Ricki Hirner (bitfire web engineering).
  ~ All rights reserved. This program and the accompanying materials
  ~ are made available under the terms of the GNU Public License v3.0
  ~ which accompanies this distribution, and is available at
@@ -9,6 +9,6 @@

<resources>

    <string name="app_name">DavdroidTest</string>
    <string name="app_name">Davx5Test</string>

</resources>
+10 −4
Original line number Diff line number Diff line
@@ -13,10 +13,13 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.StrictMode
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.graphics.drawable.toBitmap
import at.bitfire.davdroid.log.Logger
import at.bitfire.davdroid.settings.AccountSettings
import at.bitfire.davdroid.settings.Settings
import at.bitfire.davdroid.settings.SettingsManager
import at.bitfire.davdroid.ui.DebugInfoActivity
import at.bitfire.davdroid.ui.NotificationUtils
import at.bitfire.davdroid.ui.UiUtils
@@ -64,17 +67,20 @@ class App: Application(), Thread.UncaughtExceptionHandler {

        // don't block UI for some background checks
        thread {
            // set light/dark mode
            UiUtils.setTheme(this)

            // create/update app shortcuts
            UiUtils.updateShortcuts(this@App)
            UiUtils.updateShortcuts(this)

            // watch installed/removed apps
            TasksWatcher(this@App)
            TasksWatcher(this)

            // check whether a tasks app is currently installed
            TasksWatcher.updateTaskSync(this@App)
            TasksWatcher.updateTaskSync(this)

            // check/repair sync intervals
            AccountSettings.repairSyncIntervals(this@App)
            AccountSettings.repairSyncIntervals(this)

            // foreground service (possible workaround for devices which prevent DAVx5 from being started)
            ForegroundService.startIfEnabled(this)
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
                prefIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                val pendingPref = PendingIntent.getActivity(context, 0, prefIntent, PendingIntent.FLAG_UPDATE_CURRENT)
                builder.addAction(NotificationCompat.Action.Builder(
                        R.drawable.ic_settings_action,
                        R.drawable.ic_settings,
                        context.getString(R.string.logging_notification_disable),
                        pendingPref
                ).build())
+9 −0
Original line number Diff line number Diff line
package at.bitfire.davdroid.settings

import androidx.appcompat.app.AppCompatDelegate

object Settings {

    const val FOREGROUND_SERVICE = "foreground_service"
@@ -16,6 +18,13 @@ object Settings {
     */
    const val DEFAULT_SYNC_INTERVAL = "default_sync_interval"

    /**
     * Preferred theme (light/dark). Value must be one of [AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM]
     * (default if setting is missing), [AppCompatDelegate.MODE_NIGHT_NO] or [AppCompatDelegate.MODE_NIGHT_YES].
     */
    const val PREFERRED_THEME = "preferred_theme"
    const val PREFERRED_THEME_DEFAULT = AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM

    const val PREFERRED_TASKS_PROVIDER = "preferred_tasks_provider"

}
+30 −14
Original line number Diff line number Diff line
@@ -14,10 +14,8 @@ import android.os.Build
import android.os.Bundle
import androidx.annotation.UiThread
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreferenceCompat
import androidx.appcompat.app.AppCompatDelegate
import androidx.preference.*
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.davdroid.BuildConfig
import at.bitfire.davdroid.ForegroundService
@@ -62,9 +60,6 @@ class AppSettingsActivity: AppCompatActivity() {

        override fun onCreatePreferences(bundle: Bundle?, s: String?) {
            addPreferencesFromResource(R.xml.settings_app)
            loadSettings()

            settings.addOnChangeListener(this)

            // UI settings
            findPreference<Preference>("notification_settings")!!.apply {
@@ -96,8 +91,14 @@ class AppSettingsActivity: AppCompatActivity() {
            }
        }

        override fun onDestroy() {
            super.onDestroy()
        override fun onStart() {
            super.onStart()
            settings.addOnChangeListener(this)
            loadSettings()
        }

        override fun onStop() {
            super.onStop()
            settings.removeOnChangeListener(this)
        }

@@ -108,7 +109,7 @@ class AppSettingsActivity: AppCompatActivity() {
                isChecked = settings.getBooleanOrNull(Settings.FOREGROUND_SERVICE) == true
                onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
                    settings.putBoolean(Settings.FOREGROUND_SERVICE, newValue as Boolean)
                    context.startService(Intent(ForegroundService.ACTION_FOREGROUND, null, context, ForegroundService::class.java))
                    requireActivity().startService(Intent(ForegroundService.ACTION_FOREGROUND, null, requireActivity(), ForegroundService::class.java))
                    false
                }
            }
@@ -167,10 +168,24 @@ class AppSettingsActivity: AppCompatActivity() {
            findPreference<SwitchPreferenceCompat>(Settings.DISTRUST_SYSTEM_CERTIFICATES)!!
                    .isChecked = settings.getBoolean(Settings.DISTRUST_SYSTEM_CERTIFICATES)

            // user interface settings
            findPreference<ListPreference>(Settings.PREFERRED_THEME)!!.apply {
                val mode = settings.getIntOrNull(Settings.PREFERRED_THEME) ?: Settings.PREFERRED_THEME_DEFAULT
                setValueIndex(entryValues.indexOf(mode.toString()))
                summary = getString(R.string.app_settings_theme_summary, entry)

                onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
                    val newMode = (newValue as String).toInt()
                    AppCompatDelegate.setDefaultNightMode(newMode)
                    settings.putInt(Settings.PREFERRED_THEME, newMode)
                    false
                }
            }

            // integration settings
            findPreference<Preference>(Settings.PREFERRED_TASKS_PROVIDER)!!.apply {
                val pm = context.packageManager
                val taskProvider = TaskUtils.currentProvider(context)
                val pm = requireActivity().packageManager
                val taskProvider = TaskUtils.currentProvider(requireActivity())
                if (taskProvider != null) {
                    val tasksAppInfo = pm.getApplicationInfo(taskProvider.packageName, 0)
                    val inset = (24*resources.displayMetrics.density).roundToInt()  // 24dp
@@ -180,7 +195,7 @@ class AppSettingsActivity: AppCompatActivity() {
                    )
                    summary = getString(R.string.app_settings_tasks_provider_synchronizing_with, tasksAppInfo.loadLabel(pm))
                } else {
                    setIcon(R.drawable.ic_playlist_add_check_dark)
                    setIcon(R.drawable.ic_playlist_add_check)
                    setSummary(R.string.app_settings_tasks_provider_none)
                }
                setOnPreferenceClickListener {
@@ -193,6 +208,7 @@ class AppSettingsActivity: AppCompatActivity() {
        override fun onSettingsChanged() {
            // loadSettings must run in UI thread
            CoroutineScope(Dispatchers.Main).launch {
                if (isAdded)
                    loadSettings()
            }
        }
Loading