aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-03-27 17:08:37 -0700
committerScott Jackson <daneren2005@gmail.com>2015-03-27 17:08:37 -0700
commit2a466fe1bb69c64ea5e897d529a9e21ebbf5cc57 (patch)
tree42548d2c0595a6268eea99366a7f4e1b1115d17b
parent8e05176e579b0dd9932dfb2be0ca862759f8668b (diff)
downloaddsub-2a466fe1bb69c64ea5e897d529a9e21ebbf5cc57.tar.gz
dsub-2a466fe1bb69c64ea5e897d529a9e21ebbf5cc57.tar.bz2
dsub-2a466fe1bb69c64ea5e897d529a9e21ebbf5cc57.zip
Add a fallback if the new 5.0 media folder isn't accessible for whatever reason
-rw-r--r--src/github/daneren2005/dsub/util/FileUtil.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java
index 8bd53c0c..b9d7fd1b 100644
--- a/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/src/github/daneren2005/dsub/util/FileUtil.java
@@ -442,6 +442,24 @@ public class FileUtil {
if (!DEFAULT_MUSIC_DIR.exists() && !DEFAULT_MUSIC_DIR.mkdirs()) {
Log.e(TAG, "Failed to create default dir " + DEFAULT_MUSIC_DIR);
+
+ // Some devices seem to have screwed up the new media directory API. Go figure. Try again with standard locations
+ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ dirs = ContextCompat.getExternalFilesDirs(context, null);
+
+ for(int i = dirs.length - 1; i >= 0; i--) {
+ DEFAULT_MUSIC_DIR = new File(dirs[i], "music");
+ if(dirs[i] != null) {
+ break;
+ }
+ }
+
+ if (!DEFAULT_MUSIC_DIR.exists() && !DEFAULT_MUSIC_DIR.mkdirs()) {
+ Log.e(TAG, "Failed to create default dir " + DEFAULT_MUSIC_DIR);
+ } else {
+ Log.w(TAG, "Stupid OEM's messed up media dir API added in 5.0");
+ }
+ }
}
}