summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngus Kong <shkong@google.com>2013-06-04 00:44:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-06-04 00:44:00 +0000
commit44c5d5ce423bde77019b7dc2c567588b32a51d11 (patch)
tree68ac1e33dd41fbb16fef82ff92d437610a7435ac
parent8ce743f577b2056519fd8e74da272c461ff74e33 (diff)
parenta06b4e2f2664bdd0b966ed3fb24e560cd9be7124 (diff)
downloadandroid_packages_apps_Snap-44c5d5ce423bde77019b7dc2c567588b32a51d11.tar.gz
android_packages_apps_Snap-44c5d5ce423bde77019b7dc2c567588b32a51d11.tar.bz2
android_packages_apps_Snap-44c5d5ce423bde77019b7dc2c567588b32a51d11.zip
Merge "Add secure camera support." into gb-ub-photos-carlsbad
-rw-r--r--src/com/android/camera/NewCameraActivity.java19
-rw-r--r--src/com/android/camera/data/CameraDataAdapter.java88
-rw-r--r--src/com/android/camera/data/LocalData.java74
3 files changed, 139 insertions, 42 deletions
diff --git a/src/com/android/camera/NewCameraActivity.java b/src/com/android/camera/NewCameraActivity.java
index 3aee15053..2705bcf50 100644
--- a/src/com/android/camera/NewCameraActivity.java
+++ b/src/com/android/camera/NewCameraActivity.java
@@ -37,8 +37,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
+import android.widget.ImageView;
import com.android.camera.data.CameraDataAdapter;
+import com.android.camera.data.LocalData;
import com.android.camera.ui.CameraSwitcher.CameraSwitchListener;
import com.android.camera.ui.FilmStripView;
import com.android.camera.ui.NewCameraRootView;
@@ -148,8 +150,6 @@ public class NewCameraActivity extends Activity
String action = intent.getAction();
if (INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE.equals(action)) {
mSecureCamera = true;
- // Use a new album when this is started from the lock screen.
- //TODO: sSecureAlbumId++;
} else if (ACTION_IMAGE_CAPTURE_SECURE.equals(action)) {
mSecureCamera = true;
} else {
@@ -232,7 +232,20 @@ public class NewCameraActivity extends Activity
mCurrentModule.onResumeAfterSuper();
// The loading is done in background and will update the filmstrip later.
- mDataAdapter.requestLoad(getContentResolver());
+ if (!mSecureCamera) {
+ mDataAdapter.requestLoad(getContentResolver());
+ } else {
+ // Flush out all the original data first.
+ mDataAdapter.flush();
+ ImageView v = (ImageView) getLayoutInflater().inflate(
+ R.layout.secure_album_placeholder, null);
+ mDataAdapter.addLocalData(
+ new LocalData.LocalViewData(
+ v,
+ v.getDrawable().getIntrinsicWidth(),
+ v.getDrawable().getIntrinsicHeight(),
+ 0, 0));
+ }
}
@Override
diff --git a/src/com/android/camera/data/CameraDataAdapter.java b/src/com/android/camera/data/CameraDataAdapter.java
index 6e2ff101b..32b3afecc 100644
--- a/src/com/android/camera/data/CameraDataAdapter.java
+++ b/src/com/android/camera/data/CameraDataAdapter.java
@@ -164,6 +164,55 @@ public class CameraDataAdapter implements FilmStripView.DataAdapter {
}
}
+ // Update all the data but keep the camera data if already set.
+ private void replaceData(List<LocalData> list) {
+ boolean changed = (list != mImages);
+ LocalData cameraData = null;
+ if (mImages != null && mImages.size() > 0) {
+ cameraData = mImages.get(0);
+ if (cameraData.getType() != ImageData.TYPE_CAMERA_PREVIEW) {
+ cameraData = null;
+ }
+ }
+
+ mImages = list;
+ if (cameraData != null) {
+ // camera view exists, so we make sure at least 1 data is in the list.
+ if (mImages == null) {
+ mImages = new ArrayList<LocalData>();
+ }
+ mImages.add(0, cameraData);
+ if (mListener != null) {
+ // Only the camera data is not changed, everything else is changed.
+ mListener.onDataUpdated(new UpdateReporter() {
+ @Override
+ public boolean isDataRemoved(int id) {
+ return false;
+ }
+
+ @Override
+ public boolean isDataUpdated(int id) {
+ if (id == 0) return false;
+ return true;
+ }
+ });
+ }
+ } else {
+ // both might be null.
+ if (changed) {
+ mListener.onDataLoaded();
+ }
+ }
+ }
+
+ public void flush() {
+ replaceData(null);
+ }
+
+ public void addLocalData(LocalData data) {
+ insertData(data);
+ }
+
private LocalData buildCameraImageData(int width, int height) {
LocalData d = new CameraPreviewData(width, height);
return d;
@@ -277,43 +326,7 @@ public class CameraDataAdapter implements FilmStripView.DataAdapter {
@Override
protected void onPostExecute(List<LocalData> l) {
- boolean changed = (l != mImages);
- LocalData cameraData = null;
- if (mImages != null && mImages.size() > 0) {
- cameraData = mImages.get(0);
- if (cameraData.getType() != ImageData.TYPE_CAMERA_PREVIEW) {
- cameraData = null;
- }
- }
-
- mImages = l;
- if (cameraData != null) {
- // camera view exists, so we make sure at least 1 data is in the list.
- if (mImages == null) {
- mImages = new ArrayList<LocalData>();
- }
- mImages.add(0, cameraData);
- if (mListener != null) {
- // Only the camera data is not changed, everything else is changed.
- mListener.onDataUpdated(new UpdateReporter() {
- @Override
- public boolean isDataRemoved(int id) {
- return false;
- }
-
- @Override
- public boolean isDataUpdated(int id) {
- if (id == 0) return false;
- return true;
- }
- });
- }
- } else {
- // both might be null.
- if (changed) {
- mListener.onDataLoaded();
- }
- }
+ replaceData(l);
}
}
@@ -378,5 +391,4 @@ public class CameraDataAdapter implements FilmStripView.DataAdapter {
// do nothing.
}
}
-
}
diff --git a/src/com/android/camera/data/LocalData.java b/src/com/android/camera/data/LocalData.java
index 5acdee162..9ebc9caa3 100644
--- a/src/com/android/camera/data/LocalData.java
+++ b/src/com/android/camera/data/LocalData.java
@@ -41,7 +41,7 @@ import java.util.Date;
/* An abstract interface that represents the local media data. Also implements
* Comparable interface so we can sort in DataAdapter.
*/
-abstract interface LocalData extends FilmStripView.ImageData {
+public abstract interface LocalData extends FilmStripView.ImageData {
static final String TAG = "LocalData";
abstract View getView(Context c, int width, int height, Drawable placeHolder);
@@ -454,5 +454,77 @@ abstract interface LocalData extends FilmStripView.ImageData {
}
}
}
+
+ /*
+ * A LocalData that does nothing but only shows a view.
+ */
+ public static class LocalViewData implements LocalData {
+ private int mWidth;
+ private int mHeight;
+ View mView;
+ private long mDateTaken;
+ private long mDateModified;
+
+ public LocalViewData(View v,
+ int width, int height,
+ int dateTaken, int dateModified) {
+ mView = v;
+ mWidth = width;
+ mHeight = height;
+ mDateTaken = dateTaken;
+ mDateModified = dateModified;
+ }
+
+ @Override
+ public long getDateTaken() {
+ return mDateTaken;
+ }
+
+ @Override
+ public long getDateModified() {
+ return mDateModified;
+ }
+
+ @Override
+ public String getTitle() {
+ return "";
+ }
+
+ @Override
+ public int getWidth() {
+ return mWidth;
+ }
+
+ @Override
+ public int getHeight() {
+ return mHeight;
+ }
+
+ @Override
+ public int getType() {
+ return FilmStripView.ImageData.TYPE_PHOTO;
+ }
+
+ @Override
+ public boolean isActionSupported(int action) {
+ if (action == FilmStripView.ImageData.ACTION_PLAY) return true;
+ return false;
+ }
+
+ @Override
+ public View getView(Context c, int width, int height, Drawable placeHolder) {
+ return mView;
+ }
+
+ @Override
+ public void prepare() {
+ // do nothing.
+ }
+
+ @Override
+ public void recycle() {
+ // do nothing.
+ }
+ }
}