Merge pull request #443 from ltGuillaume/patch-1
Adding handleSAFDialog for EXIF rotation
This commit is contained in:
commit
6bc3e4cfa6
1 changed files with 32 additions and 30 deletions
|
@ -456,41 +456,43 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
val currPath = getCurrentPath()
|
val currPath = getCurrentPath()
|
||||||
SaveAsDialog(this, currPath, false) {
|
SaveAsDialog(this, currPath, false) {
|
||||||
Thread({
|
Thread({
|
||||||
toast(R.string.saving)
|
|
||||||
val selectedFile = File(it)
|
val selectedFile = File(it)
|
||||||
val tmpFile = File(filesDir, ".tmp_${it.getFilenameFromPath()}")
|
handleSAFDialog(selectedFile) {
|
||||||
try {
|
toast(R.string.saving)
|
||||||
val bitmap = BitmapFactory.decodeFile(currPath)
|
val tmpFile = File(filesDir, ".tmp_${it.getFilenameFromPath()}")
|
||||||
getFileOutputStream(tmpFile) {
|
try {
|
||||||
if (it == null) {
|
val bitmap = BitmapFactory.decodeFile(currPath)
|
||||||
toast(R.string.unknown_error_occurred)
|
getFileOutputStream(tmpFile) {
|
||||||
return@getFileOutputStream
|
if (it == null) {
|
||||||
}
|
toast(R.string.unknown_error_occurred)
|
||||||
|
return@getFileOutputStream
|
||||||
|
}
|
||||||
|
|
||||||
if (currPath.isJpg()) {
|
if (currPath.isJpg()) {
|
||||||
saveRotation(getCurrentFile(), tmpFile)
|
saveRotation(getCurrentFile(), tmpFile)
|
||||||
} else {
|
} else {
|
||||||
saveFile(tmpFile, bitmap, it as FileOutputStream)
|
saveFile(tmpFile, bitmap, it as FileOutputStream)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpFile.length() > 0 && selectedFile.exists()) {
|
if (tmpFile.length() > 0 && selectedFile.exists()) {
|
||||||
deleteFile(selectedFile) {}
|
deleteFile(selectedFile) {}
|
||||||
}
|
}
|
||||||
copyFile(tmpFile, selectedFile)
|
copyFile(tmpFile, selectedFile)
|
||||||
scanPath(selectedFile.absolutePath) {}
|
scanPath(selectedFile.absolutePath) {}
|
||||||
toast(R.string.file_saved)
|
toast(R.string.file_saved)
|
||||||
|
|
||||||
it.flush()
|
it.flush()
|
||||||
it.close()
|
it.close()
|
||||||
mRotationDegrees = 0f
|
mRotationDegrees = 0f
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
}
|
||||||
|
} catch (e: OutOfMemoryError) {
|
||||||
|
toast(R.string.out_of_memory_error)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showErrorToast(e)
|
||||||
|
} finally {
|
||||||
|
deleteFile(tmpFile) {}
|
||||||
}
|
}
|
||||||
} catch (e: OutOfMemoryError) {
|
|
||||||
toast(R.string.out_of_memory_error)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
showErrorToast(e)
|
|
||||||
} finally {
|
|
||||||
deleteFile(tmpFile) {}
|
|
||||||
}
|
}
|
||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue