diff options
| author | nicolasroard <nicolasroard@google.com> | 2013-08-14 10:04:37 -0700 |
|---|---|---|
| committer | nicolasroard <nicolasroard@google.com> | 2013-08-14 10:04:37 -0700 |
| commit | 0a24e52185c4e88dd52b8e072cf7cd1d04f74b0a (patch) | |
| tree | 752fae3c6a1e9f2ebe31524d1f766c03a4033ac5 | |
| parent | 2e1bc2e37f285bfaf302a0533a372d4373474d9c (diff) | |
| download | android_packages_apps_Gallery2-0a24e52185c4e88dd52b8e072cf7cd1d04f74b0a.tar.gz android_packages_apps_Gallery2-0a24e52185c4e88dd52b8e072cf7cd1d04f74b0a.tar.bz2 android_packages_apps_Gallery2-0a24e52185c4e88dd52b8e072cf7cd1d04f74b0a.zip | |
Clean up user preset dialog
Change-Id: Idefafe3a877e8a0cf25ca955f689818e193fde72
7 files changed, 53 insertions, 31 deletions
diff --git a/res/layout/filtershow_presets_management_dialog.xml b/res/layout/filtershow_presets_management_dialog.xml index f6c6fb764..68754e2ba 100644 --- a/res/layout/filtershow_presets_management_dialog.xml +++ b/res/layout/filtershow_presets_management_dialog.xml @@ -22,14 +22,30 @@ android:divider="?android:dividerVertical" android:showDividers="middle"> - <ListView - android:id="@+id/listItems" - android:orientation="vertical" + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal" + android:layout_margin="8dip"> + + <TextView + android:layout_height="wrap_content" + android:layout_width="wrap_content" + android:text="@string/filtershow_preset_name" + android:layout_margin="8dp" + /> + + <EditText + android:id="@+id/editView" + android:gravity="center" + android:textSize="18sp" + android:layout_weight="1" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="8dip" - android:divider="@android:color/transparent" - android:dividerHeight="8dip"/> + android:focusable="true" + android:imeOptions="actionDone" + android:singleLine="true"/> + </LinearLayout> <LinearLayout android:orientation="horizontal" @@ -46,14 +62,6 @@ style="?android:attr/buttonBarButtonStyle" /> <Button - android:id="@+id/addpreset" - android:layout_width="0dp" - android:layout_height="match_parent" - android:layout_weight="1" - android:text="@string/filtershow_save_preset" - style="?android:attr/buttonBarButtonStyle"/> - - <Button android:id="@+id/ok" android:layout_width="0dp" android:layout_height="match_parent" diff --git a/res/layout/filtershow_presets_management_row.xml b/res/layout/filtershow_presets_management_row.xml index 648e8746b..bd3e47928 100644 --- a/res/layout/filtershow_presets_management_row.xml +++ b/res/layout/filtershow_presets_management_row.xml @@ -47,5 +47,6 @@ android:background="@android:color/transparent" android:layout_weight=".1" android:gravity="center" - android:src="@drawable/ic_menu_trash_holo_light"/> + android:src="@drawable/ic_menu_trash_holo_light" + android:visibility="gone"/> </LinearLayout>
\ No newline at end of file diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml index 4d84007fb..6c8bbc279 100644 --- a/res/values/filtershow_strings.xml +++ b/res/values/filtershow_strings.xml @@ -257,6 +257,8 @@ <string name="filtershow_manage_preset">Manage user presets</string> <!-- Label for newly created user preset [CHAR LIMIT=30] --> <string name="filtershow_new_preset">New Preset</string> + <!-- Label for preset name [CHAR LIMIT=30] --> + <string name="filtershow_preset_name">Preset Name</string> <!-- Label for showing the image information panel [CHAR LIMIT=50] --> <string name="filtershow_show_info_panel">Information</string> diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java index 5cd780f47..f386b1bf7 100644 --- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java +++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java @@ -428,6 +428,14 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL updateVersions(); } + public void removeLook(Action action) { + FilterUserPresetRepresentation rep = (FilterUserPresetRepresentation) action.getRepresentation(); + if (rep == null) { + return; + } + mUserPresetsManager.delete(rep.getId()); + } + private void fillEffects() { FiltersManager filtersManager = FiltersManager.getManager(); ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getEffects(); @@ -1002,7 +1010,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL for (int i = 0; i < presets.size(); i++) { FilterUserPresetRepresentation representation = presets.get(i); mCategoryLooksAdapter.add( - new Action(this, representation, Action.FULL_VIEW)); + new Action(this, representation, Action.FULL_VIEW, true)); mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW)); } if (presets.size() > 0) { @@ -1011,8 +1019,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL mCategoryLooksAdapter.notifyDataSetInvalidated(); } - public void saveCurrentImagePreset() { - mUserPresetsManager.save(MasterImage.getImage().getPreset()); + public void saveCurrentImagePreset(String name) { + mUserPresetsManager.save(MasterImage.getImage().getPreset(), name); } private void deletePreset(int id) { diff --git a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java index 5c273e0e4..54aca54c5 100644 --- a/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java +++ b/src/com/android/gallery3d/filtershow/category/CategoryAdapter.java @@ -159,12 +159,17 @@ public class CategoryAdapter extends ArrayAdapter<Action> { @Override public void remove(Action action) { - if (mCategory != MainPanel.VERSIONS) { + if (!(mCategory == MainPanel.VERSIONS + || mCategory == MainPanel.LOOKS)) { return; } super.remove(action); FilterShowActivity activity = (FilterShowActivity) getContext(); - activity.removeVersion(action); + if (mCategory == MainPanel.LOOKS) { + activity.removeLook(action); + } else if (mCategory == MainPanel.VERSIONS) { + activity.removeVersion(action); + } } public void setOrientation(int orientation) { diff --git a/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java b/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java index 114cd3ebc..f36509dad 100644 --- a/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java +++ b/src/com/android/gallery3d/filtershow/data/UserPresetsManager.java @@ -86,11 +86,11 @@ public class UserPresetsManager implements Handler.Callback { String name; } - public void save(ImagePreset preset) { + public void save(ImagePreset preset, String name) { Message msg = mProcessingHandler.obtainMessage(SAVE); SaveOperation op = new SaveOperation(); op.json = preset.getJsonString(mActivity.getString(R.string.saved)); - op.name= mActivity.getString(R.string.filtershow_new_preset); + op.name = name; msg.obj = op; mProcessingHandler.sendMessage(msg); } diff --git a/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java b/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java index 7ab61fcc9..63a6165e3 100644 --- a/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java +++ b/src/com/android/gallery3d/filtershow/presets/PresetManagementDialog.java @@ -21,12 +21,15 @@ import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.EditText; +import android.widget.ImageView; import android.widget.ListView; import com.android.gallery3d.R; import com.android.gallery3d.filtershow.FilterShowActivity; public class PresetManagementDialog extends DialogFragment implements View.OnClickListener { private UserPresetsAdapter mAdapter; + private EditText mEditText; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -35,13 +38,10 @@ public class PresetManagementDialog extends DialogFragment implements View.OnCli FilterShowActivity activity = (FilterShowActivity) getActivity(); mAdapter = activity.getUserPresetsAdapter(); - ListView panel = (ListView) view.findViewById(R.id.listItems); - panel.setAdapter(mAdapter); - + mEditText = (EditText) view.findViewById(R.id.editView); view.findViewById(R.id.cancel).setOnClickListener(this); - view.findViewById(R.id.addpreset).setOnClickListener(this); view.findViewById(R.id.ok).setOnClickListener(this); - getDialog().setTitle(getString(R.string.filtershow_manage_preset)); + getDialog().setTitle(getString(R.string.filtershow_save_preset)); return view; } @@ -55,11 +55,9 @@ public class PresetManagementDialog extends DialogFragment implements View.OnCli activity.updateUserPresetsFromAdapter(mAdapter); dismiss(); break; - case R.id.addpreset: - activity.saveCurrentImagePreset(); - dismiss(); - break; case R.id.ok: + String text = String.valueOf(mEditText.getText()); + activity.saveCurrentImagePreset(text); mAdapter.updateCurrent(); activity.updateUserPresetsFromAdapter(mAdapter); dismiss(); |
