hide AllAppsFragment on long pressing an icon
This commit is contained in:
parent
9321db3cec
commit
5ccaf8ce43
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue