mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 02:17:43 +03:00
use long for timestamp and don´t fail if timestamp is empty
This commit is contained in:
parent
7f02bb0ff2
commit
f85cf5dcff
2 changed files with 8 additions and 9 deletions
|
@ -83,7 +83,7 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
|||
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 @@ public class InstantUploadBroadcastReceiver extends BroadcastReceiver {
|
|||
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)) {
|
||||
|
|
|
@ -128,22 +128,22 @@ public class FileStorageUtils {
|
|||
* @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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue