mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-04-20 04:47:33 +02:00
reworking some widget size handling
This commit is contained in:
parent
e69dc7438c
commit
a8755b566e
@ -497,7 +497,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
try {
|
try {
|
||||||
val defaultDialerPackage = (getSystemService(Context.TELECOM_SERVICE) as TelecomManager).defaultDialerPackage
|
val defaultDialerPackage = (getSystemService(Context.TELECOM_SERVICE) as TelecomManager).defaultDialerPackage
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultDialerPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultDialerPackage }?.apply {
|
||||||
val dialerIcon = HomeScreenGridItem(null, 0, ROW_COUNT - 1, 1, ROW_COUNT, 1, 1, defaultDialerPackage, title, ITEM_TYPE_ICON, "", -1, null, null)
|
val dialerIcon = HomeScreenGridItem(null, 0, ROW_COUNT - 1, 1, ROW_COUNT, defaultDialerPackage, title, ITEM_TYPE_ICON, "", -1)
|
||||||
homeScreenGridItems.add(dialerIcon)
|
homeScreenGridItems.add(dialerIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -507,7 +507,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
val defaultSMSMessengerPackage = Telephony.Sms.getDefaultSmsPackage(this)
|
val defaultSMSMessengerPackage = Telephony.Sms.getDefaultSmsPackage(this)
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultSMSMessengerPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultSMSMessengerPackage }?.apply {
|
||||||
val SMSMessengerIcon =
|
val SMSMessengerIcon =
|
||||||
HomeScreenGridItem(null, 1, ROW_COUNT - 1, 2, ROW_COUNT, 1, 1, defaultSMSMessengerPackage, title, ITEM_TYPE_ICON, "", -1, null, null)
|
HomeScreenGridItem(null, 1, ROW_COUNT - 1, 2, ROW_COUNT, defaultSMSMessengerPackage, title, ITEM_TYPE_ICON, "", -1)
|
||||||
homeScreenGridItems.add(SMSMessengerIcon)
|
homeScreenGridItems.add(SMSMessengerIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -519,7 +519,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
val defaultBrowserPackage = resolveInfo!!.activityInfo.packageName
|
val defaultBrowserPackage = resolveInfo!!.activityInfo.packageName
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultBrowserPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultBrowserPackage }?.apply {
|
||||||
val browserIcon =
|
val browserIcon =
|
||||||
HomeScreenGridItem(null, 2, ROW_COUNT - 1, 3, ROW_COUNT, 1, 1, defaultBrowserPackage, title, ITEM_TYPE_ICON, "", -1, null, null)
|
HomeScreenGridItem(null, 2, ROW_COUNT - 1, 3, ROW_COUNT, defaultBrowserPackage, title, ITEM_TYPE_ICON, "", -1)
|
||||||
homeScreenGridItems.add(browserIcon)
|
homeScreenGridItems.add(browserIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -530,7 +530,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
val storePackage = potentialStores.firstOrNull { isPackageInstalled(it) && appLaunchers.map { it.packageName }.contains(it) }
|
val storePackage = potentialStores.firstOrNull { isPackageInstalled(it) && appLaunchers.map { it.packageName }.contains(it) }
|
||||||
if (storePackage != null) {
|
if (storePackage != null) {
|
||||||
appLaunchers.firstOrNull { it.packageName == storePackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == storePackage }?.apply {
|
||||||
val storeIcon = HomeScreenGridItem(null, 3, ROW_COUNT - 1, 4, ROW_COUNT, 1, 1, storePackage, title, ITEM_TYPE_ICON, "", -1, null, null)
|
val storeIcon = HomeScreenGridItem(null, 3, ROW_COUNT - 1, 4, ROW_COUNT, storePackage, title, ITEM_TYPE_ICON, "", -1)
|
||||||
homeScreenGridItems.add(storeIcon)
|
homeScreenGridItems.add(storeIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -542,7 +542,7 @@ class MainActivity : SimpleActivity(), FlingListener {
|
|||||||
val resolveInfo = packageManager.resolveActivity(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY)
|
val resolveInfo = packageManager.resolveActivity(cameraIntent, PackageManager.MATCH_DEFAULT_ONLY)
|
||||||
val defaultCameraPackage = resolveInfo!!.activityInfo.packageName
|
val defaultCameraPackage = resolveInfo!!.activityInfo.packageName
|
||||||
appLaunchers.firstOrNull { it.packageName == defaultCameraPackage }?.apply {
|
appLaunchers.firstOrNull { it.packageName == defaultCameraPackage }?.apply {
|
||||||
val cameraIcon = HomeScreenGridItem(null, 4, ROW_COUNT - 1, 5, ROW_COUNT, 1, 1, defaultCameraPackage, title, ITEM_TYPE_ICON, "", -1, null, null)
|
val cameraIcon = HomeScreenGridItem(null, 4, ROW_COUNT - 1, 5, ROW_COUNT, defaultCameraPackage, title, ITEM_TYPE_ICON, "", -1)
|
||||||
homeScreenGridItems.add(cameraIcon)
|
homeScreenGridItems.add(cameraIcon)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
@ -230,15 +230,15 @@ class WidgetsFragment(context: Context, attributeSet: AttributeSet) : MyFragment
|
|||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
appWidget.widthCells,
|
|
||||||
appWidget.heightCells,
|
|
||||||
appWidget.appPackageName,
|
appWidget.appPackageName,
|
||||||
"",
|
"",
|
||||||
type,
|
type,
|
||||||
appWidget.className,
|
appWidget.className,
|
||||||
-1,
|
-1,
|
||||||
appWidget.widgetPreviewImage,
|
appWidget.widgetPreviewImage,
|
||||||
appWidget.providerInfo
|
appWidget.providerInfo,
|
||||||
|
appWidget.widthCells,
|
||||||
|
appWidget.heightCells
|
||||||
)
|
)
|
||||||
|
|
||||||
activity?.widgetLongPressedOnList(gridItem)
|
activity?.widgetLongPressedOnList(gridItem)
|
||||||
|
@ -13,16 +13,28 @@ data class HomeScreenGridItem(
|
|||||||
@ColumnInfo(name = "top") var top: Int,
|
@ColumnInfo(name = "top") var top: Int,
|
||||||
@ColumnInfo(name = "right") var right: Int,
|
@ColumnInfo(name = "right") var right: Int,
|
||||||
@ColumnInfo(name = "bottom") var bottom: Int,
|
@ColumnInfo(name = "bottom") var bottom: Int,
|
||||||
@ColumnInfo(name = "width_cells") var widthCells: Int,
|
|
||||||
@ColumnInfo(name = "height_cells") var heightCells: Int,
|
|
||||||
@ColumnInfo(name = "package_name") var packageName: String,
|
@ColumnInfo(name = "package_name") var packageName: String,
|
||||||
@ColumnInfo(name = "title") var title: String,
|
@ColumnInfo(name = "title") var title: String,
|
||||||
@ColumnInfo(name = "type") var type: Int,
|
@ColumnInfo(name = "type") var type: Int,
|
||||||
@ColumnInfo(name = "class_name") var className: String,
|
@ColumnInfo(name = "class_name") var className: String,
|
||||||
@ColumnInfo(name = "widget_id") var widgetId: Int,
|
@ColumnInfo(name = "widget_id") var widgetId: Int,
|
||||||
|
|
||||||
@Ignore var drawable: Drawable?,
|
@Ignore var drawable: Drawable? = null,
|
||||||
@Ignore var providerInfo: AppWidgetProviderInfo?
|
@Ignore var providerInfo: AppWidgetProviderInfo? = null,
|
||||||
|
@Ignore var widthCells: Int = 1,
|
||||||
|
@Ignore var heightCells: Int = 1
|
||||||
) {
|
) {
|
||||||
constructor() : this(null, -1, -1, -1, -1, 1, 1, "", "", ITEM_TYPE_ICON, "", -1, null, null)
|
constructor() : this(null, -1, -1, -1, -1, "", "", ITEM_TYPE_ICON, "", -1, null, null, 1, 1)
|
||||||
|
|
||||||
|
fun getWidthInCells() = if (right == -1 || left == -1) {
|
||||||
|
widthCells
|
||||||
|
} else {
|
||||||
|
right - left + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getHeightInCells() = if (bottom == -1 || top == -1) {
|
||||||
|
heightCells
|
||||||
|
} else {
|
||||||
|
bottom - top + 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import androidx.core.graphics.drawable.toDrawable
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.helpers.isSPlus
|
import com.simplemobiletools.commons.helpers.isSPlus
|
||||||
|
import com.simplemobiletools.commons.helpers.mydebug
|
||||||
import com.simplemobiletools.launcher.R
|
import com.simplemobiletools.launcher.R
|
||||||
import com.simplemobiletools.launcher.activities.MainActivity
|
import com.simplemobiletools.launcher.activities.MainActivity
|
||||||
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
import com.simplemobiletools.launcher.extensions.getDrawableForPackageName
|
||||||
@ -189,7 +190,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
}
|
}
|
||||||
|
|
||||||
resize_frame.onResizeListener = { cellsRect ->
|
resize_frame.onResizeListener = { cellsRect ->
|
||||||
|
mydebug("resized to $cellsRect")
|
||||||
|
val minWidth = (cellsRect.width() + 1) * cellWidth
|
||||||
|
val minHeight = (cellsRect.height() + 1) * cellHeight
|
||||||
|
widgetView.updateAppWidgetSize(Bundle(), minWidth, minHeight, minWidth, minHeight)
|
||||||
|
widgetView.layoutParams.width = minWidth
|
||||||
|
widgetView.layoutParams.height = minHeight
|
||||||
|
ensureBackgroundThread {
|
||||||
|
context.homeScreenGridItemsDB.updateItemPosition(cellsRect.left, cellsRect.top, cellsRect.right, cellsRect.bottom, item.id!!)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widgetView.ignoreTouches = true
|
widgetView.ignoreTouches = true
|
||||||
@ -264,8 +273,6 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
yIndex,
|
yIndex,
|
||||||
xIndex + 1,
|
xIndex + 1,
|
||||||
yIndex + 1,
|
yIndex + 1,
|
||||||
1,
|
|
||||||
1,
|
|
||||||
draggedItem!!.packageName,
|
draggedItem!!.packageName,
|
||||||
draggedItem!!.title,
|
draggedItem!!.title,
|
||||||
draggedItem!!.type,
|
draggedItem!!.type,
|
||||||
@ -420,8 +427,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
|
|
||||||
widgetView.x = calculateWidgetX(item.left)
|
widgetView.x = calculateWidgetX(item.left)
|
||||||
widgetView.y = calculateWidgetY(item.top)
|
widgetView.y = calculateWidgetY(item.top)
|
||||||
val widgetWidth = item.widthCells * cellWidth
|
val widgetWidth = item.getWidthInCells() * cellWidth
|
||||||
val widgetHeight = item.heightCells * cellHeight
|
val widgetHeight = item.getHeightInCells() * cellHeight
|
||||||
|
|
||||||
// set initial sizes to avoid some glitches
|
// set initial sizes to avoid some glitches
|
||||||
if (isSPlus()) {
|
if (isSPlus()) {
|
||||||
@ -566,8 +573,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
val widgetRect = getWidgetOccupiedRect(gridCells)
|
val widgetRect = getWidgetOccupiedRect(gridCells)
|
||||||
val leftSide = widgetRect.left * cellWidth + sideMargins.left + iconMargin.toFloat()
|
val leftSide = widgetRect.left * cellWidth + sideMargins.left + iconMargin.toFloat()
|
||||||
val topSide = widgetRect.top * cellHeight + sideMargins.top + iconMargin.toFloat()
|
val topSide = widgetRect.top * cellHeight + sideMargins.top + iconMargin.toFloat()
|
||||||
val rightSide = leftSide + draggedItem!!.widthCells * cellWidth - sideMargins.right - iconMargin.toFloat()
|
val rightSide = leftSide + draggedItem!!.getWidthInCells() * cellWidth - sideMargins.right - iconMargin.toFloat()
|
||||||
val bottomSide = topSide + draggedItem!!.heightCells * cellHeight - sideMargins.top
|
val bottomSide = topSide + draggedItem!!.getHeightInCells() * cellHeight - sideMargins.top
|
||||||
canvas.drawRoundRect(leftSide, topSide, rightSide, bottomSide, roundedCornerRadius, roundedCornerRadius, dragShadowCirclePaint)
|
canvas.drawRoundRect(leftSide, topSide, rightSide, bottomSide, roundedCornerRadius, roundedCornerRadius, dragShadowCirclePaint)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,7 +583,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
val aspectRatio = drawable.minimumHeight / drawable.minimumWidth.toFloat()
|
val aspectRatio = drawable.minimumHeight / drawable.minimumWidth.toFloat()
|
||||||
val drawableX = (draggedItemCurrentCoords.first - drawable.minimumWidth / 2f).toInt()
|
val drawableX = (draggedItemCurrentCoords.first - drawable.minimumWidth / 2f).toInt()
|
||||||
val drawableY = (draggedItemCurrentCoords.second - drawable.minimumHeight / 3f).toInt()
|
val drawableY = (draggedItemCurrentCoords.second - drawable.minimumHeight / 3f).toInt()
|
||||||
val drawableWidth = draggedItem!!.widthCells * cellWidth - iconMargin * (draggedItem!!.widthCells - 1)
|
val drawableWidth = draggedItem!!.getWidthInCells() * cellWidth - iconMargin * (draggedItem!!.getWidthInCells() - 1)
|
||||||
drawable.setBounds(
|
drawable.setBounds(
|
||||||
drawableX,
|
drawableX,
|
||||||
drawableY,
|
drawableY,
|
||||||
@ -612,8 +619,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
|
|
||||||
// drag the center of the widget, not the top left corner
|
// drag the center of the widget, not the top left corner
|
||||||
private fun getWidgetOccupiedRect(item: Pair<Int, Int>): Rect {
|
private fun getWidgetOccupiedRect(item: Pair<Int, Int>): Rect {
|
||||||
val left = item.first - Math.floor((draggedItem!!.widthCells - 1) / 2.0).toInt()
|
val left = item.first - Math.floor((draggedItem!!.getWidthInCells() - 1) / 2.0).toInt()
|
||||||
val rect = Rect(left, item.second, left + draggedItem!!.widthCells, item.second + draggedItem!!.heightCells)
|
val rect = Rect(left, item.second, left + draggedItem!!.getWidthInCells(), item.second + draggedItem!!.getHeightInCells())
|
||||||
if (rect.left < 0) {
|
if (rect.left < 0) {
|
||||||
rect.right -= rect.left
|
rect.right -= rect.left
|
||||||
rect.left = 0
|
rect.left = 0
|
||||||
@ -643,8 +650,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
|||||||
} else if (gridItem.type == ITEM_TYPE_WIDGET) {
|
} else if (gridItem.type == ITEM_TYPE_WIDGET) {
|
||||||
val left = calculateWidgetX(gridItem.left)
|
val left = calculateWidgetX(gridItem.left)
|
||||||
val top = calculateWidgetY(gridItem.top)
|
val top = calculateWidgetY(gridItem.top)
|
||||||
val right = left + gridItem.widthCells * cellWidth
|
val right = left + gridItem.getWidthInCells() * cellWidth
|
||||||
val bottom = top + gridItem.heightCells * cellHeight
|
val bottom = top + gridItem.getHeightInCells() * cellHeight
|
||||||
|
|
||||||
if (x >= left && x <= right && y >= top && y <= bottom) {
|
if (x >= left && x <= right && y >= top && y <= bottom) {
|
||||||
return gridItem
|
return gridItem
|
||||||
|
@ -137,8 +137,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
|
|
||||||
val closestCellX = roundToClosestMultiplyOfNumber(wantedLeft - sideMargins.left, cellWidth) / cellWidth
|
val closestCellX = roundToClosestMultiplyOfNumber(wantedLeft - sideMargins.left, cellWidth) / cellWidth
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in closestCellX until cellsRect.right) {
|
for (xCell in closestCellX..cellsRect.right) {
|
||||||
for (yCell in cellsRect.top until cellsRect.bottom) {
|
for (yCell in cellsRect.top..cellsRect.bottom) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -162,8 +162,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
|
|
||||||
val closestCellY = roundToClosestMultiplyOfNumber(wantedTop - sideMargins.top, cellHeight) / cellHeight
|
val closestCellY = roundToClosestMultiplyOfNumber(wantedTop - sideMargins.top, cellHeight) / cellHeight
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in cellsRect.left until cellsRect.right) {
|
for (xCell in cellsRect.left..cellsRect.right) {
|
||||||
for (yCell in closestCellY until cellsRect.bottom) {
|
for (yCell in closestCellY..cellsRect.bottom) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -187,8 +187,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
|
|
||||||
val closestCellX = roundToClosestMultiplyOfNumber(wantedRight - sideMargins.left, cellWidth) / cellWidth - 1
|
val closestCellX = roundToClosestMultiplyOfNumber(wantedRight - sideMargins.left, cellWidth) / cellWidth - 1
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in cellsRect.left until closestCellX + 1) {
|
for (xCell in cellsRect.left..closestCellX + 1) {
|
||||||
for (yCell in cellsRect.top until cellsRect.bottom) {
|
for (yCell in cellsRect.top..cellsRect.bottom) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -212,8 +212,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
|
|
||||||
val closestCellY = roundToClosestMultiplyOfNumber(wantedBottom - sideMargins.top, cellHeight) / cellHeight - 1
|
val closestCellY = roundToClosestMultiplyOfNumber(wantedBottom - sideMargins.top, cellHeight) / cellHeight - 1
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in cellsRect.left until cellsRect.right) {
|
for (xCell in cellsRect.left..cellsRect.right) {
|
||||||
for (yCell in cellsRect.top until closestCellY + 1) {
|
for (yCell in cellsRect.top..closestCellY + 1) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -245,8 +245,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
val wantedLeft = roundToClosestMultiplyOfNumber(frameRect.left - sideMargins.left, cellWidth)
|
val wantedLeft = roundToClosestMultiplyOfNumber(frameRect.left - sideMargins.left, cellWidth)
|
||||||
val wantedLeftCellX = wantedLeft / cellWidth
|
val wantedLeftCellX = wantedLeft / cellWidth
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in wantedLeftCellX until cellsRect.right) {
|
for (xCell in wantedLeftCellX..cellsRect.right) {
|
||||||
for (yCell in cellsRect.top until cellsRect.bottom) {
|
for (yCell in cellsRect.top..cellsRect.bottom) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -264,8 +264,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
val wantedTop = roundToClosestMultiplyOfNumber(frameRect.top - sideMargins.top, cellHeight)
|
val wantedTop = roundToClosestMultiplyOfNumber(frameRect.top - sideMargins.top, cellHeight)
|
||||||
val wantedTopCellY = wantedTop / cellHeight
|
val wantedTopCellY = wantedTop / cellHeight
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in cellsRect.left until cellsRect.right) {
|
for (xCell in cellsRect.left..cellsRect.right) {
|
||||||
for (yCell in wantedTopCellY until cellsRect.bottom) {
|
for (yCell in wantedTopCellY..cellsRect.bottom) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -283,8 +283,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
val wantedRight = roundToClosestMultiplyOfNumber(frameRect.right - sideMargins.left, cellWidth)
|
val wantedRight = roundToClosestMultiplyOfNumber(frameRect.right - sideMargins.left, cellWidth)
|
||||||
val wantedRightCellX = wantedRight / cellWidth - 1
|
val wantedRightCellX = wantedRight / cellWidth - 1
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in cellsRect.left until wantedRightCellX + 1) {
|
for (xCell in cellsRect.left..wantedRightCellX + 1) {
|
||||||
for (yCell in cellsRect.top until cellsRect.bottom) {
|
for (yCell in cellsRect.top..cellsRect.bottom) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
@ -302,8 +302,8 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
|||||||
val wantedBottom = roundToClosestMultiplyOfNumber(frameRect.bottom - sideMargins.top, cellHeight)
|
val wantedBottom = roundToClosestMultiplyOfNumber(frameRect.bottom - sideMargins.top, cellHeight)
|
||||||
val wantedBottomCellY = wantedBottom / cellHeight - 1
|
val wantedBottomCellY = wantedBottom / cellHeight - 1
|
||||||
var areAllCellsFree = true
|
var areAllCellsFree = true
|
||||||
for (xCell in cellsRect.left until cellsRect.right) {
|
for (xCell in cellsRect.left..cellsRect.right) {
|
||||||
for (yCell in cellsRect.top until wantedBottomCellY + 1) {
|
for (yCell in cellsRect.top..wantedBottomCellY + 1) {
|
||||||
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
if (occupiedCells.contains(Pair(xCell, yCell))) {
|
||||||
areAllCellsFree = false
|
areAllCellsFree = false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user