Added download directory entry on preferences

Changed download folder
This commit is contained in:
tom5079
2020-01-04 13:16:39 +09:00
parent 774867502d
commit 6fbb644e4b
6 changed files with 42 additions and 8 deletions

View File

@@ -208,6 +208,17 @@ class SettingsActivity : AppCompatActivity() {
}
}
with(findPreference<Preference>("dl_location")) {
this!!
summary = getDownloadDirectory(context).absolutePath
onPreferenceClickListener = Preference.OnPreferenceClickListener {
true
}
}
with(findPreference<Preference>("default_query")) {
this!!

View File

@@ -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]
}