mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-04-04 21:37:37 +03:00
fix: Better icon pack implementation
This commit is contained in:
parent
1b96747187
commit
3b3908dd7c
8 changed files with 36 additions and 9 deletions
|
@ -36,6 +36,7 @@ import com.kunzisoft.keepass.database.element.binary.BinaryCache
|
||||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||||
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
|
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
|
||||||
import com.kunzisoft.keepass.database.element.icon.IconImageDraw
|
import com.kunzisoft.keepass.database.element.icon.IconImageDraw
|
||||||
|
import com.kunzisoft.keepass.icon.IconPack
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
|
@ -22,7 +22,7 @@ package com.kunzisoft.keepass.icons
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.kunzisoft.keepass.BuildConfig
|
import com.kunzisoft.keepass.BuildConfig
|
||||||
import com.kunzisoft.keepass.R
|
import com.kunzisoft.keepass.icon.IconPack
|
||||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +65,7 @@ object IconPackChooser {
|
||||||
addDefaultIconPack(context)
|
addDefaultIconPack(context)
|
||||||
}
|
}
|
||||||
if(defaultIconSize == 0) {
|
if(defaultIconSize == 0) {
|
||||||
defaultIconSize = context.resources.getDimension(R.dimen.icon_size).toInt()
|
defaultIconSize = IconPack.defaultIconSize(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,9 @@ class IconPackListPreference @JvmOverloads constructor(context: Context,
|
||||||
val entries = ArrayList<String>()
|
val entries = ArrayList<String>()
|
||||||
val values = ArrayList<String>()
|
val values = ArrayList<String>()
|
||||||
for (iconPack in IconPackChooser.getIconPackList(context)) {
|
for (iconPack in IconPackChooser.getIconPackList(context)) {
|
||||||
if (iconPack.id != null) {
|
iconPack.id?.let { iconPackId ->
|
||||||
entries.add(iconPack.name)
|
entries.add(iconPack.name)
|
||||||
values.add(iconPack.id)
|
values.add(iconPackId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
<dimen name="card_view_margin_vertical">5dp</dimen>
|
<dimen name="card_view_margin_vertical">5dp</dimen>
|
||||||
<dimen name="card_view_padding">14dp</dimen>
|
<dimen name="card_view_padding">14dp</dimen>
|
||||||
<dimen name="item_file_info_height">148dp</dimen>
|
<dimen name="item_file_info_height">148dp</dimen>
|
||||||
<dimen name="icon_size">32dp</dimen>
|
|
||||||
<dimen name="lock_button_size">48dp</dimen>
|
<dimen name="lock_button_size">48dp</dimen>
|
||||||
<dimen name="hidden_lock_button_size">0dp</dimen>
|
<dimen name="hidden_lock_button_size">0dp</dimen>
|
||||||
<dimen name="content_percent">1</dimen>
|
<dimen name="content_percent">1</dimen>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 32
|
compileSdkVersion 32
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package com.kunzisoft.keepass.icons
|
package com.kunzisoft.keepass.icon
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.util.SparseIntArray
|
import android.util.SparseIntArray
|
||||||
import com.kunzisoft.keepass.database.R
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,7 +73,7 @@ class IconPack(packageName: String, resources: Resources, resourceId: Int) {
|
||||||
|
|
||||||
// Build the list of icons
|
// Build the list of icons
|
||||||
var num = 0
|
var num = 0
|
||||||
while (num < NB_ICONS) {
|
while (num < NB_DEFAULT_ICONS) {
|
||||||
// To construct the id with name_ic_XX_32dp (ex : classic_ic_08_32dp )
|
// To construct the id with name_ic_XX_32dp (ex : classic_ic_08_32dp )
|
||||||
val resId = resources.getIdentifier(
|
val resId = resources.getIdentifier(
|
||||||
id + "_" + String.format(Locale.ENGLISH, "%02d", num) + "_32dp",
|
id + "_" + String.format(Locale.ENGLISH, "%02d", num) + "_32dp",
|
||||||
|
@ -129,6 +129,10 @@ class IconPack(packageName: String, resources: Resources, resourceId: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val NB_ICONS = 69
|
private const val NB_DEFAULT_ICONS = 69
|
||||||
|
|
||||||
|
fun defaultIconSize(context: Context): Int {
|
||||||
|
return context.resources.getDimension(R.dimen.icon_size).toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 191 B |
22
icon-pack/src/main/res/values/dimens.xml
Normal file
22
icon-pack/src/main/res/values/dimens.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2023 Jeremy Jamet / Kunzisoft.
|
||||||
|
|
||||||
|
This file is part of KeePassDX.
|
||||||
|
|
||||||
|
KeePassDX is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
KeePassDX is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<resources>
|
||||||
|
<dimen name="icon_size">32dp</dimen>
|
||||||
|
</resources>
|
Loading…
Add table
Add a link
Reference in a new issue