Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Upgrade to components, gv nightly and beta, plus intent processor #50

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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/. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="mozilla.fenix">

<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -16,14 +17,44 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name=".FenixApplication">
<activity android:name=".MainActivity">
<activity android:name=".BrowserActivity"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|locale|layoutDirection|smallestScreenSize|screenLayout">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".CustomTabActivity"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|locale|layoutDirection|smallestScreenSize|screenLayout"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
android:exported="false"
android:taskAffinity=""
android:persistableMode="persistNever"
android:autoRemoveFromRecents="false"
android:label="@string/app_name" />

<activity android:name=".IntentReceiverActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>

<service
android:name="mozilla.components.browser.session.tab.CustomTabsService"
android:exported="true"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="android.support.customtabs.action.CustomTabsService" />
</intent-filter>
</service>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/mozilla/fenix/CustomTabActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package mozilla.fenix

class CustomTabActivity : BrowserActivity()
28 changes: 28 additions & 0 deletions app/src/main/java/mozilla/fenix/IntentReceiverActivity.kt
Original file line number Diff line number Diff line change
@@ -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()
}

}
2 changes: 2 additions & 0 deletions app/src/main/java/mozilla/fenix/components/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_browser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
tools:context=".BrowserActivity">

<mozilla.components.browser.toolbar.BrowserToolbar
android:id="@+id/toolbar"
Expand Down
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ buildscript {
// Testing
junit: '4.12',
// Mozilla
mozillaComponents: '0.15'
mozillaComponents: '0.16'
]

// 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 = [
Expand Down