Reformat code

This commit is contained in:
Ensar Sarajčić 2023-08-03 16:58:18 +02:00
parent 651d3b041c
commit 36558b8949
3 changed files with 16 additions and 1 deletions

View file

@ -26,7 +26,12 @@ class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
setContentView(binding.root) setContentView(binding.root)
updateIcons() updateIcons()
updateMaterialActivityViews(binding.manageHiddenIconsCoordinator, binding.manageHiddenIconsList, useTransparentNavigation = true, useTopSearchMenu = false) updateMaterialActivityViews(
binding.manageHiddenIconsCoordinator,
binding.manageHiddenIconsList,
useTransparentNavigation = true,
useTopSearchMenu = false
)
setupMaterialScrollListener(binding.manageHiddenIconsList, binding.manageHiddenIconsToolbar) setupMaterialScrollListener(binding.manageHiddenIconsList, binding.manageHiddenIconsToolbar)
val layoutManager = binding.manageHiddenIconsList.layoutManager as MyGridLayoutManager val layoutManager = binding.manageHiddenIconsList.layoutManager as MyGridLayoutManager

View file

@ -47,10 +47,12 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
currentCoords.y = event.rawY currentCoords.y = event.rawY
actionDownMS = System.currentTimeMillis() actionDownMS = System.currentTimeMillis()
} }
MotionEvent.ACTION_MOVE -> { MotionEvent.ACTION_MOVE -> {
currentCoords.x = event.rawX currentCoords.x = event.rawX
currentCoords.y = event.rawY currentCoords.y = event.rawY
} }
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
longPressHandler.removeCallbacksAndMessages(null) longPressHandler.removeCallbacksAndMessages(null)
} }

View file

@ -123,6 +123,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
dragDirection = DRAGGING_BOTTOM dragDirection = DRAGGING_BOTTOM
} }
} }
MotionEvent.ACTION_MOVE -> { MotionEvent.ACTION_MOVE -> {
val minWidth = minResizeWidthCells * cellWidth val minWidth = minResizeWidthCells * cellWidth
val minHeight = minResizeHeightCells * cellHeight val minHeight = minResizeHeightCells * cellHeight
@ -153,6 +154,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.left = wantedLeft frameRect.left = wantedLeft
} }
DRAGGING_TOP -> { DRAGGING_TOP -> {
val newHeight = frameRect.bottom - event.rawY.toInt() val newHeight = frameRect.bottom - event.rawY.toInt()
val wantedTop = if (newHeight >= minHeight) { val wantedTop = if (newHeight >= minHeight) {
@ -179,6 +181,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.top = wantedTop frameRect.top = wantedTop
} }
DRAGGING_RIGHT -> { DRAGGING_RIGHT -> {
val newWidth = event.rawX.toInt() - frameRect.left val newWidth = event.rawX.toInt() - frameRect.left
val wantedRight = if (newWidth >= minWidth) { val wantedRight = if (newWidth >= minWidth) {
@ -205,6 +208,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.right = wantedRight frameRect.right = wantedRight
} }
DRAGGING_BOTTOM -> { DRAGGING_BOTTOM -> {
val newHeight = event.rawY.toInt() - frameRect.top val newHeight = event.rawY.toInt() - frameRect.top
val wantedBottom = if (newHeight >= minHeight) { val wantedBottom = if (newHeight >= minHeight) {
@ -241,6 +245,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
redrawFrame() redrawFrame()
} }
} }
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> { MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
if (dragDirection == DRAGGING_NONE) { if (dragDirection == DRAGGING_NONE) {
onClickListener?.invoke() onClickListener?.invoke()
@ -269,6 +274,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.left = cellsRect.left * cellWidth + sideMargins.left frameRect.left = cellsRect.left * cellWidth + sideMargins.left
} }
} }
DRAGGING_TOP -> { DRAGGING_TOP -> {
val wantedTop = roundToClosestMultiplyOfNumber(frameRect.top - sideMargins.top, cellHeight) val wantedTop = roundToClosestMultiplyOfNumber(frameRect.top - sideMargins.top, cellHeight)
val wantedTopCellY = wantedTop / cellHeight val wantedTopCellY = wantedTop / cellHeight
@ -289,6 +295,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.top = cellsRect.top * cellHeight + sideMargins.top frameRect.top = cellsRect.top * cellHeight + sideMargins.top
} }
} }
DRAGGING_RIGHT -> { DRAGGING_RIGHT -> {
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
@ -309,6 +316,7 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
frameRect.right = (cellsRect.right + 1) * cellWidth + sideMargins.left frameRect.right = (cellsRect.right + 1) * cellWidth + sideMargins.left
} }
} }
DRAGGING_BOTTOM -> { DRAGGING_BOTTOM -> {
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