Open the search when typing on a physical keyboard
Some checks failed
Trigger F-Droid repository rebuild / trigger (release) Has been cancelled
Some checks failed
Trigger F-Droid repository rebuild / trigger (release) Has been cancelled
Typing on a physical keyboard while the home screen is shown now opens the search page and inserts the typed character, so the launcher can be used without touching the screen. It works for any printable key, appends the characters in order even when the user types faster than the launcher can recompose, and the search bar can still be tapped to edit the query with the on-screen keyboard as usual. While the search is driven by the keyboard, the search bar's text field is left unfocused on purpose: a focused text field would make the system show the on-screen keyboard, which is not wanted when there is a physical keyboard. The handler therefore inserts and deletes characters itself, including backspace and enter (to launch the best match). The behaviour is controlled by a new "Search on typing" preference in Settings -> Search, which is enabled by default. Implementation notes: - The key events are intercepted in SharedLauncherActivity.dispatchKeyEvent, which is the only place that sees hardware key events while no view has focus. The scaffold installs the handler while it is shown. - Key events are not forwarded to the search bar's text field, so the characters are inserted into the search view model directly. - SearchBar keeps a TextFieldValue instead of a String so that the cursor moves to the end of the text when the value is changed from the outside. Without this the next typed character ended up in front of the text.
This commit is contained in:
@@ -425,6 +425,8 @@
|
||||
<string name="no_account_nextcloud">Du har ikke tilknyttet en Nextcloud-konto endnu</string>
|
||||
<string name="preference_screen_buildinfo_summary">Flere oplysninger om denne udgave af denne app</string>
|
||||
<string name="preference_search_bar_launch_on_enter_summary">Start fremhævet match eller hurtig handling, når du trykker gå</string>
|
||||
<string name="preference_search_bar_search_on_typing">Søg ved indtastning</string>
|
||||
<string name="preference_search_bar_search_on_typing_summary">Åbn søgningen og begynd at skrive, når du trykker på et fysisk tastatur</string>
|
||||
<string name="search_action_message">Send besked</string>
|
||||
<string name="apps_profile_work">Arbejde</string>
|
||||
<plurals name="calendar_widget_running_events">
|
||||
|
||||
@@ -675,6 +675,8 @@
|
||||
<string name="preference_search_bar_auto_focus_summary">Automatically show the keyboard when opening the app drawer</string>
|
||||
<string name="preference_search_bar_launch_on_enter">Launch on enter</string>
|
||||
<string name="preference_search_bar_launch_on_enter_summary">Launch highlighted match or quick action upon tapping go</string>
|
||||
<string name="preference_search_bar_search_on_typing">Search on typing</string>
|
||||
<string name="preference_search_bar_search_on_typing_summary">Open the search and start typing when you press a key on a physical keyboard</string>
|
||||
<string name="preference_hidden_items">Excluded search results</string>
|
||||
<string name="preference_hidden_items_summary">Manage excluded apps and search results</string>
|
||||
<string name="preference_hidden_items_reveal_button">Show reveal button</string>
|
||||
|
||||
@@ -116,6 +116,11 @@ data class LauncherSettingsData internal constructor(
|
||||
val searchBarColors: SearchBarColors = SearchBarColors.Auto,
|
||||
val searchBarKeyboard: Boolean = true,
|
||||
val searchLaunchOnEnter: Boolean = true,
|
||||
/**
|
||||
* Open the search and start typing when a printable key is pressed on a physical keyboard
|
||||
* while the home screen is shown.
|
||||
*/
|
||||
val searchOnTyping: Boolean = true,
|
||||
val searchBarBottom: Boolean = false,
|
||||
val searchBarFixed: Boolean = false,
|
||||
|
||||
|
||||
@@ -52,6 +52,18 @@ class SearchUiSettings internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether typing on a physical keyboard while the home screen is shown opens the search.
|
||||
*/
|
||||
val searchOnTyping
|
||||
get() = launcherDataStore.data.map { it.searchOnTyping }.distinctUntilChanged()
|
||||
|
||||
fun setSearchOnTyping(searchOnTyping: Boolean) {
|
||||
launcherDataStore.update {
|
||||
it.copy(searchOnTyping = searchOnTyping)
|
||||
}
|
||||
}
|
||||
|
||||
val reversedResults
|
||||
get() = launcherDataStore.data.map { it.searchResultsReversed }.distinctUntilChanged()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user