Skip to content

Commit dead521

Browse files
Merge pull request #55 from LeKiosqueFr/release/1.20.0
[V1.20.0] Update Reader Version
2 parents 9146ca0 + 261ea30 commit dead521

5 files changed

Lines changed: 50 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# MiLibrisReaderSDK Android changelog
22

3+
# 1.20.0
4+
5+
## Features
6+
- Add page bookmark feature
7+
38
# 1.19.1
49

510
## Improvements

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ MiLibrisReaderSDK is the new miLibris reading SDK (previously called MLPDFReader
1515
- [Print](#print)
1616
- [Search publication](#search-publication)
1717
- [Interstitial advert](#interstitial-advert)
18+
- [Page bookmark](#page-bookmark)
1819
- [Configure the reader tutorial](#configure-the-reader-tutorial)
1920
- [Event tracking](#event-tracking)
2021
- [Resume reading at the last read page](#resume-reading-at-the-last-read-page)
@@ -43,7 +44,7 @@ repositories {
4344
}
4445
4546
dependencies {
46-
def miLibrisReader = "1.19.1"
47+
def miLibrisReader = "1.20.0"
4748
api("com.milibris:one-reader:$miLibrisReader") { //If you ever have conflict with the version used in our library add this line
4849
exclude group: "androidx.lifecycle"
4950
}
@@ -202,6 +203,31 @@ OneReaderActivity.newIntent(
202203
)
203204
```
204205

206+
#### Page bookmark
207+
208+
To enable page bookmark, activate the setting.
209+
```kotlin
210+
val settings = ReaderSettings(
211+
isPageBookmarkEnabled = true
212+
)
213+
```
214+
215+
Then implement the `ReaderListener` methods to provide the bookmark states and handle the changes:
216+
217+
```kotlin
218+
override fun isPageBookMarked(page: Int): Boolean? {
219+
// Get current state
220+
return pageBookmarkRepository.getState(page)
221+
}
222+
223+
override fun onPageBookMarkClicked(page: Int, bookmarkListener: BaseListener<Boolean>) {
224+
// Toggle state
225+
val newState: Boolean = pageBookmarkRepository.toggleState(page)
226+
// Provide new state to the reader
227+
bookmarkListener.onSuccessListener(newState)
228+
}
229+
```
230+
205231
### Configure the reader tutorial
206232

207233
The reader is configured to display a tutorial the first time that it is opened on a new device. You can disable it you want:

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ android {
5151
}
5252
namespace 'com.milibris.reader.sdk.sample'
5353
}
54-
ext.readerVersion = "1.19.1"
54+
ext.readerVersion = "1.20.0"
5555

5656
dependencies {
5757

app/src/main/java/com/milibris/reader/sdk/sample/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class MainActivity : AppCompatActivity() {
6060
* Enable bookmark feature
6161
*/
6262
bookmarkEnabled = true
63+
64+
/**
65+
* Page bookmark
66+
*/
67+
isPageBookmarkEnabled = true
6368
}
6469
private lateinit var coverImageURL: String
6570
override fun onCreate(savedInstanceState: Bundle?) {

app/src/main/java/com/milibris/reader/sdk/sample/ORListener.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,16 @@ class ORListener(
116116
override fun onArticleReaderTitleOrLogoClicked(article: IArticle) {
117117
Log.e("ORListener", "onArticleReaderTitleOrLogoClicked($article)")
118118
}
119+
120+
// region Page bookmark
121+
private val bookmarkedPages = mutableMapOf<Int, Boolean>()
122+
override fun isPageBookMarked(page: Int): Boolean? =
123+
bookmarkedPages.getOrDefault(page, false)
124+
125+
override fun onPageBookMarkClicked(page: Int, bookmarkListener: BaseListener<Boolean>) {
126+
val newState = !bookmarkedPages.getOrDefault(page, false)
127+
bookmarkedPages[page] = newState
128+
bookmarkListener.onSuccessListener(bookmarkedPages.getOrDefault(page, false))
129+
}
130+
// endregion
119131
}

0 commit comments

Comments
 (0)