diff options
author | Wei-Ta Chen <weita@google.com> | 2009-09-28 18:38:05 -0700 |
---|---|---|
committer | Wei-Ta Chen <weita@google.com> | 2009-09-29 11:50:22 -0700 |
commit | 1f0564eb75f20943d496109928b5542902d3bd61 (patch) | |
tree | b81c82e26c4c6be280301fc5c7e84bf1ecac40b4 /src/com | |
parent | 2f050195a3608e0413d8af30867e988c216908ee (diff) | |
download | LegacyCamera-1f0564eb75f20943d496109928b5542902d3bd61.zip LegacyCamera-1f0564eb75f20943d496109928b5542902d3bd61.tar.gz LegacyCamera-1f0564eb75f20943d496109928b5542902d3bd61.tar.bz2 |
Fix http://b/2144865 by re-positioning the on-screen setting when the size of preview frame is changed.
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/camera/OnScreenSettings.java | 4 | ||||
-rw-r--r-- | src/com/android/camera/PreviewFrameLayout.java | 13 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 22 |
3 files changed, 32 insertions, 7 deletions
diff --git a/src/com/android/camera/OnScreenSettings.java b/src/com/android/camera/OnScreenSettings.java index ca2f5de..c9d1f93 100644 --- a/src/com/android/camera/OnScreenSettings.java +++ b/src/com/android/camera/OnScreenSettings.java @@ -112,7 +112,7 @@ public class OnScreenSettings { mContainerLayoutParams.token = mOwnerView.getWindowToken(); } mWindowManager.addView(mContainer, mContainerLayoutParams); - refreshPositioningVariables(); + updateLayout(); } else { // Reset the two menus mSubMenu.setAdapter(null); @@ -148,7 +148,7 @@ public class OnScreenSettings { }); } - private void refreshPositioningVariables() { + public void updateLayout() { // if the mOwnerView is detached from window then skip. if (mOwnerView.getWindowToken() == null) return; diff --git a/src/com/android/camera/PreviewFrameLayout.java b/src/com/android/camera/PreviewFrameLayout.java index c8af838..459338c 100644 --- a/src/com/android/camera/PreviewFrameLayout.java +++ b/src/com/android/camera/PreviewFrameLayout.java @@ -24,14 +24,24 @@ import android.widget.ImageView; import android.widget.FrameLayout; public class PreviewFrameLayout extends ViewGroup { + public interface OnSizeChangedListener { + public void onSizeChanged(); + } + private double mAspectRatio = 4.0 / 3.0; private ImageView mGripper; private FrameLayout mFrame; + private OnSizeChangedListener mSizeListener; + public PreviewFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } + public void setOnSizeChangedListener(OnSizeChangedListener listener) { + mSizeListener = listener; + } + @Override protected void onFinishInflate() { mGripper = (ImageView) findViewById(R.id.btn_gripper); @@ -114,6 +124,9 @@ public class PreviewFrameLayout extends ViewGroup { } myLayoutChild(mFrame, Math.max(l + leftSpace, l + gripperWidth), t + topSpace, frameWidth, frameHeight); + if (mSizeListener != null) { + mSizeListener.onSizeChanged(); + } } private static void myLayoutChild(View child, int l, int t, int w, int h) { diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 718325a..db6d5ae 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -66,6 +66,7 @@ import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; +import com.android.camera.PreviewFrameLayout.OnSizeChangedListener; import com.android.camera.gallery.IImage; import com.android.camera.gallery.IImageList; @@ -84,7 +85,8 @@ public class VideoCamera extends Activity implements View.OnClickListener, ShutterButton.OnShutterButtonListener, SurfaceHolder.Callback, MediaRecorder.OnErrorListener, MediaRecorder.OnInfoListener, Switcher.OnSwitchListener, OnSharedPreferenceChangeListener, - OnScreenSettings.OnVisibilityChangedListener { + OnScreenSettings.OnVisibilityChangedListener, + PreviewFrameLayout.OnSizeChangedListener { private static final String TAG = "videocamera"; @@ -107,6 +109,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, private SharedPreferences mPreferences; + private PreviewFrameLayout mPreviewFrameLayout; private SurfaceView mVideoPreview; private SurfaceHolder mSurfaceHolder = null; private ImageView mVideoFrame; @@ -258,7 +261,11 @@ public class VideoCamera extends Activity implements View.OnClickListener, requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.video_camera); + mPreviewFrameLayout = (PreviewFrameLayout) + findViewById(R.id.frame_layout); + mPreviewFrameLayout.setOnSizeChangedListener(this); resizeForPreviewAspectRatio(); + mVideoPreview = (SurfaceView) findViewById(R.id.camera_preview); mVideoFrame = (ImageView) findViewById(R.id.video_frame); @@ -505,9 +512,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, } private void resizeForPreviewAspectRatio() { - PreviewFrameLayout frameLayout = - (PreviewFrameLayout) findViewById(R.id.frame_layout); - frameLayout.setAspectRatio( + mPreviewFrameLayout.setAspectRatio( (double) mProfile.mVideoWidth / mProfile.mVideoHeight); } @@ -1423,7 +1428,6 @@ public class VideoCamera extends Activity implements View.OnClickListener, if (CameraSettings.KEY_VIDEO_DURATION.equals(key) || CameraSettings.KEY_VIDEO_QUALITY.equals(key)) { readVideoPreferences(); - resizeForPreviewAspectRatio(); } // If mCameraDevice is not ready then we can set the parameter in @@ -1438,6 +1442,7 @@ public class VideoCamera extends Activity implements View.OnClickListener, // onSharedPreferenceChanged, so we can close the camera here. closeCamera(); try { + resizeForPreviewAspectRatio(); startPreview(); // Parameters will be set in startPreview(). } catch (CameraHardwareException e) { showCameraBusyAndFinish(); @@ -1457,6 +1462,13 @@ public class VideoCamera extends Activity implements View.OnClickListener, mCameraDevice.unlock(); } } + + public void onSizeChanged() { + if (mSettings != null) { + mSettings.updateLayout(); + } + + } } // |