diff --git a/app/build.gradle b/app/build.gradle index 8768cac00..ac92590e6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -129,11 +129,11 @@ dependencies { // AndroidX libraries implementation 'androidx.annotation:annotation:1.1.0' - implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' - implementation 'androidx.biometric:biometric:1.0.1' + implementation 'androidx.appcompat:appcompat:1.3.0-alpha02' + implementation 'androidx.biometric:biometric:1.1.0-alpha02' implementation 'androidx.browser:browser:1.2.0' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-rc1' + implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0' implementation 'androidx.core:core-ktx:1.4.0-alpha01' implementation 'androidx.multidex:multidex:2.0.1' @@ -141,20 +141,20 @@ dependencies { implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha05' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01' - final lifecycle_version = '2.3.0-alpha06' + final lifecycle_version = '2.3.0-alpha07' implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" // Job scheduling - final work_version = '2.4.0' + final work_version = '2.5.0-alpha01' implementation "androidx.work:work-runtime:$work_version" implementation "androidx.work:work-runtime-ktx:$work_version" // UI library implementation 'com.google.android.material:material:1.3.0-alpha02' - standardImplementation 'com.google.firebase:firebase-core:17.4.4' + standardImplementation 'com.google.firebase:firebase-core:17.5.0' // ReactiveX implementation 'io.reactivex:rxandroid:1.2.1' @@ -200,7 +200,7 @@ dependencies { implementation 'io.requery:sqlite-android:3.32.2' // Preferences - implementation 'com.github.tfcporciuncula:flow-preferences:1.3.0' + implementation 'com.github.tfcporciuncula:flow-preferences:1.3.1' // Model View Presenter final nucleus_version = '3.0.0' @@ -276,7 +276,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$BuildPluginsVersion.KOTLIN" implementation "org.jetbrains.kotlin:kotlin-reflect:$BuildPluginsVersion.KOTLIN" - final coroutines_version = '1.3.8' + final coroutines_version = '1.3.9' + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 5b3943f6e..07ccd102e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -23,21 +23,6 @@ (); } -# OkHttp --dontwarn okhttp3.** --dontwarn okio.** --dontwarn javax.annotation.** --dontwarn retrofit2.Platform$Java8 - -# Glide specific rules # -# https://github.com/bumptech/glide --keep public class * implements com.bumptech.glide.module.GlideModule --keep public class * extends com.bumptech.glide.AppGlideModule --keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** { - **[] $VALUES; - public *; -} - # RxJava 1.1.0 -dontwarn sun.misc.** diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index d8a8368ac..400fe5648 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -198,14 +198,10 @@ class DownloadManager(private val context: Context) { * @param manga the manga of the chapters. * @param source the source of the chapters. */ - fun deleteChapters(chapters: List, manga: Manga, source: Source) { - queue.remove(chapters) + fun deleteChapters(chapters: List, manga: Manga, source: Source): List { + val filteredChapters = getChaptersToDelete(chapters) - val filteredChapters = if (!preferences.removeBookmarkedChapters()) { - chapters.filterNot { it.bookmark } - } else { - chapters - } + queue.remove(filteredChapters) val chapterDirs = provider.findChapterDirs(filteredChapters, manga, source) chapterDirs.forEach { it.delete() } @@ -213,6 +209,8 @@ class DownloadManager(private val context: Context) { if (cache.getDownloadCount(manga) == 0) { // Delete manga directory if empty chapterDirs.firstOrNull()?.parentFile?.delete() } + + return filteredChapters } /** @@ -234,7 +232,7 @@ class DownloadManager(private val context: Context) { * @param manga the manga of the chapters. */ fun enqueueDeleteChapters(chapters: List, manga: Manga) { - pendingDeleter.addChapters(chapters, manga) + pendingDeleter.addChapters(getChaptersToDelete(chapters), manga) } /** @@ -273,4 +271,12 @@ class DownloadManager(private val context: Context) { Timber.e("Could not rename downloaded chapter: %s.", oldNames.joinToString()) } } + + private fun getChaptersToDelete(chapters: List): List { + return if (!preferences.removeBookmarkedChapters()) { + chapters.filterNot { it.bookmark } + } else { + chapters + } + } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index d517a9e4c..5b2cccde2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -89,7 +89,8 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { var isWebViewOutdated = false val origRequestUrl = request.url.toString() - val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" } + val headers = request.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap() + headers["X-Requested-With"] = WebViewUtil.REQUESTED_WITH handler.post { val webview = WebView(context) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 506ef910f..23d0f00b4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -80,6 +80,7 @@ class LocalSource(private val context: Context) : CatalogueSource { .mapNotNull { it.listFiles()?.toList() } .flatten() .filter { it.isDirectory } + .filterNot { it.name.startsWith('.') } .filter { if (time == 0L) it.name.contains(query, ignoreCase = true) else it.lastModified() >= time } .distinctBy { it.name } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt index 7efc823b5..f5c2277ac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt @@ -6,7 +6,6 @@ import androidx.core.content.ContextCompat import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.RouterTransaction -import com.bluelinelabs.conductor.changehandler.FadeChangeHandler fun Router.popControllerWithTag(tag: String): Boolean { val controller = getControllerWithTag(tag) @@ -28,8 +27,8 @@ fun Controller.requestPermissionsSafe(permissions: Array, requestCode: I } } -fun Controller.withFadeTransaction(duration: Long = 150L): RouterTransaction { +fun Controller.withFadeTransaction(): RouterTransaction { return RouterTransaction.with(this) - .pushChangeHandler(FadeChangeHandler(duration)) - .popChangeHandler(FadeChangeHandler(duration)) + .pushChangeHandler(OneWayFadeChangeHandler()) + .popChangeHandler(OneWayFadeChangeHandler()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt index 0e487cb03..321d55c40 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/DialogController.kt @@ -14,7 +14,6 @@ import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler * A controller that displays a dialog window, floating on top of its activity's window. * This is a wrapper over [Dialog] object like [android.app.DialogFragment]. * - * * Implementations should override this class and implement [.onCreateDialog] to create a custom dialog, such as an [android.app.AlertDialog] */ abstract class DialogController : RestoreViewOnCreateController { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/OneWayFadeChangeHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/OneWayFadeChangeHandler.kt new file mode 100644 index 000000000..b1209e0b4 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/OneWayFadeChangeHandler.kt @@ -0,0 +1,43 @@ +package eu.kanade.tachiyomi.ui.base.controller + +import android.animation.Animator +import android.animation.AnimatorSet +import android.view.View +import android.view.ViewGroup +import com.bluelinelabs.conductor.ControllerChangeHandler +import com.bluelinelabs.conductor.changehandler.FadeChangeHandler + +/** + * A variation of [FadeChangeHandler] that only fades in. + */ +class OneWayFadeChangeHandler : FadeChangeHandler { + constructor() + constructor(removesFromViewOnPush: Boolean) : super(removesFromViewOnPush) + constructor(duration: Long) : super(duration) + constructor(duration: Long, removesFromViewOnPush: Boolean) : super( + duration, + removesFromViewOnPush + ) + + override fun getAnimator( + container: ViewGroup, + from: View?, + to: View?, + isPush: Boolean, + toAddedToContainer: Boolean + ): Animator { + if (to != null) { + return super.getAnimator(container, from, to, isPush, toAddedToContainer) + } + + if (from != null && (!isPush || removesFromViewOnPush())) { + container.removeView(from) + } + + return AnimatorSet() + } + + override fun copy(): ControllerChangeHandler { + return OneWayFadeChangeHandler(animationDuration, removesFromViewOnPush()) + } +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 1ce35ab00..a5829b6a7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -86,7 +86,7 @@ class MainActivity : BaseActivity() { setSupportActionBar(binding.toolbar) - tabAnimator = ViewHeightAnimator(binding.tabs) + tabAnimator = ViewHeightAnimator(binding.tabs, 0L) bottomNavAnimator = ViewHeightAnimator(binding.bottomNav) // Set behavior of bottom nav @@ -312,7 +312,7 @@ class MainActivity : BaseActivity() { } private fun setRoot(controller: Controller, id: Int) { - router.setRoot(RouterTransaction.with(controller).tag(id.toString())) + router.setRoot(controller.withFadeTransaction().tag(id.toString())) } private fun syncActivityViewWithController(to: Controller?, from: Controller? = null) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ViewHeightAnimator.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ViewHeightAnimator.kt index e76587889..ce22a9219 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/ViewHeightAnimator.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/ViewHeightAnimator.kt @@ -6,7 +6,7 @@ import android.view.ViewTreeObserver import android.view.animation.DecelerateInterpolator import androidx.annotation.Keep -class ViewHeightAnimator(val view: View) { +class ViewHeightAnimator(val view: View, val duration: Long = 250L) { /** * The default height of the view. It's unknown until the view is layout. @@ -23,7 +23,7 @@ class ViewHeightAnimator(val view: View) { */ private val animation by lazy { ObjectAnimator.ofInt(this, "height", height).apply { - duration = 250L + duration = this@ViewHeightAnimator.duration interpolator = DecelerateInterpolator() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index a3ea29a82..95ee65ce3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -494,16 +494,11 @@ class MangaPresenter( * @param chapters the chapters to delete. */ private fun deleteChaptersInternal(chapters: List) { - val filteredChapters = if (!preferences.removeBookmarkedChapters()) { - chapters.filterNot { it.bookmark } - } else { - chapters - } - - downloadManager.deleteChapters(filteredChapters, manga, source) - filteredChapters.forEach { - it.status = Download.NOT_DOWNLOADED - it.download = null + downloadManager.deleteChapters(chapters, manga, source).forEach { + if (it is ChapterItem) { + it.status = Download.NOT_DOWNLOADED + it.download = null + } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt index ed93fa3d1..f116b2600 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerTransitionHolder.kt @@ -1,9 +1,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager import android.annotation.SuppressLint -import android.graphics.Typeface -import android.text.Spanned -import android.text.style.StyleSpan import android.view.Gravity import android.view.View import android.view.ViewGroup @@ -13,6 +10,7 @@ import android.widget.LinearLayout import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.widget.AppCompatTextView +import androidx.core.text.bold import androidx.core.text.buildSpannedString import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition @@ -91,12 +89,9 @@ class PagerTransitionHolder( textView.text = if (nextChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_finished)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_finished)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_next)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_next)) } append("\n${nextChapter.chapter.name}\n\n") } } else { @@ -116,12 +111,9 @@ class PagerTransitionHolder( textView.text = if (prevChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_current)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_current)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_previous)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_previous)) } append("\n${prevChapter.chapter.name}\n\n") } } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt index b45ed13de..e220b0680 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonTransitionHolder.kt @@ -1,8 +1,5 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon -import android.graphics.Typeface -import android.text.Spanned -import android.text.style.StyleSpan import android.view.Gravity import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT @@ -11,6 +8,7 @@ import android.widget.ProgressBar import android.widget.TextView import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatTextView +import androidx.core.text.bold import androidx.core.text.buildSpannedString import androidx.core.view.isNotEmpty import androidx.core.view.isVisible @@ -94,12 +92,9 @@ class WebtoonTransitionHolder( textView.text = if (nextChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_finished)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_finished)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_next)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_next)) } append("\n${nextChapter.chapter.name}\n\n") } } else { @@ -119,12 +114,9 @@ class WebtoonTransitionHolder( textView.text = if (prevChapter != null) { buildSpannedString { - append(context.getString(R.string.transition_current)) - setSpan(StyleSpan(Typeface.BOLD), 0, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_current)) } append("\n${transition.from.chapter.name}\n\n") - val currSize = length - append(context.getString(R.string.transition_previous)) - setSpan(StyleSpan(Typeface.BOLD), currSize, length, Spanned.SPAN_INCLUSIVE_EXCLUSIVE) + bold { append(context.getString(R.string.transition_previous)) } append("\n${prevChapter.chapter.name}\n\n") } } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt index 2eaed5bd6..89b7933f9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt @@ -70,13 +70,14 @@ class WebViewActivity : BaseActivity() { if (bundle == null) { val url = intent.extras!!.getString(URL_KEY) ?: return - var headers = emptyMap() + var headers = mutableMapOf() val source = sourceManager.get(intent.extras!!.getLong(SOURCE_KEY)) as? HttpSource if (source != null) { - headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" } + headers = source.headers.toMultimap().mapValues { it.value.getOrNull(0) ?: "" }.toMutableMap() binding.webview.settings.userAgentString = source.headers["User-Agent"] } + headers["X-Requested-With"] = WebViewUtil.REQUESTED_WITH binding.webview.setDefaultSettings() @@ -100,7 +101,7 @@ class WebViewActivity : BaseActivity() { binding.webview.webViewClient = object : WebViewClientCompat() { override fun shouldOverrideUrlCompat(view: WebView, url: String): Boolean { - view.loadUrl(url) + view.loadUrl(url, headers) return true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt index b92866e46..8527c6539 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt @@ -11,6 +11,8 @@ object WebViewUtil { Regex(""".*Chrome/(\d+)\..*""") } + const val REQUESTED_WITH = "com.android.browser" + const val MINIMUM_WEBVIEW_VERSION = 80 fun supportsWebView(context: Context): Boolean { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 872a4c0b3..3f0e8822f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -337,7 +337,7 @@ Update chapter progress after reading Services - One-way sync to update the chapter progress in tracking services. Set up tracking for individual manga entries from their tracking chip. + One-way sync to update the chapter progress in tracking services. Set up tracking for individual manga entries from their tracking button. Check for extension updates diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index bb38bd7ca..9a3845cba 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -14,6 +14,14 @@ ?attr/colorOnPrimary + + + + diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index caa83dff5..738f9211c 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -47,6 +47,9 @@ ?attr/colorPrimary true false + @style/Theme.ActionMode + @style/Theme.ActionMode.CloseButton + @drawable/ic_close_24dp @style/ThemeOverlay.MaterialComponents @style/Theme.Toolbar.Navigation @style/PreferenceThemeOverlay @@ -131,6 +134,9 @@ ?attr/colorPrimary true false + @style/Theme.ActionMode + @style/Theme.ActionMode.CloseButton + @drawable/ic_close_24dp @style/ThemeOverlay.MaterialComponents.Dark.ActionBar @style/ThemeOverlay.MaterialComponents @style/Theme.Toolbar.Navigation diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 1602df39a..6b9c1f921 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -4,7 +4,7 @@ object Versions { object BuildPluginsVersion { const val AGP = "4.0.1" - const val KOTLIN = "1.3.72" + const val KOTLIN = "1.4.0" const val KTLINT = "9.2.1" const val VERSIONS_PLUGIN = "0.28.0" }