Merge remote-tracking branch 'origin/master' into niels-profile
This commit is contained in:
@@ -4,9 +4,9 @@ import android.app.Activity;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Matrix;
|
|
||||||
import android.hardware.Camera;
|
import android.hardware.Camera;
|
||||||
import android.hardware.Camera.PictureCallback;
|
import android.hardware.Camera.PictureCallback;
|
||||||
|
import android.media.Image;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
@@ -18,6 +18,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
import nl.myhyvesbookplus.tagram.controller.PostUploader;
|
||||||
@@ -46,7 +47,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
|
|
||||||
private Camera mCamera;
|
private Camera mCamera;
|
||||||
private CameraPreview mPreview;
|
private CameraPreview mPreview;
|
||||||
private byte[] mPhotoRaw;
|
|
||||||
private Bitmap mPhoto;
|
private Bitmap mPhoto;
|
||||||
private int facing = Camera.CameraInfo.CAMERA_FACING_BACK;
|
private int facing = Camera.CameraInfo.CAMERA_FACING_BACK;
|
||||||
|
|
||||||
@@ -91,22 +91,16 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
final View view = inflater.inflate(R.layout.fragment_camera, container, false);
|
final View view = inflater.inflate(R.layout.fragment_camera, container, false);
|
||||||
|
|
||||||
mCamera = getCameraInstance(facing);
|
mCamera = getCameraInstance(facing);
|
||||||
Camera.Parameters params = mCamera.getParameters();
|
|
||||||
params.setRotation(0);
|
|
||||||
mCamera.setParameters(params);
|
|
||||||
|
|
||||||
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
||||||
final RelativeLayout pictureButtons = (RelativeLayout) view.findViewById(R.id.picture_taken_buttons);
|
|
||||||
final RelativeLayout filterButtons = (RelativeLayout) view.findViewById(R.id.filter_buttons);
|
final RelativeLayout filterButtons = (RelativeLayout) view.findViewById(R.id.filter_buttons);
|
||||||
final RelativeLayout mCameraLayout = (RelativeLayout) view.findViewById(R.id.camera_preview);
|
final RelativeLayout mCameraLayout = (RelativeLayout) view.findViewById(R.id.camera_preview);
|
||||||
// final RelativeLayout mImageTaken = (RelativeLayout) view.findViewById(R.id.picture_view);
|
|
||||||
|
|
||||||
mCameraLayout.addView(mPreview);
|
mCameraLayout.addView(mPreview);
|
||||||
|
|
||||||
// Draw buttons over preview
|
// Draw buttons over preview
|
||||||
view.findViewById(R.id.picture_button).bringToFront();
|
view.findViewById(R.id.picture_button).bringToFront();
|
||||||
view.findViewById(R.id.switch_camera_button).bringToFront();
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
pictureButtons.bringToFront();
|
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
|
|
||||||
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.switch_camera_button)).setOnClickListener(new View.OnClickListener() {
|
||||||
@@ -131,8 +125,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
mCamera.takePicture(null, null, new PictureCallback() {
|
mCamera.takePicture(null, null, new PictureCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPictureTaken(byte[] data, Camera camera) {
|
public void onPictureTaken(byte[] data, Camera camera) {
|
||||||
// Bitmap bmp = rotate(BitmapFactory.decodeByteArray(data, 0, data.length, null), 90);
|
|
||||||
// mPhoto = bmp;
|
|
||||||
mPhoto = BitmapFactory.decodeByteArray(data, 0, data.length, null);
|
mPhoto = BitmapFactory.decodeByteArray(data, 0, data.length, null);
|
||||||
|
|
||||||
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto);
|
PicturePreview mPicPreview = new PicturePreview(getActivity().getBaseContext(), mPhoto);
|
||||||
@@ -143,7 +135,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
filterButtons.setVisibility(View.VISIBLE);
|
filterButtons.setVisibility(View.VISIBLE);
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
|
|
||||||
// mPicPreview.invalidate();
|
|
||||||
switchButtons(view);
|
switchButtons(view);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -153,7 +144,11 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
(view.findViewById(R.id.upload_button)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.upload_button)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
view.findViewById(R.id.comment_box).setClickable(true);
|
||||||
|
view.findViewById(R.id.comment_box).setVisibility(View.VISIBLE);
|
||||||
view.findViewById(R.id.comment_box).bringToFront();
|
view.findViewById(R.id.comment_box).bringToFront();
|
||||||
|
view.findViewById(R.id.filter_buttons).setVisibility(View.GONE);
|
||||||
|
((FloatingActionButton)view.findViewById(R.id.upload_button)).hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -169,7 +164,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
upload.uploadPicture(new BitmapPost(((PicturePreview)view.findViewById(R.id.pic_preview)).getPicture(), comment));
|
upload.uploadPicture(new BitmapPost(((PicturePreview)view.findViewById(R.id.pic_preview)).getPicture(), comment));
|
||||||
|
|
||||||
mPhoto.recycle();
|
mPhoto.recycle();
|
||||||
mPhoto = null;
|
|
||||||
|
|
||||||
filterButtons.setVisibility(View.GONE);
|
filterButtons.setVisibility(View.GONE);
|
||||||
switchButtons(view);
|
switchButtons(view);
|
||||||
@@ -177,9 +171,6 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
mCameraLayout.removeView(mPreview);
|
mCameraLayout.removeView(mPreview);
|
||||||
|
|
||||||
mCamera = getCameraInstance(facing);
|
mCamera = getCameraInstance(facing);
|
||||||
Camera.Parameters params = mCamera.getParameters();
|
|
||||||
params.setRotation(90);
|
|
||||||
mCamera.setParameters(params);
|
|
||||||
|
|
||||||
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
||||||
mCameraLayout.addView(mPreview);
|
mCameraLayout.addView(mPreview);
|
||||||
@@ -188,7 +179,30 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
view.findViewById(R.id.switch_camera_button).bringToFront();
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
|
|
||||||
mCameraLayout.removeView(view.findViewById(R.id.pic_preview));
|
mCameraLayout.removeView(view.findViewById(R.id.pic_preview));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
(view.findViewById(R.id.comment_cancel)).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
((EditText) view.findViewById(R.id.comment_text)).setText("");
|
||||||
|
|
||||||
|
mPhoto.recycle();
|
||||||
|
|
||||||
|
filterButtons.setVisibility(View.GONE);
|
||||||
|
switchButtons(view);
|
||||||
|
|
||||||
|
mCameraLayout.removeView(mPreview);
|
||||||
|
|
||||||
|
mCamera = getCameraInstance(facing);
|
||||||
|
|
||||||
|
mPreview = new CameraPreview(getActivity().getBaseContext(), mCamera);
|
||||||
|
mCameraLayout.addView(mPreview);
|
||||||
|
|
||||||
|
view.findViewById(R.id.picture_button).bringToFront();
|
||||||
|
view.findViewById(R.id.switch_camera_button).bringToFront();
|
||||||
|
|
||||||
|
mCameraLayout.removeView(view.findViewById(R.id.pic_preview));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -204,7 +218,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
|
|
||||||
mCameraLayout.addView(mPicPreview);
|
mCameraLayout.addView(mPicPreview);
|
||||||
|
|
||||||
view.findViewById(R.id.picture_taken_buttons).bringToFront();
|
view.findViewById(R.id.upload_button).bringToFront();
|
||||||
filterButtons.setVisibility(View.VISIBLE);
|
filterButtons.setVisibility(View.VISIBLE);
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
}
|
}
|
||||||
@@ -222,7 +236,7 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
|
|
||||||
mCameraLayout.addView(mPicPreview);
|
mCameraLayout.addView(mPicPreview);
|
||||||
|
|
||||||
view.findViewById(R.id.picture_taken_buttons).bringToFront();
|
view.findViewById(R.id.upload_button).bringToFront();
|
||||||
filterButtons.setVisibility(View.VISIBLE);
|
filterButtons.setVisibility(View.VISIBLE);
|
||||||
filterButtons.bringToFront();
|
filterButtons.bringToFront();
|
||||||
}
|
}
|
||||||
@@ -273,20 +287,13 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|
||||||
int padding = 16; // 6 dps
|
int padding = 16;
|
||||||
float scale = getResources().getDisplayMetrics().density;
|
float scale = getResources().getDisplayMetrics().density;
|
||||||
int dp = (int) (padding * scale + 0.5f);
|
int dp = (int) (padding * scale + 0.5f);
|
||||||
((AppCompatActivity)getActivity()).getSupportActionBar().show();
|
((AppCompatActivity)getActivity()).getSupportActionBar().show();
|
||||||
getActivity().findViewById(R.id.content).setPadding(dp,dp,dp,dp);
|
getActivity().findViewById(R.id.content).setPadding(dp,dp,dp,dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap rotate(Bitmap bmp, int degree) {
|
|
||||||
Matrix mtx = new Matrix();
|
|
||||||
mtx.setRotate(degree);
|
|
||||||
|
|
||||||
return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mtx, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Camera getCameraInstance(int facing) {
|
public static Camera getCameraInstance(int facing) {
|
||||||
Camera c = null;
|
Camera c = null;
|
||||||
try {
|
try {
|
||||||
@@ -305,23 +312,26 @@ public class CameraFragment extends Fragment implements PostUploader.PostUploadL
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void switchButtons(View view) {
|
public void switchButtons(View view) {
|
||||||
RelativeLayout pictureButtons = (RelativeLayout) view.findViewById(R.id.picture_taken_buttons);
|
|
||||||
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_button);
|
FloatingActionButton upload = (FloatingActionButton) view.findViewById(R.id.upload_button);
|
||||||
// FloatingActionButton save = (FloatingActionButton) view.findViewById(R.id.save_button);
|
ImageButton picButton = (ImageButton) view.findViewById(R.id.picture_button);
|
||||||
|
ImageButton switchButton = (ImageButton) view.findViewById(R.id.switch_camera_button);
|
||||||
|
|
||||||
if (((Integer)upload.getVisibility()).equals(View.VISIBLE)) {
|
if (((Integer)picButton.getVisibility()).equals(View.GONE)) {
|
||||||
|
Log.d(TAG, "switchButtons: GONE");
|
||||||
upload.hide();
|
upload.hide();
|
||||||
// save.hide();
|
|
||||||
|
|
||||||
view.findViewById(R.id.picture_button).setVisibility(View.VISIBLE);
|
picButton.setVisibility(View.VISIBLE);
|
||||||
view.findViewById(R.id.switch_camera_button).setVisibility(View.VISIBLE);
|
switchButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
picButton.bringToFront();
|
||||||
|
switchButton.bringToFront();
|
||||||
} else {
|
} else {
|
||||||
pictureButtons.bringToFront();
|
Log.d(TAG, "switchButtons: VISIBLE");
|
||||||
|
upload.bringToFront();
|
||||||
upload.show();
|
upload.show();
|
||||||
// save.show();
|
|
||||||
|
|
||||||
view.findViewById(R.id.picture_button).setVisibility(View.GONE);
|
picButton.setVisibility(View.GONE);
|
||||||
view.findViewById(R.id.switch_camera_button).setVisibility(View.GONE);
|
switchButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,21 +34,14 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
@Override
|
@Override
|
||||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||||
if (mHolder.getSurface() == null){
|
if (mHolder.getSurface() == null){
|
||||||
// preview surface does not exist
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop preview before making changes
|
|
||||||
try {
|
try {
|
||||||
mCamera.stopPreview();
|
mCamera.stopPreview();
|
||||||
} catch (Exception e){
|
} catch (Exception e){
|
||||||
// ignore: tried to stop a non-existent preview
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set preview size and make any resize, rotate or
|
|
||||||
// reformatting changes here
|
|
||||||
|
|
||||||
// start preview with new settings
|
|
||||||
try {
|
try {
|
||||||
mCamera.setPreviewDisplay(mHolder);
|
mCamera.setPreviewDisplay(mHolder);
|
||||||
mCamera.startPreview();
|
mCamera.startPreview();
|
||||||
@@ -60,6 +53,7 @@ public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
Log.d(TAG, "surfaceDestroyed: CAMERA DESTROYED");
|
||||||
mCamera.stopPreview();
|
mCamera.stopPreview();
|
||||||
mCamera.release();
|
mCamera.release();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package nl.myhyvesbookplus.tagram;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.ColorMatrix;
|
import android.graphics.ColorMatrix;
|
||||||
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.ColorMatrixColorFilter;
|
||||||
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
@@ -16,9 +18,11 @@ import android.view.SurfaceView;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class PicturePreview extends SurfaceView implements SurfaceHolder.Callback {
|
public class PicturePreview extends SurfaceView implements SurfaceHolder.Callback {
|
||||||
|
private static final String TAG = "PicturePreveiew";
|
||||||
private static final int FILTER_NONE = 0;
|
private static final int FILTER_NONE = 0;
|
||||||
private static final int FILTER_SEPIA = 1;
|
private static final int FILTER_SEPIA = 1;
|
||||||
private static final int FILTER_BW = 2;
|
private static final int FILTER_BW = 2;
|
||||||
|
private static final int FILTER_NEG = 3;
|
||||||
|
|
||||||
private static int currentFilter = FILTER_NONE;
|
private static int currentFilter = FILTER_NONE;
|
||||||
|
|
||||||
@@ -27,9 +31,10 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
|
|
||||||
public PicturePreview(Context context, Bitmap bmp) {
|
public PicturePreview(Context context, Bitmap bmp) {
|
||||||
super(context);
|
super(context);
|
||||||
picture = Bitmap.createScaledBitmap(bmp, bmp.getWidth() / 2, bmp.getHeight() / 2, false);
|
|
||||||
// picture = Bitmap.createBitmap(bmp);
|
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
|
|
||||||
|
picture = Bitmap.createScaledBitmap(bmp, bmp.getWidth() / 2, bmp.getHeight() / 2, false);
|
||||||
|
Log.d(TAG, "PicturePreview: " + bmp.getWidth() + " " + bmp.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -38,38 +43,62 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
ColorMatrix cm = new ColorMatrix();
|
ColorMatrix cm = new ColorMatrix();
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
ColorMatrixColorFilter filter;
|
ColorMatrixColorFilter filter;
|
||||||
|
Canvas saveCanvas = new Canvas();
|
||||||
|
|
||||||
switch (currentFilter) {
|
switch (currentFilter) {
|
||||||
case FILTER_NONE:
|
case FILTER_NONE:
|
||||||
canvas.drawBitmap(picture, 0, 0, null);
|
canvas.drawBitmap(rotate(picture, 90), 0, 0, null);
|
||||||
canvas.rotate(90);
|
filterPicture = rotate(picture, 90);
|
||||||
filterPicture = picture;
|
|
||||||
break;
|
break;
|
||||||
case FILTER_SEPIA:
|
case FILTER_SEPIA:
|
||||||
canvas.drawBitmap(toSepia(picture), 0, 0, null);
|
filterPicture = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
canvas.rotate(90);
|
Log.d(TAG, "onDraw: " + Integer.toString(canvas.getWidth()));
|
||||||
filterPicture = toSepia(picture);
|
|
||||||
break;
|
float[] sepia = {0.393f,0.769f,0.189f,0f,0f,
|
||||||
case FILTER_BW:
|
0.349f,0.686f,0.168f,0f,0f,
|
||||||
Canvas bw = new Canvas();
|
0.272f,0.534f,0.131f,0f,0f,
|
||||||
// filterPicture = Bitmap.createBitmap(1920, 1440, null);
|
0f, 0f, 0f, 1f, 0f};
|
||||||
filterPicture = Bitmap.createBitmap(picture.getWidth() / 2, picture.getHeight() / 2, Bitmap.Config.ARGB_8888);
|
cm.set(sepia);
|
||||||
cm.setSaturation(0);
|
|
||||||
filter = new ColorMatrixColorFilter(cm);
|
filter = new ColorMatrixColorFilter(cm);
|
||||||
paint.setColorFilter(filter);
|
paint.setColorFilter(filter);
|
||||||
bw.setBitmap(filterPicture);
|
saveCanvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
|
||||||
bw.drawBitmap(picture, 0, 0, paint);
|
canvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
|
||||||
bw.rotate(90);
|
|
||||||
canvas.drawBitmap(picture, 0, 0, paint);
|
|
||||||
canvas.rotate(90);
|
|
||||||
break;
|
break;
|
||||||
|
case FILTER_BW:
|
||||||
|
filterPicture = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
|
cm.setSaturation(0);
|
||||||
|
|
||||||
|
filter = new ColorMatrixColorFilter(cm);
|
||||||
|
paint.setColorFilter(filter);
|
||||||
|
saveCanvas.setBitmap(filterPicture);
|
||||||
|
saveCanvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
|
||||||
|
canvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
|
||||||
|
break;
|
||||||
|
case FILTER_NEG:
|
||||||
|
filterPicture = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
|
|
||||||
|
float[] neg = {-1f,0f,0f,0f,255f,
|
||||||
|
0f,-1f,0f,0f,255f,
|
||||||
|
0f,0f,-1f,0f,255f,
|
||||||
|
0f,0f,0f,1f,0f};
|
||||||
|
cm.set(neg);
|
||||||
|
|
||||||
|
filter = new ColorMatrixColorFilter(cm);
|
||||||
|
paint.setColorFilter(filter);
|
||||||
|
saveCanvas.setBitmap(filterPicture);
|
||||||
|
saveCanvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
|
||||||
|
canvas.drawBitmap(rotate(picture, 90), 0, 0, paint);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void filterPrev() {
|
public static void filterPrev() {
|
||||||
switch (currentFilter) {
|
switch (currentFilter) {
|
||||||
case FILTER_NONE:
|
case FILTER_NONE:
|
||||||
currentFilter = FILTER_BW;
|
currentFilter = FILTER_NEG;
|
||||||
break;
|
break;
|
||||||
case FILTER_SEPIA:
|
case FILTER_SEPIA:
|
||||||
currentFilter = FILTER_NONE;
|
currentFilter = FILTER_NONE;
|
||||||
@@ -77,6 +106,9 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
case FILTER_BW:
|
case FILTER_BW:
|
||||||
currentFilter = FILTER_SEPIA;
|
currentFilter = FILTER_SEPIA;
|
||||||
break;
|
break;
|
||||||
|
case FILTER_NEG:
|
||||||
|
currentFilter = FILTER_BW;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,44 +121,23 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
currentFilter = FILTER_BW;
|
currentFilter = FILTER_BW;
|
||||||
break;
|
break;
|
||||||
case FILTER_BW:
|
case FILTER_BW:
|
||||||
|
currentFilter = FILTER_NEG;
|
||||||
|
break;
|
||||||
|
case FILTER_NEG:
|
||||||
currentFilter = FILTER_NONE;
|
currentFilter = FILTER_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap toSepia(Bitmap color) {
|
public static Bitmap rotate(Bitmap bmp, int degree) {
|
||||||
int red, green, blue, pixel;
|
Matrix mtx = new Matrix();
|
||||||
int height = color.getHeight();
|
mtx.postRotate(degree);
|
||||||
int width = color.getWidth();
|
|
||||||
int depth = 20;
|
|
||||||
|
|
||||||
Bitmap sepia = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), mtx, true);
|
||||||
|
|
||||||
int[] pixels = new int[width * height];
|
|
||||||
color.getPixels(pixels, 0, width, 0, 0, width, height);
|
|
||||||
for (int i = 0; i < pixels.length; i++) {
|
|
||||||
pixel = pixels[i];
|
|
||||||
|
|
||||||
red = (pixel >> 16) & 0xFF;
|
|
||||||
green = (pixel >> 8) & 0xFF;
|
|
||||||
blue = pixel & 0xFF;
|
|
||||||
|
|
||||||
red = green = blue = (red + green + blue) / 3;
|
|
||||||
|
|
||||||
red += (depth * 2);
|
|
||||||
green += depth;
|
|
||||||
|
|
||||||
if (red > 255)
|
|
||||||
red = 255;
|
|
||||||
if (green > 255)
|
|
||||||
green = 255;
|
|
||||||
pixels[i] = (0xFF << 24) | (red << 16) | (green << 8) | blue;
|
|
||||||
}
|
|
||||||
sepia.setPixels(pixels, 0, width, 0, 0, width, height);
|
|
||||||
return sepia;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getPicture() {
|
public Bitmap getPicture() {
|
||||||
|
picture.recycle();
|
||||||
return filterPicture;
|
return filterPicture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,5 +151,8 @@ public class PicturePreview extends SurfaceView implements SurfaceHolder.Callbac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
Log.d(TAG, "surfaceDestroyed: PICTURE DESTROYED");
|
||||||
|
picture.recycle();
|
||||||
|
filterPicture.recycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package nl.myhyvesbookplus.tagram.controller;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.firebase.auth.FirebaseAuth;
|
||||||
import com.google.firebase.database.DataSnapshot;
|
import com.google.firebase.database.DataSnapshot;
|
||||||
import com.google.firebase.database.DatabaseError;
|
import com.google.firebase.database.DatabaseError;
|
||||||
import com.google.firebase.database.DatabaseReference;
|
import com.google.firebase.database.DatabaseReference;
|
||||||
@@ -36,7 +37,6 @@ public class DownloadClass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getPostsFromServer() {
|
public void getPostsFromServer() {
|
||||||
Log.d(TAG, "getPostsFromServer: Begin of function");
|
|
||||||
mDataRef.child("posts").addListenerForSingleValueEvent(new ValueEventListener() {
|
mDataRef.child("posts").addListenerForSingleValueEvent(new ValueEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onDataChange(DataSnapshot dataSnapshot) {
|
public void onDataChange(DataSnapshot dataSnapshot) {
|
||||||
@@ -60,6 +60,18 @@ public class DownloadClass {
|
|||||||
return mList;
|
return mList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<UriPost> getOwnPosts() {
|
||||||
|
String currentUid = FirebaseAuth.getInstance().getCurrentUser().getUid();
|
||||||
|
ArrayList<UriPost> posts = new ArrayList<UriPost>();
|
||||||
|
|
||||||
|
for (UriPost post : mList) {
|
||||||
|
if (post.getPoster().equals(currentUid)) {
|
||||||
|
posts.add(post);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return posts;
|
||||||
|
}
|
||||||
|
|
||||||
public interface PostDownloadListener {
|
public interface PostDownloadListener {
|
||||||
void PostDownloaded();
|
void PostDownloaded();
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 199 B |
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||||
|
</vector>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 222 B |
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M9.4,10.5l4.77,-8.26C13.47,2.09 12.75,2 12,2c-2.4,0 -4.6,0.85 -6.32,2.25l3.66,6.35 0.06,-0.1zM21.54,9c-0.92,-2.92 -3.15,-5.26 -6,-6.34L11.88,9h9.66zM21.8,10h-7.49l0.29,0.5 4.76,8.25C21,16.97 22,14.61 22,12c0,-0.69 -0.07,-1.35 -0.2,-2zM8.54,12l-3.9,-6.75C3.01,7.03 2,9.39 2,12c0,0.69 0.07,1.35 0.2,2h7.49l-1.15,-2zM2.46,15c0.92,2.92 3.15,5.26 6,6.34L12.12,15L2.46,15zM13.73,15l-3.9,6.76c0.7,0.15 1.42,0.24 2.17,0.24 2.4,0 4.6,-0.85 6.32,-2.25l-3.66,-6.35 -0.93,1.6z"/>
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:strokeColor="#AAAAAA" android:strokeWidth="0.5"
|
||||||
|
android:fillColor="#FFFFFFFF"
|
||||||
|
android:fillAlpha="0.5"
|
||||||
|
android:pathData="M20,4h-3.17L15,2L9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM15,15.5L15,13L9,13v2.5L5.5,12 9,8.5L9,11h6L15,8.5l3.5,3.5 -3.5,3.5z"/>
|
||||||
|
</vector>
|
||||||
@@ -18,20 +18,23 @@
|
|||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:padding="10dp"
|
android:padding="15dp"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:scaleX="2"
|
android:scaleX="2.5"
|
||||||
android:scaleY="2"
|
android:scaleY="2.5"
|
||||||
app:srcCompat="@android:drawable/ic_menu_camera" />
|
android:src="@drawable/ic_camera_black_24dp"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/switch_camera_button"
|
android:id="@+id/switch_camera_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
android:padding="10dp"
|
||||||
android:layout_margin="9dp"
|
android:layout_margin="9dp"
|
||||||
|
android:scaleX="1.5"
|
||||||
|
android:scaleY="1.5"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
app:srcCompat="@android:drawable/ic_menu_revert" />
|
android:src="@drawable/ic_switch_camera_black_24dp"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/load_bar"
|
android:id="@+id/load_bar"
|
||||||
@@ -54,8 +57,10 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:scaleX="0.5"
|
android:scaleX="2"
|
||||||
android:scaleY="0.5"
|
android:scaleY="2"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:src="@drawable/ic_arrow_back_black_24dp"/>
|
android:src="@drawable/ic_arrow_back_black_24dp"/>
|
||||||
|
|
||||||
@@ -64,8 +69,10 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@android:color/transparent"
|
android:background="@android:color/transparent"
|
||||||
android:scaleX="0.5"
|
android:scaleX="2"
|
||||||
android:scaleY="0.5"
|
android:scaleY="2"
|
||||||
|
android:padding="10dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:src="@drawable/ic_arrow_forward_black_24dp"/>
|
android:src="@drawable/ic_arrow_forward_black_24dp"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
@@ -74,13 +81,17 @@
|
|||||||
android:id="@+id/comment_box"
|
android:id="@+id/comment_box"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:clickable="false"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
|
android:padding="5dp"
|
||||||
|
android:background="@android:color/background_light"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Comment:"/>
|
android:text="@string/comment"/>
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/comment_text"
|
android:id="@+id/comment_text"
|
||||||
@@ -89,24 +100,29 @@
|
|||||||
android:lines="4"
|
android:lines="4"
|
||||||
android:layout_margin="4dp"
|
android:layout_margin="4dp"
|
||||||
android:padding="5dp"
|
android:padding="5dp"
|
||||||
android:visibility="visible"
|
|
||||||
android:background="@android:color/darker_gray"/>
|
android:background="@android:color/darker_gray"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/comment_submit"
|
android:id="@+id/comment_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Submit"/>
|
android:layout_weight="1"
|
||||||
|
android:text="@string/upload"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/comment_cancel"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/cancel"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
</LinearLayout>
|
||||||
android:id="@+id/picture_taken_buttons"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginLeft="30dp"
|
|
||||||
android:layout_marginRight="30dp"
|
|
||||||
android:layout_marginBottom="20dp">
|
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.design.widget.FloatingActionButton
|
||||||
android:id="@+id/upload_button"
|
android:id="@+id/upload_button"
|
||||||
@@ -116,21 +132,10 @@
|
|||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
|
android:layout_margin="15dp"
|
||||||
app:fabSize="normal"
|
app:fabSize="normal"
|
||||||
android:src="@android:drawable/ic_menu_upload"/>
|
android:src="@android:drawable/ic_menu_upload"/>
|
||||||
|
|
||||||
<!--<android.support.design.widget.FloatingActionButton
|
|
||||||
android:id="@+id/save_button"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:scaleType="center"
|
|
||||||
app:fabSize="normal"
|
|
||||||
android:src="@android:drawable/ic_menu_save"/>-->
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|||||||
@@ -32,4 +32,6 @@
|
|||||||
<string name="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
<string name="upload_profile_pic">Profielfoto aan het uploaden…</string>
|
||||||
<string name="niet_slecht">"\"Niet slecht.\"s "</string>
|
<string name="niet_slecht">"\"Niet slecht.\"s "</string>
|
||||||
<string name="mail_success">An e-mail was sent, please follow its instructions.</string>
|
<string name="mail_success">An e-mail was sent, please follow its instructions.</string>
|
||||||
|
<string name="comment">Bijschrift:</string>
|
||||||
|
<string name="cancel">Annuleer</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -30,4 +30,6 @@
|
|||||||
<string name="image_save_error">Saving image to storage failed. Please make sure there is space available on the device.</string>
|
<string name="image_save_error">Saving image to storage failed. Please make sure there is space available on the device.</string>
|
||||||
<string name="update_profile_pic_error">Updating the profile picture failed. Please check network connection.</string>
|
<string name="update_profile_pic_error">Updating the profile picture failed. Please check network connection.</string>
|
||||||
<string name="upload_profile_pic">Uploading profile picture…</string>
|
<string name="upload_profile_pic">Uploading profile picture…</string>
|
||||||
|
<string name="comment">Comment:</string>
|
||||||
|
<string name="cancel">Cancel</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user