Created a different layout to show the map pin's markers for tellers and merchants. Added more fields to the tellers db table, to include the newly added in the V2 of the webservice: Keybase, Whatsapp, Viber and Email and created a db migration to reflect that. Added the code to show the teller's newly added fields to the pin's markers if such fields exist and hide that field otherwise.

master
Severiano Jaramillo 2019-04-25 21:14:42 -05:00
parent 8af2042039
commit 23d2cd6836
6 changed files with 577 additions and 4 deletions

View File

@ -0,0 +1,445 @@
{
"formatVersion": 1,
"database": {
"version": 4,
"identityHash": "4614e60ba10b66b28349657f75320694",
"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, `issuer` TEXT NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "symbol",
"columnName": "symbol",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "precision",
"columnName": "precision",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "description",
"columnName": "description",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "issuer",
"columnName": "issuer",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "authorities",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `user_id` TEXT NOT NULL, `authority_type` INTEGER NOT NULL, `encrypted_wif` TEXT NOT NULL, `encrypted_brain_key` TEXT NOT NULL, `encrypted_sequence_number` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "userId",
"columnName": "user_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "authorityType",
"columnName": "authority_type",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "encryptedWIF",
"columnName": "encrypted_wif",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "encryptedBrainKey",
"columnName": "encrypted_brain_key",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "encryptedSequenceNumber",
"columnName": "encrypted_sequence_number",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "balances",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`asset_id` TEXT NOT NULL, `asset_amount` INTEGER NOT NULL, `last_update` INTEGER NOT NULL, PRIMARY KEY(`asset_id`))",
"fields": [
{
"fieldPath": "assetId",
"columnName": "asset_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "assetAmount",
"columnName": "asset_amount",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "lastUpdate",
"columnName": "last_update",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"asset_id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "equivalent_values",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`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`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
"fields": [
{
"fieldPath": "transferId",
"columnName": "transfer_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "value",
"columnName": "value",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "symbol",
"columnName": "symbol",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"transfer_id",
"symbol"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": [
{
"table": "transfers",
"onDelete": "NO ACTION",
"onUpdate": "NO ACTION",
"columns": [
"transfer_id"
],
"referencedColumns": [
"id"
]
}
]
},
{
"tableName": "transfers",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `block_number` INTEGER NOT NULL, `timestamp` INTEGER NOT NULL, `fee_amount` INTEGER NOT NULL, `fee_asset_id` TEXT NOT NULL, `source` TEXT NOT NULL, `destination` TEXT NOT NULL, `transfer_amount` INTEGER NOT NULL, `transfer_asset_id` TEXT NOT NULL, `memo` TEXT NOT NULL, `bts_value` INTEGER, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "blockNumber",
"columnName": "block_number",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "timestamp",
"columnName": "timestamp",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "feeAmount",
"columnName": "fee_amount",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "feeAssetId",
"columnName": "fee_asset_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "source",
"columnName": "source",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "destination",
"columnName": "destination",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "transferAmount",
"columnName": "transfer_amount",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "transferAssetId",
"columnName": "transfer_asset_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "memo",
"columnName": "memo",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "btsValue",
"columnName": "bts_value",
"affinity": "INTEGER",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "user_accounts",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `is_ltm` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "isLtm",
"columnName": "is_ltm",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "merchants",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `address` TEXT, `lat` REAL NOT NULL, `lon` REAL NOT NULL, `phone` TEXT, `telegram` TEXT, `website` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "_id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "address",
"columnName": "address",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "lat",
"columnName": "lat",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "lon",
"columnName": "lon",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "phone",
"columnName": "phone",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "telegram",
"columnName": "telegram",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "website",
"columnName": "website",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "tellers",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL, `address` TEXT, `lat` REAL NOT NULL, `lon` REAL NOT NULL, `phone` TEXT, `telegram` TEXT, `keybase` TEXT, `whatsapp` TEXT, `viber` TEXT, `email` TEXT, `website` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "_id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "gt_name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "address",
"columnName": "address",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "lat",
"columnName": "lat",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "lon",
"columnName": "lon",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "phone",
"columnName": "phone",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "telegram",
"columnName": "telegram",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "keybase",
"columnName": "keybase",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "whatsapp",
"columnName": "whatsapp",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "viber",
"columnName": "viber",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "email",
"columnName": "email",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "url",
"columnName": "website",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"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, \"4614e60ba10b66b28349657f75320694\")"
]
}
}

View File

@ -21,7 +21,7 @@ import cy.agorise.bitsybitshareswallet.database.joins.TransferDetailDao
Merchant::class,
Teller::class
],
version = 3,
version = 4,
exportSchema = true)
abstract class BitsyDatabase : RoomDatabase() {
abstract fun assetDao(): AssetDao
@ -49,6 +49,7 @@ abstract class BitsyDatabase : RoomDatabase() {
BitsyDatabase::class.java, "BiTSyWallet.db"
).addMigrations(MIGRATION_1_2)
.addMigrations(MIGRATION_2_3)
.addMigrations(MIGRATION_3_4)
.build()
}
}
@ -76,5 +77,12 @@ abstract class BitsyDatabase : RoomDatabase() {
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`))")
}
}
val MIGRATION_3_4 = object : Migration(3,4) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("DROP TABLE tellers")
database.execSQL("CREATE TABLE IF NOT EXISTS tellers (id TEXT NOT NULL PRIMARY KEY, name TEXT NOT NULL, address TEXT, lat REAL NOT NULL, lon REAL NOT NULL, phone TEXT, telegram TEXT, keybase TEXT, whatsapp TEXT, viber TEXT, email TEXT, website TEXT)")
}
}
}
}

View File

@ -16,6 +16,10 @@ data class Teller(
@ColumnInfo(name = "lon") val lon: Double,
@ColumnInfo(name = "phone") val phone: String?,
@ColumnInfo(name = "telegram") val telegram: String?,
@ColumnInfo(name = "keybase") val keybase: String?,
@ColumnInfo(name = "whatsapp") val whatsapp: String?,
@ColumnInfo(name = "viber") val viber: String?,
@ColumnInfo(name = "email") val email: String?,
@ColumnInfo(name = "website") val url: String?
) : ClusterItem {
override fun getSnippet(): String {

View File

@ -157,7 +157,7 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
}
private fun setupPopupWindow() {
val popupView = layoutInflater?.inflate(R.layout.popup_menu_merchants, null, false)
val popupView = layoutInflater.inflate(R.layout.popup_menu_merchants, null, false)
val switchMerchants = popupView?.findViewById<SwitchCompat>(R.id.switchMerchants)
switchMerchants?.isChecked = showMerchantsMarkers
@ -512,7 +512,7 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
override fun getInfoWindow(marker: Marker?): View {
val infoWindowLayout: View = LayoutInflater.from(context).inflate(
R.layout.marker_info_window, null)
R.layout.marker_merch_info_window, null)
val tvName = infoWindowLayout.findViewById<TextView>(R.id.tvName)
val tvAddress = infoWindowLayout.findViewById<TextView>(R.id.tvAddress)
val tvPhone = infoWindowLayout.findViewById<TextView>(R.id.tvPhone)
@ -557,11 +557,15 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
override fun getInfoWindow(marker: Marker?): View {
val infoWindowLayout: View = LayoutInflater.from(context).inflate(
R.layout.marker_info_window, null)
R.layout.marker_teller_info_window, null)
val tvName = infoWindowLayout.findViewById<TextView>(R.id.tvName)
val tvAddress = infoWindowLayout.findViewById<TextView>(R.id.tvAddress)
val tvPhone = infoWindowLayout.findViewById<TextView>(R.id.tvPhone)
val tvTelegram = infoWindowLayout.findViewById<TextView>(R.id.tvTelegram)
val tvKeybase = infoWindowLayout.findViewById<TextView>(R.id.tvKeybase)
val tvWhatsapp = infoWindowLayout.findViewById<TextView>(R.id.tvWhatsapp)
val tvViber = infoWindowLayout.findViewById<TextView>(R.id.tvViber)
val tvEmail = infoWindowLayout.findViewById<TextView>(R.id.tvEmail)
val tvWebsite = infoWindowLayout.findViewById<TextView>(R.id.tvWebsite)
if (selectedTeller != null) {
@ -583,6 +587,30 @@ class MerchantsFragment : Fragment(), OnMapReadyCallback, SearchView.OnSuggestio
} else
tvTelegram.visibility = View.GONE
if (!selectedTeller?.keybase.equals("")) {
val keybase = "Keybase: ${selectedTeller?.keybase}"
tvKeybase.text = keybase
} else
tvKeybase.visibility = View.GONE
if (!selectedTeller?.whatsapp.equals("")) {
val whatsapp = "WhatsApp: ${selectedTeller?.whatsapp}"
tvWhatsapp.text = whatsapp
} else
tvWhatsapp.visibility = View.GONE
if (!selectedTeller?.viber.equals("")) {
val viber = "Viber: ${selectedTeller?.viber}"
tvViber.text = viber
} else
tvViber.visibility = View.GONE
if (!selectedTeller?.email.equals("")) {
val email = "Email: ${selectedTeller?.email}"
tvEmail.text = email
} else
tvEmail.visibility = View.GONE
if (!selectedTeller?.url.equals(""))
tvWebsite.text = selectedTeller?.url
?.removePrefix("http://")?.removePrefix("https://")

View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="12dp"
android:background="@drawable/marker_info_window_background">
<TextView
android:id="@+id/tvName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Hareem Haque"
android:textAppearance="@style/TextAppearance.Bitsy.Body1"/>
<TextView
android:id="@+id/tvAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Toronto, Ontario, Canada"/>
<TextView
android:id="@+id/tvPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="1-647-518-4916"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvTelegram"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Telegram: \@gridcenter"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvKeybase"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Viber: \@gridcenter"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvWhatsapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Whatsapp: 1-647-518-4916"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvViber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Telegram: \@gridcenter"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Email: hareem.haque\@outlook.com"
android:maxLines="1"
android:ellipsize="end"/>
<TextView
android:id="@+id/tvWebsite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="Bambuddha.com.mx"
android:maxLines="1"
android:ellipsize="end"/>
</LinearLayout>