diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index cc25f4d..fea7cf2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -29,6 +29,8 @@
+
+
diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/CryptoCoinTransactionReceiptActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/CryptoCoinTransactionReceiptActivity.java
new file mode 100644
index 0000000..f7c8c1f
--- /dev/null
+++ b/app/src/main/java/cy/agorise/crystalwallet/activities/CryptoCoinTransactionReceiptActivity.java
@@ -0,0 +1,74 @@
+package cy.agorise.crystalwallet.activities;
+
+import android.arch.lifecycle.LiveData;
+import android.arch.lifecycle.Observer;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.widget.TextView;
+
+import org.w3c.dom.Text;
+
+import java.text.SimpleDateFormat;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import cy.agorise.crystalwallet.R;
+import cy.agorise.crystalwallet.dao.CrystalDatabase;
+import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
+import cy.agorise.crystalwallet.models.CryptoCurrency;
+
+public class CryptoCoinTransactionReceiptActivity extends AppCompatActivity {
+
+ @BindView(R.id.tvOtherName)
+ TextView tvOtherName;
+ @BindView(R.id.tvUserName)
+ TextView tvUserName;
+ @BindView(R.id.tvTime)
+ TextView tvTime;
+ @BindView(R.id.tvPaymentAmount)
+ TextView tvPaymentAmount;
+
+ private long cryptoCoinTransactionId;
+ private LiveData cryptoCoinTransactionLiveData;
+ private CrystalDatabase db;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.e_receipt);
+
+ ButterKnife.bind(this);
+
+
+ this.cryptoCoinTransactionId = getIntent().getLongExtra("CRYPTO_COIN_TRANSACTION_ID", -1);
+
+ if (this.cryptoCoinTransactionId != -1) {
+ db = CrystalDatabase.getAppDatabase(this);
+ this.cryptoCoinTransactionLiveData = db.transactionDao().getById(this.cryptoCoinTransactionId);
+
+ this.cryptoCoinTransactionLiveData.observe(this, new Observer() {
+ @Override
+ public void onChanged(@Nullable CryptoCoinTransaction cryptoCoinTransaction) {
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yy");
+ CryptoCurrency cryptoCurrency = CrystalDatabase.getAppDatabase(getApplicationContext()).cryptoCurrencyDao().getById(cryptoCoinTransaction.getIdCurrency());
+
+ String userAccount = (cryptoCoinTransaction.getInput()?cryptoCoinTransaction.getTo():cryptoCoinTransaction.getFrom());
+ String otherAccount = (cryptoCoinTransaction.getInput()?cryptoCoinTransaction.getFrom():cryptoCoinTransaction.getTo());
+ String transactionDateString = dateFormat.format(cryptoCoinTransaction.getDate());
+ String timezoneString = dateFormat.getTimeZone().getDisplayName();
+ String amountString = String.format("%.2f",cryptoCoinTransaction.getAmount()/(Math.pow(10,cryptoCurrency.getPrecision())));
+
+ tvUserName.setText(userAccount);
+ tvOtherName.setText(otherAccount);
+ tvTime.setText(transactionDateString+" "+timezoneString);
+ tvPaymentAmount.setText(amountString+" "+cryptoCurrency.getName());
+ }
+ });
+ } else {
+ this.finish();
+ }
+ }
+}
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 d84a61b..5b6673a 100644
--- a/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java
+++ b/app/src/main/java/cy/agorise/crystalwallet/dao/TransactionDao.java
@@ -29,6 +29,9 @@ public interface TransactionDao {
@Query("SELECT * FROM crypto_coin_transaction WHERE account_id = :idAccount ORDER BY date DESC")
List getByIdAccount(long idAccount);
+ @Query("SELECT * FROM crypto_coin_transaction WHERE id = :id")
+ LiveData getById(long id);
+
@Insert(onConflict = OnConflictStrategy.REPLACE)
public long[] insertTransaction(CryptoCoinTransaction... transactions);
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 3aa6ecd..364a581 100644
--- a/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java
+++ b/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java
@@ -2,12 +2,16 @@ package cy.agorise.crystalwallet.views;
import android.arch.lifecycle.LifecycleOwner;
import android.arch.lifecycle.ViewModelProviders;
+import android.content.Context;
+import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.View;
+import android.widget.RelativeLayout;
import android.widget.TextView;
import cy.agorise.crystalwallet.R;
+import cy.agorise.crystalwallet.activities.CryptoCoinTransactionReceiptActivity;
import cy.agorise.crystalwallet.models.CryptoCoinTransaction;
import cy.agorise.crystalwallet.models.CryptoCurrency;
import cy.agorise.crystalwallet.viewmodels.CryptoCurrencyViewModel;
@@ -31,19 +35,50 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
* The view holding the transaction amount
*/
private TextView transactionAmount;
-
private TextView tvTransactionDate;
+ private View rootView;
private Fragment fragment;
+ private long cryptoCoinTransactionId;
+
public TransactionViewHolder(View itemView, Fragment fragment) {
super(itemView);
//TODO: use ButterKnife to load this
+ this.cryptoCoinTransactionId = -1;
+
+ rootView = itemView.findViewById(R.id.rlTransactionItem);
transactionFrom = (TextView) itemView.findViewById(R.id.fromText);
transactionTo = (TextView) itemView.findViewById(R.id.toText);
transactionAmount = (TextView) itemView.findViewById(R.id.amountText);
tvTransactionDate = (TextView) itemView.findViewById(R.id.tvTransactionDate);
this.fragment = fragment;
+
+ rootView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ ereceiptOfThisTransaction();
+ }
+ });
+ }
+
+ /*
+ * dispatch the user to the receipt activity using this transaction
+ */
+ public void ereceiptOfThisTransaction(){
+ //if the transaction was loaded
+ if (this.cryptoCoinTransactionId >= 0) {
+ Context context = fragment.getContext();
+ Intent startActivity = new Intent();
+ startActivity.setClass(context, CryptoCoinTransactionReceiptActivity.class);
+ startActivity.setAction(CryptoCoinTransactionReceiptActivity.class.getName());
+ //Pass the transaction id as an extra parameter to the receipt activity
+ startActivity.putExtra("CRYPTO_COIN_TRANSACTION_ID", this.cryptoCoinTransactionId);
+ startActivity.setFlags(
+ Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ context.startActivity(startActivity);
+ }
}
/*
@@ -64,6 +99,7 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder {
transactionTo.setText("");
transactionAmount.setText("");
} else {
+ this.cryptoCoinTransactionId = transaction.getId();
CryptoCurrencyViewModel cryptoCurrencyViewModel = ViewModelProviders.of(this.fragment).get(CryptoCurrencyViewModel.class);
CryptoCurrency cryptoCurrency = cryptoCurrencyViewModel.getCryptoCurrencyById(transaction.getIdCurrency());
String amountString = String.format("%.2f",transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision()));
diff --git a/app/src/main/res/layout/e_receipt.xml b/app/src/main/res/layout/e_receipt.xml
new file mode 100644
index 0000000..a438e41
--- /dev/null
+++ b/app/src/main/res/layout/e_receipt.xml
@@ -0,0 +1,562 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/transaction_list_item.xml b/app/src/main/res/layout/transaction_list_item.xml
index 27a8aa9..c71db3f 100644
--- a/app/src/main/res/layout/transaction_list_item.xml
+++ b/app/src/main/res/layout/transaction_list_item.xml
@@ -8,6 +8,7 @@
android:paddingTop="10dp">