@@ -0,0 +1,1908 @@
+package cmput301f17t09.goalsandhabits.Main_Habits;%0D%0A%0D%0Aimport android.graphics.Bitmap;%0D%0Aimport android.graphics.BitmapFactory;%0D%0Aimport android.os.AsyncTask;%0D%0Aimport android.util.Base64;%0D%0A%0D%0Aimport java.io.ByteArrayOutputStream;%0D%0A%0D%0A/**%0D%0A * Created by Simone on 2017/12/2.%0D%0A */%0D%0A%0D%0Apublic class ImageController %7B%0D%0A    //public static class Compressor extends AsyncTask%3CBitmap, Void, String%3E %7B%0D%0A    public static class Compressor extends AsyncTask%3CHabitEvent, Void, Void%3E %7B%0D%0A        private final int COMPRESSION_QUALITY = 100;%0D%0A        private String encodedImage;%0D%0A        ByteArrayOutputStream byteArrayBitmapStream = new ByteArrayOutputStream();%0D%0A%0D%0A        @Override%0D%0A        protected Void doInBackground(HabitEvent... habitEvents) %7B%0D%0A            for(HabitEvent he : habitEvents)%7B%0D%0A                Bitmap photo = he.getDecodedPhoto();%0D%0A                he.setDecodedPhoto(null);%0D%0A                photo.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY, byteArrayBitmapStream);%0D%0A                byte%5B%5D b = byteArrayBitmapStream.toByteArray();%0D%0A                encodedImage = Base64.encodeToString(b, Base64.DEFAULT);%0D%0A                he.setEncodedPhoto(encodedImage);%0D%0A            %7D%0D%0A            return null;%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    /**%0D%0A     * Decompresses the image%0D%0A     */%0D%0A    public static class Decompressor extends AsyncTask%3CString, Void, Bitmap%3E%7B%0D%0A%0D%0A        private Bitmap decodedByte;%0D%0A%0D%0A        // Code taken from: http://mobile.cs.fsu.edu/converting-images-to-json-objects/%0D%0A        @Override%0D%0A        protected Bitmap doInBackground(String... strings) %7B%0D%0A            for (String stringPicture : strings) %7B%0D%0A                byte%5B%5D decodedString = Base64.decode(stringPicture, Base64.DEFAULT);%0D%0A%0D%0A                decodedByte = BitmapFactory.decodeByteArray(decodedString,%0D%0A                        0, decodedString.length);%0D%0A            %7D%0D%0A            return decodedByte;%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

add image controller