diff options
| author | Wu-cheng Li <wuchengli@google.com> | 2012-09-25 02:59:17 -0700 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-25 02:59:18 -0700 |
| commit | b24323c723fa55f057211f785b17e2d0d534eb7d (patch) | |
| tree | 6680ec94c8c2d5d3da29fc36687f45759f07e568 | |
| parent | 32de13e9dd6905f548ca74a60056fabd4c499b99 (diff) | |
| parent | b2f6a0c2d2ecbac4047f96621980ba36d3c647c8 (diff) | |
| download | android_packages_apps_Snap-b24323c723fa55f057211f785b17e2d0d534eb7d.tar.gz android_packages_apps_Snap-b24323c723fa55f057211f785b17e2d0d534eb7d.tar.bz2 android_packages_apps_Snap-b24323c723fa55f057211f785b17e2d0d534eb7d.zip | |
Merge "Add an unlock image in the end of secure album." into gb-ub-photos-arches
| -rw-r--r-- | src/com/android/gallery3d/app/PhotoPage.java | 8 | ||||
| -rw-r--r-- | src/com/android/gallery3d/data/MediaObject.java | 1 | ||||
| -rw-r--r-- | src/com/android/gallery3d/data/SecureAlbum.java | 11 | ||||
| -rw-r--r-- | src/com/android/gallery3d/data/SecureSource.java | 12 | ||||
| -rw-r--r-- | src/com/android/gallery3d/data/UnlockImage.java | 102 |
5 files changed, 127 insertions, 7 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java index 5f97fb2f7..46a04f057 100644 --- a/src/com/android/gallery3d/app/PhotoPage.java +++ b/src/com/android/gallery3d/app/PhotoPage.java @@ -877,10 +877,12 @@ public class PhotoPage extends ActivityState implements return; } + int supported = item.getSupportedOperations(); boolean playVideo = (mSecureAlbum == null) && - ((item.getSupportedOperations() & MediaItem.SUPPORT_PLAY) != 0); + ((supported & MediaItem.SUPPORT_PLAY) != 0); boolean viewPanorama = (mSecureAlbum == null) && - (item.getSupportedOperations() & MediaItem.SUPPORT_PANORAMA) != 0; + ((supported & MediaItem.SUPPORT_PANORAMA) != 0); + boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0); if (playVideo) { // determine if the point is at center (1/6) of the photo view. @@ -895,6 +897,8 @@ public class PhotoPage extends ActivityState implements playVideo(mActivity, item.getPlayUri(), item.getName()); } else if (viewPanorama) { LightCycleHelper.viewPanorama(mActivity, item.getContentUri()); + } else if (unlock) { + mActivity.getStateManager().finishState(this); } else { toggleBars(); } diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java index 917f6953e..b4aa8d861 100644 --- a/src/com/android/gallery3d/data/MediaObject.java +++ b/src/com/android/gallery3d/data/MediaObject.java @@ -38,6 +38,7 @@ public abstract class MediaObject { public static final int SUPPORT_IMPORT = 1 << 11; public static final int SUPPORT_TRIM = 1 << 12; public static final int SUPPORT_PANORAMA = 1 << 13; + public static final int SUPPORT_UNLOCK = 1 << 14; public static final int SUPPORT_ALL = 0xffffffff; // These are the bits returned from getMediaType(): diff --git a/src/com/android/gallery3d/data/SecureAlbum.java b/src/com/android/gallery3d/data/SecureAlbum.java index 01f86ff0c..42364b5e9 100644 --- a/src/com/android/gallery3d/data/SecureAlbum.java +++ b/src/com/android/gallery3d/data/SecureAlbum.java @@ -46,12 +46,16 @@ public class SecureAlbum extends MediaSet { private static final Uri[] mWatchUris = {Images.Media.EXTERNAL_CONTENT_URI, Video.Media.EXTERNAL_CONTENT_URI}; private final ChangeNotifier mNotifier; + // A placeholder image in the end of secure album. When it is tapped, it + // will take the user to the lock screen. + private MediaItem mUnlockItem; - public SecureAlbum(Path path, GalleryApp application) { + public SecureAlbum(Path path, GalleryApp application, MediaItem unlock) { super(path, nextVersionNumber()); mContext = application.getAndroidContext(); mDataManager = application.getDataManager(); mNotifier = new ChangeNotifier(this, mWatchUris, application); + mUnlockItem = unlock; } public void addMediaItem(boolean isVideo, int id) { @@ -70,7 +74,7 @@ public class SecureAlbum extends MediaSet { @Override public ArrayList<MediaItem> getMediaItem(int start, int count) { - if (start >= mExistingItems.size()) { + if (start >= mExistingItems.size() + 1) { return new ArrayList<MediaItem>(); } int end = Math.min(start + count, mExistingItems.size()); @@ -88,12 +92,13 @@ public class SecureAlbum extends MediaSet { for (int i = 0; i < buf.length; i++) { result.add(buf[i]); } + result.add(mUnlockItem); return result; } @Override public int getMediaItemCount() { - return mExistingItems.size(); + return mExistingItems.size() + 1; } @Override diff --git a/src/com/android/gallery3d/data/SecureSource.java b/src/com/android/gallery3d/data/SecureSource.java index 9e89438e6..6bc8cc295 100644 --- a/src/com/android/gallery3d/data/SecureSource.java +++ b/src/com/android/gallery3d/data/SecureSource.java @@ -22,9 +22,11 @@ public class SecureSource extends MediaSource { private GalleryApp mApplication; private static PathMatcher mMatcher = new PathMatcher(); private static final int SECURE_ALBUM = 0; + private static final int SECURE_UNLOCK = 1; static { mMatcher.add("/secure/all/*", SECURE_ALBUM); + mMatcher.add("/secure/unlock", SECURE_UNLOCK); } public SecureSource(GalleryApp context) { @@ -39,8 +41,14 @@ public class SecureSource extends MediaSource { @Override public MediaObject createMediaObject(Path path) { switch (mMatcher.match(path)) { - case SECURE_ALBUM: - return new SecureAlbum(path, mApplication); + case SECURE_ALBUM: { + DataManager dataManager = mApplication.getDataManager(); + MediaItem unlock = (MediaItem) dataManager.getMediaObject( + "/secure/unlock"); + return new SecureAlbum(path, mApplication, unlock); + } + case SECURE_UNLOCK: + return new UnlockImage(path, mApplication); default: throw new RuntimeException("bad path: " + path); } diff --git a/src/com/android/gallery3d/data/UnlockImage.java b/src/com/android/gallery3d/data/UnlockImage.java new file mode 100644 index 000000000..68e6f0f9c --- /dev/null +++ b/src/com/android/gallery3d/data/UnlockImage.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.gallery3d.data; + +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.BitmapRegionDecoder; +import android.net.Uri; + +import com.android.gallery3d.app.GalleryApp; +import com.android.gallery3d.common.BitmapUtils; +import com.android.gallery3d.common.Utils; +import com.android.gallery3d.util.ThreadPool.Job; +import com.android.gallery3d.util.ThreadPool.JobContext; +import com.android.gallery3d.R; + +public class UnlockImage extends MediaItem { + @SuppressWarnings("unused") + private static final String TAG = "UnlockImage"; + private GalleryApp mApplication; + + public UnlockImage(Path path, GalleryApp application) { + super(path, nextVersionNumber()); + mApplication = Utils.checkNotNull(application); + } + + @Override + public Job<Bitmap> requestImage(int type) { + return new BitmapJob(type); + } + + @Override + public Job<BitmapRegionDecoder> requestLargeImage() { + return null; + } + + private class BitmapJob implements Job<Bitmap> { + private int mType; + + protected BitmapJob(int type) { + mType = type; + } + + @Override + public Bitmap run(JobContext jc) { + int targetSize = MediaItem.getTargetSize(mType); + Bitmap bitmap = BitmapFactory.decodeResource(mApplication.getResources(), + R.drawable.ic_lockscreen_unlock_normal); + + if (mType == MediaItem.TYPE_MICROTHUMBNAIL) { + bitmap = BitmapUtils.resizeAndCropCenter(bitmap, targetSize, true); + } else { + bitmap = BitmapUtils.resizeDownBySideLength(bitmap, targetSize, true); + } + return bitmap; + } + } + + @Override + public int getSupportedOperations() { + return SUPPORT_UNLOCK; + } + + @Override + public int getMediaType() { + return MEDIA_TYPE_IMAGE; + } + + @Override + public Uri getContentUri() { + return null; + } + + @Override + public String getMimeType() { + return ""; + } + + @Override + public int getWidth() { + return 0; + } + + @Override + public int getHeight() { + return 0; + } +} |
