Loading res/layout/filtershow_presets_management_dialog.xml 0 → 100644 +66 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?android:dividerVertical" android:showDividers="middle"> <ListView android:id="@+id/listItems" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dip" android:divider="@android:color/transparent" android:dividerHeight="8dip"/> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="48dp" style="?android:attr/buttonBarStyle"> <Button android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="@string/cancel" 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" android:layout_weight="1" android:text="@string/ok" style="?android:attr/buttonBarButtonStyle"/> </LinearLayout> </LinearLayout> No newline at end of file res/layout/filtershow_presets_management_row.xml 0 → 100644 +51 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView" android:layout_weight=".1" android:layout_width="80dip" android:layout_height="80dip" android:scaleType="fitCenter" android:layout_gravity="left|center_vertical"/> <EditText android:id="@+id/editView" android:gravity="center" android:textSize="18sp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="true" android:imeOptions="actionDone" android:singleLine="true"/> <ImageButton android:id="@+id/deleteUserPreset" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="right|center_vertical" android:background="@android:color/transparent" android:layout_weight=".1" android:gravity="center" android:src="@drawable/ic_menu_trash_holo_light"/> </LinearLayout> No newline at end of file res/menu/filtershow_activity_menu.xml +5 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,11 @@ android:showAsAction="never" android:visible="true" android:title="@string/show_imagestate_panel" /> <item android:id="@+id/manageUserPresets" android:showAsAction="never" android:visible="true" android:title="@string/filtershow_manage_preset" /> <item android:id="@+id/exportFlattenButton" android:showAsAction="never" Loading res/values/filtershow_strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -221,4 +221,11 @@ <!-- Label for the notification message [CHAR LIMIT=50] --> <string name="filtershow_notification_message">Processing...</string> <!-- Label for the save preset menu [CHAR LIMIT=30] --> <string name="filtershow_save_preset">Save current preset</string> <!-- Label for the manage preset menu [CHAR LIMIT=30] --> <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> </resources> src/com/android/gallery3d/filtershow/FilterShowActivity.java +78 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; 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.FragmentTransaction; Loading @@ -59,6 +60,9 @@ import com.android.gallery3d.R; import com.android.gallery3d.app.PhotoPage; import com.android.gallery3d.data.LocalAlbum; import com.android.gallery3d.filtershow.editors.EditorGrad; import com.android.gallery3d.filtershow.data.FilterStackSource; import com.android.gallery3d.filtershow.data.UserPresetsManager; import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation; import com.android.gallery3d.filtershow.pipeline.CachingPipeline; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.category.Action; Loading Loading @@ -88,6 +92,8 @@ import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.imageshow.Spline; import com.android.gallery3d.filtershow.pipeline.ImagePreset; import com.android.gallery3d.filtershow.pipeline.ProcessingService; import com.android.gallery3d.filtershow.presets.PresetManagementDialog; import com.android.gallery3d.filtershow.presets.UserPresetsAdapter; import com.android.gallery3d.filtershow.provider.SharedImageProvider; import com.android.gallery3d.filtershow.state.StateAdapter; import com.android.gallery3d.filtershow.tools.SaveImage; Loading Loading @@ -143,6 +149,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private Uri mSelectedImageUri = null; private UserPresetsManager mUserPresetsManager = null; private UserPresetsAdapter mUserPresetsAdapter = null; private CategoryAdapter mCategoryLooksAdapter = null; private CategoryAdapter mCategoryBordersAdapter = null; private CategoryAdapter mCategoryGeometryAdapter = null; Loading Loading @@ -208,6 +216,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private void setupPipeline() { doBindService(); ImageFilter.setActivityForMemoryToasts(this); mUserPresetsManager = new UserPresetsManager(this); mUserPresetsAdapter = new UserPresetsAdapter(this); mCategoryLooksAdapter = new CategoryAdapter(this); } public void updateUIAfterServiceStarted() { Loading Loading @@ -321,6 +332,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void fillCategories() { fillLooks(); loadUserPresets(); fillBorders(); fillTools(); fillEffects(); Loading Loading @@ -439,6 +451,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } public UserPresetsAdapter getUserPresetsAdapter() { return mUserPresetsAdapter; } public CategoryAdapter getCategoryLooksAdapter() { return mCategoryLooksAdapter; } Loading Loading @@ -662,6 +678,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL if (mLoadBitmapTask != null) { mLoadBitmapTask.cancel(false); } mUserPresetsManager.close(); doUnbindService(); super.onDestroy(); } Loading Loading @@ -829,10 +846,70 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL saveImage(); return true; } case R.id.manageUserPresets: { manageUserPresets(); return true; } } return false; } private void manageUserPresets() { DialogFragment dialog = new PresetManagementDialog(); dialog.show(getSupportFragmentManager(), "NoticeDialogFragment"); } public void updateUserPresetsFromAdapter(UserPresetsAdapter adapter) { ArrayList<FilterUserPresetRepresentation> representations = adapter.getDeletedRepresentations(); for (FilterUserPresetRepresentation representation : representations) { deletePreset(representation.getId()); } ArrayList<FilterUserPresetRepresentation> changedRepresentations = adapter.getChangedRepresentations(); for (FilterUserPresetRepresentation representation : changedRepresentations) { updatePreset(representation); } adapter.clearDeletedRepresentations(); adapter.clearChangedRepresentations(); loadUserPresets(); } public void loadUserPresets() { mUserPresetsManager.load(); } public void updateUserPresetsFromManager() { ArrayList<FilterUserPresetRepresentation> presets = mUserPresetsManager.getRepresentations(); if (presets == null) { return; } if (mCategoryLooksAdapter != null) { fillLooks(); } mUserPresetsAdapter.clear(); for (int i = 0; i < presets.size(); i++) { FilterUserPresetRepresentation representation = presets.get(i); mCategoryLooksAdapter.add( new Action(this, representation, Action.FULL_VIEW)); mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW)); } mCategoryLooksAdapter.notifyDataSetInvalidated(); } public void saveCurrentImagePreset() { mUserPresetsManager.save(MasterImage.getImage().getPreset()); } private void deletePreset(int id) { mUserPresetsManager.delete(id); } private void updatePreset(FilterUserPresetRepresentation representation) { mUserPresetsManager.update(representation); } public void enableSave(boolean enable) { if (mSaveButton != null) { mSaveButton.setEnabled(enable); Loading @@ -843,7 +920,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL FiltersManager filtersManager = FiltersManager.getManager(); ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getLooks(); mCategoryLooksAdapter = new CategoryAdapter(this); mCategoryLooksAdapter.clear(); int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height); mCategoryLooksAdapter.setItemHeight(verticalItemHeight); for (FilterRepresentation representation : filtersRepresentations) { Loading Loading
res/layout/filtershow_presets_management_dialog.xml 0 → 100644 +66 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:divider="?android:dividerVertical" android:showDividers="middle"> <ListView android:id="@+id/listItems" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dip" android:divider="@android:color/transparent" android:dividerHeight="8dip"/> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="48dp" style="?android:attr/buttonBarStyle"> <Button android:id="@+id/cancel" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="@string/cancel" 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" android:layout_weight="1" android:text="@string/ok" style="?android:attr/buttonBarButtonStyle"/> </LinearLayout> </LinearLayout> No newline at end of file
res/layout/filtershow_presets_management_row.xml 0 → 100644 +51 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2013 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/imageView" android:layout_weight=".1" android:layout_width="80dip" android:layout_height="80dip" android:scaleType="fitCenter" android:layout_gravity="left|center_vertical"/> <EditText android:id="@+id/editView" android:gravity="center" android:textSize="18sp" android:layout_weight="1" android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="true" android:imeOptions="actionDone" android:singleLine="true"/> <ImageButton android:id="@+id/deleteUserPreset" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="right|center_vertical" android:background="@android:color/transparent" android:layout_weight=".1" android:gravity="center" android:src="@drawable/ic_menu_trash_holo_light"/> </LinearLayout> No newline at end of file
res/menu/filtershow_activity_menu.xml +5 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,11 @@ android:showAsAction="never" android:visible="true" android:title="@string/show_imagestate_panel" /> <item android:id="@+id/manageUserPresets" android:showAsAction="never" android:visible="true" android:title="@string/filtershow_manage_preset" /> <item android:id="@+id/exportFlattenButton" android:showAsAction="never" Loading
res/values/filtershow_strings.xml +7 −0 Original line number Diff line number Diff line Loading @@ -221,4 +221,11 @@ <!-- Label for the notification message [CHAR LIMIT=50] --> <string name="filtershow_notification_message">Processing...</string> <!-- Label for the save preset menu [CHAR LIMIT=30] --> <string name="filtershow_save_preset">Save current preset</string> <!-- Label for the manage preset menu [CHAR LIMIT=30] --> <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> </resources>
src/com/android/gallery3d/filtershow/FilterShowActivity.java +78 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; 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.FragmentTransaction; Loading @@ -59,6 +60,9 @@ import com.android.gallery3d.R; import com.android.gallery3d.app.PhotoPage; import com.android.gallery3d.data.LocalAlbum; import com.android.gallery3d.filtershow.editors.EditorGrad; import com.android.gallery3d.filtershow.data.FilterStackSource; import com.android.gallery3d.filtershow.data.UserPresetsManager; import com.android.gallery3d.filtershow.filters.FilterUserPresetRepresentation; import com.android.gallery3d.filtershow.pipeline.CachingPipeline; import com.android.gallery3d.filtershow.cache.ImageLoader; import com.android.gallery3d.filtershow.category.Action; Loading Loading @@ -88,6 +92,8 @@ import com.android.gallery3d.filtershow.imageshow.MasterImage; import com.android.gallery3d.filtershow.imageshow.Spline; import com.android.gallery3d.filtershow.pipeline.ImagePreset; import com.android.gallery3d.filtershow.pipeline.ProcessingService; import com.android.gallery3d.filtershow.presets.PresetManagementDialog; import com.android.gallery3d.filtershow.presets.UserPresetsAdapter; import com.android.gallery3d.filtershow.provider.SharedImageProvider; import com.android.gallery3d.filtershow.state.StateAdapter; import com.android.gallery3d.filtershow.tools.SaveImage; Loading Loading @@ -143,6 +149,8 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private Uri mSelectedImageUri = null; private UserPresetsManager mUserPresetsManager = null; private UserPresetsAdapter mUserPresetsAdapter = null; private CategoryAdapter mCategoryLooksAdapter = null; private CategoryAdapter mCategoryBordersAdapter = null; private CategoryAdapter mCategoryGeometryAdapter = null; Loading Loading @@ -208,6 +216,9 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL private void setupPipeline() { doBindService(); ImageFilter.setActivityForMemoryToasts(this); mUserPresetsManager = new UserPresetsManager(this); mUserPresetsAdapter = new UserPresetsAdapter(this); mCategoryLooksAdapter = new CategoryAdapter(this); } public void updateUIAfterServiceStarted() { Loading Loading @@ -321,6 +332,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL public void fillCategories() { fillLooks(); loadUserPresets(); fillBorders(); fillTools(); fillEffects(); Loading Loading @@ -439,6 +451,10 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL } } public UserPresetsAdapter getUserPresetsAdapter() { return mUserPresetsAdapter; } public CategoryAdapter getCategoryLooksAdapter() { return mCategoryLooksAdapter; } Loading Loading @@ -662,6 +678,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL if (mLoadBitmapTask != null) { mLoadBitmapTask.cancel(false); } mUserPresetsManager.close(); doUnbindService(); super.onDestroy(); } Loading Loading @@ -829,10 +846,70 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL saveImage(); return true; } case R.id.manageUserPresets: { manageUserPresets(); return true; } } return false; } private void manageUserPresets() { DialogFragment dialog = new PresetManagementDialog(); dialog.show(getSupportFragmentManager(), "NoticeDialogFragment"); } public void updateUserPresetsFromAdapter(UserPresetsAdapter adapter) { ArrayList<FilterUserPresetRepresentation> representations = adapter.getDeletedRepresentations(); for (FilterUserPresetRepresentation representation : representations) { deletePreset(representation.getId()); } ArrayList<FilterUserPresetRepresentation> changedRepresentations = adapter.getChangedRepresentations(); for (FilterUserPresetRepresentation representation : changedRepresentations) { updatePreset(representation); } adapter.clearDeletedRepresentations(); adapter.clearChangedRepresentations(); loadUserPresets(); } public void loadUserPresets() { mUserPresetsManager.load(); } public void updateUserPresetsFromManager() { ArrayList<FilterUserPresetRepresentation> presets = mUserPresetsManager.getRepresentations(); if (presets == null) { return; } if (mCategoryLooksAdapter != null) { fillLooks(); } mUserPresetsAdapter.clear(); for (int i = 0; i < presets.size(); i++) { FilterUserPresetRepresentation representation = presets.get(i); mCategoryLooksAdapter.add( new Action(this, representation, Action.FULL_VIEW)); mUserPresetsAdapter.add(new Action(this, representation, Action.FULL_VIEW)); } mCategoryLooksAdapter.notifyDataSetInvalidated(); } public void saveCurrentImagePreset() { mUserPresetsManager.save(MasterImage.getImage().getPreset()); } private void deletePreset(int id) { mUserPresetsManager.delete(id); } private void updatePreset(FilterUserPresetRepresentation representation) { mUserPresetsManager.update(representation); } public void enableSave(boolean enable) { if (mSaveButton != null) { mSaveButton.setEnabled(enable); Loading @@ -843,7 +920,7 @@ public class FilterShowActivity extends FragmentActivity implements OnItemClickL FiltersManager filtersManager = FiltersManager.getManager(); ArrayList<FilterRepresentation> filtersRepresentations = filtersManager.getLooks(); mCategoryLooksAdapter = new CategoryAdapter(this); mCategoryLooksAdapter.clear(); int verticalItemHeight = (int) getResources().getDimension(R.dimen.action_item_height); mCategoryLooksAdapter.setItemHeight(verticalItemHeight); for (FilterRepresentation representation : filtersRepresentations) { Loading