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/PhotoMenu.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/PhotoMenu.java')
-rw-r--r-- | src/com/android/camera/PhotoMenu.java | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java index 271640d29..078a23e2d 100644 --- a/src/com/android/camera/PhotoMenu.java +++ b/src/com/android/camera/PhotoMenu.java @@ -44,6 +44,7 @@ import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; import com.android.camera.CameraPreference.OnPreferenceChangedListener; +import com.android.camera.ui.CameraRootView; import com.android.camera.ui.CountdownTimerPopup; import com.android.camera.ui.ListSubMenu; import com.android.camera.ui.ListMenu; @@ -53,8 +54,6 @@ import com.android.camera.ui.RotateTextToast; import org.codeaurora.snapcam.R; import android.widget.HorizontalScrollView; import android.view.ViewGroup; -import android.view.WindowManager; -import android.view.Display; import com.android.camera.util.CameraUtil; import java.util.Locale; @@ -798,8 +797,6 @@ public class PhotoMenu extends MenuController if (!mIsDefaultToPortrait) { rotation = (rotation + 90) % 360; } - WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE); - Display display = wm.getDefaultDisplay(); CharSequence[] entries = pref.getEntries(); @@ -831,22 +828,23 @@ public class PhotoMenu extends MenuController gridRes, null, false); mUI.dismissSceneModeMenu(); - LinearLayout previewMenuLayout = new LinearLayout(mActivity); - mUI.setPreviewMenuLayout(previewMenuLayout); + mUI.setPreviewMenuLayout(basic); ViewGroup.LayoutParams params = null; + CameraRootView rootView = mUI.getRootView(); if (portrait) { params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT); - previewMenuLayout.setLayoutParams(params); - ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout); } else { params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size); - previewMenuLayout.setLayoutParams(params); - ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout); - previewMenuLayout.setY(display.getHeight() - size); + + int rootViewBottom = rootView.getClientRectForOrientation(rotation).bottom; + basic.setY(rootViewBottom - size); } - basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, - LayoutParams.MATCH_PARENT)); + basic.setLayoutParams(params); + rootView.addView(basic); + LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout); + Rect insets = rootView.getInsetsForOrientation(rotation); + layout.setPadding(insets.left, insets.top, insets.right, insets.bottom); final View[] views = new View[entries.length]; int init = pref.getCurrentIndex(); @@ -886,7 +884,6 @@ public class PhotoMenu extends MenuController label.setText(entries[i]); layout.addView(layout2); } - previewMenuLayout.addView(basic); mPreviewMenu = basic; } @@ -936,8 +933,6 @@ public class PhotoMenu extends MenuController if (!mIsDefaultToPortrait) { rotation = (rotation + 90) % 360; } - WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE); - Display display = wm.getDefaultDisplay(); CharSequence[] entries = pref.getEntries(); Resources r = mActivity.getResources(); @@ -968,22 +963,24 @@ public class PhotoMenu extends MenuController gridRes, null, false); mUI.dismissSceneModeMenu(); - LinearLayout previewMenuLayout = new LinearLayout(mActivity); - mUI.setPreviewMenuLayout(previewMenuLayout); + mUI.setPreviewMenuLayout(basic); ViewGroup.LayoutParams params = null; + CameraRootView rootView = mUI.getRootView(); if (portrait) { params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT); - previewMenuLayout.setLayoutParams(params); - ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout); } else { params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size); - previewMenuLayout.setLayoutParams(params); - ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout); - previewMenuLayout.setY(display.getHeight() - size); + + int rootViewBottom = rootView.getClientRectForOrientation(rotation).bottom; + basic.setY(rootViewBottom - size); } - basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, - LayoutParams.MATCH_PARENT)); + basic.setLayoutParams(params); + rootView.addView(basic); + LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout); + Rect insets = rootView.getInsetsForOrientation(rotation); + layout.setPadding(insets.left, insets.top, insets.right, insets.bottom); + final View[] views = new View[entries.length]; int init = pref.getCurrentIndex(); for (int i = 0; i < entries.length; i++) { @@ -1019,7 +1016,6 @@ public class PhotoMenu extends MenuController label.setText(entries[i]); layout.addView(layout2); } - previewMenuLayout.addView(basic); mPreviewMenu = basic; } |