From 535796b0be9389eb8f4bf215c29d9f408559ab91 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 31 Jan 2019 17:59:14 -0600 Subject: [PATCH] Change the db assets table to include the issuer column, and provide the db migration. --- .../3.json | 10 +++++----- .../activities/ConnectedActivity.kt | 2 +- .../bitsybitshareswallet/activities/MainActivity.kt | 2 +- .../bitsybitshareswallet/database/BitsyDatabase.kt | 3 +++ .../bitsybitshareswallet/database/daos/AssetDao.kt | 2 +- .../bitsybitshareswallet/database/entities/Asset.kt | 2 +- .../fragments/ReceiveTransactionFragment.kt | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json b/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json index 7e0f04c..3b68ce6 100644 --- a/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json +++ b/app/schemas/cy.agorise.bitsybitshareswallet.database.BitsyDatabase/3.json @@ -2,11 +2,11 @@ "formatVersion": 1, "database": { "version": 3, - "identityHash": "36ac924b7b8d78fb2d937d1ff9ba8897", + "identityHash": "5b34bbcb2a3774fb9db64655b7217bbc", "entities": [ { "tableName": "assets", - "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `symbol` TEXT NOT NULL, `precision` INTEGER NOT NULL, `description` TEXT NOT NULL, `bit_asset_id` TEXT NOT NULL, PRIMARY KEY(`id`))", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `symbol` TEXT NOT NULL, `precision` INTEGER NOT NULL, `description` TEXT NOT NULL, `issuer` TEXT NOT NULL, PRIMARY KEY(`id`))", "fields": [ { "fieldPath": "id", @@ -33,8 +33,8 @@ "notNull": true }, { - "fieldPath": "bitAssetId", - "columnName": "bit_asset_id", + "fieldPath": "issuer", + "columnName": "issuer", "affinity": "TEXT", "notNull": true } @@ -409,7 +409,7 @@ "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, \"36ac924b7b8d78fb2d937d1ff9ba8897\")" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"5b34bbcb2a3774fb9db64655b7217bbc\")" ] } } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt index ad498fa..2230daa 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/ConnectedActivity.kt @@ -304,7 +304,7 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection { _asset.symbol, _asset.precision, _asset.description ?: "", - _asset.bitassetId ?: "" + _asset.issuer ?: "" ) assets.add(asset) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt index 79a22ee..69d5656 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/activities/MainActivity.kt @@ -88,7 +88,7 @@ class MainActivity : ConnectedActivity() { } private fun startHandler() { - mHandler.postDelayed(mRunnable, 30 * 1000) //for 3 minutes + mHandler.postDelayed(mRunnable, 3 * 60 * 1000) //for 3 minutes } override fun onOptionsItemSelected(item: MenuItem): Boolean { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt index aa344b2..af507c2 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/BitsyDatabase.kt @@ -68,6 +68,9 @@ abstract class BitsyDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.execSQL("DROP TABLE 'equivalent_values'") database.execSQL("CREATE TABLE IF NOT EXISTS 'equivalent_values' ('transfer_id' TEXT NOT NULL, 'value' INTEGER NOT NULL, 'symbol' TEXT NOT NULL, PRIMARY KEY(transfer_id, symbol), FOREIGN KEY (transfer_id) REFERENCES transfers(id))") + + database.execSQL("DROP TABLE assets") + database.execSQL("CREATE TABLE IF NOT EXISTS assets (`id` TEXT NOT NULL, `symbol` TEXT NOT NULL, `precision` INTEGER NOT NULL, `description` TEXT NOT NULL, `issuer` TEXT NOT NULL, PRIMARY KEY(`id`))") } } } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/AssetDao.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/AssetDao.kt index 8de0030..275f90f 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/AssetDao.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/daos/AssetDao.kt @@ -15,6 +15,6 @@ interface AssetDao { @Insert(onConflict = OnConflictStrategy.REPLACE) fun insertAll(assets: List) - @Query("SELECT id, symbol, precision, description, bit_asset_id FROM assets INNER JOIN balances WHERE assets.id = balances.asset_id AND balances.asset_amount > 0") + @Query("SELECT id, symbol, precision, description, issuer FROM assets INNER JOIN balances WHERE assets.id = balances.asset_id AND balances.asset_amount > 0") fun getAllNonZero(): LiveData> } diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Asset.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Asset.kt index e065ac6..7963115 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Asset.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/entities/Asset.kt @@ -11,7 +11,7 @@ data class Asset( @ColumnInfo(name = "symbol") val symbol: String, @ColumnInfo(name = "precision") val precision: Int, @ColumnInfo(name = "description") val description: String, - @ColumnInfo(name = "bit_asset_id") val bitAssetId: String + @ColumnInfo(name = "issuer") val issuer: String ) { override fun toString(): String { return symbol diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt index c7cbb0b..71a0cd8 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ReceiveTransactionFragment.kt @@ -233,7 +233,7 @@ class ReceiveTransactionFragment : ConnectedFragment() { _asset.symbol, _asset.precision, _asset.description ?: "", - _asset.bitassetId ?: "" + _asset.issuer ?: "" ) assets.add(asset)