Disable save action for local chapters
This commit is contained in:
6
.idea/kotlinc.xml
generated
Normal file
6
.idea/kotlinc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Kotlin2JvmCompilerArguments">
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/vcs.xml
generated
9
.idea/vcs.xml
generated
@@ -1,5 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitSharedSettings">
|
||||
<option name="FORCE_PUSH_PROHIBITED_PATTERNS">
|
||||
<list>
|
||||
<option value="master" />
|
||||
<option value="devel" />
|
||||
<option value="legacy" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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<MangaChapter> {
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user