use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.
the class ImageCrop method forceStateConsistency.
private void forceStateConsistency() {
MasterImage master = MasterImage.getImage();
Bitmap image = master.getFiltersOnlyImage();
FilterShowActivity filterShowActivity = (FilterShowActivity) getContext();
boolean isReload = filterShowActivity.isReloadByConfigurationChanged();
int width = image.getWidth();
int height = image.getHeight();
if (mCropObj == null || (!mUpdateHolder.equals(mGeometry) && !isReload) || mImageBounds.width() != width || mImageBounds.height() != height || !mLocalRep.getCrop().equals(mUpdateHolder.crop)) {
mImageBounds.set(0, 0, width, height);
mGeometry.set(mUpdateHolder);
mLocalRep.setCrop(mUpdateHolder.crop);
RectF scaledCrop = new RectF(mUpdateHolder.crop);
FilterCropRepresentation.findScaledCrop(scaledCrop, width, height);
mCropObj = new CropObject(mImageBounds, scaledCrop, (int) mUpdateHolder.straighten);
mState = Mode.NONE;
clearDisplay();
}
}
use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.
the class ImageCrop method onSizeChanged.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
FilterShowActivity filterShowActivity = (FilterShowActivity) getContext();
if (filterShowActivity.isShowEditCropPanel()) {
updateMatrix(w, h);
} else {
clearDisplay();
}
}
use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.
the class StateView method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean ret = super.onTouchEvent(event);
FilterShowActivity activity = (FilterShowActivity) getContext();
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
activity.startTouchAnimation(this, event.getX(), event.getY());
}
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mStartTouchY = event.getY();
mStartTouchX = event.getX();
if (mType == BEGIN) {
MasterImage.getImage().setShowsOriginal(true);
}
}
if (event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
setTranslationX(0);
setTranslationY(0);
MasterImage.getImage().setShowsOriginal(false);
if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_UP) {
setSelected(true);
FilterRepresentation representation = getState().getFilterRepresentation();
MasterImage image = MasterImage.getImage();
ImagePreset preset = image != null ? image.getCurrentPreset() : null;
if (getTranslationY() == 0 && image != null && preset != null && representation != image.getCurrentFilterRepresentation() && preset.getRepresentation(representation) != null) {
activity.showRepresentation(representation);
setSelected(false);
}
}
}
if (mType != BEGIN && event.getActionMasked() == MotionEvent.ACTION_MOVE) {
float delta = event.getY() - mStartTouchY;
if (Math.abs(delta) > mDeleteSlope) {
activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
}
}
return true;
}
use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.
the class ImageCurves method showPopupMenu.
private void showPopupMenu(LinearLayout accessoryViewList) {
final Button button = (Button) accessoryViewList.findViewById(R.id.applyEffect);
if (button == null) {
return;
}
if (mIdStrLut == null) {
mIdStrLut = new HashMap<Integer, String>();
mIdStrLut.put(R.id.curve_menu_rgb, getContext().getString(R.string.curves_channel_rgb));
mIdStrLut.put(R.id.curve_menu_red, getContext().getString(R.string.curves_channel_red));
mIdStrLut.put(R.id.curve_menu_green, getContext().getString(R.string.curves_channel_green));
mIdStrLut.put(R.id.curve_menu_blue, getContext().getString(R.string.curves_channel_blue));
}
PopupMenu popupMenu = new PopupMenu(getActivity(), button);
popupMenu.getMenuInflater().inflate(R.menu.filtershow_menu_curves, popupMenu.getMenu());
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
setChannel(item.getItemId());
button.setText(mIdStrLut.get(item.getItemId()));
return true;
}
});
Editor.hackFixStrings(popupMenu.getMenu());
popupMenu.show();
((FilterShowActivity) getContext()).onShowMenu(popupMenu);
}
use of com.android.gallery3d.filtershow.FilterShowActivity in project android_packages_apps_Gallery2 by LineageOS.
the class CategoryView method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean ret = super.onTouchEvent(event);
FilterShowActivity activity = (FilterShowActivity) getContext();
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
activity.startTouchAnimation(this, event.getX(), event.getY());
}
if (!canBeRemoved() || checkPreset()) {
return ret;
}
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mStartTouchY = event.getY();
mStartTouchX = event.getX();
}
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
setTranslationX(0);
setTranslationY(0);
}
if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
float delta = event.getY() - mStartTouchY;
if (getOrientation() == CategoryView.VERTICAL) {
delta = event.getX() - mStartTouchX;
}
if (Math.abs(delta) > mDeleteSlope) {
activity.setHandlesSwipeForView(this, mStartTouchX, mStartTouchY);
}
}
return true;
}
Aggregations