From 0316f86c60f65ad521ee1e0a12919b82a2d3c03f Mon Sep 17 00:00:00 2001 From: Chao Zhang Date: Thu, 28 Jan 2016 20:55:00 +0800 Subject: Gallery2: fix crop button and action bar overlapped when crop a 16:9 photo. When crop a 16:9 photo, crop button and action bar overlapped. Add a topMargin to editor container. Change-Id: I9ed2356d5575a859bbfba172692fa9a91802b3e8 CRs-Fixed: 967548 --- .../gallery3d/filtershow/FilterShowActivity.java | 21 ++++++++++++++++++++- .../gallery3d/filtershow/editors/Editor.java | 4 +++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 1824e7fd0..ab921e689 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -739,11 +739,30 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } private void setupEditors() { - mEditorPlaceHolder.setContainer((FrameLayout) findViewById(R.id.editorContainer)); + FrameLayout editorContainer = (FrameLayout) findViewById(R.id.editorContainer); + LayoutParams layoutParams = (LayoutParams) editorContainer.getLayoutParams(); + // if topMargin is not set in xml, set a default value here. + if (layoutParams.topMargin == 0) { + layoutParams.topMargin = getActionBarHeight() + getStatusBarHeight(); + editorContainer.setLayoutParams(layoutParams); + } + + mEditorPlaceHolder.setContainer(editorContainer); EditorManager.addEditors(mEditorPlaceHolder); mEditorPlaceHolder.setOldViews(mImageViews); } + private int getActionBarHeight() { + ActionBar actionBar = getActionBar(); + return actionBar == null ? 0 : actionBar.getHeight(); + } + + private int getStatusBarHeight() { + Rect frame = new Rect(); + getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); + return frame.top; + } + private void setDefaultValues() { Resources res = getResources(); diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java index 490e5991c..d4d872a4d 100644 --- a/src/com/android/gallery3d/filtershow/editors/Editor.java +++ b/src/com/android/gallery3d/filtershow/editors/Editor.java @@ -145,10 +145,12 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar); mSeekBar.setOnSeekBarChangeListener(this); mSeekBar.setVisibility(View.GONE); + editControl.setVisibility(View.GONE); if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { if (showsSeekBar()) { - mSeekBar.setVisibility(View.VISIBLE); + mSeekBar.setVisibility(View.VISIBLE); + editControl.setVisibility(View.VISIBLE); } } -- cgit v1.2.3