summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2010-12-29 15:46:25 +0800
committerChia-chi Yeh <chiachi@android.com>2010-12-29 15:59:28 +0800
commit0aaed976b603c56006213d196e6b0703285dafd5 (patch)
treebd073eb67eee69ccc8f8e31b1ff1bd7906cdda83 /src
parent37cffb8467d1ccca719a7847582d04da36c5bc6f (diff)
downloadLegacyCamera-0aaed976b603c56006213d196e6b0703285dafd5.zip
LegacyCamera-0aaed976b603c56006213d196e6b0703285dafd5.tar.gz
LegacyCamera-0aaed976b603c56006213d196e6b0703285dafd5.tar.bz2
Refactoring: Remove the dependency to ImageManager.
Also polish Storage.addImage() a little bit. Change-Id: I1001f2aeab031e39510ac513eafe85581e164b95
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java8
-rw-r--r--src/com/android/camera/MenuHelper.java9
-rw-r--r--src/com/android/camera/Storage.java12
-rw-r--r--src/com/android/camera/VideoCamera.java7
4 files changed, 26 insertions, 10 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index dc7d365..13947b7 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -97,6 +97,9 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
private static final String TAG = "camera";
+ private static final String LAST_THUMB_PATH =
+ Storage.THUMBNAILS + "/image_last_thumb";
+
private static final int CROP_MSG = 1;
private static final int FIRST_TIME_INIT = 2;
private static final int RESTART_PREVIEW = 3;
@@ -383,7 +386,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
(RotateImageView) findViewById(R.id.review_thumbnail);
if (mThumbnailButton != null) {
mThumbnailButton.setOnClickListener(this);
- mThumbnailButton.loadData(ImageManager.getLastImageThumbPath());
+ mThumbnailButton.loadData(LAST_THUMB_PATH);
updateThumbnailButton();
}
}
@@ -1444,8 +1447,7 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
mOrientationListener.disable();
if (!mIsImageCaptureIntent) {
if (mThumbnailButton != null) {
- mThumbnailButton.storeData(
- ImageManager.getLastImageThumbPath());
+ mThumbnailButton.storeData(LAST_THUMB_PATH);
}
}
hidePostCaptureAlert();
diff --git a/src/com/android/camera/MenuHelper.java b/src/com/android/camera/MenuHelper.java
index 0346e9a..5fe851c 100644
--- a/src/com/android/camera/MenuHelper.java
+++ b/src/com/android/camera/MenuHelper.java
@@ -49,6 +49,9 @@ public class MenuHelper {
public static final int INCLUDE_DETAILS_MENU = (1 << 6);
public static final int INCLUDE_SHOWMAP_MENU = (1 << 7);
+ public static final int INCLUDE_IMAGES = (1 << 0);
+ public static final int INCLUDE_VIDEOS = (1 << 2);
+
public static final int MENU_IMAGE_SHARE = 1;
public static final int MENU_IMAGE_SHOWMAP = 2;
@@ -140,13 +143,11 @@ public class MenuHelper {
}
public static void gotoCameraImageGallery(Activity activity) {
- gotoGallery(activity, R.string.gallery_camera_bucket_name,
- ImageManager.INCLUDE_IMAGES);
+ gotoGallery(activity, R.string.gallery_camera_bucket_name, INCLUDE_IMAGES);
}
public static void gotoCameraVideoGallery(Activity activity) {
- gotoGallery(activity, R.string.gallery_camera_videos_bucket_name,
- ImageManager.INCLUDE_VIDEOS);
+ gotoGallery(activity, R.string.gallery_camera_videos_bucket_name, INCLUDE_VIDEOS);
}
private static void gotoGallery(Activity activity, int windowTitleId,
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java
index ea2ee8e..344b551 100644
--- a/src/com/android/camera/Storage.java
+++ b/src/com/android/camera/Storage.java
@@ -44,6 +44,8 @@ class Storage {
public static final String DIRECTORY = DCIM + "/Camera";
+ public static final String THUMBNAILS = DCIM + "/.thumbnails";
+
// Match the code in MediaProvider.computeBucketValues().
public static final String BUCKET_ID =
String.valueOf(DIRECTORY.toLowerCase().hashCode());
@@ -174,7 +176,7 @@ class Storage {
// Get the orientation.
int orientation = Exif.getOrientation(jpeg);
- // Insert a row through ContentResolver.
+ // Insert into MediaStore.
ContentValues values = new ContentValues(9);
values.put(ImageColumns.TITLE, title);
values.put(ImageColumns.DISPLAY_NAME, title + ".jpg");
@@ -190,11 +192,19 @@ class Storage {
}
Uri uri = resolver.insert(Images.Media.EXTERNAL_CONTENT_URI, values);
+ if (uri == null) {
+ Log.e(TAG, "Failed to write MediaStore");
+ return null;
+ }
// Create the thumbnail.
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 16;
Bitmap bitmap = BitmapFactory.decodeByteArray(jpeg, 0, jpeg.length, options);
+ if (bitmap == null) {
+ Log.e(TAG, "Failed to create thumbnail");
+ return null;
+ }
return new Thumbnail(uri, bitmap, orientation);
}
diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java
index 302c7b7..c1c658e 100644
--- a/src/com/android/camera/VideoCamera.java
+++ b/src/com/android/camera/VideoCamera.java
@@ -97,6 +97,9 @@ public class VideoCamera extends NoSearchActivity
private static final String TAG = "videocamera";
+ private static final String LAST_THUMB_PATH =
+ Storage.THUMBNAILS + "/video_last_thumb";
+
private static final int CLEAR_SCREEN_DELAY = 4;
private static final int UPDATE_RECORD_TIME = 5;
private static final int ENABLE_SHUTTER_BUTTON = 6;
@@ -929,7 +932,7 @@ public class VideoCamera extends NoSearchActivity
resetScreenOn();
if (!mIsVideoCaptureIntent && mThumbnailButton != null) {
- mThumbnailButton.storeData(ImageManager.getLastVideoThumbPath());
+ mThumbnailButton.storeData(LAST_THUMB_PATH);
}
if (mStorageHint != null) {
@@ -1571,7 +1574,7 @@ public class VideoCamera extends NoSearchActivity
mThumbnailButton = (RotateImageView)findViewById(R.id.review_thumbnail);
if (mThumbnailButton != null) {
mThumbnailButton.setOnClickListener(this);
- mThumbnailButton.loadData(ImageManager.getLastVideoThumbPath());
+ mThumbnailButton.loadData(LAST_THUMB_PATH);
}
}