Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit fd511fb

Browse files
csadilekpocmo
authored andcommitted
[components] Closes mozilla-mobile/android-components#164: Add concept-session-storage module
1 parent e55ba1b commit fd511fb

File tree

11 files changed

+80
-3
lines changed

11 files changed

+80
-3
lines changed

android-components/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ _API contracts and abstraction layers for browser components._
4040

4141
* **Engine** - Abstraction layer that allows hiding the actual browser engine implementation.
4242

43+
* **Session-Storage** - Abstraction layer and contracts for hiding the actual session storage implementation.
44+
4345
* **Toolbar** - Abstract definition of a browser toolbar component.
4446

4547
## Feature
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
apply plugin: 'com.android.library'
6+
apply plugin: 'kotlin-android'
7+
8+
android {
9+
compileSdkVersion rootProject.ext.build['compileSdkVersion']
10+
11+
defaultConfig {
12+
minSdkVersion rootProject.ext.build['minSdkVersion']
13+
targetSdkVersion rootProject.ext.build['targetSdkVersion']
14+
}
15+
16+
lintOptions {
17+
warningsAsErrors true
18+
abortOnError true
19+
}
20+
21+
buildTypes {
22+
release {
23+
minifyEnabled false
24+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25+
}
26+
}
27+
}
28+
29+
dependencies {
30+
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.dependencies['kotlin']}"
31+
32+
implementation project(':concept-engine')
33+
implementation project(':browser-session')
34+
}
35+
36+
archivesBaseName = "session-storage"
37+
38+
apply from: '../../../publish.gradle'
39+
ext.configurePublish(
40+
'org.mozilla.components',
41+
'session-storage',
42+
'An abstract layer and contracts for hiding the actual session storage implementation.')
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- This Source Code Form is subject to the terms of the Mozilla Public
2+
- License, v. 2.0. If a copy of the MPL was not distributed with this
3+
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
4+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
5+
package="mozilla.components.concept.session.storage" />

android-components/components/feature/session/src/main/java/mozilla/components/feature/session/SessionStorage.kt renamed to android-components/components/concept/session-storage/src/main/java/mozilla/components/concept/session/storage/SessionStorage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
package mozilla.components.feature.session
5+
package mozilla.components.concept.session.storage
66

77
import mozilla.components.browser.session.Session
88
import mozilla.components.concept.engine.Engine

android-components/components/feature/session/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ android {
2929
dependencies {
3030
implementation project(':browser-session')
3131
implementation project(':concept-engine')
32+
implementation project(':concept-session-storage')
3233

3334
implementation "org.jetbrains.kotlin:kotlin-stdlib:${rootProject.ext.dependencies['kotlin']}"
3435

android-components/components/feature/session/src/main/java/mozilla/components/feature/session/DefaultSessionStorage.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.content.Context
88
import mozilla.components.browser.session.Session
99
import mozilla.components.concept.engine.Engine
1010
import mozilla.components.concept.engine.EngineSession
11+
import mozilla.components.concept.session.storage.SessionStorage
1112
import org.json.JSONException
1213
import org.json.JSONObject
1314
import java.io.FileNotFoundException

android-components/components/feature/session/src/main/java/mozilla/components/feature/session/SessionProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import mozilla.components.browser.session.Session
99
import mozilla.components.browser.session.SessionManager
1010
import mozilla.components.concept.engine.Engine
1111
import mozilla.components.concept.engine.EngineSession
12+
import mozilla.components.concept.session.storage.SessionStorage
1213
import java.util.concurrent.Executors
1314
import java.util.concurrent.ScheduledExecutorService
1415
import java.util.concurrent.TimeUnit
@@ -43,7 +44,7 @@ class SessionProvider(
4344

4445
if (savePeriodically) {
4546
scheduler.scheduleAtFixedRate(
46-
{ sessionStorage.persist(sessions, sessionManager.selectedSession?.id) },
47+
{ sessionStorage.persist(sessions, selectedSession.id) },
4748
saveIntervalInSeconds,
4849
saveIntervalInSeconds,
4950
TimeUnit.SECONDS)
@@ -70,7 +71,6 @@ class SessionProvider(
7071
* Stops this provider and periodic saves.
7172
*/
7273
fun stop() {
73-
sessions.clear()
7474
scheduler.shutdown()
7575
}
7676
}

android-components/components/feature/session/src/test/java/mozilla/components/feature/session/SessionProviderTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package mozilla.components.feature.session
77
import mozilla.components.browser.session.Session
88
import mozilla.components.concept.engine.Engine
99
import mozilla.components.concept.engine.EngineSession
10+
import mozilla.components.concept.session.storage.SessionStorage
1011
import org.junit.Assert.assertEquals
1112
import org.junit.Test
1213
import org.junit.runner.RunWith

android-components/samples/browser/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ android {
3030

3131
dependencies {
3232
implementation project(':concept-engine')
33+
implementation project(':concept-session-storage')
3334
implementation project(':concept-toolbar')
3435

3536
implementation project(':browser-engine-system')

android-components/settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ project(':concept-toolbar').projectDir = new File(rootDir, 'components/concept/t
1212
include ':concept-engine'
1313
project(':concept-engine').projectDir = new File(rootDir, 'components/concept/engine')
1414

15+
include ':concept-session-storage'
16+
project(':concept-session-storage').projectDir = new File(rootDir, 'components/concept/session-storage')
17+
1518
////////////////////////////////////////////////////////////////////////////////////////////////////
1619
// Features
1720
////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)