From 6fbb644e4be47a7be8c56d430ec9a5d24edc0019 Mon Sep 17 00:00:00 2001 From: tom5079 Date: Sat, 4 Jan 2020 13:16:39 +0900 Subject: [PATCH] Added download directory entry on preferences Changed download folder --- .../xyz/quaver/pupil/ui/SettingsActivity.kt | 11 +++++++++++ .../main/java/xyz/quaver/pupil/util/file.kt | 12 +++++------- app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-ko/strings.xml | 1 + app/src/main/res/values/strings.xml | 19 +++++++++++++++++++ app/src/main/res/xml/root_preferences.xml | 6 +++++- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/xyz/quaver/pupil/ui/SettingsActivity.kt b/app/src/main/java/xyz/quaver/pupil/ui/SettingsActivity.kt index 60f9a724..229a5836 100644 --- a/app/src/main/java/xyz/quaver/pupil/ui/SettingsActivity.kt +++ b/app/src/main/java/xyz/quaver/pupil/ui/SettingsActivity.kt @@ -208,6 +208,17 @@ class SettingsActivity : AppCompatActivity() { } } + with(findPreference("dl_location")) { + this!! + + summary = getDownloadDirectory(context).absolutePath + + onPreferenceClickListener = Preference.OnPreferenceClickListener { + + true + } + } + with(findPreference("default_query")) { this!! diff --git a/app/src/main/java/xyz/quaver/pupil/util/file.kt b/app/src/main/java/xyz/quaver/pupil/util/file.kt index 84342718..746687db 100644 --- a/app/src/main/java/xyz/quaver/pupil/util/file.kt +++ b/app/src/main/java/xyz/quaver/pupil/util/file.kt @@ -19,8 +19,8 @@ package xyz.quaver.pupil.util import android.content.Context -import android.os.Build -import android.os.Environment +import androidx.core.content.ContextCompat +import androidx.preference.PreferenceManager import java.io.File fun getCachedGallery(context: Context, galleryID: Int): File { @@ -32,10 +32,8 @@ fun getCachedGallery(context: Context, galleryID: Int): File { } } -@Suppress("DEPRECATION") fun getDownloadDirectory(context: Context): File { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) - context.getExternalFilesDir("Pupil")!! - else - File(Environment.getExternalStorageDirectory(), "Pupil") + val dlLocation = PreferenceManager.getDefaultSharedPreferences(context).getInt("dl_location", 0) + + return ContextCompat.getExternalFilesDirs(context, null)[dlLocation] } \ 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 3614852e..f161508d 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -110,4 +110,5 @@ 確認 復元に失敗しました %1$d項目を復元しました + ダウンロード場所 \ 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 e93e36cf..03d91747 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -110,4 +110,5 @@ 확인 복원에 실패했습니다 %1$d개 항목을 복원했습니다 + 다운로드 위치 \ 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 5f695d13..47d7b3b6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -96,6 +96,8 @@ Type: %1$s Language: %1$s + + Loading Go to page Fullscreen @@ -107,11 +109,17 @@ Help + + Settings + App version Search Settings Galleries per page Default query + + + Storage Clear cache Deleting cache can affect image loading speed. Do you want to continue? @@ -121,8 +129,15 @@ Clear history Do you want to clear histories? %1$d histories saved + Download directory + + + App lock App lock type + + + Miscellaneous Use hiyobi.me Load images from hiyobi.me to improve loading speed (if available) @@ -139,6 +154,8 @@ Restore failed %1$d entries restored + + None Pattern PIN @@ -150,6 +167,8 @@ Do you want to remove lock? Lock is different from last one. Please try again. + + Set default query Language: Filter BL diff --git a/app/src/main/res/xml/root_preferences.xml b/app/src/main/res/xml/root_preferences.xml index 244a015f..5730bbfa 100644 --- a/app/src/main/res/xml/root_preferences.xml +++ b/app/src/main/res/xml/root_preferences.xml @@ -20,7 +20,7 @@ + app:useSimpleSummaryPrKovider="true"/> @@ -39,6 +39,10 @@ app:title="@string/settings_clear_history" app:key="clear_history"/> + +