Show app options menu on long click

As many people interact in this way with a list. Does not change the 
normal interaction with the apps list.
This commit is contained in:
Finn M Glas 2020-06-09 18:56:50 +02:00
parent d36daa6006
commit 1e79993563
No known key found for this signature in database
GPG key ID: 902A30146014DFBF

View file

@ -62,7 +62,22 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp
if (getSavedTheme(activity) == "dark") transformGrayscale(viewHolder.img)
viewHolder.menuDots.setOnClickListener{ //creating a popup menu
// decide when to show the options popup menu about
if (isSystemApp || action == "pick") {
viewHolder.menuDots.visibility = View.INVISIBLE
}
else {
viewHolder.menuDots.visibility = View.VISIBLE
viewHolder.menuDots.setOnClickListener{ showOptionsPopup(viewHolder, appPackageName) }
viewHolder.menuDots.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName) }
viewHolder.textView.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName) }
viewHolder.img.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName) }
}
}
private fun showOptionsPopup(viewHolder: ViewHolder, appPackageName: String): Boolean {
//create the popup menu
val popup = PopupMenu(activity, viewHolder.menuDots)
popup.inflate(R.menu.menu_app)
@ -88,9 +103,7 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp
}
popup.show()
}
viewHolder.menuDots.visibility = if(isSystemApp || action == "pick") View.INVISIBLE else View.VISIBLE
return true
}
override fun getItemCount(): Int { return appsList.size }