replace tile counts with "Shortcut" at shortcut widgets
This commit is contained in:
parent
3e79d22fbb
commit
480de21288
3 changed files with 13 additions and 5 deletions
|
@ -82,7 +82,11 @@ class WidgetsAdapter(
|
|||
}
|
||||
|
||||
widgetPreview.widget_size.apply {
|
||||
text = "${widget.widthTiles} x ${widget.heightTiles}"
|
||||
text = if (widget.isShortcut) {
|
||||
activity.getString(R.string.shortcut)
|
||||
} else {
|
||||
"${widget.widthTiles} x ${widget.heightTiles}"
|
||||
}
|
||||
setTextColor(textColor)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon
|
||||
val widthTileCount = getTileCount(info.minWidth)
|
||||
val heightTileCount = getTileCount(info.minHeight)
|
||||
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthTileCount, heightTileCount)
|
||||
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthTileCount, heightTileCount, false)
|
||||
appWidgets.add(widget)
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
val appIcon = appMetadata.appIcon
|
||||
val widgetTitle = info.loadLabel(packageManager).toString()
|
||||
val widgetPreviewImage = packageManager.getDrawable(componentInfo.packageName, info.iconResource, componentInfo)
|
||||
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, 0, 0)
|
||||
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, 0, 0, true)
|
||||
appWidgets.add(widget)
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,10 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||
}
|
||||
}
|
||||
|
||||
private fun getTileCount(size: Int) = Math.ceil(((size / resources.displayMetrics.density) - 30) / 70.0).toInt()
|
||||
private fun getTileCount(size: Int): Int {
|
||||
val tiles = Math.ceil(((size / resources.displayMetrics.density) - 30) / 70.0).toInt()
|
||||
return Math.max(tiles, 1)
|
||||
}
|
||||
|
||||
private fun splitWidgetsByApps(appWidgets: ArrayList<AppWidget>) {
|
||||
var currentAppPackageName = ""
|
||||
|
|
|
@ -9,5 +9,6 @@ data class AppWidget(
|
|||
val widgetTitle: String,
|
||||
val widgetPreviewImage: Drawable?,
|
||||
var widthTiles: Int,
|
||||
val heightTiles: Int
|
||||
val heightTiles: Int,
|
||||
val isShortcut: Boolean
|
||||
) : WidgetsListItem()
|
||||
|
|
Loading…
Reference in a new issue