mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
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:
parent
d36daa6006
commit
1e79993563
1 changed files with 36 additions and 23 deletions
|
@ -62,7 +62,22 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp
|
||||||
|
|
||||||
if (getSavedTheme(activity) == "dark") transformGrayscale(viewHolder.img)
|
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)
|
val popup = PopupMenu(activity, viewHolder.menuDots)
|
||||||
popup.inflate(R.menu.menu_app)
|
popup.inflate(R.menu.menu_app)
|
||||||
|
@ -88,9 +103,7 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp
|
||||||
}
|
}
|
||||||
|
|
||||||
popup.show()
|
popup.show()
|
||||||
}
|
return true
|
||||||
|
|
||||||
viewHolder.menuDots.visibility = if(isSystemApp || action == "pick") View.INVISIBLE else View.VISIBLE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int { return appsList.size }
|
override fun getItemCount(): Int { return appsList.size }
|
||||||
|
|
Loading…
Add table
Reference in a new issue