diff options
-rw-r--r-- | src/com/android/camera/Camera.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/CropImage.java | 6 | ||||
-rw-r--r-- | src/com/android/camera/GalleryPicker.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/ImageGallery2.java | 4 | ||||
-rwxr-xr-x | src/com/android/camera/ImageManager.java | 152 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 1 | ||||
-rw-r--r-- | src/com/android/camera/ViewImage.java | 3 |
7 files changed, 69 insertions, 107 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index c37009e..4500e2b 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -487,7 +487,6 @@ public class Camera extends Activity implements View.OnClickListener, long dateTaken = System.currentTimeMillis(); String name = createName(dateTaken) + ".jpg"; mLastContentUri = ImageManager.addImage( - Camera.this, mContentResolver, name, dateTaken, @@ -502,7 +501,7 @@ public class Camera extends Activity implements View.OnClickListener, } if (!mCancel) { mAddImageCancelable = ImageManager.storeImage( - mLastContentUri, Camera.this, mContentResolver, + mLastContentUri, mContentResolver, 0, null, data); mAddImageCancelable.get(); mAddImageCancelable = null; @@ -1342,7 +1341,6 @@ public class Camera extends Activity implements View.OnClickListener, private void updateLastImage() { IImageList list = ImageManager.allImages( - this, mContentResolver, dataLocation(), ImageManager.INCLUDE_IMAGES, @@ -1571,7 +1569,6 @@ public class Camera extends Activity implements View.OnClickListener, private IImage getImageForURI(Uri uri) { IImageList list = ImageManager.allImages( - this, mContentResolver, dataLocation(), ImageManager.INCLUDE_IMAGES, diff --git a/src/com/android/camera/CropImage.java b/src/com/android/camera/CropImage.java index 9386fd2..fc3e360 100644 --- a/src/com/android/camera/CropImage.java +++ b/src/com/android/camera/CropImage.java @@ -134,8 +134,8 @@ public class CropImage extends Activity { if (mBitmap == null) { Uri target = intent.getData(); - mAllImages = ImageManager.makeImageList(target, CropImage.this, - ImageManager.SORT_ASCENDING); + mAllImages = ImageManager.makeImageList(target, + mContentResolver, ImageManager.SORT_ASCENDING); mImage = mAllImages.getImageForUri(target); if (mImage != null) { // don't read in really large bitmaps. max out at 1000. @@ -358,7 +358,6 @@ public class CropImage extends Activity { try { Uri newUri = ImageManager.addImage( - CropImage.this, getContentResolver(), mImage.getTitle(), mImage.getDateTaken(), @@ -374,7 +373,6 @@ public class CropImage extends Activity { ICancelable<Void> cancelable = ImageManager.storeImage( newUri, - CropImage.this, getContentResolver(), 0, // TODO fix this orientation mCroppedImage, diff --git a/src/com/android/camera/GalleryPicker.java b/src/com/android/camera/GalleryPicker.java index 8d3087d..8093f83 100644 --- a/src/com/android/camera/GalleryPicker.java +++ b/src/com/android/camera/GalleryPicker.java @@ -373,7 +373,6 @@ public class GalleryPicker extends Activity { IImageList images; if (assumeMounted) { images = ImageManager.allImages( - GalleryPicker.this, getContentResolver(), ImageManager.DataLocation.ALL, ImageManager.INCLUDE_IMAGES @@ -618,7 +617,8 @@ public class GalleryPicker extends Activity { mGridView.setAdapter(mAdapter); setBackgrounds(getResources()); - boolean scanning = ImageManager.isMediaScannerScanning(this); + boolean scanning = ImageManager.isMediaScannerScanning( + getContentResolver()); rebake(false, scanning); // install an intent filter to receive SD card related events. @@ -797,7 +797,6 @@ public class GalleryPicker extends Activity { private IImageList createImageList(int mediaTypes, String bucketId) { return ImageManager.allImages( - this, getContentResolver(), ImageManager.DataLocation.ALL, mediaTypes, diff --git a/src/com/android/camera/ImageGallery2.java b/src/com/android/camera/ImageGallery2.java index 7ece4ac..2fb5a33 100644 --- a/src/com/android/camera/ImageGallery2.java +++ b/src/com/android/camera/ImageGallery2.java @@ -503,7 +503,8 @@ public class ImageGallery2 extends Activity { } }; registerReceiver(mReceiver, intentFilter); - rebake(false, ImageManager.isMediaScannerScanning(this)); + rebake(false, ImageManager.isMediaScannerScanning( + getContentResolver())); } private void stopCheckingThumbnails() { @@ -700,7 +701,6 @@ public class ImageGallery2 extends Activity { mAllImages = ImageManager.emptyImageList(); } else { mAllImages = ImageManager.allImages( - ImageGallery2.this, getContentResolver(), ImageManager.DataLocation.NONE, mInclusion, diff --git a/src/com/android/camera/ImageManager.java b/src/com/android/camera/ImageManager.java index b16b860..05b197e 100755 --- a/src/com/android/camera/ImageManager.java +++ b/src/com/android/camera/ImageManager.java @@ -32,7 +32,6 @@ import com.android.camera.gallery.VideoList; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; -import android.content.Context; import android.database.Cursor; import android.graphics.Bitmap; import android.location.Location; @@ -181,7 +180,7 @@ public class ImageManager { cr.update(uri, values, null, null); } - public static Uri addImage(Context ctx, ContentResolver cr, String title, + public static Uri addImage(ContentResolver cr, String title, long dateTaken, Location location, int orientation, String directory, String filename) { @@ -292,14 +291,14 @@ public class ImageManager { } public static ICancelable<Void> storeImage( - Uri uri, Context ctx, ContentResolver cr, int orientation, + Uri uri, ContentResolver cr, int orientation, Bitmap source, byte [] jpegData) { return new AddImageCancelable( uri, cr, orientation, source, jpegData); } - public static IImageList makeImageList(Uri uri, Context ctx, int sort) { - ContentResolver cr = ctx.getContentResolver(); + public static IImageList makeImageList(Uri uri, ContentResolver cr, + int sort) { String uriString = (uri != null) ? uri.toString() : ""; // TODO: we need to figure out whether we're viewing @@ -309,14 +308,14 @@ public class ImageManager { if (uriString.startsWith("content://drm")) { imageList = ImageManager.allImages( - ctx, cr, ImageManager.DataLocation.ALL, + cr, ImageManager.DataLocation.ALL, ImageManager.INCLUDE_DRM_IMAGES, sort); } else if (isSingleImageMode(uriString)) { imageList = new SingleImageList(cr, uri); } else { String bucketId = uri.getQueryParameter("bucketId"); imageList = ImageManager.allImages( - ctx, cr, ImageManager.DataLocation.ALL, + cr, ImageManager.DataLocation.ALL, ImageManager.INCLUDE_IMAGES, sort, bucketId); } return imageList; @@ -369,97 +368,66 @@ public class ImageManager { return new EmptyImageList(); } - public static IImageList allImages(Context ctx, ContentResolver cr, + public static IImageList allImages(ContentResolver cr, DataLocation location, int inclusion, int sort) { - return allImages(ctx, cr, location, inclusion, sort, null, null); + return allImages(cr, location, inclusion, sort, null); } - public static IImageList allImages(Context ctx, ContentResolver cr, + public static IImageList allImages(ContentResolver cr, DataLocation location, int inclusion, int sort, String bucketId) { - return allImages(ctx, cr, location, inclusion, sort, bucketId, null); - } - - public static IImageList allImages( - Context ctx, ContentResolver cr, DataLocation location, - int inclusion, int sort, String bucketId, Uri specificImageUri) { if (cr == null) { return null; - } else { - // false ==> don't require write access - boolean haveSdCard = hasStorage(false); - - if (true) { - // use this code to merge videos and stills into the same list - ArrayList<IImageList> l = new ArrayList<IImageList>(); - if (specificImageUri != null) { - try { - if (specificImageUri.getScheme() - .equalsIgnoreCase("content")) { - l.add(new ImageList(cr, specificImageUri, - THUMB_URI, sort, bucketId)); - } else { - l.add(new SingleImageList(cr, specificImageUri)); - } - } catch (UnsupportedOperationException ex) { - // ignore exception - } - } else { - if (haveSdCard && location != DataLocation.INTERNAL) { - if ((inclusion & INCLUDE_IMAGES) != 0) { - try { - l.add(new ImageList(cr, STORAGE_URI, - THUMB_URI, sort, bucketId)); - } catch (UnsupportedOperationException ex) { - // ignore exception - } - } - if ((inclusion & INCLUDE_VIDEOS) != 0) { - try { - l.add(new VideoList(cr, VIDEO_STORAGE_URI, - VIDEO_THUMBNAIL_URI, sort, bucketId)); - } catch (UnsupportedOperationException ex) { - // ignore exception - } - } - } - if (location == DataLocation.INTERNAL - || location == DataLocation.ALL) { - if ((inclusion & INCLUDE_IMAGES) != 0) { - try { - l.add(new ImageList(cr, - Images.Media.INTERNAL_CONTENT_URI, - Images.Thumbnails.INTERNAL_CONTENT_URI, - sort, bucketId)); - } catch (UnsupportedOperationException ex) { - // ignore exception - } - } - if ((inclusion & INCLUDE_DRM_IMAGES) != 0) { - try { - l.add(new DrmImageList(cr, - DrmStore.Images.CONTENT_URI, - sort, bucketId)); - } catch (UnsupportedOperationException ex) { - // ignore exception - } - } - } - } + } - IImageList [] imageList = l.toArray(new IImageList[l.size()]); - return new ImageListUber(imageList, sort); - } else { - if (haveSdCard && location != DataLocation.INTERNAL) { - return new ImageList( - cr, STORAGE_URI, THUMB_URI, sort, bucketId); - } else { - return new ImageList(cr, + // false ==> don't require write access + boolean haveSdCard = hasStorage(false); + + // use this code to merge videos and stills into the same list + ArrayList<IImageList> l = new ArrayList<IImageList>(); + + if (haveSdCard && location != DataLocation.INTERNAL) { + if ((inclusion & INCLUDE_IMAGES) != 0) { + try { + l.add(new ImageList(cr, STORAGE_URI, + THUMB_URI, sort, bucketId)); + } catch (UnsupportedOperationException ex) { + // ignore exception + } + } + if ((inclusion & INCLUDE_VIDEOS) != 0) { + try { + l.add(new VideoList(cr, VIDEO_STORAGE_URI, + VIDEO_THUMBNAIL_URI, sort, bucketId)); + } catch (UnsupportedOperationException ex) { + // ignore exception + } + } + } + if (location == DataLocation.INTERNAL + || location == DataLocation.ALL) { + if ((inclusion & INCLUDE_IMAGES) != 0) { + try { + l.add(new ImageList(cr, Images.Media.INTERNAL_CONTENT_URI, - Images.Thumbnails.INTERNAL_CONTENT_URI, sort, - bucketId); + Images.Thumbnails.INTERNAL_CONTENT_URI, + sort, bucketId)); + } catch (UnsupportedOperationException ex) { + // ignore exception + } + } + if ((inclusion & INCLUDE_DRM_IMAGES) != 0) { + try { + l.add(new DrmImageList(cr, + DrmStore.Images.CONTENT_URI, + sort, bucketId)); + } catch (UnsupportedOperationException ex) { + // ignore exception } } } + + IImageList [] imageList = l.toArray(new IImageList[l.size()]); + return new ImageListUber(imageList, sort); } private static boolean checkFsWritable() { @@ -511,10 +479,10 @@ public class ImageManager { return false; } - public static Cursor query(Context context, Uri uri, String[] projection, - String selection, String[] selectionArgs, String sortOrder) { + private static Cursor query(ContentResolver resolver, Uri uri, + String[] projection, String selection, String[] selectionArgs, + String sortOrder) { try { - ContentResolver resolver = context.getContentResolver(); if (resolver == null) { return null; } @@ -526,9 +494,9 @@ public class ImageManager { } - public static boolean isMediaScannerScanning(Context context) { + public static boolean isMediaScannerScanning(ContentResolver cr) { boolean result = false; - Cursor cursor = query(context, MediaStore.getMediaScannerUri(), + Cursor cursor = query(cr, MediaStore.getMediaScannerUri(), new String [] {MediaStore.MEDIA_SCANNER_VOLUME}, null, null, null); if (cursor != null) { diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 7fe6041..88ff947 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -1113,7 +1113,6 @@ public class VideoCamera extends Activity implements View.OnClickListener, private void updateLastVideo() { IImageList list = ImageManager.allImages( - this, mContentResolver, dataLocation(), ImageManager.INCLUDE_VIDEOS, diff --git a/src/com/android/camera/ViewImage.java b/src/com/android/camera/ViewImage.java index 31bd829..0139be6 100644 --- a/src/com/android/camera/ViewImage.java +++ b/src/com/android/camera/ViewImage.java @@ -855,7 +855,8 @@ public class ViewImage extends Activity implements View.OnClickListener { int sort = mSortAscending ? ImageManager.SORT_ASCENDING : ImageManager.SORT_DESCENDING; - mAllImages = ImageManager.makeImageList(uri, this, sort); + mAllImages = ImageManager.makeImageList(uri, getContentResolver(), + sort); uri = uri.buildUpon().query(null).build(); // TODO smarter/faster here please |