react-native-readium 1.0.0-alpha.4 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,6 +16,11 @@ A react-native wrapper for https://readium.org/
16
16
 
17
17
  ## Installation
18
18
 
19
+ #### Prerequisites
20
+
21
+ 1. **iOS**: Requires an iOS target >= `13.0` (see the iOS section for more details).
22
+ 2. **Android**: Requires `compileSdkVersion` >= `31` (see the Android section for more details).
23
+
19
24
  #### Install Module
20
25
 
21
26
  **NPM**
@@ -32,17 +37,14 @@ yarn add react-native-readium
32
37
 
33
38
  #### iOS
34
39
 
35
- ###### Requirements
36
-
37
- This project requires an iOS target >= `13.0`.
38
-
39
- ###### Pod Install
40
-
41
40
  Due to the current state of the `Readium` swift libraries you need to manually
42
41
  update your `Podfile` ([see more on that here](https://github.com/readium/swift-toolkit/issues/38)).
43
42
 
44
43
  ```rb
45
44
  # ./ios/Podfile
45
+ ...
46
+ platform :ios, '13.0'
47
+
46
48
  ...
47
49
 
48
50
  target 'ExampleApp' do
@@ -61,6 +63,21 @@ Finally, install the pods:
61
63
 
62
64
  `pod install`
63
65
 
66
+ #### Android
67
+
68
+ If you're not using `compileSdkVersion` >= 31 you'll need to update that:
69
+
70
+ ```groovy
71
+ // android/build.gradle
72
+ ...
73
+ buildscript {
74
+ ...
75
+ ext {
76
+ ...
77
+ compileSdkVersion = 31
78
+ ...
79
+ ```
80
+
64
81
  ## Usage
65
82
 
66
83
  ```tsx
@@ -136,16 +136,20 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
136
136
 
137
137
  dependencies {
138
138
  // noinspection GradleDynamicVersion
139
- api 'com.facebook.react:react-native:+'
139
+ api "com.facebook.react:react-native:+"
140
140
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
141
141
 
142
142
  // readium deps
143
143
  implementation "com.github.readium.kotlin-toolkit:readium-shared:$readium_version"
144
144
  implementation "com.github.readium.kotlin-toolkit:readium-streamer:$readium_version"
145
- implementation "com.github.readium.kotlin-toolkit:readium-navigator:$readium_version"
145
+ implementation ("com.github.readium.kotlin-toolkit:readium-navigator:$readium_version") {
146
+ // this package doesn't provide audio playback, so remove exoplayer
147
+ // transitive deps to avoid potential collisions with other projects.
148
+ exclude group: "com.google.android.exoplayer"
149
+ }
146
150
 
147
151
  // other deps
148
- implementation 'androidx.core:core-ktx:1.6.0'
152
+ implementation "androidx.core:core-ktx:1.6.0"
149
153
  implementation "androidx.activity:activity-ktx:1.3.1"
150
154
  implementation "androidx.appcompat:appcompat:1.3.1"
151
155
  implementation "androidx.browser:browser:1.3.0"
@@ -178,15 +182,15 @@ dependencies {
178
182
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
179
183
  // AM NOTE: needs to stay this version for now (June 24,2020)
180
184
  //noinspection GradleDependency
181
- implementation 'org.jsoup:jsoup:1.13.1'
185
+ implementation "org.jsoup:jsoup:1.13.1"
182
186
 
183
187
  // Room database
184
- final room_version = '2.4.0-beta01'
188
+ final room_version = "2.4.0-beta01"
185
189
  implementation "androidx.room:room-runtime:$room_version"
186
190
  implementation "androidx.room:room-ktx:$room_version"
187
191
  annotationProcessor "androidx.room:room-compiler:$room_version"
188
192
 
189
- implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
193
+ implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
190
194
  //noinspection LifecycleAnnotationProcessorWithJava8
191
195
  annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
192
196
 
@@ -35,7 +35,8 @@ class ReadiumViewManager(
35
35
 
36
36
  @ReactProp(name = "file")
37
37
  fun setFile(view: ReadiumView, file: ReadableMap) {
38
- val path = file.getString("url")
38
+ val path = (file.getString("url") ?: "")
39
+ .replace("^(file:/+)?(/.*)$".toRegex(), "$2")
39
40
  val locatorMap = file.getMap("initialLocation")
40
41
  var initialLocation: Locator? = null
41
42
 
@@ -44,7 +45,7 @@ class ReadiumViewManager(
44
45
  }
45
46
 
46
47
  runBlocking {
47
- svc.openPublication(path!!, initialLocation) { fragment ->
48
+ svc.openPublication(path, initialLocation) { fragment ->
48
49
  view.addFragment(fragment)
49
50
  }
50
51
  }
@@ -38,6 +38,7 @@ class EpubReaderFragment : VisualReaderFragment(), EpubNavigatorFragment.Listene
38
38
  private lateinit var publication: Publication
39
39
  lateinit var navigatorFragment: EpubNavigatorFragment
40
40
  private lateinit var factory: ReaderViewModel.Factory
41
+ private var initialSettingsMap: Map<String, Any>? = null
41
42
 
42
43
  private lateinit var menuScreenReader: MenuItem
43
44
  private lateinit var menuSearch: MenuItem
@@ -61,8 +62,11 @@ class EpubReaderFragment : VisualReaderFragment(), EpubNavigatorFragment.Listene
61
62
  }
62
63
 
63
64
  fun updateSettingsFromMap(map: Map<String, Any>) {
64
- if (userSettings != null) {
65
+ if (this::userSettings.isInitialized) {
65
66
  userSettings.updateSettingsFromMap(map)
67
+ initialSettingsMap = null
68
+ } else {
69
+ initialSettingsMap = map
66
70
  }
67
71
  }
68
72
 
@@ -122,7 +126,11 @@ class EpubReaderFragment : VisualReaderFragment(), EpubNavigatorFragment.Listene
122
126
  super.onViewCreated(view, savedInstanceState)
123
127
 
124
128
  val activity = requireActivity()
125
- userSettings = UserSettings(navigatorFragment.preferences, activity, publication.userSettingsUIPreset)
129
+ userSettings = UserSettings(
130
+ navigatorFragment.preferences,
131
+ activity,
132
+ publication.userSettingsUIPreset
133
+ )
126
134
 
127
135
  // This is a hack to draw the right background color on top and bottom blank spaces
128
136
  navigatorFragment.lifecycleScope.launchWhenStarted {
@@ -137,6 +145,7 @@ class EpubReaderFragment : VisualReaderFragment(), EpubNavigatorFragment.Listene
137
145
  val activity = requireActivity()
138
146
 
139
147
  userSettings.resourcePager = navigatorFragment.resourcePager
148
+ initialSettingsMap?.let { updateSettingsFromMap(it) }
140
149
 
141
150
  // If TalkBack or any touch exploration service is activated we force scroll mode (and
142
151
  // override user preferences)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-readium",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "A react-native wrapper for https://readium.org/",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",