show destination in tx view

This commit is contained in:
m2049r 2017-08-22 13:02:31 +02:00
parent 110621824a
commit 0421bcfac3
3 changed files with 37 additions and 2 deletions

View File

@ -41,6 +41,8 @@ import java.io.File;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
public class TxFragment extends Fragment { public class TxFragment extends Fragment {
@ -60,6 +62,7 @@ public class TxFragment extends Fragment {
TextView tvTxTimestamp; TextView tvTxTimestamp;
TextView tvTxId; TextView tvTxId;
TextView tvTxKey; TextView tvTxKey;
TextView tvDestination;
TextView tvTxPaymentId; TextView tvTxPaymentId;
TextView tvTxBlockheight; TextView tvTxBlockheight;
TextView tvTxAmount; TextView tvTxAmount;
@ -78,6 +81,7 @@ public class TxFragment extends Fragment {
tvTxTimestamp = (TextView) view.findViewById(R.id.tvTxTimestamp); tvTxTimestamp = (TextView) view.findViewById(R.id.tvTxTimestamp);
tvTxId = (TextView) view.findViewById(R.id.tvTxId); tvTxId = (TextView) view.findViewById(R.id.tvTxId);
tvTxKey = (TextView) view.findViewById(R.id.tvTxKey); tvTxKey = (TextView) view.findViewById(R.id.tvTxKey);
tvDestination = (TextView) view.findViewById(R.id.tvDestination);
tvTxPaymentId = (TextView) view.findViewById(R.id.tvTxPaymentId); tvTxPaymentId = (TextView) view.findViewById(R.id.tvTxPaymentId);
tvTxBlockheight = (TextView) view.findViewById(R.id.tvTxBlockheight); tvTxBlockheight = (TextView) view.findViewById(R.id.tvTxBlockheight);
tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount); tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount);
@ -154,11 +158,11 @@ public class TxFragment extends Fragment {
boolean comma = false; boolean comma = false;
for (Transfer transfer : info.transfers) { for (Transfer transfer : info.transfers) {
if (comma) { if (comma) {
sb.append(","); sb.append(", ");
} else { } else {
comma = true; comma = true;
} }
sb.append("[").append(transfer.address.substring(0, 6)).append("] "); sb.append(transfer.address).append(": ");
sb.append(Wallet.getDisplayAmount(transfer.amount)); sb.append(Wallet.getDisplayAmount(transfer.amount));
} }
} else { } else {
@ -202,10 +206,13 @@ public class TxFragment extends Fragment {
String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-"); String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-");
tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount)); tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount));
tvTxFee.setText(Wallet.getDisplayAmount(info.fee)); tvTxFee.setText(Wallet.getDisplayAmount(info.fee));
Set<String> destinations = new HashSet<>();
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
StringBuffer dstSb = new StringBuffer();
if (info.transfers != null) { if (info.transfers != null) {
boolean newline = false; boolean newline = false;
for (Transfer transfer : info.transfers) { for (Transfer transfer : info.transfers) {
destinations.add(transfer.address);
if (newline) { if (newline) {
sb.append("\n"); sb.append("\n");
} else { } else {
@ -214,10 +221,21 @@ public class TxFragment extends Fragment {
sb.append("[").append(transfer.address.substring(0, 6)).append("] "); sb.append("[").append(transfer.address.substring(0, 6)).append("] ");
sb.append(Wallet.getDisplayAmount(transfer.amount)); sb.append(Wallet.getDisplayAmount(transfer.amount));
} }
newline = false;
for (String dst : destinations) {
if (newline) {
dstSb.append("\n");
} else {
newline = true;
}
dstSb.append(dst);
}
} else { } else {
sb.append("-"); sb.append("-");
dstSb.append(info.direction == TransactionInfo.Direction.Direction_In ? activityCallback.getWalletAddress() : "-");
} }
tvTxTransfers.setText(sb.toString()); tvTxTransfers.setText(sb.toString());
tvDestination.setText(dstSb.toString());
this.info = info; this.info = info;
bCopy.setEnabled(true); bCopy.setEnabled(true);
} }

View File

@ -46,6 +46,22 @@
android:textIsSelectable="true" /> android:textIsSelectable="true" />
</TableRow> </TableRow>
<TableRow>
<TextView
android:gravity="right"
android:padding="8dp"
android:text="@string/tx_destination"
android:textColor="@color/colorAccent" />
<TextView
android:id="@+id/tvDestination"
android:gravity="left"
android:padding="8dip"
android:selectAllOnFocus="true"
android:textIsSelectable="true" />
</TableRow>
<TableRow> <TableRow>
<TextView <TextView

View File

@ -121,6 +121,7 @@
<string name="tx_timestamp">Timestamp</string> <string name="tx_timestamp">Timestamp</string>
<string name="tx_id">TX ID</string> <string name="tx_id">TX ID</string>
<string name="tx_key">TX Key</string> <string name="tx_key">TX Key</string>
<string name="tx_destination">Destination</string>
<string name="tx_paymentId">Payment ID</string> <string name="tx_paymentId">Payment ID</string>
<string name="tx_blockheight">Block</string> <string name="tx_blockheight">Block</string>
<string name="tx_amount">Amount</string> <string name="tx_amount">Amount</string>