// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/utils/android/LogUtils.java
// @Beta
// public class LogUtils {
// 
//     @SuppressWarnings("unused")
//     private static final String TAG = LogUtils.class.getSimpleName();
// 
//     private LogUtils() {
//         // hidden constructor, no instantiation needed
//     }
// 
//     /**
//      * Logs a message in LogCat, only if library debugging is active.
//      *
//      * @param logLevel   The log level to use: must be one of the level constants provided by the
//      *                   {@link Log} class.
//      * @param logTag
//      * @param logMessage
//      */
//     public static void log(int logLevel, String logTag, String logMessage) {
//         if (DroidConfig.DEBUG) {
//             switch (logLevel) {
//                 case Log.ASSERT:
//                 case Log.VERBOSE:
//                     Log.v(logTag, logMessage);
//                     break;
//                 case Log.DEBUG:
//                     Log.d(logTag, logMessage);
//                     break;
//                 case Log.INFO:
//                     Log.i(logTag, logMessage);
//                     break;
//                 case Log.WARN:
//                     Log.w(logTag, logMessage);
//                     break;
//                 case Log.ERROR:
//                     Log.e(logTag, logMessage);
//                     break;
//             }
//         }
//     }
// 
//     /**
//      * Prints on LogCat a stack track of an exception, only if library debugging is active.
//      *
//      * @param t The {@link Throwable} to get the stack trace from
//      */
//     public static void logException(Throwable t) {
//         if (DroidConfig.DEBUG) {
//             if (t != null) {
//                 t.printStackTrace();
//             }
//         }
//     }
// 
//     /**
//      * Prints on LogCat a log warning message with the exception stack, only if library debugging is
//      * active.
//      *
//      * @param logTag
//      * @param logMessage
//      * @param t          The {@link Throwable} to get the stack trace from
//      */
//     public static void logException(String logTag, String logMessage, Throwable t) {
//         if (DroidConfig.DEBUG) {
//             if (t != null) {
//                 Log.w(logTag, logMessage, t);
//             }
//         }
//     }
// 
//     /**
//      * Prints on LogCat a log warning message with the exception's message string, only if library
//      * debugging is active.
//      *
//      * @param t The {@link Throwable} to get the message from
//      */
//     public static void logExceptionMessage(String logTag, String logMessage, Throwable t) {
//         if (DroidConfig.DEBUG) {
//             if (t != null) {
//                 Log.w(logTag,
//                         logMessage + "\n" + t.getClass().getSimpleName() + " message: "
//                                 + t.getMessage());
//             }
//         }
//     }
// 
// }


