From 39a8a1e4467b3ecbb2e26250f25dceb7be5f37f3 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sat, 16 Jun 2018 22:17:27 -0400 Subject: [PATCH] - Now the transactions list use first the contact name, then the bitshares account name and finally the user's account name. If none of them is useful, the bitshares account id will appear instead. --- .../java/cy/agorise/crystalwallet/dao/CrystalDatabase.java | 1 + .../java/cy/agorise/crystalwallet/dao/TransactionDao.java | 3 ++- .../models/CryptoCoinTransactionExtended.java | 7 +++++++ .../agorise/crystalwallet/views/TransactionViewHolder.java | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java index 81570ea..5db0c0f 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CrystalDatabase.java @@ -54,6 +54,7 @@ public abstract class CrystalDatabase extends RoomDatabase { public abstract CryptoCoinBalanceDao cryptoCoinBalanceDao(); public abstract CryptoCurrencyDao cryptoCurrencyDao(); public abstract BitsharesAssetDao bitsharesAssetDao(); + public abstract BitsharesAccountNameCacheDao bitsharesAccountNameCacheDao(); public abstract CryptoCurrencyEquivalenceDao cryptoCurrencyEquivalenceDao(); public abstract GeneralSettingDao generalSettingDao(); diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java index bcdca57..6e10049 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java @@ -20,9 +20,10 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransactionExtended; @Dao public interface TransactionDao { - static final String transactionsQuery = "SELECT cct.*, cna.name AS user_account_name, c.name AS contact_name FROM crypto_coin_transaction cct " + + static final String transactionsQuery = "SELECT cct.*, cna.name AS user_account_name, c.name AS contact_name, banc.name AS bitshares_account_name FROM crypto_coin_transaction cct " + "LEFT JOIN crypto_net_account cna ON cct.account_id = cna.id " + "LEFT JOIN contact c ON c.id = (SELECT ca.contact_id FROM contact_address ca WHERE ca.address LIKE (CASE is_input WHEN 1 THEN cct.\"from\" ELSE cct.\"to\" END) LIMIT 1) " + + "LEFT JOIN bitshares_account_name_cache banc ON banc.account_id = (CASE is_input WHEN 1 THEN cct.\"from\" ELSE cct.\"to\" END) " + "WHERE user_account_name LIKE '%'||:search||'%' OR contact_name LIKE '%'||:search||'%' OR cct.\"from\" LIKE '%'||:search||'%' OR cct.\"to\" LIKE '%'||:search||'%'"; @Query("SELECT * FROM crypto_coin_transaction") diff --git a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransactionExtended.java b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransactionExtended.java index 00ae487..b319e15 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransactionExtended.java +++ b/app/src/main/java/cy/agorise/crystalwallet/models/CryptoCoinTransactionExtended.java @@ -29,6 +29,9 @@ public class CryptoCoinTransactionExtended { @ColumnInfo(name="contact_name") public String contactName; + @ColumnInfo(name="bitshares_account_name") + public String bitsharesAccountName; + public String getUserAccountName(){ return this.userAccountName; } @@ -37,6 +40,10 @@ public class CryptoCoinTransactionExtended { return this.contactName; } + public String getBitsharesAccountName(){ + return this.bitsharesAccountName; + } + public String getFrom() { return this.cryptoCoinTransaction.getFrom(); } public String getTo() { return this.cryptoCoinTransaction.getTo(); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java b/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java index a8ca0d0..b4b134b 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java @@ -156,12 +156,16 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder { if ((transaction.getContactName() != null)&&(!transaction.equals(""))){ tvFrom.setText(transaction.getContactName()); + } else if ((transaction.getBitsharesAccountName() != null)&&(!transaction.equals(""))){ + tvFrom.setText(transaction.getBitsharesAccountName()); } } else { tvFrom.setText(transaction.getUserAccountName()); if ((transaction.getContactName() != null)&&(!transaction.equals(""))){ tvTo.setText(transaction.getContactName()); + } else if ((transaction.getBitsharesAccountName() != null)&&(!transaction.equals(""))){ + tvTo.setText(transaction.getBitsharesAccountName()); } } // }