diff options
author | Likai Ding <likaid@codeaurora.org> | 2015-01-26 10:07:21 +0800 |
---|---|---|
committer | Likai Ding <likaid@codeaurora.org> | 2015-02-02 13:55:08 +0800 |
commit | e2fb5dc7798cf677f6a66b6a697c4a011b0a101f (patch) | |
tree | 9250c3a47e27b90e3c094c9d3ffa1365c3914178 /src/com/android/camera/VideoUI.java | |
parent | 07cf80cc97c68f12d5728919fcebba28e750761d (diff) | |
download | android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.tar.gz android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.tar.bz2 android_packages_apps_Snap-e2fb5dc7798cf677f6a66b6a697c4a011b0a101f.zip |
SnapdragonCamera: fix portrait orientation
Fix camera activity to portrait, so there is no delay when rotation
occurs. Main changes are:
1. RotateLayout now supports padding and dynamically added child.
2. Camera controls and gesture detetion are now orientation-aware.
3. Toasts are replaced with RotateTextToast.
4. Obselete layout files are removed.
Change-Id: I338849bd7fb84b847eb357f771a24a5cc09bf6fa
Diffstat (limited to 'src/com/android/camera/VideoUI.java')
-rw-r--r-- | src/com/android/camera/VideoUI.java | 76 |
1 files changed, 67 insertions, 9 deletions
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java index 54a1bfcd4..13db502c5 100644 --- a/src/com/android/camera/VideoUI.java +++ b/src/com/android/camera/VideoUI.java @@ -51,10 +51,12 @@ import com.android.camera.CameraPreference.OnPreferenceChangedListener; import com.android.camera.ui.AbstractSettingPopup; import com.android.camera.ui.CameraControls; import com.android.camera.ui.CameraRootView; +import com.android.camera.ui.ListSubMenu; import com.android.camera.ui.ModuleSwitcher; import com.android.camera.ui.PieRenderer; import com.android.camera.ui.RenderOverlay; import com.android.camera.ui.RotateLayout; +import com.android.camera.ui.RotateTextToast; import com.android.camera.ui.ZoomRenderer; import com.android.camera.util.CameraUtil; import org.codeaurora.snapcam.R; @@ -101,8 +103,8 @@ public class VideoUI implements PieRenderer.PieListener, private boolean mOrientationResize; private boolean mPrevOrientationResize; private boolean mIsTimeLapse = false; - private LinearLayout mMenuLayout; - private LinearLayout mSubMenuLayout; + private RotateLayout mMenuLayout; + private RotateLayout mSubMenuLayout; private LinearLayout mPreviewMenuLayout; private View mPreviewCover; @@ -117,6 +119,7 @@ public class VideoUI implements PieRenderer.PieListener, private final AnimationManager mAnimationManager; private boolean mUIhidden = false; private int mPreviewOrientation = -1; + private int mOrientation; // temporary variables for updating SurfaceView private int mTempWidth; @@ -243,6 +246,7 @@ public class VideoUI implements PieRenderer.PieListener, @Override public void onClick(View v) { mSwitcher.showPopup(); + mSwitcher.setOrientation(mOrientation, false); } }); @@ -532,7 +536,6 @@ public class VideoUI implements PieRenderer.PieListener, mLabelsLinearLayout.setOrientation(LinearLayout.HORIZONTAL); } } - mRecordingTimeRect.setOrientation(0, animation); } public SurfaceHolder getSurfaceHolder() { @@ -731,29 +734,46 @@ public class VideoUI implements PieRenderer.PieListener, popup.setVisibility(View.VISIBLE); if (level == 1) { if (mMenuLayout == null) { - mMenuLayout = new LinearLayout(mActivity); - ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( - CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT); + mMenuLayout = new RotateLayout(mActivity, null); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( + CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, + Gravity.LEFT | Gravity.TOP); mMenuLayout.setLayoutParams(params); ((ViewGroup) mRootView).addView(mMenuLayout); } + mMenuLayout.setOrientation(mOrientation, true); mMenuLayout.addView(popup); } if (level == 2) { if (mSubMenuLayout == null) { - mSubMenuLayout = new LinearLayout(mActivity); + mSubMenuLayout = new RotateLayout(mActivity, null); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT); mSubMenuLayout.setLayoutParams(params); ((ViewGroup) mRootView).addView(mSubMenuLayout); } + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( + CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, + Gravity.LEFT | Gravity.TOP); + + int screenHeight = (mOrientation == 0 || mOrientation == 180) + ? mRootView.getHeight() : mRootView.getWidth(); + int height = ((ListSubMenu) popup).getPreCalculatedHeight(); + int yBase = ((ListSubMenu) popup).getYBase(); + int y = Math.max(0, yBase); + if (yBase + height > screenHeight) + y = Math.max(0, screenHeight - height); + params.setMargins(0, y, 0, 0); + params.setMarginStart(CameraActivity.SETTING_LIST_WIDTH_1); + + mSubMenuLayout.setLayoutParams(params); mSubMenuLayout.addView(popup); - mSubMenuLayout.setX(CameraActivity.SETTING_LIST_WIDTH_1); + mSubMenuLayout.setOrientation(mOrientation, true); } if (animate) { if (level == 1) - mVideoMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true); + mVideoMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true); if (level == 2) mVideoMenu.animateFadeIn(popup); } @@ -1051,4 +1071,42 @@ public class VideoUI implements PieRenderer.PieListener, } return false; } + + public void setOrientation(int orientation, boolean animation) { + mCameraControls.setOrientation(orientation, animation); + if (mMenuLayout != null) + mMenuLayout.setOrientation(orientation, animation); + if (mSubMenuLayout != null) + mSubMenuLayout.setOrientation(orientation, animation); + if (mRecordingTimeRect != null) { + if (orientation == 180) { + mRecordingTimeRect.setOrientation(0, false); + mRecordingTimeView.setRotation(180); + } else { + mRecordingTimeView.setRotation(0); + mRecordingTimeRect.setOrientation(orientation, false); + } + } + if (mPreviewMenuLayout != null) { + ViewGroup vg = (ViewGroup) mPreviewMenuLayout.getChildAt(0); + if (vg != null) + vg = (ViewGroup) vg.getChildAt(0); + if (vg != null) { + for (int i = vg.getChildCount() - 1; i >= 0; --i) { + RotateLayout l = (RotateLayout) vg.getChildAt(i); + l.setOrientation(orientation, animation); + } + } + } + RotateTextToast.setOrientation(orientation); + mOrientation = orientation; + } + + public int getOrientation() { + return mOrientation; + } + + public void adjustOrientation() { + setOrientation(mOrientation, false); + } } |