import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.github.marcosalis.kraken.utils.android.LogUtils;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
            case ExifInterface.ORIENTATION_ROTATE_270:
                rotateValue += 90;
            case ExifInterface.ORIENTATION_ROTATE_180:
                rotateValue += 90;
            case ExifInterface.ORIENTATION_ROTATE_90:
                rotateValue += 90;
                break;
        }
        return rotateValue;
    }

    /**
     * Loads and crops an image to be used as a squared picture, mostly to be used as a "profile"
     * picture of some sort: if the image is in portrait format, it is cropped from its bottom. If
     * the image is in landscape format, the image is cropped to its center to make it squared.
     *
     * @param url     The path where to retrieve the image (must be not null)
     * @param maxSide The maximum required image side (the cropped resulting image may be smaller)
     * @return The cropped {@link Bitmap} or null if an error occurred
     */
    @Nullable
    public static Bitmap cropProfileBitmap(@NonNull String picturePath, int maxSide) {
        Preconditions.checkArgument(maxSide > 0);

        int rotateValue = 0;
        // check for orientation
        int orientation = getExifOrientation(picturePath);
        rotateValue = getRotationAngleFromOrientation(orientation);

        // First decode with inJustDecodeBounds = true to check dimensions
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/utils/android/LogUtils.java
// @Beta
// public class LogUtils {
// 
//     @SuppressWarnings("unused")
//     private static final String TAG = LogUtils.class.getSimpleName();
// 
//     private LogUtils() {
//         // hidden constructor, no instantiation needed
//     }
// 
//     /**
//      * Logs a message in LogCat, only if library debugging is active.
//      *
//      * @param logLevel   The log level to use: must be one of the level constants provided by the
//      *                   {@link Log} class.
//      * @param logTag
//      * @param logMessage
//      */
//     public static void log(int logLevel, String logTag, String logMessage) {
//         if (DroidConfig.DEBUG) {
//             switch (logLevel) {
//                 case Log.ASSERT:
//                 case Log.VERBOSE:
//                     Log.v(logTag, logMessage);
//                     break;
//                 case Log.DEBUG:
//                     Log.d(logTag, logMessage);
//                     break;
//                 case Log.INFO:
//                     Log.i(logTag, logMessage);
//                     break;
//                 case Log.WARN:
//                     Log.w(logTag, logMessage);
//                     break;
//                 case Log.ERROR:
//                     Log.e(logTag, logMessage);
//                     break;
//             }
//         }
//     }
// 
//     /**
//      * Prints on LogCat a stack track of an exception, only if library debugging is active.
//      *
//      * @param t The {@link Throwable} to get the stack trace from
//      */
//     public static void logException(Throwable t) {
//         if (DroidConfig.DEBUG) {
//             if (t != null) {
//                 t.printStackTrace();
//             }
//         }
//     }
// 
//     /**
//      * Prints on LogCat a log warning message with the exception stack, only if library debugging is
//      * active.
//      *
//      * @param logTag
//      * @param logMessage
//      * @param t          The {@link Throwable} to get the stack trace from
//      */
//     public static void logException(String logTag, String logMessage, Throwable t) {
//         if (DroidConfig.DEBUG) {
//             if (t != null) {
//                 Log.w(logTag, logMessage, t);
//             }
//         }
//     }
// 
//     /**
//      * Prints on LogCat a log warning message with the exception's message string, only if library
//      * debugging is active.
//      *
//      * @param t The {@link Throwable} to get the message from
//      */
//     public static void logExceptionMessage(String logTag, String logMessage, Throwable t) {
//         if (DroidConfig.DEBUG) {
//             if (t != null) {
//                 Log.w(logTag,
//                         logMessage + "\n" + t.getClass().getSimpleName() + " message: "
//                                 + t.getMessage());
//             }
//         }
//     }
// 
// }


// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/utils/BitmapUtils.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.media.ExifInterface;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.github.marcosalis.kraken.utils.android.LogUtils;
import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.io.IOException;

            case ExifInterface.ORIENTATION_ROTATE_270:
                rotateValue += 90;
            case ExifInterface.ORIENTATION_ROTATE_180:
                rotateValue += 90;
            case ExifInterface.ORIENTATION_ROTATE_90:
                rotateValue += 90;
                break;
        }
        return rotateValue;
    }

    /**
     * Loads and crops an image to be used as a squared picture, mostly to be used as a "profile"
     * picture of some sort: if the image is in portrait format, it is cropped from its bottom. If
     * the image is in landscape format, the image is cropped to its center to make it squared.
     *
     * @param url     The path where to retrieve the image (must be not null)
     * @param maxSide The maximum required image side (the cropped resulting image may be smaller)
     * @return The cropped {@link Bitmap} or null if an error occurred
     */
    @Nullable
    public static Bitmap cropProfileBitmap(@NonNull String picturePath, int maxSide) {
        Preconditions.checkArgument(maxSide > 0);

        int rotateValue = 0;
        // check for orientation
        int orientation = getExifOrientation(picturePath);
        rotateValue = getRotationAngleFromOrientation(orientation);

        // First decode with inJustDecodeBounds = true to check dimensions
        final BitmapFactory.Options options = new BitmapFactory.Options();