diff options
author | Danny Baumann <dannybaumann@web.de> | 2016-03-27 14:31:16 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-04-03 04:41:55 -0700 |
commit | 222c665b32fcc14a97494c896c22012d10ddd8a3 (patch) | |
tree | c950b9cf8f26e97de6d42ec98d185335715ca381 /src/com/android/camera/VideoUI.java | |
parent | ba9f88b3d6930bbd686e23672d3b1203dd1a3015 (diff) | |
download | android_packages_apps_Snap-222c665b32fcc14a97494c896c22012d10ddd8a3.tar.gz android_packages_apps_Snap-222c665b32fcc14a97494c896c22012d10ddd8a3.tar.bz2 android_packages_apps_Snap-222c665b32fcc14a97494c896c22012d10ddd8a3.zip |
Properly respect navigation bar size when laying out menus.
For top level menus, add padding so all menu items can be scrolled to
not be covered by the navigation bar. For sub menus, place them to not
be covered by the navigation bar.
Change-Id: I22961c19b7bf80a26eec03b5feabfda10e910669
Diffstat (limited to 'src/com/android/camera/VideoUI.java')
-rw-r--r-- | src/com/android/camera/VideoUI.java | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java index 778e067a2..0883f5fac 100644 --- a/src/com/android/camera/VideoUI.java +++ b/src/com/android/camera/VideoUI.java @@ -68,7 +68,7 @@ public class VideoUI implements PieRenderer.PieListener, // module fields private final FocusRing mFocusRing; private CameraActivity mActivity; - private View mRootView; + private CameraRootView mRootView; private SurfaceHolder mSurfaceHolder; // An review image having same size as preview. It is displayed when // recording is stopped in capture intent. @@ -102,7 +102,7 @@ public class VideoUI implements PieRenderer.PieListener, private boolean mIsTimeLapse = false; private RotateLayout mMenuLayout; private RotateLayout mSubMenuLayout; - private LinearLayout mPreviewMenuLayout; + private ViewGroup mPreviewMenuLayout; private View mPreviewCover; private SurfaceView mSurfaceView = null; @@ -171,9 +171,8 @@ public class VideoUI implements PieRenderer.PieListener, public VideoUI(CameraActivity activity, VideoController controller, View parent) { mActivity = activity; mController = controller; - mRootView = parent; - mActivity.getLayoutInflater().inflate(R.layout.video_module, - (ViewGroup) mRootView, true); + mRootView = (CameraRootView) parent; + mActivity.getLayoutInflater().inflate(R.layout.video_module, mRootView, true); mPreviewCover = mRootView.findViewById(R.id.preview_cover); // display the view mSurfaceView = (SurfaceView) mRootView.findViewById(R.id.mdp_preview_content); @@ -264,7 +263,7 @@ public class VideoUI implements PieRenderer.PieListener, public void initializeSurfaceView() { if (mSurfaceView == null) { mSurfaceView = new SurfaceView(mActivity); - ((ViewGroup) mRootView).addView(mSurfaceView, 0); + mRootView.addView(mSurfaceView, 0); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(this); } @@ -520,7 +519,7 @@ public class VideoUI implements PieRenderer.PieListener, } public void initDisplayChangeListener() { - ((CameraRootView) mRootView).setDisplayChangeListener(this); + mRootView.setDisplayChangeListener(this); } public void setDisplayOrientation(int orientation) { @@ -533,7 +532,7 @@ public class VideoUI implements PieRenderer.PieListener, } public void removeDisplayChangeListener() { - ((CameraRootView) mRootView).removeDisplayChangeListener(); + mRootView.removeDisplayChangeListener(); } // no customvideo? @@ -686,14 +685,14 @@ public class VideoUI implements PieRenderer.PieListener, public void dismissLevel1() { if (mMenuLayout != null) { - ((ViewGroup) mRootView).removeView(mMenuLayout); + mRootView.removeView(mMenuLayout); mMenuLayout = null; } } public void dismissLevel2() { if (mSubMenuLayout != null) { - ((ViewGroup) mRootView).removeView(mSubMenuLayout); + mRootView.removeView(mSubMenuLayout); mSubMenuLayout = null; } } @@ -712,14 +711,14 @@ public class VideoUI implements PieRenderer.PieListener, public void dismissSceneModeMenu() { if (mPreviewMenuLayout != null) { - ((ViewGroup) mRootView).removeView(mPreviewMenuLayout); + mRootView.removeView(mPreviewMenuLayout); mPreviewMenuLayout = null; } } public void removeSceneModeMenu() { if (mPreviewMenuLayout != null) { - ((ViewGroup) mRootView).removeView(mPreviewMenuLayout); + mRootView.removeView(mPreviewMenuLayout); mPreviewMenuLayout = null; } cleanupListview(); @@ -740,6 +739,7 @@ public class VideoUI implements PieRenderer.PieListener, if (level == 1) { if (mMenuLayout == null) { mMenuLayout = new RotateLayout(mActivity, null); + mMenuLayout.setRootView(mRootView); if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) { layoutParams = new FrameLayout.LayoutParams( CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, @@ -750,10 +750,10 @@ public class VideoUI implements PieRenderer.PieListener, Gravity.RIGHT | Gravity.TOP); } mMenuLayout.setLayoutParams(layoutParams); - ((ViewGroup) mRootView).addView(mMenuLayout); + mRootView.addView(mMenuLayout); } - mMenuLayout.setOrientation(mOrientation, true); mMenuLayout.addView(popup); + mMenuLayout.setOrientation(mOrientation, true); } if (level == 2) { if (mSubMenuLayout == null) { @@ -762,7 +762,7 @@ public class VideoUI implements PieRenderer.PieListener, CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT); mSubMenuLayout.setLayoutParams(params); - ((ViewGroup) mRootView).addView(mSubMenuLayout); + mRootView.addView(mSubMenuLayout); } if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) { layoutParams = new FrameLayout.LayoutParams( @@ -774,13 +774,14 @@ public class VideoUI implements PieRenderer.PieListener, Gravity.RIGHT | Gravity.TOP); } - int screenHeight = (mOrientation == 0 || mOrientation == 180) - ? mRootView.getHeight() : mRootView.getWidth(); + final int containerHeight = + mRootView.getClientRectForOrientation(mOrientation).height(); 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); + int yBase = ((ListSubMenu) popup).getYBase(), y = yBase; + if (yBase + height > containerHeight) { + y = Math.max(0, containerHeight - height); + } + if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) { layoutParams.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0); } else { @@ -805,7 +806,7 @@ public class VideoUI implements PieRenderer.PieListener, return mMenuLayout; } - public void setPreviewMenuLayout(LinearLayout layout) { + public void setPreviewMenuLayout(ViewGroup layout) { mPreviewMenuLayout = layout; } @@ -1050,7 +1051,7 @@ public class VideoUI implements PieRenderer.PieListener, mController.onPreviewUIDestroyed(); } - public View getRootView() { + public CameraRootView getRootView() { return mRootView; } @@ -1103,8 +1104,6 @@ public class VideoUI implements PieRenderer.PieListener, } 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); |