From 9014ad6d77fc80b5b7341f1b7751841a2ecd4c8d Mon Sep 17 00:00:00 2001 From: tom5079 Date: Thu, 6 Jun 2019 00:57:10 +0900 Subject: [PATCH] Added auto export feature --- .../quaver/pupil/util/GalleryDownloader.kt | 20 ++++++++++++++++--- app/src/main/res/values-ja/strings.xml | 2 ++ app/src/main/res/values-ko/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/root_preferences.xml | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/xyz/quaver/pupil/util/GalleryDownloader.kt b/app/src/main/java/xyz/quaver/pupil/util/GalleryDownloader.kt index 5cfabe95..7f8e1405 100644 --- a/app/src/main/java/xyz/quaver/pupil/util/GalleryDownloader.kt +++ b/app/src/main/java/xyz/quaver/pupil/util/GalleryDownloader.kt @@ -59,8 +59,6 @@ class GalleryDownloader( downloads.add(galleryBlock.id) } else { field = false - - downloads.remove(galleryBlock.id) } onNotifyChangedHandler?.invoke(value) @@ -232,7 +230,23 @@ class GalleryDownloader( } } - notificationManager.notify(galleryBlock.id, notificationBuilder.build()) + val preference = PreferenceManager.getDefaultSharedPreferences(this@GalleryDownloader) + val autoExport = preference.getBoolean("auto_export", false) + + if (autoExport) { + export({ + notificationManager.notify(galleryBlock.id, notificationBuilder.build()) + }, { + notificationBuilder + .setContentTitle(galleryBlock.title) + .setContentText(getString(R.string.main_export_error)) + .setProgress(0, 0, false) + + notificationManager.notify(galleryBlock.id, notificationBuilder.build()) + }) + } else { + notificationManager.notify(galleryBlock.id, notificationBuilder.build()) + } } download = false diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index b5739491..ea55a8f6 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -63,4 +63,6 @@ エクスポートエラーが発生しました zipエクスポート イメージフォルダの代わりzipファイルでエクスポート + 自動エクスポート + ダウンロード完了後自動的にエクスポート \ 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 4500e7e8..eebc573d 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -63,4 +63,6 @@ 내보내기 오류가 발생했습니다 zip 파일로 내보내기 이미지 폴더 대신 zip 파일로 내보내기 + 자동 내보내기 + 다운로드가 끝난 후 자동 내보내기 \ 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 46b34b97..9c232fff 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,6 +89,8 @@ Load images from hiyobi.me to improve loading speed (if available) Export zip Export to zip instead of image folder + Auto Export + Automatically exports galleries when download is finished Enable security mode Enable security mode to make the screen invisible on recent app window diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 1bd66aac..e30ef341 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -47,6 +47,11 @@ app:title="@string/settings_export_zip_title" app:summary="@string/settings_export_zip_summary"/> + +