mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
move the EXIF rotating attempt in a separate function
This commit is contained in:
parent
5a4a35f6d2
commit
67c9f875ae
1 changed files with 28 additions and 22 deletions
|
@ -522,31 +522,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
|
||||||
private fun saveImageToFile(oldPath: String, newPath: String) {
|
private fun saveImageToFile(oldPath: String, newPath: String) {
|
||||||
toast(R.string.saving)
|
toast(R.string.saving)
|
||||||
if (oldPath == newPath && oldPath.isJpg()) {
|
if (oldPath == newPath && oldPath.isJpg()) {
|
||||||
try {
|
if (tryRotateByExif(oldPath)) {
|
||||||
if (!isPathOnSD(oldPath)) {
|
|
||||||
saveExifRotation(ExifInterface(oldPath))
|
|
||||||
mRotationDegrees = 0f
|
|
||||||
invalidateOptionsMenu()
|
|
||||||
toast(R.string.file_saved)
|
|
||||||
return
|
|
||||||
} else if (isNougatPlus()) {
|
|
||||||
val documentFile = getSomeDocumentFile(oldPath)
|
|
||||||
if (documentFile != null) {
|
|
||||||
val parcelFileDescriptor = contentResolver.openFileDescriptor(documentFile.uri, "rw")
|
|
||||||
val fileDescriptor = parcelFileDescriptor.fileDescriptor
|
|
||||||
saveExifRotation(ExifInterface(fileDescriptor))
|
|
||||||
mRotationDegrees = 0f
|
|
||||||
invalidateOptionsMenu()
|
|
||||||
toast(R.string.file_saved)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
showErrorToast(e)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -603,6 +582,33 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.N)
|
||||||
|
private fun tryRotateByExif(path: String): Boolean {
|
||||||
|
try {
|
||||||
|
if (!isPathOnSD(path)) {
|
||||||
|
saveExifRotation(ExifInterface(path))
|
||||||
|
mRotationDegrees = 0f
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
toast(R.string.file_saved)
|
||||||
|
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))
|
||||||
|
mRotationDegrees = 0f
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
toast(R.string.file_saved)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
private fun copyFile(source: File, destination: File) {
|
private fun copyFile(source: File, destination: File) {
|
||||||
var inputStream: InputStream? = null
|
var inputStream: InputStream? = null
|
||||||
var out: OutputStream? = null
|
var out: OutputStream? = null
|
||||||
|
|
Loading…
Reference in a new issue