diff options
author | wqi <wqi@codeaurora.org> | 2016-04-13 09:57:51 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-04-18 03:28:28 -0700 |
commit | 070553715d59999705e470794fae85d916e6d600 (patch) | |
tree | 0f63289c90f301a4bb68344c3db78b3c565cd672 /src/com/android/gallery3d | |
parent | f4653073a0f154ec447d58a51a6e0ce461b21764 (diff) | |
download | android_packages_apps_Gallery2-070553715d59999705e470794fae85d916e6d600.tar.gz android_packages_apps_Gallery2-070553715d59999705e470794fae85d916e6d600.tar.bz2 android_packages_apps_Gallery2-070553715d59999705e470794fae85d916e6d600.zip |
Gallery2: Modify actionbar in photo editor interface.
Add a exit button and move save button to right in photo editor
interface according to UX specification document.
Change-Id: I2cdbb0b4967822b78f65af6eea2b8571a6e653b9
CRs-Fixed: 988043
Diffstat (limited to 'src/com/android/gallery3d')
3 files changed, 76 insertions, 75 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index bf5deedd5..39dfbd42e 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -55,6 +55,7 @@ import android.support.v4.print.PrintHelper; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -143,7 +144,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private ImageShow mImageShow = null; private View mSaveButton = null; - private View mDoneButton = null, mCancelButton = null; + private View mExitButton = null, mCancelButton = null; private EditorPlaceHolder mEditorPlaceHolder = new EditorPlaceHolder(this); private Editor mCurrentEditor = null; @@ -210,6 +211,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL RelativeLayout rlImageContainer; boolean isOrientationChanged; private boolean isComingFromEditorScreen; + private AlertDialog.Builder mBackAlertDialogBuilder; private ProgressDialog mLoadingDialog; @@ -373,7 +375,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private void loadXML() { setContentView(R.layout.filtershow_activity); Resources r = getResources(); - setActionBar(false); + setActionBar(); mPopUpText = r.getString(R.string.discard).toUpperCase( Locale.getDefault()); mCancel = r.getString(R.string.cancel).toUpperCase(Locale.getDefault()); @@ -428,53 +430,44 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL imgComparison.setVisibility(View.GONE); } + public void setActionBar() { + setActionBar(false); + } + public void setActionBar(boolean isEffectClicked) { ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setBackgroundDrawable(new ColorDrawable(getResources() .getColor(R.color.edit_actionbar_background))); - if (!isEffectClicked) { - actionBar.setCustomView(R.layout.filtershow_actionbar); - mSaveButton = actionBar.getCustomView(); - mSaveButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - saveImage(); - } - }); - invalidateOptionsMenu(); - } else { - if (mMenu != null) { - mMenu.clear(); + ActionBar.LayoutParams lp = new ActionBar.LayoutParams( + ActionBar.LayoutParams.MATCH_PARENT, + ActionBar.LayoutParams.MATCH_PARENT, + Gravity.CENTER); + View customView = getLayoutInflater().inflate(R.layout.filtershow_actionbar, null); + actionBar.setCustomView(customView, lp); + mSaveButton = actionBar.getCustomView().findViewById(R.id.filtershow_done); + mSaveButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + saveImage(); } - actionBar.setCustomView(R.layout.filtershow_actionbar_new); - mCancelButton = actionBar.getCustomView().findViewById( - R.id.imgCancel); - mDoneButton = actionBar.getCustomView().findViewById(R.id.imgDone); - mCancelButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - setActionBar(false); - HistoryManager adapter = mMasterImage.getHistory(); - int position = adapter.undoCurrentFilter(); - mMasterImage.onHistoryItemClick(position); - adapter.resetActiveFilter(); - backToMain(); - invalidateViews(); - } - }); - mDoneButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - // saveImage(); - setActionBar(false); - HistoryManager adapter = mMasterImage - .getHistory(); - adapter.resetActiveFilter(); + }); + mExitButton = actionBar.getCustomView().findViewById(R.id.filtershow_exit); + mExitButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if (mImageShow.hasModifications()) { + if (mBackAlertDialogBuilder == null) { + createBackDialog(); + } + mBackAlertDialogBuilder.show(); + } else { + done(); } - }); - } + } + }); + invalidateOptionsMenu(); } public void setActionBarForEffects(final Editor currentEditor) { @@ -501,7 +494,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void onClick(View v) { cancelCurrentFilter(); FilterShowActivity.this.backToMain(); - setActionBar(false); + setActionBar(); } }); applyButton.setOnClickListener(new View.OnClickListener() { @@ -509,7 +502,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void onClick(View v) { currentEditor.finalApplyCalled(); FilterShowActivity.this.backToMain(); - setActionBar(false); + setActionBar(); } }); @@ -1665,36 +1658,22 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL @Override public void onBackPressed() { - if (imgComparison != null && imgComparison.getVisibility() == View.GONE) { - imgComparison.setVisibility(View.VISIBLE); - } - Fragment currentPanel = getSupportFragmentManager().findFragmentByTag( + if (imgComparison != null && imgComparison.getVisibility() == View.GONE) { + imgComparison.setVisibility(View.VISIBLE); + } + Fragment currentPanel = getSupportFragmentManager().findFragmentByTag( MainPanel.FRAGMENT_TAG); if (currentPanel instanceof MainPanel) { if (mImageShow.hasModifications()) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(R.string.unsaved).setTitle( - R.string.save_before_exit); - builder.setPositiveButton(mPopUpText, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - done(); - } - }); - builder.setNegativeButton(mCancel, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - dialog.dismiss(); - } - }); - builder.show(); + if (mBackAlertDialogBuilder == null) { + createBackDialog(); + } + mBackAlertDialogBuilder.show(); } else { done(); } - setActionBar(false); + setActionBar(); invalidateOptionsMenu(); if (MasterImage.getImage().getScaleFactor() < 1) setScaleImage(false); @@ -1705,6 +1684,26 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } + private void createBackDialog() { + mBackAlertDialogBuilder = new AlertDialog.Builder(this); + mBackAlertDialogBuilder.setMessage(R.string.unsaved).setTitle( + R.string.save_before_exit); + mBackAlertDialogBuilder.setPositiveButton(mPopUpText, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + done(); + } + }); + mBackAlertDialogBuilder.setNegativeButton(mCancel, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + }); + } + public void cannotLoadImage() { Toast.makeText(this, R.string.cannot_load_image, Toast.LENGTH_SHORT).show(); finish(); diff --git a/src/com/android/gallery3d/filtershow/category/MainPanel.java b/src/com/android/gallery3d/filtershow/category/MainPanel.java index 94282e7dd..ef554e615 100644 --- a/src/com/android/gallery3d/filtershow/category/MainPanel.java +++ b/src/com/android/gallery3d/filtershow/category/MainPanel.java @@ -65,7 +65,6 @@ public class MainPanel extends Fragment { private int mCurrentSelected = -1; private int mPreviousToggleVersions = -1; - private boolean isEffectClicked; private void selection(int position, boolean value) { if (value) { @@ -237,12 +236,7 @@ public class MainPanel extends Fragment { } else { transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left); } - if (isEffectClicked) { - activity.setActionBar(true); - isEffectClicked = false; - } else { - activity.setActionBar(false); - } + activity.setActionBar(); transaction.replace(R.id.category_panel_container, category, CategoryPanel.FRAGMENT_TAG); transaction.commitAllowingStateLoss(); } @@ -380,7 +374,6 @@ public class MainPanel extends Fragment { } public void showPanel(int currentPanel) { - isEffectClicked = true; FilterShowActivity activity = (FilterShowActivity) getActivity(); switch (currentPanel) { case LOOKS: { diff --git a/src/com/android/gallery3d/filtershow/crop/CropActivity.java b/src/com/android/gallery3d/filtershow/crop/CropActivity.java index 94c859333..cc8d3e28b 100644 --- a/src/com/android/gallery3d/filtershow/crop/CropActivity.java +++ b/src/com/android/gallery3d/filtershow/crop/CropActivity.java @@ -110,13 +110,22 @@ public class CropActivity extends Activity { actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setCustomView(R.layout.filtershow_actionbar); - View mSaveButton = actionBar.getCustomView(); + View mSaveButton = actionBar.getCustomView().findViewById( + R.id.filtershow_done); mSaveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { startFinishOutput(); } }); + View mExitButton = actionBar.getCustomView().findViewById( + R.id.filtershow_exit); + mExitButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); } if (intent.getData() != null) { mSourceUri = intent.getData(); |