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 bf25d2e..5d7e70a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/activities/MainActivity.kt @@ -233,8 +233,7 @@ class MainActivity : SimpleActivity(), FlingListener { main_holder.performHapticFeedback() val clickedGridItem = home_screen_grid.isClickingGridItem(getGridTouchedX(x), getGridTouchedY(y)) if (clickedGridItem != null) { - mLongPressedIcon = clickedGridItem - showHomeIconMenu(x, y - resources.getDimension(R.dimen.icon_long_press_anchor_offset_y), clickedGridItem.packageName) + showHomeIconMenu(x, y - resources.getDimension(R.dimen.icon_long_press_anchor_offset_y), clickedGridItem, false) return } @@ -254,10 +253,15 @@ class MainActivity : SimpleActivity(), FlingListener { private fun getGridTouchedY(y: Float) = Math.min(Math.max(y.toInt() - home_screen_grid.marginTop, 0), home_screen_grid.height).toInt() - fun showHomeIconMenu(x: Float, y: Float, clickedPackageName: String) { + fun showHomeIconMenu(x: Float, y: Float, gridItem: HomeScreenGridItem, isFromAllAppsFragment: Boolean) { + if (isFromAllAppsFragment) { + hideFragment(all_apps_fragment) + } + + mLongPressedIcon = gridItem home_screen_popup_menu_anchor.x = x home_screen_popup_menu_anchor.y = y - mOpenPopupMenu = handleGridItemPopupMenu(home_screen_popup_menu_anchor, clickedPackageName) + mOpenPopupMenu = handleGridItemPopupMenu(home_screen_popup_menu_anchor, gridItem.packageName) } private fun showMainLongPressMenu(x: Float, y: Float) { 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 bfb0f86..b858e78 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/adapters/LaunchersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/adapters/LaunchersAdapter.kt @@ -89,7 +89,7 @@ class LaunchersAdapter( setOnClickListener { itemClick(launcher) } setOnLongClickListener { view -> - allAppsListener.onIconLongPressed(view.x, view.y, launcher.packageName) + allAppsListener.onAppLauncherLongPressed(view.x, view.y, launcher) true } } diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt index 4a60b1e..ca94a1f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/fragments/AllAppsFragment.kt @@ -16,6 +16,7 @@ import com.simplemobiletools.launcher.extensions.getColumnCount import com.simplemobiletools.launcher.extensions.launchApp import com.simplemobiletools.launcher.interfaces.AllAppsListener import com.simplemobiletools.launcher.models.AppLauncher +import com.simplemobiletools.launcher.models.HomeScreenGridItem import kotlinx.android.synthetic.main.all_apps_fragment.view.* class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment(context, attributeSet), AllAppsListener { @@ -120,7 +121,8 @@ class AllAppsFragment(context: Context, attributeSet: AttributeSet) : MyFragment all_apps_fastscroller.setPadding(leftListPadding, 0, rightListPadding, 0) } - override fun onIconLongPressed(x: Float, y: Float, packageName: String) { - activity?.showHomeIconMenu(x, y, packageName) + override fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) { + val gridItem = HomeScreenGridItem(null, -1, -1, -1, 1, appLauncher.packageName, appLauncher.title) + activity?.showHomeIconMenu(x, y, gridItem, true) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/AllAppsListener.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/AllAppsListener.kt index b0ab92e..513b2ae 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/AllAppsListener.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/interfaces/AllAppsListener.kt @@ -1,5 +1,7 @@ package com.simplemobiletools.launcher.interfaces +import com.simplemobiletools.launcher.models.AppLauncher + interface AllAppsListener { - fun onIconLongPressed(x: Float, y: Float, packageName: String) + fun onAppLauncherLongPressed(x: Float, y: Float, appLauncher: AppLauncher) }