summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorwqi <wqi@codeaurora.org>2016-05-03 17:17:10 +0800
committerLikai Ding <likaid@codeaurora.org>2016-07-12 11:29:19 +0800
commit99b35c190ab111742881628df6fb93f80463d19b (patch)
tree87b8212681fda239555cc88d7555bcda9a26923e /src/com/android
parentb7f0f7f067f5979e7e7e52aa9836ed3dbcca475c (diff)
downloadandroid_packages_apps_Gallery2-99b35c190ab111742881628df6fb93f80463d19b.tar.gz
android_packages_apps_Gallery2-99b35c190ab111742881628df6fb93f80463d19b.tar.bz2
android_packages_apps_Gallery2-99b35c190ab111742881628df6fb93f80463d19b.zip
Gallery2: Modified landscape layout of editor crop in editor interface.
Modified landscape layout of editor crop and keep function is normal according to UX specification document. Change-Id: I1bbd1239b28b806cbb866b44640d1caf79692ecf CRs-Fixed: 988687
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java63
-rw-r--r--src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java19
-rw-r--r--src/com/android/gallery3d/filtershow/category/EditorCropPanel.java16
-rw-r--r--src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java51
5 files changed, 129 insertions, 23 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index f0af615c0..284f8159f 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -92,7 +92,6 @@ import com.android.gallery3d.filtershow.category.StraightenPanel;
import com.android.gallery3d.filtershow.category.SwipableView;
import com.android.gallery3d.filtershow.category.TrueScannerPanel;
import com.android.gallery3d.filtershow.data.UserPresetsManager;
-import com.android.gallery3d.filtershow.editors.BasicEditor;
import com.android.gallery3d.filtershow.editors.Editor;
import com.android.gallery3d.filtershow.editors.EditorCrop;
import com.android.gallery3d.filtershow.editors.EditorDualCamFusion;
@@ -214,7 +213,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
private ImageButton imgComparison;
private String mPopUpText, mCancel;
RelativeLayout rlImageContainer;
+ private int mEditrCropButtonSelect = 0;
private boolean isComingFromEditorScreen;
+ private boolean mIsReloadByConfigurationChanged;
private AlertDialog.Builder mBackAlertDialogBuilder;
private ProgressDialog mLoadingDialog;
@@ -376,19 +377,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
}
final int currentId = currentEditor.getID();
if (currentId == EditorCrop.ID) {
- new Runnable() {
- @Override
- public void run() {
- EditorCropPanel panel = new EditorCropPanel();
- FragmentTransaction transaction =
- getSupportFragmentManager().beginTransaction();
- transaction.remove(getSupportFragmentManager().findFragmentByTag(
- MainPanel.FRAGMENT_TAG));
- transaction.replace(R.id.main_panel_container, panel,
- MainPanel.FRAGMENT_TAG);
- transaction.commit();
- }
- }.run();
+ loadEditorCropPanel();
return;
}
if (useStraightenPanel(currentId)) {
@@ -464,6 +453,22 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
return (EditorID == EditorStraighten.ID || EditorID == HazeBusterEditor.ID || EditorID == SeeStraightEditor.ID);
}
+ private void loadEditorCropPanel() {
+ new Runnable() {
+ @Override
+ public void run() {
+ EditorCropPanel panel = new EditorCropPanel();
+ FragmentTransaction transaction =
+ getSupportFragmentManager().beginTransaction();
+ transaction.remove(getSupportFragmentManager().findFragmentByTag(
+ MainPanel.FRAGMENT_TAG));
+ transaction.replace(R.id.main_panel_container, panel,
+ MainPanel.FRAGMENT_TAG);
+ transaction.commit();
+ }
+ }.run();
+ }
+
public void leaveSeekBarPanel() {
removeSeekBarPanel();
showDefaultImageView();
@@ -1729,6 +1734,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
super.onConfigurationChanged(newConfig);
setDefaultValues();
+ if (isShowEditCropPanel()) {
+ mIsReloadByConfigurationChanged = true;
+ loadEditorCropPanel();
+ }
if (mMasterImage == null) {
return;
}
@@ -1806,6 +1815,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
if (currentPanel instanceof MainPanel) {
return;
}
+ mIsReloadByConfigurationChanged = false;
loadMainPanel();
showDefaultImageView();
showComparisonButton();
@@ -2018,4 +2028,29 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL
public void setScaleImage(boolean isScaled) {
mImageShow.scaleImage(isScaled, getBaseContext());
}
+
+ public void saveEditorCropState(int select) {
+ mEditrCropButtonSelect = select;
+ }
+
+ public boolean isReloadByConfigurationChanged() {
+ return mIsReloadByConfigurationChanged;
+ }
+
+ public boolean isShowEditCropPanel() {
+ if (mCurrentEditor == null) {
+ return false;
+ }
+ Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(
+ MainPanel.FRAGMENT_TAG);
+ if (currentPanel instanceof MainPanel) {
+ return false;
+ }
+ return mCurrentEditor.getID() == EditorCrop.ID;
+ }
+
+ public int getEditorCropButtonSelect() {
+ return mEditrCropButtonSelect;
+ }
+
}
diff --git a/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java b/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java
index 52d16a56c..466ecd87f 100644
--- a/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java
@@ -30,6 +30,7 @@
package com.android.gallery3d.filtershow.category;
+import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
@@ -38,6 +39,7 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
+import com.android.gallery3d.filtershow.FilterShowActivity;
import org.codeaurora.gallery.R;
public class BasicGeometryPanel extends Fragment {
@@ -54,8 +56,15 @@ public class BasicGeometryPanel extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- mMainView = inflater.inflate(R.layout.filtershow_category_geometry_panel, container, false);
- mEditorName = (TextView) mMainView.findViewById(R.id.editor_name);
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ if (isLandscape() && activity.isShowEditCropPanel()) {
+ mMainView = inflater.inflate(R.layout.filtershow_editor_crop_landscape,
+ container, false);
+ } else {
+ mMainView = inflater.inflate(R.layout.filtershow_category_geometry_panel,
+ container, false);
+ mEditorName = (TextView) mMainView.findViewById(R.id.editor_name);
+ }
initButtons();
initTexts();
@@ -91,4 +100,10 @@ public class BasicGeometryPanel extends Fragment {
mMainView.findViewById(R.id.rightPanel)
};
}
+
+ protected boolean isLandscape() {
+ Configuration mConfiguration = this.getResources().getConfiguration();
+ return mConfiguration.orientation == Configuration.ORIENTATION_LANDSCAPE ?
+ true : false;
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java b/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java
index 3e6124c0a..db7dfd019 100644
--- a/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java
+++ b/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java
@@ -30,6 +30,7 @@
package com.android.gallery3d.filtershow.category;
import android.app.Activity;
+import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
@@ -76,13 +77,19 @@ public class EditorCropPanel extends BasicGeometryPanel {
public void onAttach(Activity activity) {
super.onAttach(activity);
FilterShowActivity filterShowActivity = (FilterShowActivity) activity;
+ if (filterShowActivity.isReloadByConfigurationChanged()) {
+ mSelectPosition = filterShowActivity.getEditorCropButtonSelect();
+ }
mEditorCrop = (EditorCrop) filterShowActivity.getEditor(EditorCrop.ID);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mEditorName.setText(R.string.crop);
+ if (!isLandscape()) {
+ mEditorName.setText(R.string.crop);
+ mBottomPanel.setVisibility(View.VISIBLE);
+ }
mMainView.setBackgroundColor(getContext().getResources().getColor(
R.color.edit_actionbar_background));
@@ -166,4 +173,11 @@ public class EditorCropPanel extends BasicGeometryPanel {
}
super.onDetach();
}
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ FilterShowActivity activity = (FilterShowActivity) getActivity();
+ activity.saveEditorCropState(mSelectPosition);
+ }
}
diff --git a/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java b/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
index b3f1af72d..5937c789a 100644
--- a/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
+++ b/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java
@@ -75,7 +75,8 @@ public abstract class CropDrawingUtils {
float x = 0;
float y = 0;
for (int i = 0; i < 2; i++) {
- y = i * rectHeight + bounds.top + strokeWidth / 2;
+ y = i * rectHeight + bounds.top;
+
canvas.drawLine(bounds.left - strokeWidth / 2, y, cornerLength + bounds.left, y, p);
canvas.drawLine(bounds.right - cornerLength, y, bounds.right + strokeWidth / 2, y, p);
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
index 294fbb7a7..4921c7ce9 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java
@@ -28,13 +28,14 @@ import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
-import org.codeaurora.gallery.R;
+import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.filtershow.crop.CropDrawingUtils;
import com.android.gallery3d.filtershow.crop.CropMath;
import com.android.gallery3d.filtershow.crop.CropObject;
import com.android.gallery3d.filtershow.editors.EditorCrop;
import com.android.gallery3d.filtershow.filters.FilterCropRepresentation;
import com.android.gallery3d.filtershow.imageshow.GeometryMathUtils.GeometryHolder;
+import org.codeaurora.gallery.R;
public class ImageCrop extends ImageShow {
private static final String TAG = ImageCrop.class.getSimpleName();
@@ -232,9 +233,11 @@ public class ImageCrop extends ImageShow {
private void forceStateConsistency() {
MasterImage master = MasterImage.getImage();
Bitmap image = master.getFiltersOnlyImage();
+ FilterShowActivity filterShowActivity = (FilterShowActivity) getContext();
+ boolean isReload = filterShowActivity.isReloadByConfigurationChanged();
int width = image.getWidth();
int height = image.getHeight();
- if (mCropObj == null || !mUpdateHolder.equals(mGeometry)
+ if (mCropObj == null || (!mUpdateHolder.equals(mGeometry) && !isReload)
|| mImageBounds.width() != width || mImageBounds.height() != height
|| !mLocalRep.getCrop().equals(mUpdateHolder.crop)) {
mImageBounds.set(0, 0, width, height);
@@ -251,7 +254,12 @@ public class ImageCrop extends ImageShow {
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
- clearDisplay();
+ FilterShowActivity filterShowActivity = (FilterShowActivity) getContext();
+ if (filterShowActivity.isShowEditCropPanel()) {
+ updateMatrix(w, h);
+ } else {
+ clearDisplay();
+ }
}
@Override
@@ -270,8 +278,13 @@ public class ImageCrop extends ImageShow {
if (mDisplayCropMatrix == null || mDisplayMatrix == null || mDisplayMatrixInverse == null) {
mCropObj.unsetAspectRatio();
Resources res = getContext().getResources();
- int panelHeight = res.getDimensionPixelOffset(R.dimen.category_panel_height) +
- res.getDimensionPixelOffset(R.dimen.category_actionbar_panel_height);
+ int panelHeight = 0;
+ if (canvas.getWidth() < canvas.getHeight()) {
+ panelHeight = res.getDimensionPixelOffset(R.dimen.category_panel_height) +
+ res.getDimensionPixelOffset(R.dimen.category_actionbar_panel_height);
+ } else {
+ panelHeight = res.getDimensionPixelOffset(R.dimen.crop_panel_height_lanscape);
+ }
mDisplayMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry,
bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(),
canvas.getHeight() - panelHeight);
@@ -331,4 +344,32 @@ public class ImageCrop extends ImageShow {
public void setEditor(EditorCrop editorCrop) {
mEditorCrop = editorCrop;
}
+
+ private void updateMatrix(int w, int h) {
+ Bitmap bitmap = MasterImage.getImage().getFiltersOnlyImage();
+ if (bitmap == null) {
+ MasterImage.getImage().invalidateFiltersOnly();
+ }
+ if (!mValidDraw || bitmap == null) {
+ return;
+ }
+ Resources res = getContext().getResources();
+ int panelHeight = 0;
+ if (w < h) {
+ panelHeight = res.getDimensionPixelOffset(R.dimen.category_panel_height) +
+ res.getDimensionPixelOffset(R.dimen.category_actionbar_panel_height);
+ } else {
+ panelHeight = res.getDimensionPixelOffset(R.dimen.crop_panel_height_lanscape);
+ }
+ mDisplayMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry,
+ bitmap.getWidth(), bitmap.getHeight(), w, h - panelHeight);
+ mDisplayCropMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry,
+ bitmap.getWidth(), bitmap.getHeight(), w, h - panelHeight);
+ mDisplayMatrixInverse = new Matrix();
+ mDisplayMatrixInverse.reset();
+ if (!mDisplayCropMatrix.invert(mDisplayMatrixInverse)) {
+ Log.w(TAG, "could not invert display matrix");
+ mDisplayMatrixInverse = null;
+ }
+ }
}