Skip to content

Commit 7a38090

Browse files
committed
Closes mozilla-mobile#1346: Add ReaderView feature component
1 parent 57f27d3 commit 7a38090

File tree

19 files changed

+17573
-1
lines changed

19 files changed

+17573
-1
lines changed

.buildconfig.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ projects:
5252
path: components/feature/intent
5353
description: 'Combining various feature components for intent processing.'
5454
publish: true
55+
feature-readerview:
56+
path: components/feature/readerview
57+
description: 'Feature implementation providing a Reader View WebExtension.'
58+
publish: true
5559
feature-search:
5660
path: components/feature/search
5761
description: 'Feature implementation connecting an engine implementation with the search module.'

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ _Combined components to implement feature-specific use cases._
118118

119119
* 🔴 [**Progressive Web Apps (PWA)**](components/feature/pwa/README.md) - A component that provides functionality for supporting Progressive Web Apps (PWA).
120120

121+
* 🔴 [**Reader View**](components/feature/readerview/README.md) - A component that provides Reader View functionality.
122+
121123
*[**QR**](components/feature/qr/README.md) - A component that provides functionality for scanning QR codes.
122124

123125
* 🔴 [**Search**](components/feature/search/README.md) - A component that connects an (concept) engine implementation with the browser search module.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# [Android Components](../../../README.md) > Feature > Reader View
2+
3+
A component wrapping/providing a Reader View WebExtension.
4+
5+
## Usage
6+
7+
### Setting up the dependency
8+
9+
Use Gradle to download the library from [maven.mozilla.org](https://maven.mozilla.org/) ([Setup repository](../../../README.md#maven-repository)):
10+
11+
```Groovy
12+
implementation "org.mozilla.components:feature-readerview:{latest-version}"
13+
```
14+
15+
### Integration
16+
17+
Initializing the feature:
18+
19+
```kotlin
20+
val readerViewFeature = ReaderViewFeature(
21+
context,
22+
engine,
23+
sessionManager,
24+
onReaderViewAvailableChange = {
25+
// e.g. readerViewToolbarActionVisible = it
26+
}
27+
)
28+
29+
```
30+
31+
Showing and hiding Reader View:
32+
33+
```kotlin
34+
readerViewFeature.showReaderView()
35+
readerViewFeature.hideReaderView()
36+
```
37+
38+
Showing and hiding the Reader View appearance UI (to adjust font size, font type and color scheme). Note that changes to the appearance settings are automatically persisted as user preferences.
39+
40+
```kotlin
41+
readerViewFeature.showAppearanceControls()
42+
readerViewFeature.hideAppearanceControls()
43+
```
44+
45+
## License
46+
47+
This Source Code Form is subject to the terms of the Mozilla Public
48+
License, v. 2.0. If a copy of the MPL was not distributed with this
49+
file, You can obtain one at http://mozilla.org/MPL/2.0/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 config.compileSdkVersion
10+
11+
defaultConfig {
12+
minSdkVersion config.minSdkVersion
13+
targetSdkVersion config.targetSdkVersion
14+
}
15+
16+
buildTypes {
17+
release {
18+
minifyEnabled false
19+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20+
}
21+
}
22+
}
23+
24+
dependencies {
25+
implementation project(':browser-menu')
26+
implementation project(':browser-session')
27+
implementation project(':concept-engine')
28+
implementation project(':support-base')
29+
implementation project(':support-ktx')
30+
implementation project(':support-utils')
31+
implementation project(':ui-icons')
32+
33+
implementation Dependencies.kotlin_stdlib
34+
implementation Dependencies.kotlin_coroutines
35+
36+
api Dependencies.support_customtabs
37+
38+
testImplementation project(':support-test')
39+
testImplementation Dependencies.androidx_test_core
40+
testImplementation Dependencies.testing_junit
41+
testImplementation Dependencies.testing_robolectric
42+
testImplementation Dependencies.testing_mockito
43+
}
44+
45+
apply from: '../../../publish.gradle'
46+
ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description)
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.feature.readerview" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "Mozilla Android Components - ReaderView",
4+
"version": "1.0",
5+
"content_scripts": [
6+
{
7+
"matches": ["*://*/*"],
8+
"js": ["readability/readability-0.2.0.js", "readability/readability-readerable-0.2.0.js", "moment/moment-2.24.0.js", "readerview.js"],
9+
"css": ["readerview.css"],
10+
"run_at": "document_end"
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)