Add text selection shortcut to invoke global search (closes #4058)

This commit is contained in:
arkon 2020-12-08 22:48:04 -05:00
parent 59859e124f
commit b6e246c6b2
3 changed files with 12 additions and 3 deletions

View file

@ -42,7 +42,8 @@
<activity
android:name=".ui.main.DeepLinkActivity"
android:launchMode="singleTask"
android:theme="@android:style/Theme.NoDisplay">
android:theme="@android:style/Theme.NoDisplay"
android:label="@string/process_text_action_name">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
@ -53,6 +54,11 @@
<action android:name="eu.kanade.tachiyomi.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PROCESS_TEXT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<meta-data
android:name="android.app.searchable"

View file

@ -241,12 +241,12 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
setSelectedNavItem(R.id.nav_more)
router.pushController(RouterTransaction.with(DownloadController()))
}
Intent.ACTION_SEARCH, "com.google.android.gms.actions.SEARCH_ACTION" -> {
Intent.ACTION_SEARCH, Intent.ACTION_PROCESS_TEXT, "com.google.android.gms.actions.SEARCH_ACTION" -> {
// If the intent match the "standard" Android search intent
// or the Google-specific search intent (triggered by saying or typing "search *query* on *Tachiyomi*" in Google Search/Google Assistant)
// Get the search query provided in extras, and if not null, perform a global search with it.
val query = intent.getStringExtra(SearchManager.QUERY)
val query = intent.getStringExtra(SearchManager.QUERY) ?: intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT)?.toString()
if (query != null && query.isNotEmpty()) {
if (router.backstackSize > 1) {
router.popToRoot()

View file

@ -731,4 +731,7 @@
<string name="spen_previous_page">Previous page</string>
<string name="spen_next_page">Next page</string>
<!-- Android OS text selection menu action -->
<string name="process_text_action_name">Search in Tachiyomi</string>
</resources>