Search in sources :

Example 1 with FilterPresetSource

use of com.android.gallery3d.filtershow.data.FilterPresetSource in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method handlePreset.

public void handlePreset(Action action, View view, int i) {
    mChangeable = true;
    mHandledSwipeView = view;
    final Action ac = action;
    mFilterPresetSource = new FilterPresetSource(this);
    switch(i) {
        case R.id.renameButton:
            final View layout = View.inflate(this, R.layout.filtershow_default_edittext, null);
            AlertDialog.Builder renameAlertDialogBuilder = new AlertDialog.Builder(this);
            renameAlertDialogBuilder.setTitle(R.string.rename_before_exit);
            renameAlertDialogBuilder.setView(layout);
            renameAlertDialogBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    EditText mEditText = (EditText) layout.findViewById(R.id.filtershow_default_edit);
                    String name = String.valueOf(mEditText.getText());
                    if ((name.trim().length() == 0) || name.isEmpty()) {
                        Toast.makeText(getApplicationContext(), getString(R.string.filter_name_notification), Toast.LENGTH_SHORT).show();
                    } else if (isDuplicateName(name)) {
                        Toast.makeText(getApplicationContext(), getString(R.string.filter_name_duplicate), Toast.LENGTH_SHORT).show();
                    } else {
                        renamePreset(ac, name);
                    }
                    dialog.dismiss();
                }
            });
            renameAlertDialogBuilder.setNegativeButton(mCancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                }
            });
            renameAlertDialogBuilder.create().show();
            break;
        case R.id.deleteButton:
            String name = action.getName();
            AlertDialog.Builder deleteAlertDialogBuilder = new AlertDialog.Builder(this);
            String textview = "Do you want to delete " + name + "?";
            deleteAlertDialogBuilder.setMessage(textview).setTitle(R.string.delete_before_exit);
            deleteAlertDialogBuilder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    ((SwipableView) mHandledSwipeView).delete();
                    dialog.dismiss();
                }
            });
            deleteAlertDialogBuilder.setNegativeButton(mCancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int id) {
                    dialog.dismiss();
                }
            });
            deleteAlertDialogBuilder.create().show();
            break;
    }
}
Also used : AlertDialog(android.app.AlertDialog) EditText(android.widget.EditText) Action(com.android.gallery3d.filtershow.category.Action) FilterPresetSource(com.android.gallery3d.filtershow.data.FilterPresetSource) DialogInterface(android.content.DialogInterface) CategoryView(com.android.gallery3d.filtershow.category.CategoryView) SwipableView(com.android.gallery3d.filtershow.category.SwipableView) WaterMarkView(com.android.gallery3d.filtershow.category.WaterMarkView) View(android.view.View) AdapterView(android.widget.AdapterView) Point(android.graphics.Point)

Example 2 with FilterPresetSource

use of com.android.gallery3d.filtershow.data.FilterPresetSource in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method onMediaPickerResult.

public void onMediaPickerResult(Uri selImg) {
    mFilterPresetSource = new FilterPresetSource(this);
    int id = nameFilter(mFilterPresetSource, tempFilterArray);
    FilterPresetRepresentation fp = new FilterPresetRepresentation(getString(R.string.filtershow_preset_title) + id, id, id);
    fp.setSerializationName("Custom");
    fp.setUri(selImg);
    ImagePreset preset = new ImagePreset();
    preset.addFilter(fp);
    SaveOption sp = new SaveOption();
    sp._id = id;
    sp.name = "Custom" + id;
    sp.Uri = selImg.toString();
    tempFilterArray.add(sp);
    FiltersManager.getManager().addRepresentation(fp);
    mCategoryLooksAdapter.add(new Action(this, fp, Action.FULL_VIEW, true));
    useFilterRepresentation(fp);
    int pos = mCategoryLooksAdapter.getPositionOfPresentation(fp);
    if (pos != -1)
        backAndSetCustomFilterSelected(pos);
}
Also used : FilterPresetSource(com.android.gallery3d.filtershow.data.FilterPresetSource) Action(com.android.gallery3d.filtershow.category.Action) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) FilterPresetRepresentation(com.android.gallery3d.filtershow.filters.FilterPresetRepresentation) Point(android.graphics.Point) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Example 3 with FilterPresetSource

use of com.android.gallery3d.filtershow.data.FilterPresetSource in project android_packages_apps_Gallery2 by LineageOS.

the class BaseFiltersManager method addFilterPreset.

public void addFilterPreset(Context context) {
    FilterPresetSource fp = new FilterPresetSource(context);
    ArrayList<SaveOption> ret = fp.getAllUserPresets();
    if (ret == null)
        return;
    for (int id = 0; id < ret.size(); id++) {
        FilterPresetRepresentation representation = new FilterPresetRepresentation(ret.get(id).name, ret.get(id)._id, id + 1);
        Uri filteredUri = Uri.parse(ret.get(id).Uri);
        representation.setUri(filteredUri);
        representation.setSerializationName("Custom");
        mFilterPreset.add(representation);
        ImagePreset preset = new ImagePreset();
        preset.addFilter(representation);
        addRepresentation(representation);
    }
}
Also used : FilterPresetSource(com.android.gallery3d.filtershow.data.FilterPresetSource) ImagePreset(com.android.gallery3d.filtershow.pipeline.ImagePreset) Uri(android.net.Uri) SaveOption(com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)

Aggregations

FilterPresetSource (com.android.gallery3d.filtershow.data.FilterPresetSource)3 Point (android.graphics.Point)2 Action (com.android.gallery3d.filtershow.category.Action)2 SaveOption (com.android.gallery3d.filtershow.data.FilterPresetSource.SaveOption)2 ImagePreset (com.android.gallery3d.filtershow.pipeline.ImagePreset)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Uri (android.net.Uri)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 CategoryView (com.android.gallery3d.filtershow.category.CategoryView)1 SwipableView (com.android.gallery3d.filtershow.category.SwipableView)1 WaterMarkView (com.android.gallery3d.filtershow.category.WaterMarkView)1 FilterPresetRepresentation (com.android.gallery3d.filtershow.filters.FilterPresetRepresentation)1