2019-06-21 04:18:38 +00:00
|
|
|
package org.thoughtcrime.securesms.loki
|
|
|
|
|
|
|
|
import android.content.res.Resources
|
|
|
|
import android.os.Build
|
|
|
|
import android.support.annotation.ColorRes
|
2019-06-21 05:29:25 +00:00
|
|
|
import kotlin.math.roundToInt
|
2019-06-21 04:18:38 +00:00
|
|
|
|
|
|
|
fun Resources.getColorWithID(@ColorRes id: Int, theme: Resources.Theme?): Int {
|
|
|
|
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
|
|
getColor(id, theme)
|
|
|
|
} else {
|
|
|
|
@Suppress("DEPRECATION") getColor(id)
|
|
|
|
}
|
2019-06-21 05:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fun convertToPixels(points: Int, resources: Resources): Int {
|
|
|
|
val scale = resources.displayMetrics.density
|
|
|
|
return (points * scale).roundToInt()
|
2019-06-21 04:18:38 +00:00
|
|
|
}
|