Loading build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 propVersionName = '3.17.21' propVersionName = '3.17.22' kotlin_version = '1.2.31' support_libs = '27.1.0' } Loading commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +27 −0 Original line number Diff line number Diff line Loading @@ -8,13 +8,16 @@ import android.content.Intent import android.content.pm.PackageManager import android.database.Cursor import android.graphics.Color import android.media.ExifInterface import android.media.RingtoneManager import android.net.Uri import android.os.Build import android.os.Environment import android.provider.BaseColumns import android.provider.DocumentsContract import android.provider.MediaStore import android.provider.OpenableColumns import android.support.annotation.RequiresApi import android.support.v4.content.ContextCompat import android.support.v4.content.CursorLoader import android.support.v4.content.FileProvider Loading Loading @@ -492,3 +495,27 @@ fun Context.storeNewYourAlarmSound(resultData: Intent): AlarmSound { return newAlarmSound } @RequiresApi(Build.VERSION_CODES.N) fun Context.saveImageRotation(path: String, degrees: Int): Boolean { if (!isPathOnSD(path)) { saveExifRotation(ExifInterface(path), degrees) return true } else if (isNougatPlus()) { val documentFile = getSomeDocumentFile(path) if (documentFile != null) { val parcelFileDescriptor = contentResolver.openFileDescriptor(documentFile.uri, "rw") val fileDescriptor = parcelFileDescriptor.fileDescriptor saveExifRotation(ExifInterface(fileDescriptor), degrees) return true } } return false } private fun saveExifRotation(exif: ExifInterface, degrees: Int) { val orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL) val orientationDegrees = (orientation.degreesFromOrientation() + degrees) % 360 exif.setAttribute(ExifInterface.TAG_ORIENTATION, orientationDegrees.orientationFromDegrees()) exif.saveAttributes() } Loading
build.gradle +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 propVersionName = '3.17.21' propVersionName = '3.17.22' kotlin_version = '1.2.31' support_libs = '27.1.0' } Loading
commons/src/main/kotlin/com/simplemobiletools/commons/extensions/Context.kt +27 −0 Original line number Diff line number Diff line Loading @@ -8,13 +8,16 @@ import android.content.Intent import android.content.pm.PackageManager import android.database.Cursor import android.graphics.Color import android.media.ExifInterface import android.media.RingtoneManager import android.net.Uri import android.os.Build import android.os.Environment import android.provider.BaseColumns import android.provider.DocumentsContract import android.provider.MediaStore import android.provider.OpenableColumns import android.support.annotation.RequiresApi import android.support.v4.content.ContextCompat import android.support.v4.content.CursorLoader import android.support.v4.content.FileProvider Loading Loading @@ -492,3 +495,27 @@ fun Context.storeNewYourAlarmSound(resultData: Intent): AlarmSound { return newAlarmSound } @RequiresApi(Build.VERSION_CODES.N) fun Context.saveImageRotation(path: String, degrees: Int): Boolean { if (!isPathOnSD(path)) { saveExifRotation(ExifInterface(path), degrees) return true } else if (isNougatPlus()) { val documentFile = getSomeDocumentFile(path) if (documentFile != null) { val parcelFileDescriptor = contentResolver.openFileDescriptor(documentFile.uri, "rw") val fileDescriptor = parcelFileDescriptor.fileDescriptor saveExifRotation(ExifInterface(fileDescriptor), degrees) return true } } return false } private fun saveExifRotation(exif: ExifInterface, degrees: Int) { val orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL) val orientationDegrees = (orientation.degreesFromOrientation() + degrees) % 360 exif.setAttribute(ExifInterface.TAG_ORIENTATION, orientationDegrees.orientationFromDegrees()) exif.saveAttributes() }