named compression algorithm

This commit is contained in:
GianpaMX
2022-10-26 15:25:38 +01:00
parent b11533f9fe
commit 9e0b6fa800
13 changed files with 134 additions and 91 deletions

View File

@@ -37,7 +37,9 @@ import com.kunzisoft.keepass.database.crypto.EncryptionAlgorithm
import com.kunzisoft.keepass.database.crypto.kdf.KdfEngine
import com.kunzisoft.keepass.database.element.Database
import com.kunzisoft.keepass.database.element.Group
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
import com.kunzisoft.keepass.database.element.database.NamedCompressionAlgorithm
import com.kunzisoft.keepass.database.element.database.toCompressionAlgorithm
import com.kunzisoft.keepass.database.element.database.toNamedCompressionAlgorithm
import com.kunzisoft.keepass.database.element.template.TemplateEngine
import com.kunzisoft.keepass.services.DatabaseTaskNotificationService
import com.kunzisoft.keepass.settings.preference.*
@@ -198,8 +200,8 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment(), DatabaseRetriev
// Database compression
dbDataCompressionPref = findPreference(getString(R.string.database_data_compression_key))
if (database.allowDataCompression) {
dbDataCompressionPref?.summary = (database.compressionAlgorithm
?: CompressionAlgorithm.None).getName(resources)
dbDataCompressionPref?.summary = (database.compressionAlgorithm?.toNamedCompressionAlgorithm()
?: NamedCompressionAlgorithm.None).getName(resources)
} else {
dbCompressionPrefCategory?.isVisible = false
}
@@ -433,13 +435,13 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment(), DatabaseRetriev
dbCustomColorPref?.summary = defaultColorToShow
}
DatabaseTaskNotificationService.ACTION_DATABASE_UPDATE_COMPRESSION_TASK -> {
val oldCompression = data.getSerializable(DatabaseTaskNotificationService.OLD_ELEMENT_KEY) as CompressionAlgorithm
val newCompression = data.getSerializable(DatabaseTaskNotificationService.NEW_ELEMENT_KEY) as CompressionAlgorithm
val oldCompression = data.getSerializable(DatabaseTaskNotificationService.OLD_ELEMENT_KEY) as NamedCompressionAlgorithm
val newCompression = data.getSerializable(DatabaseTaskNotificationService.NEW_ELEMENT_KEY) as NamedCompressionAlgorithm
val algorithmToShow =
if (result.isSuccess) {
newCompression
} else {
mDatabase?.compressionAlgorithm = oldCompression
mDatabase?.compressionAlgorithm = oldCompression.toCompressionAlgorithm()
oldCompression
}
dbDataCompressionPref?.summary = algorithmToShow.getName(resources)
@@ -716,4 +718,4 @@ class NestedDatabaseSettingsFragment : NestedSettingsFragment(), DatabaseRetriev
companion object {
private const val TAG_PREF_FRAGMENT = "TAG_PREF_FRAGMENT"
}
}
}