diff options
author | Doris Liu <tianliu@google.com> | 2013-10-14 12:06:20 -0700 |
---|---|---|
committer | Doris Liu <tianliu@google.com> | 2013-10-14 12:06:20 -0700 |
commit | 352b014552d77948193d84ec177c7673552eb1ee (patch) | |
tree | fd6023c568c1ae31cb2047a334b4094065c99291 | |
parent | ae1697302b4ef59bbfebdf1127bc73531ce550b7 (diff) | |
download | android_packages_apps_Snap-352b014552d77948193d84ec177c7673552eb1ee.tar.gz android_packages_apps_Snap-352b014552d77948193d84ec177c7673552eb1ee.tar.bz2 android_packages_apps_Snap-352b014552d77948193d84ec177c7673552eb1ee.zip |
Fix SRI upside down preview in reverse landscape and reverse portrait
Also make sure preview is not upside down after device flip, and
fix camera controls jiggering during rotation
Bug: 11216647
Bug: 11174540
Change-Id: I764e5b86549fa87c2224d8e85ff06f57f0a315d1
-rw-r--r-- | res/layout/panorama_module.xml | 5 | ||||
-rw-r--r-- | src/com/android/camera/WideAnglePanoramaModule.java | 5 | ||||
-rw-r--r-- | src/com/android/camera/WideAnglePanoramaUI.java | 29 |
3 files changed, 31 insertions, 8 deletions
diff --git a/res/layout/panorama_module.xml b/res/layout/panorama_module.xml index 3711cc67f..0b2785a3e 100644 --- a/res/layout/panorama_module.xml +++ b/res/layout/panorama_module.xml @@ -14,8 +14,7 @@ limitations under the License. --> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/pano_layout" +<merge xmlns:android="http://schemas.android.com/apk/res/android" android:clickable="true" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -24,4 +23,4 @@ <include layout="@layout/camera_controls" android:layout_gravity="center" style="@style/CameraControls"/> -</FrameLayout> +</merge> diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java index 189bf99d1..91c3049c6 100644 --- a/src/com/android/camera/WideAnglePanoramaModule.java +++ b/src/com/android/camera/WideAnglePanoramaModule.java @@ -454,7 +454,7 @@ public class WideAnglePanoramaModule final boolean isLandscape = (mActivity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE); - + mUI.flipPreviewIfNeeded(); MosaicPreviewRenderer renderer = new MosaicPreviewRenderer( mUI.getSurfaceTexture(), mPreviewUIWidth, mPreviewUIHeight, isLandscape); @@ -819,6 +819,7 @@ public class WideAnglePanoramaModule mWaitProcessorTask = null; } resetScreenOn(); + mUI.removeDisplayChangeListener(); if (mSoundPlayer != null) { mSoundPlayer.release(); mSoundPlayer = null; @@ -879,7 +880,7 @@ public class WideAnglePanoramaModule boolean recordLocation = RecordLocationPreference.get(mPreferences, mContentResolver); mLocationManager.recordLocation(recordLocation); - + mUI.initDisplayChangeListener(); UsageStatistics.onContentViewChanged( UsageStatistics.COMPONENT_CAMERA, "PanoramaModule"); } diff --git a/src/com/android/camera/WideAnglePanoramaUI.java b/src/com/android/camera/WideAnglePanoramaUI.java index 407160933..202303091 100644 --- a/src/com/android/camera/WideAnglePanoramaUI.java +++ b/src/com/android/camera/WideAnglePanoramaUI.java @@ -43,6 +43,7 @@ import android.widget.TextView; import com.android.camera.ui.CameraControls; import com.android.camera.ui.CameraRootView; import com.android.camera.ui.ModuleSwitcher; +import com.android.camera.util.CameraUtil; import com.android.camera2.R; /** @@ -51,6 +52,7 @@ import com.android.camera2.R; public class WideAnglePanoramaUI implements TextureView.SurfaceTextureListener, ShutterButton.OnShutterButtonListener, + CameraRootView.MyDisplayListener, View.OnLayoutChangeListener { @SuppressWarnings("unused") @@ -61,7 +63,6 @@ public class WideAnglePanoramaUI implements private ViewGroup mRootView; private ModuleSwitcher mSwitcher; - private ViewGroup mPanoLayout; private FrameLayout mCaptureLayout; private View mReviewLayout; private ImageView mReview; @@ -274,7 +275,7 @@ public class WideAnglePanoramaUI implements mReviewControl.removeAllViews(); inflater.inflate(R.layout.pano_review_control, mReviewControl, true); - mPanoLayout.bringChildToFront(mCameraControls); + mRootView.bringChildToFront(mCameraControls); setViews(mActivity.getResources()); if (threadRunning) { mReview.setImageDrawable(lowResReview); @@ -333,7 +334,6 @@ public class WideAnglePanoramaUI implements mReviewBackground = appRes.getColor(R.color.review_background); mIndicatorColorFast = appRes.getColor(R.color.pano_progress_indication_fast); - mPanoLayout = (ViewGroup) mRootView.findViewById(R.id.pano_layout); 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); @@ -418,6 +418,29 @@ public class WideAnglePanoramaUI implements mRightIndicator.setEnabled(false); } + public void flipPreviewIfNeeded() { + if (CameraUtil.getDisplayRotation(mActivity) >= 180) { + // In either reverse landscape or reverse portrait + mTextureView.setRotation(180); + } else { + mTextureView.setRotation(0); + } + } + + @Override + public void onDisplayChanged() { + mCameraControls.checkLayoutFlip(); + flipPreviewIfNeeded(); + } + + public void initDisplayChangeListener() { + ((CameraRootView) mRootView).setDisplayChangeListener(this); + } + + public void removeDisplayChangeListener() { + ((CameraRootView) mRootView).removeDisplayChangeListener(); + } + private class DialogHelper { private ProgressDialog mProgressDialog; private AlertDialog mAlertDialog; |