rely on className instead of shortClassName at widgets

This commit is contained in:
tibbi 2022-10-01 10:23:05 +02:00
parent a337f5e081
commit 833a3f0529
4 changed files with 5 additions and 5 deletions

View File

@ -95,7 +95,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon
val widthCells = Math.min(COLUMN_COUNT, getTileCount(info.minWidth))
val heightCells = Math.min(ROW_COUNT, getTileCount(info.minHeight))
val className = info.provider.shortClassName
val className = info.provider.className
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthCells, heightCells, false, className)
appWidgets.add(widget)
}
@ -239,7 +239,7 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
appWidget.appPackageName,
"",
type,
appWidget.shortClassName,
appWidget.className,
-1,
appWidget.widgetPreviewImage
)

View File

@ -11,7 +11,7 @@ data class AppWidget(
var widthCells: Int,
val heightCells: Int,
val isShortcut: Boolean,
val shortClassName: String // identifier to know which app widget are we using
val className: String // identifier to know which app widget are we using
) : WidgetsListItem() {
override fun getHashToCompare() = getStringToCompare().hashCode()

View File

@ -17,7 +17,7 @@ data class HomeScreenGridItem(
@ColumnInfo(name = "package_name") var packageName: String,
@ColumnInfo(name = "title") var title: String,
@ColumnInfo(name = "type") var type: Int,
@ColumnInfo(name = "short_class_name") var shortClassName: String,
@ColumnInfo(name = "class_name") var className: String,
@ColumnInfo(name = "widget_id") var widgetId: Int,
@Ignore var drawable: Drawable?

View File

@ -287,7 +287,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
private fun bindWidget(item: HomeScreenGridItem, isInitialDrawAfterLaunch: Boolean) {
val activity = context as MainActivity
val infoList = appWidgetManager!!.installedProviders
val appWidgetProviderInfo = infoList.firstOrNull { it.provider.shortClassName == item.shortClassName }
val appWidgetProviderInfo = infoList.firstOrNull { it.provider.className == item.className }
if (appWidgetProviderInfo != null) {
val appWidgetId = appWidgetHost.allocateAppWidgetId()
activity.handleWidgetBinding(appWidgetManager, appWidgetId, appWidgetProviderInfo) { canBind ->