summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/PhotoUI.java
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-03-27 14:31:16 +0200
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-04-03 04:41:55 -0700
commit222c665b32fcc14a97494c896c22012d10ddd8a3 (patch)
treec950b9cf8f26e97de6d42ec98d185335715ca381 /src/com/android/camera/PhotoUI.java
parentba9f88b3d6930bbd686e23672d3b1203dd1a3015 (diff)
downloadandroid_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/PhotoUI.java')
-rw-r--r--src/com/android/camera/PhotoUI.java58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index 5c13a7573..c26664c2f 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -92,7 +92,7 @@ public class PhotoUI implements PieListener,
private PhotoController mController;
private PreviewGestures mGestures;
- private View mRootView;
+ private CameraRootView mRootView;
private SurfaceHolder mSurfaceHolder;
private PopupWindow mPopup;
@@ -141,7 +141,7 @@ public class PhotoUI implements PieListener,
private View mPreviewCover;
private RotateLayout mMenuLayout;
private RotateLayout mSubMenuLayout;
- private LinearLayout mPreviewMenuLayout;
+ private ViewGroup mPreviewMenuLayout;
private boolean mUIhidden = false;
private int mPreviewOrientation = -1;
@@ -223,9 +223,8 @@ public class PhotoUI implements PieListener,
public PhotoUI(CameraActivity activity, PhotoController controller, View parent) {
mActivity = activity;
mController = controller;
- mRootView = parent;
- mActivity.getLayoutInflater().inflate(R.layout.photo_module,
- (ViewGroup) mRootView, true);
+ mRootView = (CameraRootView) parent;
+ mActivity.getLayoutInflater().inflate(R.layout.photo_module, mRootView, true);
mPreviewCover = mRootView.findViewById(R.id.preview_cover);
// display the view
mSurfaceView = (SurfaceView) mRootView.findViewById(R.id.mdp_preview_content);
@@ -485,7 +484,7 @@ public class PhotoUI implements PieListener,
mController.onPreviewUIDestroyed();
}
- public View getRootView() {
+ public CameraRootView getRootView() {
return mRootView;
}
@@ -792,7 +791,7 @@ public class PhotoUI implements PieListener,
return mMenuLayout;
}
- public void setPreviewMenuLayout(LinearLayout layout) {
+ public void setPreviewMenuLayout(ViewGroup layout) {
mPreviewMenuLayout = layout;
}
@@ -808,6 +807,7 @@ public class PhotoUI implements PieListener,
if (level == 1) {
if (mMenuLayout == null) {
mMenuLayout = new RotateLayout(mActivity, null);
+ mMenuLayout.setRootView(mRootView);
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
params = new FrameLayout.LayoutParams(
CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT,
@@ -818,15 +818,15 @@ public class PhotoUI implements PieListener,
Gravity.RIGHT | Gravity.TOP);
}
mMenuLayout.setLayoutParams(params);
- ((ViewGroup) mRootView).addView(mMenuLayout);
+ mRootView.addView(mMenuLayout);
}
- mMenuLayout.setOrientation(mOrientation, true);
mMenuLayout.addView(popup);
+ mMenuLayout.setOrientation(mOrientation, true);
}
if (level == 2) {
if (mSubMenuLayout == null) {
mSubMenuLayout = new RotateLayout(mActivity, null);
- ((ViewGroup) mRootView).addView(mSubMenuLayout);
+ mRootView.addView(mSubMenuLayout);
}
if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
params = new FrameLayout.LayoutParams(
@@ -837,13 +837,14 @@ public class PhotoUI implements PieListener,
CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT,
Gravity.RIGHT | Gravity.TOP);
}
- int screenHeight = (mOrientation == 0 || mOrientation == 180)
- ? mRootView.getHeight() : mRootView.getWidth();
+
+ 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) {
params.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0);
} else {
@@ -852,8 +853,8 @@ public class PhotoUI implements PieListener,
mSubMenuLayout.setLayoutParams(params);
- mSubMenuLayout.addView(popup);
mSubMenuLayout.setOrientation(mOrientation, true);
+ mSubMenuLayout.addView(popup);
}
if (animate) {
if (level == 1)
@@ -920,14 +921,14 @@ public class PhotoUI implements 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;
}
}
@@ -946,14 +947,14 @@ public class PhotoUI implements 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();
@@ -1095,9 +1096,8 @@ public class PhotoUI implements PieListener,
// Countdown timer
private void initializeCountDown() {
- mActivity.getLayoutInflater().inflate(R.layout.count_down_to_capture,
- (ViewGroup) mRootView, true);
- mCountDownView = (CountDownView) (mRootView.findViewById(R.id.count_down_to_capture));
+ mActivity.getLayoutInflater().inflate(R.layout.count_down_to_capture, mRootView, true);
+ mCountDownView = (CountDownView) mRootView.findViewById(R.id.count_down_to_capture);
mCountDownView.setCountDownFinishedListener((OnCountDownFinishedListener) mController);
mCountDownView.bringToFront();
mCountDownView.setOrientation(mOrientation);
@@ -1121,7 +1121,7 @@ public class PhotoUI implements PieListener,
public void startSelfieFlash() {
if(mSelfieView == null)
- mSelfieView = (SelfieFlashView) (mRootView.findViewById(R.id.selfie_flash));
+ mSelfieView = (SelfieFlashView) mRootView.findViewById(R.id.selfie_flash);
mSelfieView.bringToFront();
mSelfieView.open();
mScreenBrightness = setScreenBrightness(1F);
@@ -1129,7 +1129,7 @@ public class PhotoUI implements PieListener,
public void stopSelfieFlash() {
if(mSelfieView == null)
- mSelfieView = (SelfieFlashView) (mRootView.findViewById(R.id.selfie_flash));
+ mSelfieView = (SelfieFlashView) mRootView.findViewById(R.id.selfie_flash);
mSelfieView.close();
if(mScreenBrightness != 0.0f)
setScreenBrightness(mScreenBrightness);
@@ -1178,11 +1178,11 @@ public class PhotoUI implements PieListener,
}
public void initDisplayChangeListener() {
- ((CameraRootView) mRootView).setDisplayChangeListener(this);
+ mRootView.setDisplayChangeListener(this);
}
public void removeDisplayChangeListener() {
- ((CameraRootView) mRootView).removeDisplayChangeListener();
+ mRootView.removeDisplayChangeListener();
}
public FocusRing getFocusRing() {
@@ -1241,8 +1241,6 @@ public class PhotoUI implements PieListener,
mSubMenuLayout.setOrientation(orientation, animation);
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);