1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-02 01:01:17 +00:00

FileUtils: Move getExternalStorageDownloadsDirectory code into separate function

This commit is contained in:
Catfriend1 2019-02-24 13:19:18 +01:00
parent cc76014207
commit 4ef5853b88

View file

@ -115,8 +115,7 @@ public class FileUtils {
} }
if (DOWNLOADS_VOLUME_NAME.equals(volumeId)) { if (DOWNLOADS_VOLUME_NAME.equals(volumeId)) {
Log.v(TAG, "getVolumePath: isDownloadsVolume"); Log.v(TAG, "getVolumePath: isDownloadsVolume");
// Reading the environment var avoids hard coding the case of the "downloads" folder. return getExternalStorageDownloadsDirectory();
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
} }
StorageManager mStorageManager = StorageManager mStorageManager =
@ -237,6 +236,13 @@ public class FileUtils {
else return File.separator; else return File.separator;
} }
/**
* Reading the environment var avoids hard coding the absolute path of the "/Download" folder.
*/
public static String getExternalStorageDownloadsDirectory() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
}
@Nullable @Nullable
public static String cutTrailingSlash(final String path) { public static String cutTrailingSlash(final String path) {
if (path.endsWith(File.separator)) { if (path.endsWith(File.separator)) {