diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-01-25 20:37:55 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2011-01-26 18:04:01 +0800 |
commit | 855b4ca04f982c7110acd81b509c955df976926f (patch) | |
tree | d51876d5635c9126abb456c571ce699a6587e33f /src/com/android/camera/Camera.java | |
parent | de0d58c0368407e37181c8236cc31c2da8b3491b (diff) | |
download | LegacyCamera-855b4ca04f982c7110acd81b509c955df976926f.zip LegacyCamera-855b4ca04f982c7110acd81b509c955df976926f.tar.gz LegacyCamera-855b4ca04f982c7110acd81b509c955df976926f.tar.bz2 |
Fix camera preview orientation when device is held in portrait.
The problem is the rotation animation may still in progress during
onCreate. When we start the preview in onCreate, the display rotation
is still the value in portrait. So we check the display rotation
again in surfaceChanged. If it is different, restart the preview.
bug:3362860
Change-Id: Ib930c18d089114a3b5b9ca0f599e1ebdace73eb7
Diffstat (limited to 'src/com/android/camera/Camera.java')
-rw-r--r-- | src/com/android/camera/Camera.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 84456e3..0a8cc99 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -190,6 +190,9 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, "android.intent.extra.quickCapture"; private boolean mPreviewing; + // The display rotation in degrees. This is only valid when mPreviewing is + // true. + private int mDisplayRotation; private boolean mPausing; private boolean mFirstTimeInitialized; private boolean mIsImageCaptureIntent; @@ -1646,7 +1649,13 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, // Ignore it. if (mPausing || isFinishing()) return; - if (mPreviewing && holder.isCreating()) { + // Set preview display if the surface is being created. Preview was + // already started. Also restart the preview if display rotation has + // changed. Sometimes this happens when the device is held in portrait + // and camera app is opened. Rotation animation takes some time and + // display rotation in onCreate may not be what we want. + if (mPreviewing && (Util.getDisplayRotation(this) == mDisplayRotation) + && holder.isCreating()) { // Set preview display if the surface is being created and preview // was already started. That means preview display was set to null // and we need to set it now. @@ -1730,7 +1739,8 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, if (mPreviewing) stopPreview(); setPreviewDisplay(mSurfaceHolder); - Util.setCameraDisplayOrientation(this, mCameraId, mCameraDevice); + mDisplayRotation = Util.getDisplayRotation(this); + Util.setCameraDisplayOrientation(mDisplayRotation, mCameraId, mCameraDevice); setCameraParameters(UPDATE_PARAM_ALL); |