mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
feature: submitting search opens first app matching the query
This commit is contained in:
parent
62c6e1fc2f
commit
f792271a5a
3 changed files with 35 additions and 23 deletions
|
@ -40,9 +40,9 @@ import java.util.*
|
||||||
* @param forGesture - the action which an app is chosen for (when the intention is "pick")
|
* @param forGesture - the action which an app is chosen for (when the intention is "pick")
|
||||||
*/
|
*/
|
||||||
class AppsRecyclerAdapter(val activity: Activity,
|
class AppsRecyclerAdapter(val activity: Activity,
|
||||||
val intention: ListActivity.ListActivityIntention
|
private val intention: ListActivity.ListActivityIntention
|
||||||
= ListActivity.ListActivityIntention.VIEW,
|
= ListActivity.ListActivityIntention.VIEW,
|
||||||
val forGesture: String? = ""):
|
private val forGesture: String? = ""):
|
||||||
RecyclerView.Adapter<AppsRecyclerAdapter.ViewHolder>() {
|
RecyclerView.Adapter<AppsRecyclerAdapter.ViewHolder>() {
|
||||||
|
|
||||||
private val appsListDisplayed: MutableList<AppInfo>
|
private val appsListDisplayed: MutableList<AppInfo>
|
||||||
|
@ -53,24 +53,9 @@ class AppsRecyclerAdapter(val activity: Activity,
|
||||||
var img: ImageView = itemView.findViewById(R.id.list_apps_row_icon)
|
var img: ImageView = itemView.findViewById(R.id.list_apps_row_icon)
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
val pos = adapterPosition
|
var rect = Rect()
|
||||||
val appPackageName = appsListDisplayed[pos].packageName.toString()
|
|
||||||
val appUser = appsListDisplayed[pos].user
|
|
||||||
when (intention){
|
|
||||||
ListActivity.ListActivityIntention.VIEW -> {
|
|
||||||
val rect = Rect()
|
|
||||||
img.getGlobalVisibleRect(rect)
|
img.getGlobalVisibleRect(rect)
|
||||||
launchApp(appPackageName, appUser, activity, rect)
|
selectItem(adapterPosition, rect)
|
||||||
}
|
|
||||||
ListActivity.ListActivityIntention.PICK -> {
|
|
||||||
val returnIntent = Intent()
|
|
||||||
returnIntent.putExtra("value", appPackageName)
|
|
||||||
appUser?.let{ returnIntent.putExtra("user", it) }
|
|
||||||
returnIntent.putExtra("forGesture", forGesture)
|
|
||||||
activity.setResult(REQUEST_CHOOSE_APP, returnIntent)
|
|
||||||
activity.finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init { itemView.setOnClickListener(this) }
|
init { itemView.setOnClickListener(this) }
|
||||||
|
@ -152,6 +137,27 @@ class AppsRecyclerAdapter(val activity: Activity,
|
||||||
appsListDisplayed.addAll(appsList)
|
appsListDisplayed.addAll(appsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun selectItem(pos: Int, rect: Rect = Rect()) {
|
||||||
|
if(pos >= appsListDisplayed.size) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val appPackageName = appsListDisplayed[pos].packageName.toString()
|
||||||
|
val appUser = appsListDisplayed[pos].user
|
||||||
|
when (intention){
|
||||||
|
ListActivity.ListActivityIntention.VIEW -> {
|
||||||
|
launchApp(appPackageName, appUser, activity, rect)
|
||||||
|
}
|
||||||
|
ListActivity.ListActivityIntention.PICK -> {
|
||||||
|
val returnIntent = Intent()
|
||||||
|
returnIntent.putExtra("value", appPackageName)
|
||||||
|
appUser?.let{ returnIntent.putExtra("user", it) }
|
||||||
|
returnIntent.putExtra("forGesture", forGesture)
|
||||||
|
activity.setResult(REQUEST_CHOOSE_APP, returnIntent)
|
||||||
|
activity.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The function [filter] is used to search elements within this [RecyclerView].
|
* The function [filter] is used to search elements within this [RecyclerView].
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -44,7 +44,7 @@ class ListFragmentApps : Fragment(), UIObject {
|
||||||
|
|
||||||
override fun adjustLayout() {
|
override fun adjustLayout() {
|
||||||
|
|
||||||
val appsRViewAdapter = AppsRecyclerAdapter(activity!!, intention, forGesture)
|
val appsRViewAdapter = AppsRecyclerAdapter(requireActivity(), intention, forGesture)
|
||||||
|
|
||||||
// set up the list / recycler
|
// set up the list / recycler
|
||||||
binding.listAppsRview.apply {
|
binding.listAppsRview.apply {
|
||||||
|
@ -59,7 +59,8 @@ class ListFragmentApps : Fragment(), UIObject {
|
||||||
|
|
||||||
override fun onQueryTextSubmit(query: String): Boolean {
|
override fun onQueryTextSubmit(query: String): Boolean {
|
||||||
appsRViewAdapter.filter(query)
|
appsRViewAdapter.filter(query)
|
||||||
return false
|
appsRViewAdapter.selectItem(0)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueryTextChange(newText: String): Boolean {
|
override fun onQueryTextChange(newText: String): Boolean {
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
- Chinese translation (thank you, yzqzss!)
|
- Chinese translation (thank you, yzqzss!)
|
||||||
|
|
||||||
|
All Apps:
|
||||||
|
- Removed three dots in app list (use long click instead)
|
||||||
|
- Pressing enter opens the first app matching the query
|
||||||
- Fixed workaround for bug when opening keyboard in full screen mode
|
- Fixed workaround for bug when opening keyboard in full screen mode
|
||||||
- Removed uninstall option for system apps
|
- Removed uninstall option for system apps
|
||||||
- Removed three dots in app list (use long click instead)
|
|
||||||
|
Settings:
|
||||||
- Fixed settings for small displays
|
- Fixed settings for small displays
|
||||||
|
|
Loading…
Add table
Reference in a new issue