mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-01-18 09:42:38 +01:00
Switch to a new Ktlint Formatter (#705)
* Switch to new Ktlint plugin * Add ktlintCheck to PR builds * Run formatter * Put ktlint version in libs toml * Fix lint * Use Zip4Java from libs.toml
This commit is contained in:
@@ -12,7 +12,7 @@ class PreferenceManager {
|
||||
fun getDefaultSharedPreferences(context: Context) =
|
||||
context.getSharedPreferences(
|
||||
context.applicationInfo.packageName,
|
||||
Context.MODE_PRIVATE
|
||||
Context.MODE_PRIVATE,
|
||||
)!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.kodein.di.instance
|
||||
import xyz.nulldev.androidcompat.androidimpl.CustomContext
|
||||
|
||||
class AndroidCompat {
|
||||
|
||||
val context: CustomContext by DI.global.instance()
|
||||
|
||||
fun startApp(application: Application) {
|
||||
|
||||
@@ -18,10 +18,13 @@ class AndroidCompatInitializer {
|
||||
GlobalConfigManager.registerModules(
|
||||
FilesConfigModule.register(GlobalConfigManager.config),
|
||||
ApplicationInfoConfigModule.register(GlobalConfigManager.config),
|
||||
SystemConfigModule.register(GlobalConfigManager.config)
|
||||
SystemConfigModule.register(GlobalConfigManager.config),
|
||||
)
|
||||
|
||||
// Set some properties extensions use
|
||||
System.setProperty("http.agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
|
||||
System.setProperty(
|
||||
"http.agent",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,24 @@ import xyz.nulldev.androidcompat.service.ServiceSupport
|
||||
*/
|
||||
|
||||
class AndroidCompatModule {
|
||||
fun create() = DI.Module("AndroidCompat") {
|
||||
bind<AndroidFiles>() with singleton { AndroidFiles() }
|
||||
fun create() =
|
||||
DI.Module("AndroidCompat") {
|
||||
bind<AndroidFiles>() with singleton { AndroidFiles() }
|
||||
|
||||
bind<ApplicationInfoImpl>() with singleton { ApplicationInfoImpl() }
|
||||
bind<ApplicationInfoImpl>() with singleton { ApplicationInfoImpl() }
|
||||
|
||||
bind<ServiceSupport>() with singleton { ServiceSupport() }
|
||||
bind<ServiceSupport>() with singleton { ServiceSupport() }
|
||||
|
||||
bind<FakePackageManager>() with singleton { FakePackageManager() }
|
||||
bind<FakePackageManager>() with singleton { FakePackageManager() }
|
||||
|
||||
bind<PackageController>() with singleton { PackageController() }
|
||||
bind<PackageController>() with singleton { PackageController() }
|
||||
|
||||
// Context
|
||||
bind<CustomContext>() with singleton { CustomContext() }
|
||||
bind<Context>() with singleton {
|
||||
val context: Context by DI.global.instance<CustomContext>()
|
||||
context
|
||||
// Context
|
||||
bind<CustomContext>() with singleton { CustomContext() }
|
||||
bind<Context>() with
|
||||
singleton {
|
||||
val context: Context by DI.global.instance<CustomContext>()
|
||||
context
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ class ApplicationInfoConfigModule(getConfig: () -> Config) : ConfigModule(getCon
|
||||
val debug: Boolean by getConfig()
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
ApplicationInfoConfigModule { config.getConfig("android.app") }
|
||||
fun register(config: Config) = ApplicationInfoConfigModule { config.getConfig("android.app") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ class FilesConfigModule(getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val packageDir: String by getConfig()
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
FilesConfigModule { config.getConfig("android.files") }
|
||||
fun register(config: Config) = FilesConfigModule { config.getConfig("android.files") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,16 @@ class SystemConfigModule(val getConfig: () -> Config) : ConfigModule(getConfig)
|
||||
val propertyPrefix = "properties."
|
||||
|
||||
fun getStringProperty(property: String) = getConfig().getString("$propertyPrefix$property")!!
|
||||
|
||||
fun getIntProperty(property: String) = getConfig().getInt("$propertyPrefix$property")
|
||||
|
||||
fun getLongProperty(property: String) = getConfig().getLong("$propertyPrefix$property")
|
||||
|
||||
fun getBooleanProperty(property: String) = getConfig().getBoolean("$propertyPrefix$property")
|
||||
|
||||
fun hasProperty(property: String) = getConfig().hasPath("$propertyPrefix$property")
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
SystemConfigModule { config.getConfig("android.system") }
|
||||
fun register(config: Config) = SystemConfigModule { config.getConfig("android.system") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Calendar
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
private val cachedContent = mutableListOf<ResultSetEntry>()
|
||||
private val columnCache = mutableMapOf<String, Int>()
|
||||
private var lastReturnWasNull = false
|
||||
@@ -29,9 +28,10 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
val parentMetadata = parent.metaData
|
||||
val columnCount = parentMetadata.columnCount
|
||||
val columnLabels = (1..columnCount).map {
|
||||
parentMetadata.getColumnLabel(it)
|
||||
}.toTypedArray()
|
||||
val columnLabels =
|
||||
(1..columnCount).map {
|
||||
parentMetadata.getColumnLabel(it)
|
||||
}.toTypedArray()
|
||||
|
||||
init {
|
||||
val columnCount = columnCount
|
||||
@@ -43,10 +43,11 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
// Fill cache
|
||||
while (parent.next()) {
|
||||
cachedContent += ResultSetEntry().apply {
|
||||
for (i in 1..columnCount)
|
||||
data += parent.getObject(i)
|
||||
}
|
||||
cachedContent +=
|
||||
ResultSetEntry().apply {
|
||||
for (i in 1..columnCount)
|
||||
data += parent.getObject(i)
|
||||
}
|
||||
resultSetLength++
|
||||
}
|
||||
}
|
||||
@@ -92,67 +93,121 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as NClob
|
||||
}
|
||||
|
||||
override fun updateNString(columnIndex: Int, nString: String?) {
|
||||
override fun updateNString(
|
||||
columnIndex: Int,
|
||||
nString: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNString(columnLabel: String?, nString: String?) {
|
||||
override fun updateNString(
|
||||
columnLabel: String?,
|
||||
nString: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnIndex: Int, x: InputStream?, length: Int) {
|
||||
override fun updateBinaryStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnLabel: String?, x: InputStream?, length: Int) {
|
||||
override fun updateBinaryStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnIndex: Int, x: InputStream?, length: Long) {
|
||||
override fun updateBinaryStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnLabel: String?, x: InputStream?, length: Long) {
|
||||
override fun updateBinaryStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnIndex: Int, x: InputStream?) {
|
||||
override fun updateBinaryStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnLabel: String?, x: InputStream?) {
|
||||
override fun updateBinaryStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateTimestamp(columnIndex: Int, x: Timestamp?) {
|
||||
override fun updateTimestamp(
|
||||
columnIndex: Int,
|
||||
x: Timestamp?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateTimestamp(columnLabel: String?, x: Timestamp?) {
|
||||
override fun updateTimestamp(
|
||||
columnLabel: String?,
|
||||
x: Timestamp?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnIndex: Int, x: Reader?, length: Long) {
|
||||
override fun updateNCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateNCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnIndex: Int, x: Reader?) {
|
||||
override fun updateNCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateNCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateInt(columnIndex: Int, x: Int) {
|
||||
override fun updateInt(
|
||||
columnIndex: Int,
|
||||
x: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateInt(columnLabel: String?, x: Int) {
|
||||
override fun updateInt(
|
||||
columnLabel: String?,
|
||||
x: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -170,12 +225,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnIndex: Int, cal: Calendar?): Date {
|
||||
override fun getDate(
|
||||
columnIndex: Int,
|
||||
cal: Calendar?,
|
||||
): Date {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnLabel: String?, cal: Calendar?): Date {
|
||||
override fun getDate(
|
||||
columnLabel: String?,
|
||||
cal: Calendar?,
|
||||
): Date {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -185,11 +246,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateFloat(columnIndex: Int, x: Float) {
|
||||
override fun updateFloat(
|
||||
columnIndex: Int,
|
||||
x: Float,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateFloat(columnLabel: String?, x: Float) {
|
||||
override fun updateFloat(
|
||||
columnLabel: String?,
|
||||
x: Float,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -205,12 +272,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursor - 1 < resultSetLength
|
||||
}
|
||||
|
||||
override fun getBigDecimal(columnIndex: Int, scale: Int): BigDecimal {
|
||||
override fun getBigDecimal(
|
||||
columnIndex: Int,
|
||||
scale: Int,
|
||||
): BigDecimal {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getBigDecimal(columnLabel: String?, scale: Int): BigDecimal {
|
||||
override fun getBigDecimal(
|
||||
columnLabel: String?,
|
||||
scale: Int,
|
||||
): BigDecimal {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -223,11 +296,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as BigDecimal
|
||||
}
|
||||
|
||||
override fun updateBytes(columnIndex: Int, x: ByteArray?) {
|
||||
override fun updateBytes(
|
||||
columnIndex: Int,
|
||||
x: ByteArray?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBytes(columnLabel: String?, x: ByteArray?) {
|
||||
override fun updateBytes(
|
||||
columnLabel: String?,
|
||||
x: ByteArray?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -249,12 +328,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnIndex: Int, cal: Calendar?): Time {
|
||||
override fun getTime(
|
||||
columnIndex: Int,
|
||||
cal: Calendar?,
|
||||
): Time {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnLabel: String?, cal: Calendar?): Time {
|
||||
override fun getTime(
|
||||
columnLabel: String?,
|
||||
cal: Calendar?,
|
||||
): Time {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -328,27 +413,49 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursorValid()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnIndex: Int, x: InputStream?, length: Int) {
|
||||
override fun updateAsciiStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnLabel: String?, x: InputStream?, length: Int) {
|
||||
override fun updateAsciiStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnIndex: Int, x: InputStream?, length: Long) {
|
||||
override fun updateAsciiStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnLabel: String?, x: InputStream?, length: Long) {
|
||||
override fun updateAsciiStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnIndex: Int, x: InputStream?) {
|
||||
override fun updateAsciiStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnLabel: String?, x: InputStream?) {
|
||||
override fun updateAsciiStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -360,61 +467,107 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as URL
|
||||
}
|
||||
|
||||
override fun updateShort(columnIndex: Int, x: Short) {
|
||||
override fun updateShort(
|
||||
columnIndex: Int,
|
||||
x: Short,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateShort(columnLabel: String?, x: Short) {
|
||||
override fun updateShort(
|
||||
columnLabel: String?,
|
||||
x: Short,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getType() = ResultSet.TYPE_SCROLL_INSENSITIVE
|
||||
|
||||
override fun updateNClob(columnIndex: Int, nClob: NClob?) {
|
||||
override fun updateNClob(
|
||||
columnIndex: Int,
|
||||
nClob: NClob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnLabel: String?, nClob: NClob?) {
|
||||
override fun updateNClob(
|
||||
columnLabel: String?,
|
||||
nClob: NClob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnIndex: Int, reader: Reader?, length: Long) {
|
||||
override fun updateNClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateNClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnIndex: Int, reader: Reader?) {
|
||||
override fun updateNClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateNClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateRef(columnIndex: Int, x: Ref?) {
|
||||
override fun updateRef(
|
||||
columnIndex: Int,
|
||||
x: Ref?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateRef(columnLabel: String?, x: Ref?) {
|
||||
override fun updateRef(
|
||||
columnLabel: String?,
|
||||
x: Ref?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnIndex: Int, x: Any?, scaleOrLength: Int) {
|
||||
override fun updateObject(
|
||||
columnIndex: Int,
|
||||
x: Any?,
|
||||
scaleOrLength: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnIndex: Int, x: Any?) {
|
||||
override fun updateObject(
|
||||
columnIndex: Int,
|
||||
x: Any?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnLabel: String?, x: Any?, scaleOrLength: Int) {
|
||||
override fun updateObject(
|
||||
columnLabel: String?,
|
||||
x: Any?,
|
||||
scaleOrLength: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnLabel: String?, x: Any?) {
|
||||
override fun updateObject(
|
||||
columnLabel: String?,
|
||||
x: Any?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -422,11 +575,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
internalMove(resultSetLength + 1)
|
||||
}
|
||||
|
||||
override fun updateLong(columnIndex: Int, x: Long) {
|
||||
override fun updateLong(
|
||||
columnIndex: Int,
|
||||
x: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateLong(columnLabel: String?, x: Long) {
|
||||
override fun updateLong(
|
||||
columnLabel: String?,
|
||||
x: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -440,27 +599,47 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnIndex: Int, x: Clob?) {
|
||||
override fun updateClob(
|
||||
columnIndex: Int,
|
||||
x: Clob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnLabel: String?, x: Clob?) {
|
||||
override fun updateClob(
|
||||
columnLabel: String?,
|
||||
x: Clob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnIndex: Int, reader: Reader?, length: Long) {
|
||||
override fun updateClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnIndex: Int, reader: Reader?) {
|
||||
override fun updateClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -480,19 +659,31 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as String?
|
||||
}
|
||||
|
||||
override fun updateSQLXML(columnIndex: Int, xmlObject: SQLXML?) {
|
||||
override fun updateSQLXML(
|
||||
columnIndex: Int,
|
||||
xmlObject: SQLXML?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateSQLXML(columnLabel: String?, xmlObject: SQLXML?) {
|
||||
override fun updateSQLXML(
|
||||
columnLabel: String?,
|
||||
xmlObject: SQLXML?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateDate(columnIndex: Int, x: Date?) {
|
||||
override fun updateDate(
|
||||
columnIndex: Int,
|
||||
x: Date?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateDate(columnLabel: String?, x: Date?) {
|
||||
override fun updateDate(
|
||||
columnLabel: String?,
|
||||
x: Date?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -504,21 +695,33 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel)
|
||||
}
|
||||
|
||||
override fun getObject(columnIndex: Int, map: MutableMap<String, Class<*>>?): Any {
|
||||
override fun getObject(
|
||||
columnIndex: Int,
|
||||
map: MutableMap<String, Class<*>>?,
|
||||
): Any {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getObject(columnLabel: String?, map: MutableMap<String, Class<*>>?): Any {
|
||||
override fun getObject(
|
||||
columnLabel: String?,
|
||||
map: MutableMap<String, Class<*>>?,
|
||||
): Any {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun <T : Any?> getObject(columnIndex: Int, type: Class<T>?): T {
|
||||
override fun <T : Any?> getObject(
|
||||
columnIndex: Int,
|
||||
type: Class<T>?,
|
||||
): T {
|
||||
return obj(columnIndex) as T
|
||||
}
|
||||
|
||||
override fun <T : Any?> getObject(columnLabel: String?, type: Class<T>?): T {
|
||||
override fun <T : Any?> getObject(
|
||||
columnLabel: String?,
|
||||
type: Class<T>?,
|
||||
): T {
|
||||
return obj(columnLabel) as T
|
||||
}
|
||||
|
||||
@@ -527,11 +730,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursorValid()
|
||||
}
|
||||
|
||||
override fun updateDouble(columnIndex: Int, x: Double) {
|
||||
override fun updateDouble(
|
||||
columnIndex: Int,
|
||||
x: Double,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateDouble(columnLabel: String?, x: Double) {
|
||||
override fun updateDouble(
|
||||
columnLabel: String?,
|
||||
x: Double,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -565,35 +774,61 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnIndex: Int, x: Blob?) {
|
||||
override fun updateBlob(
|
||||
columnIndex: Int,
|
||||
x: Blob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnLabel: String?, x: Blob?) {
|
||||
override fun updateBlob(
|
||||
columnLabel: String?,
|
||||
x: Blob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnIndex: Int, inputStream: InputStream?, length: Long) {
|
||||
override fun updateBlob(
|
||||
columnIndex: Int,
|
||||
inputStream: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnLabel: String?, inputStream: InputStream?, length: Long) {
|
||||
override fun updateBlob(
|
||||
columnLabel: String?,
|
||||
inputStream: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnIndex: Int, inputStream: InputStream?) {
|
||||
override fun updateBlob(
|
||||
columnIndex: Int,
|
||||
inputStream: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnLabel: String?, inputStream: InputStream?) {
|
||||
override fun updateBlob(
|
||||
columnLabel: String?,
|
||||
inputStream: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateByte(columnIndex: Int, x: Byte) {
|
||||
override fun updateByte(
|
||||
columnIndex: Int,
|
||||
x: Byte,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateByte(columnLabel: String?, x: Byte) {
|
||||
override fun updateByte(
|
||||
columnLabel: String?,
|
||||
x: Byte,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -627,11 +862,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateString(columnIndex: Int, x: String?) {
|
||||
override fun updateString(
|
||||
columnIndex: Int,
|
||||
x: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateString(columnLabel: String?, x: String?) {
|
||||
override fun updateString(
|
||||
columnLabel: String?,
|
||||
x: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -651,11 +892,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursor - 1 < resultSetLength
|
||||
}
|
||||
|
||||
override fun updateBoolean(columnIndex: Int, x: Boolean) {
|
||||
override fun updateBoolean(
|
||||
columnIndex: Int,
|
||||
x: Boolean,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBoolean(columnLabel: String?, x: Boolean) {
|
||||
override fun updateBoolean(
|
||||
columnLabel: String?,
|
||||
x: Boolean,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -665,11 +912,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
override fun rowUpdated() = false
|
||||
|
||||
override fun updateBigDecimal(columnIndex: Int, x: BigDecimal?) {
|
||||
override fun updateBigDecimal(
|
||||
columnIndex: Int,
|
||||
x: BigDecimal?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBigDecimal(columnLabel: String?, x: BigDecimal?) {
|
||||
override fun updateBigDecimal(
|
||||
columnLabel: String?,
|
||||
x: BigDecimal?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -689,11 +942,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return getBinaryStream(columnLabel)
|
||||
}
|
||||
|
||||
override fun updateTime(columnIndex: Int, x: Time?) {
|
||||
override fun updateTime(
|
||||
columnIndex: Int,
|
||||
x: Time?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateTime(columnLabel: String?, x: Time?) {
|
||||
override fun updateTime(
|
||||
columnLabel: String?,
|
||||
x: Time?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -707,12 +966,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnIndex: Int, cal: Calendar?): Timestamp {
|
||||
override fun getTimestamp(
|
||||
columnIndex: Int,
|
||||
cal: Calendar?,
|
||||
): Timestamp {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnLabel: String?, cal: Calendar?): Timestamp {
|
||||
override fun getTimestamp(
|
||||
columnLabel: String?,
|
||||
cal: Calendar?,
|
||||
): Timestamp {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -729,11 +994,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
override fun getConcurrency() = ResultSet.CONCUR_READ_ONLY
|
||||
|
||||
override fun updateRowId(columnIndex: Int, x: RowId?) {
|
||||
override fun updateRowId(
|
||||
columnIndex: Int,
|
||||
x: RowId?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateRowId(columnLabel: String?, x: RowId?) {
|
||||
override fun updateRowId(
|
||||
columnLabel: String?,
|
||||
x: RowId?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -745,11 +1016,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return getBinaryStream(columnLabel).reader()
|
||||
}
|
||||
|
||||
override fun updateArray(columnIndex: Int, x: Array?) {
|
||||
override fun updateArray(
|
||||
columnIndex: Int,
|
||||
x: Array?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateArray(columnLabel: String?, x: Array?) {
|
||||
override fun updateArray(
|
||||
columnLabel: String?,
|
||||
x: Array?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -814,9 +1091,13 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
override fun getMetaData(): ResultSetMetaData {
|
||||
return object : ResultSetMetaData by parentMetadata {
|
||||
override fun isReadOnly(column: Int) = true
|
||||
|
||||
override fun isWritable(column: Int) = false
|
||||
|
||||
override fun isDefinitelyWritable(column: Int) = false
|
||||
|
||||
override fun getColumnCount() = this@ScrollableResultSet.columnCount
|
||||
|
||||
override fun getColumnLabel(column: Int): String {
|
||||
return columnLabels[column - 1]
|
||||
}
|
||||
@@ -831,27 +1112,49 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return (obj(columnLabel) as ByteArray).inputStream()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnIndex: Int, x: Reader?, length: Int) {
|
||||
override fun updateCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnLabel: String?, reader: Reader?, length: Int) {
|
||||
override fun updateCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnIndex: Int, x: Reader?, length: Long) {
|
||||
override fun updateCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnIndex: Int, x: Reader?) {
|
||||
override fun updateCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,10 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
return preferences.keys.associateWith { preferences.getStringOrNull(it) }.toMutableMap()
|
||||
}
|
||||
|
||||
override fun getString(key: String, defValue: String?): String? {
|
||||
override fun getString(
|
||||
key: String,
|
||||
defValue: String?,
|
||||
): String? {
|
||||
return if (defValue != null) {
|
||||
preferences.getString(key, defValue)
|
||||
} else {
|
||||
@@ -39,7 +42,10 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getStringSet(key: String, defValues: Set<String>?): Set<String>? {
|
||||
override fun getStringSet(
|
||||
key: String,
|
||||
defValues: Set<String>?,
|
||||
): Set<String>? {
|
||||
try {
|
||||
return if (defValues != null) {
|
||||
preferences.decodeValue(SetSerializer(String.serializer()), key, defValues)
|
||||
@@ -51,19 +57,31 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInt(key: String, defValue: Int): Int {
|
||||
override fun getInt(
|
||||
key: String,
|
||||
defValue: Int,
|
||||
): Int {
|
||||
return preferences.getInt(key, defValue)
|
||||
}
|
||||
|
||||
override fun getLong(key: String, defValue: Long): Long {
|
||||
override fun getLong(
|
||||
key: String,
|
||||
defValue: Long,
|
||||
): Long {
|
||||
return preferences.getLong(key, defValue)
|
||||
}
|
||||
|
||||
override fun getFloat(key: String, defValue: Float): Float {
|
||||
override fun getFloat(
|
||||
key: String,
|
||||
defValue: Float,
|
||||
): Float {
|
||||
return preferences.getFloat(key, defValue)
|
||||
}
|
||||
|
||||
override fun getBoolean(key: String, defValue: Boolean): Boolean {
|
||||
override fun getBoolean(
|
||||
key: String,
|
||||
defValue: Boolean,
|
||||
): Boolean {
|
||||
return preferences.getBoolean(key, defValue)
|
||||
}
|
||||
|
||||
@@ -80,11 +98,15 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
|
||||
private sealed class Action {
|
||||
data class Add(val key: String, val value: Any) : Action()
|
||||
|
||||
data class Remove(val key: String) : Action()
|
||||
object Clear : Action()
|
||||
}
|
||||
|
||||
override fun putString(key: String, value: String?): SharedPreferences.Editor {
|
||||
override fun putString(
|
||||
key: String,
|
||||
value: String?,
|
||||
): SharedPreferences.Editor {
|
||||
if (value != null) {
|
||||
actions += Action.Add(key, value)
|
||||
} else {
|
||||
@@ -95,7 +117,7 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
|
||||
override fun putStringSet(
|
||||
key: String,
|
||||
values: MutableSet<String>?
|
||||
values: MutableSet<String>?,
|
||||
): SharedPreferences.Editor {
|
||||
if (values != null) {
|
||||
actions += Action.Add(key, values)
|
||||
@@ -105,22 +127,34 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putInt(key: String, value: Int): SharedPreferences.Editor {
|
||||
override fun putInt(
|
||||
key: String,
|
||||
value: Int,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putLong(key: String, value: Long): SharedPreferences.Editor {
|
||||
override fun putLong(
|
||||
key: String,
|
||||
value: Long,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putFloat(key: String, value: Float): SharedPreferences.Editor {
|
||||
override fun putFloat(
|
||||
key: String,
|
||||
value: Float,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putBoolean(key: String, value: Boolean): SharedPreferences.Editor {
|
||||
override fun putBoolean(
|
||||
key: String,
|
||||
value: Boolean,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
@@ -148,15 +182,16 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
actions.forEach {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
when (it) {
|
||||
is Action.Add -> when (val value = it.value) {
|
||||
is Set<*> -> preferences.encodeValue(SetSerializer(String.serializer()), it.key, value as Set<String>)
|
||||
is String -> preferences.putString(it.key, value)
|
||||
is Int -> preferences.putInt(it.key, value)
|
||||
is Long -> preferences.putLong(it.key, value)
|
||||
is Float -> preferences.putFloat(it.key, value)
|
||||
is Double -> preferences.putDouble(it.key, value)
|
||||
is Boolean -> preferences.putBoolean(it.key, value)
|
||||
}
|
||||
is Action.Add ->
|
||||
when (val value = it.value) {
|
||||
is Set<*> -> preferences.encodeValue(SetSerializer(String.serializer()), it.key, value as Set<String>)
|
||||
is String -> preferences.putString(it.key, value)
|
||||
is Int -> preferences.putInt(it.key, value)
|
||||
is Long -> preferences.putLong(it.key, value)
|
||||
is Float -> preferences.putFloat(it.key, value)
|
||||
is Double -> preferences.putDouble(it.key, value)
|
||||
is Boolean -> preferences.putBoolean(it.key, value)
|
||||
}
|
||||
is Action.Remove -> {
|
||||
preferences.remove(it.key)
|
||||
/**
|
||||
@@ -178,9 +213,10 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
|
||||
override fun registerOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
val javaListener = PreferenceChangeListener {
|
||||
listener.onSharedPreferenceChanged(this, it.key)
|
||||
}
|
||||
val javaListener =
|
||||
PreferenceChangeListener {
|
||||
listener.onSharedPreferenceChanged(this, it.key)
|
||||
}
|
||||
listeners[listener] = javaListener
|
||||
javaPreferences.addPreferenceChangeListener(javaListener)
|
||||
}
|
||||
|
||||
@@ -20,42 +20,47 @@ data class InstalledPackage(val root: File) {
|
||||
val icon = File(root, "icon.png")
|
||||
|
||||
val info: PackageInfo
|
||||
get() = ApkParsers.getMetaInfo(apk).toPackageInfo(apk).also {
|
||||
val parsed = ApkFile(apk)
|
||||
val dbFactory = DocumentBuilderFactory.newInstance()
|
||||
val dBuilder = dbFactory.newDocumentBuilder()
|
||||
val doc = parsed.manifestXml.byteInputStream().use {
|
||||
dBuilder.parse(it)
|
||||
get() =
|
||||
ApkParsers.getMetaInfo(apk).toPackageInfo(apk).also {
|
||||
val parsed = ApkFile(apk)
|
||||
val dbFactory = DocumentBuilderFactory.newInstance()
|
||||
val dBuilder = dbFactory.newDocumentBuilder()
|
||||
val doc =
|
||||
parsed.manifestXml.byteInputStream().use {
|
||||
dBuilder.parse(it)
|
||||
}
|
||||
|
||||
it.applicationInfo.metaData =
|
||||
Bundle().apply {
|
||||
val appTag = doc.getElementsByTagName("application").item(0)
|
||||
|
||||
appTag?.childNodes?.toList()?.filter {
|
||||
it.nodeType == Node.ELEMENT_NODE
|
||||
}?.map {
|
||||
it as Element
|
||||
}?.filter {
|
||||
it.tagName == "meta-data"
|
||||
}?.map {
|
||||
putString(
|
||||
it.attributes.getNamedItem("android:name").nodeValue,
|
||||
it.attributes.getNamedItem("android:value").nodeValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
it.signatures =
|
||||
(
|
||||
parsed.apkSingers.flatMap { it.certificateMetas }
|
||||
// + parsed.apkV2Singers.flatMap { it.certificateMetas }
|
||||
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||
.map { Signature(it.data) }.toTypedArray()
|
||||
}
|
||||
|
||||
it.applicationInfo.metaData = Bundle().apply {
|
||||
val appTag = doc.getElementsByTagName("application").item(0)
|
||||
|
||||
appTag?.childNodes?.toList()?.filter {
|
||||
it.nodeType == Node.ELEMENT_NODE
|
||||
}?.map {
|
||||
it as Element
|
||||
}?.filter {
|
||||
it.tagName == "meta-data"
|
||||
}?.map {
|
||||
putString(
|
||||
it.attributes.getNamedItem("android:name").nodeValue,
|
||||
it.attributes.getNamedItem("android:value").nodeValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
it.signatures = (
|
||||
parsed.apkSingers.flatMap { it.certificateMetas }
|
||||
/*+ parsed.apkV2Singers.flatMap { it.certificateMetas }*/
|
||||
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||
.map { Signature(it.data) }.toTypedArray()
|
||||
}
|
||||
|
||||
fun verify(): Boolean {
|
||||
val res = ApkVerifier.Builder(apk)
|
||||
.build()
|
||||
.verify()
|
||||
val res =
|
||||
ApkVerifier.Builder(apk)
|
||||
.build()
|
||||
.verify()
|
||||
|
||||
return res.isVerified
|
||||
}
|
||||
@@ -64,11 +69,12 @@ data class InstalledPackage(val root: File) {
|
||||
try {
|
||||
val icons = ApkFile(apk).allIcons
|
||||
|
||||
val read = icons.filter { it.isFile }.map {
|
||||
it.data.inputStream().use {
|
||||
ImageIO.read(it)
|
||||
}
|
||||
}.sortedByDescending { it.width * it.height }.firstOrNull() ?: return
|
||||
val read =
|
||||
icons.filter { it.isFile }.map {
|
||||
it.data.inputStream().use {
|
||||
ImageIO.read(it)
|
||||
}
|
||||
}.sortedByDescending { it.width * it.height }.firstOrNull() ?: return
|
||||
|
||||
ImageIO.write(read, "png", icon)
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -25,7 +25,10 @@ class PackageController {
|
||||
return File(androidFiles.packagesDir, pn)
|
||||
}
|
||||
|
||||
fun installPackage(apk: File, allowReinstall: Boolean) {
|
||||
fun installPackage(
|
||||
apk: File,
|
||||
allowReinstall: Boolean,
|
||||
) {
|
||||
val root = findRoot(apk)
|
||||
|
||||
if (root.exists()) {
|
||||
|
||||
@@ -12,16 +12,18 @@ fun ApkMeta.toPackageInfo(apk: File): PackageInfo {
|
||||
it.versionCode = versionCode.toInt()
|
||||
it.versionName = versionName
|
||||
|
||||
it.reqFeatures = usesFeatures.map {
|
||||
FeatureInfo().apply {
|
||||
name = it.name
|
||||
}
|
||||
}.toTypedArray()
|
||||
it.reqFeatures =
|
||||
usesFeatures.map {
|
||||
FeatureInfo().apply {
|
||||
name = it.name
|
||||
}
|
||||
}.toTypedArray()
|
||||
|
||||
it.applicationInfo = ApplicationInfo().apply {
|
||||
packageName = it.packageName
|
||||
nonLocalizedLabel = label
|
||||
sourceDir = apk.absolutePath
|
||||
}
|
||||
it.applicationInfo =
|
||||
ApplicationInfo().apply {
|
||||
packageName = it.packageName
|
||||
nonLocalizedLabel = label
|
||||
sourceDir = apk.absolutePath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ class ServiceSupport {
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
fun startService(@Suppress("UNUSED_PARAMETER") context: Context, intent: Intent) {
|
||||
fun startService(
|
||||
@Suppress("UNUSED_PARAMETER") context: Context,
|
||||
intent: Intent,
|
||||
) {
|
||||
val name = intentToClassName(intent)
|
||||
|
||||
logger.debug { "Starting service: $name" }
|
||||
@@ -35,7 +38,10 @@ class ServiceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
fun stopService(@Suppress("UNUSED_PARAMETER") context: Context, intent: Intent) {
|
||||
fun stopService(
|
||||
@Suppress("UNUSED_PARAMETER") context: Context,
|
||||
intent: Intent,
|
||||
) {
|
||||
val name = intentToClassName(intent)
|
||||
stopService(name)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,10 @@ object KodeinGlobalHelper {
|
||||
*/
|
||||
@JvmStatic
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : Any> instance(type: Class<T>, kodein: DI? = null): T {
|
||||
fun <T : Any> instance(
|
||||
type: Class<T>,
|
||||
kodein: DI? = null,
|
||||
): T {
|
||||
return when (type) {
|
||||
AndroidFiles::class.java -> {
|
||||
val instance: AndroidFiles by (kodein ?: kodein()).instance()
|
||||
|
||||
@@ -24,5 +24,7 @@ import java.net.URI
|
||||
* Utilites to convert between Java and Android Uris.
|
||||
*/
|
||||
fun Uri.java() = URI(this.toString())
|
||||
|
||||
fun Uri.file() = File(this.path)
|
||||
|
||||
fun URI.android() = Uri.parse(this.toString())!!
|
||||
|
||||
@@ -22,7 +22,10 @@ class CookieManagerImpl : CookieManager() {
|
||||
return acceptCookie
|
||||
}
|
||||
|
||||
override fun setAcceptThirdPartyCookies(webview: WebView?, accept: Boolean) {
|
||||
override fun setAcceptThirdPartyCookies(
|
||||
webview: WebView?,
|
||||
accept: Boolean,
|
||||
) {
|
||||
acceptThirdPartyCookies = accept
|
||||
}
|
||||
|
||||
@@ -30,29 +33,38 @@ class CookieManagerImpl : CookieManager() {
|
||||
return acceptThirdPartyCookies
|
||||
}
|
||||
|
||||
override fun setCookie(url: String, value: String?) {
|
||||
val uri = if (url.startsWith("http")) {
|
||||
URI(url)
|
||||
} else {
|
||||
URI("http://$url")
|
||||
}
|
||||
override fun setCookie(
|
||||
url: String,
|
||||
value: String?,
|
||||
) {
|
||||
val uri =
|
||||
if (url.startsWith("http")) {
|
||||
URI(url)
|
||||
} else {
|
||||
URI("http://$url")
|
||||
}
|
||||
|
||||
HttpCookie.parse(value).forEach {
|
||||
cookieHandler.cookieStore.add(uri, it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setCookie(url: String, value: String?, callback: ValueCallback<Boolean>?) {
|
||||
override fun setCookie(
|
||||
url: String,
|
||||
value: String?,
|
||||
callback: ValueCallback<Boolean>?,
|
||||
) {
|
||||
setCookie(url, value)
|
||||
callback?.onReceiveValue(true)
|
||||
}
|
||||
|
||||
override fun getCookie(url: String): String {
|
||||
val uri = if (url.startsWith("http")) {
|
||||
URI(url)
|
||||
} else {
|
||||
URI("http://$url")
|
||||
}
|
||||
val uri =
|
||||
if (url.startsWith("http")) {
|
||||
URI(url)
|
||||
} else {
|
||||
URI("http://$url")
|
||||
}
|
||||
return cookieHandler.cookieStore.get(uri)
|
||||
.joinToString("; ") { "${it.name}=${it.value}" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user