Update website build to use PackageInstaller.

This commit is contained in:
Greyson Parrelli
2023-10-23 11:30:37 -07:00
committed by GitHub
parent d468d4c21b
commit 4b004f70ec
24 changed files with 759 additions and 458 deletions

View File

@@ -0,0 +1,13 @@
/*
* Copyright 2023 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.signal.core.util
import android.app.DownloadManager
import android.content.Context
fun Context.getDownloadManager(): DownloadManager {
return this.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
}

View File

@@ -181,6 +181,10 @@ inline fun Cursor.forEach(operation: (Cursor) -> Unit) {
}
}
fun Cursor.iterable(): Iterable<Cursor> {
return CursorIterable(this)
}
fun Boolean.toInt(): Int = if (this) 1 else 0
/**
@@ -202,3 +206,23 @@ fun Cursor.rowToString(): String {
return builder.toString()
}
private class CursorIterable(private val cursor: Cursor) : Iterable<Cursor> {
override fun iterator(): Iterator<Cursor> {
return CursorIterator(cursor)
}
}
private class CursorIterator(private val cursor: Cursor) : Iterator<Cursor> {
override fun hasNext(): Boolean {
return !cursor.isClosed && cursor.count > 0 && !cursor.isLast && !cursor.isAfterLast
}
override fun next(): Cursor {
return if (cursor.moveToNext()) {
cursor
} else {
throw NoSuchElementException()
}
}
}