From 7f787cef0803fcc23c20a3796d06043e7361d823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Fri, 28 Jul 2023 13:40:21 +0200 Subject: [PATCH] Fix anchor positioning on all apps fragment and home screen --- .../simplemobiletools/launcher/activities/MainActivity.kt | 8 ++++---- .../launcher/adapters/LaunchersAdapter.kt | 4 +++- .../simplemobiletools/launcher/views/HomeScreenGrid.kt | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt index ba0289f..25d1821 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -523,11 +523,11 @@ class MainActivity : SimpleActivity(), FlingListener { home_screen_grid.hideResizeLines() mLongPressedIcon = gridItem val anchorY = if (isOnAllAppsFragment || gridItem.type == ITEM_TYPE_WIDGET) { - y - } else if (gridItem.top == config.homeRowCount - 1) { - home_screen_grid.sideMargins.top + (gridItem.top * home_screen_grid.cellHeight.toFloat()) + val iconSize = realScreenSize.x / config.drawerColumnCount + y - iconSize / 2f } else { - (gridItem.top * home_screen_grid.cellHeight.toFloat()) + val clickableRect = home_screen_grid.getClickableRect(gridItem) + clickableRect.top.toFloat() - home_screen_grid.iconSize / 2f } home_screen_popup_menu_anchor.x = x diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/adapters/LaunchersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/adapters/LaunchersAdapter.kt index 9b5344d..908ec1e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/adapters/LaunchersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/adapters/LaunchersAdapter.kt @@ -120,7 +120,9 @@ class LaunchersAdapter( setOnClickListener { itemClick(launcher) } setOnLongClickListener { view -> - allAppsListener.onAppLauncherLongPressed(view.x + width / 2, view.y, launcher) + val location = IntArray(2) + getLocationOnScreen(location) + allAppsListener.onAppLauncherLongPressed((location[0] + width / 2).toFloat(), location[1].toFloat(), launcher) true } } diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt index dfda1d3..db7913d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -67,7 +67,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel private var resizedWidget: HomeScreenGridItem? = null private var isFirstDraw = true private var redrawWidgets = false - private var iconSize = 0 + var iconSize = 0 + private set private var lastPage = 0 private var currentPage = 0