From 8f2878a841223357d42fa3a97a6fda95a579ce95 Mon Sep 17 00:00:00 2001
From: Amine A <15179425+AmineI@users.noreply.github.com>
Date: Wed, 3 Apr 2019 10:25:52 +0200
Subject: [PATCH] Added search intent handler and Google Search Action, for the
global search (#1787)
* Added search intent handler
* Added support for Google Search actions
---
app/src/main/AndroidManifest.xml | 7 ++++++-
.../java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 12 ++++++++++++
app/src/main/res/xml/searchable.xml | 5 +++++
3 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 app/src/main/res/xml/searchable.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ac0eb94e3..3e5f35a9b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -28,7 +28,12 @@
-
+
+
+
+
+
+
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
index d96b222c2..63d07429b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.main
import android.animation.ObjectAnimator
+import android.app.SearchManager
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
@@ -15,6 +16,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
import eu.kanade.tachiyomi.ui.base.controller.*
import eu.kanade.tachiyomi.ui.catalogue.CatalogueController
+import eu.kanade.tachiyomi.ui.catalogue.global_search.CatalogueSearchController
import eu.kanade.tachiyomi.ui.download.DownloadController
import eu.kanade.tachiyomi.ui.extension.ExtensionController
import eu.kanade.tachiyomi.ui.library.LibraryController
@@ -158,6 +160,16 @@ class MainActivity : BaseActivity() {
setSelectedDrawerItem(R.id.nav_drawer_downloads)
}
}
+ Intent.ACTION_SEARCH, "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)
+
+ setSelectedDrawerItem(R.id.nav_drawer_catalogues)
+ //Get the search query provided in extras, and if not null, perform a global search with it.
+ intent.getStringExtra(SearchManager.QUERY)?.also { query ->
+ router.pushController(CatalogueSearchController(query).withFadeTransaction())
+ }
+ }
else -> return false
}
return true
diff --git a/app/src/main/res/xml/searchable.xml b/app/src/main/res/xml/searchable.xml
new file mode 100644
index 000000000..f224a1c83
--- /dev/null
+++ b/app/src/main/res/xml/searchable.xml
@@ -0,0 +1,5 @@
+
+
+
\ No newline at end of file