Skip to content

Commit

Permalink
Merge pull request #16 from m2049r/feature_txrecipient
Browse files Browse the repository at this point in the history
show destinations in tx view
  • Loading branch information
m2049r authored Aug 22, 2017
2 parents b6c4e06 + 0421bcf commit 807d217
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
22 changes: 20 additions & 2 deletions app/src/main/java/com/m2049r/xmrwallet/TxFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;

public class TxFragment extends Fragment {
Expand All @@ -60,6 +62,7 @@ public TxFragment() {
TextView tvTxTimestamp;
TextView tvTxId;
TextView tvTxKey;
TextView tvDestination;
TextView tvTxPaymentId;
TextView tvTxBlockheight;
TextView tvTxAmount;
Expand All @@ -78,6 +81,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
tvTxTimestamp = (TextView) view.findViewById(R.id.tvTxTimestamp);
tvTxId = (TextView) view.findViewById(R.id.tvTxId);
tvTxKey = (TextView) view.findViewById(R.id.tvTxKey);
tvDestination = (TextView) view.findViewById(R.id.tvDestination);
tvTxPaymentId = (TextView) view.findViewById(R.id.tvTxPaymentId);
tvTxBlockheight = (TextView) view.findViewById(R.id.tvTxBlockheight);
tvTxAmount = (TextView) view.findViewById(R.id.tvTxAmount);
Expand Down Expand Up @@ -154,11 +158,11 @@ void copyToClipboard() {
boolean comma = false;
for (Transfer transfer : info.transfers) {
if (comma) {
sb.append(",");
sb.append(", ");
} else {
comma = true;
}
sb.append("[").append(transfer.address.substring(0, 6)).append("] ");
sb.append(transfer.address).append(": ");
sb.append(Wallet.getDisplayAmount(transfer.amount));
}
} else {
Expand Down Expand Up @@ -202,10 +206,13 @@ private void show(TransactionInfo info) {
String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-");
tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount));
tvTxFee.setText(Wallet.getDisplayAmount(info.fee));
Set<String> destinations = new HashSet<>();
StringBuffer sb = new StringBuffer();
StringBuffer dstSb = new StringBuffer();
if (info.transfers != null) {
boolean newline = false;
for (Transfer transfer : info.transfers) {
destinations.add(transfer.address);
if (newline) {
sb.append("\n");
} else {
Expand All @@ -214,10 +221,21 @@ private void show(TransactionInfo info) {
sb.append("[").append(transfer.address.substring(0, 6)).append("] ");
sb.append(Wallet.getDisplayAmount(transfer.amount));
}
newline = false;
for (String dst : destinations) {
if (newline) {
dstSb.append("\n");
} else {
newline = true;
}
dstSb.append(dst);
}
} else {
sb.append("-");
dstSb.append(info.direction == TransactionInfo.Direction.Direction_In ? activityCallback.getWalletAddress() : "-");
}
tvTxTransfers.setText(sb.toString());
tvDestination.setText(dstSb.toString());
this.info = info;
bCopy.setEnabled(true);
}
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/layout/tx_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@
android:textIsSelectable="true" />
</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>

<TextView
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<string name="tx_timestamp">Timestamp</string>
<string name="tx_id">TX ID</string>
<string name="tx_key">TX Key</string>
<string name="tx_destination">Destination</string>
<string name="tx_paymentId">Payment ID</string>
<string name="tx_blockheight">Block</string>
<string name="tx_amount">Amount</string>
Expand Down

0 comments on commit 807d217

Please sign in to comment.