diff --git a/MemeProject/.idea/compiler.xml b/MemeProject/.idea/compiler.xml
index 96cc43e..8acb7a2 100644
--- a/MemeProject/.idea/compiler.xml
+++ b/MemeProject/.idea/compiler.xml
@@ -1,6 +1,7 @@
+
@@ -19,4 +20,5 @@
-
\ No newline at end of file
+
+
diff --git a/MemeProject/.idea/encodings.xml b/MemeProject/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/MemeProject/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/MemeProject/.idea/gradle.xml b/MemeProject/.idea/gradle.xml
index 3ec5955..fe865d3 100644
--- a/MemeProject/.idea/gradle.xml
+++ b/MemeProject/.idea/gradle.xml
@@ -6,7 +6,6 @@
-
-
\ No newline at end of file
+
+
diff --git a/MemeProject/.idea/misc.xml b/MemeProject/.idea/misc.xml
index e930905..3281523 100644
--- a/MemeProject/.idea/misc.xml
+++ b/MemeProject/.idea/misc.xml
@@ -13,10 +13,11 @@
-
+
-
\ No newline at end of file
+
+
diff --git a/MemeProject/.idea/modules.xml b/MemeProject/.idea/modules.xml
index d953495..db189d3 100644
--- a/MemeProject/.idea/modules.xml
+++ b/MemeProject/.idea/modules.xml
@@ -6,4 +6,5 @@
-
\ No newline at end of file
+
+
diff --git a/MemeProject/.idea/vcs.xml b/MemeProject/.idea/vcs.xml
index 6564d52..def6a6a 100644
--- a/MemeProject/.idea/vcs.xml
+++ b/MemeProject/.idea/vcs.xml
@@ -3,4 +3,5 @@
-
\ No newline at end of file
+
+
diff --git a/MemeProject/MemeProject.iml b/MemeProject/MemeProject.iml
index 9a5441c..29deca7 100644
--- a/MemeProject/MemeProject.iml
+++ b/MemeProject/MemeProject.iml
@@ -4,7 +4,6 @@
-
@@ -16,4 +15,5 @@
-
\ No newline at end of file
+
+
diff --git a/MemeProject/app/app.iml b/MemeProject/app/app.iml
index f41a9f7..6edc67a 100644
--- a/MemeProject/app/app.iml
+++ b/MemeProject/app/app.iml
@@ -12,9 +12,8 @@
-
-
+
@@ -90,4 +89,5 @@
-
\ No newline at end of file
+
+
diff --git a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ApplyFilters.java b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ApplyFilters.java
index 3e93a53..cff3e0d 100644
--- a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ApplyFilters.java
+++ b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ApplyFilters.java
@@ -36,10 +36,8 @@ public static Bitmap doInvert(Bitmap src) {
int width = src.getWidth();
// scan through every pixel
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
// get one pixel
pixelColor = src.getPixel(x, y);
// saving alpha channel
@@ -74,8 +72,8 @@ public static Bitmap doGreyscale(Bitmap src) {
int height = src.getHeight();
// scan through every single pixel
- for(int x = 0; x < width; ++x) {
- for(int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ for (int y = 0; y < height; ++y) {
// get one pixel color
pixel = src.getPixel(x, y);
// retrieve color of all channels
@@ -84,7 +82,7 @@ public static Bitmap doGreyscale(Bitmap src) {
G = Color.green(pixel);
B = Color.blue(pixel);
// take conversion up to one single value
- R = G = B = (int)(GS_RED * R + GS_GREEN * G + GS_BLUE * B);
+ R = G = B = (int) (GS_RED * R + GS_GREEN * G + GS_BLUE * B);
// set new pixel color to output bitmap
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
}
@@ -104,8 +102,8 @@ public static Bitmap applyShadingFilter(Bitmap source, int shadingColor) {
int index = 0;
// iteration through pixels
- for(int y = 0; y < height; ++y) {
- for(int x = 0; x < width; ++x) {
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
// get current index in 2D-matrix
index = y * width + x;
// AND
@@ -132,10 +130,10 @@ public static Bitmap applyReflection(Bitmap originalImage) {
// create a Bitmap with the flip matrix applied to it.
// we only want the bottom half of the image
- Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, height/2, width, height/2, matrix, false);
+ Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, height / 2, width, height / 2, matrix, false);
// create a new bitmap with same width but taller to fit reflection
- Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height/2), Bitmap.Config.ARGB_8888);
+ Bitmap bitmapWithReflection = Bitmap.createBitmap(width, (height + height / 2), Bitmap.Config.ARGB_8888);
// create a new Canvas with the bitmap that's big enough for
// the image plus gap plus reflection
@@ -146,7 +144,7 @@ public static Bitmap applyReflection(Bitmap originalImage) {
Paint defaultPaint = new Paint();
canvas.drawRect(0, height, width, height + reflectionGap, defaultPaint);
// draw in the reflection
- canvas.drawBitmap(reflectionImage,0, height + reflectionGap, null);
+ canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
// create a shader that is a linear gradient that covers the reflection
Paint paint = new Paint();
diff --git a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ColorPicker.java b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ColorPicker.java
new file mode 100644
index 0000000..3e55bae
--- /dev/null
+++ b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ColorPicker.java
@@ -0,0 +1,337 @@
+package madelyntav.c4q.nyc.memeproject;
+
+/**
+ * Created by c4q-raynaldie on 6/7/15.
+ */
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ComposeShader;
+import android.graphics.Matrix;
+import android.graphics.Paint;
+import android.graphics.Paint.Join;
+import android.graphics.Paint.Style;
+import android.graphics.Path;
+import android.graphics.PorterDuff;
+import android.graphics.RadialGradient;
+import android.graphics.RectF;
+import android.graphics.Shader.TileMode;
+import android.graphics.SweepGradient;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+
+public class ColorPicker extends View {
+
+ /**
+ * Customizable display parameters (in percents)
+ */
+ private final int paramOuterPadding = 2; // outer padding of the whole color picker view
+ private final int paramInnerPadding = 5; // distance between value slider wheel and inner color wheel
+ private final int paramValueSliderWidth = 10; // width of the value slider
+ private final int paramArrowPointerSize = 4; // size of the arrow pointer; set to 0 to hide the pointer
+
+ private Paint colorWheelPaint;
+ private Paint valueSliderPaint;
+
+ private Paint colorViewPaint;
+
+ private Paint colorPointerPaint;
+ private RectF colorPointerCoords;
+
+ private Paint valuePointerPaint;
+ private Paint valuePointerArrowPaint;
+
+ private RectF outerWheelRect;
+ private RectF innerWheelRect;
+
+ private Path colorViewPath;
+ private Path valueSliderPath;
+ private Path arrowPointerPath;
+
+ private Bitmap colorWheelBitmap;
+
+ private int valueSliderWidth;
+ private int innerPadding;
+ private int outerPadding;
+
+ private int arrowPointerSize;
+ private int outerWheelRadius;
+ private int innerWheelRadius;
+ private int colorWheelRadius;
+
+ private Matrix gradientRotationMatrix;
+
+ /**
+ * Currently selected color
+ */
+ private float[] colorHSV = new float[]{0f, 0f, 1f};
+
+ public ColorPicker(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ public ColorPicker(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public ColorPicker(Context context) {
+ super(context);
+ init();
+ }
+
+ private void init() {
+
+ colorPointerPaint = new Paint();
+ colorPointerPaint.setStyle(Style.STROKE);
+ colorPointerPaint.setStrokeWidth(2f);
+ colorPointerPaint.setARGB(128, 0, 0, 0);
+
+ valuePointerPaint = new Paint();
+ valuePointerPaint.setStyle(Style.STROKE);
+ valuePointerPaint.setStrokeWidth(2f);
+
+ valuePointerArrowPaint = new Paint();
+
+ colorWheelPaint = new Paint();
+ colorWheelPaint.setAntiAlias(true);
+ colorWheelPaint.setDither(true);
+
+ valueSliderPaint = new Paint();
+ valueSliderPaint.setAntiAlias(true);
+ valueSliderPaint.setDither(true);
+
+ colorViewPaint = new Paint();
+ colorViewPaint.setAntiAlias(true);
+
+ colorViewPath = new Path();
+ valueSliderPath = new Path();
+ arrowPointerPath = new Path();
+
+ outerWheelRect = new RectF();
+ innerWheelRect = new RectF();
+
+ colorPointerCoords = new RectF();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int widthSize = MeasureSpec.getSize(widthMeasureSpec);
+ int heightSize = MeasureSpec.getSize(heightMeasureSpec);
+ int size = Math.min(widthSize, heightSize);
+ setMeasuredDimension(size, size);
+ }
+
+ @SuppressLint("DrawAllocation")
+ @Override
+ protected void onDraw(Canvas canvas) {
+
+ int centerX = getWidth() / 2;
+ int centerY = getHeight() / 2;
+
+ // drawing color wheel
+
+ canvas.drawBitmap(colorWheelBitmap, centerX - colorWheelRadius, centerY - colorWheelRadius, null);
+
+ // drawing color view
+
+ colorViewPaint.setColor(Color.HSVToColor(colorHSV));
+ canvas.drawPath(colorViewPath, colorViewPaint);
+
+ // drawing value slider
+
+ float[] hsv = new float[]{colorHSV[0], colorHSV[1], 1f};
+
+ SweepGradient sweepGradient = new SweepGradient(centerX, centerY, new int[]{Color.BLACK, Color.HSVToColor(hsv), Color.WHITE}, null);
+ sweepGradient.setLocalMatrix(gradientRotationMatrix);
+ valueSliderPaint.setShader(sweepGradient);
+
+ canvas.drawPath(valueSliderPath, valueSliderPaint);
+
+ // drawing color wheel pointer
+
+ float hueAngle = (float) Math.toRadians(colorHSV[0]);
+ int colorPointX = (int) (-Math.cos(hueAngle) * colorHSV[1] * colorWheelRadius) + centerX;
+ int colorPointY = (int) (-Math.sin(hueAngle) * colorHSV[1] * colorWheelRadius) + centerY;
+
+ float pointerRadius = 0.075f * colorWheelRadius;
+ int pointerX = (int) (colorPointX - pointerRadius / 2);
+ int pointerY = (int) (colorPointY - pointerRadius / 2);
+
+ colorPointerCoords.set(pointerX, pointerY, pointerX + pointerRadius, pointerY + pointerRadius);
+ canvas.drawOval(colorPointerCoords, colorPointerPaint);
+
+ // drawing value pointer
+
+ valuePointerPaint.setColor(Color.HSVToColor(new float[]{0f, 0f, 1f - colorHSV[2]}));
+
+ double valueAngle = (colorHSV[2] - 0.5f) * Math.PI;
+ float valueAngleX = (float) Math.cos(valueAngle);
+ float valueAngleY = (float) Math.sin(valueAngle);
+
+ canvas.drawLine(valueAngleX * innerWheelRadius + centerX, valueAngleY * innerWheelRadius + centerY, valueAngleX * outerWheelRadius + centerX,
+ valueAngleY * outerWheelRadius + centerY, valuePointerPaint);
+
+ // drawing pointer arrow
+
+ if (arrowPointerSize > 0) {
+ drawPointerArrow(canvas);
+ }
+ }
+
+ private void drawPointerArrow(Canvas canvas) {
+
+ int centerX = getWidth() / 2;
+ int centerY = getHeight() / 2;
+
+ double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
+ double leftAngle = tipAngle + Math.PI / 96;
+ double rightAngle = tipAngle - Math.PI / 96;
+
+ double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
+ double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
+ double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
+ double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
+ double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
+ double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);
+
+ arrowPointerPath.reset();
+ arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
+ arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
+ arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
+ arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
+
+ valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
+ valuePointerArrowPaint.setStyle(Style.FILL);
+ canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
+
+ valuePointerArrowPaint.setStyle(Style.STROKE);
+ valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
+ valuePointerArrowPaint.setColor(Color.BLACK);
+ canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
+ }
+
+ @Override
+ protected void onSizeChanged(int width, int height, int oldw, int oldh) {
+
+ int centerX = width / 2;
+ int centerY = height / 2;
+
+ innerPadding = (int) (paramInnerPadding * width / 100);
+ outerPadding = (int) (paramOuterPadding * width / 100);
+ arrowPointerSize = (int) (paramArrowPointerSize * width / 100);
+ valueSliderWidth = (int) (paramValueSliderWidth * width / 100);
+
+ outerWheelRadius = width / 2 - outerPadding - arrowPointerSize;
+ innerWheelRadius = outerWheelRadius - valueSliderWidth;
+ colorWheelRadius = innerWheelRadius - innerPadding;
+
+ outerWheelRect.set(centerX - outerWheelRadius, centerY - outerWheelRadius, centerX + outerWheelRadius, centerY + outerWheelRadius);
+ innerWheelRect.set(centerX - innerWheelRadius, centerY - innerWheelRadius, centerX + innerWheelRadius, centerY + innerWheelRadius);
+
+ colorWheelBitmap = createColorWheelBitmap(colorWheelRadius * 2, colorWheelRadius * 2);
+
+ gradientRotationMatrix = new Matrix();
+ gradientRotationMatrix.preRotate(270, width / 2, height / 2);
+
+ colorViewPath.arcTo(outerWheelRect, 270, -180);
+ colorViewPath.arcTo(innerWheelRect, 90, 180);
+
+ valueSliderPath.arcTo(outerWheelRect, 270, 180);
+ valueSliderPath.arcTo(innerWheelRect, 90, -180);
+ }
+
+ private Bitmap createColorWheelBitmap(int width, int height) {
+
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+
+ int colorCount = 12;
+ int colorAngleStep = 360 / 12;
+ int colors[] = new int[colorCount + 1];
+ float hsv[] = new float[]{0f, 1f, 1f};
+ for (int i = 0; i < colors.length; i++) {
+ hsv[0] = (i * colorAngleStep + 180) % 360;
+ colors[i] = Color.HSVToColor(hsv);
+ }
+ colors[colorCount] = colors[0];
+
+ SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
+ RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
+ ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);
+
+ colorWheelPaint.setShader(composeShader);
+
+ Canvas canvas = new Canvas(bitmap);
+ canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);
+
+ return bitmap;
+
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ int action = event.getAction();
+ switch (action) {
+ case MotionEvent.ACTION_DOWN:
+ case MotionEvent.ACTION_MOVE:
+
+ int x = (int) event.getX();
+ int y = (int) event.getY();
+ int cx = x - getWidth() / 2;
+ int cy = y - getHeight() / 2;
+ double d = Math.sqrt(cx * cx + cy * cy);
+
+ if (d <= colorWheelRadius) {
+
+ colorHSV[0] = (float) (Math.toDegrees(Math.atan2(cy, cx)) + 180f);
+ colorHSV[1] = Math.max(0f, Math.min(1f, (float) (d / colorWheelRadius)));
+
+ invalidate();
+
+ } else if (x >= getWidth() / 2 && d >= innerWheelRadius) {
+
+ colorHSV[2] = (float) Math.max(0, Math.min(1, Math.atan2(cy, cx) / Math.PI + 0.5f));
+
+ invalidate();
+ }
+
+ return true;
+ }
+ return super.onTouchEvent(event);
+ }
+
+ public void setColor(int color) {
+ Color.colorToHSV(color, colorHSV);
+ }
+
+ public int getColor() {
+ return Color.HSVToColor(colorHSV);
+ }
+
+ @Override
+ protected Parcelable onSaveInstanceState() {
+ Bundle state = new Bundle();
+ state.putFloatArray("color", colorHSV);
+ state.putParcelable("super", super.onSaveInstanceState());
+ return state;
+ }
+
+ @Override
+ protected void onRestoreInstanceState(Parcelable state) {
+ if (state instanceof Bundle) {
+ Bundle bundle = (Bundle) state;
+ colorHSV = bundle.getFloatArray("color");
+ super.onRestoreInstanceState(bundle.getParcelable("super"));
+ } else {
+ super.onRestoreInstanceState(state);
+ }
+ }
+}
\ No newline at end of file
diff --git a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ConvolutionMatrix.java b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ConvolutionMatrix.java
index 612d47b..a88953d 100644
--- a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ConvolutionMatrix.java
+++ b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/ConvolutionMatrix.java
@@ -3,8 +3,7 @@
import android.graphics.Bitmap;
import android.graphics.Color;
-public class ConvolutionMatrix
-{
+public class ConvolutionMatrix {
public static final int SIZE = 3;
public double[][] Matrix;
@@ -24,8 +23,8 @@ public void setAll(double value) {
}
public void applyConfig(double[][] config) {
- for(int x = 0; x < SIZE; ++x) {
- for(int y = 0; y < SIZE; ++y) {
+ for (int x = 0; x < SIZE; ++x) {
+ for (int y = 0; y < SIZE; ++y) {
Matrix[x][y] = config[x][y];
}
}
@@ -40,12 +39,12 @@ public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix)
int sumR, sumG, sumB;
int[][] pixels = new int[SIZE][SIZE];
- for(int y = 0; y < height - 2; ++y) {
- for(int x = 0; x < width - 2; ++x) {
+ for (int y = 0; y < height - 2; ++y) {
+ for (int x = 0; x < width - 2; ++x) {
// get pixel matrix
- for(int i = 0; i < SIZE; ++i) {
- for(int j = 0; j < SIZE; ++j) {
+ for (int i = 0; i < SIZE; ++i) {
+ for (int j = 0; j < SIZE; ++j) {
pixels[i][j] = src.getPixel(x + i, y + j);
}
}
@@ -57,8 +56,8 @@ public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix)
sumR = sumG = sumB = 0;
// get sum of RGB on matrix
- for(int i = 0; i < SIZE; ++i) {
- for(int j = 0; j < SIZE; ++j) {
+ for (int i = 0; i < SIZE; ++i) {
+ for (int j = 0; j < SIZE; ++j) {
sumR += (Color.red(pixels[i][j]) * matrix.Matrix[i][j]);
sumG += (Color.green(pixels[i][j]) * matrix.Matrix[i][j]);
sumB += (Color.blue(pixels[i][j]) * matrix.Matrix[i][j]);
@@ -66,19 +65,28 @@ public static Bitmap computeConvolution3x3(Bitmap src, ConvolutionMatrix matrix)
}
// get final Red
- R = (int)(sumR / matrix.Factor + matrix.Offset);
- if(R < 0) { R = 0; }
- else if(R > 255) { R = 255; }
+ R = (int) (sumR / matrix.Factor + matrix.Offset);
+ if (R < 0) {
+ R = 0;
+ } else if (R > 255) {
+ R = 255;
+ }
// get final Green
- G = (int)(sumG / matrix.Factor + matrix.Offset);
- if(G < 0) { G = 0; }
- else if(G > 255) { G = 255; }
+ G = (int) (sumG / matrix.Factor + matrix.Offset);
+ if (G < 0) {
+ G = 0;
+ } else if (G > 255) {
+ G = 255;
+ }
// get final Blue
- B = (int)(sumB / matrix.Factor + matrix.Offset);
- if(B < 0) { B = 0; }
- else if(B > 255) { B = 255; }
+ B = (int) (sumB / matrix.Factor + matrix.Offset);
+ if (B < 0) {
+ B = 0;
+ } else if (B > 255) {
+ B = 255;
+ }
// apply new pixel
result.setPixel(x + 1, y + 1, Color.argb(A, R, G, B));
diff --git a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/CustomArrayAdapter.java b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/CustomArrayAdapter.java
index ea5d617..1ed841f 100644
--- a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/CustomArrayAdapter.java
+++ b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/CustomArrayAdapter.java
@@ -15,7 +15,7 @@
*/
public class CustomArrayAdapter extends ArrayAdapter {
- List memeNames= null;
+ List memeNames = null;
List memeImages = null;
private static LayoutInflater inflater = null;
@@ -32,13 +32,13 @@ public class CustomArrayAdapter extends ArrayAdapter {
@Override
public View getView(int position, View convertView,
ViewGroup parent) {
- if (convertView==null) {
- convertView=newView(parent);
+ if (convertView == null) {
+ convertView = newView(parent);
}
bindView(position, convertView);
- return(convertView);
+ return (convertView);
}
private View newView(ViewGroup parent) {
@@ -46,11 +46,11 @@ private View newView(ViewGroup parent) {
}
private void bindView(int position, View row) {
- TextView label=(TextView)row.findViewById(R.id.memeName);
+ TextView label = (TextView) row.findViewById(R.id.memeName);
label.setText(memeNames.get(position));
- ImageView icon=(ImageView)row.findViewById(R.id.memeImage);
+ ImageView icon = (ImageView) row.findViewById(R.id.memeImage);
icon.setImageResource(memeImages.get(position));
}
diff --git a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/EditPhoto.java b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/EditPhoto.java
index 5b6d269..e2eece3 100644
--- a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/EditPhoto.java
+++ b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/EditPhoto.java
@@ -1,8 +1,7 @@
package madelyntav.c4q.nyc.memeproject;
-import android.widget.Button;
-import android.content.Context;
import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -21,11 +20,13 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -33,510 +34,446 @@
import java.util.Date;
+public class EditPhoto extends Activity implements View.OnTouchListener, View.OnDragListener {
+
+ private ColorPicker colorPicker;
+ Bitmap b;
+ Bitmap bitmap;
+ private Button Vanilla;
+ private Button demotivational;
+ private EditText editText, editText2, demoTitle, demoText;
+ private ImageView imageView, demoImage;
+ private String TAG = "GallerySaving";
+ RelativeLayout memeLayout;
+ LinearLayout linearLayout2;
+ LinearLayout linearLayout3;
+ Button ten;
+ Button fifteen;
+ Button twenty;
+ Button twentyfive;
+ RelativeLayout root;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_edit_photo);
+
+ colorPicker = (ColorPicker) findViewById(R.id.colorPicker);
+ imageView = (ImageView) findViewById(R.id.mImageView);
+ demoImage = (ImageView) findViewById(R.id.demotivationalImage);
+ root = (RelativeLayout) findViewById(R.id.root);
+ linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+ ten = (Button) findViewById(R.id.ten);
+ fifteen = (Button) findViewById(R.id.fifteen);
+ twenty = (Button) findViewById(R.id.twenty);
+ twentyfive = (Button) findViewById(R.id.twentyfive);
+ Vanilla = (Button) findViewById(R.id.vanilla);
+ editText = (EditText) findViewById(R.id.editText);
+ editText2 = (EditText) findViewById(R.id.editText2);
+
+ Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/impact.ttf");
+ editText.setTypeface(custom_font);
+ editText2.setTypeface(custom_font);
+
+ editText.setOnTouchListener(this);
+ editText2.setOnTouchListener(this);
+
+ //Drag and drop layouts for drag and drop EditText feature
+ LinearLayout textTop = (LinearLayout) findViewById(R.id.textTop);
+ LinearLayout textMid = (LinearLayout) findViewById(R.id.textMid);
+ LinearLayout textBot = (LinearLayout) findViewById(R.id.textBottom);
+
+ textBot.setOnDragListener(this);
+ textMid.setOnDragListener(this);
+ textTop.setOnDragListener(this);
+
+ imageView = (ImageView) findViewById(R.id.mImageView);
+ demoImage = (ImageView) findViewById(R.id.demotivationalImage);
+ memeLayout = (RelativeLayout) findViewById(R.id.meme);
+
+
+ //----------------------------GET IMAGE FROM PREVIOUS INTENT--------------------------//
+
+ //opens pic in this activity
+ if (getIntent().hasExtra("byteArray")) {
+ b = BitmapFactory.decodeByteArray(getIntent().getByteArrayExtra("byteArray"), 0, getIntent().getByteArrayExtra("byteArray").length);
+ imageView = (ImageView) findViewById(R.id.mImageView);
+ Vanilla = (Button) findViewById(R.id.vanilla);
+ editText = (EditText) findViewById(R.id.editText);
+ editText2 = (EditText) findViewById(R.id.editText2);
+ demoTitle = (EditText) findViewById(R.id.demotivationalTitle);
+ demoText = (EditText) findViewById(R.id.demotivationalText);
+ imageView.setImageBitmap(b);
+ demoImage.setImageBitmap(b);
+ }
+ else {
+ //retrieve passed uri
+ Uri uri = getIntent().getExtras().getParcelable("image");
+ //retrieve bitmap uri from intent
+ try {
+ bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
- public class EditPhoto extends Activity implements View.OnTouchListener, View.OnDragListener {
-
-
- Bitmap b;
- Bitmap bitmap;
- private Button Vanilla;
- private Button demotivational;
- private EditText editText, editText2, demoTitle, demoText;
- private ImageView imageView, demoImage;
- private String TAG = "GallerySaving";
- RelativeLayout memeLayout;
- LinearLayout linearLayout2;
- LinearLayout linearLayout3;
- Button ten;
- Button fifteen;
- Button twenty;
- Button twentyfive;
- Button black;
- Button white;
- Button red;
- Button blue;
- RelativeLayout root;
-
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ //create bitmap for use within activity
+ try {
+ bitmap = Bitmap.createBitmap(MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ imageView.setImageBitmap(bitmap);
+ demoImage.setImageBitmap(bitmap);
+ }
+ //-----------------------------SHARE BUTTON ONCLICKLISTENER---------------------------//
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_edit_photo);
+ // Shares image via Email, Text, Bluetooth, etc...
+ Button share = (Button) findViewById(R.id.share);
+ share.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
- imageView = (ImageView) findViewById(R.id.mImageView);
- demoImage = (ImageView) findViewById(R.id.demotivationalImage);
-
- root = (RelativeLayout) findViewById(R.id.root);
- linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- ten = (Button) findViewById(R.id.ten);
- fifteen = (Button) findViewById(R.id.fifteen);
- twenty = (Button) findViewById(R.id.twenty);
- twentyfive = (Button) findViewById(R.id.twentyfive);
- black = (Button) findViewById(R.id.black);
- white = (Button) findViewById(R.id.white);
- red = (Button) findViewById(R.id.red);
- blue = (Button) findViewById(R.id.blue);
+ imageView = (ImageView) findViewById(R.id.mImageView);
Vanilla = (Button) findViewById(R.id.vanilla);
-
-
editText = (EditText) findViewById(R.id.editText);
editText2 = (EditText) findViewById(R.id.editText2);
- Typeface custom_font = Typeface.createFromAsset(getAssets(), "fonts/impact.ttf");
-
- editText.setTypeface(custom_font);
- editText2.setTypeface(custom_font);
-
-
- editText.setOnTouchListener(this);
- editText2.setOnTouchListener(this);
-
-
- //Drag and drop layouts for drag and drop EditText feature
- LinearLayout textTop = (LinearLayout) findViewById(R.id.textTop);
- LinearLayout textMid = (LinearLayout) findViewById(R.id.textMid);
- LinearLayout textBot = (LinearLayout) findViewById(R.id.textBottom);
-
- textBot.setOnDragListener(this);
- textMid.setOnDragListener(this);
- textTop.setOnDragListener(this);
-
- imageView = (ImageView) findViewById(R.id.mImageView);
- demoImage = (ImageView) findViewById(R.id.demotivationalImage);
- memeLayout = (RelativeLayout) findViewById(R.id.meme);
+ editText.setHint("");
+ editText2.setHint("");
-
- //----------------------------GET IMAGE FROM PREVIOUS INTENT--------------------------//
-
- //opens pic in this activity
+ //opens pic in this activity
if (getIntent().hasExtra("byteArray")) {
- b = BitmapFactory.decodeByteArray(getIntent().getByteArrayExtra("byteArray"), 0, getIntent().getByteArrayExtra("byteArray").length);
- imageView = (ImageView) findViewById(R.id.mImageView);
- Vanilla = (Button) findViewById(R.id.vanilla);
- editText = (EditText) findViewById(R.id.editText);
- editText2 = (EditText) findViewById(R.id.editText2);
- demoTitle = (EditText) findViewById(R.id.demotivationalTitle);
- demoText = (EditText) findViewById(R.id.demotivationalText);
- imageView.setImageBitmap(b);
- demoImage.setImageBitmap(b);
-
- } else {
-
- //retrieve passed uri
- Uri uri = getIntent().getExtras().getParcelable("image");
- //retrieve bitmap uri from intent
- try {
- bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
-
- } catch (IOException e) {
- e.printStackTrace();
- }
- //create bitmap for use within activity
- try {
- bitmap = Bitmap.createBitmap(MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri));
- } catch (IOException e) {
- e.printStackTrace();
- }
- imageView.setImageBitmap(bitmap);
- demoImage.setImageBitmap(bitmap);
+ Bundle extras = getIntent().getExtras();
+ byte[] byteArray = extras.getByteArray("byteArray");
+ Bitmap bm = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
+ imageView.setImageBitmap(bm);
}
- //-----------------------------SHARE BUTTON ONCLICKLISTENER---------------------------//
- // Shares image via Email, Text, Bluetooth, etc...
Button share = (Button) findViewById(R.id.share);
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
-
- imageView = (ImageView) findViewById(R.id.mImageView);
- Vanilla = (Button) findViewById(R.id.vanilla);
- editText = (EditText) findViewById(R.id.editText);
- editText2 = (EditText) findViewById(R.id.editText2);
- editText.setHint("");
- editText2.setHint("");
- //opens pic in this activity
- if (getIntent().hasExtra("byteArray")) {
- Bundle extras = getIntent().getExtras();
- byte[] byteArray = extras.getByteArray("byteArray");
- Bitmap bm = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
- imageView.setImageBitmap(bm);
- }
-
- Button share = (Button) findViewById(R.id.share);
- share.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String pathOfBmp = MediaStore.Images.Media.insertImage(getContentResolver(), b, "title", null);
- Uri bmpUri = Uri.parse(pathOfBmp);
- Intent attachIntent = new Intent(Intent.ACTION_SEND);
- attachIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
- attachIntent.setType("image/png");
- startActivity(attachIntent);
- }
- });
-
- b = getBitmapFromView(memeLayout);
-
String pathOfBmp = MediaStore.Images.Media.insertImage(getContentResolver(), b, "title", null);
Uri bmpUri = Uri.parse(pathOfBmp);
-
Intent attachIntent = new Intent(Intent.ACTION_SEND);
attachIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
attachIntent.setType("image/png");
startActivity(attachIntent);
}
});
- }
-
- //----------------------------VANILLA AND DEMOTIVATIONAL METHODS--------------------------//
- //Sets Vanilla meme editing view
- public void vanillaM(View v) {
- linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- editText = (EditText) findViewById(R.id.editText);
- editText2 = (EditText) findViewById(R.id.editText2);
- memeLayout = (RelativeLayout) findViewById(R.id.meme);
- demoImage = (ImageView) findViewById(R.id.demotivationalImage);
- demoTitle = (EditText) findViewById(R.id.demotivationalTitle);
- demoText = (EditText) findViewById(R.id.demotivationalText);
- linearLayout2.setVisibility(View.VISIBLE);
- imageView.setVisibility(View.VISIBLE);
- editText.setVisibility(View.VISIBLE);
- editText2.setVisibility(View.VISIBLE);
- demoImage.setVisibility(View.INVISIBLE);
- demoTitle.setVisibility(View.INVISIBLE);
- demoText.setVisibility(View.INVISIBLE);
- }
-
- //Sets demotivational meme editing view
- public void demotivate(View v) {
-
- editText = (EditText) findViewById(R.id.editText);
- editText2 = (EditText) findViewById(R.id.editText2);
- memeLayout = (RelativeLayout) findViewById(R.id.meme);
- demoImage = (ImageView) findViewById(R.id.demotivationalImage);
- demoTitle = (EditText) findViewById(R.id.demotivationalTitle);
- demoText = (EditText) findViewById(R.id.demotivationalText);
-
-
- memeLayout.setBackgroundColor(Color.BLACK);
- imageView.setVisibility(View.INVISIBLE);
- editText.setVisibility(View.INVISIBLE);
- editText2.setVisibility(View.INVISIBLE);
- demoImage.setVisibility(View.VISIBLE);
- demoTitle.setVisibility(View.VISIBLE);
- demoText.setVisibility(View.VISIBLE);
-
- }
-
- //-------------------------------IMAGE STORE AND SAVE METHODS-----------------------------//
-
- //onClick method for the save button. Calls other methods to create the save image function
- public void storeImage(View v) {
- editText.setHint("");
- editText2.setHint("");
- Bitmap image = getBitmapFromView(memeLayout);
- File pictureFile = createImageFile();
- addImageToFile(image, pictureFile);
-
- }
+ b = getBitmapFromView(memeLayout);
- /**
- * Create a File for saving an image
- * Handles file name, and where to store it
- */
- private File createImageFile() {
- String timeStamp = new SimpleDateFormat("MMddyyyy_HHmmss").format(new Date());
- String imageName = "MEME_" + timeStamp + ".jpg";
+ String pathOfBmp = MediaStore.Images.Media.insertImage(getContentResolver(), b, "title", null);
+ Uri bmpUri = Uri.parse(pathOfBmp);
- File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
- File imageFile = new File(path, imageName);
- Log.d("Path: ", path.getPath());
- return imageFile;
-
- }
-
- private void addImageToFile(Bitmap image, File file) {
- FileOutputStream fos = null;
- //Tries to add the bitmap image to the file
+ Intent attachIntent = new Intent(Intent.ACTION_SEND);
+ attachIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
+ attachIntent.setType("image/png");
+ startActivity(attachIntent);
+ }
+ });
+ }
+
+ //----------------------------VANILLA AND DEMOTIVATIONAL METHODS--------------------------//
+
+ //Sets Vanilla meme editing view
+ public void vanillaM(View v) {
+ linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+ editText = (EditText) findViewById(R.id.editText);
+ editText2 = (EditText) findViewById(R.id.editText2);
+ memeLayout = (RelativeLayout) findViewById(R.id.meme);
+ demoImage = (ImageView) findViewById(R.id.demotivationalImage);
+ demoTitle = (EditText) findViewById(R.id.demotivationalTitle);
+ demoText = (EditText) findViewById(R.id.demotivationalText);
+ linearLayout2.setVisibility(View.VISIBLE);
+ imageView.setVisibility(View.VISIBLE);
+ demoImage.setVisibility(View.INVISIBLE);
+ demoTitle.setVisibility(View.INVISIBLE);
+ demoText.setVisibility(View.INVISIBLE);
+ }
+
+ //Sets demotivational meme editing view
+ public void demotivate(View v) {
+ editText = (EditText) findViewById(R.id.editText);
+ editText2 = (EditText) findViewById(R.id.editText2);
+ memeLayout = (RelativeLayout) findViewById(R.id.meme);
+ demoImage = (ImageView) findViewById(R.id.demotivationalImage);
+ demoTitle = (EditText) findViewById(R.id.demotivationalTitle);
+ demoText = (EditText) findViewById(R.id.demotivationalText);
+ memeLayout.setBackgroundColor(Color.BLACK);
+ imageView.setVisibility(View.INVISIBLE);
+ editText.setVisibility(View.INVISIBLE);
+ editText2.setVisibility(View.INVISIBLE);
+ demoImage.setVisibility(View.VISIBLE);
+ demoTitle.setVisibility(View.VISIBLE);
+ demoText.setVisibility(View.VISIBLE);
+ }
+
+ //-------------------------------IMAGE STORE AND SAVE METHODS-----------------------------//
+
+ //onClick method for the save button. Calls other methods to create the save image function
+ public void storeImage(View v) {
+ editText.setHint("");
+ editText2.setHint("");
+ Bitmap image = getBitmapFromView(memeLayout);
+ File pictureFile = createImageFile();
+ addImageToFile(image, pictureFile);
+ }
+
+ /**
+ * Create a File for saving an image
+ * Handles file name, and where to store it
+ */
+ private File createImageFile() {
+ String timeStamp = new SimpleDateFormat("MMddyyyy_HHmmss").format(new Date());
+ String imageName = "MEME_" + timeStamp + ".jpg";
+
+ File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
+ File imageFile = new File(path, imageName);
+ Log.d("Path: ", path.getPath());
+ return imageFile;
+
+ }
+
+ private void addImageToFile(Bitmap image, File file) {
+ FileOutputStream fos = null;
+ //Tries to add the bitmap image to the file
+ try {
+ fos = new FileOutputStream(file);
+ image.compress(Bitmap.CompressFormat.PNG, 90, fos);
+
+ Toast.makeText(this, "Saved image to camera pictures", Toast.LENGTH_SHORT).show();
+
+ } catch (Exception e) {
+ Log.d(TAG, "trying to compress image did not work" + e.getMessage());
+ } finally {
try {
- fos = new FileOutputStream(file);
- image.compress(Bitmap.CompressFormat.PNG, 90, fos);
-
- Toast.makeText(this, "Saved image to camera pictures", Toast.LENGTH_SHORT).show();
-
- } catch (Exception e) {
- Log.d(TAG, "trying to compress image did not work" + e.getMessage());
- } finally {
- try {
- if (fos != null) {
- fos.close(); //Closes the fileoutput stream
- //Scans the image file that was just created so user can immediately see it in Pictures
- try {
- Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
- Uri uri = Uri.fromFile(file);
- mediaScanIntent.setData(uri);
- sendBroadcast(mediaScanIntent);
- } catch (Exception e) {
- Log.d("scanIntent", "Failed: ");
- }
+ if (fos != null) {
+ fos.close(); //Closes the fileoutput stream
+ //Scans the image file that was just created so user can immediately see it in Pictures
+ try {
+ Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
+ Uri uri = Uri.fromFile(file);
+ mediaScanIntent.setData(uri);
+ sendBroadcast(mediaScanIntent);
+ } catch (Exception e) {
+ Log.d("scanIntent", "Failed: ");
}
- } catch (IOException e) {
- Log.d(TAG, "fos did not close " + e.getMessage());
}
- }
-
- }
-
- //------------------------------CREATE BITMAP FROM VIEW METHOD----------------------------//
-
- //Takes the current view and creates a bitmap representing that view.
- public Bitmap getBitmapFromView(View view) {
- Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(returnedBitmap);
-
- Drawable bgDrawable = view.getBackground();
- if (bgDrawable != null)
- bgDrawable.draw(canvas);
- else
- canvas.drawColor(Color.WHITE);
- view.draw(canvas);
- return returnedBitmap;
- }
-
-
- //---------------------------------DRAGGING EDITTEXT METHODS------------------------------//
-
- // onTouch and onDrag work together to allow for views to be moved around within the layout
- //to children of that layout
- public boolean onTouch(View v, MotionEvent e) {
- if (e.getAction() == MotionEvent.ACTION_DOWN) {//Action_Down means a pressed gesture had started, view has been set in motion
- View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);//Creates an image that the system displays during the drag and drop operation.
- v.startDrag(null, shadowBuilder, v, 0);
- v.isInEditMode();
- v.setVisibility(View.INVISIBLE);
- return true;
- } else {
- return false;
+ } catch (IOException e) {
+ Log.d(TAG, "fos did not close " + e.getMessage());
}
}
+ }
- public boolean onDrag(View v, DragEvent e) {
- if (e.getAction() == DragEvent.ACTION_DROP) {//if the shadow has been released within the view
- View view = (View) e.getLocalState();
- ViewGroup from = (ViewGroup) view.getParent();
+ //------------------------------CREATE BITMAP FROM VIEW METHOD----------------------------//
- LinearLayout to = (LinearLayout) v;
+ //Takes the current view and creates a bitmap representing that view.
+ public Bitmap getBitmapFromView(View view) {
+ Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(returnedBitmap);
- if((to.getResources().getInteger(Integer.valueOf(R.id.editText)) == (from.getResources().getInteger(Integer.valueOf(R.id.editText2))))) {
+ Drawable bgDrawable = view.getBackground();
+ if (bgDrawable != null)
+ bgDrawable.draw(canvas);
+ else
+ canvas.drawColor(Color.WHITE);
+ view.draw(canvas);
+ return returnedBitmap;
+ }
+ //---------------------------------DRAGGING EDITTEXT METHODS------------------------------//
- }
- from.removeView(view);
- to.addView(view);
- view.setVisibility(View.VISIBLE);
-
-
- view.requestFocus();
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
-
-
- }
+ // onTouch and onDrag work together to allow for views to be moved around within the layout
+ //to children of that layout
+ public boolean onTouch(View v, MotionEvent e) {
+ if (e.getAction() == MotionEvent.ACTION_DOWN) {//Action_Down means a pressed gesture had started, view has been set in motion
+ View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(v);//Creates an image that the system displays during the drag and drop operation.
+ v.startDrag(null, shadowBuilder, v, 0);
+ v.isInEditMode();
+ v.setVisibility(View.INVISIBLE);
return true;
+ } else {
+ return false;
}
-
-
- //----------------------------VANILLA EDITTEXT FONT SIZE METHODS--------------------------//
-
-
- // Sets Vanilla font size to 10sp
- public void setTen(View v) {
- linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
-
- linearLayout2.setVisibility(View.GONE);
- linearLayout3.setVisibility(View.VISIBLE);
- editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
- editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
+ }
+
+ public boolean onDrag(View v, DragEvent e) {
+ if (e.getAction() == DragEvent.ACTION_DROP) {//if the shadow has been released within the view
+ View view = (View) e.getLocalState();
+ ViewGroup from = (ViewGroup) view.getParent();
+
+ LinearLayout to = (LinearLayout) v;
+
+ if ((to.getResources().getInteger(Integer.valueOf(R.id.editText)) == (from.getResources().getInteger(Integer.valueOf(R.id.editText2))))){}
+ from.removeView(view);
+ to.addView(view);
+ view.setVisibility(View.VISIBLE);
+ view.requestFocus();
+ InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
-
- // Sets Vanilla font size to 15sp
- public void setFifteen(View v) {
- linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout2.setVisibility(View.GONE);
- linearLayout3.setVisibility(View.VISIBLE);
- editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
- editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ return true;
+ }
+
+ //----------------------------VANILLA EDITTEXT FONT SIZE METHODS--------------------------//
+
+ // Sets Vanilla font size to 10dp
+ public void setTen(View v) {
+ linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+
+ linearLayout2.setVisibility(View.GONE);
+ linearLayout3.setVisibility(View.VISIBLE);
+ editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
+ editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
+ }
+
+ // Sets Vanilla font size to 15dp
+ public void setFifteen(View v) {
+ linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+ linearLayout2.setVisibility(View.GONE);
+ linearLayout3.setVisibility(View.VISIBLE);
+ editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
+ }
+
+ // Sets Vanilla font size to 20dp
+ public void setTwenty(View v) {
+ linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+ linearLayout2.setVisibility(View.GONE);
+ linearLayout3.setVisibility(View.VISIBLE);
+ editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ }
+
+ // Sets Vanilla font size to 25dp
+ public void setTwentyfive(View v) {
+ linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+ linearLayout2.setVisibility(View.GONE);
+ linearLayout3.setVisibility(View.VISIBLE);
+ editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);
+ editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);
+ }
+
+ //---------------------------VANILLA EDITTEXT FONT COLOR METHODS--------------------------//
+
+ public void choseColor(View v) {
+ int color = colorPicker.getColor();
+ linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
+ linearLayout3.setVisibility(View.GONE);
+ editText.setVisibility(View.VISIBLE);
+ editText2.setVisibility(View.VISIBLE);
+ editText.setTextColor(color);
+ editText2.setTextColor(color);
+ }
+
+ //----------------------------------IMAGE EFFECTS METHODS---------------------------------//
+
+ // Applies engrave effect to image
+ public void engravedImage(View view) {
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap engraved = ApplyFilters.engrave(b);
+ imageView.setImageBitmap(engraved);
+ demoImage.setImageBitmap(engraved);
+ } else {
+ Bitmap engraved = ApplyFilters.engrave(bitmap);
+ imageView.setImageBitmap(engraved);
+ demoImage.setImageBitmap(engraved);
}
-
- // Sets Vanilla font size to 20sp
- public void setTwenty(View v) {
- linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout2.setVisibility(View.GONE);
- linearLayout3.setVisibility(View.VISIBLE);
- editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
- editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ Toast.makeText(this, "Engraved!", Toast.LENGTH_SHORT).show();
+ }
+
+ // Applies inverted colors effect to image
+ public void invertColors(View view) {
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap inverted = ApplyFilters.doInvert(b);
+ imageView.setImageBitmap(inverted);
+ demoImage.setImageBitmap(inverted);
+ } else {
+ Bitmap inverted = ApplyFilters.doInvert(bitmap);
+ imageView.setImageBitmap(inverted);
+ demoImage.setImageBitmap(inverted);
}
-
- // Sets Vanilla font size to 25sp
- public void setTwentyfive(View v) {
- linearLayout2 = (LinearLayout) findViewById(R.id.linearLayout2);
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout2.setVisibility(View.GONE);
- linearLayout3.setVisibility(View.VISIBLE);
- editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);
- editText2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);
+ Toast.makeText(this, "Inverted!", Toast.LENGTH_SHORT).show();
+
+ }
+
+ // Applies greyscale effect to image
+ public void greyscaleImage(View view) {
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap greyscaled = ApplyFilters.doGreyscale(b);
+ imageView.setImageBitmap(greyscaled);
+ demoImage.setImageBitmap(greyscaled);
+ } else {
+ Bitmap greyscaled = ApplyFilters.doGreyscale(bitmap);
+ imageView.setImageBitmap(greyscaled);
+ demoImage.setImageBitmap(greyscaled);
}
-
- //---------------------------VANILLA EDITTEXT FONT COLOR METHODS--------------------------//
-
- // Sets Vanilla font to black
- public void setBlack(View v) {
-
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout3.setVisibility(View.GONE);
- editText.setVisibility(View.VISIBLE);
- editText2.setVisibility(View.VISIBLE);
- }
-
- // Sets Vanilla font to white
- public void setWhite(View v) {
-
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout3.setVisibility(View.GONE);
- editText.setVisibility(View.VISIBLE);
- editText2.setVisibility(View.VISIBLE);
- editText.setTextColor(Color.WHITE);
- editText2.setTextColor(Color.WHITE);
- }
-
- // Sets Vanilla font to red
- public void setRed(View v) {
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout3.setVisibility(View.GONE);
- editText.setVisibility(View.VISIBLE);
- editText2.setVisibility(View.VISIBLE);
- editText.setTextColor(Color.RED);
- editText2.setTextColor(Color.RED);
- }
-
- // Sets Vanilla font to blue
- public void setBlue(View v) {
-
- linearLayout3 = (LinearLayout) findViewById(R.id.linearLayout3);
- linearLayout3.setVisibility(View.GONE);
- editText.setVisibility(View.VISIBLE);
- editText2.setVisibility(View.VISIBLE);
- editText.setTextColor(Color.BLUE);
- editText2.setTextColor(Color.BLUE);
- }
-
-
- //----------------------------------IMAGE EFFECTS METHODS---------------------------------//
-
- // Applies engrave effect to image
- public void engravedImage(View view) {
- if (getIntent().hasExtra("byteArray")) {
- Bitmap engraved = ApplyFilters.engrave(b);
- imageView.setImageBitmap(engraved);
- demoImage.setImageBitmap(engraved);
- } else {
- Bitmap engraved = ApplyFilters.engrave(bitmap);
- imageView.setImageBitmap(engraved);
- demoImage.setImageBitmap(engraved);
- }
- Toast.makeText(this, "Engraved!", Toast.LENGTH_SHORT).show();
- }
-
- // Applies inverted colors effect to image
- public void invertColors(View view) {
- if (getIntent().hasExtra("byteArray")) {
- Bitmap inverted = ApplyFilters.doInvert(b);
- imageView.setImageBitmap(inverted);
- demoImage.setImageBitmap(inverted);
- } else {
- Bitmap inverted = ApplyFilters.doInvert(bitmap);
- imageView.setImageBitmap(inverted);
- demoImage.setImageBitmap(inverted);
- }
- Toast.makeText(this,"Inverted!",Toast.LENGTH_SHORT).show();
-
+ Toast.makeText(this, "Old School Flow!", Toast.LENGTH_SHORT).show();
+ }
+
+ // Applies blue shading effect to image
+ public void shadingFilterBlue(View view) {
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap blueShade = ApplyFilters.applyShadingFilter(b, Color.BLUE);
+ imageView.setImageBitmap(blueShade);
+ demoImage.setImageBitmap(blueShade);
+ } else {
+ Bitmap blueShade = ApplyFilters.applyShadingFilter(bitmap, Color.BLUE);
+ imageView.setImageBitmap(blueShade);
+ demoImage.setImageBitmap(blueShade);
}
-
- // Applies greyscale effect to image
- public void greyscaleImage(View view) {
- if (getIntent().hasExtra("byteArray")) {
- Bitmap greyscaled = ApplyFilters.doGreyscale(b);
- imageView.setImageBitmap(greyscaled);
- demoImage.setImageBitmap(greyscaled);
- } else {
- Bitmap greyscaled = ApplyFilters.doGreyscale(bitmap);
- imageView.setImageBitmap(greyscaled);
- demoImage.setImageBitmap(greyscaled);
- }
- Toast.makeText(this,"Old School Flow!",Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, "BLUE!", Toast.LENGTH_SHORT).show();
+ }
+
+ // Applies red shading effect to image
+ public void shadingFilterRed(View view) {
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap redShade = ApplyFilters.applyShadingFilter(b, Color.RED);
+ imageView.setImageBitmap(redShade);
+ demoImage.setImageBitmap(redShade);
+ } else {
+ Bitmap redShade = ApplyFilters.applyShadingFilter(bitmap, Color.RED);
+ imageView.setImageBitmap(redShade);
+ demoImage.setImageBitmap(redShade);
}
-
- // Applies blue shading effect to image
- public void shadingFilterBlue(View view) {
- if (getIntent().hasExtra("byteArray")) {
- Bitmap blueShade = ApplyFilters.applyShadingFilter(b, Color.BLUE);
- imageView.setImageBitmap(blueShade);
- demoImage.setImageBitmap(blueShade);
- } else {
- Bitmap blueShade = ApplyFilters.applyShadingFilter(bitmap, Color.BLUE);
- imageView.setImageBitmap(blueShade);
- demoImage.setImageBitmap(blueShade);
- }
- Toast.makeText(this,"BLUE!",Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, "RED!", Toast.LENGTH_SHORT).show();
+ }
+
+ // Applies green shading effect to image
+ public void shadingFilterGreen(View view) {
+
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap greenShade = ApplyFilters.applyShadingFilter(b, Color.GREEN);
+ imageView.setImageBitmap(greenShade);
+ demoImage.setImageBitmap(greenShade);
+ } else {
+ Bitmap greenShade = ApplyFilters.applyShadingFilter(bitmap, Color.GREEN);
+ imageView.setImageBitmap(greenShade);
+ demoImage.setImageBitmap(greenShade);
}
-
- // Applies red shading effect to image
- public void shadingFilterRed(View view) {
- if (getIntent().hasExtra("byteArray")) {
- Bitmap redShade = ApplyFilters.applyShadingFilter(b, Color.RED);
- imageView.setImageBitmap(redShade);
- demoImage.setImageBitmap(redShade);
- } else {
- Bitmap redShade = ApplyFilters.applyShadingFilter(bitmap, Color.RED);
- imageView.setImageBitmap(redShade);
- demoImage.setImageBitmap(redShade);
- }
- Toast.makeText(this,"RED!",Toast.LENGTH_SHORT).show();
- }
-
- // Applies green shading effect to image
- public void shadingFilterGreen(View view) {
-
- if (getIntent().hasExtra("byteArray")) {
- Bitmap greenShade = ApplyFilters.applyShadingFilter(b, Color.GREEN);
- imageView.setImageBitmap(greenShade);
- demoImage.setImageBitmap(greenShade);
- } else {
- Bitmap greenShade = ApplyFilters.applyShadingFilter(bitmap, Color.GREEN);
- imageView.setImageBitmap(greenShade);
- demoImage.setImageBitmap(greenShade);
- }
- Toast.makeText(this,"GREEN FACES ONLY!!",Toast.LENGTH_SHORT).show();
- }
-
- // Applies reflection effect to image
- public void reflectionEffect(View view) {
- if (getIntent().hasExtra("byteArray")) {
- Bitmap reflected = ApplyFilters.applyReflection(b);
- imageView.setImageBitmap(reflected);
- demoImage.setImageBitmap(reflected);
- } else {
- Bitmap reflected = ApplyFilters.applyReflection(bitmap);
- imageView.setImageBitmap(reflected);
- demoImage.setImageBitmap(reflected);
- }
- Toast.makeText(this,"Reflected!",Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, "GREEN FACES ONLY!!", Toast.LENGTH_SHORT).show();
+ }
+
+ // Applies reflection effect to image
+ public void reflectionEffect(View view) {
+ if (getIntent().hasExtra("byteArray")) {
+ Bitmap reflected = ApplyFilters.applyReflection(b);
+ imageView.setImageBitmap(reflected);
+ demoImage.setImageBitmap(reflected);
+ } else {
+ Bitmap reflected = ApplyFilters.applyReflection(bitmap);
+ imageView.setImageBitmap(reflected);
+ demoImage.setImageBitmap(reflected);
}
- }
\ No newline at end of file
+ Toast.makeText(this, "Reflected!", Toast.LENGTH_SHORT).show();
+ }
+}
\ No newline at end of file
diff --git a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/MainActivity.java b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/MainActivity.java
index 6aa7d96..a5ed8b5 100644
--- a/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/MainActivity.java
+++ b/MemeProject/app/src/main/java/madelyntav/c4q/nyc/memeproject/MainActivity.java
@@ -1,10 +1,8 @@
package madelyntav.c4q.nyc.memeproject;
-import android.app.Activity;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
@@ -13,11 +11,9 @@
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
+
import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.io.InputStream;
-
public class MainActivity extends ActionBarActivity {
private ImageView mImageView;
@@ -29,8 +25,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
-// isExternalStorageReadable();
-
mImageView = (ImageView) findViewById(R.id.mImageView);
mImageView.setVisibility(View.INVISIBLE);
}
@@ -50,7 +44,6 @@ public void usePic(View v) {
startActivityForResult(choosePictureIntent, 0);
}
-
public void takePic(View v) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
@@ -58,7 +51,6 @@ public void takePic(View v) {
}
}
-
@Override // saves pic and sends it to editPhoto activity
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@@ -77,7 +69,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//Image selected message
Toast.makeText(this, "Image Selected!", Toast.LENGTH_SHORT).show();
- // get Uri from selected image
+ // get Uri from selected image
Uri targetUri = data.getData();
Bitmap bitmap = null;
ContentResolver cr = getContentResolver();
@@ -94,8 +86,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
intent.putExtra("image", targetUri);
mImageView.setImageBitmap(bitmap);
startActivity(intent);
-
}
}
-
}
\ No newline at end of file
diff --git a/MemeProject/app/src/main/res/layout/activity_edit_photo.xml b/MemeProject/app/src/main/res/layout/activity_edit_photo.xml
index 845204d..53d8856 100644
--- a/MemeProject/app/src/main/res/layout/activity_edit_photo.xml
+++ b/MemeProject/app/src/main/res/layout/activity_edit_photo.xml
@@ -21,8 +21,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
- android:layout_centerHorizontal="true"
- >
+ android:layout_centerHorizontal="true">