Fix icon selection and icon removed no longer accessible

This commit is contained in:
J-Jamet
2021-03-07 17:15:48 +01:00
parent 76d60ded4c
commit e5184a1568
2 changed files with 15 additions and 12 deletions

View File

@@ -34,9 +34,9 @@ class IconStandardFragment : IconFragment<IconImageStandard>() {
return database.getStandardIconList()
}
override fun onIconLongClickListener(icon: IconImageStandard) {
override fun onIconClickListener(icon: IconImageStandard) {
iconPickerViewModel.pickStandardIcon(icon)
}
override fun onIconClickListener(icon: IconImageStandard) {}
override fun onIconLongClickListener(icon: IconImageStandard) {}
}

View File

@@ -66,22 +66,23 @@ class IconDrawableFactory(private val retrieveCipherKey : () -> Database.LoadedK
*/
private fun getIconSuperDrawable(context: Context, iconDraw: IconImageDraw, width: Int, tintColor: Int = Color.WHITE): SuperDrawable {
val icon = iconDraw.getIconImageToDraw()
return if (!icon.custom.isUnknown) {
SuperDrawable(getIconDrawable(context.resources, icon.custom))
} else {
if (!icon.custom.isUnknown) {
getIconDrawable(context.resources, icon.custom)?.let {
return SuperDrawable(it)
}
}
val iconPack = IconPackChooser.getSelectedIconPack(context)
iconPack?.iconToResId(icon.standard.id)?.let { iconId ->
SuperDrawable(getIconDrawable(context.resources, iconId, width, tintColor), iconPack.tintable())
return SuperDrawable(getIconDrawable(context.resources, iconId, width, tintColor), iconPack.tintable())
} ?: run {
SuperDrawable(PatternIcon(context.resources).blankDrawable)
}
return SuperDrawable(PatternIcon(context.resources).blankDrawable)
}
}
/**
* Build a custom [Drawable] from custom [icon]
*/
private fun getIconDrawable(resources: Resources, icon: IconImageCustom): Drawable {
private fun getIconDrawable(resources: Resources, icon: IconImageCustom): Drawable? {
val patternIcon = PatternIcon(resources)
val cipherKey = retrieveCipherKey.invoke()
if (cipherKey != null) {
@@ -93,12 +94,14 @@ class IconDrawableFactory(private val retrieveCipherKey : () -> Database.LoadedK
val createdDraw = BitmapDrawable(resources, bitmap)
customIconMap[icon.uuid] = WeakReference(createdDraw)
return createdDraw
} ?: run {
}
} else {
return draw
}
}
return patternIcon.blankDrawable
return null
}
/**