Search in sources :

Example 1 with SwipableView

use of com.android.gallery3d.filtershow.category.SwipableView 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 SwipableView

use of com.android.gallery3d.filtershow.category.SwipableView in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method dispatchTouchEvent.

public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mHandlingSwipeButton) {
        int direction = CategoryView.HORIZONTAL;
        if (mHandledSwipeView instanceof CategoryView) {
            direction = ((CategoryView) mHandledSwipeView).getOrientation();
        }
        if (ev.getActionMasked() == MotionEvent.ACTION_MOVE) {
            float delta = ev.getY() - mSwipeStartY;
            float distance = mHandledSwipeView.getHeight();
            if (direction == CategoryView.VERTICAL) {
                delta = ev.getX() - mSwipeStartX;
                mHandledSwipeView.setTranslationX(delta);
                distance = mHandledSwipeView.getWidth();
            } else {
                mHandledSwipeView.setTranslationY(delta);
            }
            delta = Math.abs(delta);
            float transparency = Math.min(1, delta / distance);
            mHandledSwipeView.setAlpha(1.f - transparency);
            mHandledSwipeViewLastDelta = delta;
        }
        if (ev.getActionMasked() == MotionEvent.ACTION_CANCEL || ev.getActionMasked() == MotionEvent.ACTION_UP) {
            mHandledSwipeView.setTranslationX(0);
            mHandledSwipeView.setTranslationY(0);
            mHandledSwipeView.setAlpha(1.f);
            mHandlingSwipeButton = false;
            float distance = mHandledSwipeView.getHeight();
            if (direction == CategoryView.VERTICAL) {
                distance = mHandledSwipeView.getWidth();
            }
            if (mHandledSwipeViewLastDelta > distance) {
                ((SwipableView) mHandledSwipeView).delete();
            }
        }
        return true;
    }
    return super.dispatchTouchEvent(ev);
}
Also used : SwipableView(com.android.gallery3d.filtershow.category.SwipableView) CategoryView(com.android.gallery3d.filtershow.category.CategoryView) Point(android.graphics.Point)

Aggregations

Point (android.graphics.Point)2 CategoryView (com.android.gallery3d.filtershow.category.CategoryView)2 SwipableView (com.android.gallery3d.filtershow.category.SwipableView)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 EditText (android.widget.EditText)1 Action (com.android.gallery3d.filtershow.category.Action)1 WaterMarkView (com.android.gallery3d.filtershow.category.WaterMarkView)1 FilterPresetSource (com.android.gallery3d.filtershow.data.FilterPresetSource)1