fixed gallery import
This commit is contained in:
@@ -5,7 +5,7 @@ apply plugin: "kotlin-android-extensions"
|
|||||||
apply plugin: "kotlinx-serialization"
|
apply plugin: "kotlinx-serialization"
|
||||||
apply plugin: "com.google.android.gms.oss-licenses-plugin"
|
apply plugin: "com.google.android.gms.oss-licenses-plugin"
|
||||||
|
|
||||||
if (file("google-services.json").exists()) {
|
if (file("google-services.json").exists() && file("src/debug/google-services.json").exists()) {
|
||||||
logger.lifecycle("Firebase Enabled")
|
logger.lifecycle("Firebase Enabled")
|
||||||
apply plugin: "com.google.gms.google-services"
|
apply plugin: "com.google.gms.google-services"
|
||||||
apply plugin: "com.google.firebase.crashlytics"
|
apply plugin: "com.google.firebase.crashlytics"
|
||||||
@@ -38,7 +38,7 @@ android {
|
|||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 63
|
versionCode 63
|
||||||
versionName "5.1.7"
|
versionName "5.1.6-hotfix7-alpha5"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
@@ -77,8 +77,8 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
|
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.0"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1"
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0"
|
||||||
|
|
||||||
implementation "androidx.appcompat:appcompat:1.2.0"
|
implementation "androidx.appcompat:appcompat:1.2.0"
|
||||||
implementation "androidx.activity:activity-ktx:1.2.0-beta01"
|
implementation "androidx.activity:activity-ktx:1.2.0-beta01"
|
||||||
@@ -96,8 +96,8 @@ dependencies {
|
|||||||
|
|
||||||
implementation "com.google.firebase:firebase-core:18.0.0"
|
implementation "com.google.firebase:firebase-core:18.0.0"
|
||||||
implementation "com.google.firebase:firebase-analytics:18.0.0"
|
implementation "com.google.firebase:firebase-analytics:18.0.0"
|
||||||
implementation "com.google.firebase:firebase-crashlytics:17.3.0"
|
implementation "com.google.firebase:firebase-crashlytics:17.2.2"
|
||||||
implementation "com.google.firebase:firebase-perf:19.0.10"
|
implementation "com.google.firebase:firebase-perf:19.0.9"
|
||||||
|
|
||||||
implementation "com.google.android.gms:play-services-oss-licenses:17.0.0"
|
implementation "com.google.android.gms:play-services-oss-licenses:17.0.0"
|
||||||
implementation "com.google.android.gms:play-services-mlkit-face-detection:16.1.1"
|
implementation "com.google.android.gms:play-services-mlkit-face-detection:16.1.1"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"versionCode": 63,
|
"versionCode": 63,
|
||||||
"versionName": "5.1.6-hotfix7",
|
"versionName": "5.1.6-hotfix7-alpha5",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ import xyz.quaver.pupil.util.ellipsize
|
|||||||
import xyz.quaver.pupil.util.normalizeID
|
import xyz.quaver.pupil.util.normalizeID
|
||||||
import xyz.quaver.pupil.util.requestBuilders
|
import xyz.quaver.pupil.util.requestBuilders
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import kotlin.math.ceil
|
import kotlin.math.ceil
|
||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
@@ -203,6 +202,8 @@ class DownloadService : Service() {
|
|||||||
private val callback = object: Callback {
|
private val callback = object: Callback {
|
||||||
|
|
||||||
override fun onFailure(call: Call, e: IOException) {
|
override fun onFailure(call: Call, e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
|
||||||
if (e.message?.contains("cancel", true) == false) {
|
if (e.message?.contains("cancel", true) == false) {
|
||||||
val galleryID = (call.request().tag() as Tag).galleryID
|
val galleryID = (call.request().tag() as Tag).galleryID
|
||||||
|
|
||||||
@@ -235,6 +236,7 @@ class DownloadService : Service() {
|
|||||||
startId?.let { stopSelf(it) }
|
startId?.let { stopSelf(it) }
|
||||||
}
|
}
|
||||||
}.onFailure {
|
}.onFailure {
|
||||||
|
it.printStackTrace()
|
||||||
cancel(galleryID)
|
cancel(galleryID)
|
||||||
download(galleryID)
|
download(galleryID)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ import xyz.quaver.pupil.R
|
|||||||
import xyz.quaver.pupil.adapters.GalleryBlockAdapter
|
import xyz.quaver.pupil.adapters.GalleryBlockAdapter
|
||||||
import xyz.quaver.pupil.adapters.ThumbnailPageAdapter
|
import xyz.quaver.pupil.adapters.ThumbnailPageAdapter
|
||||||
import xyz.quaver.pupil.favoriteTags
|
import xyz.quaver.pupil.favoriteTags
|
||||||
import xyz.quaver.pupil.histories
|
|
||||||
import xyz.quaver.pupil.types.Tag
|
import xyz.quaver.pupil.types.Tag
|
||||||
import xyz.quaver.pupil.ui.ReaderActivity
|
import xyz.quaver.pupil.ui.ReaderActivity
|
||||||
import xyz.quaver.pupil.ui.view.TagChip
|
import xyz.quaver.pupil.ui.view.TagChip
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.*
|
||||||
import kotlinx.serialization.json.jsonArray
|
|
||||||
import kotlinx.serialization.json.jsonObject
|
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import xyz.quaver.Code
|
import xyz.quaver.Code
|
||||||
@@ -137,4 +135,7 @@ operator fun JsonElement.get(index: Int) =
|
|||||||
this.jsonArray[index]
|
this.jsonArray[index]
|
||||||
|
|
||||||
operator fun JsonElement.get(tag: String) =
|
operator fun JsonElement.get(tag: String) =
|
||||||
this.jsonObject[tag]
|
this.jsonObject[tag]
|
||||||
|
|
||||||
|
val JsonElement.content
|
||||||
|
get() = this.jsonPrimitive.contentOrNull
|
||||||
@@ -32,6 +32,7 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@@ -256,6 +257,13 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
|
|||||||
|
|
||||||
job?.cancel()
|
job?.cancel()
|
||||||
job = CoroutineScope(Dispatchers.IO).launch {
|
job = CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val images = listOf(
|
||||||
|
"jpg",
|
||||||
|
"png",
|
||||||
|
"gif",
|
||||||
|
"webp"
|
||||||
|
)
|
||||||
|
|
||||||
val downloadFolders = downloadFolder.listFiles { folder ->
|
val downloadFolders = downloadFolder.listFiles { folder ->
|
||||||
folder.isDirectory && !downloadFolderMap.values.contains(folder.name)
|
folder.isDirectory && !downloadFolderMap.values.contains(folder.name)
|
||||||
}?.map {
|
}?.map {
|
||||||
@@ -273,52 +281,56 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
|
|||||||
.setProgress(index, downloadFolders.size, false)
|
.setProgress(index, downloadFolders.size, false)
|
||||||
notificationManager.notify(R.id.notification_id_import, notification.build())
|
notificationManager.notify(R.id.notification_id_import, notification.build())
|
||||||
|
|
||||||
kotlin.runCatching {
|
val metadata = kotlin.runCatching {
|
||||||
val metadata = kotlin.runCatching {
|
folder.getChild(".metadata").readText()?.let { Json.parseToJsonElement(it) }
|
||||||
folder.getChild(".metadata").readText()?.let { Json.parseToJsonElement(it).jsonObject }
|
}.getOrNull()
|
||||||
}.getOrNull()
|
|
||||||
|
|
||||||
val galleryID = folder.name.toIntOrNull() ?: return@runCatching
|
val galleryID = metadata?.get("reader")?.get("galleryInfo")?.get("id")?.content?.toIntOrNull()
|
||||||
|
?: folder.name.toIntOrNull() ?: return@forEachIndexed
|
||||||
|
|
||||||
val galleryBlock: GalleryBlock? = kotlin.runCatching {
|
val galleryBlock: GalleryBlock? = kotlin.runCatching {
|
||||||
metadata?.get("galleryBlock")?.let { Json.decodeFromJsonElement<GalleryBlock>(it) }
|
metadata?.get("galleryBlock")?.let { Json.decodeFromJsonElement<GalleryBlock>(it) }
|
||||||
}.getOrNull() ?: getGalleryBlock(galleryID)
|
}.getOrNull() ?: kotlin.runCatching {
|
||||||
val reader: Reader? = kotlin.runCatching {
|
getGalleryBlock(galleryID)
|
||||||
metadata?.get("reader")?.let { Json.decodeFromJsonElement<Reader>(it) }
|
}.getOrNull() ?: kotlin.runCatching {
|
||||||
}.getOrNull() ?: getReader(galleryID)
|
xyz.quaver.hiyobi.getGalleryBlock(galleryID)
|
||||||
|
}.getOrNull()
|
||||||
|
|
||||||
metadata?.get("thumbnail")?.jsonPrimitive?.contentOrNull?.also { thumbnail ->
|
val reader: Reader? = kotlin.runCatching {
|
||||||
val file = folder.getChild(".thumbnail").also {
|
metadata?.get("reader")?.let { Json.decodeFromJsonElement<Reader>(it) }
|
||||||
if (it.exists())
|
}.getOrNull() ?: kotlin.runCatching {
|
||||||
it.delete()
|
getReader(galleryID)
|
||||||
it.createNewFile()
|
}.getOrNull() ?: kotlin.runCatching {
|
||||||
}
|
xyz.quaver.hiyobi.getReader(galleryID)
|
||||||
|
}.getOrNull()
|
||||||
|
|
||||||
file.writeBytes(Base64.decode(thumbnail, Base64.DEFAULT))
|
metadata?.get("thumbnail")?.jsonPrimitive?.contentOrNull?.also { thumbnail ->
|
||||||
|
val file = folder.getChild(".thumbnail").also {
|
||||||
|
if (it.exists())
|
||||||
|
it.delete()
|
||||||
|
it.createNewFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
val list: MutableList<String?> =
|
file.writeBytes(Base64.decode(thumbnail, Base64.DEFAULT))
|
||||||
MutableList(reader!!.galleryInfo.files.size) { null }
|
|
||||||
|
|
||||||
folder.listFiles { file ->
|
|
||||||
file?.nameWithoutExtension?.let {
|
|
||||||
Regex("""\d{5}""").matches(it) && it.toIntOrNull() != null
|
|
||||||
} == true
|
|
||||||
}?.forEach {
|
|
||||||
list[it.nameWithoutExtension.toInt()] = it.name
|
|
||||||
}
|
|
||||||
|
|
||||||
folder.getChild(".metadata").also { if (it.exists()) it.delete(); it.createNewFile() }.writeText(
|
|
||||||
Json.encodeToString(Metadata(galleryBlock, reader, list))
|
|
||||||
)
|
|
||||||
|
|
||||||
synchronized(Cache) {
|
|
||||||
Cache.delete(this@migrate, galleryID)
|
|
||||||
}
|
|
||||||
downloadFolderMap[galleryID] = folder.name
|
|
||||||
|
|
||||||
downloadFolder.getChild(".download").let { if (!it.exists()) it.createNewFile(); it.writeText(Json.encodeToString(downloadFolderMap)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val list: MutableList<String?> =
|
||||||
|
MutableList(reader!!.galleryInfo.files.size) { null }
|
||||||
|
|
||||||
|
folder.list { _, name ->
|
||||||
|
name?.substringAfterLast('.') in images
|
||||||
|
}?.sorted()?.take(list.size)?.forEachIndexed { i, name ->
|
||||||
|
list[i] = name
|
||||||
|
}
|
||||||
|
|
||||||
|
folder.getChild(".metadata").also { if (it.exists()) it.delete(); it.createNewFile() }.writeText(
|
||||||
|
Json.encodeToString(Metadata(galleryBlock, reader, list))
|
||||||
|
)
|
||||||
|
|
||||||
|
Cache.delete(this@migrate, galleryID)
|
||||||
|
downloadFolderMap[galleryID] = folder.name
|
||||||
|
|
||||||
|
downloadFolder.getChild(".download").let { if (!it.exists()) it.createNewFile(); it.writeText(Json.encodeToString(downloadFolderMap)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
notification
|
notification
|
||||||
|
|||||||
Reference in New Issue
Block a user