mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-06-05 21:59:15 +02:00
pass the proper context at creating widgets
This commit is contained in:
@ -95,8 +95,8 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon
|
val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon
|
||||||
val widthCells = Math.min(COLUMN_COUNT, getTileCount(info.minWidth))
|
val widthCells = Math.min(COLUMN_COUNT, getTileCount(info.minWidth))
|
||||||
val heightCells = Math.min(ROW_COUNT, getTileCount(info.minHeight))
|
val heightCells = Math.min(ROW_COUNT, getTileCount(info.minHeight))
|
||||||
val widget =
|
val className = info.provider.shortClassName
|
||||||
AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthCells, heightCells, false, info.provider.shortClassName)
|
val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthCells, heightCells, false, className)
|
||||||
appWidgets.add(widget)
|
appWidgets.add(widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
null
|
null
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
val widgetView = appWidgetHost.createView(context, appWidgetId, appWidgetProviderInfo) as MyAppWidgetHostView
|
// we have to pass the base context here, else there will be errors with the themes
|
||||||
|
val widgetView = appWidgetHost.createView(activity.baseContext, appWidgetId, appWidgetProviderInfo) as MyAppWidgetHostView
|
||||||
widgetView.setAppWidget(appWidgetId, appWidgetProviderInfo)
|
widgetView.setAppWidget(appWidgetId, appWidgetProviderInfo)
|
||||||
|
|
||||||
widgetView.x = item.left * rowWidth + sideMargins.left.toFloat()
|
widgetView.x = item.left * rowWidth + sideMargins.left.toFloat()
|
||||||
|
Reference in New Issue
Block a user