diff --git a/CHANGELOG.md b/CHANGELOG.md index d094eaa0..c75610e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,13 @@ All notable changes to this project will be documented in this file. **Warning:** Features marked as *experimental* may change or be removed in a future release without notice. Use with caution. +[unreleased]: https://github.com/readium/r2-navigator-kotlin/compare/master...HEAD +[1.2.0]: https://github.com/readium/r2-navigator-kotlin/compare/1.1.6...1.2.0 + ## [Unreleased] +## [1.2.0] + ### Added * The [position](https://github.com/readium/architecture/tree/master/models/locators/positions) is now reported in the locators for EPUB, CBZ and PDF. @@ -30,6 +35,3 @@ All notable changes to this project will be documented in this file. * [Crash when opening a publication with a space in its filename](https://github.com/readium/r2-navigator-kotlin/pull/136). * [Jumping to an EPUB location from the search](https://github.com/readium/r2-navigator-kotlin/pull/111). * The `AndroidManifest.xml` is not forcing anymore `allowBackup` and `supportsRtl`, to let reading apps manage these features themselves (contributed by [@twaddington](https://github.com/readium/r2-navigator-kotlin/pull/118)). - -[unreleased]: https://github.com/readium/r2-navigator-kotlin/compare/master...HEAD -[x.x.x]: https://github.com/readium/r2-navigator-kotlin/compare/1.1.6...x.x.x diff --git a/build.gradle b/build.gradle index e7abc85e..9dbc6f2e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,20 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.61' + ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { + // AM NOTE: needs to stay this version for now (June 24,2020) + //noinspection GradleDependency classpath 'com.android.tools.build:gradle:3.5.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' + + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/r2-navigator/build.gradle b/r2-navigator/build.gradle index 24633c90..9cf4d77f 100644 --- a/r2-navigator/build.gradle +++ b/r2-navigator/build.gradle @@ -15,15 +15,15 @@ group='com.github.readium' android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { minSdkVersion 21 - targetSdkVersion 29 + targetSdkVersion 30 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } compileOptions { - sourceCompatibility 1.8 - targetCompatibility 1.8 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = "1.8" @@ -40,41 +40,46 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation 'com.shopgun.android:utils:1.0.9' + if (findProject(':r2-shared')) { implementation project(':r2-shared') } else { implementation "com.github.readium:r2-shared-kotlin:1.1.6" } - implementation "androidx.appcompat:appcompat:1.2.0-beta01" + + implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation "androidx.core:core-ktx:1.3.0" - implementation 'androidx.webkit:webkit:1.1.0' + implementation 'androidx.webkit:webkit:1.2.0' implementation "androidx.legacy:legacy-support-v4:1.0.0" - implementation "com.google.android.material:material:1.2.0-alpha03" - implementation 'joda-time:joda-time:2.9.9' + implementation 'com.google.android.material:material:1.3.0-alpha01' + implementation 'joda-time:joda-time:2.10.5' implementation 'com.duolingo.open:rtl-viewpager:1.0.3' implementation 'com.jakewharton.timber:timber:4.7.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.6' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5' - implementation 'org.zeroturnaround:zt-zip:1.13' + implementation 'org.zeroturnaround:zt-zip:1.14' + // AM NOTE: needs to stay this version for now (June 24,2020) + //noinspection GradleDependency implementation 'org.jsoup:jsoup:1.10.3' + api 'com.github.barteksc:android-pdf-viewer:2.8.2' - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" implementation "androidx.activity:activity-ktx:1.1.0" - implementation "androidx.appcompat:appcompat:1.2.0-beta01" + implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation "androidx.core:core-ktx:1.2.0" - implementation "androidx.fragment:fragment-ktx:1.2.4" + implementation 'androidx.core:core-ktx:1.3.0' + implementation 'androidx.fragment:fragment-ktx:1.2.5' implementation "androidx.legacy:legacy-support-core-ui:1.0.0" implementation "androidx.legacy:legacy-support-v4:1.0.0" implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0" @@ -83,7 +88,7 @@ dependencies { implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0" implementation "androidx.recyclerview:recyclerview:1.1.0" implementation 'androidx.viewpager2:viewpager2:1.0.0' - implementation 'androidx.webkit:webkit:1.1.0' + implementation 'androidx.webkit:webkit:1.2.0' // ChrisBane/PhotoView ( for the Zoom handling ) implementation 'com.github.chrisbanes:PhotoView:2.1.4' diff --git a/r2-navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt b/r2-navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt index 36ff181b..00a62b6c 100644 --- a/r2-navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt +++ b/r2-navigator/src/main/java/org/readium/r2/navigator/R2WebView.kt @@ -47,7 +47,7 @@ class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView(context, uiScope.launch { if (mCurItem < numPages - 1) { mCurItem++ - listener.onPageChanged(mCurItem + 1, numPages, url) + url?.let { listener.onPageChanged(mCurItem + 1, numPages, it) } } } } @@ -58,7 +58,7 @@ class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView(context, uiScope.launch { if (mCurItem > 0) { mCurItem-- - listener.onPageChanged(mCurItem + 1, numPages, url) + url?.let { listener.onPageChanged(mCurItem + 1, numPages, it) } } } } @@ -323,7 +323,7 @@ class R2WebView(context: Context, attrs: AttributeSet) : R2BasicWebView(context, } if (post) { - listener.onPageChanged(item + 1, numPages, url) + url?.let { listener.onPageChanged(item + 1, numPages, it) } } diff --git a/r2-navigator/src/main/java/org/readium/r2/navigator/audiobook/R2AudiobookActivity.kt b/r2-navigator/src/main/java/org/readium/r2/navigator/audiobook/R2AudiobookActivity.kt index a215b70a..8601085d 100644 --- a/r2-navigator/src/main/java/org/readium/r2/navigator/audiobook/R2AudiobookActivity.kt +++ b/r2-navigator/src/main/java/org/readium/r2/navigator/audiobook/R2AudiobookActivity.kt @@ -380,24 +380,26 @@ open class R2AudiobookActivity : AppCompatActivity(), CoroutineScope, IR2Activit super.onActivityResult(requestCode, resultCode, data) if (requestCode == 2 && resultCode == Activity.RESULT_OK) { if (data != null) { - val locator = data.getParcelableExtra("locator") as Locator + val locator = data.getParcelableExtra("locator") as? Locator - // href is the link to the page in the toc - var href = locator.href + locator?.let { + // href is the link to the page in the toc + var href = locator.href - if (href.indexOf("#") > 0) { - href = href.substring(0, href.indexOf("#")) - } + if (href.indexOf("#") > 0) { + href = href.substring(0, href.indexOf("#")) + } - var index = 0 - for (resource in publication.readingOrder) { - if (resource.href.endsWith(href)) { - currentResource = index - break + var index = 0 + for (resource in publication.readingOrder) { + if (resource.href.endsWith(href)) { + currentResource = index + break + } + index++ } - index++ + seekLocation = locator.locations } - seekLocation = locator.locations isSeekNeeded = true diff --git a/r2-navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt b/r2-navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt index 4aa7b85f..4bf83254 100644 --- a/r2-navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt +++ b/r2-navigator/src/main/java/org/readium/r2/navigator/cbz/R2CbzActivity.kt @@ -221,21 +221,23 @@ open class R2CbzActivity : AppCompatActivity(), CoroutineScope, IR2Activity, Vis if (requestCode == 2 && resultCode == Activity.RESULT_OK) { if (data != null) { - val locator = data.getParcelableExtra("locator") as Locator - - fun setCurrent(resources: List) { - for (index in 0 until resources.count()) { - val resource = resources[index] - if (resource.endsWith(locator.href)) { - resourcePager.currentItem = index - break + val locator = data.getParcelableExtra("locator") as? Locator + + locator?.let { + fun setCurrent(resources: List) { + for (index in 0 until resources.count()) { + val resource = resources[index] + if (resource.endsWith(locator.href)) { + resourcePager.currentItem = index + break + } } } - } - resourcePager.adapter = adapter + resourcePager.adapter = adapter - setCurrent(resources) + setCurrent(resources) + } if (supportActionBar!!.isShowing && allowToggleActionBar) { resourcePager.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE diff --git a/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt b/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt index 7867b73b..6dbb4cd4 100755 --- a/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt +++ b/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2EpubPageFragment.kt @@ -235,7 +235,7 @@ class R2EpubPageFragment : Fragment() { if (id != null) { webView.loadUrl("$resourceUrl#$id") } else { - webView.loadUrl(resourceUrl) + resourceUrl?.let { webView.loadUrl(it) } } return v diff --git a/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2FXLPageFragment.kt b/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2FXLPageFragment.kt index 07346282..f1dd9b52 100755 --- a/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2FXLPageFragment.kt +++ b/r2-navigator/src/main/java/org/readium/r2/navigator/pager/R2FXLPageFragment.kt @@ -134,7 +134,7 @@ class R2FXLPageFragment : Fragment() { true } - webView.loadUrl(resourceUrl) + resourceUrl?.let { webView.loadUrl(it) } } companion object {