Skip to content

Commit 8bfc94e

Browse files
Grisha Kruglovgrigoryk
Grisha Kruglov
authored andcommitted
Update sample browser to use HistoryTrackingFeature with an in-memory storage
1 parent 1fc50a7 commit 8bfc94e

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

samples/browser/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ dependencies {
109109
implementation project(':concept-engine')
110110
implementation project(':concept-tabstray')
111111
implementation project(':concept-toolbar')
112+
implementation project(':concept-storage')
112113

113114
implementation project(':browser-engine-system')
114115

@@ -117,10 +118,12 @@ dependencies {
117118
implementation project(':browser-tabstray')
118119
implementation project(':browser-toolbar')
119120
implementation project(':browser-menu')
121+
implementation project(':browser-storage-memory')
120122

121123
implementation project(':feature-intent')
122124
implementation project(':feature-search')
123125
implementation project(':feature-session')
126+
implementation project(':feature-storage')
124127
implementation project(':feature-toolbar')
125128
implementation project(':feature-tabs')
126129

samples/browser/src/main/java/org/mozilla/samples/browser/BrowserFragment.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import kotlinx.android.synthetic.main.fragment_browser.*
1515
import mozilla.components.feature.downloads.DownloadsFeature
1616
import mozilla.components.feature.downloads.SimpleDownloadDialogFragment.DownloadDialogListener
1717
import mozilla.components.feature.session.SessionFeature
18+
import mozilla.components.feature.storage.HistoryTrackingFeature
1819
import mozilla.components.feature.tabs.toolbar.TabsToolbarFeature
1920
import mozilla.components.feature.toolbar.ToolbarFeature
2021
import mozilla.components.support.ktx.android.content.isPermissionGranted
@@ -25,6 +26,7 @@ class BrowserFragment : Fragment(), BackHandler, DownloadDialogListener {
2526
private lateinit var toolbarFeature: ToolbarFeature
2627
private lateinit var tabsToolbarFeature: TabsToolbarFeature
2728
private lateinit var downloadsFeature: DownloadsFeature
29+
private lateinit var historyTrackingFeature: HistoryTrackingFeature
2830

2931
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
3032
return inflater.inflate(R.layout.fragment_browser, container, false)
@@ -37,6 +39,11 @@ class BrowserFragment : Fragment(), BackHandler, DownloadDialogListener {
3739

3840
val sessionId = arguments?.getString(SESSION_ID)
3941

42+
historyTrackingFeature = HistoryTrackingFeature(
43+
components.engine,
44+
components.historyStorage
45+
)
46+
4047
sessionFeature = SessionFeature(
4148
components.sessionManager,
4249
components.sessionUseCases,

samples/browser/src/main/java/org/mozilla/samples/browser/DefaultComponents.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import mozilla.components.browser.search.SearchEngineManager
1616
import mozilla.components.browser.session.Session
1717
import mozilla.components.browser.session.SessionManager
1818
import mozilla.components.browser.session.storage.DefaultSessionStorage
19+
import mozilla.components.browser.storage.memory.InMemoryHistoryStorage
1920
import mozilla.components.concept.engine.DefaultSettings
2021
import mozilla.components.concept.engine.Engine
2122
import mozilla.components.feature.intent.IntentProcessor
@@ -34,6 +35,9 @@ open class DefaultComponents(private val applicationContext: Context) {
3435
SystemEngine(applicationContext, settings)
3536
}
3637

38+
// Storage
39+
val historyStorage by lazy { InMemoryHistoryStorage() }
40+
3741
// Session
3842
val sessionStorage by lazy { DefaultSessionStorage(applicationContext) }
3943

0 commit comments

Comments
 (0)