hide the menu at long pressing an item and moving gesture

This commit is contained in:
tibbi
2022-09-22 21:22:32 +02:00
parent 5ccaf8ce43
commit 61801ebcb2
3 changed files with 32 additions and 28 deletions

View File

@ -4,13 +4,7 @@ import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import android.view.ContextThemeWrapper
import android.view.Gravity
import android.view.View
import android.widget.PopupMenu
import com.simplemobiletools.commons.extensions.getPopupMenuTheme
import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.launcher.R
import com.simplemobiletools.launcher.helpers.UNINSTALL_APP_REQUEST_CODE
fun Activity.launchApp(packageName: String) {
@ -35,18 +29,3 @@ fun Activity.uninstallApp(packageName: String) {
startActivityForResult(this, UNINSTALL_APP_REQUEST_CODE)
}
}
fun Activity.handleGridItemPopupMenu(anchorView: View, appPackageName: String): PopupMenu {
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
return PopupMenu(contextTheme, anchorView, Gravity.TOP or Gravity.END).apply {
inflate(R.menu.menu_app_icon)
setOnMenuItemClickListener { item ->
when (item.itemId) {
R.id.app_info -> launchAppInfo(appPackageName)
R.id.uninstall -> uninstallApp(appPackageName)
}
true
}
show()
}
}