mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Fix icon crop
Rectangular icons were causing issues with the conversation icon display (probably an Android bug) and shortcut icons were being cropped in unnecessarily.
This commit is contained in:
parent
996b4e7a45
commit
5df0bd69c7
2 changed files with 8 additions and 2 deletions
|
@ -171,6 +171,7 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active
|
||||||
.toBitmap(width = iconSize, height = iconSize))
|
.toBitmap(width = iconSize, height = iconSize))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.apply(RequestOptions.centerCropTransform())
|
||||||
.submit(iconSize, iconSize)
|
.submit(iconSize, iconSize)
|
||||||
.get()
|
.get()
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.home
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.pm.ShortcutInfo
|
import android.content.pm.ShortcutInfo
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.Canvas
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.annotation.WorkerThread
|
import androidx.annotation.WorkerThread
|
||||||
import androidx.core.content.pm.ShortcutInfoCompat
|
import androidx.core.content.pm.ShortcutInfoCompat
|
||||||
|
@ -46,7 +47,7 @@ class ShortcutCreator @Inject constructor(
|
||||||
private val adaptiveIconOuterSides = dimensionConverter.dpToPx(adaptiveIconOuterSidesDp)
|
private val adaptiveIconOuterSides = dimensionConverter.dpToPx(adaptiveIconOuterSidesDp)
|
||||||
private val iconSize by lazy {
|
private val iconSize by lazy {
|
||||||
if (useAdaptiveIcon) {
|
if (useAdaptiveIcon) {
|
||||||
adaptiveIconSize - adaptiveIconOuterSides
|
adaptiveIconSize - (adaptiveIconOuterSides * 2)
|
||||||
} else {
|
} else {
|
||||||
dimensionConverter.dpToPx(72)
|
dimensionConverter.dpToPx(72)
|
||||||
}
|
}
|
||||||
|
@ -80,7 +81,11 @@ class ShortcutCreator @Inject constructor(
|
||||||
|
|
||||||
private fun Bitmap.toProfileImageIcon(): IconCompat {
|
private fun Bitmap.toProfileImageIcon(): IconCompat {
|
||||||
return if (useAdaptiveIcon) {
|
return if (useAdaptiveIcon) {
|
||||||
IconCompat.createWithAdaptiveBitmap(this)
|
val insetBmp = Bitmap.createBitmap(adaptiveIconSize, adaptiveIconSize, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(insetBmp)
|
||||||
|
canvas.drawBitmap(this, adaptiveIconOuterSides.toFloat(), adaptiveIconOuterSides.toFloat(), null)
|
||||||
|
|
||||||
|
IconCompat.createWithAdaptiveBitmap(insetBmp)
|
||||||
} else {
|
} else {
|
||||||
IconCompat.createWithBitmap(this)
|
IconCompat.createWithBitmap(this)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue