summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Yoo <jyoo@codeaurora.org>2016-02-22 17:40:11 -0800
committerSteve Kondik <steve@cyngn.com>2016-08-14 00:05:32 -0700
commit1a18632c11d3f4593547e9afe309cad1f4ea7204 (patch)
treef9404217b3618c2ee987ea678e1819d6f35cfff7
parent2e94604fc2fd300ce6fc14d027e6d87eca83d708 (diff)
downloadandroid_packages_apps_Snap-1a18632c11d3f4593547e9afe309cad1f4ea7204.tar.gz
android_packages_apps_Snap-1a18632c11d3f4593547e9afe309cad1f4ea7204.tar.bz2
android_packages_apps_Snap-1a18632c11d3f4593547e9afe309cad1f4ea7204.zip
SnapdragonCamera: Adjusting view initialization
Instead of removing and adding the entire root view, changing only core surface view on module change. Change-Id: I5c39cf23b2a58280f4e4e8484865bbed0b12e1cf CRs-Fixed: 979254
-rw-r--r--res/layout/video_module.xml3
-rw-r--r--src/com/android/camera/CameraActivity.java11
-rw-r--r--src/com/android/camera/PhotoModule.java6
-rw-r--r--src/com/android/camera/PhotoUI.java20
-rw-r--r--src/com/android/camera/VideoModule.java5
-rw-r--r--src/com/android/camera/VideoUI.java22
6 files changed, 44 insertions, 23 deletions
diff --git a/res/layout/video_module.xml b/res/layout/video_module.xml
index 75487d49e..561539e08 100644
--- a/res/layout/video_module.xml
+++ b/res/layout/video_module.xml
@@ -26,8 +26,7 @@
<SurfaceView
android:id="@+id/mdp_preview_content"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone" />
+ android:layout_height="match_parent" />
</FrameLayout>
<View
android:id="@+id/preview_cover"
diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java
index 6a3bddbd2..bdb03bb0a 100644
--- a/src/com/android/camera/CameraActivity.java
+++ b/src/com/android/camera/CameraActivity.java
@@ -1944,10 +1944,7 @@ public class CameraActivity extends Activity
mCameraPhotoModuleRootView.setVisibility(View.GONE);
mCameraVideoModuleRootView.setVisibility(View.GONE);
mCameraPanoModuleRootView.setVisibility(View.GONE);
- mCameraRootFrame.removeAllViews();
mCurrentModuleIndex = moduleIndex;
-
- final CameraRootView rootView;
switch (moduleIndex) {
case ModuleSwitcher.VIDEO_MODULE_INDEX:
if (mVideoModule == null) {
@@ -1955,7 +1952,7 @@ public class CameraActivity extends Activity
mVideoModule.init(this, mCameraVideoModuleRootView);
}
mCurrentModule = mVideoModule;
- rootView = mCameraVideoModuleRootView;
+ mCameraVideoModuleRootView.setVisibility(View.VISIBLE);
break;
case ModuleSwitcher.WIDE_ANGLE_PANO_MODULE_INDEX:
@@ -1964,7 +1961,7 @@ public class CameraActivity extends Activity
mPanoModule.init(this, mCameraPanoModuleRootView);
}
mCurrentModule = mPanoModule;
- rootView = mCameraPanoModuleRootView;
+ mCameraPanoModuleRootView.setVisibility(View.VISIBLE);
break;
case ModuleSwitcher.PHOTO_MODULE_INDEX:
@@ -1976,11 +1973,9 @@ public class CameraActivity extends Activity
mPhotoModule.init(this, mCameraPhotoModuleRootView);
}
mCurrentModule = mPhotoModule;
- rootView = mCameraPhotoModuleRootView;
+ mCameraPhotoModuleRootView.setVisibility(View.VISIBLE);
break;
}
- mCameraRootFrame.addView(rootView);
- rootView.setVisibility(View.VISIBLE);
// Re-apply the last fitSystemWindows() run. Our views rely on this, but
// the framework's ActionBarOverlayLayout effectively prevents this if the
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index c867bc7a8..1d49cfbd5 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -688,6 +688,7 @@ public class PhotoModule
private void switchCamera() {
if (mPaused) return;
+ mUI.applySurfaceChange(PhotoUI.SURFACE_STATUS.HIDE);
Log.v(TAG, "Start to switch camera. id=" + mPendingSwitchCameraId);
mCameraId = mPendingSwitchCameraId;
mPendingSwitchCameraId = -1;
@@ -735,6 +736,7 @@ public class PhotoModule
mFocusManager.setParameters(mInitialParams);
setupPreview();
+ mUI.applySurfaceChange(PhotoUI.SURFACE_STATUS.SURFACE_VIEW);
// reset zoom value index
mZoomValue = 0;
resizeForPreviewAspectRatio();
@@ -2449,6 +2451,8 @@ public class PhotoModule
mOpenCameraThread.start();
}
+ mUI.applySurfaceChange(PhotoUI.SURFACE_STATUS.SURFACE_VIEW);
+
mJpegPictureCallbackTime = 0;
mZoomValue = 0;
@@ -2485,6 +2489,8 @@ public class PhotoModule
@Override
public void onPauseBeforeSuper() {
mPaused = true;
+ mUI.applySurfaceChange(PhotoUI.SURFACE_STATUS.HIDE);
+
Sensor gsensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (gsensor != null) {
mSensorManager.unregisterListener(this, gsensor);
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index a2d86313b..23ed1bad4 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -151,6 +151,11 @@ public class PhotoUI implements PieListener,
private int mOrientation;
private float mScreenBrightness = 0.0f;
+ public enum SURFACE_STATUS {
+ HIDE,
+ SURFACE_VIEW;
+ }
+
public interface SurfaceTextureSizeChangedListener {
public void onSurfaceTextureSizeChanged(int uncroppedWidth, int uncroppedHeight);
}
@@ -220,6 +225,14 @@ public class PhotoUI implements PieListener,
}
}
+ public synchronized void applySurfaceChange(SURFACE_STATUS status) {
+ if(status == SURFACE_STATUS.HIDE) {
+ mSurfaceView.setVisibility(View.GONE);
+ return;
+ }
+ mSurfaceView.setVisibility(View.VISIBLE);
+ }
+
public PhotoUI(CameraActivity activity, PhotoController controller, View parent) {
mActivity = activity;
mController = controller;
@@ -232,11 +245,8 @@ public class PhotoUI implements PieListener,
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- mSurfaceView.addOnLayoutChangeListener(mLayoutListener);
Log.v(TAG, "Using mdp_preview_content (MDP path)");
-
- View surfaceContainer = mRootView.findViewById(R.id.preview_container);
- surfaceContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() {
+ mSurfaceView.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight,
@@ -245,6 +255,8 @@ public class PhotoUI implements PieListener,
int height = bottom - top;
boolean isMaxSizeBeingValid = false;
+ tryToCloseSubList();
+
if (mMaxPreviewWidth == 0 && mMaxPreviewHeight == 0) {
mMaxPreviewWidth = width;
mMaxPreviewHeight = height;
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index 721fb957d..a9e6074ae 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -1154,6 +1154,8 @@ public class VideoModule implements CameraModule,
mUI.enableShutter(true);
}
+ mUI.applySurfaceChange(VideoUI.SURFACE_STATUS.SURFACE_VIEW);
+
mUI.initDisplayChangeListener();
// Initializing it here after the preview is started.
mUI.initializeZoom(mParameters);
@@ -1338,6 +1340,7 @@ public class VideoModule implements CameraModule,
mUI.collapseCameraControls();
mUI.removeDisplayChangeListener();
+ mUI.applySurfaceChange(VideoUI.SURFACE_STATUS.HIDE);
}
@Override
@@ -2763,6 +2766,7 @@ public class VideoModule implements CameraModule,
}
Log.d(TAG, "Start to switch camera.");
+ mUI.applySurfaceChange(VideoUI.SURFACE_STATUS.HIDE);
mCameraId = mPendingSwitchCameraId;
mPendingSwitchCameraId = -1;
setCameraId(mCameraId);
@@ -2782,6 +2786,7 @@ public class VideoModule implements CameraModule,
mFocusManager.setParameters(mParameters);
readVideoPreferences();
+ mUI.applySurfaceChange(VideoUI.SURFACE_STATUS.SURFACE_VIEW);
startPreview();
initializeVideoSnapshot();
resizeForPreviewAspectRatio();
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 4fcc20fbf..9eecd6bd6 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -118,13 +118,10 @@ public class VideoUI implements PieRenderer.PieListener,
private int mTopMargin = 0;
private int mBottomMargin = 0;
- private OnLayoutChangeListener mLayoutListener = new OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right,
- int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
- tryToCloseSubList();
- }
- };
+ public enum SURFACE_STATUS {
+ HIDE,
+ SURFACE_VIEW;
+ }
public void showPreviewCover() {
mPreviewCover.setVisibility(View.VISIBLE);
@@ -165,6 +162,14 @@ public class VideoUI implements PieRenderer.PieListener,
}
}
+ public synchronized void applySurfaceChange(SURFACE_STATUS status) {
+ if(status == SURFACE_STATUS.HIDE) {
+ mSurfaceView.setVisibility(View.GONE);
+ return;
+ }
+ mSurfaceView.setVisibility(View.VISIBLE);
+ }
+
public VideoUI(CameraActivity activity, VideoController controller, View parent) {
mActivity = activity;
mController = controller;
@@ -177,9 +182,7 @@ public class VideoUI implements PieRenderer.PieListener,
mSurfaceHolder = mSurfaceView.getHolder();
mSurfaceHolder.addCallback(this);
mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
- mSurfaceView.addOnLayoutChangeListener(mLayoutListener);
Log.v(TAG, "Using mdp_preview_content (MDP path)");
-
View surfaceContainer = mRootView.findViewById(R.id.preview_container);
surfaceContainer.addOnLayoutChangeListener(new OnLayoutChangeListener() {
@Override
@@ -189,6 +192,7 @@ public class VideoUI implements PieRenderer.PieListener,
int width = right - left;
int height = bottom - top;
+ tryToCloseSubList();
if (mMaxPreviewWidth == 0 && mMaxPreviewHeight == 0) {
mMaxPreviewWidth = width;
mMaxPreviewHeight = height;