react-native-readium 1.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +135 -0
- package/android/build.gradle +198 -0
- package/android/gradle.properties +3 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/reactnativereadium/ReadiumPackage.kt +17 -0
- package/android/src/main/java/com/reactnativereadium/ReadiumView.kt +84 -0
- package/android/src/main/java/com/reactnativereadium/ReadiumViewManager.kt +80 -0
- package/android/src/main/java/com/reactnativereadium/epub/UserSettings.kt +236 -0
- package/android/src/main/java/com/reactnativereadium/reader/BaseReaderFragment.kt +81 -0
- package/android/src/main/java/com/reactnativereadium/reader/EpubReaderFragment.kt +375 -0
- package/android/src/main/java/com/reactnativereadium/reader/ImageReaderFragment.kt +68 -0
- package/android/src/main/java/com/reactnativereadium/reader/PdfReaderFragment.kt +82 -0
- package/android/src/main/java/com/reactnativereadium/reader/ReaderService.kt +116 -0
- package/android/src/main/java/com/reactnativereadium/reader/ReaderViewModel.kt +120 -0
- package/android/src/main/java/com/reactnativereadium/reader/VisualReaderFragment.kt +78 -0
- package/android/src/main/java/com/reactnativereadium/search/SearchFragment.kt +100 -0
- package/android/src/main/java/com/reactnativereadium/search/SearchPagingSource.kt +44 -0
- package/android/src/main/java/com/reactnativereadium/search/SearchResultAdapter.kt +68 -0
- package/android/src/main/java/com/reactnativereadium/utils/ContentResolverUtil.kt +156 -0
- package/android/src/main/java/com/reactnativereadium/utils/Dimensions.kt +6 -0
- package/android/src/main/java/com/reactnativereadium/utils/EventChannel.kt +61 -0
- package/android/src/main/java/com/reactnativereadium/utils/FragmentFactory.kt +46 -0
- package/android/src/main/java/com/reactnativereadium/utils/R2DispatcherActivity.kt +45 -0
- package/android/src/main/java/com/reactnativereadium/utils/SectionDecoration.kt +98 -0
- package/android/src/main/java/com/reactnativereadium/utils/SingleClickListener.kt +32 -0
- package/android/src/main/java/com/reactnativereadium/utils/SystemUiManagement.kt +63 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Bitmap.kt +23 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Context.kt +16 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/File.kt +22 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/InputStream.kt +23 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Link.kt +6 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Metadata.kt +6 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/URL.kt +29 -0
- package/android/src/main/java/com/reactnativereadium/utils/extensions/Uri.kt +17 -0
- package/android/src/main/res/drawable/background_action_mode.xml +6 -0
- package/android/src/main/res/drawable/cnl.png +0 -0
- package/android/src/main/res/drawable/cover.png +0 -0
- package/android/src/main/res/drawable/ic_add_white_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_baseline_arrow_forward_24.xml +5 -0
- package/android/src/main/res/drawable/ic_baseline_bookmark_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_delete_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_edit_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_enhanced_encryption_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_fast_forward_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_fast_rewind_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_headphones_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_pause_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_play_arrow_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_search_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_skip_next_24.xml +10 -0
- package/android/src/main/res/drawable/ic_baseline_skip_previous_24.xml +10 -0
- package/android/src/main/res/drawable/ic_dashboard_black_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_fastforward_30.xml +7 -0
- package/android/src/main/res/drawable/ic_info_black_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_local_library_black_24dp.xml +9 -0
- package/android/src/main/res/drawable/ic_notch.xml +4 -0
- package/android/src/main/res/drawable/ic_outline_add_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_format_align_justify_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_format_align_left_24.xml +11 -0
- package/android/src/main/res/drawable/ic_outline_format_size_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_light_mode_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_menu_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_remove_24.xml +10 -0
- package/android/src/main/res/drawable/ic_outline_wb_sunny_24.xml +10 -0
- package/android/src/main/res/drawable/ic_rewind_30.xml +7 -0
- package/android/src/main/res/drawable/icon_font_decrease.png +0 -0
- package/android/src/main/res/drawable/icon_font_increase.png +0 -0
- package/android/src/main/res/drawable/icon_overflow.png +0 -0
- package/android/src/main/res/drawable/rbtn_selector.xml +25 -0
- package/android/src/main/res/drawable/rbtn_textcolor_selector.xml +16 -0
- package/android/src/main/res/drawable/repfr.png +0 -0
- package/android/src/main/res/drawable/selector_blue.xml +42 -0
- package/android/src/main/res/drawable/selector_green.xml +42 -0
- package/android/src/main/res/drawable/selector_purple.xml +42 -0
- package/android/src/main/res/drawable/selector_red.xml +42 -0
- package/android/src/main/res/drawable/selector_yellow.xml +41 -0
- package/android/src/main/res/layout/activity_epub.xml +23 -0
- package/android/src/main/res/layout/activity_main.xml +32 -0
- package/android/src/main/res/layout/activity_reader.xml +6 -0
- package/android/src/main/res/layout/add_catalog_dialog.xml +25 -0
- package/android/src/main/res/layout/filter_row.xml +34 -0
- package/android/src/main/res/layout/filter_window.xml +24 -0
- package/android/src/main/res/layout/fragment_about.xml +150 -0
- package/android/src/main/res/layout/fragment_audiobook.xml +151 -0
- package/android/src/main/res/layout/fragment_bookshelf.xml +35 -0
- package/android/src/main/res/layout/fragment_catalog.xml +56 -0
- package/android/src/main/res/layout/fragment_catalog_feed_list.xml +27 -0
- package/android/src/main/res/layout/fragment_drm_management.xml +284 -0
- package/android/src/main/res/layout/fragment_listview.xml +24 -0
- package/android/src/main/res/layout/fragment_outline.xml +31 -0
- package/android/src/main/res/layout/fragment_publication_detail.xml +55 -0
- package/android/src/main/res/layout/fragment_reader.xml +6 -0
- package/android/src/main/res/layout/fragment_screen_reader.xml +143 -0
- package/android/src/main/res/layout/fragment_search.xml +39 -0
- package/android/src/main/res/layout/item_group_view.xml +22 -0
- package/android/src/main/res/layout/item_recycle_book.xml +55 -0
- package/android/src/main/res/layout/item_recycle_bookmark.xml +72 -0
- package/android/src/main/res/layout/item_recycle_button.xml +23 -0
- package/android/src/main/res/layout/item_recycle_catalog.xml +56 -0
- package/android/src/main/res/layout/item_recycle_highlight.xml +85 -0
- package/android/src/main/res/layout/item_recycle_horizontal.xml +45 -0
- package/android/src/main/res/layout/item_recycle_navigation.xml +34 -0
- package/android/src/main/res/layout/item_recycle_search.xml +14 -0
- package/android/src/main/res/layout/item_spinner_days.xml +19 -0
- package/android/src/main/res/layout/my_fragment.xml +13 -0
- package/android/src/main/res/layout/popup_delete.xml +29 -0
- package/android/src/main/res/layout/popup_note.xml +105 -0
- package/android/src/main/res/layout/popup_passphrase.xml +126 -0
- package/android/src/main/res/layout/popup_window_user_settings.xml +576 -0
- package/android/src/main/res/layout/section_header.xml +25 -0
- package/android/src/main/res/layout/view_action_mode.xml +100 -0
- package/android/src/main/res/layout/view_action_mode_reverse.xml +99 -0
- package/android/src/main/res/menu/bottom_nav_menu.xml +19 -0
- package/android/src/main/res/menu/menu_action_mode.xml +26 -0
- package/android/src/main/res/menu/menu_bookmark.xml +18 -0
- package/android/src/main/res/menu/menu_epub.xml +41 -0
- package/android/src/main/res/menu/menu_filter.xml +21 -0
- package/android/src/main/res/menu/menu_reader.xml +33 -0
- package/android/src/main/res/navigation/navigation.xml +46 -0
- package/android/src/main/res/values/arrays.xml +18 -0
- package/android/src/main/res/values/colors.xml +22 -0
- package/android/src/main/res/values/refs.xml +5 -0
- package/android/src/main/res/values/strings.xml +200 -0
- package/android/src/main/res/values/styles.xml +46 -0
- package/android/src/main/res/xml/network_security_config.xml +38 -0
- package/ios/App/AppModule.swift +62 -0
- package/ios/Common/Paths.swift +52 -0
- package/ios/Common/Publication.swift +15 -0
- package/ios/Common/Toolkit/Extensions/AnyPublisher.swift +14 -0
- package/ios/Common/Toolkit/Extensions/Future.swift +16 -0
- package/ios/Common/Toolkit/Extensions/HTTPClient.swift +65 -0
- package/ios/Common/Toolkit/Extensions/Locator.swift +14 -0
- package/ios/Common/Toolkit/Extensions/String.swift +16 -0
- package/ios/Common/Toolkit/Extensions/UIImage.swift +12 -0
- package/ios/Common/Toolkit/Extensions/UIViewController.swift +19 -0
- package/ios/Common/Toolkit/ScreenOrientation.swift +13 -0
- package/ios/Data/Bookmark.swift +23 -0
- package/ios/Reader/Common/ReaderViewController.swift +309 -0
- package/ios/Reader/EPUB/AssociatedColors.swift +27 -0
- package/ios/Reader/EPUB/EPUBModule.swift +38 -0
- package/ios/Reader/EPUB/EPUBViewController.swift +79 -0
- package/ios/Reader/ReaderError.swift +25 -0
- package/ios/Reader/ReaderFormatModule.swift +27 -0
- package/ios/Reader/ReaderModule.swift +84 -0
- package/ios/Reader/ReaderService.swift +126 -0
- package/ios/Readium-Bridging-Header.h +2 -0
- package/ios/Readium.xcodeproj/project.pbxproj +293 -0
- package/ios/ReadiumView.swift +156 -0
- package/ios/ReadiumViewManager.m +10 -0
- package/ios/ReadiumViewManager.swift +9 -0
- package/lib/commonjs/enums/Appearance.js +16 -0
- package/lib/commonjs/enums/Appearance.js.map +1 -0
- package/lib/commonjs/enums/ColumnCount.js +16 -0
- package/lib/commonjs/enums/ColumnCount.js.map +1 -0
- package/lib/commonjs/enums/FontFamily.js +21 -0
- package/lib/commonjs/enums/FontFamily.js.map +1 -0
- package/lib/commonjs/enums/TextAlignment.js +15 -0
- package/lib/commonjs/enums/TextAlignment.js.map +1 -0
- package/lib/commonjs/enums/index.js +58 -0
- package/lib/commonjs/enums/index.js.map +1 -0
- package/lib/commonjs/index.js +105 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/interfaces/Dimensions.js +2 -0
- package/lib/commonjs/interfaces/Dimensions.js.map +1 -0
- package/lib/commonjs/interfaces/File.js +6 -0
- package/lib/commonjs/interfaces/File.js.map +1 -0
- package/lib/commonjs/interfaces/Locator.js +2 -0
- package/lib/commonjs/interfaces/Locator.js.map +1 -0
- package/lib/commonjs/interfaces/Settings.js +71 -0
- package/lib/commonjs/interfaces/Settings.js.map +1 -0
- package/lib/commonjs/interfaces/index.js +58 -0
- package/lib/commonjs/interfaces/index.js.map +1 -0
- package/lib/commonjs/utils/index.js +30 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/enums/Appearance.js +9 -0
- package/lib/module/enums/Appearance.js.map +1 -0
- package/lib/module/enums/ColumnCount.js +9 -0
- package/lib/module/enums/ColumnCount.js.map +1 -0
- package/lib/module/enums/FontFamily.js +14 -0
- package/lib/module/enums/FontFamily.js.map +1 -0
- package/lib/module/enums/TextAlignment.js +8 -0
- package/lib/module/enums/TextAlignment.js.map +1 -0
- package/lib/module/enums/index.js +5 -0
- package/lib/module/enums/index.js.map +1 -0
- package/lib/module/index.js +61 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/interfaces/Dimensions.js +2 -0
- package/lib/module/interfaces/Dimensions.js.map +1 -0
- package/lib/module/interfaces/File.js +2 -0
- package/lib/module/interfaces/File.js.map +1 -0
- package/lib/module/interfaces/Locator.js +2 -0
- package/lib/module/interfaces/Locator.js.map +1 -0
- package/lib/module/interfaces/Settings.js +61 -0
- package/lib/module/interfaces/Settings.js.map +1 -0
- package/lib/module/interfaces/index.js +5 -0
- package/lib/module/interfaces/index.js.map +1 -0
- package/lib/module/utils/index.js +17 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/enums/Appearance.d.ts +11 -0
- package/lib/typescript/enums/ColumnCount.d.ts +5 -0
- package/lib/typescript/enums/FontFamily.d.ts +10 -0
- package/lib/typescript/enums/TextAlignment.d.ts +4 -0
- package/lib/typescript/enums/index.d.ts +4 -0
- package/lib/typescript/index.d.ts +17 -0
- package/lib/typescript/interfaces/Dimensions.d.ts +4 -0
- package/lib/typescript/interfaces/File.d.ts +11 -0
- package/lib/typescript/interfaces/Locator.d.ts +14 -0
- package/lib/typescript/interfaces/Settings.d.ts +40 -0
- package/lib/typescript/interfaces/index.d.ts +4 -0
- package/lib/typescript/utils/index.d.ts +10 -0
- package/package.json +160 -0
- package/react-native-readium.podspec +25 -0
- package/src/enums/Appearance.ts +14 -0
- package/src/enums/ColumnCount.ts +6 -0
- package/src/enums/FontFamily.ts +11 -0
- package/src/enums/TextAlignment.ts +5 -0
- package/src/enums/index.ts +4 -0
- package/src/index.tsx +78 -0
- package/src/interfaces/Dimensions.ts +4 -0
- package/src/interfaces/File.ts +14 -0
- package/src/interfaces/Locator.ts +14 -0
- package/src/interfaces/Settings.ts +85 -0
- package/src/interfaces/index.ts +4 -0
- package/src/utils/index.ts +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Jacob Spizziri
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# react-native-readium
|
|
2
|
+
|
|
3
|
+
A react-native wrapper for https://readium.org/
|
|
4
|
+
|
|
5
|
+
- [Installation](#installation)
|
|
6
|
+
- [Usage](#usage)
|
|
7
|
+
- [Supported Formats & DRM](#supported-formats--drm)
|
|
8
|
+
- [API](#api)
|
|
9
|
+
- [Contributing](#contributing)
|
|
10
|
+
- [Release](#release)
|
|
11
|
+
- [License](#license)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
#### Install Module
|
|
17
|
+
**NPM**
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm install react-native-readium
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Yarn**
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
yarn add react-native-readium
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
#### Pod Install
|
|
31
|
+
|
|
32
|
+
Due to the current state of the `Readium` swift libraries you need to manually
|
|
33
|
+
update your `Podfile` ([see more on that here](https://github.com/readium/swift-toolkit/issues/38)).
|
|
34
|
+
|
|
35
|
+
```rb
|
|
36
|
+
# ./ios/Podfile
|
|
37
|
+
...
|
|
38
|
+
|
|
39
|
+
target 'ExampleApp' do
|
|
40
|
+
config = use_native_modules!
|
|
41
|
+
...
|
|
42
|
+
pod 'GCDWebServer', podspec: 'https://raw.githubusercontent.com/readium/GCDWebServer/a8edee9790ef0995b2cf620ba1a9b5cf146b7221/GCDWebServer.podspec', modular_headers: true
|
|
43
|
+
pod 'R2Shared', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.2.0/Support/CocoaPods/ReadiumShared.podspec'
|
|
44
|
+
pod 'R2Streamer', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.2.0/Support/CocoaPods/ReadiumStreamer.podspec'
|
|
45
|
+
pod 'R2Navigator', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.2.0/Support/CocoaPods/ReadiumNavigator.podspec'
|
|
46
|
+
pod 'ReadiumOPDS', podspec: 'https://raw.githubusercontent.com/readium/swift-toolkit/2.2.0/Support/CocoaPods/ReadiumOPDS.podspec'
|
|
47
|
+
pod 'Minizip', modular_headers: true
|
|
48
|
+
...
|
|
49
|
+
end
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Finally, install the pods:
|
|
53
|
+
|
|
54
|
+
`pod install`
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import React, { useState } from 'react';
|
|
60
|
+
import { ReadiumView } from 'react-native-readium';
|
|
61
|
+
import type { File } from 'react-native-readium';
|
|
62
|
+
|
|
63
|
+
const MyComponent: React.FC = () => {
|
|
64
|
+
const [file] = useState<File>({
|
|
65
|
+
url: SOME_LOCAL_FILE_URL,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ReadiumView
|
|
70
|
+
file={file}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
[Take a look at the Example App](https://github.com/5-stones/react-native-readium/blob/main/example/src/App.tsx) for a more complex usage example.
|
|
77
|
+
|
|
78
|
+
## Supported Formats & DRM
|
|
79
|
+
|
|
80
|
+
#### Format Support
|
|
81
|
+
|
|
82
|
+
| Format | Support | Notes |
|
|
83
|
+
|--------|---------|-------|
|
|
84
|
+
| Epub 2 | :white_check_mark: | |
|
|
85
|
+
| Epub 3 | :white_check_mark: | |
|
|
86
|
+
| PDF | :x: | On the roadmap, feel free to submit a PR or ask for direction. |
|
|
87
|
+
| CBZ | :x: | On the roadmap, feel free to submit a PR or ask for direction. |
|
|
88
|
+
|
|
89
|
+
**Missing a format you need?** Reach out and see if it can be added to the roadmap.
|
|
90
|
+
|
|
91
|
+
#### DRM Support
|
|
92
|
+
|
|
93
|
+
DRM is not supported at this time. However, there is a clear path to [support it via LCP](https://www.edrlab.org/readium-lcp/) and the intention is to eventually implement it.
|
|
94
|
+
|
|
95
|
+
## API
|
|
96
|
+
|
|
97
|
+
#### View Props
|
|
98
|
+
|
|
99
|
+
| Name | Type | Optional | Description |
|
|
100
|
+
|------|------|----------|-------------|
|
|
101
|
+
| `file` | [`File`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/File.ts) | :x: | A file object containing the path to the eBook file on disk. |
|
|
102
|
+
| `location` | [`Locator`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Locator.ts) | :white_check_mark: | A locator prop that allows you to externally control the location of the reader (e.g. Chapters or Bookmarks)|
|
|
103
|
+
| `settings` | [`Partial<Settings>`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Settings.ts) | :white_check_mark: | An object that allows you to control various aspects of the reader's UI (epub only) |
|
|
104
|
+
| `style` | `ViewStyle` | :white_check_mark: | A traditional style object. |
|
|
105
|
+
| `onLocationChange` | `(locator: Locator) => void` | :white_check_mark: | A callback that fires whenever the location is changed (e.g. the user transitions to a new page)|
|
|
106
|
+
|
|
107
|
+
## Contributing
|
|
108
|
+
|
|
109
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
110
|
+
|
|
111
|
+
## Release
|
|
112
|
+
|
|
113
|
+
The standard release command for this project is:
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
yarn version
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This command will:
|
|
120
|
+
|
|
121
|
+
1. Generate/update the Changelog
|
|
122
|
+
1. Bump the package version
|
|
123
|
+
1. Tag & pushing the commit
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
e.g.
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
yarn version --new-version 1.2.17
|
|
130
|
+
yarn version --patch // 1.2.17 -> 1.2.18
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
MIT
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Readium_kotlinVersion']
|
|
4
|
+
ext.readium_version = '2.1.1'
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
google()
|
|
8
|
+
mavenCentral()
|
|
9
|
+
jcenter()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dependencies {
|
|
13
|
+
classpath 'com.android.tools.build:gradle:4.2.2'
|
|
14
|
+
// noinspection DifferentKotlinGradleVersion
|
|
15
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
apply plugin: 'com.android.library'
|
|
20
|
+
apply plugin: 'kotlin-android'
|
|
21
|
+
|
|
22
|
+
def getExtOrDefault(name) {
|
|
23
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Readium_' + name]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
def getExtOrIntegerDefault(name) {
|
|
27
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['Readium_' + name]).toInteger()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
android {
|
|
31
|
+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
32
|
+
defaultConfig {
|
|
33
|
+
minSdkVersion 21
|
|
34
|
+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
35
|
+
versionCode 1
|
|
36
|
+
versionName "1.0"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
buildTypes {
|
|
40
|
+
release {
|
|
41
|
+
minifyEnabled false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
lintOptions {
|
|
45
|
+
disable 'GradleCompatible'
|
|
46
|
+
}
|
|
47
|
+
compileOptions {
|
|
48
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
49
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
kotlinOptions {
|
|
53
|
+
jvmTarget = "1.8"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
buildFeatures {
|
|
57
|
+
viewBinding true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
repositories {
|
|
62
|
+
|
|
63
|
+
maven { url 'https://jitpack.io' }
|
|
64
|
+
|
|
65
|
+
mavenCentral()
|
|
66
|
+
jcenter()
|
|
67
|
+
google()
|
|
68
|
+
|
|
69
|
+
def found = false
|
|
70
|
+
def defaultDir = null
|
|
71
|
+
def androidSourcesName = 'React Native sources'
|
|
72
|
+
|
|
73
|
+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
74
|
+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
75
|
+
} else {
|
|
76
|
+
defaultDir = new File(
|
|
77
|
+
projectDir,
|
|
78
|
+
'/../../../node_modules/react-native/android'
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (defaultDir.exists()) {
|
|
83
|
+
maven {
|
|
84
|
+
url defaultDir.toString()
|
|
85
|
+
name androidSourcesName
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
89
|
+
found = true
|
|
90
|
+
} else {
|
|
91
|
+
def parentDir = rootProject.projectDir
|
|
92
|
+
|
|
93
|
+
1.upto(5, {
|
|
94
|
+
if (found) return true
|
|
95
|
+
parentDir = parentDir.parentFile
|
|
96
|
+
|
|
97
|
+
def androidSourcesDir = new File(
|
|
98
|
+
parentDir,
|
|
99
|
+
'node_modules/react-native'
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
def androidPrebuiltBinaryDir = new File(
|
|
103
|
+
parentDir,
|
|
104
|
+
'node_modules/react-native/android'
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
if (androidPrebuiltBinaryDir.exists()) {
|
|
108
|
+
maven {
|
|
109
|
+
url androidPrebuiltBinaryDir.toString()
|
|
110
|
+
name androidSourcesName
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
114
|
+
found = true
|
|
115
|
+
} else if (androidSourcesDir.exists()) {
|
|
116
|
+
maven {
|
|
117
|
+
url androidSourcesDir.toString()
|
|
118
|
+
name androidSourcesName
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
122
|
+
found = true
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!found) {
|
|
128
|
+
throw new GradleException(
|
|
129
|
+
"${project.name}: unable to locate React Native android sources. " +
|
|
130
|
+
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
136
|
+
|
|
137
|
+
dependencies {
|
|
138
|
+
// noinspection GradleDynamicVersion
|
|
139
|
+
api 'com.facebook.react:react-native:+'
|
|
140
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
141
|
+
|
|
142
|
+
// readium deps
|
|
143
|
+
implementation "com.github.readium.kotlin-toolkit:readium-shared:$readium_version"
|
|
144
|
+
implementation "com.github.readium.kotlin-toolkit:readium-streamer:$readium_version"
|
|
145
|
+
implementation "com.github.readium.kotlin-toolkit:readium-navigator:$readium_version"
|
|
146
|
+
|
|
147
|
+
// other deps
|
|
148
|
+
implementation 'androidx.core:core-ktx:1.6.0'
|
|
149
|
+
implementation "androidx.activity:activity-ktx:1.3.1"
|
|
150
|
+
implementation "androidx.appcompat:appcompat:1.3.1"
|
|
151
|
+
implementation "androidx.browser:browser:1.3.0"
|
|
152
|
+
implementation "androidx.cardview:cardview:1.0.0"
|
|
153
|
+
implementation "androidx.constraintlayout:constraintlayout:2.1.1"
|
|
154
|
+
implementation "androidx.fragment:fragment-ktx:1.3.6"
|
|
155
|
+
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
|
|
156
|
+
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
|
|
157
|
+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
|
|
158
|
+
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
|
159
|
+
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
|
160
|
+
implementation "androidx.paging:paging-runtime-ktx:3.0.1"
|
|
161
|
+
implementation "androidx.recyclerview:recyclerview:1.2.1"
|
|
162
|
+
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
|
163
|
+
implementation "androidx.webkit:webkit:1.4.0"
|
|
164
|
+
//noinspection GradleDependency
|
|
165
|
+
implementation ("com.github.edrlab.nanohttpd:nanohttpd:master-SNAPSHOT") {
|
|
166
|
+
exclude group: 'org.parboiled'
|
|
167
|
+
}
|
|
168
|
+
//noinspection GradleDependency
|
|
169
|
+
implementation ("com.github.edrlab.nanohttpd:nanohttpd-nanolets:master-SNAPSHOT") {
|
|
170
|
+
exclude group: 'org.parboiled'
|
|
171
|
+
}
|
|
172
|
+
implementation "com.google.android.material:material:1.4.0"
|
|
173
|
+
implementation "com.jakewharton.timber:timber:4.7.1"
|
|
174
|
+
// AM NOTE: needs to stay this version for now (June 24,2020)
|
|
175
|
+
//noinspection GradleDependency
|
|
176
|
+
implementation "com.squareup.picasso:picasso:2.5.2"
|
|
177
|
+
implementation "joda-time:joda-time:2.10.10"
|
|
178
|
+
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2"
|
|
179
|
+
// AM NOTE: needs to stay this version for now (June 24,2020)
|
|
180
|
+
//noinspection GradleDependency
|
|
181
|
+
implementation 'org.jsoup:jsoup:1.13.1'
|
|
182
|
+
|
|
183
|
+
// Room database
|
|
184
|
+
final room_version = '2.4.0-beta01'
|
|
185
|
+
implementation "androidx.room:room-runtime:$room_version"
|
|
186
|
+
implementation "androidx.room:room-ktx:$room_version"
|
|
187
|
+
annotationProcessor "androidx.room:room-compiler:$room_version"
|
|
188
|
+
|
|
189
|
+
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
|
190
|
+
//noinspection LifecycleAnnotationProcessorWithJava8
|
|
191
|
+
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
|
|
192
|
+
|
|
193
|
+
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
|
194
|
+
testImplementation "junit:junit:4.13.2"
|
|
195
|
+
|
|
196
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
|
|
197
|
+
androidTestImplementation "androidx.test:runner:1.4.0"
|
|
198
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.reactnativereadium
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ReadiumPackage : ReactPackage {
|
|
10
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
+
return emptyList()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
+
return listOf(ReadiumViewManager(reactContext))
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package com.reactnativereadium
|
|
2
|
+
|
|
3
|
+
import android.view.Choreographer
|
|
4
|
+
import android.widget.FrameLayout
|
|
5
|
+
import androidx.fragment.app.FragmentActivity
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
+
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
9
|
+
import com.reactnativereadium.reader.BaseReaderFragment
|
|
10
|
+
import com.reactnativereadium.reader.EpubReaderFragment
|
|
11
|
+
import com.reactnativereadium.reader.ReaderViewModel
|
|
12
|
+
import com.reactnativereadium.utils.Dimensions
|
|
13
|
+
import org.readium.r2.shared.extensions.toMap
|
|
14
|
+
import org.readium.r2.shared.publication.Locator
|
|
15
|
+
|
|
16
|
+
class ReadiumView(
|
|
17
|
+
val reactContext: ThemedReactContext
|
|
18
|
+
) : FrameLayout(reactContext) {
|
|
19
|
+
var dimensions: Dimensions = Dimensions(0,0)
|
|
20
|
+
var fragment: BaseReaderFragment? = null
|
|
21
|
+
|
|
22
|
+
fun updateLocation(locator: Locator) : Boolean {
|
|
23
|
+
if (fragment == null) {
|
|
24
|
+
return false
|
|
25
|
+
} else {
|
|
26
|
+
return this.fragment!!.go(locator, true)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fun updateSettingsFromMap(map: Map<String, Any>) {
|
|
31
|
+
if (fragment != null && fragment is EpubReaderFragment) {
|
|
32
|
+
(fragment as EpubReaderFragment).updateSettingsFromMap(map)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun addFragment(frag: BaseReaderFragment) {
|
|
37
|
+
fragment = frag
|
|
38
|
+
setupLayout()
|
|
39
|
+
val activity: FragmentActivity? = reactContext.currentActivity as FragmentActivity?
|
|
40
|
+
activity!!.supportFragmentManager
|
|
41
|
+
.beginTransaction()
|
|
42
|
+
.replace(this.id, frag, this.id.toString())
|
|
43
|
+
.commit()
|
|
44
|
+
|
|
45
|
+
// subscribe to reader events
|
|
46
|
+
frag.channel.receive(frag) { event ->
|
|
47
|
+
val module = reactContext.getJSModule(RCTEventEmitter::class.java)
|
|
48
|
+
when (event) {
|
|
49
|
+
is ReaderViewModel.Event.LocatorUpdate -> {
|
|
50
|
+
val json = event.locator.toJSON()
|
|
51
|
+
val payload = Arguments.makeNativeMap(json.toMap())
|
|
52
|
+
module.receiveEvent(
|
|
53
|
+
this.id.toInt(),
|
|
54
|
+
ReadiumViewManager.ON_LOCATION_CHANGE,
|
|
55
|
+
payload
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private fun setupLayout() {
|
|
63
|
+
Choreographer.getInstance().postFrameCallback(object : Choreographer.FrameCallback {
|
|
64
|
+
override fun doFrame(frameTimeNanos: Long) {
|
|
65
|
+
manuallyLayoutChildren()
|
|
66
|
+
this@ReadiumView.viewTreeObserver.dispatchOnGlobalLayout()
|
|
67
|
+
Choreographer.getInstance().postFrameCallback(this)
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Layout all children properly
|
|
74
|
+
*/
|
|
75
|
+
private fun manuallyLayoutChildren() {
|
|
76
|
+
// propWidth and propHeight coming from react-native props
|
|
77
|
+
val width = dimensions.width
|
|
78
|
+
val height = dimensions.height
|
|
79
|
+
this.measure(
|
|
80
|
+
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
|
81
|
+
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
|
|
82
|
+
this.layout(0, 0, width, height)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package com.reactnativereadium
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.facebook.react.common.MapBuilder
|
|
5
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactPropGroup
|
|
7
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
9
|
+
import com.reactnativereadium.reader.ReaderService
|
|
10
|
+
import kotlinx.coroutines.runBlocking
|
|
11
|
+
import org.json.JSONObject
|
|
12
|
+
import org.readium.r2.shared.publication.Locator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ReadiumViewManager(
|
|
16
|
+
val reactContext: ReactApplicationContext
|
|
17
|
+
) : ViewGroupManager<ReadiumView>() {
|
|
18
|
+
private var svc = ReaderService(reactContext)
|
|
19
|
+
|
|
20
|
+
override fun getName() = "ReadiumView"
|
|
21
|
+
|
|
22
|
+
override fun createViewInstance(reactContext: ThemedReactContext): ReadiumView {
|
|
23
|
+
return ReadiumView(reactContext)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
override fun getExportedCustomBubblingEventTypeConstants(): Map<String, Any> {
|
|
27
|
+
return MapBuilder.builder<String, Any>().put(
|
|
28
|
+
ON_LOCATION_CHANGE,
|
|
29
|
+
MapBuilder.of(
|
|
30
|
+
"phasedRegistrationNames",
|
|
31
|
+
MapBuilder.of("bubbled", ON_LOCATION_CHANGE)
|
|
32
|
+
)
|
|
33
|
+
).build()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactProp(name = "file")
|
|
37
|
+
fun setFile(view: ReadiumView, file: ReadableMap) {
|
|
38
|
+
val path = file.getString("url")
|
|
39
|
+
val locatorMap = file.getMap("initialLocation")
|
|
40
|
+
var initialLocation: Locator? = null
|
|
41
|
+
|
|
42
|
+
if (locatorMap != null) {
|
|
43
|
+
initialLocation = Locator.fromJSON(JSONObject(locatorMap.toHashMap()))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
runBlocking {
|
|
47
|
+
svc.openPublication(path!!, initialLocation) { fragment ->
|
|
48
|
+
view.addFragment(fragment)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ReactProp(name = "location")
|
|
54
|
+
fun setLocation(view: ReadiumView, location: ReadableMap) {
|
|
55
|
+
val locator = Locator.fromJSON(JSONObject(location.toHashMap()))
|
|
56
|
+
|
|
57
|
+
if (locator != null) {
|
|
58
|
+
view.updateLocation(locator)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@ReactProp(name = "settings")
|
|
63
|
+
fun setSettings(view: ReadiumView, settings: ReadableMap) {
|
|
64
|
+
view.updateSettingsFromMap(settings.toHashMap())
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@ReactPropGroup(names = ["width", "height"], customType = "Style")
|
|
68
|
+
fun setStyle(view: ReadiumView?, index: Int, value: Int) {
|
|
69
|
+
if (index == 0) {
|
|
70
|
+
view?.dimensions?.width = value
|
|
71
|
+
}
|
|
72
|
+
if (index == 1) {
|
|
73
|
+
view?.dimensions?.height = value
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
companion object {
|
|
78
|
+
var ON_LOCATION_CHANGE = "onLocationChange"
|
|
79
|
+
}
|
|
80
|
+
}
|