Merge branch 'dev' into dev-settings-search

This commit is contained in:
mpm11011 2020-08-26 21:00:21 -04:00 committed by GitHub
commit b10b13a339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 113 additions and 82 deletions

View File

@ -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"

View File

@ -23,21 +23,6 @@
<init>();
}
# 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.**

View File

@ -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<Chapter>, manga: Manga, source: Source) {
queue.remove(chapters)
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source): List<Chapter> {
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<Chapter>, 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<Chapter>): List<Chapter> {
return if (!preferences.removeBookmarkedChapters()) {
chapters.filterNot { it.bookmark }
} else {
chapters
}
}
}

View File

@ -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)

View File

@ -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 }

View File

@ -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<String>, 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())
}

View File

@ -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 {

View File

@ -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())
}
}

View File

@ -86,7 +86,7 @@ class MainActivity : BaseActivity<MainActivityBinding>() {
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<MainActivityBinding>() {
}
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) {

View File

@ -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()
}
}

View File

@ -494,16 +494,11 @@ class MangaPresenter(
* @param chapters the chapters to delete.
*/
private fun deleteChaptersInternal(chapters: List<ChapterItem>) {
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
}
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -70,13 +70,14 @@ class WebViewActivity : BaseActivity<WebviewActivityBinding>() {
if (bundle == null) {
val url = intent.extras!!.getString(URL_KEY) ?: return
var headers = emptyMap<String, String>()
var headers = mutableMapOf<String, String>()
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<WebviewActivityBinding>() {
binding.webview.webViewClient = object : WebViewClientCompat() {
override fun shouldOverrideUrlCompat(view: WebView, url: String): Boolean {
view.loadUrl(url)
view.loadUrl(url, headers)
return true
}

View File

@ -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 {

View File

@ -337,7 +337,7 @@
<!-- Tracking section -->
<string name="pref_auto_update_manga_sync">Update chapter progress after reading</string>
<string name="services">Services</string>
<string name="tracking_info">One-way sync to update the chapter progress in tracking services. Set up tracking for individual manga entries from their tracking chip.</string>
<string name="tracking_info">One-way sync to update the chapter progress in tracking services. Set up tracking for individual manga entries from their tracking button.</string>
<!-- Browse section -->
<string name="pref_enable_automatic_extension_updates">Check for extension updates</string>

View File

@ -14,6 +14,14 @@
<item name="tint">?attr/colorOnPrimary</item>
</style>
<style name="Theme.ActionMode" parent="Base.Widget.AppCompat.ActionMode">
<item name="background">?attr/colorPrimary</item>
</style>
<style name="Theme.ActionMode.CloseButton" parent="Base.Widget.AppCompat.ActionButton.CloseMode">
<item name="android:tint">?attr/colorOnPrimary</item>
</style>
<!--===========-->
<!--AlertDialog-->

View File

@ -47,6 +47,9 @@
<item name="android:navigationBarColor">?attr/colorPrimary</item>
<item name="windowActionModeOverlay">true</item>
<item name="elevationOverlayEnabled">false</item>
<item name="actionModeStyle">@style/Theme.ActionMode</item>
<item name="actionModeCloseButtonStyle">@style/Theme.ActionMode.CloseButton</item>
<item name="actionModeCloseDrawable">@drawable/ic_close_24dp</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents</item>
<item name="toolbarNavigationButtonStyle">@style/Theme.Toolbar.Navigation</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
@ -131,6 +134,9 @@
<item name="android:navigationBarColor">?attr/colorPrimary</item>
<item name="windowActionModeOverlay">true</item>
<item name="elevationOverlayEnabled">false</item>
<item name="actionModeStyle">@style/Theme.ActionMode</item>
<item name="actionModeCloseButtonStyle">@style/Theme.ActionMode.CloseButton</item>
<item name="actionModeCloseDrawable">@drawable/ic_close_24dp</item>
<item name="actionBarTheme">@style/ThemeOverlay.MaterialComponents.Dark.ActionBar</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents</item>
<item name="toolbarNavigationButtonStyle">@style/Theme.Toolbar.Navigation</item>

View File

@ -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"
}