diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 000000000..0dd4b3546
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7f4..549089efd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,5 +1,14 @@
+
+
+
diff --git a/app/build.gradle b/app/build.gradle
index e8a72de1d..bb872aa8d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -66,7 +66,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01'
- implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha02'
+ implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha03'
implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.work:work-runtime-ktx:2.3.4'
@@ -82,12 +82,12 @@ dependencies {
implementation 'com.github.moxy-community:moxy-ktx:2.1.2'
kapt 'com.github.moxy-community:moxy-compiler:2.1.2'
- implementation 'com.squareup.okhttp3:okhttp:4.5.0'
- implementation 'com.squareup.okio:okio:2.5.0'
+ implementation 'com.squareup.okhttp3:okhttp:4.6.0'
+ implementation 'com.squareup.okio:okio:2.6.0'
implementation 'org.jsoup:jsoup:1.13.1'
implementation 'org.koin:koin-android:2.1.5'
- implementation 'io.coil-kt:coil:0.9.5'
+ implementation 'io.coil-kt:coil:0.10.1'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
implementation 'com.tomclaw.cache:cache:1.0'
diff --git a/app/src/main/java/org/koitharu/kotatsu/ui/details/ChaptersFragment.kt b/app/src/main/java/org/koitharu/kotatsu/ui/details/ChaptersFragment.kt
index 0dec517ec..a4dd04424 100644
--- a/app/src/main/java/org/koitharu/kotatsu/ui/details/ChaptersFragment.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/ui/details/ChaptersFragment.kt
@@ -1,8 +1,11 @@
package org.koitharu.kotatsu.ui.details
import android.app.ActivityOptions
+import android.content.Context
import android.os.Bundle
+import android.view.MenuItem
import android.view.View
+import androidx.appcompat.widget.PopupMenu
import androidx.core.view.isVisible
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
@@ -10,15 +13,12 @@ import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.fragment_chapters.*
import moxy.ktx.moxyPresenter
import org.koitharu.kotatsu.R
-import org.koitharu.kotatsu.core.model.FavouriteCategory
-import org.koitharu.kotatsu.core.model.Manga
-import org.koitharu.kotatsu.core.model.MangaChapter
-import org.koitharu.kotatsu.core.model.MangaHistory
+import org.koitharu.kotatsu.core.model.*
import org.koitharu.kotatsu.ui.common.BaseFragment
import org.koitharu.kotatsu.ui.common.list.OnRecyclerItemClickListener
import org.koitharu.kotatsu.ui.download.DownloadService
import org.koitharu.kotatsu.ui.reader.ReaderActivity
-import org.koitharu.kotatsu.utils.ext.showPopupMenu
+import org.koitharu.kotatsu.utils.ext.resolveDp
class ChaptersFragment : BaseFragment(R.layout.fragment_chapters), MangaDetailsView,
OnRecyclerItemClickListener {
@@ -86,20 +86,16 @@ class ChaptersFragment : BaseFragment(R.layout.fragment_chapters), MangaDetailsV
}
override fun onItemLongClick(item: MangaChapter, position: Int, view: View): Boolean {
- view.showPopupMenu(R.menu.popup_chapter) {
- val ctx = context ?: return@showPopupMenu false
- val m = manga ?: return@showPopupMenu false
- when (it.itemId) {
- R.id.action_save_this -> DownloadService.start(ctx, m, setOf(item.id))
- R.id.action_save_this_next -> DownloadService.start(ctx, m, m.chapters.orEmpty()
- .filter { x -> x.number >= item.number }.map { x -> x.id })
- R.id.action_save_this_prev -> DownloadService.start(ctx, m, m.chapters.orEmpty()
- .filter { x -> x.number <= item.number }.map { x -> x.id })
- else -> return@showPopupMenu false
- }
- true
+ if (item.source == MangaSource.LOCAL) {
+ return false
}
- return true
+ return context?.run {
+ val menu = PopupMenu(this, view)
+ menu.inflate(R.menu.popup_chapter)
+ menu.setOnMenuItemClickListener(PopupMenuListener(this, manga ?: return false, item))
+ menu.show()
+ true
+ } ?: false
}
private fun scrollToCurrent() {
@@ -107,7 +103,33 @@ class ChaptersFragment : BaseFragment(R.layout.fragment_chapters), MangaDetailsV
?: RecyclerView.NO_POSITION
if (pos != RecyclerView.NO_POSITION) {
(recyclerView_chapters.layoutManager as? LinearLayoutManager)
- ?.scrollToPositionWithOffset(pos, 100)
+ ?.scrollToPositionWithOffset(pos, resources.resolveDp(40))
}
}
+
+ private class PopupMenuListener(
+ private val context: Context,
+ private val manga: Manga,
+ private val chapter: MangaChapter
+ ) : PopupMenu.OnMenuItemClickListener {
+
+ override fun onMenuItemClick(item: MenuItem?): Boolean = when (item?.itemId) {
+ R.id.action_save_this -> {
+ DownloadService.start(context, manga, setOf(chapter.id))
+ true
+ }
+ R.id.action_save_this_next -> {
+ DownloadService.start(context, manga, manga.chapters.orEmpty()
+ .filter { x -> x.number >= chapter.number }.map { x -> x.id })
+ true
+ }
+ R.id.action_save_this_prev -> {
+ DownloadService.start(context, manga, manga.chapters.orEmpty()
+ .filter { x -> x.number <= chapter.number }.map { x -> x.id })
+ true
+ }
+ else -> false
+ }
+
+ }
}
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 079d1fcd8..209fec629 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ buildscript {
}
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0-alpha07'
+ classpath 'com.android.tools.build:gradle:4.1.0-alpha08'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 3d1e072c4..ea3af997a 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sat Apr 25 17:13:08 EEST 2020
+#Sun May 03 16:59:44 EEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-rc-2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-rc-4-all.zip