mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
properly determine image width and height at rotation by aspect ratio
This commit is contained in:
parent
50eb1a4565
commit
9858a149ea
1 changed files with 12 additions and 2 deletions
|
@ -826,10 +826,20 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun checkOrientation() {
|
private fun checkOrientation() {
|
||||||
if (!mIsOrientationLocked && config.screenRotation == ROTATE_BY_ASPECT_RATIO) {
|
if (!mIsOrientationLocked && config.screenRotation == ROTATE_BY_ASPECT_RATIO) {
|
||||||
|
var flipSides = false
|
||||||
|
try {
|
||||||
|
val pathToLoad = getCurrentPath()
|
||||||
|
val exif = android.media.ExifInterface(pathToLoad)
|
||||||
|
val orientation = exif.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, -1)
|
||||||
|
flipSides = orientation == ExifInterface.ORIENTATION_ROTATE_90 || orientation == ExifInterface.ORIENTATION_ROTATE_270
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
val res = getCurrentPath().getResolution() ?: return
|
val res = getCurrentPath().getResolution() ?: return
|
||||||
if (res.x > res.y) {
|
val width = if (flipSides) res.y else res.x
|
||||||
|
val height = if (flipSides) res.x else res.y
|
||||||
|
if (width > height) {
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
} else if (res.x < res.y) {
|
} else if (width < height) {
|
||||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue