From fffc28dcab3ae031c41c5aa290861ab4c4303550 Mon Sep 17 00:00:00 2001 From: George Mount Date: Tue, 9 Oct 2012 21:02:42 -0700 Subject: Change how stitched images are inserted into Gallery. Bug 7299396 Stitching images now use normal LocalImages for their MediaItem instead of LightCycleItems. They are no longer part of a special album. Change-Id: Ic62822a44b9743829dee50bcfa6f455cd538afa7 --- src/com/android/gallery3d/app/PhotoPage.java | 43 +++++++----------- .../gallery3d/app/StitchingChangeListener.java | 8 ++-- src/com/android/gallery3d/data/DataManager.java | 2 - src/com/android/gallery3d/data/LocalAlbumSet.java | 6 --- src/com/android/gallery3d/data/LocalImage.java | 5 ++ src/com/android/gallery3d/data/SecureAlbum.java | 53 +++------------------- 6 files changed, 30 insertions(+), 87 deletions(-) (limited to 'src/com') diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 6f2a1e007..d6723ca51 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -46,6 +46,7 @@ import com.android.gallery3d.data.ComboAlbum; import com.android.gallery3d.data.DataManager; import com.android.gallery3d.data.FilterDeleteSet; import com.android.gallery3d.data.FilterSource; +import com.android.gallery3d.data.LocalImage; import com.android.gallery3d.data.MediaDetails; import com.android.gallery3d.data.MediaItem; import com.android.gallery3d.data.MediaObject; @@ -207,26 +208,25 @@ public class PhotoPage extends ActivityState implements private class UpdateProgressListener implements StitchingChangeListener { @Override - public void onStitchingResult(Path path, Uri uri) { - sendUpdate(path); + public void onStitchingResult(Uri uri) { + sendUpdate(uri); } @Override - public void onStitchingQueued(Path path) { - sendUpdate(path); + public void onStitchingQueued(Uri uri) { + sendUpdate(uri); } @Override - public void onStitchingProgress(Path path, final int progress) { - sendUpdate(path); + public void onStitchingProgress(Uri uri, final int progress) { + sendUpdate(uri); } - private void sendUpdate(Path path) { - boolean isCurrentPhoto = mCurrentPhoto != null - && mCurrentPhoto.getPath().toString().equals(path.toString()); + private void sendUpdate(Uri uri) { + boolean isCurrentPhoto = mCurrentPhoto instanceof LocalImage + && mCurrentPhoto.getContentUri().equals(uri); if (isCurrentPhoto) { mHandler.sendEmptyMessage(MSG_REFRESH_IMAGE); - } } }; @@ -388,20 +388,13 @@ public class PhotoPage extends ActivityState implements mFlags |= FLAG_SHOW_WHEN_LOCKED; } - // Don't display "empty album" action item or panorama - // progress for capture intents. + // Don't display "empty album" action item for capture intents. if (!mSetPathString.equals("/local/all/0")) { // Check if the path is a secure album. if (SecureSource.isSecurePath(mSetPathString)) { mSecureAlbum = (SecureAlbum) mActivity.getDataManager() .getMediaSet(mSetPathString); mShowSpinner = false; - } else { - // Use lightcycle album to handle panorama progress if - // the path is not a secure album. - if (LightCycleHelper.hasLightCycleCapture(mActivity.getAndroidContext())) { - mSetPathString = LightCycleHelper.wrapGalleryPath(mSetPathString); - } } mSetPathString = "/filter/empty/{"+mSetPathString+"}"; } @@ -669,15 +662,11 @@ public class PhotoPage extends ActivityState implements updateShareURI(photo.getPath()); } StitchingProgressManager progressManager = mApplication.getStitchingProgressManager(); - if (progressManager != null) { - int itemCount = progressManager.getItemCount(); - mProgressBar.hideProgress(); - for (int i = 0; i < itemCount; i++) { - MediaItem item = progressManager.getItem(i); - if (item.getPath().equals(photo.getPath())) { - mProgressBar.setProgress(progressManager.getProgress(item.getFilePath())); - break; - } + mProgressBar.hideProgress(); + if (progressManager != null && mCurrentPhoto instanceof LocalImage) { + Integer progress = progressManager.getProgress(photo.getContentUri()); + if (progress != null) { + mProgressBar.setProgress(progress); } } } diff --git a/src/com/android/gallery3d/app/StitchingChangeListener.java b/src/com/android/gallery3d/app/StitchingChangeListener.java index 40f59a52c..0b8c2d6d6 100644 --- a/src/com/android/gallery3d/app/StitchingChangeListener.java +++ b/src/com/android/gallery3d/app/StitchingChangeListener.java @@ -16,14 +16,12 @@ package com.android.gallery3d.app; -import com.android.gallery3d.data.Path; - import android.net.Uri; public interface StitchingChangeListener { - public void onStitchingQueued(Path path); + public void onStitchingQueued(Uri uri); - public void onStitchingResult(Path path, Uri uri); + public void onStitchingResult(Uri uri); - public void onStitchingProgress(Path path, int progress); + public void onStitchingProgress(Uri uri, int progress); } diff --git a/src/com/android/gallery3d/data/DataManager.java b/src/com/android/gallery3d/data/DataManager.java index e3b7bfc19..95954e59a 100644 --- a/src/com/android/gallery3d/data/DataManager.java +++ b/src/com/android/gallery3d/data/DataManager.java @@ -28,7 +28,6 @@ import com.android.gallery3d.common.Utils; import com.android.gallery3d.data.MediaSet.ItemConsumer; import com.android.gallery3d.data.MediaSource.PathId; import com.android.gallery3d.picasasource.PicasaSource; -import com.android.gallery3d.util.LightCycleHelper; import java.util.ArrayList; import java.util.Comparator; @@ -131,7 +130,6 @@ public class DataManager { addSource(new SecureSource(mApplication)); addSource(new UriSource(mApplication)); addSource(new SnailSource(mApplication)); - addSource(LightCycleHelper.createMediaSourceInstance(mApplication)); if (mActiveCount > 0) { for (MediaSource source : mSourceMap.values()) { diff --git a/src/com/android/gallery3d/data/LocalAlbumSet.java b/src/com/android/gallery3d/data/LocalAlbumSet.java index afaac4965..b2b4b8c5d 100644 --- a/src/com/android/gallery3d/data/LocalAlbumSet.java +++ b/src/com/android/gallery3d/data/LocalAlbumSet.java @@ -26,7 +26,6 @@ import com.android.gallery3d.app.GalleryApp; import com.android.gallery3d.data.BucketHelper.BucketEntry; import com.android.gallery3d.util.Future; import com.android.gallery3d.util.FutureListener; -import com.android.gallery3d.util.LightCycleHelper; import com.android.gallery3d.util.MediaSetUtils; import com.android.gallery3d.util.ThreadPool; import com.android.gallery3d.util.ThreadPool.JobContext; @@ -128,11 +127,6 @@ public class LocalAlbumSet extends MediaSet for (BucketEntry entry : entries) { MediaSet album = getLocalAlbum(dataManager, mType, mPath, entry.bucketId, entry.bucketName); - if (LightCycleHelper.hasLightCycleCapture(mApplication.getAndroidContext()) - && album.isCameraRoll()) { - album = dataManager.getMediaSet(Path.fromString( - LightCycleHelper.wrapGalleryPath(album.getPath().toString()))); - } albums.add(album); } return albums; diff --git a/src/com/android/gallery3d/data/LocalImage.java b/src/com/android/gallery3d/data/LocalImage.java index 52f707b60..7006b0a82 100644 --- a/src/com/android/gallery3d/data/LocalImage.java +++ b/src/com/android/gallery3d/data/LocalImage.java @@ -33,6 +33,7 @@ import android.provider.MediaStore.MediaColumns; import android.util.Log; import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.app.StitchingProgressManager; import com.android.gallery3d.common.ApiHelper; import com.android.gallery3d.common.BitmapUtils; import com.android.gallery3d.util.GalleryUtils; @@ -236,6 +237,10 @@ public class LocalImage extends LocalMediaItem { @Override public int getSupportedOperations() { + StitchingProgressManager progressManager = mApplication.getStitchingProgressManager(); + if (progressManager != null && progressManager.getProgress(getContentUri()) != null) { + return 0; // doesn't support anything while stitching! + } int operation = SUPPORT_DELETE | SUPPORT_SHARE | SUPPORT_CROP | SUPPORT_SETAS | SUPPORT_EDIT | SUPPORT_INFO; if (BitmapUtils.isSupportedByRegionDecoder(mimeType)) { diff --git a/src/com/android/gallery3d/data/SecureAlbum.java b/src/com/android/gallery3d/data/SecureAlbum.java index 4e33cda49..c666bdc75 100644 --- a/src/com/android/gallery3d/data/SecureAlbum.java +++ b/src/com/android/gallery3d/data/SecureAlbum.java @@ -19,19 +19,17 @@ package com.android.gallery3d.data; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import android.provider.MediaStore.MediaColumns; import android.provider.MediaStore.Images; +import android.provider.MediaStore.MediaColumns; import android.provider.MediaStore.Video; import com.android.gallery3d.app.GalleryApp; -import com.android.gallery3d.app.StitchingChangeListener; -import com.android.gallery3d.app.StitchingProgressManager; import com.android.gallery3d.util.MediaSetUtils; import java.util.ArrayList; // This class lists all media items added by the client. -public class SecureAlbum extends MediaSet implements StitchingChangeListener { +public class SecureAlbum extends MediaSet { @SuppressWarnings("unused") private static final String TAG = "SecureAlbum"; private static final String[] PROJECTION = {MediaColumns._ID}; @@ -44,10 +42,8 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { // The types of items in mAllItems. True is video and false is image. private ArrayList mAllItemTypes = new ArrayList(); private ArrayList mExistingItems = new ArrayList(); - private ArrayList mStitchingItems = new ArrayList(); private Context mContext; private DataManager mDataManager; - private StitchingProgressManager mStitchingProgressManager; private static final Uri[] mWatchUris = {Images.Media.EXTERNAL_CONTENT_URI, Video.Media.EXTERNAL_CONTENT_URI}; private final ChangeNotifier mNotifier; @@ -64,8 +60,6 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { mUnlockItem = unlock; mShowUnlockItem = (!isCameraBucketEmpty(Images.Media.EXTERNAL_CONTENT_URI) || !isCameraBucketEmpty(Video.Media.EXTERNAL_CONTENT_URI)); - mStitchingProgressManager = application.getStitchingProgressManager(); - mStitchingProgressManager.addChangeListener(this); } public void addMediaItem(boolean isVideo, int id) { @@ -85,26 +79,14 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { // The sequence is stitching items, local media items, and unlock image. @Override public ArrayList getMediaItem(int start, int count) { - int stitchingCount = mStitchingItems.size(); int existingCount = mExistingItems.size(); - if (start >= stitchingCount + existingCount + 1) { + if (start >= existingCount + 1) { return new ArrayList(); } // Add paths of requested stitching items. - int end = Math.min(start + count, stitchingCount + existingCount); - ArrayList subset = new ArrayList(); - if (start < stitchingCount) { - subset.addAll(mStitchingItems.subList( - start, Math.min(stitchingCount, end))); - } - - // Add paths of requested local media items. - if (end >= stitchingCount) { - int existingStart = Math.max(0, start - stitchingCount); - int existingEnd = end - stitchingCount; - subset.addAll(mExistingItems.subList(existingStart, existingEnd)); - } + int end = Math.min(start + count, existingCount); + ArrayList subset = new ArrayList(mExistingItems.subList(start, end)); // Convert paths to media items. final MediaItem[] buf = new MediaItem[end - start]; @@ -125,8 +107,7 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { @Override public int getMediaItemCount() { - return (mStitchingItems.size() + mExistingItems.size() - + (mShowUnlockItem ? 1 : 0)); + return (mExistingItems.size() + (mShowUnlockItem ? 1 : 0)); } @Override @@ -202,26 +183,4 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { public boolean isLeafAlbum() { return true; } - - @Override - public void onStitchingQueued(Path path) { - mStitchingItems.add(path); - notifyContentChanged(); - } - - @Override - public void onStitchingResult(Path path, Uri uri) { - if (mStitchingItems.remove(path)) { - int id = Integer.parseInt(uri.getLastPathSegment()); - addMediaItem(false, id); - notifyContentChanged(); - } - } - - @Override - public void onStitchingProgress(Path path, int progress) { - if (mStitchingItems.contains(path)) { - notifyContentChanged(); - } - } } -- cgit v1.2.3