diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 766a3ca7..c0514b8f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
package="xyz.quaver.pupil">
+
-
-
-
-
diff --git a/app/src/main/java/xyz/quaver/pupil/MainActivity.kt b/app/src/main/java/xyz/quaver/pupil/MainActivity.kt
index d35b14b4..e4432784 100644
--- a/app/src/main/java/xyz/quaver/pupil/MainActivity.kt
+++ b/app/src/main/java/xyz/quaver/pupil/MainActivity.kt
@@ -15,6 +15,7 @@ import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.cardview.widget.CardView
+import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.GravityCompat
import com.arlib.floatingsearchview.FloatingSearchView
@@ -359,10 +360,9 @@ class MainActivity : AppCompatActivity() {
isEnabled = !(adapter as GalleryBlockAdapter).completeFlag.get(galleryBlock.id, false)
setOnClickListener {
val downloader = GalleryDownloader.get(galleryBlock.id)
- if (downloader == null) {
+ if (downloader == null)
GalleryDownloader(context, galleryBlock, true).start()
- downloads.add(galleryBlock.id)
- } else {
+ else {
downloader.cancel()
downloader.clearNotification()
}
@@ -377,12 +377,25 @@ class MainActivity : AppCompatActivity() {
this?.cancelAndJoin()
this?.clearNotification()
}
- val cache = File(cacheDir, "imageCache/${galleryBlock.id}/images/")
+ val cache = File(cacheDir, "imageCache/${galleryBlock.id}")
+ val data = File(ContextCompat.getDataDir(this@MainActivity), "images/${galleryBlock.id}")
cache.deleteRecursively()
+ data.deleteRecursively()
+
+ downloads.remove(galleryBlock.id)
+
+ if (mode == Mode.DOWNLOAD) {
+ runOnUiThread {
+ cancelFetch()
+ clearGalleries()
+ fetchGalleries(query)
+ loadBlocks()
+ }
+ }
- dialog.dismiss()
(adapter as GalleryBlockAdapter).completeFlag.put(galleryBlock.id, false)
}
+ dialog.dismiss()
}
dialog.show()
diff --git a/app/src/main/java/xyz/quaver/pupil/adapters/GalleryBlockAdapter.kt b/app/src/main/java/xyz/quaver/pupil/adapters/GalleryBlockAdapter.kt
index c75529b7..ed8aa83d 100644
--- a/app/src/main/java/xyz/quaver/pupil/adapters/GalleryBlockAdapter.kt
+++ b/app/src/main/java/xyz/quaver/pupil/adapters/GalleryBlockAdapter.kt
@@ -68,16 +68,30 @@ class GalleryBlockAdapter(private val galleries: List it
+ else -> File(context.cacheDir, "imageCache/${gallery.id}/reader.json")
+ }
+ }
+ }
+ val imageCache = {
+ File(ContextCompat.getDataDir(context), "images/${gallery.id}/images").let {
+ when {
+ it.exists() -> it
+ else -> File(context.cacheDir, "imageCache/${gallery.id}/images")
+ }
+ }
+ }
- if (readerCache.exists()) {
+ if (readerCache.invoke().exists()) {
val reader = Json(JsonConfiguration.Stable)
- .parse(ReaderItem.serializer().list, readerCache.readText())
+ .parse(ReaderItem.serializer().list, readerCache.invoke().readText())
with(galleryblock_progressbar) {
max = reader.size
- progress = imageCache.list()?.size ?: 0
+ progress = imageCache.invoke().list()?.size ?: 0
visibility = View.VISIBLE
}
@@ -89,9 +103,9 @@ class GalleryBlockAdapter(private val galleries: List it
+ else -> File(cacheDir, "imageCache/${galleryBlock.id}/reader.json")
+ }
+ }
if (cache.exists()) {
val cached = json.parse(serializer, cache.readText())
@@ -148,7 +169,12 @@ class GalleryDownloader(
val name = "$index".padStart(4, '0')
val ext = url.split('.').last()
- val cache = File(cacheDir, "/imageCache/${galleryBlock.id}/images/$name.$ext")
+ val cache = File(ContextCompat.getDataDir(this@GalleryDownloader), "images/${galleryBlock.id}/images/$name.$ext").let {
+ when {
+ it.exists() -> it
+ else -> File(cacheDir, "/imageCache/${galleryBlock.id}/images/$name.$ext")
+ }
+ }
if (!cache.exists())
try {
@@ -163,6 +189,8 @@ class GalleryDownloader(
} catch (e: Exception) {
cache.delete()
+ downloads.remove(galleryBlock.id)
+
onErrorHandler?.invoke(e)
notificationBuilder
@@ -189,8 +217,19 @@ class GalleryDownloader(
.setContentText(getString(R.string.reader_notification_complete))
.setProgress(0, 0, false)
- if (download)
+ if (download) {
+ File(cacheDir, "imageCache/${galleryBlock.id}").let {
+ if (it.exists()) {
+ it.copyRecursively(
+ File(ContextCompat.getDataDir(this@GalleryDownloader), "images/${galleryBlock.id}"),
+ true
+ )
+ it.deleteRecursively()
+ }
+ }
+
notificationManager.notify(galleryBlock.id, notificationBuilder.build())
+ }
download = false
}
@@ -207,6 +246,8 @@ class GalleryDownloader(
suspend fun cancelAndJoin() {
downloadJob?.cancelAndJoin()
+
+ remove(galleryBlock.id)
}
fun invokeOnReaderLoaded() {
diff --git a/app/src/main/res/layout/dialog_galleryblock.xml b/app/src/main/res/layout/dialog_galleryblock.xml
index 3c9bc82a..391e4525 100644
--- a/app/src/main/res/layout/dialog_galleryblock.xml
+++ b/app/src/main/res/layout/dialog_galleryblock.xml
@@ -20,4 +20,12 @@
android:text="@string/main_dialog_delete"
app:layout_constraintTop_toBottomOf="@id/main_dialog_download"/>
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 24689f50..fbd1d05a 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -59,4 +59,5 @@
%1$dページへ移動
(Korean only)
(Korean only)
+ ギャラリーエクスポート
\ No newline at end of file
diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml
index 003f882c..feb49c12 100644
--- a/app/src/main/res/values-ko/strings.xml
+++ b/app/src/main/res/values-ko/strings.xml
@@ -59,4 +59,5 @@
%1$d 페이지로 이동
접속 불가 현상 안내
최근 https 차단으로 접속이 안 되는 경우가 발생하고 있습니다\n이 경우 플레이스토어에서 SNIper앱을 이용하시면 정상이용이 가능합니다.
+ 갤러리 저장
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1a4abd09..44e81ce1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -46,6 +46,7 @@
Move to page %1$d
Delete this gallery
+ Export this gallery
WIP
While in progress!