diff options
15 files changed, 328 insertions, 152 deletions
diff --git a/res/drawable/filtershow_state_button_background b/res/drawable/filtershow_state_button_background deleted file mode 100644 index e69de29bb..000000000 --- a/res/drawable/filtershow_state_button_background +++ /dev/null diff --git a/res/layout/filtershow_bottom_panel.xml b/res/layout/filtershow_bottom_panel.xml new file mode 100644 index 000000000..abefcba39 --- /dev/null +++ b/res/layout/filtershow_bottom_panel.xml @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + 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. +--> + +<com.android.gallery3d.filtershow.CenteredLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/bottom_panel" + android:layout_width="match_parent" + android:layout_height="48dip" + android:layout_gravity="center|bottom" + android:background="@color/bottom_panel_background_color" + android:orientation="vertical"> + + <LinearLayout + android:id="@+id/effectsContainer" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@android:color/transparent"> + + <ImageButton + android:id="@+id/fxButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:scaleType="centerInside" + android:src="@drawable/color_background" /> + + <ImageButton + android:id="@+id/borderButton" + android:layout_width="@dimen/thumbnail_size" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/frames_background" + android:visibility="gone" /> + + <ImageButton + android:id="@+id/geometryButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/crop_background" /> + + <ImageButton + android:id="@+id/colorsButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/exposure_background" /> + + <ImageButton + android:id="@+id/makeupButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/beautify_background" + android:visibility="gone" /> + + <ImageButton + android:id="@+id/dualCamButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/dualcamera_background" + android:visibility="gone" /> + + <ImageButton + android:id="@+id/trueScannerButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/truescanner" /> + + <ImageButton + android:id="@+id/hazeBusterButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/hazebuster" /> + + <ImageButton + android:id="@+id/seeStraightButton" + android:layout_width="0dp" + android:layout_height="match_parent" + android:layout_weight="1" + android:background="@android:color/transparent" + android:padding="2dip" + android:scaleType="centerInside" + android:src="@drawable/seestraight" /> + </LinearLayout> +</com.android.gallery3d.filtershow.CenteredLinearLayout>
\ No newline at end of file diff --git a/res/layout/filtershow_editor_panel.xml b/res/layout/filtershow_editor_panel.xml index b7ec266f2..39770c6e8 100644 --- a/res/layout/filtershow_editor_panel.xml +++ b/res/layout/filtershow_editor_panel.xml @@ -20,6 +20,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" + android:background="@color/bottom_panel_background_color" android:visibility="visible" > <Button @@ -46,7 +47,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" - android:background="#000000" android:orientation="horizontal" android:gravity="center" android:visibility="visible" > diff --git a/res/layout/filtershow_main_panel.xml b/res/layout/filtershow_main_panel.xml index 7046f3089..b9b18a036 100644 --- a/res/layout/filtershow_main_panel.xml +++ b/res/layout/filtershow_main_panel.xml @@ -44,112 +44,10 @@ android:background="@color/crop_panel_background_color" android:layout_weight="1"/> - <com.android.gallery3d.filtershow.CenteredLinearLayout - xmlns:custom="http://schemas.android.com/apk/res/com.android.gallery3d" - android:id="@+id/bottom_panel" - android:layout_width="match_parent" - android:layout_height="48dip" - android:layout_gravity="center|bottom" - android:orientation="vertical" - android:background="@color/crop_panel_background_color" > - - <LinearLayout - android:id="@+id/effectsContainer" + <FrameLayout + android:id="@+id/bottom_panel_container" android:layout_width="match_parent" - android:layout_height="match_parent" - android:background="@android:color/transparent" > - - <ImageButton - android:id="@+id/fxButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:scaleType="centerInside" - android:src="@drawable/color_background" /> - - <ImageButton - android:id="@+id/borderButton" - android:layout_width="@dimen/thumbnail_size" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:visibility="gone" - android:src="@drawable/frames_background" /> - - <ImageButton - android:id="@+id/geometryButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:src="@drawable/crop_background" /> - - <ImageButton - android:id="@+id/colorsButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:src="@drawable/exposure_background" /> - - <ImageButton - android:id="@+id/makeupButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:src="@drawable/beautify_background" - android:visibility="gone" /> - - <ImageButton - android:id="@+id/dualCamButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:visibility="gone" - android:src="@drawable/dualcamera_background"/> - - <ImageButton - android:id="@+id/trueScannerButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:src="@drawable/truescanner"/> - - <ImageButton - android:id="@+id/hazeBusterButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:src="@drawable/hazebuster"/> - - <ImageButton - android:id="@+id/seeStraightButton" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:background="@android:color/transparent" - android:padding="2dip" - android:scaleType="centerInside" - android:src="@drawable/seestraight"/> - </LinearLayout> - </com.android.gallery3d.filtershow.CenteredLinearLayout> + android:layout_height="48dip" + android:visibility="visible" + android:layout_gravity="center"/> </LinearLayout> diff --git a/res/layout/filtershow_seekbar.xml b/res/layout/filtershow_seekbar.xml index 5b884ae49..216b72a9c 100644 --- a/res/layout/filtershow_seekbar.xml +++ b/res/layout/filtershow_seekbar.xml @@ -28,7 +28,7 @@ android:layout_height="60dp" android:src="@drawable/cancel" android:layout_gravity="center_vertical" - android:background="#000000" /> + android:background="@android:color/transparent" /> <SeekBar android:id="@+id/primarySeekBar" @@ -47,6 +47,6 @@ android:layout_height="60dp" android:src="@drawable/done" android:layout_gravity="center_vertical" - android:background="#000000" /> + android:background="@android:color/transparent" /> </LinearLayout> diff --git a/res/values/filtershow_color.xml b/res/values/filtershow_color.xml index a768e690e..d6a09a9cf 100644 --- a/res/values/filtershow_color.xml +++ b/res/values/filtershow_color.xml @@ -64,6 +64,7 @@ <color name="filtershow_color_xprocess">#409797</color> <color name="iconview_bottom_color">#80000000</color> + <color name="bottom_panel_background_color">#A5000000</color> <color name="crop_panel_background_color">#A5000000</color> <color name="crop_text_color">#4f92e9</color> </resources>
\ No newline at end of file diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 102aaaa6d..592c756a4 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -83,13 +83,13 @@ import com.android.gallery3d.data.LocalAlbum; import com.android.gallery3d.filtershow.cache.ImageLoader; 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.BasicEditor; import com.android.gallery3d.filtershow.editors.Editor; import com.android.gallery3d.filtershow.editors.EditorCrop; import com.android.gallery3d.filtershow.editors.EditorDualCamFusion; @@ -144,7 +144,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private ImageShow mImageShow = null; private View mSaveButton = null; - private View mExitButton = null, mCancelButton = null; private EditorPlaceHolder mEditorPlaceHolder = new EditorPlaceHolder(this); private Editor mCurrentEditor = null; @@ -209,7 +208,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private ImageButton imgComparison; private String mPopUpText, mCancel; RelativeLayout rlImageContainer; - boolean isOrientationChanged; private boolean isComingFromEditorScreen; private AlertDialog.Builder mBackAlertDialogBuilder; @@ -377,10 +375,11 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL EditorPanel panel = new EditorPanel(); panel.setEditor(currentId); setActionBarForEffects(currentEditor); - FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.remove(getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG)); - transaction.replace(R.id.main_panel_container, panel, MainPanel.FRAGMENT_TAG); - transaction.commit(); + Fragment main = + getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); + if (main instanceof MainPanel) { + ((MainPanel) main).setEditorPanelFragment(panel); + } } }; Fragment main = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); @@ -403,6 +402,21 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } + public void leaveSeekBarPanel() { + removeSeekBarPanel(); + showDefaultImageView(); + setActionBar(); + showActionBar(true); + } + + private void removeSeekBarPanel() { + Fragment currentPanel = + getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); + if (currentPanel instanceof MainPanel) { + ((MainPanel) currentPanel).removeEditorPanelFragment(); + } + } + public void toggleInformationPanel() { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); @@ -477,10 +491,6 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } public void setActionBar() { - setActionBar(false); - } - - public void setActionBar(boolean isEffectClicked) { ActionBar actionBar = getActionBar(); actionBar.setShowHideAnimationEnabled(false); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); @@ -502,8 +512,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL showSaveButtonIfNeed(); - mExitButton = actionBar.getCustomView().findViewById(R.id.filtershow_exit); - mExitButton.setOnClickListener(new OnClickListener() { + View exitButton = actionBar.getCustomView().findViewById(R.id.filtershow_exit); + exitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mImageShow.hasModifications()) { @@ -967,6 +977,18 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL return; } + Fragment currentPanel = + getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); + if (currentPanel instanceof MainPanel && ((MainPanel) currentPanel).hasEditorPanel()) { + if (representation.equals(MasterImage.getImage().getCurrentFilterRepresentation())) { + return; + } + // cancel previous filter. + cancelCurrentFilter(); + showDefaultImageView(); + removeSeekBarPanel(); + } + if (representation.getFilterType() == FilterRepresentation.TYPE_DUALCAM && MasterImage.getImage().getDepthMapLoadingStatus() == DdmStatus.DDM_FAILED) { Toast.makeText(this, getString(R.string.dualcam_filter_not_supported), Toast.LENGTH_SHORT).show(); @@ -989,7 +1011,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL FilterRepresentation filterRepresentation = representation.copy(); MasterImage.getImage().setPreset(copy, filterRepresentation, true); MasterImage.getImage().setCurrentFilterRepresentation(null); - showSaveButtonIfNeed(); + + setActionBar(); + showActionBar(true); return; } } @@ -1027,6 +1051,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL ImagePreset preset = mMasterImage.getPreset(); mCategoryLooksAdapter.reflectImagePreset(preset); mCategoryBordersAdapter.reflectImagePreset(preset); + mCategoryFiltersAdapter.reflectImagePreset(preset); + mCategoryMakeupAdapter.reflectImagePreset(preset); mCategoryDualCamAdapter.reflectImagePreset(preset); } @@ -1718,6 +1744,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } public void backToMain() { + removeSeekBarPanel(); showActionBar(true); Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); if (currentPanel instanceof MainPanel) { diff --git a/src/com/android/gallery3d/filtershow/category/BottomPanel.java b/src/com/android/gallery3d/filtershow/category/BottomPanel.java new file mode 100644 index 000000000..cd4f65775 --- /dev/null +++ b/src/com/android/gallery3d/filtershow/category/BottomPanel.java @@ -0,0 +1,60 @@ +/* + * 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; + +public class BottomPanel extends Fragment { + public static final String FRAGMENT_TAG = "BottomPanel"; + + private BottomPanelDelegate mPanelDelegate; + private View mBottomView; + + interface BottomPanelDelegate { + View getBottomPanelView(LayoutInflater inflater); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + if (mBottomView == null && mPanelDelegate != null) { + mBottomView = mPanelDelegate.getBottomPanelView(inflater); + } + return mBottomView; + } + + public void setBottomPanelDelegate(BottomPanelDelegate panelDelegate) { + mPanelDelegate = panelDelegate; + } +} diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java index d5fafee14..7ef3c0bb2 100644 --- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java +++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java @@ -31,6 +31,7 @@ import com.android.gallery3d.filtershow.pipeline.ImagePreset; public class CategoryAdapter extends ArrayAdapter<Action> { private static final String LOGTAG = "CategoryAdapter"; + private static final int UNKNOWN_INDEX = -1; private int mItemHeight; private View mContainer; private int mItemWidth = ListView.LayoutParams.MATCH_PARENT; @@ -234,6 +235,8 @@ public class CategoryAdapter extends ArrayAdapter<Action> { if (pos != -1) { rep = preset.getFilterRepresentation(pos); } + } else if (mCategory == MainPanel.FILTERS || mCategory == MainPanel.MAKEUP) { + selected = UNKNOWN_INDEX; } if (rep != null) { for (int i = 0; i < getCount(); i++) { diff --git a/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java b/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java index d98f79d03..55d52fff3 100644 --- a/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java +++ b/src/com/android/gallery3d/filtershow/category/EditorCropPanel.java @@ -100,7 +100,7 @@ public class EditorCropPanel extends BasicGeometryPanel { public void onClick(View v) { mEditorCrop.finalApplyCalled(); activity.backToMain(); - activity.setActionBar(false); + activity.setActionBar(); } }); mExitButton.setOnClickListener(new View.OnClickListener() { @@ -108,7 +108,7 @@ public class EditorCropPanel extends BasicGeometryPanel { public void onClick(View v) { activity.cancelCurrentFilter(); activity.backToMain(); - activity.setActionBar(false); + activity.setActionBar(); } }); } diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java index c68f83cbd..f2c3b099b 100644 --- a/src/com/android/gallery3d/filtershow/category/MainPanel.java +++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java @@ -27,6 +27,7 @@ import android.widget.LinearLayout; import com.android.gallery3d.R; import com.android.gallery3d.filtershow.FilterShowActivity; +import com.android.gallery3d.filtershow.editors.EditorPanel; import com.android.gallery3d.filtershow.filters.HazeBusterActs; import com.android.gallery3d.filtershow.filters.SeeStraightActs; import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter; @@ -35,11 +36,12 @@ import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.state.StatePanel; import com.android.gallery3d.filtershow.tools.DualCameraNativeEngine.DdmStatus; -public class MainPanel extends Fragment { +public class MainPanel extends Fragment implements BottomPanel.BottomPanelDelegate { private static final String LOGTAG = "MainPanel"; private LinearLayout mMainView; + private View mBottomPanelView; private ImageButton looksButton; private ImageButton bordersButton; private ImageButton geometryButton; @@ -124,17 +126,40 @@ public class MainPanel extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - mMainView = (LinearLayout) inflater.inflate( R.layout.filtershow_main_panel, null, false); - looksButton = (ImageButton) mMainView.findViewById(R.id.fxButton); - bordersButton = (ImageButton) mMainView.findViewById(R.id.borderButton); - geometryButton = (ImageButton) mMainView.findViewById(R.id.geometryButton); - filtersButton = (ImageButton) mMainView.findViewById(R.id.colorsButton); - dualCamButton = (ImageButton) mMainView.findViewById(R.id.dualCamButton); + getBottomPanelView(inflater); + initBottomPanel(); + + updateDualCameraButton(); + FilterShowActivity activity = (FilterShowActivity) getActivity(); + showPanel(activity.getCurrentPanel()); + return mMainView; + } + + private void initBottomPanel() { + BottomPanel panel = new BottomPanel(); + panel.setBottomPanelDelegate(this); + setActionFragment(panel, BottomPanel.FRAGMENT_TAG); + } + + @Override + public View getBottomPanelView(LayoutInflater inflater) { + if (mBottomPanelView != null) { + return mBottomPanelView; + } + + LinearLayout bottomPanel = (LinearLayout) inflater.inflate( + R.layout.filtershow_bottom_panel, null, false); + + looksButton = (ImageButton) bottomPanel.findViewById(R.id.fxButton); + bordersButton = (ImageButton) bottomPanel.findViewById(R.id.borderButton); + geometryButton = (ImageButton) bottomPanel.findViewById(R.id.geometryButton); + filtersButton = (ImageButton) bottomPanel.findViewById(R.id.colorsButton); + dualCamButton = (ImageButton) bottomPanel.findViewById(R.id.dualCamButton); if (SimpleMakeupImageFilter.HAS_TS_MAKEUP) { - makeupButton = (ImageButton) mMainView.findViewById(R.id.makeupButton); + makeupButton = (ImageButton) bottomPanel.findViewById(R.id.makeupButton); makeupButton.setVisibility(View.VISIBLE); } @@ -146,18 +171,18 @@ public class MainPanel extends Fragment { } }); } - trueScannerButton = (ImageButton) mMainView.findViewById(R.id.trueScannerButton); + trueScannerButton = (ImageButton) bottomPanel.findViewById(R.id.trueScannerButton); if (!TrueScannerActs.isTrueScannerEnabled()) { trueScannerButton.setVisibility(View.GONE); } - hazeBusterButton = (ImageButton) mMainView.findViewById(R.id.hazeBusterButton); - if(!HazeBusterActs.isHazeBusterEnabled()) { + hazeBusterButton = (ImageButton) bottomPanel.findViewById(R.id.hazeBusterButton); + if (!HazeBusterActs.isHazeBusterEnabled()) { hazeBusterButton.setVisibility(View.GONE); } - seeStraightButton = (ImageButton) mMainView.findViewById(R.id.seeStraightButton); - if(!SeeStraightActs.isSeeStraightEnabled()) { + seeStraightButton = (ImageButton) bottomPanel.findViewById(R.id.seeStraightButton); + if (!SeeStraightActs.isSeeStraightEnabled()) { seeStraightButton.setVisibility(View.GONE); } @@ -192,8 +217,6 @@ public class MainPanel extends Fragment { } }); - updateDualCameraButton(); - trueScannerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -215,10 +238,8 @@ public class MainPanel extends Fragment { } }); - FilterShowActivity activity = (FilterShowActivity) getActivity(); -// showImageStatePanel(activity.isShowingImageStatePanel()); - showPanel(activity.getCurrentPanel()); - return mMainView; + mBottomPanelView = bottomPanel; + return bottomPanel; } private boolean isRightAnimation(int newPos) { @@ -228,6 +249,26 @@ public class MainPanel extends Fragment { return true; } + private void setActionFragment(Fragment actionFragment, String tag) { + FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); + transaction.replace(R.id.bottom_panel_container, actionFragment, tag); + transaction.commitAllowingStateLoss(); + } + + public boolean hasEditorPanel() { + Fragment fragment = getChildFragmentManager().findFragmentByTag(EditorPanel.FRAGMENT_TAG); + return (fragment != null); + } + + public void setEditorPanelFragment(Fragment editorFragment) { + setActionFragment(editorFragment, EditorPanel.FRAGMENT_TAG); + } + + public void removeEditorPanelFragment() { + // use bottom panel replace editor panel. + initBottomPanel(); + } + private void setCategoryFragment(Fragment category, boolean fromRight) { FragmentTransaction transaction = getChildFragmentManager().beginTransaction(); FilterShowActivity activity = (FilterShowActivity) getActivity(); diff --git a/src/com/android/gallery3d/filtershow/category/StraightenPanel.java b/src/com/android/gallery3d/filtershow/category/StraightenPanel.java index c3be2c956..c16bbe394 100644 --- a/src/com/android/gallery3d/filtershow/category/StraightenPanel.java +++ b/src/com/android/gallery3d/filtershow/category/StraightenPanel.java @@ -61,7 +61,7 @@ public class StraightenPanel extends BasicGeometryPanel { public void onClick(View v) { activity.cancelCurrentFilter(); activity.backToMain(); - activity.setActionBar(false); + activity.setActionBar(); } }); mApplyButton.setOnClickListener(new View.OnClickListener() { @@ -69,7 +69,7 @@ public class StraightenPanel extends BasicGeometryPanel { public void onClick(View v) { mEditorStraighten.finalApplyCalled(); activity.backToMain(); - activity.setActionBar(false); + activity.setActionBar(); } }); } diff --git a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java index 10ac65985..53be81ba4 100644 --- a/src/com/android/gallery3d/filtershow/controller/BasicSlider.java +++ b/src/com/android/gallery3d/filtershow/controller/BasicSlider.java @@ -52,8 +52,7 @@ public class BasicSlider implements Control { public void onClick(View v) { FilterShowActivity activity = (FilterShowActivity) context; mEditor.finalApplyCalled(); - activity.backToMain(); - activity.setActionBar(); + activity.leaveSeekBarPanel(); } }); } @@ -64,8 +63,7 @@ public class BasicSlider implements Control { public void onClick(View v) { FilterShowActivity activity = (FilterShowActivity) context; activity.cancelCurrentFilter(); - activity.backToMain(); - activity.setActionBar(); + activity.leaveSeekBarPanel(); } }); } diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java index 6161f1911..80c6cf712 100644 --- a/src/com/android/gallery3d/filtershow/editors/Editor.java +++ b/src/com/android/gallery3d/filtershow/editors/Editor.java @@ -369,6 +369,12 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis } + public void attach() { + if (mImageShow != null) { + mImageShow.attach(); + } + } + public void detach() { if (mImageShow != null) { mImageShow.detach(); diff --git a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java index a127ddf2e..ac9e16a59 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorPanel.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorPanel.java @@ -39,6 +39,7 @@ import com.android.gallery3d.filtershow.state.StatePanel; public class EditorPanel extends Fragment { private static final String LOGTAG = "EditorPanel"; + public static final String FRAGMENT_TAG = "EditorPanel"; private LinearLayout mMainView; private Editor mEditor; @@ -53,7 +54,11 @@ public class EditorPanel extends Fragment { super.onAttach(activity); FilterShowActivity filterShowActivity = (FilterShowActivity) activity; mEditor = filterShowActivity.getEditor(mEditorID); - Log.d(LOGTAG, "EditorPanle.onAttach(): mEditorID is " + mEditorID + ", mEditor is " + mEditor); + if (mEditor != null) { + mEditor.attach(); + } + Log.d(LOGTAG, "EditorPanel.onAttach(): mEditorID is " + mEditorID + + ", mEditor is " + mEditor); } public void cancelCurrentFilter() { |
