diff options
| author | wqi <wqi@codeaurora.org> | 2016-04-14 11:25:23 +0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-04-22 02:51:33 -0700 |
| commit | 6c5a2dd884a861e8d279fb7cd50c11b4c7d68004 (patch) | |
| tree | 8fcb5cfbfc6f6fdc8f1845767add280e59422ee9 /src/com | |
| parent | 317616930e7273b40e8b7a367fee225b1c9e6bea (diff) | |
| download | android_packages_apps_Gallery2-6c5a2dd884a861e8d279fb7cd50c11b4c7d68004.tar.gz android_packages_apps_Gallery2-6c5a2dd884a861e8d279fb7cd50c11b4c7d68004.tar.bz2 android_packages_apps_Gallery2-6c5a2dd884a861e8d279fb7cd50c11b4c7d68004.zip | |
Gallery2: Modified layout of crop and exposure model in photo editor.
1. Modified layout in crop model.
2. Remove mirror and draw only keep crop, straighten, rotate in
crop model.
3. Adjust style of seekbar in exposure model.
4. Modified layout in exposure model.
5. Remove '4:3', '3:4', '5:7' and '7:5' functions from crop.
According to UX specification document.
Change-Id: Ib536b3f57a83053bac8fc6ec778675a82b6327e6
CRs-Fixed: 988082 988090
Diffstat (limited to 'src/com')
13 files changed, 577 insertions, 32 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index a5b58f2b1..7c2768f8b 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -86,13 +86,17 @@ import com.android.gallery3d.filtershow.category.Action; import com.android.gallery3d.filtershow.category.CategoryAdapter; import com.android.gallery3d.filtershow.category.CategorySelected; import com.android.gallery3d.filtershow.category.CategoryView; +import com.android.gallery3d.filtershow.category.EditorCropPanel; import com.android.gallery3d.filtershow.category.MainPanel; +import com.android.gallery3d.filtershow.category.StraightenPanel; import com.android.gallery3d.filtershow.category.SwipableView; import com.android.gallery3d.filtershow.data.UserPresetsManager; import com.android.gallery3d.filtershow.editors.Editor; +import com.android.gallery3d.filtershow.editors.EditorCrop; import com.android.gallery3d.filtershow.editors.EditorDualCamFusion; import com.android.gallery3d.filtershow.editors.EditorManager; import com.android.gallery3d.filtershow.editors.EditorPanel; +import com.android.gallery3d.filtershow.editors.EditorStraighten; import com.android.gallery3d.filtershow.editors.ImageOnlyEditor; import com.android.gallery3d.filtershow.editors.TrueScannerEditor; import com.android.gallery3d.filtershow.filters.FilterDrawRepresentation; @@ -332,6 +336,38 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL return; } 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(); + return; + } + if (currentId == EditorStraighten.ID) { + new Runnable() { + @Override + public void run() { + StraightenPanel panel = new StraightenPanel(); + 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(); + return; + } Runnable showEditor = new Runnable() { @Override public void run() { diff --git a/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java b/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java new file mode 100644 index 000000000..30d874040 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/category/BasicGeometryPanel.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.gallery3d.filtershow.category; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.TextView; + +import com.android.gallery3d.R; + +public class BasicGeometryPanel extends Fragment { + protected View mMainView; + protected ImageButton mExitButton; + protected ImageButton mApplyButton; + protected View mBottomPanel; + protected TextView mEditorName; + + protected ImageButton[] mButtons; + protected TextView[] mTextViews; + protected View[] mPanels; + + @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); + + initButtons(); + initTexts(); + initPanels(); + + mBottomPanel = mMainView.findViewById(R.id.bottom_panel); + + mExitButton = (ImageButton) mMainView.findViewById(R.id.cancel); + mApplyButton = (ImageButton) mMainView.findViewById(R.id.done); + return mMainView; + } + + protected void initButtons() { + mButtons = new ImageButton[] { + (ImageButton) mMainView.findViewById(R.id.leftButton), + (ImageButton) mMainView.findViewById(R.id.centerButton), + (ImageButton) mMainView.findViewById(R.id.rightButton) + }; + } + + protected void initTexts() { + mTextViews = new TextView[] { + (TextView) mMainView.findViewById(R.id.leftText), + (TextView) mMainView.findViewById(R.id.centerText), + (TextView) mMainView.findViewById(R.id.rightText) + }; + } + + protected void initPanels() { + mPanels = new View[] { + mMainView.findViewById(R.id.leftPanel), + mMainView.findViewById(R.id.centerPanel), + mMainView.findViewById(R.id.rightPanel) + }; + } +} diff --git a/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java b/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java new file mode 100644 index 000000000..d98f79d03 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.gallery3d.filtershow.category; + +import android.app.Activity; +import android.graphics.Color; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.View; +import android.widget.ImageButton; +import android.widget.TextView; + +import com.android.gallery3d.R; +import com.android.gallery3d.filtershow.FilterShowActivity; +import com.android.gallery3d.filtershow.editors.EditorCrop; + +public class EditorCropPanel extends BasicGeometryPanel { + private EditorCrop mEditorCrop; + + private int mSelectPosition = 0; + + private final int[] mCropAspectIds = { + R.id.crop_menu_none, + R.id.crop_menu_original, + R.id.crop_menu_1to1 + }; + + private final int[] mCropDrawableIds = { + R.drawable.crop_free_background, + R.drawable.crop_original_background, + R.drawable.crop_one_background + }; + + private final int[] mCropTextIds = { + R.string.aspectNone_effect, + R.string.aspectOriginal_effect, + R.string.aspect1to1_effect + }; + + private View.OnClickListener mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + int index = (int) v.getTag(); + changeSelection(index); + } + }; + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + FilterShowActivity filterShowActivity = (FilterShowActivity) activity; + mEditorCrop = (EditorCrop) filterShowActivity.getEditor(EditorCrop.ID); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mEditorName.setText(R.string.crop); + mMainView.setBackgroundColor(getContext().getResources().getColor( + R.color.edit_actionbar_background)); + + mBottomPanel.setVisibility(View.VISIBLE); + + if (mEditorCrop != null) { + mEditorCrop.reflectCurrentFilter(); + } + + highlightIndex(mSelectPosition); + + final FilterShowActivity activity = (FilterShowActivity) getActivity(); + mApplyButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mEditorCrop.finalApplyCalled(); + activity.backToMain(); + activity.setActionBar(false); + } + }); + mExitButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + activity.cancelCurrentFilter(); + activity.backToMain(); + activity.setActionBar(false); + } + }); + } + + @Override + protected void initButtons() { + super.initButtons(); + int size = mButtons.length; + for (int i = 0; i < size; i++) { + ImageButton view = mButtons[i]; + view.setImageDrawable(getResources().getDrawable(mCropDrawableIds[i])); + // ues tag to store index. + view.setTag(i); + view.setOnClickListener(mOnClickListener); + } + } + + @Override + protected void initTexts() { + super.initTexts(); + int size = mTextViews.length; + for (int i = 0; i < size; i++) { + TextView view = mTextViews[i]; + view.setText(mCropTextIds[i]); + } + } + + private void changeSelection(int index) { + if (index >= 0 && index < mButtons.length) { + mSelectPosition = index; + mEditorCrop.changeCropAspect(mCropAspectIds[index]); + highlightIndex(index); + } + } + + private void highlightIndex(int index) { + int size = mButtons.length; + for (int i = 0; i < size; i++) { + View view = mButtons[i]; + view.setSelected(index == i); + } + size = mTextViews.length; + for (int i = 0; i < size; i++) { + TextView view = mTextViews[i]; + view.setTextColor(index == i ? + getResources().getColor(R.color.crop_text_color) : + Color.WHITE); + } + } + + @Override + public void onDetach() { + if (mEditorCrop != null) { + mEditorCrop.detach(); + } + super.onDetach(); + } +} diff --git a/src/com/android/gallery3d/filtershow/category/GeometryPanel.java b/src/com/android/gallery3d/filtershow/category/GeometryPanel.java new file mode 100644 index 000000000..b0d39175c --- /dev/null +++ b/src/com/android/gallery3d/filtershow/category/GeometryPanel.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.gallery3d.filtershow.category; + +import android.content.res.Resources; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.TextView; + +import com.android.gallery3d.filtershow.FilterShowActivity; +import com.android.gallery3d.filtershow.filters.FilterRepresentation; +import com.android.gallery3d.filtershow.filters.FiltersManager; + +import java.util.ArrayList; + +public class GeometryPanel extends BasicGeometryPanel { + + ArrayList<FilterRepresentation> mFiltersRepresentations; + + private View.OnClickListener mOnClickListener = new View.OnClickListener() { + @Override + public void onClick(View v) { + int index = (int) v.getTag(); + if (index >= 0 && index < mButtons.length) { + final FilterShowActivity activity = (FilterShowActivity) getActivity(); + activity.showRepresentation(mFiltersRepresentations.get(index)); + } + } + }; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + FiltersManager filtersManager = FiltersManager.getManager(); + mFiltersRepresentations = filtersManager.getTools(); + return super.onCreateView(inflater, container, savedInstanceState); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + } + + @Override + protected void initButtons() { + super.initButtons(); + Resources res = getActivity().getResources(); + int size = mButtons.length; + for (int i = 0; i < size; i++) { + ImageButton view = mButtons[i]; + view.setImageDrawable(res.getDrawable(mFiltersRepresentations.get(i).getOverlayId())); + // ues tag to store index. + view.setTag(i); + view.setOnClickListener(mOnClickListener); + } + } + + @Override + protected void initTexts() { + super.initTexts(); + Resources res = getActivity().getResources(); + int size = mTextViews.length; + for (int i = 0; i < size; i++) { + TextView view = mTextViews[i]; + view.setText(res.getString(mFiltersRepresentations.get(i).getTextId())); + } + } +} diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java index ef554e615..c68f83cbd 100644 --- a/src/com/android/gallery3d/filtershow/category/MainPanel.java +++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java @@ -228,7 +228,7 @@ public class MainPanel extends Fragment { return true; } - private void setCategoryFragment(CategoryPanel category, boolean fromRight) { + private void setCategoryFragment(Fragment category, boolean fromRight) { FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); FilterShowActivity activity = (FilterShowActivity) getActivity(); if (fromRight) { @@ -289,8 +289,7 @@ public class MainPanel extends Fragment { } boolean fromRight = isRightAnimation(GEOMETRY); selection(mCurrentSelected, false); - CategoryPanel categoryPanel = new CategoryPanel(); - categoryPanel.setAdapter(GEOMETRY); + GeometryPanel categoryPanel = new GeometryPanel(); setCategoryFragment(categoryPanel, fromRight); mCurrentSelected = GEOMETRY; selection(mCurrentSelected, true); diff --git a/src/com/android/gallery3d/filtershow/category/StraightenPanel.java b/src/com/android/gallery3d/filtershow/category/StraightenPanel.java new file mode 100644 index 000000000..c3be2c956 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/category/StraightenPanel.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016, The Linux Foundation. All rights reserved. + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.gallery3d.filtershow.category; + +import android.app.Activity; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.View; + +import com.android.gallery3d.R; +import com.android.gallery3d.filtershow.FilterShowActivity; +import com.android.gallery3d.filtershow.editors.EditorStraighten; + +public class StraightenPanel extends BasicGeometryPanel { + private EditorStraighten mEditorStraighten; + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + FilterShowActivity filterShowActivity = (FilterShowActivity) activity; + mEditorStraighten = (EditorStraighten) filterShowActivity.getEditor(EditorStraighten.ID); + } + + @Override + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + mEditorName.setText(R.string.straighten); + + mBottomPanel.setVisibility(View.VISIBLE); + + final FilterShowActivity activity = (FilterShowActivity) getActivity(); + mExitButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + activity.cancelCurrentFilter(); + activity.backToMain(); + activity.setActionBar(false); + } + }); + mApplyButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mEditorStraighten.finalApplyCalled(); + activity.backToMain(); + activity.setActionBar(false); + } + }); + } + + @Override + protected void initPanels() { + super.initPanels(); + int size = mPanels.length; + for (int i = 0; i < size; i++) { + View view = mPanels[i]; + view.setVisibility(View.GONE); + } + } + + @Override + public void onDetach() { + if (mEditorStraighten != null) { + mEditorStraighten.detach(); + } + super.onDetach(); + } +} diff --git a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java index 1ff3e1677..10ac65985 100644 --- a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java +++ b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java @@ -21,17 +21,15 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.SeekBar.OnSeekBarChangeListener; -import android.widget.TextView; import com.android.gallery3d.R; +import com.android.gallery3d.filtershow.FilterShowActivity; import com.android.gallery3d.filtershow.editors.Editor; public class BasicSlider implements Control { private SeekBar mSeekBar; - private TextView mFilterValue,mFilterText; private ParameterInteger mParameter; Editor mEditor; @@ -39,18 +37,38 @@ public class BasicSlider implements Control { public void setUp(ViewGroup container, Parameter parameter, Editor editor) { container.removeAllViews(); mEditor = editor; - Context context = container.getContext(); + final Context context = container.getContext(); mParameter = (ParameterInteger) parameter; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout lp = (LinearLayout) inflater.inflate( R.layout.filtershow_seekbar, container, true); - LinearLayout lpBasicFilterContainer = (LinearLayout) lp.findViewById(R.id.basicFilterContainer); mSeekBar = (SeekBar) lp.findViewById(R.id.primarySeekBar); - mFilterText = (TextView)lpBasicFilterContainer.findViewById(R.id.tvFilterName); - mFilterValue = (TextView)lpBasicFilterContainer.findViewById(R.id.tvFilterValue); mSeekBar.setVisibility(View.VISIBLE); - mEditor.setBasicFilterUI(mFilterText, mFilterValue); + View saveButton = lp.findViewById(R.id.slider_save); + if (saveButton != null) { + saveButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FilterShowActivity activity = (FilterShowActivity) context; + mEditor.finalApplyCalled(); + activity.backToMain(); + activity.setActionBar(); + } + }); + } + View cancelButton = lp.findViewById(R.id.slider_cancel); + if (cancelButton != null) { + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + FilterShowActivity activity = (FilterShowActivity) context; + activity.cancelCurrentFilter(); + activity.backToMain(); + activity.setActionBar(); + } + }); + } updateUI(); mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { diff --git a/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java b/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java index df0f14fe0..8edbcba8f 100644 --- a/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java +++ b/src/com/android/gallery3d/filtershow/crop/CropDrawingUtils.java @@ -16,6 +16,7 @@ package com.android.gallery3d.filtershow.crop; +import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Matrix; @@ -25,13 +26,16 @@ import android.graphics.RectF; import android.graphics.Region; import android.graphics.drawable.Drawable; +import com.android.gallery3d.R; + public abstract class CropDrawingUtils { - public static void drawRuleOfThird(Canvas canvas, RectF bounds) { + public static void drawRuleOfThird(Canvas canvas, RectF bounds, Context context) { Paint p = new Paint(); p.setStyle(Paint.Style.STROKE); - p.setColor(Color.argb(128, 255, 255, 255)); - p.setStrokeWidth(2); + p.setColor(Color.argb(75, 255, 255, 255)); + p.setStrokeWidth(context.getResources().getDimensionPixelOffset( + R.dimen.crop_line_stroke)); float stepX = bounds.width() / 3.0f; float stepY = bounds.height() / 3.0f; float x = bounds.left + stepX; @@ -46,14 +50,42 @@ public abstract class CropDrawingUtils { } } - public static void drawCropRect(Canvas canvas, RectF bounds) { + public static void drawCropRect(Canvas canvas, RectF bounds, Context context) { Paint p = new Paint(); p.setStyle(Paint.Style.STROKE); p.setColor(Color.WHITE); - p.setStrokeWidth(3); + p.setAlpha(75); + p.setStrokeWidth(context.getResources().getDimensionPixelOffset( + R.dimen.crop_rect_stroke)); canvas.drawRect(bounds, p); } + public static void drawCorner(Canvas canvas, RectF bounds, Context context) { + int strokeWidth = context.getResources().getDimensionPixelOffset( + R.dimen.crop_rect_stroke); + Paint p = new Paint(); + p.setStyle(Paint.Style.FILL); + p.setColor(Color.WHITE); + p.setAntiAlias(true); + p.setStrokeWidth(strokeWidth); + float cornerLength = context.getResources().getDimensionPixelOffset( + R.dimen.crop_corner_length); + float rectWidth = bounds.right - bounds.left; + float rectHeight = bounds.bottom - bounds.top; + float x = 0; + float y = 0; + for (int i = 0; i < 2; i++) { + y = i * rectHeight + bounds.top + strokeWidth / 2; + canvas.drawLine(bounds.left - strokeWidth / 2, y, cornerLength + bounds.left, y, p); + canvas.drawLine(bounds.right - cornerLength, y, bounds.right + strokeWidth / 2, y, p); + } + for (int j = 0; j < 2; j++) { + x = j * rectWidth + bounds.left; + canvas.drawLine(x, bounds.top, x, bounds.top + cornerLength, p); + canvas.drawLine(x, bounds.bottom - cornerLength, x, bounds.bottom, p); + } + } + public static void drawShade(Canvas canvas, RectF bounds) { int w = canvas.getWidth(); int h = canvas.getHeight(); diff --git a/src/com/android/gallery3d/filtershow/crop/CropView.java b/src/com/android/gallery3d/filtershow/crop/CropView.java index bbb7cfd4c..e1f42066c 100644 --- a/src/com/android/gallery3d/filtershow/crop/CropView.java +++ b/src/com/android/gallery3d/filtershow/crop/CropView.java @@ -356,9 +356,10 @@ public class CropView extends View { CropDrawingUtils.drawShadows(canvas, p, mScreenCropBounds, mScreenImageBounds); // Draw crop rect and markers - CropDrawingUtils.drawCropRect(canvas, mScreenCropBounds); + CropDrawingUtils.drawCropRect(canvas, mScreenCropBounds, getContext()); + CropDrawingUtils.drawCorner(canvas, mScreenCropBounds, getContext()); if (!mDoSpot) { - CropDrawingUtils.drawRuleOfThird(canvas, mScreenCropBounds); + CropDrawingUtils.drawRuleOfThird(canvas, mScreenCropBounds, getContext()); } else { Paint wpPaint = new Paint(); wpPaint.setColor(mWPMarkerColor); @@ -370,8 +371,6 @@ public class CropView extends View { CropDrawingUtils.drawWallpaperSelectionFrame(canvas, mScreenCropBounds, mSpotX, mSpotY, wpPaint, p); } - CropDrawingUtils.drawIndicators(canvas, mCropIndicator, mIndicatorSize, - mScreenCropBounds, mCropObj.isFixedAspect(), decode(mCropObj.getSelectState(), mRotation)); } } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java index 6b19d3c2f..9312091d5 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java @@ -114,7 +114,7 @@ public class EditorCrop extends Editor implements EditorInfo { }); } - private void changeCropAspect(int itemId) { + public void changeCropAspect(int itemId) { AspectInfo info = sAspects.get(itemId); if (info == null) { throw new IllegalArgumentException("Invalid resource ID: " + itemId); diff --git a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java index 8398c31c2..d7b7f5724 100644 --- a/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java +++ b/src/com/android/gallery3d/filtershow/editors/ParametricEditor.java @@ -79,7 +79,7 @@ public class ParametricEditor extends Editor { landscapeMap.put(ParameterColor.sParameterType, ColorChooser.class); portraitMap.put(ParameterInteger.sParameterType, BasicSlider.class); - landscapeMap.put(ParameterInteger.sParameterType, TitledSlider.class); + landscapeMap.put(ParameterInteger.sParameterType, BasicSlider.class); portraitMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class); landscapeMap.put(ParameterActionAndInt.sParameterType, ActionSlider.class); portraitMap.put(ParameterStyles.sParameterType, StyleChooser.class); diff --git a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java index b72b5d2fd..d9b28cef1 100644 --- a/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java +++ b/src/com/android/gallery3d/filtershow/filters/BaseFiltersManager.java @@ -388,9 +388,9 @@ public abstract class BaseFiltersManager implements FiltersManagerInterface { }; int[] overlayId = { - R.drawable.filtershow_button_geometry_crop, - R.drawable.filtershow_button_geometry_straighten, - R.drawable.filtershow_button_geometry_rotate + R.drawable.crop_crop, + R.drawable.crop_straighten, + R.drawable.crop_rotate }; FilterRepresentation[] geometryFilters = { diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java index 2161f9af5..e2de11e8c 100644 --- a/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java +++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCrop.java @@ -188,6 +188,8 @@ public class ImageCrop extends ImageShow { x = y; y = tmp; } + RectF outer = mCropObj.getOuterBounds(); + mCropObj.resetBoundsTo(outer, outer); if (!mCropObj.setInnerAspectRatio(x, y)) { Log.w(TAG, "failed to set aspect ratio"); } @@ -267,12 +269,17 @@ public class ImageCrop extends ImageShow { // If display matrix doesn't exist, create it and its dependencies 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); mDisplayMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry, - bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(), canvas.getHeight()); + bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(), + canvas.getHeight() - panelHeight); float straighten = mGeometry.straighten; mGeometry.straighten = 0; mDisplayCropMatrix = GeometryMathUtils.getFullGeometryToScreenMatrix(mGeometry, - bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(), canvas.getHeight()); + bitmap.getWidth(), bitmap.getHeight(), canvas.getWidth(), + canvas.getHeight() - panelHeight); mGeometry.straighten = straighten; mDisplayMatrixInverse = new Matrix(); mDisplayMatrixInverse.reset(); @@ -314,12 +321,10 @@ public class ImageCrop extends ImageShow { bitmap.getHeight()); if (mDisplayCropMatrix.mapRect(mScreenCropBounds)) { // Draw crop rect and markers - CropDrawingUtils.drawCropRect(canvas, mScreenCropBounds); CropDrawingUtils.drawShade(canvas, mScreenCropBounds); - CropDrawingUtils.drawRuleOfThird(canvas, mScreenCropBounds); - CropDrawingUtils.drawIndicators(canvas, mCropIndicator, mIndicatorSize, - mScreenCropBounds, mCropObj.isFixedAspect(), - decode(mCropObj.getSelectState(), mGeometry.rotation.value())); + CropDrawingUtils.drawCropRect(canvas, mScreenCropBounds, getContext()); + CropDrawingUtils.drawCorner(canvas, mScreenCropBounds, getContext()); + CropDrawingUtils.drawRuleOfThird(canvas, mScreenCropBounds, getContext()); } } |
