From 12bb79d07e4f54a2ca35403c82d6f484b3d7fe43 Mon Sep 17 00:00:00 2001 From: az4521 <18432684+az4521@users.noreply.github.com> Date: Sat, 17 Feb 2024 03:36:00 +0000 Subject: [PATCH] update gradle and AGP, add heif/avif support --- app/build.gradle | 8 +++-- app/proguard-rules.pro | 1 + .../tachiyomi/ui/library/LibraryController.kt | 4 +-- .../ui/manga/chapter/ChaptersController.kt | 4 +-- .../ui/migration/SearchController.kt | 4 +-- .../manga/process/MigrationListController.kt | 4 +-- .../ui/reader/viewer/ReaderProgressBar.kt | 4 +-- .../ui/reader/viewer/pager/PagerPageHolder.kt | 10 +++--- .../ui/reader/viewer/webtoon/WebtoonFrame.kt | 8 ++--- .../viewer/webtoon/WebtoonPageHolder.kt | 8 ++--- .../source/browse/BrowseSourceController.kt | 6 ++-- .../globalsearch/GlobalSearchController.kt | 4 +-- .../kanade/tachiyomi/util/system/ImageUtil.kt | 35 ++++++++++++++++--- .../tachiyomi/util/system/WebViewUtil.kt | 1 - app/src/main/res/layout/video_activity.xml | 2 ++ buildSrc/src/main/kotlin/Dependencies.kt | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +-- 17 files changed, 70 insertions(+), 39 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2bcc0fa3d37a..d12457fe3a81 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -36,7 +36,7 @@ ext { } android { - compileSdkVersion 31 + compileSdkVersion 33 publishNonDefault true defaultConfig { @@ -148,7 +148,7 @@ kapt { dependencies { // Anime dependencies (AZ) - implementation 'com.google.android.exoplayer:exoplayer:2.12.2' + //implementation 'com.google.android.exoplayer:exoplayer:2.12.2' // Modified dependencies @@ -255,10 +255,12 @@ dependencies { implementation "com.github.inorichi.injekt:injekt-core:65b0440" // Image library - final glide_version = '4.10.0' + final glide_version = '4.16.0' implementation "com.github.bumptech.glide:glide:$glide_version" + implementation "com.github.bumptech.glide:avif-integration:$glide_version" implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version" kapt "com.github.bumptech.glide:compiler:$glide_version" + implementation "com.github.tachiyomiorg:image-decoder:fbd6601290" //for some exts // Logging implementation 'com.jakewharton.timber:timber:4.7.1' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 44b5ab621d0d..9a4342d43c06 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -15,6 +15,7 @@ -keep,allowoptimization class kotlinx.serialization.** { *; } -keep,allowoptimization class kotlinx.coroutines.** { public protected *; } -keep,allowoptimization class kotlin.time.** { public protected *; } +-keep,allowoptimization class tachiyomi.decoder.** { *; } # === Keep EH classes -keep class exh.** { *; } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index ae1828f22648..da2521daadd6 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -415,7 +415,7 @@ class LibraryController( searchItem.fixExpand(onExpand = { invalidateMenuOnExpand() }) // Mutate the filter icon because it needs to be tinted and the resource is shared. - menu.findItem(R.id.action_filter).icon.mutate() + menu.findItem(R.id.action_filter).icon?.mutate() menu.findItem(R.id.action_sync_favorites).isVisible = preferences.eh_isHentaiEnabled().get() } @@ -432,7 +432,7 @@ class LibraryController( // Tint icon if there's a filter active if (navView.hasActiveFilters()) { val filterColor = activity!!.getResourceColor(R.attr.colorFilterActive) - DrawableCompat.setTint(filterItem.icon, filterColor) + filterItem.icon?.let { DrawableCompat.setTint(it, filterColor) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt index 333c11c824cb..b97a4b32264d 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChaptersController.kt @@ -117,7 +117,7 @@ class ChaptersController : if (item != null) { // Create animation listener val revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { + override fun onAnimationStart(animation: Animator) { openChapter(item.chapter, true) } } @@ -183,7 +183,7 @@ class ChaptersController : if (filterSet) { val filterColor = activity!!.getResourceColor(R.attr.colorFilterActive) - DrawableCompat.setTint(menu.findItem(R.id.action_filter).icon, filterColor) + menu.findItem(R.id.action_filter).icon?.let { DrawableCompat.setTint(it, filterColor) } } // Only show remove filter option if there's a filter set. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt index d24187c6d826..a6e4b116d2dd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/SearchController.kt @@ -176,13 +176,13 @@ class SearchController( val searchView = searchItem.actionView as SearchView searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener { - override fun onMenuItemActionExpand(item: MenuItem?): Boolean { + override fun onMenuItemActionExpand(item: MenuItem): Boolean { searchView.onActionViewExpanded() // Required to show the query in the view searchView.setQuery(presenter.query, false) return true } - override fun onMenuItemActionCollapse(item: MenuItem?): Boolean { + override fun onMenuItemActionCollapse(item: MenuItem): Boolean { return true } }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt index 9b7fd16e3611..55ff57991db0 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/process/MigrationListController.kt @@ -486,8 +486,8 @@ class MigrationListController(bundle: Bundle? = null) : ) } - menuCopy.icon.mutate() - menuMigrate.icon.mutate() + menuCopy.icon?.mutate() + menuMigrate.icon?.mutate() val tintColor = activity?.getResourceColor(R.attr.colorOnPrimary) ?: Color.WHITE val translucentWhite = ColorUtils.setAlphaComponent(tintColor, 127) menuCopy.icon?.setTint(if (allMangasDone) tintColor else translucentWhite) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt index 9b6eed602ba7..c3c9fda920b0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ReaderProgressBar.kt @@ -163,12 +163,12 @@ class ReaderProgressBar @JvmOverloads constructor( interpolator = DecelerateInterpolator() duration = 1000 addListener(object : AnimatorListenerAdapter() { - override fun onAnimationEnd(animation: Animator?) { + override fun onAnimationEnd(animation: Animator) { gone() alpha = 1f } - override fun onAnimationCancel(animation: Animator?) { + override fun onAnimationCancel(animation: Animator) { alpha = 1f } }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt index 6d5147532ae2..e1da1c6133a5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerPageHolder.kt @@ -491,7 +491,7 @@ class PagerPageHolder( override fun onLoadFailed( e: GlideException?, model: Any?, - target: Target?, + target: Target, isFirstResource: Boolean ): Boolean { onImageDecodeError() @@ -499,10 +499,10 @@ class PagerPageHolder( } override fun onResourceReady( - resource: Drawable?, - model: Any?, - target: Target?, - dataSource: DataSource?, + resource: Drawable, + model: Any, + target: Target, + dataSource: DataSource, isFirstResource: Boolean ): Boolean { if (resource is GifDrawable) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt index 3f919569ca54..b80c16fdec19 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt @@ -44,7 +44,7 @@ class WebtoonFrame(context: Context) : FrameLayout(context) { * Scale listener used to delegate events to the recycler view. */ inner class ScaleListener : ScaleGestureDetector.SimpleOnScaleGestureListener() { - override fun onScaleBegin(detector: ScaleGestureDetector?): Boolean { + override fun onScaleBegin(detector: ScaleGestureDetector): Boolean { recycler?.onScaleBegin() return true } @@ -63,13 +63,13 @@ class WebtoonFrame(context: Context) : FrameLayout(context) { * Fling listener used to delegate events to the recycler view. */ inner class FlingListener : GestureDetector.SimpleOnGestureListener() { - override fun onDown(e: MotionEvent?): Boolean { + override fun onDown(e: MotionEvent): Boolean { return true } override fun onFling( - e1: MotionEvent?, - e2: MotionEvent?, + e1: MotionEvent, + e2: MotionEvent, velocityX: Float, velocityY: Float ): Boolean { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt index 384cc978d4e1..3122bdf0689b 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonPageHolder.kt @@ -497,7 +497,7 @@ class WebtoonPageHolder( override fun onLoadFailed( e: GlideException?, model: Any?, - target: Target?, + target: Target, isFirstResource: Boolean ): Boolean { onImageDecodeError() @@ -505,10 +505,10 @@ class WebtoonPageHolder( } override fun onResourceReady( - resource: Drawable?, - model: Any?, + resource: Drawable, + model: Any, target: Target?, - dataSource: DataSource?, + dataSource: DataSource, isFirstResource: Boolean ): Boolean { if (resource is GifDrawable) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt index f6447339e1ac..3c854053eddb 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceController.kt @@ -376,13 +376,13 @@ open class BrowseSourceController(bundle: Bundle) : // Setup filters button menu.findItem(R.id.action_set_filter).apply { - icon.mutate() + icon?.mutate() if (presenter.sourceFilters.isEmpty()) { // isEnabled = false [EXH] - icon.alpha = 128 + icon?.alpha = 128 } else { // isEnabled = true [EXH] - icon.alpha = 255 + icon?.alpha = 255 } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/globalsearch/GlobalSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/globalsearch/GlobalSearchController.kt index d8320eab9c01..caac605dddf0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/globalsearch/GlobalSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/globalsearch/GlobalSearchController.kt @@ -112,13 +112,13 @@ open class GlobalSearchController( searchView.maxWidth = Int.MAX_VALUE searchItem.setOnActionExpandListener(object : MenuItem.OnActionExpandListener { - override fun onMenuItemActionExpand(item: MenuItem?): Boolean { + override fun onMenuItemActionExpand(item: MenuItem): Boolean { searchView.onActionViewExpanded() // Required to show the query in the view searchView.setQuery(presenter.query, false) return true } - override fun onMenuItemActionCollapse(item: MenuItem?): Boolean { + override fun onMenuItemActionCollapse(item: MenuItem): Boolean { return true } }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt index 85bb61e01081..b1763008bc7f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt @@ -53,18 +53,43 @@ object ImageUtil { if (bytes.compareWith("RIFF".toByteArray())) { return ImageType.WEBP } - } catch (e: Exception) { + if (bytes.compareWith("ftyp".toByteArray(), 4)) { + if (bytes.compareWith("avi".toByteArray(), 8)) { + return ImageType.AVIF + } else if (bytes.getSlice(8, 4).comparesWithAnyOf( + listOf( + "hei".toByteArray(), + "mif1".toByteArray(), + "hev".toByteArray() + ) + ) + ) { + return ImageType.HEIF + } + } + } catch (_: Exception) { } return null } - private fun ByteArray.compareWith(magic: ByteArray): Boolean { + private fun ByteArray.comparesWithAnyOf(magics: List): Boolean { + for (x in magics) { + if (this.compareWith(x)) { + return true + } + } + return false + } + private fun ByteArray.compareWith(magic: ByteArray, offset: Int = 0): Boolean { for (i in magic.indices) { - if (this[i] != magic[i]) return false + if (this[i + offset] != magic[i]) return false } return true } + private fun ByteArray.getSlice(offset: Int, length: Int): ByteArray { + return this.slice(IntRange(offset, offset + length - 1)).toByteArray() + } private fun charByteArrayOf(vararg bytes: Int): ByteArray { return ByteArray(bytes.size).apply { for (i in bytes.indices) { @@ -77,7 +102,9 @@ object ImageUtil { JPG("image/jpeg", "jpg"), PNG("image/png", "png"), GIF("image/gif", "gif"), - WEBP("image/webp", "webp") + WEBP("image/webp", "webp"), + HEIF("image/heif", "heif"), + AVIF("image/avif", "avif"), } // SY --> 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 892918f23d16..d0ca441f356a 100755 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewUtil.kt @@ -37,7 +37,6 @@ fun WebView.setDefaultSettings() { javaScriptEnabled = true domStorageEnabled = true databaseEnabled = true - setAppCacheEnabled(true) useWideViewPort = true loadWithOverviewMode = true cacheMode = WebSettings.LOAD_DEFAULT diff --git a/app/src/main/res/layout/video_activity.xml b/app/src/main/res/layout/video_activity.xml index f58edda06a5a..3cb80c4c15af 100755 --- a/app/src/main/res/layout/video_activity.xml +++ b/app/src/main/res/layout/video_activity.xml @@ -6,9 +6,11 @@ android:layout_height="match_parent" android:gravity="center"> + \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 9806e2f3c442..654601e3b7e0 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -3,7 +3,7 @@ object Versions { } object BuildPluginsVersion { - const val AGP = "4.0.1" + const val AGP = "7.4.2" const val KOTLIN = "1.9.22" const val KTLINT = "9.2.1" const val VERSIONS_PLUGIN = "0.28.0" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d8b5be72ce97..87e0eb368957 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Jan 15 21:00:55 EST 2024 +#Fri Feb 16 20:29:34 EST 2024 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME