// Path: src/main/java/com/github/randoapp/log/Log.java
// public class Log {
// 
//     public static void i(Class clazz, String... msgs) {
//         android.util.Log.i(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void d(Class clazz, String... msgs) {
//         android.util.Log.d(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void w(Class clazz, String... msgs) {
//         android.util.Log.w(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void e(Class clazz, String... msgs) {
//         android.util.Log.e(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void e(Class clazz, String comment, Throwable throwable) {
//         android.util.Log.e(clazz.getName(), comment + " error:", throwable);
//     }
// 
//     public static void v(Class clazz, String... msgs) {
//         android.util.Log.v(clazz.getName(), concatenate(msgs));
//     }
// 
//     private static String concatenate(String[] msgs) {
//         if (msgs == null) {
//             return "";
//         }
// 
//         StringBuilder sb = new StringBuilder();
//         for (String msg : msgs) {
//             sb.append(msg).append(" ");
//         }
//         return sb.toString();
//     }
// 
// }
// 
// Path: src/main/java/com/github/randoapp/util/FileUtil.java
// public class FileUtil {
// 
//     public static File getOutputMediaDir() {
//         File mediaStorageDir = new File(
//                 Environment
//                         .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
//                 Constants.ALBUM_NAME);
//         if (!mediaStorageDir.exists()) {
//             if (!mediaStorageDir.mkdirs()) {
//                 return null;
//             }
//         }
//         return mediaStorageDir;
//     }
// 
//     public static File getOutputMediaFile() {
//         Log.d(FileUtil.class, "getOutputMediaFile");
// 
//         File mediaStorageDir = getOutputMediaDir();
//         if (mediaStorageDir == null) {
//             return null;
//         }
//         // Create a media file name
//         String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
//                 .format(new Date());
//         File mediaFile;
//         mediaFile = new File(mediaStorageDir.getPath() + File.separator
//                 + Constants.IMAGE_PREFIX + timeStamp + Constants.IMAGE_POSTFIX);
//         return mediaFile;
//     }
// 
//     public static void removeFileIfExist(String filename) {
//         File file = new File(filename);
//         if (file.isFile()) {
//             file.delete();
//         }
//     }
// 
//     public static byte[] readFile(File file) {
//         int size = (int) file.length();
//         byte[] bytes = new byte[size];
//         BufferedInputStream buf = null;
//         try {
//             buf = new BufferedInputStream(new FileInputStream(file));
//             buf.read(bytes, 0, bytes.length);
//         } catch (FileNotFoundException e) {
//             Log.e(FileUtil.class, "Error Reading File", e);
//         } catch (IOException e) {
//             Log.e(FileUtil.class, "Error Reading File", e);
//         } finally {
//             if (buf != null) {
//                 try {
//                     buf.close();
//                 } catch (IOException e) {
//                 }
//             }
//         }
//         return bytes;
//     }
// }
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_BROADCAST_EVENT = "RANDO_CAMERA_EVENT";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String RANDO_PHOTO_PATH = "RANDO_PHOTO_PATH";


import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.support.media.ExifInterface;
import android.support.v4.content.LocalBroadcastManager;
import com.github.randoapp.log.Log;
import com.github.randoapp.util.FileUtil;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.github.randoapp.Constants.CAMERA_BROADCAST_EVENT;
import static com.github.randoapp.Constants.RANDO_PHOTO_PATH;
                    break;
                default:
                    break;
            }
        }
        return rotation;
    }

    private File saveBitmap(Bitmap bitmap) {
        try {
            File file = FileUtil.getOutputMediaFile();
            FileOutputStream fos = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 80, fos);
            fos.close();
            Log.d(CropToSquareImageTask.class, "Camera Pic Processed.");
            return file;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    public void run() {
        File image = saveSquareImage();
        Intent intent = new Intent(CAMERA_BROADCAST_EVENT);
        if (image != null && !isCanceled.get()) {
// Path: src/main/java/com/github/randoapp/log/Log.java
// public class Log {
// 
//     public static void i(Class clazz, String... msgs) {
//         android.util.Log.i(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void d(Class clazz, String... msgs) {
//         android.util.Log.d(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void w(Class clazz, String... msgs) {
//         android.util.Log.w(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void e(Class clazz, String... msgs) {
//         android.util.Log.e(clazz.getName(), concatenate(msgs));
//     }
// 
//     public static void e(Class clazz, String comment, Throwable throwable) {
//         android.util.Log.e(clazz.getName(), comment + " error:", throwable);
//     }
// 
//     public static void v(Class clazz, String... msgs) {
//         android.util.Log.v(clazz.getName(), concatenate(msgs));
//     }
// 
//     private static String concatenate(String[] msgs) {
//         if (msgs == null) {
//             return "";
//         }
// 
//         StringBuilder sb = new StringBuilder();
//         for (String msg : msgs) {
//             sb.append(msg).append(" ");
//         }
//         return sb.toString();
//     }
// 
// }
// 
// Path: src/main/java/com/github/randoapp/util/FileUtil.java
// public class FileUtil {
// 
//     public static File getOutputMediaDir() {
//         File mediaStorageDir = new File(
//                 Environment
//                         .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
//                 Constants.ALBUM_NAME);
//         if (!mediaStorageDir.exists()) {
//             if (!mediaStorageDir.mkdirs()) {
//                 return null;
//             }
//         }
//         return mediaStorageDir;
//     }
// 
//     public static File getOutputMediaFile() {
//         Log.d(FileUtil.class, "getOutputMediaFile");
// 
//         File mediaStorageDir = getOutputMediaDir();
//         if (mediaStorageDir == null) {
//             return null;
//         }
//         // Create a media file name
//         String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
//                 .format(new Date());
//         File mediaFile;
//         mediaFile = new File(mediaStorageDir.getPath() + File.separator
//                 + Constants.IMAGE_PREFIX + timeStamp + Constants.IMAGE_POSTFIX);
//         return mediaFile;
//     }
// 
//     public static void removeFileIfExist(String filename) {
//         File file = new File(filename);
//         if (file.isFile()) {
//             file.delete();
//         }
//     }
// 
//     public static byte[] readFile(File file) {
//         int size = (int) file.length();
//         byte[] bytes = new byte[size];
//         BufferedInputStream buf = null;
//         try {
//             buf = new BufferedInputStream(new FileInputStream(file));
//             buf.read(bytes, 0, bytes.length);
//         } catch (FileNotFoundException e) {
//             Log.e(FileUtil.class, "Error Reading File", e);
//         } catch (IOException e) {
//             Log.e(FileUtil.class, "Error Reading File", e);
//         } finally {
//             if (buf != null) {
//                 try {
//                     buf.close();
//                 } catch (IOException e) {
//                 }
//             }
//         }
//         return bytes;
//     }
// }
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String CAMERA_BROADCAST_EVENT = "RANDO_CAMERA_EVENT";
// 
// Path: src/main/java/com/github/randoapp/Constants.java
// public static final String RANDO_PHOTO_PATH = "RANDO_PHOTO_PATH";


// Path: src/main/java/com/github/randoapp/task/CropToSquareImageTask.java
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapRegionDecoder;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.support.media.ExifInterface;
import android.support.v4.content.LocalBroadcastManager;
import com.github.randoapp.log.Log;
import com.github.randoapp.util.FileUtil;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.github.randoapp.Constants.CAMERA_BROADCAST_EVENT;
import static com.github.randoapp.Constants.RANDO_PHOTO_PATH;

                    break;
                default:
                    break;
            }
        }
        return rotation;
    }

    private File saveBitmap(Bitmap bitmap) {
        try {
            File file = FileUtil.getOutputMediaFile();
            FileOutputStream fos = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG, 80, fos);
            fos.close();
            Log.d(CropToSquareImageTask.class, "Camera Pic Processed.");
            return file;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    public void run() {
        File image = saveSquareImage();
        Intent intent = new Intent(CAMERA_BROADCAST_EVENT);
        if (image != null && !isCanceled.get()) {
            intent.putExtra(RANDO_PHOTO_PATH, image.getAbsolutePath());