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

Commit 2d3b8a5b authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge branch '298-Chip_color_is_not_in_accent_color_issue' into 'main'

298-Chip_color_is_not_in_accent_color_issue

See merge request !74
parents f8a1ec65 4d7feb4d
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ class AccountPreferenceSerializer(

            accountNumber = storage.getInt("$accountUuid.accountNumber", UNASSIGNED_ACCOUNT_NUMBER)

            chipColor = storage.getInt("$accountUuid.chipColor", FALLBACK_ACCOUNT_COLOR)
            chipColor = FALLBACK_ACCOUNT_COLOR

            sortType = getEnumStringPref<SortType>(storage, "$accountUuid.sortTypeEnum", SortType.SORT_DATE)

@@ -291,7 +291,7 @@ class AccountPreferenceSerializer(
            editor.putBoolean("$accountUuid.syncRemoteDeletions", isSyncRemoteDeletions)
            editor.putInt("$accountUuid.maxPushFolders", maxPushFolders)
            editor.putString("$accountUuid.searchableFolders", searchableFolders.name)
            editor.putInt("$accountUuid.chipColor", chipColor)
            editor.putInt("$accountUuid.chipColor", FALLBACK_ACCOUNT_COLOR)
            editor.putBoolean("$accountUuid.subscribedFoldersOnly", isSubscribedFoldersOnly)
            editor.putInt("$accountUuid.maximumPolledMessageAge", maximumPolledMessageAge)
            editor.putInt("$accountUuid.maximumAutoDownloadMessageSize", maximumAutoDownloadMessageSize)
@@ -626,7 +626,7 @@ class AccountPreferenceSerializer(
        const val IDENTITY_EMAIL_KEY = "email"
        const val IDENTITY_DESCRIPTION_KEY = "description"

        const val FALLBACK_ACCOUNT_COLOR = 0x0099CC
        const val FALLBACK_ACCOUNT_COLOR = 0x0086FF

        @JvmField
        val DEFAULT_MESSAGE_FORMAT = MessageFormat.HTML
+2 −2
Original line number Diff line number Diff line
package com.fsck.k9.account

import android.content.res.Resources
import androidx.core.content.res.ResourcesCompat
import com.fsck.k9.Account.DeletePolicy
import com.fsck.k9.Preferences
import com.fsck.k9.mail.ConnectionSecurity
@@ -52,8 +53,7 @@ class AccountCreator(private val preferences: Preferences, private val resources
    }

    fun pickColor(): Int {
        val accountColors = resources.getIntArray(R.array.account_colors).toList()
        return accountColors[0];
        return ResourcesCompat.getColor(resources, R.color.color_default_accent, null)
    }

    companion object {
+1 −13
Original line number Diff line number Diff line
@@ -463,24 +463,12 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
    )

    private fun getDrawerColorsForAccount(account: Account): DrawerColors {
        val baseColor = if (themeManager.appTheme == Theme.DARK) {
            getDarkThemeAccentColor(account.chipColor)
        } else {
            account.chipColor
        }
        return DrawerColors(
            accentColor = baseColor,
            accentColor = ResourcesCompat.getColor(resources, R.color.color_default_accent, null),
            selectedColor =  ResourcesCompat.getColor(resources, R.color.color_drawer_selected_background, null)
        )
    }

    private fun getDarkThemeAccentColor(color: Int): Int {
        val lightColors = resources.getIntArray(R.array.account_colors)
        val darkColors = resources.getIntArray(R.array.drawer_account_accent_color_dark_theme)
        val index = lightColors.indexOf(color)
        return if (index == -1) color else darkColors[index]
    }

    fun open() {
        drawer.openDrawer(GravityCompat.START)
    }
+1 −16
Original line number Diff line number Diff line
@@ -79,12 +79,7 @@ class AccountSettingsDataStore(
    }

    override fun putInt(key: String?, value: Int) {
        when (key) {
            "chip_color" -> setAccountColor(value)
            else -> return
        }

        saveSettingsInBackground()
        return
    }

    override fun getLong(key: String?, defValue: Long): Long {
@@ -187,16 +182,6 @@ class AccountSettingsDataStore(
        saveSettingsInBackground()
    }

    private fun setAccountColor(color: Int) {
        if (color != account.chipColor) {
            account.chipColor = color

            if (account.notificationSettings.light == NotificationLight.AccountColor) {
                notificationSettingsChanged = true
            }
        }
    }

    private fun setNotificationSound(value: String) {
        account.notificationSettings.let { notificationSettings ->
            if (!notificationSettings.isRingEnabled || notificationSettings.ringtone != value) {