summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBobby Georgescu <georgescu@google.com>2012-10-02 13:30:09 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-02 14:25:05 -0700
commit7067fa61419d004d4f7d016556ca40512a26a118 (patch)
tree4f02b8bb60441cd1b88e39684f5a2886a48d4636 /src
parent1ebac746eb319663f44fe9fbb7786cb9bb87489b (diff)
downloadandroid_packages_apps_Snap-7067fa61419d004d4f7d016556ca40512a26a118.tar.gz
android_packages_apps_Snap-7067fa61419d004d4f7d016556ca40512a26a118.tar.bz2
android_packages_apps_Snap-7067fa61419d004d4f7d016556ca40512a26a118.zip
Show Camera placeholder as first filmstrip item in roll
Bug: 7272674 The camera roll filmstrip view now shows a shortcut to launch the camera when opened from the Gallery app. Note: the edits to SnailAlbum and SnailSource were made to allow sharing code between SingleItemAlbum and SnailAlbum Change-Id: I1bd2f3db99138c4b79a41c9c5baee46704cd18e0
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/AlbumSetPage.java1
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java20
-rw-r--r--src/com/android/gallery3d/data/CameraShortcutImage.java34
-rw-r--r--src/com/android/gallery3d/data/FilterSource.java19
-rw-r--r--src/com/android/gallery3d/data/MediaObject.java1
-rw-r--r--src/com/android/gallery3d/data/SingleItemAlbum.java68
-rw-r--r--src/com/android/gallery3d/data/SnailAlbum.java38
-rw-r--r--src/com/android/gallery3d/data/SnailSource.java4
8 files changed, 142 insertions, 43 deletions
diff --git a/src/com/android/gallery3d/app/AlbumSetPage.java b/src/com/android/gallery3d/app/AlbumSetPage.java
index a7d5d15ae..7af1d445e 100644
--- a/src/com/android/gallery3d/app/AlbumSetPage.java
+++ b/src/com/android/gallery3d/app/AlbumSetPage.java
@@ -276,6 +276,7 @@ public class AlbumSetPage extends ActivityState implements
data.putString(PhotoPage.KEY_MEDIA_SET_PATH,
mediaPath);
data.putBoolean(PhotoPage.KEY_START_IN_FILMSTRIP, true);
+ data.putBoolean(PhotoPage.KEY_IN_CAMERA_ROLL, targetSet.isCameraRoll());
mActivity.getStateManager().startStateForResult(
PhotoPage.class, AlbumPage.REQUEST_PHOTO, data);
return;
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index 8e2356e7b..e07746ed1 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -45,6 +45,7 @@ import com.android.gallery3d.common.Utils;
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.MediaDetails;
import com.android.gallery3d.data.MediaItem;
import com.android.gallery3d.data.MediaObject;
@@ -111,6 +112,7 @@ public class PhotoPage extends ActivityState implements
public static final String KEY_START_IN_FILMSTRIP = "start-in-filmstrip";
public static final String KEY_RETURN_INDEX_HINT = "return-index-hint";
public static final String KEY_SHOW_WHEN_LOCKED = "show_when_locked";
+ public static final String KEY_IN_CAMERA_ROLL = "in_camera_roll";
public static final String KEY_ALBUMPAGE_TRANSITION = "albumpage-transition";
public static final int MSG_ALBUMPAGE_NONE = 0;
@@ -156,6 +158,7 @@ public class PhotoPage extends ActivityState implements
private boolean mHasActivityResult;
private boolean mTreatBackAsUp;
private boolean mStartInFilmstrip;
+ private boolean mInCameraRoll;
private boolean mStartedFromAlbumPage;
private long mCameraSwitchCutoff = 0;
@@ -321,16 +324,17 @@ public class PhotoPage extends ActivityState implements
Path.fromString(data.getString(KEY_MEDIA_ITEM_PATH)) :
null;
mTreatBackAsUp = data.getBoolean(KEY_TREAT_BACK_AS_UP, false);
- mStartInFilmstrip =
- data.getBoolean(KEY_START_IN_FILMSTRIP, false);
+ mStartInFilmstrip = data.getBoolean(KEY_START_IN_FILMSTRIP, false);
+ mInCameraRoll = data.getBoolean(KEY_IN_CAMERA_ROLL, false);
mStartedFromAlbumPage =
data.getInt(KEY_ALBUMPAGE_TRANSITION,
MSG_ALBUMPAGE_NONE) == MSG_ALBUMPAGE_STARTED;
+ mCurrentIndex = data.getInt(KEY_INDEX_HINT, 0);
if (mSetPathString != null) {
mAppBridge = (AppBridge) data.getParcelable(KEY_APP_BRIDGE);
if (mAppBridge != null) {
mShowBars = false;
-
+ mInCameraRoll = true;
mAppBridge.setServer(this);
mOrientationManager.lockOrientation();
@@ -366,11 +370,15 @@ public class PhotoPage extends ActivityState implements
// Start from the screen nail.
itemPath = screenNailItemPath;
+ } else if (mInCameraRoll && GalleryUtils.isCameraAvailable(mActivity)) {
+ mSetPathString = "/combo/item/{" + FilterSource.FILTER_CAMERA_SHORTCUT +
+ "," + mSetPathString + "}";
+ mCurrentIndex++;
}
MediaSet originalSet = mActivity.getDataManager()
.getMediaSet(mSetPathString);
- if (originalSet instanceof ComboAlbum) {
+ if (mInCameraRoll && originalSet instanceof ComboAlbum) {
// Use the name of the camera album rather than the default
// ComboAlbum behavior
((ComboAlbum) originalSet).useNameOfChild(1);
@@ -379,7 +387,6 @@ public class PhotoPage extends ActivityState implements
mSetPathString = "/filter/delete/{" + mSetPathString + "}";
mMediaSet = (FilterDeleteSet) mActivity.getDataManager()
.getMediaSet(mSetPathString);
- mCurrentIndex = data.getInt(KEY_INDEX_HINT, 0);
if (mMediaSet == null) {
Log.w(TAG, "failed to restore " + mSetPathString);
}
@@ -973,6 +980,7 @@ public class PhotoPage extends ActivityState implements
((supported & MediaItem.SUPPORT_PLAY) != 0);
boolean unlock = ((supported & MediaItem.SUPPORT_UNLOCK) != 0);
boolean goBack = ((supported & MediaItem.SUPPORT_BACK) != 0);
+ boolean launchCamera = ((supported & MediaItem.SUPPORT_CAMERA_SHORTCUT) != 0);
if (playVideo) {
// determine if the point is at center (1/6) of the photo view.
@@ -989,6 +997,8 @@ public class PhotoPage extends ActivityState implements
onBackPressed();
} else if (unlock) {
mActivity.getStateManager().finishState(this);
+ } else if (launchCamera) {
+ GalleryUtils.startCameraActivity(mActivity);
} else {
toggleBars();
}
diff --git a/src/com/android/gallery3d/data/CameraShortcutImage.java b/src/com/android/gallery3d/data/CameraShortcutImage.java
new file mode 100644
index 000000000..865270b4c
--- /dev/null
+++ b/src/com/android/gallery3d/data/CameraShortcutImage.java
@@ -0,0 +1,34 @@
+/*
+ * 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 com.android.gallery3d.R;
+import com.android.gallery3d.app.GalleryApp;
+
+public class CameraShortcutImage extends ActionImage {
+ @SuppressWarnings("unused")
+ private static final String TAG = "CameraShortcutImage";
+
+ public CameraShortcutImage(Path path, GalleryApp application) {
+ super(path, application, R.drawable.placeholder_camera);
+ }
+
+ @Override
+ public int getSupportedOperations() {
+ return super.getSupportedOperations() | SUPPORT_CAMERA_SHORTCUT;
+ }
+}
diff --git a/src/com/android/gallery3d/data/FilterSource.java b/src/com/android/gallery3d/data/FilterSource.java
index 3244da34f..d689fe336 100644
--- a/src/com/android/gallery3d/data/FilterSource.java
+++ b/src/com/android/gallery3d/data/FilterSource.java
@@ -18,19 +18,24 @@ package com.android.gallery3d.data;
import com.android.gallery3d.app.GalleryApp;
-class FilterSource extends MediaSource {
+public class FilterSource extends MediaSource {
@SuppressWarnings("unused")
private static final String TAG = "FilterSource";
private static final int FILTER_BY_MEDIATYPE = 0;
private static final int FILTER_BY_DELETE = 1;
private static final int FILTER_BY_EMPTY = 2;
private static final int FILTER_BY_EMPTY_ITEM = 3;
+ private static final int FILTER_BY_CAMERA_SHORTCUT = 4;
+ private static final int FILTER_BY_CAMERA_SHORTCUT_ITEM = 5;
public static final String FILTER_EMPTY_ITEM = "/filter/empty_prompt";
+ public static final String FILTER_CAMERA_SHORTCUT = "/filter/camera_shortcut";
+ private static final String FILTER_CAMERA_SHORTCUT_ITEM = "/filter/camera_shortcut_item";
private GalleryApp mApplication;
private PathMatcher mMatcher;
private MediaItem mEmptyItem;
+ private MediaItem mCameraShortcutItem;
public FilterSource(GalleryApp application) {
super("filter");
@@ -39,10 +44,14 @@ class FilterSource extends MediaSource {
mMatcher.add("/filter/mediatype/*/*", FILTER_BY_MEDIATYPE);
mMatcher.add("/filter/delete/*", FILTER_BY_DELETE);
mMatcher.add("/filter/empty/*", FILTER_BY_EMPTY);
- mMatcher.add("/filter/empty_item", FILTER_BY_EMPTY_ITEM);
+ mMatcher.add(FILTER_EMPTY_ITEM, FILTER_BY_EMPTY_ITEM);
+ mMatcher.add(FILTER_CAMERA_SHORTCUT, FILTER_BY_CAMERA_SHORTCUT);
+ mMatcher.add(FILTER_CAMERA_SHORTCUT_ITEM, FILTER_BY_CAMERA_SHORTCUT_ITEM);
mEmptyItem = new EmptyAlbumImage(Path.fromString(FILTER_EMPTY_ITEM),
mApplication);
+ mCameraShortcutItem = new CameraShortcutImage(
+ Path.fromString(FILTER_CAMERA_SHORTCUT_ITEM), mApplication);
}
// The name we accept are:
@@ -72,6 +81,12 @@ class FilterSource extends MediaSource {
case FILTER_BY_EMPTY_ITEM: {
return mEmptyItem;
}
+ case FILTER_BY_CAMERA_SHORTCUT: {
+ return new SingleItemAlbum(path, mCameraShortcutItem);
+ }
+ case FILTER_BY_CAMERA_SHORTCUT_ITEM: {
+ return mCameraShortcutItem;
+ }
default:
throw new RuntimeException("bad path: " + path);
}
diff --git a/src/com/android/gallery3d/data/MediaObject.java b/src/com/android/gallery3d/data/MediaObject.java
index 9e8d84ca7..e738011ef 100644
--- a/src/com/android/gallery3d/data/MediaObject.java
+++ b/src/com/android/gallery3d/data/MediaObject.java
@@ -41,6 +41,7 @@ public abstract class MediaObject {
public static final int SUPPORT_UNLOCK = 1 << 14;
public static final int SUPPORT_BACK = 1 << 15;
public static final int SUPPORT_ACTION = 1 << 16;
+ public static final int SUPPORT_CAMERA_SHORTCUT = 1 << 17;
public static final int SUPPORT_ALL = 0xffffffff;
// These are the bits returned from getMediaType():
diff --git a/src/com/android/gallery3d/data/SingleItemAlbum.java b/src/com/android/gallery3d/data/SingleItemAlbum.java
new file mode 100644
index 000000000..a0093e0c3
--- /dev/null
+++ b/src/com/android/gallery3d/data/SingleItemAlbum.java
@@ -0,0 +1,68 @@
+/*
+ * 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 java.util.ArrayList;
+
+public class SingleItemAlbum extends MediaSet {
+ @SuppressWarnings("unused")
+ private static final String TAG = "SingleItemAlbum";
+ private final MediaItem mItem;
+ private final String mName;
+
+ public SingleItemAlbum(Path path, MediaItem item) {
+ super(path, nextVersionNumber());
+ mItem = item;
+ mName = "SingleItemAlbum("+mItem.getClass().getSimpleName()+")";
+ }
+
+ @Override
+ public int getMediaItemCount() {
+ return 1;
+ }
+
+ @Override
+ public ArrayList<MediaItem> getMediaItem(int start, int count) {
+ ArrayList<MediaItem> result = new ArrayList<MediaItem>();
+
+ // If [start, start+count) contains the index 0, return the item.
+ if (start <= 0 && start + count > 0) {
+ result.add(mItem);
+ }
+
+ return result;
+ }
+
+ public MediaItem getItem() {
+ return mItem;
+ }
+
+ @Override
+ public boolean isLeafAlbum() {
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return mName;
+ }
+
+ @Override
+ public long reload() {
+ return mDataVersion;
+ }
+}
diff --git a/src/com/android/gallery3d/data/SnailAlbum.java b/src/com/android/gallery3d/data/SnailAlbum.java
index 18905fb2b..7bce7a695 100644
--- a/src/com/android/gallery3d/data/SnailAlbum.java
+++ b/src/com/android/gallery3d/data/SnailAlbum.java
@@ -16,52 +16,22 @@
package com.android.gallery3d.data;
-import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
// This is a simple MediaSet which contains only one MediaItem -- a SnailItem.
-public class SnailAlbum extends MediaSet {
+public class SnailAlbum extends SingleItemAlbum {
@SuppressWarnings("unused")
private static final String TAG = "SnailAlbum";
- private SnailItem mItem;
private AtomicBoolean mDirty = new AtomicBoolean(false);
- public SnailAlbum(Path path, MediaItem item) {
- super(path, nextVersionNumber());
- mItem = (SnailItem) item;
- }
-
- @Override
- public int getMediaItemCount() {
- return 1;
- }
-
- @Override
- public ArrayList<MediaItem> getMediaItem(int start, int count) {
- ArrayList<MediaItem> result = new ArrayList<MediaItem>();
-
- // If [start, start+count) contains the index 0, return the item.
- if (start <= 0 && start + count > 0) {
- result.add(mItem);
- }
-
- return result;
- }
-
- @Override
- public boolean isLeafAlbum() {
- return true;
- }
-
- @Override
- public String getName() {
- return "SnailAlbum";
+ public SnailAlbum(Path path, SnailItem item) {
+ super(path, item);
}
@Override
public long reload() {
if (mDirty.compareAndSet(true, false)) {
- mItem.updateVersion();
+ ((SnailItem) getItem()).updateVersion();
mDataVersion = nextVersionNumber();
}
return mDataVersion;
diff --git a/src/com/android/gallery3d/data/SnailSource.java b/src/com/android/gallery3d/data/SnailSource.java
index 7f971d3e0..5c690ccdb 100644
--- a/src/com/android/gallery3d/data/SnailSource.java
+++ b/src/com/android/gallery3d/data/SnailSource.java
@@ -42,8 +42,8 @@ public class SnailSource extends MediaSource {
switch (mMatcher.match(path)) {
case SNAIL_ALBUM:
String itemPath = "/snail/item/" + mMatcher.getVar(0);
- MediaItem item =
- (MediaItem) dataManager.getMediaObject(itemPath);
+ SnailItem item =
+ (SnailItem) dataManager.getMediaObject(itemPath);
return new SnailAlbum(path, item);
case SNAIL_ITEM: {
int id = mMatcher.getIntVar(0);