v3.1.2 - Android 13, auto update, R8 minification

This commit is contained in:
Arty Bishop authored and Arty Bishop committed 2022-10-23 14:20:54 +01:00
1 parent baf61ca9bc
commit b156f666ef
7 files changed
+56 -52

No files matched your search

@@ -19,11 +19,7 @@ package com.rtbishop.look4sat.utility
import com.rtbishop.look4sat.domain.predict.DEG2RAD
import com.rtbishop.look4sat.domain.predict.RAD2DEG
import java.net.InetSocketAddress
import java.net.Socket
import java.security.MessageDigest
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
fun Long.toTimerString(): String {
val format = "%02d:%02d:%02d"
@@ -43,23 +39,23 @@ fun Double.toDegrees(): Double = this * RAD2DEG
fun Double.toRadians(): Double = this * DEG2RAD
fun String.getHash(type: String = "SHA-256"): String {
val hexChars = "0123456789ABCDEF"
val bytes = MessageDigest.getInstance(type).digest(this.toByteArray())
val result = StringBuilder(bytes.size * 2)
bytes.forEach {
val i = it.toInt()
result.append(hexChars[i shr 4 and 0x0f])
result.append(hexChars[i and 0x0f])
}
return result.toString()
}
//fun String.getHash(type: String = "SHA-256"): String {
// val hexChars = "0123456789ABCDEF"
// val bytes = MessageDigest.getInstance(type).digest(this.toByteArray())
// val result = StringBuilder(bytes.size * 2)
// bytes.forEach {
// val i = it.toInt()
// result.append(hexChars[i shr 4 and 0x0f])
// result.append(hexChars[i and 0x0f])
// }
// return result.toString()
//}
fun String.isValidEmail(): Boolean {
val expression = "^[\\w.-]+@([\\w\\-]+\\.)+[A-Z]{2,8}$"
val pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE)
return pattern.matcher(this).matches()
}
//fun String.isValidEmail(): Boolean {
// val expression = "^[\\w.-]+@([\\w\\-]+\\.)+[A-Z]{2,8}$"
// val pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE)
// return pattern.matcher(this).matches()
//}
fun String.isValidIPv4(): Boolean {
val ip4 = "^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.(?!\$)|\$)){4}\$"
@@ -71,16 +67,16 @@ fun String.isValidPort(): Boolean {
return this.matches(port.toRegex()) && this.toInt() in 1024..65535
}
fun ping(hostname: String, port: Int): Int {
val start = System.currentTimeMillis()
val socket = Socket()
try {
socket.connect(InetSocketAddress(hostname, port), 5000)
socket.close()
} catch (exception: Exception) {
exception.printStackTrace()
println("Failed to ping: $hostname")
return Int.MAX_VALUE
}
return (System.currentTimeMillis() - start).toInt()
}
//fun ping(hostname: String, port: Int): Int {
// val start = System.currentTimeMillis()
// val socket = Socket()
// try {
// socket.connect(InetSocketAddress(hostname, port), 5000)
// socket.close()
// } catch (exception: Exception) {
// exception.printStackTrace()
// println("Failed to ping: $hostname")
// return Int.MAX_VALUE
// }
// return (System.currentTimeMillis() - start).toInt()
//}
@@ -55,7 +55,7 @@ object QthConverter {
return (lat >= -90.0 && lat <= 90.0) && (lon >= -180.0 && lon <= 360.0)
}
fun isValidLocator(locator: String): Boolean {
private fun isValidLocator(locator: String): Boolean {
return locator.matches("[a-xA-X][a-xA-X][0-9][0-9][a-xA-X][a-xA-X]".toRegex())
}
}