summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPetri Gynther <pgynther@google.com>2009-10-20 16:51:28 -0700
committerChih-Chung Chang <chihchung@google.com>2009-11-25 17:21:40 +0800
commit30055f6830b3d524cfbdfeab6536bb46e390747a (patch)
tree88037c702a6e57e4c49292774768581fcf921d34 /src
parent4d0f30896f412439b92f38bee204766fb5853b1a (diff)
downloadLegacyCamera-30055f6830b3d524cfbdfeab6536bb46e390747a.zip
LegacyCamera-30055f6830b3d524cfbdfeab6536bb46e390747a.tar.gz
LegacyCamera-30055f6830b3d524cfbdfeab6536bb46e390747a.tar.bz2
Camera: Clean up the image/video file naming code
1) Create 'image_file_name_format' string in strings.xml 2) Change createName() routines in Camera.java and VideoCamera.java to use 'image_file_name_format' and 'video_file_name_format', respectively. 3) Change image filenames on SD card to format: IMG_yyyyMMdd_HHmmss.jpg -- e.g. IMG_20091020_120000.jpg (Old format was 'yyyy-MM-dd HH.mm.ss.jpg' which contained undesirable space character in the filename.) 4) Similarly, change video filenames to format: VID_yyyyMMdd_HHmmss.3gp -- e.g. VID_20091020_120000.3gp (Old format was 'video-yyyy-MM-dd-HH-mm-ss.3gp' which was not consistent with the image filename format.)
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java20
-rw-r--r--src/com/android/camera/VideoCamera.java23
2 files changed, 24 insertions, 19 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 770d45f..a82a83e 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -48,7 +48,6 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
-import android.text.format.DateFormat;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
@@ -77,8 +76,10 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Date;
import java.util.List;
/** The Camera activity which can preview and take pictures. */
@@ -738,14 +739,15 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
private int storeImage(byte[] data, Location loc) {
try {
long dateTaken = System.currentTimeMillis();
- String name = createName(dateTaken) + ".jpg";
+ String title = createName(dateTaken);
+ String filename = title + ".jpg";
int[] degree = new int[1];
mLastContentUri = ImageManager.addImage(
mContentResolver,
- name,
+ title,
dateTaken,
loc, // location from gps/network
- ImageManager.CAMERA_IMAGE_BUCKET_NAME, name,
+ ImageManager.CAMERA_IMAGE_BUCKET_NAME, filename,
null, data,
degree);
if (mLastContentUri == null) {
@@ -755,7 +757,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
if (!mCancel) {
ImageManager.setImageSize(mContentResolver, mLastContentUri,
new File(ImageManager.CAMERA_IMAGE_BUCKET_NAME,
- name).length());
+ filename).length());
}
return degree[0];
} catch (Exception ex) {
@@ -900,8 +902,12 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
mThumbController.setData(uri, lastPictureThumb);
}
- private static String createName(long dateTaken) {
- return DateFormat.format("yyyy-MM-dd kk.mm.ss", dateTaken).toString();
+ private String createName(long dateTaken) {
+ Date date = new Date(dateTaken);
+ SimpleDateFormat dateFormat = new SimpleDateFormat(
+ getString(R.string.image_file_name_format));
+
+ return dateFormat.format(date);
}
@Override
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 9b8957c..1fc745d 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -45,7 +45,6 @@ import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.provider.MediaStore;
import android.provider.MediaStore.Video;
-import android.text.format.DateFormat;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -213,8 +212,12 @@ public class VideoCamera extends NoSearchActivity
}
}
- private static String createName(long dateTaken) {
- return DateFormat.format("yyyy-MM-dd kk.mm.ss", dateTaken).toString();
+ private String createName(long dateTaken) {
+ Date date = new Date(dateTaken);
+ SimpleDateFormat dateFormat = new SimpleDateFormat(
+ getString(R.string.video_file_name_format));
+
+ return dateFormat.format(date);
}
private void showCameraBusyAndFinish() {
@@ -932,22 +935,18 @@ public class VideoCamera extends NoSearchActivity
private void createVideoPath() {
long dateTaken = System.currentTimeMillis();
String title = createName(dateTaken);
- String displayName = title + ".3gp"; // Used when emailing.
+ String filename = title + ".3gp"; // Used when emailing.
String cameraDirPath = ImageManager.CAMERA_IMAGE_BUCKET_NAME;
+ String filePath = cameraDirPath + "/" + filename;
File cameraDir = new File(cameraDirPath);
cameraDir.mkdirs();
- SimpleDateFormat dateFormat = new SimpleDateFormat(
- getString(R.string.video_file_name_format));
- Date date = new Date(dateTaken);
- String filepart = dateFormat.format(date);
- String filename = cameraDirPath + "/" + filepart + ".3gp";
ContentValues values = new ContentValues(7);
values.put(Video.Media.TITLE, title);
- values.put(Video.Media.DISPLAY_NAME, displayName);
+ values.put(Video.Media.DISPLAY_NAME, filename);
values.put(Video.Media.DATE_TAKEN, dateTaken);
values.put(Video.Media.MIME_TYPE, "video/3gpp");
- values.put(Video.Media.DATA, filename);
- mCameraVideoFilename = filename;
+ values.put(Video.Media.DATA, filePath);
+ mCameraVideoFilename = filePath;
Log.v(TAG, "Current camera video filename: " + mCameraVideoFilename);
mCurrentVideoValues = values;
}