mirror of
				https://github.com/SimpleMobileTools/Simple-Launcher.git
				synced 2025-06-05 21:59:15 +02:00 
			
		
		
		
	calculate widget tiles from real sizes
This commit is contained in:
		| @@ -50,9 +50,9 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment | |||||||
|                 val appIcon = appMetadata.appIcon |                 val appIcon = appMetadata.appIcon | ||||||
|                 val widgetTitle = info.loadLabel(packageManager) |                 val widgetTitle = info.loadLabel(packageManager) | ||||||
|                 val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon |                 val widgetPreviewImage = info.loadPreviewImage(context, resources.displayMetrics.densityDpi) ?: appIcon | ||||||
|                 val width = info.minWidth |                 val widthTileCount = getTileCount(info.minWidth) | ||||||
|                 val height = info.minHeight |                 val heightTileCount = getTileCount(info.minHeight) | ||||||
|                 val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, width, height) |                 val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthTileCount, heightTileCount) | ||||||
|                 appWidgets.add(widget) |                 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>) { |     private fun splitWidgetsByApps(appWidgets: ArrayList<AppWidget>) { | ||||||
|         var currentAppPackageName = "" |         var currentAppPackageName = "" | ||||||
|         val widgetListItems = ArrayList<WidgetsListItem>() |         val widgetListItems = ArrayList<WidgetsListItem>() | ||||||
|   | |||||||
| @@ -8,6 +8,6 @@ data class AppWidget( | |||||||
|     val appIcon: Drawable, |     val appIcon: Drawable, | ||||||
|     val widgetTitle: String, |     val widgetTitle: String, | ||||||
|     val widgetPreviewImage: Drawable?, |     val widgetPreviewImage: Drawable?, | ||||||
|     var width: Int, |     var widthTiles: Int, | ||||||
|     val height: Int |     val heightTiles: Int | ||||||
| ) : WidgetsListItem() | ) : WidgetsListItem() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user