Skip to content

Commit

Permalink
Merge pull request #30 from hegocre/enhancement/favicons
Browse files Browse the repository at this point in the history
Rework password icon loading
  • Loading branch information
hegocre authored Nov 16, 2023
2 parents 3c3d1b2 + 3625dbe commit 65c4481
Show file tree
Hide file tree
Showing 14 changed files with 398 additions and 306 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
{
"formatVersion": 1,
"database": {
"version": 3,
"identityHash": "93e9a73ac790c295e6009993d8ff5c56",
"entities": [
{
"tableName": "folders",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `label` TEXT NOT NULL, `parent` TEXT NOT NULL, `revision` TEXT NOT NULL, `cseType` TEXT NOT NULL, `cseKey` TEXT NOT NULL, `sseType` TEXT NOT NULL, `client` TEXT NOT NULL, `hidden` INTEGER NOT NULL, `trashed` INTEGER NOT NULL, `favorite` INTEGER NOT NULL, `created` INTEGER NOT NULL, `updated` INTEGER NOT NULL, `edited` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "parent",
"columnName": "parent",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "revision",
"columnName": "revision",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "cseType",
"columnName": "cseType",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "cseKey",
"columnName": "cseKey",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "sseType",
"columnName": "sseType",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "client",
"columnName": "client",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "hidden",
"columnName": "hidden",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "trashed",
"columnName": "trashed",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "favorite",
"columnName": "favorite",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "created",
"columnName": "created",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updated",
"columnName": "updated",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "edited",
"columnName": "edited",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_folders_id",
"unique": true,
"columnNames": [
"id"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_folders_id` ON `${TABLE_NAME}` (`id`)"
}
],
"foreignKeys": []
},
{
"tableName": "passwords",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `label` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, `url` TEXT NOT NULL, `notes` TEXT NOT NULL, `customFields` TEXT NOT NULL, `status` INTEGER NOT NULL, `statusCode` TEXT NOT NULL, `hash` TEXT NOT NULL, `folder` TEXT NOT NULL, `revision` TEXT NOT NULL, `share` TEXT, `shared` INTEGER NOT NULL, `cseType` TEXT NOT NULL, `cseKey` TEXT NOT NULL, `sseType` TEXT NOT NULL, `client` TEXT NOT NULL, `hidden` INTEGER NOT NULL, `trashed` INTEGER NOT NULL, `favorite` INTEGER NOT NULL, `editable` INTEGER NOT NULL, `edited` INTEGER NOT NULL, `created` INTEGER NOT NULL, `updated` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "username",
"columnName": "username",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "password",
"columnName": "password",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "url",
"columnName": "url",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "notes",
"columnName": "notes",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "customFields",
"columnName": "customFields",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "status",
"columnName": "status",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "statusCode",
"columnName": "statusCode",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "hash",
"columnName": "hash",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "folder",
"columnName": "folder",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "revision",
"columnName": "revision",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "share",
"columnName": "share",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "shared",
"columnName": "shared",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "cseType",
"columnName": "cseType",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "cseKey",
"columnName": "cseKey",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "sseType",
"columnName": "sseType",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "client",
"columnName": "client",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "hidden",
"columnName": "hidden",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "trashed",
"columnName": "trashed",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "favorite",
"columnName": "favorite",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "editable",
"columnName": "editable",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "edited",
"columnName": "edited",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "created",
"columnName": "created",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "updated",
"columnName": "updated",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
},
"indices": [
{
"name": "index_passwords_id",
"unique": true,
"columnNames": [
"id"
],
"orders": [],
"createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_passwords_id` ON `${TABLE_NAME}` (`id`)"
}
],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '93e9a73ac790c295e6009993d8ff5c56')"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,6 @@ class ApiController private constructor(context: Context) {
return foldersApi.list(sessionCode)
}

/**
* Gets a favicon from a url via the [ServiceApi] class. An open session is not needed for
* this method to be called.
*
* @param url The url of the requested site favicon.
* @return A [ByteArray] with the encoded bitmap.
*/
suspend fun getFavicon(url: String): ByteArray? {
val result = serviceApi.favicon(url)
return if (result is Result.Success) {
result.data
} else {
if (result is Result.Error)
Log.d("API Controller", "Error ${result.code} requesting favicon")
null
}
}

/**
* Creates a new password via the [PasswordsApi] class. This can only be called when a
* session is open, otherwise an error is thrown.
Expand Down Expand Up @@ -322,6 +304,9 @@ class ApiController private constructor(context: Context) {
return result is Result.Success
}

fun getFaviconServiceRequest(url: String): Pair<String, Server> =
Pair(serviceApi.getFaviconUrl(url), server)

companion object {
private var instance: ApiController? = null

Expand Down
Loading

0 comments on commit 65c4481

Please sign in to comment.