Merge "Show a preview cover until real preview is ready" into gb-ub-photos-carlsbad
diff --git a/res/layout/panorama_module.xml b/res/layout/panorama_module.xml
index 0b2785a..581170f 100644
--- a/res/layout/panorama_module.xml
+++ b/res/layout/panorama_module.xml
@@ -19,6 +19,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/pano_module_capture" />
+ <View
+ android:id="@+id/preview_cover"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/black"
+ android:visibility="gone" />
<include layout="@layout/pano_module_review" />
<include layout="@layout/camera_controls"
android:layout_gravity="center"
diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml
index b63d536..0410f16 100644
--- a/res/layout/photo_module.xml
+++ b/res/layout/photo_module.xml
@@ -33,6 +33,12 @@
android:id="@+id/preview_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <View
+ android:id="@+id/preview_cover"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/black"
+ android:visibility="gone" />
</FrameLayout>
<ImageView
android:id="@+id/review_image"
diff --git a/res/layout/video_module.xml b/res/layout/video_module.xml
index b4444e7..198be89 100644
--- a/res/layout/video_module.xml
+++ b/res/layout/video_module.xml
@@ -26,6 +26,12 @@
android:id="@+id/preview_content"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <View
+ android:id="@+id/preview_cover"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="@android:color/black"
+ android:visibility="gone" />
</FrameLayout>
<View
android:id="@+id/flash_overlay"
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 6256bfb..aeca3dd 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1190,6 +1190,7 @@
@Override
public void onResumeAfterSuper() {
+ Log.v(TAG, "On resume.");
if (mOpenCameraFail || mCameraDisabled) return;
mJpegPictureCallbackTime = 0;
@@ -1240,6 +1241,8 @@
@Override
public void onPauseAfterSuper() {
+ Log.v(TAG, "On pause.");
+ mUI.showPreviewCover();
// When camera is started from secure lock screen for the first time
// after screen on, the activity gets onCreate->onResume->onPause->onResume.
// To reduce the latency, keep the camera for a short time so it does
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index b966b7b..cd3b9a5 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -115,6 +115,7 @@
private TextureView mTextureView;
private Matrix mMatrix = null;
private float mAspectRatio = 4f / 3f;
+ private View mPreviewCover;
public interface SurfaceTextureSizeChangedListener {
public void onSurfaceTextureSizeChanged(int uncroppedWidth, int uncroppedHeight);
@@ -196,6 +197,7 @@
(ViewGroup) mRootView, true);
mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
mFlashOverlay = mRootView.findViewById(R.id.flash_overlay);
+ mPreviewCover = mRootView.findViewById(R.id.preview_cover);
// display the view
mTextureView = (TextureView) mRootView.findViewById(R.id.preview_content);
mTextureView.setSurfaceTextureListener(this);
@@ -256,6 +258,7 @@
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Log.v(TAG, "SurfaceTexture ready.");
+ mPreviewCover.setVisibility(View.GONE);
mSurfaceTexture = surface;
mController.onPreviewUIReady();
// Workaround for b/11168275, see b/10981460 for more details
@@ -756,6 +759,10 @@
mNotSelectableToast.show();
}
+ public void showPreviewCover() {
+ mPreviewCover.setVisibility(View.VISIBLE);
+ }
+
public void onPause() {
cancelCountDown();
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index fdd48e2..0ee62bb 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -783,6 +783,7 @@
public void onPauseBeforeSuper() {
mPaused = true;
+ mUI.showPreviewCover();
if (mMediaRecorderRecording) {
// Camera will be released in onStopVideoRecording.
onStopVideoRecording();
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 23d08db..02b2567 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -93,6 +93,7 @@
private View mPreviewThumb;
private View mFlashOverlay;
+ private View mPreviewCover;
private SurfaceView mSurfaceView = null;
private int mPreviewWidth = 0;
private int mPreviewHeight = 0;
@@ -134,6 +135,10 @@
}
};
+ public void showPreviewCover() {
+ mPreviewCover.setVisibility(View.VISIBLE);
+ }
+
private class SettingsPopup extends PopupWindow {
public SettingsPopup(View popup) {
super(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
@@ -168,6 +173,7 @@
mController = controller;
mRootView = parent;
mActivity.getLayoutInflater().inflate(R.layout.video_module, (ViewGroup) mRootView, true);
+ mPreviewCover = mRootView.findViewById(R.id.preview_cover);
mTextureView = (TextureView) mRootView.findViewById(R.id.preview_content);
mTextureView.setSurfaceTextureListener(this);
mTextureView.addOnLayoutChangeListener(mLayoutListener);
@@ -712,6 +718,7 @@
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
mSurfaceTexture = surface;
+ mPreviewCover.setVisibility(View.GONE);
mController.onPreviewUIReady();
}
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index aa66bdc..db4e59d 100644
--- a/src/com/android/camera/WideAnglePanoramaModule.java
+++ b/src/com/android/camera/WideAnglePanoramaModule.java
@@ -805,7 +805,7 @@
stopCapture(true);
reset();
}
-
+ mUI.showPreviewCover();
releaseCamera();
synchronized (mRendererLock) {
mCameraTexture = null;
diff --git a/src/com/android/camera/WideAnglePanoramaUI.java b/src/com/android/camera/WideAnglePanoramaUI.java
index da49638..b0f3de4 100644
--- a/src/com/android/camera/WideAnglePanoramaUI.java
+++ b/src/com/android/camera/WideAnglePanoramaUI.java
@@ -89,6 +89,7 @@
private int mIndicatorColorFast;
private int mReviewBackground;
private SurfaceTexture mSurfaceTexture;
+ private View mPreviewCover;
/** Constructor. */
public WideAnglePanoramaUI(
@@ -225,6 +226,7 @@
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i2) {
mSurfaceTexture = surfaceTexture;
+ mPreviewCover.setVisibility(View.GONE);
mController.onPreviewUIReady();
}
@@ -346,6 +348,7 @@
mReviewBackground = appRes.getColor(R.color.review_background);
mIndicatorColorFast = appRes.getColor(R.color.pano_progress_indication_fast);
+ mPreviewCover = mRootView.findViewById(R.id.preview_cover);
mPreviewLayout = mRootView.findViewById(R.id.pano_preview_layout);
mReviewControl = (ViewGroup) mRootView.findViewById(R.id.pano_review_control);
mReviewLayout = mRootView.findViewById(R.id.pano_review_layout);
@@ -453,6 +456,10 @@
((CameraRootView) mRootView).removeDisplayChangeListener();
}
+ public void showPreviewCover() {
+ mPreviewCover.setVisibility(View.VISIBLE);
+ }
+
private class DialogHelper {
private ProgressDialog mProgressDialog;
private AlertDialog mAlertDialog;