mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
Update ViewPagerActivity.kt
- Removed `mRotationDegrees != 0f` check, because save buttton wouldn't have shown anyway - Check if output file is written - Added helpers functions (with `.toString()` instead of using `""+`)
This commit is contained in:
parent
25bd77bd12
commit
fdc1063838
1 changed files with 18 additions and 15 deletions
|
@ -515,26 +515,29 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
inputStream?.close()
|
inputStream?.close()
|
||||||
outputStream?.close()
|
outputStream?.close()
|
||||||
}
|
}
|
||||||
if (mRotationDegrees != 0f) {
|
if (out.exists()) {
|
||||||
val exif = ExifInterface(out.absolutePath)
|
val exif = ExifInterface(out.absolutePath)
|
||||||
var orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
var orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL)
|
||||||
var orientationDegrees = when (orientation) {
|
var orientationDegrees = (degreesForRotation(orientation) + mRotationDegrees) % 360
|
||||||
8 -> 270f
|
exif.setAttribute(ExifInterface.TAG_ORIENTATION, rotationFromDegrees(orientationDegrees))
|
||||||
3 -> 180f
|
|
||||||
6 -> 90f
|
|
||||||
else -> 0f
|
|
||||||
}
|
|
||||||
orientationDegrees = (orientationDegrees + mRotationDegrees) % 360
|
|
||||||
orientation = when (orientationDegrees) {
|
|
||||||
90f -> 6
|
|
||||||
180f -> 3
|
|
||||||
270f -> 8
|
|
||||||
else -> 1
|
|
||||||
}
|
|
||||||
exif.setAttribute(ExifInterface.TAG_ORIENTATION, ""+ orientation)
|
|
||||||
exif.saveAttributes()
|
exif.saveAttributes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun degreesForRotation(orientation: Int) = when (orientation) {
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_270 -> 270f
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_180 -> 180f
|
||||||
|
ExifInterface.ORIENTATION_ROTATE_90 -> 90f
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun rotationFromDegrees(degrees: Float) = when (degrees) {
|
||||||
|
90f -> ExifInterface.ORIENTATION_ROTATE_90
|
||||||
|
180f -> ExifInterface.ORIENTATION_ROTATE_180
|
||||||
|
270f -> ExifInterface.ORIENTATION_ROTATE_270
|
||||||
|
else -> ExifInterface.ORIENTATION_NORMAL
|
||||||
|
}.toString()
|
||||||
|
|
||||||
private fun isShowHiddenFlagNeeded(): Boolean {
|
private fun isShowHiddenFlagNeeded(): Boolean {
|
||||||
val file = File(mPath)
|
val file = File(mPath)
|
||||||
if (file.isHidden)
|
if (file.isHidden)
|
||||||
|
|
Loading…
Reference in a new issue