Move common gradle config into convention plugins.

This commit is contained in:
Greyson Parrelli
2023-02-13 17:03:08 -05:00
parent 9fa4741e49
commit 6145fa213e
67 changed files with 684 additions and 786 deletions

View File

@@ -5,7 +5,7 @@ import kotlin.math.max
class AsciiArt {
private class Table (
private class Table(
private val columns: List<String>,
private val rows: List<List<String>>
) {

View File

@@ -24,4 +24,4 @@ val Float.sp: Float get() = DimensionUnit.SP.toPixels(this)
* Converts the given Int SP value into Pixels
*/
@get:Px
val Int.sp: Int get() = this.toFloat().sp.toInt()
val Int.sp: Int get() = this.toFloat().sp.toInt()

View File

@@ -7,7 +7,6 @@ import android.graphics.Paint
import android.graphics.PorterDuff
import kotlin.math.abs
object FontUtil {
private const val SAMPLE_EMOJI = "\uD83C\uDF0D" // 🌍
@@ -37,4 +36,4 @@ object FontUtil {
return bitmap.getPixel(0, 0) != 0
}
}
}

View File

@@ -16,4 +16,4 @@ fun <E> Optional<E>.isAbsent(): Boolean {
fun <E : Any> E?.toOptional(): Optional<E> {
return Optional.ofNullable(this)
}
}

View File

@@ -25,5 +25,4 @@ object StringStringSerializer : StringSerializer<String?> {
override fun deserialize(data: String): String {
return data
}
}
}

View File

@@ -82,7 +82,7 @@ object SqlUtil {
@JvmStatic
fun getForeignKeyDependencies(db: SupportSQLiteDatabase, table: String): Set<String> {
return db.query("PRAGMA foreign_key_list($table)")
.readToSet{ cursor ->
.readToSet { cursor ->
cursor.requireNonNullString("table")
}
}
@@ -393,4 +393,4 @@ object SqlUtil {
}
class Query(val where: String, val whereArgs: Array<String>)
}
}

View File

@@ -37,4 +37,4 @@ fun String.asListContains(item: String): Boolean {
*/
fun String.toSingleLine(): String {
return this.trimIndent().split("\n").joinToString(separator = " ")
}
}

View File

@@ -21,13 +21,13 @@ class DeadlockDetector(private val handler: Handler, private val pollingInterval
var lastThreadDumpTime: Long = -1
fun start() {
Log.d(TAG, "Beginning deadlock monitoring.");
Log.d(TAG, "Beginning deadlock monitoring.")
running = true
handler.postDelayed(this::poll, pollingInterval)
}
fun stop() {
Log.d(TAG, "Ending deadlock monitoring.");
Log.d(TAG, "Ending deadlock monitoring.")
running = false
handler.removeCallbacksAndMessages(null)
}
@@ -122,7 +122,6 @@ class DeadlockDetector(private val handler: Handler, private val pollingInterval
for (entry in blocked) {
stringBuilder.append("-- [${entry.key.id}] ${entry.key.name} | ${entry.key.state}\n")
val callerThrowable: Throwable? = TracedThreads.callerStackTraces[entry.key.id]
val stackTrace: Array<StackTraceElement> = if (callerThrowable != null) {
ExceptionUtil.joinStackTrace(entry.value, callerThrowable.stackTrace)

View File

@@ -31,25 +31,28 @@ internal class TracingExecutorService(val wrapped: ExecutorService) : ExecutorSe
val queue: Queue<Runnable>
get() {
return if (wrapped is ThreadPoolExecutor)
return if (wrapped is ThreadPoolExecutor) {
wrapped.queue
else
} else {
LinkedBlockingQueue()
}
}
val activeCount: Int
get() {
return if (wrapped is ThreadPoolExecutor)
return if (wrapped is ThreadPoolExecutor) {
wrapped.activeCount
else
} else {
0
}
}
val maximumPoolSize: Int
get() {
return if (wrapped is ThreadPoolExecutor)
return if (wrapped is ThreadPoolExecutor) {
wrapped.maximumPoolSize
else
} else {
0
}
}
}

View File

@@ -5,12 +5,13 @@ import org.signal.core.util.ExceptionUtil
/**
* An uncaught exception handler that will combine a caller stack trace with the exception to print a more useful stack trace.
*/
internal class TracingUncaughtExceptionHandler (
val originalHandler: Thread.UncaughtExceptionHandler?,
private val callerStackTrace: Throwable) : Thread.UncaughtExceptionHandler {
internal class TracingUncaughtExceptionHandler(
val originalHandler: Thread.UncaughtExceptionHandler?,
private val callerStackTrace: Throwable
) : Thread.UncaughtExceptionHandler {
override fun uncaughtException(thread: Thread, exception: Throwable) {
val updated = ExceptionUtil.joinStackTrace(exception, callerStackTrace)
originalHandler?.uncaughtException(thread, updated)
}
}
}

View File

@@ -21,4 +21,4 @@ object PlatformCurrencyUtil {
fun getAvailableCurrencyCodes(): Set<String> {
return Currency.getAvailableCurrencies().map { it.currencyCode }.toSet()
}
}
}

View File

@@ -32,7 +32,7 @@ class StringExtensions_asListContains(
arrayOf("a", "b", false),
arrayOf("a", "abc", false),
arrayOf("b", "a*", false),
arrayOf("b", "a*", false)
).toList()
}
}

View File

@@ -51,4 +51,4 @@ class StringUtilTest_endsWith {
assertEquals(expected, result)
}
}
}

View File

@@ -48,4 +48,4 @@ class StringUtilTest_replace {
assertEquals(expected.toString(), result.toString())
}
}
}

View File

@@ -51,4 +51,4 @@ class StringUtilTest_startsWith {
assertEquals(expected, result)
}
}
}