diff options
author | Khalid Zubair <kzubair@cyngn.com> | 2016-05-18 17:23:28 -0700 |
---|---|---|
committer | Chippa-a <vusal1372@gmail.com> | 2019-10-25 15:55:25 +0300 |
commit | 5e7995dc3bab665baae12a93833776452a724af6 (patch) | |
tree | ca096b46a97eb74ab429b7e3c3d43862711b8a36 | |
parent | b1319c956afe6c027062e3f6432bb8e06bb980a6 (diff) | |
download | android_packages_apps_Snap-5e7995dc3bab665baae12a93833776452a724af6.tar.gz android_packages_apps_Snap-5e7995dc3bab665baae12a93833776452a724af6.tar.bz2 android_packages_apps_Snap-5e7995dc3bab665baae12a93833776452a724af6.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); } |