<commit_before>package io.skygear.plugins.chat.ui.utils

import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Matrix
import android.net.Uri
import android.os.Environment
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
import android.media.ExifInterface
import android.R.attr.path
import java.io.FileOutputStream


/**
 * Created by carmenlau on 10/2/17.
 */

private val THUMBNAIL_SIZE= 100.0
private val IMAGE_SIZE = 1600.0
var mCurrentPhotoPath: String = ""

data class ImageData(val thumbnail: Bitmap,
                     val image: Bitmap)

fun getResizedBitmap(context: Context, uri: Uri): ImageData? {
    var input = context.getContentResolver().openInputStream(uri)

    val onlyBoundsOptions = BitmapFactory.Options()
    onlyBoundsOptions.inJustDecodeBounds = true
    onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888//optional
    BitmapFactory.decodeStream(input, null, onlyBoundsOptions)
    input.close()

    if (onlyBoundsOptions.outWidth == -1 || onlyBoundsOptions.outHeight == -1) {
        return null
    }

    // get orientation exif
    input = context.getContentResolver().openInputStream(uri)<commit_msg>Update thumbnail image size to 80px and match iOS version.<commit_after>package io.skygear.plugins.chat.ui.utils

import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Matrix
import android.net.Uri
import android.os.Environment
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
import android.media.ExifInterface
import android.R.attr.path
import java.io.FileOutputStream


/**
 * Created by carmenlau on 10/2/17.
 */

private val THUMBNAIL_SIZE = 80.0
private val IMAGE_SIZE = 1600.0
var mCurrentPhotoPath: String = ""

data class ImageData(val thumbnail: Bitmap,
                     val image: Bitmap)

fun getResizedBitmap(context: Context, uri: Uri): ImageData? {
    var input = context.getContentResolver().openInputStream(uri)

    val onlyBoundsOptions = BitmapFactory.Options()
    onlyBoundsOptions.inJustDecodeBounds = true
    onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888//optional
    BitmapFactory.decodeStream(input, null, onlyBoundsOptions)
    input.close()

    if (onlyBoundsOptions.outWidth == -1 || onlyBoundsOptions.outHeight == -1) {
        return null
    }

    // get orientation exif
    input = context.getContentResolver().openInputStream(uri)
{'fraction_non_alphanumeric': 0.08940022632968692, 'fraction_numerical': 0.015465861938890985, 'mean_word_length': 4.325301204819277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5043933', 'n_tokens_mistral': 787, 'n_tokens_neox': 738, 'n_words': 180}