diff options
author | Khalid Zubair <kzubair@cyngn.com> | 2016-05-18 17:23:28 -0700 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-11-20 02:11:04 -0800 |
commit | b3bff03623009620f762608633aa1f8faa4a6fa6 (patch) | |
tree | 031443951bad56582000021baa14a9b56b4bd7b6 | |
parent | fe77d1616940b924a772f6b8ddd199540a4fae3f (diff) | |
download | android_packages_apps_Snap-b3bff03623009620f762608633aa1f8faa4a6fa6.tar.gz android_packages_apps_Snap-b3bff03623009620f762608633aa1f8faa4a6fa6.tar.bz2 android_packages_apps_Snap-b3bff03623009620f762608633aa1f8faa4a6fa6.zip |
Fix broken filenames for cropped images
makeAndInsertUri() was missing the filename prefix and ended up
creating filenames like '_20160518_170242.JPG'.
getNewFile() already does most of what we need to handle PANO and IMG
prefixes. Modify it to accept a time argument and use that instead.
CYNGNOS-2877
Change-Id: I593be63d43b18efbae134c10b59921498d48df8f
-rw-r--r-- | src/com/android/camera/crop/SaveImage.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/com/android/camera/crop/SaveImage.java b/src/com/android/camera/crop/SaveImage.java index c48e861fe..f5e89de4b 100644 --- a/src/com/android/camera/crop/SaveImage.java +++ b/src/com/android/camera/crop/SaveImage.java @@ -142,16 +142,19 @@ public class SaveImage { return saveDirectory; } - public static File getNewFile(Context context, Uri sourceUri) { + public static File getNewFile(Context context, Uri sourceUri, long time) { File saveDirectory = getFinalSaveDirectory(context, sourceUri); - String filename = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date( - System.currentTimeMillis())); + String filename = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(time)); if (hasPanoPrefix(context, sourceUri)) { return new File(saveDirectory, PREFIX_PANO + filename + POSTFIX_JPG); } return new File(saveDirectory, PREFIX_IMG + filename + POSTFIX_JPG); } + public static File getNewFile(Context context, Uri sourceUri) { + return getNewFile(context, sourceUri, System.currentTimeMillis()); + } + /** * Remove the files in the auxiliary directory whose names are the same as * the source image. @@ -339,9 +342,7 @@ public class SaveImage { public static Uri makeAndInsertUri(Context context, Uri sourceUri) { long time = System.currentTimeMillis(); - String filename = new SimpleDateFormat(TIME_STAMP_NAME).format(new Date(time)); - File saveDirectory = getFinalSaveDirectory(context, sourceUri); - File file = new File(saveDirectory, filename + ".JPG"); + File file = getNewFile(context, sourceUri, time); return linkNewFileToUri(context, sourceUri, file, time, false); } |