mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
allow to prefix query with space to disable auto launch
This commit is contained in:
parent
92772d715c
commit
ce5fade39a
4 changed files with 30 additions and 9 deletions
|
@ -49,6 +49,9 @@ class AppsRecyclerAdapter(
|
||||||
private val apps = (activity.applicationContext as Application).apps
|
private val apps = (activity.applicationContext as Application).apps
|
||||||
private val appsListDisplayed: MutableList<DetailedAppInfo> = mutableListOf()
|
private val appsListDisplayed: MutableList<DetailedAppInfo> = mutableListOf()
|
||||||
|
|
||||||
|
// temporarily disable auto launch
|
||||||
|
var disableAutoLaunch: Boolean = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
apps.observe(this.activity as AppCompatActivity) {
|
apps.observe(this.activity as AppCompatActivity) {
|
||||||
updateAppsList()
|
updateAppsList()
|
||||||
|
@ -205,6 +208,7 @@ class AppsRecyclerAdapter(
|
||||||
if (triggerAutoLaunch &&
|
if (triggerAutoLaunch &&
|
||||||
appsListDisplayed.size == 1
|
appsListDisplayed.size == 1
|
||||||
&& intention == ListActivity.ListActivityIntention.VIEW
|
&& intention == ListActivity.ListActivityIntention.VIEW
|
||||||
|
&& !disableAutoLaunch
|
||||||
&& LauncherPreferences.functionality().searchAutoLaunch()
|
&& LauncherPreferences.functionality().searchAutoLaunch()
|
||||||
) {
|
) {
|
||||||
val info = appsListDisplayed[0]
|
val info = appsListDisplayed[0]
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import de.jrpie.android.launcher.R
|
||||||
import de.jrpie.android.launcher.apps.AppFilter
|
import de.jrpie.android.launcher.apps.AppFilter
|
||||||
import de.jrpie.android.launcher.databinding.ListAppsBinding
|
import de.jrpie.android.launcher.databinding.ListAppsBinding
|
||||||
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
import de.jrpie.android.launcher.preferences.LauncherPreferences
|
||||||
|
@ -26,11 +27,11 @@ import de.jrpie.android.launcher.ui.openSoftKeyboard
|
||||||
*/
|
*/
|
||||||
class ListFragmentApps : Fragment(), UIObject {
|
class ListFragmentApps : Fragment(), UIObject {
|
||||||
private lateinit var binding: ListAppsBinding
|
private lateinit var binding: ListAppsBinding
|
||||||
private lateinit var appsRViewAdapter: AppsRecyclerAdapter
|
private lateinit var appsRecyclerAdapter: AppsRecyclerAdapter
|
||||||
|
|
||||||
private var sharedPreferencesListener =
|
private var sharedPreferencesListener =
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
|
SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
|
||||||
appsRViewAdapter.updateAppsList()
|
appsRecyclerAdapter.updateAppsList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
@ -62,7 +63,7 @@ class ListFragmentApps : Fragment(), UIObject {
|
||||||
|
|
||||||
override fun adjustLayout() {
|
override fun adjustLayout() {
|
||||||
|
|
||||||
appsRViewAdapter =
|
appsRecyclerAdapter =
|
||||||
AppsRecyclerAdapter(
|
AppsRecyclerAdapter(
|
||||||
requireActivity(), binding.root, intention, forGesture,
|
requireActivity(), binding.root, intention, forGesture,
|
||||||
appFilter = AppFilter(
|
appFilter = AppFilter(
|
||||||
|
@ -79,26 +80,40 @@ class ListFragmentApps : Fragment(), UIObject {
|
||||||
// improve performance (since content changes don't change the layout size)
|
// improve performance (since content changes don't change the layout size)
|
||||||
setHasFixedSize(true)
|
setHasFixedSize(true)
|
||||||
layoutManager = LauncherPreferences.list().layout().layoutManager(context)
|
layoutManager = LauncherPreferences.list().layout().layoutManager(context)
|
||||||
adapter = appsRViewAdapter
|
adapter = appsRecyclerAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.listAppsSearchview.setOnQueryTextListener(object :
|
binding.listAppsSearchview.setOnQueryTextListener(object :
|
||||||
androidx.appcompat.widget.SearchView.OnQueryTextListener {
|
androidx.appcompat.widget.SearchView.OnQueryTextListener {
|
||||||
|
|
||||||
override fun onQueryTextSubmit(query: String): Boolean {
|
override fun onQueryTextSubmit(query: String): Boolean {
|
||||||
appsRViewAdapter.setSearchString(query)
|
appsRecyclerAdapter.setSearchString(query)
|
||||||
|
|
||||||
if (LauncherPreferences.functionality().searchWeb()) {
|
if (LauncherPreferences.functionality().searchWeb()) {
|
||||||
val i = Intent(Intent.ACTION_WEB_SEARCH).putExtra("query", query)
|
val i = Intent(Intent.ACTION_WEB_SEARCH).putExtra("query", query)
|
||||||
activity?.startActivity(i)
|
activity?.startActivity(i)
|
||||||
} else {
|
} else {
|
||||||
appsRViewAdapter.selectItem(0)
|
appsRecyclerAdapter.selectItem(0)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueryTextChange(newText: String): Boolean {
|
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
|
return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -110,7 +125,7 @@ class ListFragmentApps : Fragment(), UIObject {
|
||||||
} else {
|
} else {
|
||||||
AppFilter.Companion.AppSetVisibility.VISIBLE
|
AppFilter.Companion.AppSetVisibility.VISIBLE
|
||||||
}
|
}
|
||||||
appsRViewAdapter.setFavoritesVisibility(favoritesVisibility)
|
appsRecyclerAdapter.setFavoritesVisibility(favoritesVisibility)
|
||||||
(activity as? ListActivity)?.updateTitle()
|
(activity as? ListActivity)?.updateTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,8 @@
|
||||||
<string name="list_removed">Removed the selected application</string>
|
<string name="list_removed">Removed the selected application</string>
|
||||||
<string name="list_not_removed">Unable to remove 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_settings">µLauncher Settings</string>
|
||||||
<string name="list_other_list">All Applications</string>
|
<string name="list_other_list">All Applications</string>
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
* prefix search query with space to temporarily disable auto launch
|
||||||
* improved French translation (thank you, Alexandre Ancel and Nin Dan!)
|
* improved French translation (thank you, Alexandre Ancel and Nin Dan!)
|
||||||
|
|
Loading…
Add table
Reference in a new issue