Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfe435c4f3 | ||
|
|
69e85f8b90 | ||
|
|
c9bde3c487 | ||
|
|
65e9557d9f |
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "xyz.quaver.pupil"
|
applicationId "xyz.quaver.pupil"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode 43
|
versionCode 45
|
||||||
versionName "4.7"
|
versionName "4.9"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":43,"versionName":"4.7","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":45,"versionName":"4.9","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
package xyz.quaver.pupil.adapters
|
package xyz.quaver.pupil.adapters
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -29,7 +28,6 @@ import com.bumptech.glide.Glide
|
|||||||
import com.bumptech.glide.ListPreloader
|
import com.bumptech.glide.ListPreloader
|
||||||
import com.bumptech.glide.RequestBuilder
|
import com.bumptech.glide.RequestBuilder
|
||||||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader
|
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
|
||||||
import com.crashlytics.android.Crashlytics
|
import com.crashlytics.android.Crashlytics
|
||||||
import io.fabric.sdk.android.Fabric
|
import io.fabric.sdk.android.Fabric
|
||||||
import kotlinx.android.synthetic.main.item_reader.view.*
|
import kotlinx.android.synthetic.main.item_reader.view.*
|
||||||
@@ -65,8 +63,7 @@ class ReaderAdapter(private val context: Context,
|
|||||||
override fun getPreloadRequestBuilder(item: File): RequestBuilder<*>? {
|
override fun getPreloadRequestBuilder(item: File): RequestBuilder<*>? {
|
||||||
return glide
|
return glide
|
||||||
.load(item)
|
.load(item)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
.fitCenter()
|
||||||
.skipMemoryCache(true)
|
|
||||||
.error(R.drawable.image_broken_variant)
|
.error(R.drawable.image_broken_variant)
|
||||||
.apply {
|
.apply {
|
||||||
if (BuildConfig.CENSOR)
|
if (BuildConfig.CENSOR)
|
||||||
@@ -115,7 +112,7 @@ class ReaderAdapter(private val context: Context,
|
|||||||
|
|
||||||
if (!isFullScreen)
|
if (!isFullScreen)
|
||||||
(holder.view.container.layoutParams as ConstraintLayout.LayoutParams)
|
(holder.view.container.layoutParams as ConstraintLayout.LayoutParams)
|
||||||
.dimensionRatio = "${reader!!.galleryInfo.files[position].width}:${reader!!.galleryInfo.files[position].height}"
|
.dimensionRatio = "W,${reader!!.galleryInfo.files[position].width}:${reader!!.galleryInfo.files[position].height}"
|
||||||
|
|
||||||
holder.view.reader_index.text = (position+1).toString()
|
holder.view.reader_index.text = (position+1).toString()
|
||||||
|
|
||||||
@@ -124,34 +121,19 @@ class ReaderAdapter(private val context: Context,
|
|||||||
|
|
||||||
if (progress?.isInfinite() == true && images != null) {
|
if (progress?.isInfinite() == true && images != null) {
|
||||||
holder.view.reader_item_progressbar.visibility = View.INVISIBLE
|
holder.view.reader_item_progressbar.visibility = View.INVISIBLE
|
||||||
holder.view.container.apply {
|
|
||||||
val options = BitmapFactory.Options().apply {
|
|
||||||
inJustDecodeBounds = true
|
|
||||||
}
|
|
||||||
|
|
||||||
BitmapFactory.decodeFile(images.canonicalPath, options)
|
holder.view.image.post {
|
||||||
|
glide
|
||||||
maxWidth = options.outWidth
|
.load(images)
|
||||||
maxHeight = options.outHeight
|
.fitCenter()
|
||||||
|
.error(R.drawable.image_broken_variant)
|
||||||
|
.into(holder.view.image)
|
||||||
}
|
}
|
||||||
|
|
||||||
glide
|
|
||||||
.load(images)
|
|
||||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
|
||||||
.skipMemoryCache(true)
|
|
||||||
.dontTransform()
|
|
||||||
.error(R.drawable.image_broken_variant)
|
|
||||||
.apply {
|
|
||||||
if (BuildConfig.CENSOR)
|
|
||||||
override(5, 8)
|
|
||||||
}
|
|
||||||
.into(holder.view.image)
|
|
||||||
} else {
|
} else {
|
||||||
holder.view.reader_item_progressbar.visibility = View.VISIBLE
|
holder.view.reader_item_progressbar.visibility = View.VISIBLE
|
||||||
holder.view.container.apply {
|
|
||||||
maxWidth = Integer.MAX_VALUE
|
glide.clear(holder.view.image)
|
||||||
maxHeight = Integer.MAX_VALUE
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress?.isNaN() == true) {
|
if (progress?.isNaN() == true) {
|
||||||
if (Fabric.isInitialized())
|
if (Fabric.isInitialized())
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import xyz.quaver.Code
|
|||||||
import xyz.quaver.hitomi.GalleryBlock
|
import xyz.quaver.hitomi.GalleryBlock
|
||||||
import xyz.quaver.hitomi.Reader
|
import xyz.quaver.hitomi.Reader
|
||||||
import xyz.quaver.proxy
|
import xyz.quaver.proxy
|
||||||
|
import xyz.quaver.pupil.util.copyRecursively
|
||||||
import xyz.quaver.pupil.util.getCachedGallery
|
import xyz.quaver.pupil.util.getCachedGallery
|
||||||
import xyz.quaver.pupil.util.getDownloadDirectory
|
import xyz.quaver.pupil.util.getDownloadDirectory
|
||||||
import xyz.quaver.pupil.util.json
|
import xyz.quaver.pupil.util.json
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.os.storage.StorageManager
|
|||||||
import android.provider.DocumentsContract
|
import android.provider.DocumentsContract
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import kotlinx.io.IOException
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.lang.reflect.Array
|
import java.lang.reflect.Array
|
||||||
@@ -212,3 +213,65 @@ fun Uri.toFile(context: Context): File? {
|
|||||||
|
|
||||||
return File(context.getExternalFilesDir(null)?.canonicalPath?.substringBeforeLast("/Android/data") ?: return null, folderName)
|
return File(context.getExternalFilesDir(null)?.canonicalPath?.substringBeforeLast("/Android/data") ?: return null, folderName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun File.copyRecursively(
|
||||||
|
target: File,
|
||||||
|
overwrite: Boolean = false,
|
||||||
|
onError: (File, IOException) -> OnErrorAction = { _, exception -> throw exception }
|
||||||
|
): Boolean {
|
||||||
|
if (!exists()) {
|
||||||
|
return onError(this, NoSuchFileException(file = this, reason = "The source file doesn't exist.")) !=
|
||||||
|
OnErrorAction.TERMINATE
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// We cannot break for loop from inside a lambda, so we have to use an exception here
|
||||||
|
for (src in walkTopDown().onFail { f, e -> if (onError(f, e) == OnErrorAction.TERMINATE) throw IOException("Walk failed") }) {
|
||||||
|
if (!src.exists()) {
|
||||||
|
if (onError(src, NoSuchFileException(file = src, reason = "The source file doesn't exist.")) ==
|
||||||
|
OnErrorAction.TERMINATE)
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
val relPath = src.toRelativeString(this)
|
||||||
|
val dstFile = File(target, relPath)
|
||||||
|
if (dstFile.exists() && !(src.isDirectory && dstFile.isDirectory)) {
|
||||||
|
val stillExists = if (!overwrite) true else {
|
||||||
|
if (dstFile.isDirectory)
|
||||||
|
!dstFile.deleteRecursively()
|
||||||
|
else
|
||||||
|
!dstFile.delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stillExists) {
|
||||||
|
if (onError(dstFile, FileAlreadyExistsException(file = src,
|
||||||
|
other = dstFile,
|
||||||
|
reason = "The destination file already exists.")) == OnErrorAction.TERMINATE)
|
||||||
|
return false
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (src.isDirectory) {
|
||||||
|
dstFile.mkdirs()
|
||||||
|
} else {
|
||||||
|
val length = try {
|
||||||
|
src.copyTo(dstFile, overwrite).length()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
if (onError(src, e) == OnErrorAction.TERMINATE)
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
-1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (length != src.length()) {
|
||||||
|
if (onError(src, IOException("Source file wasn't copied completely, length of destination file differs.")) == OnErrorAction.TERMINATE)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} catch (e: IOException) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,8 +25,9 @@
|
|||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintHeight_max="2000dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
@@ -63,11 +64,12 @@
|
|||||||
|
|
||||||
<com.github.chrisbanes.photoview.PhotoView
|
<com.github.chrisbanes.photoview.PhotoView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:contentDescription="@string/reader_imageview_description"
|
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
android:paddingBottom="8dp"/>
|
android:paddingBottom="8dp"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user