From 84199fb8584ce3b796596caf4ae717ad2fecb669 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 10 Jun 2018 22:51:22 +0200 Subject: [PATCH] recognize 19:9 and 19:8 aspect ratios better --- .../simplemobiletools/camera/models/MySize.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/models/MySize.kt b/app/src/main/kotlin/com/simplemobiletools/camera/models/MySize.kt index fdbfe47d..b23e292d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/models/MySize.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/models/MySize.kt @@ -47,6 +47,20 @@ data class MySize(val width: Int, val height: Int) { return diff < RATIO_TOLERANCE } + private fun isNineteenToNine(): Boolean { + val selectedRatio = Math.abs(width / height.toFloat()) + val checkedRatio = 19 / 9.toFloat() + val diff = Math.abs(selectedRatio - checkedRatio) + return diff < RATIO_TOLERANCE + } + + private fun isNineteenToEight(): Boolean { + val selectedRatio = Math.abs(width / height.toFloat()) + val checkedRatio = 19 / 8.toFloat() + val diff = Math.abs(selectedRatio - checkedRatio) + return diff < RATIO_TOLERANCE + } + private fun isOneNineToOne() = Math.abs(1.9 - (width / height.toFloat())) < RATIO_TOLERANCE private fun isSquare() = width == height @@ -59,6 +73,8 @@ data class MySize(val width: Int, val height: Int) { isThreeToTwo() -> "3:2" isSixToFive() -> "6:5" isOneNineToOne() -> "1.9:1" + isNineteenToNine() -> "19:9" + isNineteenToEight() -> "19:8" isSquare() -> "1:1" else -> context.resources.getString(R.string.other) }