|
33 | 33 | /**
|
34 | 34 | * @author gubatron
|
35 | 35 | * @author aldenml
|
| 36 | + * JED2K stores all files to one place without sub dirs |
36 | 37 | */
|
37 | 38 | public final class AndroidPaths {
|
38 |
| - |
39 |
| - /** |
40 |
| - * base storage path |
41 |
| - */ |
42 |
| - private static final String STORAGE_PATH = "Mule_on_Android"; |
43 |
| - |
44 |
| - /** |
45 |
| - * downloaded files path |
46 |
| - */ |
47 |
| - private static final String DOWNLOADS_PATH = ""; |
48 |
| - |
49 |
| - /** |
50 |
| - * metadata path for fast resume data saving |
51 |
| - */ |
52 |
| - private static final String METADATA_PATH = ".metadata"; |
53 |
| - |
54 |
| - private static final String TEMP_PATH = "temp"; |
55 |
| - |
56 | 39 | private static final boolean USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 = true;
|
57 |
| - |
58 | 40 | private final Context context;
|
59 |
| - //private final Application app; |
60 | 41 |
|
61 | 42 | public AndroidPaths(Context app) {
|
62 | 43 | this.context = app;
|
63 | 44 | }
|
64 | 45 |
|
65 |
| - // public File data(Context ctx) { |
66 |
| - //return new File(storage(), DOWNLOADS_PATH); |
67 |
| - // return storage(ctx); |
68 |
| - //} |
69 |
| - |
70 | 46 | public File data() {
|
71 |
| - //return new File(storage(), DOWNLOADS_PATH); |
72 |
| - return storage(); |
73 |
| - } |
74 |
| - |
75 |
| - //public File metadata(Context ctx) { |
76 |
| - // return new File(storage(ctx), METADATA_PATH); |
77 |
| - //} |
78 |
| - |
79 |
| - //public File temp() { |
80 |
| - // return new File(context.getExternalFilesDir(null), TEMP_PATH); |
81 |
| - //} |
82 |
| - |
83 |
| - private static final Logger LOG = LoggerFactory.getLogger(AndroidPaths.class); |
84 |
| -/* |
85 |
| - private static File storage(Context ctx) { |
86 |
| - if (SystemUtils.hasAndroid10OrNewer()) { |
87 |
| - File externalDir = ctx.getExternalFilesDir(null); |
88 |
| - return new File(USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 ? |
89 |
| - externalDir : ctx.getFilesDir(), |
90 |
| - STORAGE_PATH); |
91 |
| - } |
92 |
| -*/ |
93 |
| - /* For Older versions of Android where we used to have access to write to external storage |
94 |
| - * <externalStoragePath>/FrostWire/ |
95 |
| - */ |
96 |
| -/* String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath()); |
97 |
| - if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { |
98 |
| - return new File(path); |
99 |
| - } else { |
100 |
| - return new File(path, STORAGE_PATH); |
101 |
| - } |
102 |
| -*/ |
103 |
| - //String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH); |
104 |
| - /*if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { |
105 |
| - return new File(path); |
106 |
| - } else { |
107 |
| - return new File(path, STORAGE_PATH); |
108 |
| - } |
109 |
| - */ |
110 |
| - //return new File(path); |
111 |
| - //} |
112 |
| - |
113 |
| - private File storage() { |
114 | 47 | if (SystemUtils.hasAndroid10OrNewer()) {
|
115 | 48 | File externalDir = context.getExternalFilesDir(null);
|
116 |
| - LOG.info("storage: external path {}", externalDir); |
117 | 49 | return USE_EXTERNAL_STORAGE_DIR_ON_OR_AFTER_ANDROID_10 ? externalDir : context.getFilesDir();
|
118 | 50 |
|
119 | 51 | }
|
120 | 52 |
|
121 | 53 | /* For Older versions of Android where we used to have access to write to external storage
|
122 |
| - * <externalStoragePath>/FrostWire/ |
| 54 | + * <externalStoragePath> |
123 | 55 | */
|
124 | 56 | String path = ConfigurationManager.instance().getStoragePath();
|
125 |
| - //ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH, Environment.getExternalStorageDirectory().getAbsolutePath()); |
126 |
| - LOG.info("storage: internal path {}", path); |
127 | 57 | return new File(ConfigurationManager.instance().getStoragePath());
|
128 |
| - /* |
129 |
| - if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { |
130 |
| - return new File(path); |
131 |
| - } else { |
132 |
| - return new File(path); |
133 |
| - }*/ |
134 |
| - |
135 |
| - //String path = ConfigurationManager.instance().getString(Constants.PREF_KEY_STORAGE_PATH); |
136 |
| - /*if (path.toLowerCase().endsWith("/" + STORAGE_PATH.toLowerCase())) { |
137 |
| - return new File(path); |
138 |
| - } else { |
139 |
| - return new File(path, STORAGE_PATH); |
140 |
| - } |
141 |
| - */ |
142 |
| - //return new File(path); |
143 | 58 | }
|
144 | 59 | }
|
0 commit comments