From f68b53ba61b7c3ab15ebbb474e457fcbdb6248bd Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 16:43:12 +0200 Subject: [PATCH 01/10] introduce upload subfolders configuration variable --- res/values/strings.xml | 2 ++ res/xml/preferences.xml | 6 +++++- src/com/owncloud/android/db/PreferenceManager.java | 5 +++++ src/com/owncloud/android/ui/activity/Preferences.java | 6 +++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 519d03cb7089..86fb84f701a3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -307,6 +307,8 @@ %1$s could not be copied to %2$s local folder Upload path + Use subfolders + Store in subfolders based on year and month Sorry, sharing is not enabled on your server. Please contact your administrator. diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 882ca4413411..388372c4820a 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -25,9 +25,13 @@ - + diff --git a/src/com/owncloud/android/db/PreferenceManager.java b/src/com/owncloud/android/db/PreferenceManager.java index 22e7ec09f334..18142ef5e3f4 100644 --- a/src/com/owncloud/android/db/PreferenceManager.java +++ b/src/com/owncloud/android/db/PreferenceManager.java @@ -37,6 +37,7 @@ public abstract class PreferenceManager { private static final String AUTO_PREF__SORT_ASCENDING = "sort_ascending"; private static final String PREF__INSTANT_UPLOADING = "instant_uploading"; private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading"; + private static final String PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS = "instant_upload_path_use_subfolders"; private static final String PREF__INSTANT_UPLOAD_ON_WIFI = "instant_upload_on_wifi"; private static final String PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI = "instant_video_upload_on_wifi"; @@ -48,6 +49,10 @@ public static boolean instantVideoUploadEnabled(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOADING, false); } + public static boolean instantPictureUploadPathUseSubfolders(Context context) { + return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS, false); + } + public static boolean instantPictureUploadViaWiFiOnly(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_ON_WIFI, false); } diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index f7ce28a5efca..b37bffa0dc8a 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -110,6 +110,7 @@ public class Preferences extends PreferenceActivity private Preference mPrefInstantUpload; private Preference mPrefInstantUploadBehaviour; private Preference mPrefInstantUploadPath; + private Preference mPrefInstantUploadUseSubfolders; private Preference mPrefInstantUploadPathWiFi; private Preference mPrefInstantVideoUpload; private Preference mPrefInstantVideoUploadPath; @@ -391,7 +392,8 @@ public boolean onPreferenceClick(Preference preference) { mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category"); - + + mPrefInstantUploadUseSubfolders = findPreference("instant_upload_path_use_subfolders"); mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi"); mPrefInstantUpload = findPreference("instant_uploading"); @@ -477,9 +479,11 @@ private void toggleInstantPictureOptions(Boolean value){ if (value){ mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi); mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath); + mPrefInstantUploadCategory.addPreference(mPrefInstantUploadUseSubfolders); } else { mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi); mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath); + mPrefInstantUploadCategory.removePreference(mPrefInstantUploadUseSubfolders); } } From bd8ab1039d1f7042db78ea7a3871c16db5edf8a2 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 17:26:20 +0200 Subject: [PATCH 02/10] make InstantUploader honor the SubFolder setting --- .../files/InstantUploadBroadcastReceiver.java | 5 +++- .../android/utils/FileStorageUtils.java | 26 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index b33cb16f6a9a..a1b56a6d0df7 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -83,6 +83,7 @@ private void handleNewPictureAction(Context context, Intent intent) { String file_path = null; String file_name = null; String mime_type = null; + String date_taken = null; Log_OC.i(TAG, "New photo received"); @@ -116,6 +117,8 @@ private void handleNewPictureAction(Context context, Intent intent) { file_path = c.getString(c.getColumnIndex(Images.Media.DATA)); file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE)); + // date_taken = c.getString(c.getColumnIndex(Images.Media.DATE_TAKEN)); does not seem to work for all cameras + date_taken = Long.toString(System.currentTimeMillis()); c.close(); if (file_path.equals(lastUploadedPhotoPath)) { @@ -134,7 +137,7 @@ private void handleNewPictureAction(Context context, Intent intent) { context, account, file_path, - FileStorageUtils.getInstantUploadFilePath(context, file_name), + FileStorageUtils.getInstantUploadFilePath(context, file_name, date_taken), behaviour, mime_type, true, // create parent folder if not existent diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index b9b94141e1fc..1cc44e4452c6 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -21,8 +21,11 @@ package com.owncloud.android.utils; import java.io.File; +import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Comparator; +import java.util.Date; +import java.util.Locale; import java.util.Vector; import third_parties.daveKoeller.AlphanumComparator; @@ -117,11 +120,30 @@ public static final String getLogPath() { return Environment.getExternalStorageDirectory() + File.separator + MainApp.getDataFolder() + File.separator + "log"; } - public static String getInstantUploadFilePath(Context context, String fileName) { + /** + * Returns the InstantUploadFilePath on the owncloud instance + * + * @param context + * @param fileName + * @param dateTaken: Time in milliseconds since 1970 when the picture was taken. + * @return + */ + public static String getInstantUploadFilePath(Context context, String fileName, String dateTaken) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); - String value = uploadPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName); + String subFolders = ""; + if(dateTaken != null && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); + subFolders = formatter.format(new Date(Long.parseLong(dateTaken))); + Date d = new Date(Long.parseLong((dateTaken))); + } + catch(RuntimeException ex) { + // don´t use a subfolder if we can´t parse the date + } + } + String value = uploadPath + OCFile.PATH_SEPARATOR + subFolders + (fileName == null ? "" : fileName); return value; } From 89ae5bfe1a234c6ca78feef55b01acbb8b742079 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 23:25:52 +0200 Subject: [PATCH 03/10] =?UTF-8?q?use=20long=20for=20timestamp=20and=20don?= =?UTF-8?q?=C2=B4t=20fail=20if=20timestamp=20is=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/InstantUploadBroadcastReceiver.java | 5 ++--- src/com/owncloud/android/utils/FileStorageUtils.java | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index a1b56a6d0df7..54040af3ebe4 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -83,7 +83,7 @@ private void handleNewPictureAction(Context context, Intent intent) { String file_path = null; String file_name = null; String mime_type = null; - String date_taken = null; + long date_taken = 0; Log_OC.i(TAG, "New photo received"); @@ -117,8 +117,7 @@ private void handleNewPictureAction(Context context, Intent intent) { file_path = c.getString(c.getColumnIndex(Images.Media.DATA)); file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE)); - // date_taken = c.getString(c.getColumnIndex(Images.Media.DATE_TAKEN)); does not seem to work for all cameras - date_taken = Long.toString(System.currentTimeMillis()); + date_taken = System.currentTimeMillis(); c.close(); if (file_path.equals(lastUploadedPhotoPath)) { diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 1cc44e4452c6..7e988bf42e68 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -128,22 +128,22 @@ public static final String getLogPath() { * @param dateTaken: Time in milliseconds since 1970 when the picture was taken. * @return */ - public static String getInstantUploadFilePath(Context context, String fileName, String dateTaken) { + public static String getInstantUploadFilePath(Context context, String fileName, long dateTaken) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); - String subFolders = ""; - if(dateTaken != null && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + String subFolders = null; + if(dateTaken != 0 && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); - subFolders = formatter.format(new Date(Long.parseLong(dateTaken))); - Date d = new Date(Long.parseLong((dateTaken))); + subFolders = formatter.format(new Date(dateTaken)); + Date d = new Date(dateTaken); } catch(RuntimeException ex) { // don´t use a subfolder if we can´t parse the date } } - String value = uploadPath + OCFile.PATH_SEPARATOR + subFolders + (fileName == null ? "" : fileName); + String value = uploadPath + OCFile.PATH_SEPARATOR + (subFolders != null ? subFolders : "") + (fileName == null ? "" : fileName); return value; } From 3c388ad120644ff45fce9b7bd3f19410e9af80d0 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 23:53:15 +0200 Subject: [PATCH 04/10] implement the same for videos and do some code cleanup --- res/xml/preferences.xml | 4 ++ .../android/db/PreferenceManager.java | 5 ++ .../files/InstantUploadBroadcastReceiver.java | 4 +- .../android/ui/activity/Preferences.java | 6 ++- .../android/utils/FileStorageUtils.java | 46 +++++++++++++------ 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 388372c4820a..b75d6f24667a 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -41,6 +41,10 @@ + diff --git a/src/com/owncloud/android/db/PreferenceManager.java b/src/com/owncloud/android/db/PreferenceManager.java index 18142ef5e3f4..523ed612afe2 100644 --- a/src/com/owncloud/android/db/PreferenceManager.java +++ b/src/com/owncloud/android/db/PreferenceManager.java @@ -40,6 +40,7 @@ public abstract class PreferenceManager { private static final String PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS = "instant_upload_path_use_subfolders"; private static final String PREF__INSTANT_UPLOAD_ON_WIFI = "instant_upload_on_wifi"; private static final String PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI = "instant_video_upload_on_wifi"; + private static final String PREF__INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS = "instant_video_upload_path_use_subfolders"; public static boolean instantPictureUploadEnabled(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOADING, false); @@ -57,6 +58,10 @@ public static boolean instantPictureUploadViaWiFiOnly(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_ON_WIFI, false); } + public static boolean instantVideoUploadPathUseSubfolders(Context context) { + return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS, false); + } + public static boolean instantVideoUploadViaWiFiOnly(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI, false); } diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index 54040af3ebe4..17e3d0288b47 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -163,6 +163,7 @@ private void handleNewVideoAction(Context context, Intent intent) { String file_path = null; String file_name = null; String mime_type = null; + long date_taken = 0; Log_OC.i(TAG, "New video received"); @@ -188,6 +189,7 @@ private void handleNewVideoAction(Context context, Intent intent) { file_name = c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE)); c.close(); + date_taken = System.currentTimeMillis(); Log_OC.d(TAG, file_path + ""); int behaviour = getUploadBehaviour(context); @@ -196,7 +198,7 @@ private void handleNewVideoAction(Context context, Intent intent) { context, account, file_path, - FileStorageUtils.getInstantVideoUploadFilePath(context, file_name), + FileStorageUtils.getInstantVideoUploadFilePath(context, file_name, date_taken), behaviour, mime_type, true, // create parent folder if not existent diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index b37bffa0dc8a..68de94895f13 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -114,6 +114,7 @@ public class Preferences extends PreferenceActivity private Preference mPrefInstantUploadPathWiFi; private Preference mPrefInstantVideoUpload; private Preference mPrefInstantVideoUploadPath; + private Preference mPrefInstantVideoUploadUseSubfolders; private Preference mPrefInstantVideoUploadPathWiFi; private String mUploadVideoPath; @@ -428,7 +429,8 @@ public boolean onPreferenceClick(Preference preference) { } }); } - + + mPrefInstantVideoUploadUseSubfolders = findPreference("instant_video_upload_path_use_subfolders"); mPrefInstantVideoUploadPathWiFi = findPreference("instant_video_upload_on_wifi"); mPrefInstantVideoUpload = findPreference("instant_video_uploading"); toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked()); @@ -491,9 +493,11 @@ private void toggleInstantVideoOptions(Boolean value){ if (value){ mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi); mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath); + mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadUseSubfolders); } else { mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi); mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath); + mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadUseSubfolders); } } diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 7e988bf42e68..b2a6b79263d2 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -120,6 +120,27 @@ public static final String getLogPath() { return Environment.getExternalStorageDirectory() + File.separator + MainApp.getDataFolder() + File.separator + "log"; } + /** + * Returns the a string like 2016/08/ for the passed date. If date is 0 an empty + * string is returned + * + * @param date: date in microseconds since 1st January 1970 + * @return + */ + private static String getSubpathFromDate(long date) { + try { + if(date == 0) { + return ""; + } + SimpleDateFormat formatter = new SimpleDateFormat( + "yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); + return formatter.format(new Date(date)); + } + catch(RuntimeException ex) { + return ""; + } + } + /** * Returns the InstantUploadFilePath on the owncloud instance * @@ -132,18 +153,12 @@ public static String getInstantUploadFilePath(Context context, String fileName, SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); - String subFolders = null; - if(dateTaken != 0 && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { - try { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); - subFolders = formatter.format(new Date(dateTaken)); - Date d = new Date(dateTaken); - } - catch(RuntimeException ex) { - // don´t use a subfolder if we can´t parse the date - } + String subPath = ""; + if(com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + subPath = getSubpathFromDate(dateTaken); } - String value = uploadPath + OCFile.PATH_SEPARATOR + (subFolders != null ? subFolders : "") + (fileName == null ? "" : fileName); + String value = uploadPath + OCFile.PATH_SEPARATOR + subPath + + (fileName == null ? "" : fileName); return value; } @@ -153,11 +168,16 @@ public static String getInstantUploadFilePath(Context context, String fileName, * @param fileName: video file name * @return String: video file path composed */ - public static String getInstantVideoUploadFilePath(Context context, String fileName) { + public static String getInstantVideoUploadFilePath(Context context, String fileName, long dateTaken) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadVideoPathdef = context.getString(R.string.instant_upload_path); String uploadVideoPath = pref.getString("instant_video_upload_path", uploadVideoPathdef); - String value = uploadVideoPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName); + String subPath = ""; + if(com.owncloud.android.db.PreferenceManager.instantVideoUploadPathUseSubfolders(context)) { + subPath = getSubpathFromDate(dateTaken); + } + String value = uploadVideoPath + OCFile.PATH_SEPARATOR + subPath + + (fileName == null ? "" : fileName); return value; } From e231caa1633e754219adb2963624667dfa0f0050 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Mon, 20 Jun 2016 23:05:55 +0200 Subject: [PATCH 05/10] tidy up code based on feedback --- .../android/utils/FileStorageUtils.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index b2a6b79263d2..8c993018f792 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -33,6 +33,7 @@ import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.RemoteFile; import android.accounts.Account; @@ -50,6 +51,8 @@ * Static methods to help in access to local file system. */ public class FileStorageUtils { + private static final String TAG = FileStorageUtils.class.getSimpleName(); + public static final Integer SORT_NAME = 0; public static final Integer SORT_DATE = 1; public static final Integer SORT_SIZE = 2; @@ -128,15 +131,16 @@ public static final String getLogPath() { * @return */ private static String getSubpathFromDate(long date) { + if (date == 0) { + return ""; + } try { - if(date == 0) { - return ""; - } SimpleDateFormat formatter = new SimpleDateFormat( "yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); return formatter.format(new Date(date)); } catch(RuntimeException ex) { + Log_OC.w(TAG, "could not extract date from timestamp"); return ""; } } @@ -154,12 +158,11 @@ public static String getInstantUploadFilePath(Context context, String fileName, String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); String subPath = ""; - if(com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + if (com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { subPath = getSubpathFromDate(dateTaken); } - String value = uploadPath + OCFile.PATH_SEPARATOR + subPath + return uploadPath + OCFile.PATH_SEPARATOR + subPath + (fileName == null ? "" : fileName); - return value; } /** @@ -173,12 +176,11 @@ public static String getInstantVideoUploadFilePath(Context context, String fileN String uploadVideoPathdef = context.getString(R.string.instant_upload_path); String uploadVideoPath = pref.getString("instant_video_upload_path", uploadVideoPathdef); String subPath = ""; - if(com.owncloud.android.db.PreferenceManager.instantVideoUploadPathUseSubfolders(context)) { + if (com.owncloud.android.db.PreferenceManager.instantVideoUploadPathUseSubfolders(context)) { subPath = getSubpathFromDate(dateTaken); } - String value = uploadVideoPath + OCFile.PATH_SEPARATOR + subPath + return uploadVideoPath + OCFile.PATH_SEPARATOR + subPath + (fileName == null ? "" : fileName); - return value; } public static String getParentPath(String remotePath) { From 23e1071451690bc39ffc4e60a6263c5331cd5195 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 16:43:12 +0200 Subject: [PATCH 06/10] introduce upload subfolders configuration variable --- res/values/strings.xml | 2 ++ res/xml/preferences.xml | 6 +++++- src/com/owncloud/android/db/PreferenceManager.java | 5 +++++ src/com/owncloud/android/ui/activity/Preferences.java | 6 +++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 519d03cb7089..86fb84f701a3 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -307,6 +307,8 @@ %1$s could not be copied to %2$s local folder Upload path + Use subfolders + Store in subfolders based on year and month Sorry, sharing is not enabled on your server. Please contact your administrator. diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 882ca4413411..388372c4820a 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -25,9 +25,13 @@ - + diff --git a/src/com/owncloud/android/db/PreferenceManager.java b/src/com/owncloud/android/db/PreferenceManager.java index 22e7ec09f334..18142ef5e3f4 100644 --- a/src/com/owncloud/android/db/PreferenceManager.java +++ b/src/com/owncloud/android/db/PreferenceManager.java @@ -37,6 +37,7 @@ public abstract class PreferenceManager { private static final String AUTO_PREF__SORT_ASCENDING = "sort_ascending"; private static final String PREF__INSTANT_UPLOADING = "instant_uploading"; private static final String PREF__INSTANT_VIDEO_UPLOADING = "instant_video_uploading"; + private static final String PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS = "instant_upload_path_use_subfolders"; private static final String PREF__INSTANT_UPLOAD_ON_WIFI = "instant_upload_on_wifi"; private static final String PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI = "instant_video_upload_on_wifi"; @@ -48,6 +49,10 @@ public static boolean instantVideoUploadEnabled(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOADING, false); } + public static boolean instantPictureUploadPathUseSubfolders(Context context) { + return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS, false); + } + public static boolean instantPictureUploadViaWiFiOnly(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_ON_WIFI, false); } diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index f7ce28a5efca..b37bffa0dc8a 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -110,6 +110,7 @@ public class Preferences extends PreferenceActivity private Preference mPrefInstantUpload; private Preference mPrefInstantUploadBehaviour; private Preference mPrefInstantUploadPath; + private Preference mPrefInstantUploadUseSubfolders; private Preference mPrefInstantUploadPathWiFi; private Preference mPrefInstantVideoUpload; private Preference mPrefInstantVideoUploadPath; @@ -391,7 +392,8 @@ public boolean onPreferenceClick(Preference preference) { mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category"); - + + mPrefInstantUploadUseSubfolders = findPreference("instant_upload_path_use_subfolders"); mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi"); mPrefInstantUpload = findPreference("instant_uploading"); @@ -477,9 +479,11 @@ private void toggleInstantPictureOptions(Boolean value){ if (value){ mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi); mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath); + mPrefInstantUploadCategory.addPreference(mPrefInstantUploadUseSubfolders); } else { mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi); mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath); + mPrefInstantUploadCategory.removePreference(mPrefInstantUploadUseSubfolders); } } From 7f02bb0ff2ed2987688d17ef99107c349acc7b5c Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 17:26:20 +0200 Subject: [PATCH 07/10] make InstantUploader honor the SubFolder setting --- .../files/InstantUploadBroadcastReceiver.java | 5 +++- .../android/utils/FileStorageUtils.java | 26 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index b33cb16f6a9a..a1b56a6d0df7 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -83,6 +83,7 @@ private void handleNewPictureAction(Context context, Intent intent) { String file_path = null; String file_name = null; String mime_type = null; + String date_taken = null; Log_OC.i(TAG, "New photo received"); @@ -116,6 +117,8 @@ private void handleNewPictureAction(Context context, Intent intent) { file_path = c.getString(c.getColumnIndex(Images.Media.DATA)); file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE)); + // date_taken = c.getString(c.getColumnIndex(Images.Media.DATE_TAKEN)); does not seem to work for all cameras + date_taken = Long.toString(System.currentTimeMillis()); c.close(); if (file_path.equals(lastUploadedPhotoPath)) { @@ -134,7 +137,7 @@ private void handleNewPictureAction(Context context, Intent intent) { context, account, file_path, - FileStorageUtils.getInstantUploadFilePath(context, file_name), + FileStorageUtils.getInstantUploadFilePath(context, file_name, date_taken), behaviour, mime_type, true, // create parent folder if not existent diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index b9b94141e1fc..1cc44e4452c6 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -21,8 +21,11 @@ package com.owncloud.android.utils; import java.io.File; +import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Comparator; +import java.util.Date; +import java.util.Locale; import java.util.Vector; import third_parties.daveKoeller.AlphanumComparator; @@ -117,11 +120,30 @@ public static final String getLogPath() { return Environment.getExternalStorageDirectory() + File.separator + MainApp.getDataFolder() + File.separator + "log"; } - public static String getInstantUploadFilePath(Context context, String fileName) { + /** + * Returns the InstantUploadFilePath on the owncloud instance + * + * @param context + * @param fileName + * @param dateTaken: Time in milliseconds since 1970 when the picture was taken. + * @return + */ + public static String getInstantUploadFilePath(Context context, String fileName, String dateTaken) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); - String value = uploadPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName); + String subFolders = ""; + if(dateTaken != null && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + try { + SimpleDateFormat formatter = new SimpleDateFormat("yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); + subFolders = formatter.format(new Date(Long.parseLong(dateTaken))); + Date d = new Date(Long.parseLong((dateTaken))); + } + catch(RuntimeException ex) { + // don´t use a subfolder if we can´t parse the date + } + } + String value = uploadPath + OCFile.PATH_SEPARATOR + subFolders + (fileName == null ? "" : fileName); return value; } From f85cf5dcff9fcc1f28b8dddfeecd13f743fc8792 Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 23:25:52 +0200 Subject: [PATCH 08/10] =?UTF-8?q?use=20long=20for=20timestamp=20and=20don?= =?UTF-8?q?=C2=B4t=20fail=20if=20timestamp=20is=20empty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/InstantUploadBroadcastReceiver.java | 5 ++--- src/com/owncloud/android/utils/FileStorageUtils.java | 12 ++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index a1b56a6d0df7..54040af3ebe4 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -83,7 +83,7 @@ private void handleNewPictureAction(Context context, Intent intent) { String file_path = null; String file_name = null; String mime_type = null; - String date_taken = null; + long date_taken = 0; Log_OC.i(TAG, "New photo received"); @@ -117,8 +117,7 @@ private void handleNewPictureAction(Context context, Intent intent) { file_path = c.getString(c.getColumnIndex(Images.Media.DATA)); file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE)); - // date_taken = c.getString(c.getColumnIndex(Images.Media.DATE_TAKEN)); does not seem to work for all cameras - date_taken = Long.toString(System.currentTimeMillis()); + date_taken = System.currentTimeMillis(); c.close(); if (file_path.equals(lastUploadedPhotoPath)) { diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 1cc44e4452c6..7e988bf42e68 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -128,22 +128,22 @@ public static final String getLogPath() { * @param dateTaken: Time in milliseconds since 1970 when the picture was taken. * @return */ - public static String getInstantUploadFilePath(Context context, String fileName, String dateTaken) { + public static String getInstantUploadFilePath(Context context, String fileName, long dateTaken) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); - String subFolders = ""; - if(dateTaken != null && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + String subFolders = null; + if(dateTaken != 0 && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); - subFolders = formatter.format(new Date(Long.parseLong(dateTaken))); - Date d = new Date(Long.parseLong((dateTaken))); + subFolders = formatter.format(new Date(dateTaken)); + Date d = new Date(dateTaken); } catch(RuntimeException ex) { // don´t use a subfolder if we can´t parse the date } } - String value = uploadPath + OCFile.PATH_SEPARATOR + subFolders + (fileName == null ? "" : fileName); + String value = uploadPath + OCFile.PATH_SEPARATOR + (subFolders != null ? subFolders : "") + (fileName == null ? "" : fileName); return value; } From 6401731e64a8d331defbc293f6c02f35184ecaaf Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Sun, 19 Jun 2016 23:53:15 +0200 Subject: [PATCH 09/10] implement the same for videos and do some code cleanup --- res/xml/preferences.xml | 4 ++ .../android/db/PreferenceManager.java | 5 ++ .../files/InstantUploadBroadcastReceiver.java | 4 +- .../android/ui/activity/Preferences.java | 6 ++- .../android/utils/FileStorageUtils.java | 46 +++++++++++++------ 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 388372c4820a..b75d6f24667a 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -41,6 +41,10 @@ + diff --git a/src/com/owncloud/android/db/PreferenceManager.java b/src/com/owncloud/android/db/PreferenceManager.java index 18142ef5e3f4..523ed612afe2 100644 --- a/src/com/owncloud/android/db/PreferenceManager.java +++ b/src/com/owncloud/android/db/PreferenceManager.java @@ -40,6 +40,7 @@ public abstract class PreferenceManager { private static final String PREF__INSTANT_UPLOAD_PATH_USE_SUBFOLDERS = "instant_upload_path_use_subfolders"; private static final String PREF__INSTANT_UPLOAD_ON_WIFI = "instant_upload_on_wifi"; private static final String PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI = "instant_video_upload_on_wifi"; + private static final String PREF__INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS = "instant_video_upload_path_use_subfolders"; public static boolean instantPictureUploadEnabled(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOADING, false); @@ -57,6 +58,10 @@ public static boolean instantPictureUploadViaWiFiOnly(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_UPLOAD_ON_WIFI, false); } + public static boolean instantVideoUploadPathUseSubfolders(Context context) { + return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOAD_PATH_USE_SUBFOLDERS, false); + } + public static boolean instantVideoUploadViaWiFiOnly(Context context) { return getDefaultSharedPreferences(context).getBoolean(PREF__INSTANT_VIDEO_UPLOAD_ON_WIFI, false); } diff --git a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java index 54040af3ebe4..17e3d0288b47 100644 --- a/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java +++ b/src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java @@ -163,6 +163,7 @@ private void handleNewVideoAction(Context context, Intent intent) { String file_path = null; String file_name = null; String mime_type = null; + long date_taken = 0; Log_OC.i(TAG, "New video received"); @@ -188,6 +189,7 @@ private void handleNewVideoAction(Context context, Intent intent) { file_name = c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME)); mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE)); c.close(); + date_taken = System.currentTimeMillis(); Log_OC.d(TAG, file_path + ""); int behaviour = getUploadBehaviour(context); @@ -196,7 +198,7 @@ private void handleNewVideoAction(Context context, Intent intent) { context, account, file_path, - FileStorageUtils.getInstantVideoUploadFilePath(context, file_name), + FileStorageUtils.getInstantVideoUploadFilePath(context, file_name, date_taken), behaviour, mime_type, true, // create parent folder if not existent diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index b37bffa0dc8a..68de94895f13 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -114,6 +114,7 @@ public class Preferences extends PreferenceActivity private Preference mPrefInstantUploadPathWiFi; private Preference mPrefInstantVideoUpload; private Preference mPrefInstantVideoUploadPath; + private Preference mPrefInstantVideoUploadUseSubfolders; private Preference mPrefInstantVideoUploadPathWiFi; private String mUploadVideoPath; @@ -428,7 +429,8 @@ public boolean onPreferenceClick(Preference preference) { } }); } - + + mPrefInstantVideoUploadUseSubfolders = findPreference("instant_video_upload_path_use_subfolders"); mPrefInstantVideoUploadPathWiFi = findPreference("instant_video_upload_on_wifi"); mPrefInstantVideoUpload = findPreference("instant_video_uploading"); toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantVideoUpload).isChecked()); @@ -491,9 +493,11 @@ private void toggleInstantVideoOptions(Boolean value){ if (value){ mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi); mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath); + mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadUseSubfolders); } else { mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi); mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath); + mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadUseSubfolders); } } diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index 7e988bf42e68..b2a6b79263d2 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -120,6 +120,27 @@ public static final String getLogPath() { return Environment.getExternalStorageDirectory() + File.separator + MainApp.getDataFolder() + File.separator + "log"; } + /** + * Returns the a string like 2016/08/ for the passed date. If date is 0 an empty + * string is returned + * + * @param date: date in microseconds since 1st January 1970 + * @return + */ + private static String getSubpathFromDate(long date) { + try { + if(date == 0) { + return ""; + } + SimpleDateFormat formatter = new SimpleDateFormat( + "yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); + return formatter.format(new Date(date)); + } + catch(RuntimeException ex) { + return ""; + } + } + /** * Returns the InstantUploadFilePath on the owncloud instance * @@ -132,18 +153,12 @@ public static String getInstantUploadFilePath(Context context, String fileName, SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); - String subFolders = null; - if(dateTaken != 0 && com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { - try { - SimpleDateFormat formatter = new SimpleDateFormat("yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); - subFolders = formatter.format(new Date(dateTaken)); - Date d = new Date(dateTaken); - } - catch(RuntimeException ex) { - // don´t use a subfolder if we can´t parse the date - } + String subPath = ""; + if(com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + subPath = getSubpathFromDate(dateTaken); } - String value = uploadPath + OCFile.PATH_SEPARATOR + (subFolders != null ? subFolders : "") + (fileName == null ? "" : fileName); + String value = uploadPath + OCFile.PATH_SEPARATOR + subPath + + (fileName == null ? "" : fileName); return value; } @@ -153,11 +168,16 @@ public static String getInstantUploadFilePath(Context context, String fileName, * @param fileName: video file name * @return String: video file path composed */ - public static String getInstantVideoUploadFilePath(Context context, String fileName) { + public static String getInstantVideoUploadFilePath(Context context, String fileName, long dateTaken) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); String uploadVideoPathdef = context.getString(R.string.instant_upload_path); String uploadVideoPath = pref.getString("instant_video_upload_path", uploadVideoPathdef); - String value = uploadVideoPath + OCFile.PATH_SEPARATOR + (fileName == null ? "" : fileName); + String subPath = ""; + if(com.owncloud.android.db.PreferenceManager.instantVideoUploadPathUseSubfolders(context)) { + subPath = getSubpathFromDate(dateTaken); + } + String value = uploadVideoPath + OCFile.PATH_SEPARATOR + subPath + + (fileName == null ? "" : fileName); return value; } From bed46448c74ebebf3707b36843e55e811c58014c Mon Sep 17 00:00:00 2001 From: Timo Witte Date: Mon, 20 Jun 2016 23:05:55 +0200 Subject: [PATCH 10/10] tidy up code based on feedback --- .../android/utils/FileStorageUtils.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java index b2a6b79263d2..8c993018f792 100644 --- a/src/com/owncloud/android/utils/FileStorageUtils.java +++ b/src/com/owncloud/android/utils/FileStorageUtils.java @@ -33,6 +33,7 @@ import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; +import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.files.RemoteFile; import android.accounts.Account; @@ -50,6 +51,8 @@ * Static methods to help in access to local file system. */ public class FileStorageUtils { + private static final String TAG = FileStorageUtils.class.getSimpleName(); + public static final Integer SORT_NAME = 0; public static final Integer SORT_DATE = 1; public static final Integer SORT_SIZE = 2; @@ -128,15 +131,16 @@ public static final String getLogPath() { * @return */ private static String getSubpathFromDate(long date) { + if (date == 0) { + return ""; + } try { - if(date == 0) { - return ""; - } SimpleDateFormat formatter = new SimpleDateFormat( "yyyy" + OCFile.PATH_SEPARATOR + "MM" + OCFile.PATH_SEPARATOR, Locale.ENGLISH); return formatter.format(new Date(date)); } catch(RuntimeException ex) { + Log_OC.w(TAG, "could not extract date from timestamp"); return ""; } } @@ -154,12 +158,11 @@ public static String getInstantUploadFilePath(Context context, String fileName, String uploadPathdef = context.getString(R.string.instant_upload_path); String uploadPath = pref.getString("instant_upload_path", uploadPathdef); String subPath = ""; - if(com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { + if (com.owncloud.android.db.PreferenceManager.instantPictureUploadPathUseSubfolders(context)) { subPath = getSubpathFromDate(dateTaken); } - String value = uploadPath + OCFile.PATH_SEPARATOR + subPath + return uploadPath + OCFile.PATH_SEPARATOR + subPath + (fileName == null ? "" : fileName); - return value; } /** @@ -173,12 +176,11 @@ public static String getInstantVideoUploadFilePath(Context context, String fileN String uploadVideoPathdef = context.getString(R.string.instant_upload_path); String uploadVideoPath = pref.getString("instant_video_upload_path", uploadVideoPathdef); String subPath = ""; - if(com.owncloud.android.db.PreferenceManager.instantVideoUploadPathUseSubfolders(context)) { + if (com.owncloud.android.db.PreferenceManager.instantVideoUploadPathUseSubfolders(context)) { subPath = getSubpathFromDate(dateTaken); } - String value = uploadVideoPath + OCFile.PATH_SEPARATOR + subPath + return uploadVideoPath + OCFile.PATH_SEPARATOR + subPath + (fileName == null ? "" : fileName); - return value; } public static String getParentPath(String remotePath) {