summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/Camera.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/Camera.java')
-rw-r--r--src/com/android/camera/Camera.java46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 04a30cf..d0eb1b3 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -258,7 +258,7 @@ public class Camera extends Activity implements View.OnClickListener,
String action = intent.getAction();
if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) {
// SD card available
- updateStorageHint();
+ updateStorageHint(calculatePicturesRemaining());
} else if (action.equals(Intent.ACTION_MEDIA_UNMOUNTED) ||
action.equals(Intent.ACTION_MEDIA_CHECKING)) {
// SD card unavailable
@@ -832,7 +832,7 @@ public class Camera extends Activity implements View.OnClickListener,
loadServiceThread.join();
} catch (InterruptedException ex) {
}
-
+
ImageManager.ensureOSXCompatibleFolder();
}
@@ -1355,6 +1355,40 @@ public class Camera extends Activity implements View.OnClickListener,
}
return mCameraDevice != null;
}
+
+ private boolean isLastPictureValid() {
+ boolean isValid = true;
+ if (mLastPictureUri == null) return false;
+ try {
+ mContentResolver.openFileDescriptor(mLastPictureUri, "r").close();
+ }
+ catch (Exception ex) {
+ isValid = false;
+ Log.e(TAG, ex.toString());
+ }
+ return isValid;
+ }
+
+ private void updateLastImage() {
+ ImageManager.IImageList list = ImageManager.instance().allImages(
+ this,
+ mContentResolver,
+ dataLocation(),
+ ImageManager.INCLUDE_IMAGES,
+ ImageManager.SORT_ASCENDING,
+ ImageManager.CAMERA_IMAGE_BUCKET_ID);
+ int count = list.getCount();
+ if (count > 0) {
+ ImageManager.IImage image = list.getImageAt(count-1);
+ mLastPictureUri = image.fullSizeImageUri();
+ Log.v(TAG, "updateLastImage: count="+ count +
+ ", lastPictureUri="+mLastPictureUri);
+ setLastPictureThumb(image.miniThumbBitmap(), mLastPictureUri);
+ } else {
+ mLastPictureUri = null;
+ }
+ list.deactivate();
+ }
private void restartPreview() {
VideoPreview surfaceView = mSurfaceView;
@@ -1371,6 +1405,10 @@ public class Camera extends Activity implements View.OnClickListener,
// let the user take a picture, and delete that file if needed to save the new photo.
calculatePicturesRemaining();
+ if (!isLastPictureValid()) {
+ updateLastImage();
+ }
+
if (mShouldShowLastPictureButton) {
mShouldShowLastPictureButton = false;
mLastPictureButton.setVisibility(View.VISIBLE);
@@ -1523,7 +1561,7 @@ public class Camera extends Activity implements View.OnClickListener,
private void viewLastImage() {
Uri targetUri = mLastPictureUri;
- if (targetUri != null) {
+ if (targetUri != null && isLastPictureValid()) {
targetUri = targetUri.buildUpon().
appendQueryParameter("bucketId", ImageManager.CAMERA_IMAGE_BUCKET_ID).build();
Intent intent = new Intent(Intent.ACTION_VIEW, targetUri);
@@ -1538,6 +1576,8 @@ public class Camera extends Activity implements View.OnClickListener,
} catch (android.content.ActivityNotFoundException ex) {
// ignore.
}
+ } else {
+ Log.e(TAG, "Can't view last image.");
}
}