From 06637968b6c84812832a6dd29af3a0bc27780d0e Mon Sep 17 00:00:00 2001 From: Christian Sadilek Date: Wed, 25 Jul 2018 14:51:46 -0400 Subject: [PATCH 1/3] Upgrade to components 0.16 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6eeb6ef51ae5..1b0961ce0594 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { // Testing junit: '4.12', // Mozilla - mozillaComponents: '0.15' + mozillaComponents: '0.16' ] // Synchronized versions numbers of GeckoView (Nightly) artifacts. From 80425d7a8022fa1480bdbc030fab9d138743378d Mon Sep 17 00:00:00 2001 From: Christian Sadilek Date: Wed, 25 Jul 2018 14:53:15 -0400 Subject: [PATCH 2/3] Upgrade to GeckoView Nightly (2018.07.24) and Beta (62.0b9) --- build.gradle | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 1b0961ce0594..9b1e22e7c98f 100644 --- a/build.gradle +++ b/build.gradle @@ -18,16 +18,16 @@ buildscript { // Synchronized versions numbers of GeckoView (Nightly) artifacts. ext.geckoNightly = [ // Discover nightly builds: https://tools.taskcluster.net/index/gecko.v2.mozilla-central.nightly - nightlyDate: '2018.07.04', - revision: 'cc3401e78e8bbae22e6dbc854e525ceae4923bcf', - version: '63.0.20180704100138' + nightlyDate: '2018.07.24', + revision: '1e5fa52a612e8985e12212d1950a732954e00e45', + version: '63.0.20180724100046' ] // Synchronized versions numbers of GeckoView (Beta) artifacts. ext.geckoBeta = [ // (62.0b5) - revision: '801112336847960bbb9a018695cf09ea437dc137', - version: '62.0.20180702164905' + revision: 'd7ab2f3df0840cdb8557659afd46f61afa310379', + version: '62.0.20180713213322' ] ext.geckoRelease = [ From 752f6940c4a4c29ca5428592eecd528f8e57221c Mon Sep 17 00:00:00 2001 From: Christian Sadilek Date: Wed, 25 Jul 2018 14:59:31 -0400 Subject: [PATCH 3/3] Closes #47: Add IntentProcessor and Custom Tabs support --- app/src/main/AndroidManifest.xml | 33 ++++++++++++++++++- .../{MainActivity.kt => BrowserActivity.kt} | 7 ++-- .../java/mozilla/fenix/CustomTabActivity.kt | 3 ++ .../mozilla/fenix/IntentReceiverActivity.kt | 28 ++++++++++++++++ .../mozilla/fenix/components/Components.kt | 2 ++ app/src/main/res/layout/fragment_browser.xml | 2 +- 6 files changed, 71 insertions(+), 4 deletions(-) rename app/src/main/java/mozilla/fenix/{MainActivity.kt => BrowserActivity.kt} (82%) create mode 100644 app/src/main/java/mozilla/fenix/CustomTabActivity.kt create mode 100644 app/src/main/java/mozilla/fenix/IntentReceiverActivity.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index aeb23c5a1429..56833ffda7ab 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> @@ -16,7 +17,9 @@ android:supportsRtl="true" android:theme="@style/AppTheme" android:name=".FenixApplication"> - + @@ -24,6 +27,34 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/mozilla/fenix/MainActivity.kt b/app/src/main/java/mozilla/fenix/BrowserActivity.kt similarity index 82% rename from app/src/main/java/mozilla/fenix/MainActivity.kt rename to app/src/main/java/mozilla/fenix/BrowserActivity.kt index 3d0da9bd6870..62deeab15ae6 100644 --- a/app/src/main/java/mozilla/fenix/MainActivity.kt +++ b/app/src/main/java/mozilla/fenix/BrowserActivity.kt @@ -12,18 +12,21 @@ import android.view.View import mozilla.components.browser.tabstray.BrowserTabsTray import mozilla.components.concept.engine.EngineView import mozilla.components.concept.tabstray.TabsTray +import mozilla.components.feature.session.SessionIntentProcessor +import mozilla.components.support.utils.SafeIntent import mozilla.fenix.ext.components import mozilla.fenix.fragment.BackHandler import mozilla.fenix.fragment.BrowserFragment -class MainActivity : AppCompatActivity() { +open class BrowserActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) if (savedInstanceState == null) { + val sessionId = SafeIntent(intent).getStringExtra(SessionIntentProcessor.ACTIVE_SESSION_ID) supportFragmentManager?.beginTransaction()?.apply { - replace(R.id.container, BrowserFragment.create()) + replace(R.id.container, BrowserFragment.create(sessionId)) commit() } } diff --git a/app/src/main/java/mozilla/fenix/CustomTabActivity.kt b/app/src/main/java/mozilla/fenix/CustomTabActivity.kt new file mode 100644 index 000000000000..05332ea9c67d --- /dev/null +++ b/app/src/main/java/mozilla/fenix/CustomTabActivity.kt @@ -0,0 +1,3 @@ +package mozilla.fenix + +class CustomTabActivity : BrowserActivity() \ No newline at end of file diff --git a/app/src/main/java/mozilla/fenix/IntentReceiverActivity.kt b/app/src/main/java/mozilla/fenix/IntentReceiverActivity.kt new file mode 100644 index 000000000000..ea856bfdaa7d --- /dev/null +++ b/app/src/main/java/mozilla/fenix/IntentReceiverActivity.kt @@ -0,0 +1,28 @@ +package mozilla.fenix + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import mozilla.components.browser.session.tab.CustomTabConfig +import mozilla.components.support.utils.SafeIntent +import mozilla.fenix.ext.components + +class IntentReceiverActivity : Activity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + components.sessionIntentProcessor.process(intent) + + val intent = Intent(intent) + if (CustomTabConfig.isCustomTabIntent(SafeIntent(intent))) { + intent.setClassName(applicationContext, CustomTabActivity::class.java.name) + } else { + intent.setClassName(applicationContext, BrowserActivity::class.java.name) + } + + startActivity(intent) + finish() + } + +} \ No newline at end of file diff --git a/app/src/main/java/mozilla/fenix/components/Components.kt b/app/src/main/java/mozilla/fenix/components/Components.kt index 9a819510f4e6..0a68aeb8141c 100644 --- a/app/src/main/java/mozilla/fenix/components/Components.kt +++ b/app/src/main/java/mozilla/fenix/components/Components.kt @@ -15,6 +15,7 @@ import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.storage.DefaultSessionStorage import mozilla.components.concept.engine.Engine import mozilla.components.feature.search.SearchUseCases +import mozilla.components.feature.session.SessionIntentProcessor import mozilla.components.feature.session.SessionUseCases import mozilla.components.feature.tabs.TabsUseCases import mozilla.fenix.R @@ -45,6 +46,7 @@ class Components(private val applicationContext: Context) { } val sessionUseCases = SessionUseCases(sessionManager) + val sessionIntentProcessor by lazy { SessionIntentProcessor(sessionUseCases, sessionManager) } // Search private val searchEngineManager by lazy { diff --git a/app/src/main/res/layout/fragment_browser.xml b/app/src/main/res/layout/fragment_browser.xml index 853ca226f5b8..fc7fefc6e55d 100644 --- a/app/src/main/res/layout/fragment_browser.xml +++ b/app/src/main/res/layout/fragment_browser.xml @@ -7,7 +7,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" - tools:context=".MainActivity"> + tools:context=".BrowserActivity">