diff options
| author | Chao Zhang <chaoz@codeaurora.org> | 2016-04-14 18:04:44 +0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-04-22 02:55:01 -0700 |
| commit | 9c0d475b44b9cb5209a95f3f4539c5803979890d (patch) | |
| tree | 2cef3a213e397adfa6a27ccb58a3a7886820804f | |
| parent | 6c5a2dd884a861e8d279fb7cd50c11b4c7d68004 (diff) | |
| download | android_packages_apps_Gallery2-9c0d475b44b9cb5209a95f3f4539c5803979890d.tar.gz android_packages_apps_Gallery2-9c0d475b44b9cb5209a95f3f4539c5803979890d.tar.bz2 android_packages_apps_Gallery2-9c0d475b44b9cb5209a95f3f4539c5803979890d.zip | |
Gallery2: hide action bar in photo editor if there has bottom panel.
1. hide action bar in photo editor if there has bottom panel.
2. hide SAVE button and Reset menu item if no modifications.
Change-Id: If8e78d95052dbfdc44a5c5edeb464d2fb4e43af5
CRs-Fixed: 988053 988059
7 files changed, 62 insertions, 6 deletions
diff --git a/res/values/colors.xml b/res/values/colors.xml index b6645629a..9fd91923f 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -79,7 +79,7 @@ <color name="toolbar_theme">#e53935</color> <color name="multiselect_background">#ffffff</color> <color name="edit_background">#212121</color> - <color name="edit_actionbar_background">#000000</color> + <color name="edit_actionbar_background">#8A000000</color> <color name="dialog_button_color">#009688</color> <color name="timeline_title_text_color">#26000000</color> <color name="timeline_title_number_text_color">#1a000000</color> diff --git a/res/values/styles.xml b/res/values/styles.xml index f34f829a8..e4b02fc04 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -35,7 +35,6 @@ </style> <style name="Theme.FilterShow" parent="Theme.Gallery"> <item name="android:windowBackground">@null</item> - <item name="android:windowTranslucentStatus">false</item> <item name="android:actionBarStyle">@style/FilterShowActionBar</item> </style> <style name="Theme.Crop" parent="Theme.GalleryBase"> diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 7c2768f8b..102aaaa6d 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -49,7 +49,6 @@ import android.os.IBinder; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.support.v4.print.PrintHelper; import android.util.DisplayMetrics; @@ -98,8 +97,6 @@ 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; import com.android.gallery3d.filtershow.filters.FilterMirrorRepresentation; import com.android.gallery3d.filtershow.filters.FilterRepresentation; import com.android.gallery3d.filtershow.filters.FilterRotateRepresentation; @@ -107,7 +104,6 @@ import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation; import com.android.gallery3d.filtershow.filters.FiltersManager; import com.android.gallery3d.filtershow.filters.ImageFilter; import com.android.gallery3d.filtershow.filters.SimpleMakeupImageFilter; -import com.android.gallery3d.filtershow.filters.TrueScannerActs; import com.android.gallery3d.filtershow.history.HistoryItem; import com.android.gallery3d.filtershow.history.HistoryManager; import com.android.gallery3d.filtershow.imageshow.ImageShow; @@ -331,6 +327,13 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void loadEditorPanel(FilterRepresentation representation, final Editor currentEditor) { + if (currentEditor.showsActionBar()) { + setActionBar(); + showActionBar(true); + } else { + showActionBar(false); + } + if (representation.getEditorId() == ImageOnlyEditor.ID) { currentEditor.reflectCurrentFilter(); return; @@ -465,12 +468,21 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL imgComparison.setVisibility(View.GONE); } + private void showSaveButtonIfNeed() { + if (MasterImage.getImage().hasModifications()) { + mSaveButton.setVisibility(View.VISIBLE); + } else { + mSaveButton.setVisibility(View.GONE); + } + } + public void setActionBar() { setActionBar(false); } public void setActionBar(boolean isEffectClicked) { ActionBar actionBar = getActionBar(); + actionBar.setShowHideAnimationEnabled(false); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setBackgroundDrawable(new ColorDrawable(getResources() .getColor(R.color.edit_actionbar_background))); @@ -487,6 +499,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL saveImage(); } }); + + showSaveButtonIfNeed(); + mExitButton = actionBar.getCustomView().findViewById(R.id.filtershow_exit); mExitButton.setOnClickListener(new OnClickListener() { @Override @@ -550,6 +565,21 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } + private void showActionBar(boolean show) { + ActionBar actionBar = getActionBar(); + if (actionBar != null ) { + if (show) { + if (!actionBar.isShowing()) { + actionBar.show(); + } + } else { + if (actionBar.isShowing()) { + actionBar.hide(); + } + } + } + } + public void cancelCurrentFilter() { MasterImage masterImage = MasterImage.getImage(); HistoryManager adapter = masterImage.getHistory(); @@ -959,6 +989,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL FilterRepresentation filterRepresentation = representation.copy(); MasterImage.getImage().setPreset(copy, filterRepresentation, true); MasterImage.getImage().setCurrentFilterRepresentation(null); + showSaveButtonIfNeed(); return; } } @@ -1384,6 +1415,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL //MenuItem redoItem = mMenu.findItem(R.id.redoButton); MenuItem resetItem = mMenu.findItem(R.id.resetHistoryButton); //mMasterImage.getHistory().setMenuItems(undoItem, redoItem, resetItem); + if (!mMasterImage.hasModifications()) { + mMenu.removeItem(R.id.resetHistoryButton); + } } @Override @@ -1669,6 +1703,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mMasterImage.setPreset(original, rep, true); invalidateViews(); backToMain(); + showSaveButtonIfNeed(); } public void showDefaultImageView() { @@ -1683,6 +1718,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } public void backToMain() { + showActionBar(true); Fragment currentPanel = getSupportFragmentManager().findFragmentByTag(MainPanel.FRAGMENT_TAG); if (currentPanel instanceof MainPanel) { return; diff --git a/src/com/android/gallery3d/filtershow/editors/Editor.java b/src/com/android/gallery3d/filtershow/editors/Editor.java index d4d872a4d..6161f1911 100644 --- a/src/com/android/gallery3d/filtershow/editors/Editor.java +++ b/src/com/android/gallery3d/filtershow/editors/Editor.java @@ -96,6 +96,12 @@ public class Editor implements OnSeekBarChangeListener, SwapButton.SwapButtonLis return true; } + public boolean showsActionBar() { + // ActionBar is not need if has seek bar in default. + // Subclasses should override if need. + return !showsSeekBar(); + } + /*public void setUpEditorUI(View actionButton, View editControl, Button editTitle, Button stateButton) { mEditTitle = editTitle; diff --git a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java index 9312091d5..1f8b448f6 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorCrop.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorCrop.java @@ -156,6 +156,11 @@ public class EditorCrop extends Editor implements EditorInfo { } @Override + public boolean showsActionBar() { + return false; + } + + @Override public int getTextId() { return R.string.crop; } diff --git a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java index d77df71a9..b2c0e9ab0 100644 --- a/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java +++ b/src/com/android/gallery3d/filtershow/editors/EditorStraighten.java @@ -97,6 +97,11 @@ public class EditorStraighten extends Editor implements EditorInfo { } @Override + public boolean showsActionBar() { + return false; + } + + @Override public boolean showsPopupIndicator() { return false; } diff --git a/src/com/android/gallery3d/filtershow/editors/ImageOnlyEditor.java b/src/com/android/gallery3d/filtershow/editors/ImageOnlyEditor.java index d4e66edf8..0858a014c 100644 --- a/src/com/android/gallery3d/filtershow/editors/ImageOnlyEditor.java +++ b/src/com/android/gallery3d/filtershow/editors/ImageOnlyEditor.java @@ -37,6 +37,11 @@ public class ImageOnlyEditor extends Editor { super(id); } + @Override + public boolean showsActionBar() { + return true; + } + public boolean useUtilityPanel() { return false; } |
