diff --git a/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java b/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java index d19587484..a61deb31f 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java +++ b/app/src/main/java/io/github/gsantner/memetastic/activity/MemeCreateActivity.java @@ -56,9 +56,9 @@ import io.github.gsantner.memetastic.R; import io.github.gsantner.memetastic.data.MemeConfig; import io.github.gsantner.memetastic.data.MemeData; +import io.github.gsantner.memetastic.data.MemeEditorObject; import io.github.gsantner.memetastic.data.MemeLibConfig; -import io.github.gsantner.memetastic.data.MemeSetting; -import io.github.gsantner.memetastic.data.MemeSettingBase; +import io.github.gsantner.memetastic.data.MemeEditorObjectBase; import io.github.gsantner.memetastic.service.AssetUpdater; import io.github.gsantner.memetastic.ui.FontAdapter; import io.github.gsantner.memetastic.util.ActivityUtils; @@ -72,7 +72,7 @@ * Activity for creating memes */ public class MemeCreateActivity extends AppCompatActivity - implements MemeSetting.OnMemeSettingChangedListener { + implements MemeEditorObjectBase.OnMemeEditorObjectChangedListener { //######################## //## Static //######################## @@ -107,7 +107,7 @@ public class MemeCreateActivity extends AppCompatActivity private Bitmap lastBitmap = null; private long memeSavetime = -1; private App app; - private MemeSetting memeSetting; + private MemeEditorObject _memeEditorObject; private boolean bFullscreenImage = true; private Bundle savedInstanceState = null; boolean moarControlsContainerVisible = false; @@ -154,19 +154,19 @@ public void initMemeSettings(Bundle savedInstanceState) { MemeData.Font lastUsedFont = getFont(app.settings.getLastUsedFont()); Bitmap bitmap = extractBitmapFromIntent(getIntent()); if (savedInstanceState != null && savedInstanceState.containsKey("memeObj")) { - memeSetting = (MemeSetting) savedInstanceState.getSerializable("memeObj"); - memeSetting.getImageMain().setImage(bitmap); - memeSetting.getCaptionTop().setFont(lastUsedFont); - memeSetting.getCaptionBottom().setFont(lastUsedFont); + _memeEditorObject = (MemeEditorObject) savedInstanceState.getSerializable("memeObj"); + _memeEditorObject.getImageMain().setImage(bitmap); + _memeEditorObject.getCaptionTop().setFont(lastUsedFont); + _memeEditorObject.getCaptionBottom().setFont(lastUsedFont); } else { - memeSetting = new MemeSetting(lastUsedFont, bitmap); + _memeEditorObject = new MemeEditorObject(lastUsedFont, bitmap); } - memeSetting.getImageMain().setDisplayImage(memeSetting.getImageMain().getImage().copy(Bitmap.Config.RGB_565, false)); + _memeEditorObject.getImageMain().setDisplayImage(_memeEditorObject.getImageMain().getImage().copy(Bitmap.Config.RGB_565, false)); - textEditTopCaption.setText(memeSetting.getCaptionTop().getText()); - textEditBottomCaption.setText(memeSetting.getCaptionBottom().getText()); - memeSetting.setMemeSettingChangedListener(this); - memeSetting.notifyChangedListener(); + textEditTopCaption.setText(_memeEditorObject.getCaptionTop().getText()); + textEditBottomCaption.setText(_memeEditorObject.getCaptionBottom().getText()); + _memeEditorObject.setChangedListener(this); + _memeEditorObject.notifyChangedListener(); } public MemeData.Font getFont(String filepath) { @@ -181,19 +181,19 @@ public MemeData.Font getFont(String filepath) { public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); prepareForSaving(); - outState.putSerializable("memeObj", memeSetting); + outState.putSerializable("memeObj", _memeEditorObject); this.savedInstanceState = outState; } private void prepareForSaving() { - if (memeSetting == null) { + if (_memeEditorObject == null) { return; } - memeSetting.setMemeSettingChangedListener(null); + _memeEditorObject.setChangedListener(null); imageEditView.setImageBitmap(null); if (lastBitmap != null && !lastBitmap.isRecycled()) lastBitmap.recycle(); - MemeSetting.MemeElementImage imageMain = memeSetting.getImageMain(); + MemeEditorObject.MemeElementImage imageMain = _memeEditorObject.getImageMain(); if (imageMain.getImage() != null && !imageMain.getImage().isRecycled()) imageMain.getImage().recycle(); if (imageMain.getDisplayImage() != null && !imageMain.getDisplayImage().isRecycled()) @@ -201,9 +201,9 @@ private void prepareForSaving() { lastBitmap = null; imageMain.setDisplayImage(null); imageMain.setImage(null); - memeSetting.getCaptionTop().setFont(null); - memeSetting.getCaptionBottom().setFont(null); - memeSetting.setMemeSettingChangedListener(null); + _memeEditorObject.getCaptionTop().setFont(null); + _memeEditorObject.getCaptionBottom().setFont(null); + _memeEditorObject.setChangedListener(null); } @Override @@ -421,7 +421,7 @@ public void toggleMoarControls(boolean forceVisibile, boolean visible) { // higher weightRatio means the conf is more wide, so below view can be higher // 100 is the max weight, 55 means the below view is a little more weighted - Bitmap curImg = memeSetting.getImageMain().getDisplayImage(); + Bitmap curImg = _memeEditorObject.getImageMain().getDisplayImage(); int weight = (int) (55f * (1 + ((curImg.getWidth() / (float) curImg.getHeight()) / 10f))); weight = weight > 100 ? 100 : weight; @@ -471,13 +471,13 @@ private void initMoarControlsContainer() { // Apply existing settings - colorPickerText.setSelectedColor(memeSetting.getCaptionTop().getTextColor()); - colorPickerShade.setSelectedColor(memeSetting.getCaptionTop().getBorderColor()); - colorPickerPadding.setSelectedColor(memeSetting.getImageMain().getPaddingColor()); - adapter.setSelectedFont(dropdownFont, memeSetting.getCaptionTop().getFont()); - toggleAllCaps.setChecked(memeSetting.getCaptionTop().isAllCaps()); - seekFontSize.setProgress(memeSetting.getCaptionTop().getFontSize() - MemeLibConfig.FONT_SIZES.MIN); - seekPaddingSize.setProgress(memeSetting.getImageMain().getPadding()); + colorPickerText.setSelectedColor(_memeEditorObject.getCaptionTop().getTextColor()); + colorPickerShade.setSelectedColor(_memeEditorObject.getCaptionTop().getBorderColor()); + colorPickerPadding.setSelectedColor(_memeEditorObject.getImageMain().getPaddingColor()); + adapter.setSelectedFont(dropdownFont, _memeEditorObject.getCaptionTop().getFont()); + toggleAllCaps.setChecked(_memeEditorObject.getCaptionTop().isAllCaps()); + seekFontSize.setProgress(_memeEditorObject.getCaptionTop().getFontSize() - MemeLibConfig.FONT_SIZES.MIN); + seekPaddingSize.setProgress(_memeEditorObject.getImageMain().getPadding()); // @@ -487,14 +487,14 @@ private void initMoarControlsContainer() { public void onClick(View v) { LineColorPicker picker = (LineColorPicker) v; if (picker == colorPickerShade) { - memeSetting.getCaptionTop().setBorderColor(picker.getColor()); - memeSetting.getCaptionBottom().setBorderColor(picker.getColor()); + _memeEditorObject.getCaptionTop().setBorderColor(picker.getColor()); + _memeEditorObject.getCaptionBottom().setBorderColor(picker.getColor()); } else if (picker == colorPickerText) { - memeSetting.getCaptionTop().setTextColor(picker.getColor()); - memeSetting.getCaptionBottom().setTextColor(picker.getColor()); + _memeEditorObject.getCaptionTop().setTextColor(picker.getColor()); + _memeEditorObject.getCaptionBottom().setTextColor(picker.getColor()); } else if (picker == colorPickerPadding) { - memeSetting.getImageMain().setPaddingColor(picker.getColor()); - memeSetting.getImageMain().setPaddingColor(picker.getColor()); + _memeEditorObject.getImageMain().setPaddingColor(picker.getColor()); + _memeEditorObject.getImageMain().setPaddingColor(picker.getColor()); } } }; @@ -507,8 +507,8 @@ public void onNothingSelected(AdapterView parent) { } public void onItemSelected(AdapterView parent, View view, int position, long id) { - memeSetting.getCaptionTop().setFont((MemeData.Font) parent.getSelectedItem()); - memeSetting.getCaptionBottom().setFont((MemeData.Font) parent.getSelectedItem()); + _memeEditorObject.getCaptionTop().setFont((MemeData.Font) parent.getSelectedItem()); + _memeEditorObject.getCaptionBottom().setFont((MemeData.Font) parent.getSelectedItem()); app.settings.setLastUsedFont(((MemeData.Font) parent.getSelectedItem()).fullPath.getAbsolutePath()); } }); @@ -521,10 +521,10 @@ public void onStopTrackingTouch(SeekBar seekBar) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (seekBar == seekFontSize) { - memeSetting.getCaptionTop().setFontSize(progress + MemeLibConfig.FONT_SIZES.MIN); - memeSetting.getCaptionBottom().setFontSize(progress + MemeLibConfig.FONT_SIZES.MIN); + _memeEditorObject.getCaptionTop().setFontSize(progress + MemeLibConfig.FONT_SIZES.MIN); + _memeEditorObject.getCaptionBottom().setFontSize(progress + MemeLibConfig.FONT_SIZES.MIN); } else if (seekBar == seekPaddingSize) { - memeSetting.getImageMain().setPadding(progress); + _memeEditorObject.getImageMain().setPadding(progress); } } }; @@ -533,40 +533,40 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { seekPaddingSize.setOnSeekBarChangeListener(seekBarChangeListener); toggleAllCaps.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - memeSetting.getCaptionTop().setAllCaps(isChecked); - memeSetting.getCaptionBottom().setAllCaps(isChecked); + _memeEditorObject.getCaptionTop().setAllCaps(isChecked); + _memeEditorObject.getCaptionBottom().setAllCaps(isChecked); } }); rotateButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - memeSetting.getImageMain().setRotationDeg((memeSetting.getImageMain().getRotationDeg() + 90) % 360); + _memeEditorObject.getImageMain().setRotationDeg((_memeEditorObject.getImageMain().getRotationDeg() + 90) % 360); } }); } - public Bitmap drawMultilineTextToBitmap(Context c, MemeSetting memeSetting) { + public Bitmap drawMultilineTextToBitmap(Context c, MemeEditorObject memeEditorObject) { // prepare canvas Resources resources = c.getResources(); - Bitmap bitmap = memeSetting.getImageMain().getDisplayImage(); + Bitmap bitmap = memeEditorObject.getImageMain().getDisplayImage(); - if (memeSetting.getImageMain().getRotationDeg() != 0) { + if (memeEditorObject.getImageMain().getRotationDeg() != 0) { Matrix matrix = new Matrix(); - matrix.postRotate(memeSetting.getImageMain().getRotationDeg()); + matrix.postRotate(memeEditorObject.getImageMain().getRotationDeg()); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } - double pad = 1 + memeSetting.getImageMain().getPadding() / 100.0; + double pad = 1 + memeEditorObject.getImageMain().getPadding() / 100.0; if (pad > 1.01) { Bitmap workBmp = Bitmap.createBitmap((int) (bitmap.getWidth() * pad), (int) (bitmap.getHeight() * pad), Bitmap.Config.ARGB_8888); Canvas can = new Canvas(workBmp); //can.drawARGB(0xFF, 0xFF, 0xFF, 0xFF); //This represents White color - can.drawColor(memeSetting.getImageMain().getPaddingColor()); + can.drawColor(memeEditorObject.getImageMain().getPaddingColor()); can.drawBitmap(bitmap, (int) ((workBmp.getWidth() - bitmap.getWidth()) / 2.0), (int) ((workBmp.getHeight() - bitmap.getHeight()) / 2.0), null); bitmap = workBmp; } float scale = ContextUtils.get().getScalingFactorInPixelsForWritingOnPicture(bitmap.getWidth(), bitmap.getHeight()); - float borderScale = scale * memeSetting.getCaptionTop().getFontSize() / MemeLibConfig.FONT_SIZES.DEFAULT; + float borderScale = scale * memeEditorObject.getCaptionTop().getFontSize() / MemeLibConfig.FONT_SIZES.DEFAULT; Bitmap.Config bitmapConfig = bitmap.getConfig(); // set default bitmap config if none if (bitmapConfig == null) { @@ -579,18 +579,18 @@ public Bitmap drawMultilineTextToBitmap(Context c, MemeSetting memeSetting) { // new antialiased Paint TextPaint paint = new TextPaint(Paint.ANTI_ALIAS_FLAG); - paint.setTextSize((int) (memeSetting.getCaptionTop().getFontSize() * scale)); - paint.setTypeface(memeSetting.getCaptionTop().getFont().typeFace); - //paint.setStrokeWidth(memeSetting.getFontSize() / 4); + paint.setTextSize((int) (memeEditorObject.getCaptionTop().getFontSize() * scale)); + paint.setTypeface(memeEditorObject.getCaptionTop().getFont().typeFace); + //paint.setStrokeWidth(_memeEditorObject.getFontSize() / 4); paint.setStrokeWidth(borderScale); - MemeSetting.MemeElementText[] captions = {memeSetting.getCaptionTop(), memeSetting.getCaptionBottom()}; - boolean allCaps = memeSetting.getCaptionTop().isAllCaps(); + MemeEditorObject.MemeElementText[] captions = {memeEditorObject.getCaptionTop(), memeEditorObject.getCaptionBottom()}; + boolean allCaps = memeEditorObject.getCaptionTop().isAllCaps(); for (int i = 0; i < captions.length; i++) { String textString = allCaps ? captions[i].getText().toUpperCase() : captions[i].getText(); - paint.setColor(memeSetting.getCaptionTop().getBorderColor()); + paint.setColor(memeEditorObject.getCaptionTop().getBorderColor()); paint.setStyle(Paint.Style.FILL_AND_STROKE); // set text width to canvas width minus 16dp padding @@ -604,7 +604,7 @@ public Bitmap drawMultilineTextToBitmap(Context c, MemeSetting memeSetting) { int textHeight = textLayout.getHeight(); // get position of text in the canvas, this will depend in its internal location mode - PointF where = captions[i].getPositionInCanvas( + MemeConfig.Point where = captions[i].getPositionInCanvas( bitmap.getWidth(), bitmap.getHeight(), textWidth, textHeight); // draw text to the Canvas center @@ -613,7 +613,7 @@ public Bitmap drawMultilineTextToBitmap(Context c, MemeSetting memeSetting) { textLayout.draw(canvas); // new antialiased Paint - paint.setColor(memeSetting.getCaptionTop().getTextColor()); + paint.setColor(memeEditorObject.getCaptionTop().getTextColor()); paint.setStyle(Paint.Style.FILL); // init StaticLayout for text @@ -633,20 +633,20 @@ public Bitmap drawMultilineTextToBitmap(Context c, MemeSetting memeSetting) { @OnTextChanged(value = R.id.memecreate__activity__edit_caption_bottom, callback = OnTextChanged.Callback.TEXT_CHANGED) public void onCaptionBottomChanged(CharSequence text) { - memeSetting.getCaptionBottom().setText(text.toString()); + _memeEditorObject.getCaptionBottom().setText(text.toString()); } @OnTextChanged(value = R.id.memecreate__activity__edit_caption_top, callback = OnTextChanged.Callback.TEXT_CHANGED) public void onCaptionTopChanged(CharSequence text) { - memeSetting.getCaptionTop().setText(text.toString()); + _memeEditorObject.getCaptionTop().setText(text.toString()); } @Override - public void onMemeSettingChanged(MemeSettingBase memeSetting) { + public void onMemeEditorObjectChanged(MemeEditorObjectBase memeEditorObject) { imageEditView.setImageBitmap(null); if (lastBitmap != null) lastBitmap.recycle(); - Bitmap bmp = drawMultilineTextToBitmap(this, (MemeSetting) memeSetting); + Bitmap bmp = drawMultilineTextToBitmap(this, (MemeEditorObject) memeEditorObject); imageEditView.setImageBitmap(bmp); lastBitmap = bmp; } diff --git a/app/src/main/java/io/github/gsantner/memetastic/data/MemeConfig.java b/app/src/main/java/io/github/gsantner/memetastic/data/MemeConfig.java index a6e2a14f1..1178f028f 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/data/MemeConfig.java +++ b/app/src/main/java/io/github/gsantner/memetastic/data/MemeConfig.java @@ -14,7 +14,7 @@ @SuppressWarnings({"WeakerAccess", "unused", "SameParameterValue", "SpellCheckingInspection", "UnusedReturnValue", "JavaDoc", "FieldCanBeLocal"}) public class MemeConfig implements Serializable { - public static class Config { + public static class Config implements Serializable { private List _fonts; private List _images; @@ -83,7 +83,7 @@ public void setImages(List images) { } } - public static class Image { + public static class Image implements Serializable { public final static String IMAGE_TAG_OTHER = "other"; private List _tags; @@ -170,30 +170,64 @@ public void setImageTexts(List imageTexts) { } } - public static class ImageText { - private int _id; // -1 top, -2 bottom + public static class ImageText implements Serializable { + public static final int TYPE_TOP = 1; + public static final int TYPE_BOTTOM = 2; + public static final int TYPE_CUSTOM = 9; + private String _text; + private int _positionType; + private Point _position; // opt ; + private Point _size; // opt ; x = width, y = height public ImageText fromJson(JSONObject json) throws JSONException { - setId(json.getInt("id")); + setPositionType(json.getInt("id")); setText(json.getString("text")); + if (json.has("position")) { + _position = new Point().fromJson(json.getJSONObject("position")); + } + if (json.has("size")) { + _size = new Point().fromJson(json.getJSONObject("size")); + } return this; } public JSONObject toJson() throws JSONException { JSONObject root = new JSONObject(); - root.put("id", getId()); + root.put("id", getPositionType()); root.put("text", getText()); + if (_position != null) { + root.put("position", _position.toJson()); + } + if (_size != null) { + root.put("size", _size.toJson()); + } return root; } - public int getId() { - return _id; + public Point getPosition() { + return _position; } - public void setId(int id) { - _id = id; + public void setPosition(Point position) { + _position = position; + } + + public Point getSize() { + return _size; + } + + public void setSize(Point size) { + _size = size; + } + + public int getPositionType() { + return _positionType; + } + + public void setPositionType(int positionType) { + _positionType = positionType; } public String getText() { @@ -205,7 +239,7 @@ public void setText(String text) { } } - public static class Font { + public static class Font implements Serializable { public static final int FONT_TYPE__DEFAULT = 0; public static final int FONT_TYPE__COMIC = 1; @@ -257,4 +291,53 @@ public void setFontType(int fontType) { _fontType = fontType; } } + + // For interoperability with PointF use public members + public static class Point implements Serializable { + public float x; + public float y; + + public Point() { + + } + + public Point(float x, float y) { + setX(x); + setY(y); + } + + public Point fromJson(JSONObject json) throws JSONException { + setX((float) json.getDouble("x")); + setY((float) json.getDouble("y")); + return this; + } + + public JSONObject toJson() throws JSONException { + JSONObject root = new JSONObject(); + root.put("x", x); + root.put("y", y); + return root; + } + + public void set(float x, float y) { + setX(x); + setY(y); + } + + public float getX() { + return x; + } + + public void setX(float x) { + this.x = x; + } + + public float getY() { + return y; + } + + public void setY(float y) { + this.y = y; + } + } } diff --git a/app/src/main/java/io/github/gsantner/memetastic/data/MemeSetting.java b/app/src/main/java/io/github/gsantner/memetastic/data/MemeEditorObject.java similarity index 75% rename from app/src/main/java/io/github/gsantner/memetastic/data/MemeSetting.java rename to app/src/main/java/io/github/gsantner/memetastic/data/MemeEditorObject.java index 44b2d1b7d..f6e7f500b 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/data/MemeSetting.java +++ b/app/src/main/java/io/github/gsantner/memetastic/data/MemeEditorObject.java @@ -1,29 +1,32 @@ package io.github.gsantner.memetastic.data; import android.graphics.Bitmap; -import android.graphics.PointF; + +import java.io.Serializable; + +import static io.github.gsantner.memetastic.data.MemeConfig.Point; /** * A memes settings */ @SuppressWarnings({"unused", "WeakerAccess"}) -public class MemeSetting extends MemeSettingBase implements MemeSettingBase.OnMemeSettingChangedListener { +public class MemeEditorObject extends MemeEditorObjectBase implements MemeEditorObjectBase.OnMemeEditorObjectChangedListener, Serializable { private MemeElementText _captionTop; private MemeElementText _captionBottom; private MemeElementImage _imageMain; - public MemeSetting(MemeData.Font font, Bitmap image) { - _captionTop = new MemeElementText(font, MemeLibConfig.LOCATION_MODE.TOP); - _captionBottom = new MemeElementText(font, MemeLibConfig.LOCATION_MODE.BOTTOM); + public MemeEditorObject(MemeData.Font font, Bitmap image) { + _captionTop = new MemeElementText(font, MemeConfig.ImageText.TYPE_TOP); + _captionBottom = new MemeElementText(font, MemeConfig.ImageText.TYPE_BOTTOM); _imageMain = new MemeElementImage(image); - _captionTop.setMemeSettingChangedListener(this); - _captionBottom.setMemeSettingChangedListener(this); - _imageMain.setMemeSettingChangedListener(this); + _captionTop.setChangedListener(this); + _captionBottom.setChangedListener(this); + _imageMain.setChangedListener(this); } @Override - public void onMemeSettingChanged(MemeSettingBase memeSetting) { + public void onMemeEditorObjectChanged(MemeEditorObjectBase memeEditorObject) { notifyChangedListener(); } @@ -59,13 +62,13 @@ public void setImageMain(MemeElementImage imageMain) { notifyChangedListener(); } - public static class MemeElementText extends MemeSettingBase { + public static class MemeElementText extends MemeEditorObjectBase { private String _text = ""; private int _fontSize = MemeLibConfig.FONT_SIZES.DEFAULT; private int _textColor = MemeLibConfig.MEME_COLORS.DEFAULT_TEXT; private int _borderColor = MemeLibConfig.MEME_COLORS.DEFAULT_BORDER; - private int _locationMode = MemeLibConfig.LOCATION_MODE.CUSTOM; - private PointF _location = new PointF(); // (x, y)% for custom location + private int _locationMode = MemeConfig.ImageText.TYPE_CUSTOM; + private Point _location = new Point(); // (x, y)% for custom location private boolean _allCaps = true; private MemeData.Font _font = null; @@ -77,7 +80,7 @@ public MemeElementText(MemeData.Font font, int locationMode) { public MemeElementText(MemeData.Font font, float x, float y) { _font = font; - _locationMode = MemeLibConfig.LOCATION_MODE.CUSTOM; + _locationMode = MemeConfig.ImageText.TYPE_CUSTOM; _location.set(x, y); notifyChangedListener(); } @@ -100,19 +103,19 @@ public void setFontSize(int fontSize) { notifyChangedListener(); } - public PointF getPositionInCanvas(float width, float height, float textWidth, float textHeight) { + public Point getPositionInCanvas(float width, float height, float textWidth, float textHeight) { switch (_locationMode) { - case MemeLibConfig.LOCATION_MODE.CUSTOM: + case MemeConfig.ImageText.TYPE_CUSTOM: default: - return new PointF( - width * _location.x - textWidth * 0.5f, - height * _location.y - textHeight * 0.5f); + return new Point( + width * _location.getX() - textWidth * 0.5f, + height * _location.getY() - textHeight * 0.5f); - case MemeLibConfig.LOCATION_MODE.TOP: - return new PointF((width - textWidth) * 0.5f, height / 15f); + case MemeConfig.ImageText.TYPE_TOP: + return new Point((width - textWidth) * 0.5f, height / 15f); - case MemeLibConfig.LOCATION_MODE.BOTTOM: - return new PointF((width - textWidth) * 0.5f, height - textHeight); + case MemeConfig.ImageText.TYPE_BOTTOM: + return new Point((width - textWidth) * 0.5f, height - textHeight); } } @@ -159,7 +162,7 @@ public String toString() { } - public static class MemeElementImage extends MemeSettingBase { + public static class MemeElementImage extends MemeEditorObjectBase { private Bitmap _image = null; private Bitmap _displayImage = null; private int _rotationDeg = 0; diff --git a/app/src/main/java/io/github/gsantner/memetastic/data/MemeEditorObjectBase.java b/app/src/main/java/io/github/gsantner/memetastic/data/MemeEditorObjectBase.java new file mode 100644 index 000000000..df9362bc3 --- /dev/null +++ b/app/src/main/java/io/github/gsantner/memetastic/data/MemeEditorObjectBase.java @@ -0,0 +1,30 @@ +package io.github.gsantner.memetastic.data; + +import java.io.Serializable; + +/** + * Created by gregor on 05.08.17. + */ +@SuppressWarnings("WeakerAccess") +public class MemeEditorObjectBase implements Serializable { + public interface OnMemeEditorObjectChangedListener { + void onMemeEditorObjectChanged(MemeEditorObjectBase memeEditorObject); + } + + protected OnMemeEditorObjectChangedListener _changedListener; + + public OnMemeEditorObjectChangedListener getChangedListener() { + return _changedListener; + } + + public MemeEditorObjectBase setChangedListener(OnMemeEditorObjectChangedListener _settingChangedListener) { + _changedListener = _settingChangedListener; + return this; + } + + public void notifyChangedListener() { + if (_changedListener != null) { + _changedListener.onMemeEditorObjectChanged(this); + } + } +} diff --git a/app/src/main/java/io/github/gsantner/memetastic/data/MemeLibConfig.java b/app/src/main/java/io/github/gsantner/memetastic/data/MemeLibConfig.java index 8bee4a860..1aed3745c 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/data/MemeLibConfig.java +++ b/app/src/main/java/io/github/gsantner/memetastic/data/MemeLibConfig.java @@ -19,12 +19,6 @@ public static class FONT_SIZES { public static final int MAX = 30; } - public static class LOCATION_MODE { - public static final int CUSTOM = 0; - public static final int TOP = 1; - public static final int BOTTOM = 2; - } - public static class MEME_COLORS { public static final int BLACK = 0xff000000; public static final int WHITE = 0xffFFFFFF; diff --git a/app/src/main/java/io/github/gsantner/memetastic/data/MemeSettingBase.java b/app/src/main/java/io/github/gsantner/memetastic/data/MemeSettingBase.java deleted file mode 100644 index bd3aaf186..000000000 --- a/app/src/main/java/io/github/gsantner/memetastic/data/MemeSettingBase.java +++ /dev/null @@ -1,30 +0,0 @@ -package io.github.gsantner.memetastic.data; - -import java.io.Serializable; - -/** - * Created by gregor on 05.08.17. - */ -@SuppressWarnings("WeakerAccess") -public class MemeSettingBase implements Serializable { - public interface OnMemeSettingChangedListener { - void onMemeSettingChanged(MemeSettingBase memeSetting); - } - - protected MemeSetting.OnMemeSettingChangedListener _memeSettingChangedListener; - - public MemeSetting.OnMemeSettingChangedListener getMemeSettingChangedListener() { - return _memeSettingChangedListener; - } - - public MemeSettingBase setMemeSettingChangedListener(MemeSetting.OnMemeSettingChangedListener _settingChangedListener) { - _memeSettingChangedListener = _settingChangedListener; - return this; - } - - public void notifyChangedListener() { - if (_memeSettingChangedListener != null) { - _memeSettingChangedListener.onMemeSettingChanged(this); - } - } -}