allow to prefix query with space to disable auto launch

This commit is contained in:
Josia Pietsch 2025-01-09 01:08:01 +01:00
parent 92772d715c
commit ce5fade39a
Signed by: jrpie
GPG key ID: E70B571D66986A2D
4 changed files with 30 additions and 9 deletions

View file

@ -49,6 +49,9 @@ class AppsRecyclerAdapter(
private val apps = (activity.applicationContext as Application).apps
private val appsListDisplayed: MutableList<DetailedAppInfo> = mutableListOf()
// temporarily disable auto launch
var disableAutoLaunch: Boolean = false
init {
apps.observe(this.activity as AppCompatActivity) {
updateAppsList()
@ -205,6 +208,7 @@ class AppsRecyclerAdapter(
if (triggerAutoLaunch &&
appsListDisplayed.size == 1
&& intention == ListActivity.ListActivityIntention.VIEW
&& !disableAutoLaunch
&& LauncherPreferences.functionality().searchAutoLaunch()
) {
val info = appsListDisplayed[0]

View file

@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.apps.AppFilter
import de.jrpie.android.launcher.databinding.ListAppsBinding
import de.jrpie.android.launcher.preferences.LauncherPreferences
@ -26,11 +27,11 @@ import de.jrpie.android.launcher.ui.openSoftKeyboard
*/
class ListFragmentApps : Fragment(), UIObject {
private lateinit var binding: ListAppsBinding
private lateinit var appsRViewAdapter: AppsRecyclerAdapter
private lateinit var appsRecyclerAdapter: AppsRecyclerAdapter
private var sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
appsRViewAdapter.updateAppsList()
appsRecyclerAdapter.updateAppsList()
}
override fun onCreateView(
@ -62,7 +63,7 @@ class ListFragmentApps : Fragment(), UIObject {
override fun adjustLayout() {
appsRViewAdapter =
appsRecyclerAdapter =
AppsRecyclerAdapter(
requireActivity(), binding.root, intention, forGesture,
appFilter = AppFilter(
@ -79,26 +80,40 @@ class ListFragmentApps : Fragment(), UIObject {
// improve performance (since content changes don't change the layout size)
setHasFixedSize(true)
layoutManager = LauncherPreferences.list().layout().layoutManager(context)
adapter = appsRViewAdapter
adapter = appsRecyclerAdapter
}
binding.listAppsSearchview.setOnQueryTextListener(object :
androidx.appcompat.widget.SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
appsRViewAdapter.setSearchString(query)
appsRecyclerAdapter.setSearchString(query)
if (LauncherPreferences.functionality().searchWeb()) {
val i = Intent(Intent.ACTION_WEB_SEARCH).putExtra("query", query)
activity?.startActivity(i)
} else {
appsRViewAdapter.selectItem(0)
appsRecyclerAdapter.selectItem(0)
}
return true
}
override fun onQueryTextChange(newText: String): Boolean {
appsRViewAdapter.setSearchString(newText)
if (newText == " " &&
!appsRecyclerAdapter.disableAutoLaunch &&
intention == ListActivity.ListActivityIntention.VIEW &&
LauncherPreferences.functionality().searchAutoLaunch()
) {
appsRecyclerAdapter.disableAutoLaunch = true
binding.listAppsSearchview.apply {
queryHint = context.getString(R.string.list_apps_search_hint_no_auto_launch)
setQuery("", false)
}
return false
}
appsRecyclerAdapter.setSearchString(newText)
return false
}
})
@ -110,7 +125,7 @@ class ListFragmentApps : Fragment(), UIObject {
} else {
AppFilter.Companion.AppSetVisibility.VISIBLE
}
appsRViewAdapter.setFavoritesVisibility(favoritesVisibility)
appsRecyclerAdapter.setFavoritesVisibility(favoritesVisibility)
(activity as? ListActivity)?.updateTitle()
}

View file

@ -201,7 +201,8 @@
<string name="list_removed">Removed the selected application</string>
<string name="list_not_removed">Unable to remove application</string>
<string name="list_apps_search_hint">Search Applications</string>
<string name="list_apps_search_hint">Search</string>
<string name="list_apps_search_hint_no_auto_launch">Search (auto launch disabled)</string>
<string name="list_other_settings">µLauncher Settings</string>
<string name="list_other_list">All Applications</string>

View file

@ -1 +1,2 @@
* prefix search query with space to temporarily disable auto launch
* improved French translation (thank you, Alexandre Ancel and Nin Dan!)