diff options
author | Wu-cheng Li <wuchengli@google.com> | 2012-10-09 14:44:31 +0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-10-09 07:53:12 -0700 |
commit | ef9ff4b41f483c9c10ff7557bc7ffd7907449213 (patch) | |
tree | 309391c5c4c8767fa08bcc7a383276d191986550 /src/com/android/gallery3d/data/SecureAlbum.java | |
parent | 91af43b868a77560bbb43d2714d5685caa179fc7 (diff) | |
download | android_packages_apps_Snap-ef9ff4b41f483c9c10ff7557bc7ffd7907449213.tar.gz android_packages_apps_Snap-ef9ff4b41f483c9c10ff7557bc7ffd7907449213.tar.bz2 android_packages_apps_Snap-ef9ff4b41f483c9c10ff7557bc7ffd7907449213.zip |
Handle stitching progress in secure album.
- In secure album, show stitching progress only if it is
captured after the device is locked.
- Make sure image capture intent does not show stitching
progress.
bug:7285105
Change-Id: I0b3ba60fe3c03f488bea25e2f09843dd84ab6dfb
Diffstat (limited to 'src/com/android/gallery3d/data/SecureAlbum.java')
-rw-r--r-- | src/com/android/gallery3d/data/SecureAlbum.java | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/data/SecureAlbum.java b/src/com/android/gallery3d/data/SecureAlbum.java index 382de5bb2..4e33cda49 100644 --- a/src/com/android/gallery3d/data/SecureAlbum.java +++ b/src/com/android/gallery3d/data/SecureAlbum.java @@ -25,6 +25,7 @@ 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; @@ -43,9 +44,10 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { // The types of items in mAllItems. True is video and false is image. private ArrayList<Boolean> mAllItemTypes = new ArrayList<Boolean>(); private ArrayList<Path> mExistingItems = new ArrayList<Path>(); - private ArrayList<String> mStitchingFilePaths = new ArrayList<String>(); + private ArrayList<Path> mStitchingItems = new ArrayList<Path>(); 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; @@ -62,7 +64,8 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { mUnlockItem = unlock; mShowUnlockItem = (!isCameraBucketEmpty(Images.Media.EXTERNAL_CONTENT_URI) || !isCameraBucketEmpty(Video.Media.EXTERNAL_CONTENT_URI)); - application.getStitchingProgressManager().addChangeListener(this); + mStitchingProgressManager = application.getStitchingProgressManager(); + mStitchingProgressManager.addChangeListener(this); } public void addMediaItem(boolean isVideo, int id) { @@ -79,14 +82,31 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { mNotifier.fakeChange(); } + // The sequence is stitching items, local media items, and unlock image. @Override public ArrayList<MediaItem> getMediaItem(int start, int count) { - if (start >= mExistingItems.size() + 1) { + int stitchingCount = mStitchingItems.size(); + int existingCount = mExistingItems.size(); + if (start >= stitchingCount + existingCount + 1) { return new ArrayList<MediaItem>(); } - int end = Math.min(start + count, mExistingItems.size()); - ArrayList<Path> subset = new ArrayList<Path>( - mExistingItems.subList(start, end)); + + // Add paths of requested stitching items. + int end = Math.min(start + count, stitchingCount + existingCount); + ArrayList<Path> subset = new ArrayList<Path>(); + 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)); + } + + // Convert paths to media items. final MediaItem[] buf = new MediaItem[end - start]; ItemConsumer consumer = new ItemConsumer() { @Override @@ -105,7 +125,8 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { @Override public int getMediaItemCount() { - return mExistingItems.size() + (mShowUnlockItem ? 1 : 0); + return (mStitchingItems.size() + mExistingItems.size() + + (mShowUnlockItem ? 1 : 0)); } @Override @@ -183,19 +204,24 @@ public class SecureAlbum extends MediaSet implements StitchingChangeListener { } @Override - public void onStitchingQueued(String filePath) { - mStitchingFilePaths.add(filePath); + public void onStitchingQueued(Path path) { + mStitchingItems.add(path); + notifyContentChanged(); } @Override - public void onStitchingResult(String filePath, Uri uri) { - if (mStitchingFilePaths.remove(filePath)) { + 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(String filePath, int progress) { + public void onStitchingProgress(Path path, int progress) { + if (mStitchingItems.contains(path)) { + notifyContentChanged(); + } } } |