This commit is contained in:
Thibault Deckers 2025-01-23 00:41:03 +01:00
parent 405794467b
commit a99f4877ce
2 changed files with 6 additions and 5 deletions

View file

@ -36,7 +36,7 @@ android {
namespace 'deckers.thibault.aves' namespace 'deckers.thibault.aves'
compileSdk 35 compileSdk 35
// cf https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp // cf https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp
ndkVersion '27.0.12077973' ndkVersion '28.0.12916984'
defaultConfig { defaultConfig {
applicationId packageName applicationId packageName

View file

@ -83,7 +83,7 @@ class HomeWidgetProvider : AppWidgetProvider() {
private fun getDevicePixelRatio(): Float = Resources.getSystem().displayMetrics.density private fun getDevicePixelRatio(): Float = Resources.getSystem().displayMetrics.density
private fun getWidgetSizesDip(context: Context, widgetInfo: Bundle): List<FieldMap> { private fun getWidgetSizesDip(context: Context, widgetInfo: Bundle): List<SizeF> {
var sizes: List<SizeF>? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { var sizes: List<SizeF>? = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
widgetInfo.getParcelableArrayList(AppWidgetManager.OPTION_APPWIDGET_SIZES, SizeF::class.java) widgetInfo.getParcelableArrayList(AppWidgetManager.OPTION_APPWIDGET_SIZES, SizeF::class.java)
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
@ -102,7 +102,7 @@ class HomeWidgetProvider : AppWidgetProvider() {
sizes = listOf(SizeF(widthDip.toFloat(), heightDip.toFloat())) sizes = listOf(SizeF(widthDip.toFloat(), heightDip.toFloat()))
} }
return sizes.map { size -> hashMapOf("widthDip" to size.width, "heightDip" to size.height) } return sizes
} }
private suspend fun getProps( private suspend fun getProps(
@ -116,13 +116,14 @@ class HomeWidgetProvider : AppWidgetProvider() {
if (sizesDip.isEmpty()) return null if (sizesDip.isEmpty()) return null
val sizeDip = sizesDip.first() val sizeDip = sizesDip.first()
if (sizeDip["widthDip"] == 0 || sizeDip["heightDip"] == 0) return null if (sizeDip.width == 0f || sizeDip.height == 0f) return null
val sizesDipMap = sizesDip.map { size -> hashMapOf("widthDip" to size.width, "heightDip" to size.height) }
val isNightModeOn = (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES val isNightModeOn = (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
val params = hashMapOf( val params = hashMapOf(
"widgetId" to widgetId, "widgetId" to widgetId,
"sizesDip" to sizesDip, "sizesDip" to sizesDipMap,
"devicePixelRatio" to getDevicePixelRatio(), "devicePixelRatio" to getDevicePixelRatio(),
"drawEntryImage" to drawEntryImage, "drawEntryImage" to drawEntryImage,
"reuseEntry" to reuseEntry, "reuseEntry" to reuseEntry,