Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbWatershed committed Oct 31, 2024
2 parents dcde3a2 + 04d23a0 commit ebbacaa
Show file tree
Hide file tree
Showing 90 changed files with 1,721 additions and 1,910 deletions.
20 changes: 7 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ android {
minSdkVersion 26
targetSdkVersion 35
versionCode 130 // is updated automatically by BitRise; only used when building locally
versionName '1.20.0'
versionName '1.20.1'

def includeObjectBoxBrowser = System.getenv("INCLUDE_OBJECTBOX_BROWSER") ?: "false"
def includeLeakCanary = System.getenv("INCLUDE_LEAK_CANARY") ?: "false"
Expand Down Expand Up @@ -155,25 +155,19 @@ dependencies {
/**
* MEDIA
*/
// Image loader: github.com/bumptech/glide
def glide_version = '4.16.0'
implementation "com.github.bumptech.glide:glide:$glide_version"
ksp "com.github.bumptech.glide:ksp:$glide_version"
implementation("com.github.bumptech.glide:okhttp3-integration:$glide_version") {
exclude group: 'glide-parent'
}
// Image loader and animated pics support -> https://github.com/coil-kt/coil
implementation("io.coil-kt.coil3:coil:3.0.0-rc01")
implementation("io.coil-kt.coil3:coil-network-okhttp:3.0.0-rc01")
implementation("io.coil-kt.coil3:coil-gif:3.0.0-rc01")

// Animated pics support (APNG, AWEBP and GIF) -> https://github.com/penfeizhou/APNG4Android
// Animated pics that Coil doesn't support (APNG) -> https://github.com/penfeizhou/APNG4Android
def APNG4Android_version = '3.0.1'
implementation "com.github.penfeizhou.android.animation:apng:$APNG4Android_version"
implementation "com.github.penfeizhou.android.animation:gif:$APNG4Android_version"
implementation "com.github.penfeizhou.android.animation:awebp:$APNG4Android_version"
implementation "com.github.penfeizhou.android.animation:glide-plugin:$APNG4Android_version"

// Animated GIF creator -> https://github.com/waynejo/android-ndk-gif
implementation 'io.github.waynejo:androidndkgif:1.0.1'

// PDF creator
// PDF creator/extractor
implementation 'com.itextpdf:itext7-core:8.0.5'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ open class CustomSubsamplingScaleImageView(context: Context, attr: AttributeSet?
* @param previewSource Optional source for a preview image to be displayed and allow interaction while the full size image loads.
* @param state State to be restored. Nullable.
*/
fun setImage(imageSource: ImageSource, previewSource: ImageSource?, state: ImageViewState?) {
private fun setImage(imageSource: ImageSource, previewSource: ImageSource?, state: ImageViewState?) {
reset(true)
if (state != null) restoreState(state)
val targetScale = if ((null == state)) 1f else getVirtualScale()
Expand All @@ -575,7 +575,6 @@ open class CustomSubsamplingScaleImageView(context: Context, attr: AttributeSet?
Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + context.packageName + "/" + previewSource.getResource())
}
if (previewSourceUri != null) {

lifecycleScope?.launch {
try {
val bmp = withContext(Dispatchers.IO) {
Expand Down Expand Up @@ -2090,10 +2089,10 @@ open class CustomSubsamplingScaleImageView(context: Context, attr: AttributeSet?
tile: Tile
): Tile {
assertNonUiThread()
if (decoder.isReady && tile.visible) {
if (decoder.isReady() && tile.visible) {
view.decoderLock.readLock().lock()
try {
if (decoder.isReady) {
if (decoder.isReady()) {
tile.loading = true
// Update tile's file sRect according to rotation
tile.sRect?.let { sRect ->
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.devsaki.hentoid.customssiv.decoder

import android.content.Context
import android.graphics.Bitmap
import android.net.Uri

/**
* Interface for image decoding classes, allowing the default {@link android.graphics.BitmapFactory}
* based on the Skia library to be replaced with a custom class.
*/
interface ImageDecoder {
/**
* Decode an image. The URI can be in one of the following formats:
* <br></br>
* File: `file:///scard/picture.jpg`
* <br></br>
* Asset: `file:///android_asset/picture.png`
* <br></br>
* Resource: `android.resource://com.example.app/drawable/picture`
*
* @param context Application context
* @param uri URI of the image
* @return the decoded bitmap
* @throws Exception if decoding fails.
*/
@Throws(Exception::class)
fun decode(context: Context, uri: Uri): Bitmap
}
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
package me.devsaki.hentoid.customssiv.decoder;
package me.devsaki.hentoid.customssiv.decoder

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.net.Uri;

import androidx.annotation.NonNull;
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Point
import android.graphics.Rect
import android.net.Uri

/**
* Interface for image decoding classes, allowing the default {@link android.graphics.BitmapRegionDecoder}
* based on the Skia library to be replaced with a custom class.
*/
public interface ImageRegionDecoder {

interface ImageRegionDecoder {
/**
* Initialise the decoder. When possible, perform initial setup work once in this method. The
* dimensions of the image must be returned. The URI can be in one of the following formats:
* <br>
* File: <code>file:///scard/picture.jpg</code>
* <br>
* Asset: <code>file:///android_asset/picture.png</code>
* <br>
* Resource: <code>android.resource://com.example.app/drawable/picture</code>
* <br></br>
* File: `file:///scard/picture.jpg`
* <br></br>
* Asset: `file:///android_asset/picture.png`
* <br></br>
* Resource: `android.resource://com.example.app/drawable/picture`
* @param context Application context. A reference may be held, but must be cleared on recycle.
* @param uri URI of the image.
* @return Dimensions of the image.
* @throws Exception if initialisation fails.
*/
@NonNull
Point init(Context context, @NonNull Uri uri) throws Exception;
@Throws(Exception::class)
fun init(context: Context, uri: Uri): Point

/**
* <p>
*
*
* Decode a region of the image with the given sample size. This method is called off the UI
* thread so it can safely load the image on the current thread. It is called from
* {@link android.os.AsyncTask}s running in an executor that may have multiple threads, so
* implementations must be thread safe. Adding <code>synchronized</code> to the method signature
* is the simplest way to achieve this, but bear in mind the {@link #recycle()} method can be
* [android.os.AsyncTask]s running in an executor that may have multiple threads, so
* implementations must be thread safe. Adding `synchronized` to the method signature
* is the simplest way to achieve this, but bear in mind the [.recycle] method can be
* called concurrently.
* </p><p>
* See {@link SkiaImageRegionDecoder} and {@link SkiaPooledImageRegionDecoder} for examples of
*
*
* See [SkiaImageRegionDecoder] and [SkiaPooledImageRegionDecoder] for examples of
* internal locking and synchronization.
* </p>
*
* @param sRect Source image rectangle to decode.
* @param sampleSize Sample size.
* @return The decoded region. It is safe to return null if decoding fails.
*/
@NonNull
Bitmap decodeRegion(@NonNull Rect sRect, int sampleSize);
fun decodeRegion(sRect: Rect, sampleSize: Int): Bitmap

/**
* Status check. Should return false before initialisation and after recycle.
* @return true if the decoder is ready to be used.
*/
boolean isReady();
fun isReady(): Boolean

/**
* This method will be called when the decoder is no longer required. It should clean up any resources still in use.
*/
void recycle();

fun recycle()
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package me.devsaki.hentoid.customssiv.decoder

import android.content.Context
import android.content.pm.PackageManager
import android.content.res.Resources
import android.net.Uri
import android.text.TextUtils

@Throws(PackageManager.NameNotFoundException::class)
fun getResourceId(context: Context, uri: Uri): Int {
val res: Resources
val packageName = uri.authority
if (context.packageName == packageName) {
res = context.resources
} else {
val pm = context.packageManager
res = pm.getResourcesForApplication(packageName!!)
}

var result = 0
val segments = uri.pathSegments
val size = segments.size
if (size == 2 && segments[0] == "drawable") {
val resName = segments[1]
result = res.getIdentifier(resName, "drawable", packageName)
} else if (size == 1 && TextUtils.isDigitsOnly(segments[0])) {
try {
result = segments[0].toInt()
} catch (ignored: NumberFormatException) {
// Ignored exception
}
}

return result
}
Loading

0 comments on commit ebbacaa

Please sign in to comment.