From 2dcea7a90eadbe691417816e0f5d6f6b4c5f2c10 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 26 Sep 2022 21:30:47 +0200 Subject: [PATCH] limit widget width or height to 5 for now --- .../launcher/fragments/WidgetsFragment.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/WidgetsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/WidgetsFragment.kt index e1bdc80..a684641 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/WidgetsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/WidgetsFragment.kt @@ -16,7 +16,9 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.launcher.activities.MainActivity import com.simplemobiletools.launcher.adapters.WidgetsAdapter +import com.simplemobiletools.launcher.helpers.COLUMN_COUNT import com.simplemobiletools.launcher.helpers.ITEM_TYPE_WIDGET +import com.simplemobiletools.launcher.helpers.ROW_COUNT import com.simplemobiletools.launcher.interfaces.WidgetsFragmentListener import com.simplemobiletools.launcher.models.* import kotlinx.android.synthetic.main.widgets_fragment.view.* @@ -90,9 +92,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 widthTileCount = getTileCount(info.minWidth) - val heightTileCount = getTileCount(info.minHeight) - val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthTileCount, heightTileCount, false) + val widthCells = Math.min(COLUMN_COUNT, getTileCount(info.minWidth)) + val heightCells = Math.min(ROW_COUNT, getTileCount(info.minHeight)) + val widget = AppWidget(appPackageName, appTitle, appIcon, widgetTitle, widgetPreviewImage, widthCells, heightCells, false) appWidgets.add(widget) }