calculate widget tiles from real sizes
This commit is contained in:
parent
d23893755a
commit
08de22c3c9
|
@ -50,9 +50,9 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
val appIcon = appMetadata.appIcon
|
||||
val widgetTitle = info.loadLabel(packageManager)
|
||||
val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon
|
||||
val width = info.minWidth
|
||||
val height = info.minHeight
|
||||
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, width, height)
|
||||
val widthTileCount = getTileCount(info.minWidth)
|
||||
val heightTileCount = getTileCount(info.minHeight)
|
||||
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthTileCount, heightTileCount)
|
||||
appWidgets.add(widget)
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,8 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
}
|
||||
}
|
||||
|
||||
private fun getTileCount(size: Int) = Math.ceil(((size / resources.displayMetrics.density) - 30) / 70.0).toInt()
|
||||
|
||||
private fun splitWidgetsByApps(appWidgets: ArrayList<AppWidget>) {
|
||||
var currentAppPackageName = ""
|
||||
val widgetListItems = ArrayList<WidgetsListItem>()
|
||||
|
|
|
@ -8,6 +8,6 @@ data class AppWidget(
|
|||
val appIcon: Drawable,
|
||||
val widgetTitle: String,
|
||||
val widgetPreviewImage: Drawable?,
|
||||
var width: Int,
|
||||
val height: Int
|
||||
var widthTiles: Int,
|
||||
val heightTiles: Int
|
||||
) : WidgetsListItem()
|
||||
|
|
Loading…
Reference in New Issue