mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
icon size
This commit is contained in:
@@ -3,6 +3,7 @@ package com.kunzisoft.keepass.icons
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.BuildConfig
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.settings.DatabasePreferencesUtil
|
||||
import java.util.ArrayList
|
||||
|
||||
@@ -17,6 +18,7 @@ object IconPackChooser : InterfaceIconPackChooser {
|
||||
|
||||
private val iconPackList = ArrayList<IconPack>()
|
||||
private var iconPackSelected: IconPack? = null
|
||||
private var defaultIconSize: Int? = null
|
||||
|
||||
private var isIconPackChooserBuilt: Boolean = false
|
||||
|
||||
@@ -43,6 +45,9 @@ object IconPackChooser : InterfaceIconPackChooser {
|
||||
Log.e(TAG, "Icon packs can't be load, retry with one by default")
|
||||
addDefaultIconPack(context)
|
||||
}
|
||||
if(defaultIconSize == null) {
|
||||
setDefaultIconSize(context.resources.getDimension(R.dimen.icon_size).toInt())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,4 +110,12 @@ object IconPackChooser : InterfaceIconPackChooser {
|
||||
build(context)
|
||||
return iconPackList
|
||||
}
|
||||
|
||||
override fun setDefaultIconSize(size: Int) {
|
||||
defaultIconSize = size
|
||||
}
|
||||
|
||||
override fun getDefaultIconSize(): Int {
|
||||
return defaultIconSize!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,10 @@
|
||||
<dimen name="card_view_margin_vertical">5dp</dimen>
|
||||
<dimen name="card_view_padding">14dp</dimen>
|
||||
<dimen name="item_file_info_height">148dp</dimen>
|
||||
<dimen name="icon_size">32dp</dimen>
|
||||
<dimen name="lock_button_size">48dp</dimen>
|
||||
<dimen name="hidden_lock_button_size">0dp</dimen>
|
||||
<dimen name="content_percent">1</dimen>
|
||||
<dimen name="toolbar_parallax_height">160dp</dimen>
|
||||
<integer name="animation_duration">260</integer>
|
||||
</resources>
|
||||
</resources>
|
||||
@@ -32,7 +32,6 @@ import android.widget.RemoteViews
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import androidx.core.widget.ImageViewCompat
|
||||
import com.kunzisoft.keepass.database.R
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryCache
|
||||
import com.kunzisoft.keepass.database.element.binary.BinaryData
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImageCustom
|
||||
@@ -96,7 +95,7 @@ class IconDrawableFactory(
|
||||
return SuperDrawable(getIconDrawable(context.resources, iconId, width, tintColor),
|
||||
iconPack.tintable())
|
||||
} ?: run {
|
||||
return SuperDrawable(PatternIcon(context.resources).blankDrawable)
|
||||
return SuperDrawable(PatternIcon(iconPackChooser.getDefaultIconSize()).blankDrawable)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ class IconDrawableFactory(
|
||||
icon: IconImageCustom,
|
||||
iconCustomBinary: BinaryData?,
|
||||
): Drawable? {
|
||||
val patternIcon = PatternIcon(resources)
|
||||
val patternIcon = PatternIcon(iconPackChooser.getDefaultIconSize())
|
||||
val binaryManager = retrieveBinaryCache()
|
||||
if (binaryManager != null) {
|
||||
val draw: Drawable? = customIconMap[icon.uuid]?.get()
|
||||
@@ -161,7 +160,7 @@ class IconDrawableFactory(
|
||||
}
|
||||
|
||||
if (draw == null) {
|
||||
draw = PatternIcon(resources).blankDrawable
|
||||
draw = PatternIcon(iconPackChooser.getDefaultIconSize()).blankDrawable
|
||||
}
|
||||
draw.isFilterBitmap = false
|
||||
|
||||
@@ -277,15 +276,15 @@ class IconDrawableFactory(
|
||||
* Build a blankDrawable drawable
|
||||
* @param res Resource to build the drawable
|
||||
*/
|
||||
private class PatternIcon(res: Resources) {
|
||||
private class PatternIcon(defaultIconSize : Int) {
|
||||
|
||||
var blankDrawable: Drawable = ColorDrawable(Color.TRANSPARENT)
|
||||
var width = -1
|
||||
var height = -1
|
||||
|
||||
init {
|
||||
width = res.getDimension(R.dimen.icon_size).toInt()
|
||||
height = res.getDimension(R.dimen.icon_size).toInt()
|
||||
width = defaultIconSize
|
||||
height = defaultIconSize
|
||||
blankDrawable.setBounds(0, 0, width, height)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,6 @@ interface InterfaceIconPackChooser {
|
||||
fun setSelectedIconPack(iconPackIdString: String?)
|
||||
fun getSelectedIconPack(context: Context): IconPack?
|
||||
fun getIconPackList(context: Context): List<IconPack>
|
||||
fun setDefaultIconSize(int: Int)
|
||||
fun getDefaultIconSize(): Int
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="icon_size">32dp</dimen>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user