Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85e9f297 authored by tibbi's avatar tibbi
Browse files

adding some int helper extensions for getting orientation/degrees

parent ec39ec0b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '3.17.19'
        propVersionName = '3.17.21'
        kotlin_version = '1.2.31'
        support_libs = '27.1.0'
    }
+15 −0
Original line number Diff line number Diff line
package com.simplemobiletools.commons.extensions

import android.graphics.Color
import android.media.ExifInterface
import java.util.*

fun Int.getContrastColor(): Int {
@@ -82,3 +83,17 @@ private fun hsv2hsl(hsv: FloatArray): FloatArray {

    return floatArrayOf(hue, newSat, newHue / 2f)
}

fun Int.orientationFromDegrees() = when (this) {
    270 -> ExifInterface.ORIENTATION_ROTATE_270
    180 -> ExifInterface.ORIENTATION_ROTATE_180
    90 -> ExifInterface.ORIENTATION_ROTATE_90
    else -> ExifInterface.ORIENTATION_NORMAL
}.toString()

fun Int.degreesFromOrientation() = when (this) {
    ExifInterface.ORIENTATION_ROTATE_270 -> 270
    ExifInterface.ORIENTATION_ROTATE_180 -> 180
    ExifInterface.ORIENTATION_ROTATE_90 -> 90
    else -> 0
}