Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class RepositoryUpdaterTest {
updated = 1735315749835,
timestamp = 1725352450000,
authentication = "",
icon = "izzy-on-droid.png",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ object IndexV1Parser {
name: String,
description: String,
version: Int,
timestamp: Long
timestamp: Long,
icon: String,
)

fun onProduct(product: Product)
Expand Down Expand Up @@ -163,6 +164,7 @@ object IndexV1Parser {
private const val KEY_REPO_DESC = "description"
private const val KEY_REPO_VER = "version"
private const val KEY_REPO_TIME = "timestamp"
private const val KEY_REPO_ICON = "icon"

fun parse(repositoryId: Long, inputStream: InputStream, callback: Callback) {
val jsonParser = Json.factory.createParser(inputStream)
Expand All @@ -178,6 +180,7 @@ object IndexV1Parser {
var description = ""
var version = 0
var timestamp = 0L
var icon = ""
forEachKey {
when {
it.string(KEY_REPO_ADDRESS) -> address = valueAsString
Expand All @@ -188,6 +191,7 @@ object IndexV1Parser {
it.string(KEY_REPO_DESC) -> description = valueAsString
it.number(KEY_REPO_VER) -> version = valueAsInt
it.number(KEY_REPO_TIME) -> timestamp = valueAsLong
it.number(KEY_REPO_ICON) -> icon = valueAsString
else -> skipChildren()
}
}
Expand All @@ -203,7 +207,8 @@ object IndexV1Parser {
name = name,
description = description,
version = version,
timestamp = timestamp
timestamp = timestamp,
icon = icon,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ object RepositoryUpdater {
description: String,
version: Int,
timestamp: Long,
icon: String,
) {
changedRepository = repository.update(
mirrors,
Expand All @@ -271,6 +272,7 @@ object RepositoryUpdater {
lastModified,
entityTag,
timestamp,
icon,
)
}

Expand Down
8 changes: 6 additions & 2 deletions app/src/main/kotlin/com/looker/droidify/model/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data class Repository(
val updated: Long,
val timestamp: Long,
val authentication: String,
val icon: String,
) {

fun edit(address: String, fingerprint: String, authentication: String): Repository {
Expand All @@ -39,6 +40,7 @@ data class Repository(
lastModified: String,
entityTag: String,
timestamp: Long,
icon: String,
): Repository {
return copy(
mirrors = mirrors,
Expand All @@ -48,7 +50,8 @@ data class Repository(
lastModified = lastModified,
entityTag = entityTag,
updated = System.currentTimeMillis(),
timestamp = timestamp
timestamp = timestamp,
icon = icon,
)
}

Expand Down Expand Up @@ -80,10 +83,11 @@ data class Repository(
enabled: Boolean = false,
fingerprint: String,
authentication: String = "",
icon: String = "",
): Repository {
return Repository(
-1, address, emptyList(), name, description, version, enabled,
fingerprint, "", "", 0L, 0L, authentication
fingerprint, "", "", 0L, 0L, authentication, icon
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fun Repository.serialize(generator: JsonGenerator) {
generator.writeNumberField("updated", updated)
generator.writeNumberField("timestamp", timestamp)
generator.writeStringField("authentication", authentication)
generator.writeStringField("icon", icon)
}

fun JsonParser.repository(): Repository {
Expand All @@ -38,6 +39,7 @@ fun JsonParser.repository(): Repository {
var updated = 0L
var timestamp = 0L
var authentication = ""
var icon = ""
forEachKey {
when {
it.string("id") -> id = valueAsLong
Expand All @@ -53,11 +55,12 @@ fun JsonParser.repository(): Repository {
it.number("updated") -> updated = valueAsLong
it.number("timestamp") -> timestamp = valueAsLong
it.string("authentication") -> authentication = valueAsString
it.string("icon") -> icon = valueAsString
else -> skipChildren()
}
}
return Repository(
id, address, mirrors, name, description, version, enabled, fingerprint,
lastModified, entityTag, updated, timestamp, authentication
lastModified, entityTag, updated, timestamp, authentication, icon
)
}