summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CameraActivity.java
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2015-11-17 14:20:30 -0800
committerJay Wang <jaywang@codeaurora.org>2016-03-30 15:54:11 -0700
commit3618eb79912c36216b197580e54e366ab19d2a61 (patch)
treed3157d73b7a15382a5562e25e6cb72f073228835 /src/com/android/camera/CameraActivity.java
parentbdabec40fc13076c07fba8bb5d04a104cab2ddce (diff)
downloadandroid_packages_apps_Snap-3618eb79912c36216b197580e54e366ab19d2a61.tar.gz
android_packages_apps_Snap-3618eb79912c36216b197580e54e366ab19d2a61.tar.bz2
android_packages_apps_Snap-3618eb79912c36216b197580e54e366ab19d2a61.zip
SnapdragonCamera: Add Camera2 mode
Use camera2 API to show preview and take snapshot CRs-Fixed: 989750 Change-Id: I07e2d6743529b3d3d5acecf667e9493465a094c9
Diffstat (limited to 'src/com/android/camera/CameraActivity.java')
-rw-r--r--src/com/android/camera/CameraActivity.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 5e1d5f88f..80387a946 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -159,6 +159,8 @@ public class CameraActivity extends Activity
/** Whether onResume should reset the view to the preview. */
private boolean mResetToPreviewOnResume = true;
+ public static boolean CAMERA_2_ON = false;
+
// Supported operations at FilmStripView. Different data has different
// set of supported operations.
private static final int SUPPORT_DELETE = 1 << 0;
@@ -189,11 +191,13 @@ public class CameraActivity extends Activity
private PhotoModule mPhotoModule;
private VideoModule mVideoModule;
private WideAnglePanoramaModule mPanoModule;
+ private CaptureModule mCaptureModule;
private FrameLayout mAboveFilmstripControlLayout;
private FrameLayout mCameraRootFrame;
private View mCameraPhotoModuleRootView;
private View mCameraVideoModuleRootView;
private View mCameraPanoModuleRootView;
+ private View mCameraCaptureModuleRootView;
private FilmStripView mFilmStripView;
private ProgressBar mBottomProgress;
private View mPanoStitchingPanel;
@@ -705,6 +709,7 @@ public class CameraActivity extends Activity
}
public void updateThumbnail(final Bitmap bitmap) {
+ if (bitmap == null) return;
mThumbnailDrawable = new CircularDrawable(bitmap);
if (mThumbnail != null) {
mThumbnail.setImageDrawable(mThumbnailDrawable);
@@ -714,6 +719,7 @@ public class CameraActivity extends Activity
public void updateThumbnail(ImageView thumbnail) {
mThumbnail = thumbnail;
+ if (mThumbnail == null) return;
if (mThumbnailDrawable != null) {
mThumbnail.setImageDrawable(mThumbnailDrawable);
mThumbnail.setVisibility(View.VISIBLE);
@@ -1409,6 +1415,7 @@ public class CameraActivity extends Activity
mCameraPhotoModuleRootView = rootLayout.findViewById(R.id.camera_photo_root);
mCameraVideoModuleRootView = rootLayout.findViewById(R.id.camera_video_root);
mCameraPanoModuleRootView = rootLayout.findViewById(R.id.camera_pano_root);
+ mCameraCaptureModuleRootView = rootLayout.findViewById(R.id.camera_capture_root);
int moduleIndex = -1;
if (MediaStore.INTENT_ACTION_VIDEO_CAMERA.equals(getIntent().getAction())
@@ -1436,6 +1443,11 @@ public class CameraActivity extends Activity
moduleIndex = ModuleSwitcher.PHOTO_MODULE_INDEX;
}
}
+ SharedPreferences pref = PreferenceManager
+ .getDefaultSharedPreferences(this);
+ CAMERA_2_ON = pref.getBoolean(CameraSettings.KEY_CAMERA2, false);
+ if (CAMERA_2_ON && moduleIndex == ModuleSwitcher.PHOTO_MODULE_INDEX)
+ moduleIndex = ModuleSwitcher.CAPTURE_MODULE_INDEX;
mOrientationListener = new MyOrientationEventListener(this);
setModuleFromIndex(moduleIndex);
@@ -1799,10 +1811,10 @@ public class CameraActivity extends Activity
@Override
public void onModuleSelected(int moduleIndex) {
+ if (moduleIndex == 0 && CAMERA_2_ON) moduleIndex = ModuleSwitcher.CAPTURE_MODULE_INDEX;
if (mCurrentModuleIndex == moduleIndex) {
return;
}
-
CameraHolder.instance().keep();
closeModule(mCurrentModule);
setModuleFromIndex(moduleIndex);
@@ -1827,6 +1839,7 @@ public class CameraActivity extends Activity
mCameraPhotoModuleRootView.setVisibility(View.GONE);
mCameraVideoModuleRootView.setVisibility(View.GONE);
mCameraPanoModuleRootView.setVisibility(View.GONE);
+ mCameraCaptureModuleRootView.setVisibility(View.GONE);
mCameraRootFrame.removeAllViews();
mCurrentModuleIndex = moduleIndex;
switch (moduleIndex) {
@@ -1864,6 +1877,15 @@ public class CameraActivity extends Activity
mCameraPanoModuleRootView.setVisibility(View.VISIBLE);
break;
+ case ModuleSwitcher.CAPTURE_MODULE_INDEX:
+ if(mCaptureModule == null) {
+ mCaptureModule = new CaptureModule();
+ mCaptureModule.init(this, mCameraCaptureModuleRootView);
+ }
+ mCurrentModule = mCaptureModule;
+ mCameraRootFrame.addView(mCameraCaptureModuleRootView);
+ mCameraCaptureModuleRootView.setVisibility(View.VISIBLE);
+ break;
case ModuleSwitcher.LIGHTCYCLE_MODULE_INDEX: //Unused module for now
case ModuleSwitcher.GCAM_MODULE_INDEX: //Unused module for now
default: