From 4ef5853b889a9384c3875520c63956acc2ca9182 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sun, 24 Feb 2019 13:19:18 +0100 Subject: [PATCH] FileUtils: Move getExternalStorageDownloadsDirectory code into separate function --- .../com/nutomic/syncthingandroid/util/FileUtils.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java b/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java index f4d2613d..c81b96a3 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/FileUtils.java @@ -115,8 +115,7 @@ public class FileUtils { } if (DOWNLOADS_VOLUME_NAME.equals(volumeId)) { Log.v(TAG, "getVolumePath: isDownloadsVolume"); - // Reading the environment var avoids hard coding the case of the "downloads" folder. - return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath(); + return getExternalStorageDownloadsDirectory(); } StorageManager mStorageManager = @@ -237,6 +236,13 @@ public class FileUtils { 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 public static String cutTrailingSlash(final String path) { if (path.endsWith(File.separator)) {