From d8489bc4aa0842eccce53d6ff55be542f635794d Mon Sep 17 00:00:00 2001 From: Craig Russell Date: Thu, 25 Jan 2018 13:40:26 +0000 Subject: [PATCH] Skip home screen if launched as an assist intent --- .../java/com/duckduckgo/app/home/HomeActivity.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/duckduckgo/app/home/HomeActivity.kt b/app/src/main/java/com/duckduckgo/app/home/HomeActivity.kt index a24b3a343053..0f307d99276f 100644 --- a/app/src/main/java/com/duckduckgo/app/home/HomeActivity.kt +++ b/app/src/main/java/com/duckduckgo/app/home/HomeActivity.kt @@ -55,7 +55,7 @@ class HomeActivity : DuckDuckGoActivity() { searchInputBox.setOnClickListener { showSearchActivity() } if (savedInstanceState == null) { - consumeSharedQuery(intent) + consumeIntentAction(intent) } } @@ -76,14 +76,14 @@ class HomeActivity : DuckDuckGoActivity() { override fun onNewIntent(intent: Intent?) { super.onNewIntent(intent) - consumeSharedQuery(intent) + consumeIntentAction(intent) } - private fun consumeSharedQuery(intent: Intent?) { + private fun consumeIntentAction(intent: Intent?) { if (intent == null) return - if (intent.hasExtra(KEY_SKIP_HOME)) { + if (shouldSkipHomeActivity(intent)) { startActivity(BrowserActivity.intent(this)) return } @@ -92,6 +92,10 @@ class HomeActivity : DuckDuckGoActivity() { startActivity(BrowserActivity.intent(this, query)) } + private fun shouldSkipHomeActivity(intent: Intent) : Boolean { + return intent.hasExtra(KEY_SKIP_HOME) || intent.action == Intent.ACTION_ASSIST + } + private fun showSearchActivity() { val intent = BrowserActivity.intent(this) val options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, searchInputBox, getString(R.string.transition_url_input))