Skip to content

Commit

Permalink
update gradle and AGP, add heif/avif support
Browse files Browse the repository at this point in the history
  • Loading branch information
az4521 committed Feb 17, 2024
1 parent 1fee512 commit 12bb79d
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 39 deletions.
8 changes: 5 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ext {
}

android {
compileSdkVersion 31
compileSdkVersion 33
publishNonDefault true

defaultConfig {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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.** { *; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,18 @@ class PagerPageHolder(
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
onImageDecodeError()
return false
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
target: Target<Drawable>?,
dataSource: DataSource?,
resource: Drawable,
model: Any,
target: Target<Drawable>,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
if (resource is GifDrawable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,18 @@ class WebtoonPageHolder(
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
onImageDecodeError()
return false
}

override fun onResourceReady(
resource: Drawable?,
model: Any?,
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
if (resource is GifDrawable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down
35 changes: 31 additions & 4 deletions app/src/main/java/eu/kanade/tachiyomi/util/system/ImageUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ByteArray>): 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) {
Expand All @@ -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 -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fun WebView.setDefaultSettings() {
javaScriptEnabled = true
domStorageEnabled = true
databaseEnabled = true
setAppCacheEnabled(true)
useWideViewPort = true
loadWithOverviewMode = true
cacheMode = WebSettings.LOAD_DEFAULT
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/video_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
android:layout_height="match_parent"
android:gravity="center">

<!--
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
-->

</FrameLayout>
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 12bb79d

Please sign in to comment.