diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..647cd29 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +BatteryTracker \ No newline at end of file diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..7643783 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,123 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/schemas/com.sockenklaus.batterytracker.room.BatteryTrackerDB/3.json b/app/schemas/com.sockenklaus.batterytracker.room.BatteryTrackerDB/3.json deleted file mode 100644 index a44772b..0000000 --- a/app/schemas/com.sockenklaus.batterytracker.room.BatteryTrackerDB/3.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "formatVersion": 1, - "database": { - "version": 3, - "identityHash": "e86f0253ec49cbc67a601f90d5169a8a", - "entities": [ - { - "tableName": "charges", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `charge` REAL NOT NULL, `battery_id` INTEGER NOT NULL, `date` INTEGER NOT NULL, `comment` TEXT NOT NULL DEFAULT '', `created_at` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP, `synced` INTEGER NOT NULL DEFAULT false, FOREIGN KEY(`battery_id`) REFERENCES `batteries`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )", - "fields": [ - { - "fieldPath": "id", - "columnName": "id", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "charge", - "columnName": "charge", - "affinity": "REAL", - "notNull": true - }, - { - "fieldPath": "batteryId", - "columnName": "battery_id", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "date", - "columnName": "date", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "comment", - "columnName": "comment", - "affinity": "TEXT", - "notNull": true, - "defaultValue": "''" - }, - { - "fieldPath": "createdAt", - "columnName": "created_at", - "affinity": "INTEGER", - "notNull": true, - "defaultValue": "CURRENT_TIMESTAMP" - }, - { - "fieldPath": "synced", - "columnName": "synced", - "affinity": "INTEGER", - "notNull": true, - "defaultValue": "false" - } - ], - "primaryKey": { - "columnNames": [ - "id" - ], - "autoGenerate": true - }, - "indices": [ - { - "name": "index_charges_battery_id", - "unique": false, - "columnNames": [ - "battery_id" - ], - "orders": [], - "createSql": "CREATE INDEX IF NOT EXISTS `index_charges_battery_id` ON `${TABLE_NAME}` (`battery_id`)" - } - ], - "foreignKeys": [ - { - "table": "batteries", - "onDelete": "CASCADE", - "onUpdate": "NO ACTION", - "columns": [ - "battery_id" - ], - "referencedColumns": [ - "id" - ] - } - ] - }, - { - "tableName": "batteries", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL, `declared_capacity` REAL DEFAULT NULL, `comment` TEXT NOT NULL DEFAULT '', `synced` INTEGER NOT NULL DEFAULT false, `created_at` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP)", - "fields": [ - { - "fieldPath": "id", - "columnName": "id", - "affinity": "INTEGER", - "notNull": true - }, - { - "fieldPath": "name", - "columnName": "name", - "affinity": "TEXT", - "notNull": true - }, - { - "fieldPath": "declaredCapacity", - "columnName": "declared_capacity", - "affinity": "REAL", - "notNull": false, - "defaultValue": "NULL" - }, - { - "fieldPath": "comment", - "columnName": "comment", - "affinity": "TEXT", - "notNull": true, - "defaultValue": "''" - }, - { - "fieldPath": "synced", - "columnName": "synced", - "affinity": "INTEGER", - "notNull": true, - "defaultValue": "false" - }, - { - "fieldPath": "createdAt", - "columnName": "created_at", - "affinity": "INTEGER", - "notNull": true, - "defaultValue": "CURRENT_TIMESTAMP" - } - ], - "primaryKey": { - "columnNames": [ - "id" - ], - "autoGenerate": true - }, - "indices": [], - "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, 'e86f0253ec49cbc67a601f90d5169a8a')" - ] - } -} \ No newline at end of file diff --git a/app/src/main/java/com/sockenklaus/batterytracker/room/dao/BatteryDao.kt b/app/src/main/java/com/sockenklaus/batterytracker/room/dao/BatteryDao.kt index 8807701..156ebbe 100644 --- a/app/src/main/java/com/sockenklaus/batterytracker/room/dao/BatteryDao.kt +++ b/app/src/main/java/com/sockenklaus/batterytracker/room/dao/BatteryDao.kt @@ -16,7 +16,7 @@ interface BatteryDao { @Update fun updateBattery(battery: Battery): Int - @Query("Select * FROM batteries") + @Query("Select * FROM batteries ORDER BY name ASC") fun getBatteries(): Flow> @Query("Select * FROM batteries WHERE id = :id")