Skip to content

Commit

Permalink
Show the network fee for transactions created by us.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Oct 2, 2014
1 parent b6c75bb commit 2d2625d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 13 deletions.
32 changes: 31 additions & 1 deletion wallet/res/layout/transaction_row_extended.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,37 @@
</LinearLayout>

<LinearLayout
android:id="@+id/transaction_row_extend"
android:id="@+id/transaction_row_extend_fee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="4dp" >

<View
android:layout_width="@dimen/symbol_size_normal"
android:layout_height="@dimen/symbol_size_normal"
android:layout_marginRight="8dp" />

<TextView
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/transaction_row_fee"
android:textColor="@color/fg_insignificant"
android:textSize="@dimen/font_size_normal" />

<de.schildbach.wallet.ui.CurrencyTextView
android:id="@+id/transaction_row_fee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="8dp"
android:textColor="@color/fg_insignificant"
android:textSize="@dimen/font_size_normal" />
</LinearLayout>

<LinearLayout
android:id="@+id/transaction_row_extend_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
Expand Down
1 change: 1 addition & 0 deletions wallet/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<string name="edit_address_book_entry_dialog_label_label">Name</string>
<string name="edit_address_book_entry_dialog_button_edit">Speichern</string>

<string name="transaction_row_fee">Netzwerk-Gebühr</string>
<string name="transaction_row_message_purpose_key_rotation">Diese Transaktion stärkt deine Wallet gegen Diebstahl. &lt;u&gt;Mehr Information.&lt;/u&gt;</string>
<string name="transaction_row_message_own_unbroadcasted">Diese Zahlung ist noch nicht übertragen.</string>
<string name="transaction_row_message_received_direct">Diese Zahlung wurde direkt empfangen. Es besteht das Risiko, daß sie niemals verfügbar wird.</string>
Expand Down
1 change: 1 addition & 0 deletions wallet/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
<string name="edit_address_book_entry_dialog_address_label">Address</string>
<string name="edit_address_book_entry_dialog_label_label">Name</string>
<string name="edit_address_book_entry_dialog_button_edit">Save</string>
<string name="transaction_row_fee">Network fee</string>
<string name="transaction_row_message_purpose_key_rotation">This transaction strengthens your wallet against theft. &lt;u&gt;More info.&lt;/u&gt;</string>
<string name="transaction_row_message_own_unbroadcasted">This payment has not been transmitted yet.</string>
<string name="transaction_row_message_received_direct">This payment has been received directly. There is a risk it might never become spendable.</string>
Expand Down
38 changes: 26 additions & 12 deletions wallet/src/de/schildbach/wallet/ui/TransactionsListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ public void bindView(@Nonnull final View row, @Nonnull final Transaction tx)

final Coin value = tx.getValue(wallet);
final boolean sent = value.signum() < 0;
final Coin fee = tx.getFee();
final boolean hasFee = fee != null;

final CircularProgressView rowConfidenceCircular = (CircularProgressView) row.findViewById(R.id.transaction_row_confidence_circular);
final TextView rowConfidenceTextual = (TextView) row.findViewById(R.id.transaction_row_confidence_textual);
Expand Down Expand Up @@ -319,60 +321,72 @@ else if (address != null)
rowAddress.setText(label != null ? label : address.toString());
rowAddress.setTypeface(label != null ? Typeface.DEFAULT : Typeface.MONOSPACE);

// fee
final View rowExtendFee = row.findViewById(R.id.transaction_row_extend_fee);
if (rowExtendFee != null)
{
final CurrencyTextView rowFee = (CurrencyTextView) row.findViewById(R.id.transaction_row_fee);
rowExtendFee.setVisibility(hasFee ? View.VISIBLE : View.GONE);
rowFee.setAlwaysSigned(true);
rowFee.setFormat(format);
if (hasFee)
rowFee.setAmount(fee.negate());
}

// value
final CurrencyTextView rowValue = (CurrencyTextView) row.findViewById(R.id.transaction_row_value);
rowValue.setTextColor(textColor);
rowValue.setAlwaysSigned(true);
rowValue.setFormat(format);
rowValue.setAmount(value);
rowValue.setAmount(hasFee && rowExtendFee != null ? value.add(fee) : value);

// extended message
final View rowExtend = row.findViewById(R.id.transaction_row_extend);
if (rowExtend != null)
// message
final View rowExtendMessage = row.findViewById(R.id.transaction_row_extend_message);
if (rowExtendMessage != null)
{
final TextView rowMessage = (TextView) row.findViewById(R.id.transaction_row_message);
final boolean isTimeLocked = tx.isTimeLocked();
rowExtend.setVisibility(View.GONE);
rowExtendMessage.setVisibility(View.GONE);

if (tx.getPurpose() == Purpose.KEY_ROTATION)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(Html.fromHtml(context.getString(R.string.transaction_row_message_purpose_key_rotation)));
rowMessage.setTextColor(colorSignificant);
}
else if (isOwn && confidenceType == ConfidenceType.PENDING && confidence.numBroadcastPeers() == 0)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(R.string.transaction_row_message_own_unbroadcasted);
rowMessage.setTextColor(colorInsignificant);
}
else if (!isOwn && confidenceType == ConfidenceType.PENDING && confidence.numBroadcastPeers() == 0)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(R.string.transaction_row_message_received_direct);
rowMessage.setTextColor(colorInsignificant);
}
else if (!sent && value.compareTo(Transaction.MIN_NONDUST_OUTPUT) < 0)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(R.string.transaction_row_message_received_dust);
rowMessage.setTextColor(colorInsignificant);
}
else if (!sent && confidenceType == ConfidenceType.PENDING && isTimeLocked)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(R.string.transaction_row_message_received_unconfirmed_locked);
rowMessage.setTextColor(colorError);
}
else if (!sent && confidenceType == ConfidenceType.PENDING && !isTimeLocked)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(R.string.transaction_row_message_received_unconfirmed_unlocked);
rowMessage.setTextColor(colorInsignificant);
}
else if (!sent && confidenceType == ConfidenceType.DEAD)
{
rowExtend.setVisibility(View.VISIBLE);
rowExtendMessage.setVisibility(View.VISIBLE);
rowMessage.setText(R.string.transaction_row_message_received_dead);
rowMessage.setTextColor(colorError);
}
Expand Down

0 comments on commit 2d2625d

Please sign in to comment.