mirror of https://github.com/m2049r/xmrwallet.git
deal with pending transactions
This commit is contained in:
parent
344eeb7a3b
commit
3a68802ae7
|
@ -132,6 +132,7 @@ public class TxFragment extends Fragment {
|
||||||
sb.append(getString(R.string.tx_paymentId)).append(": ");
|
sb.append(getString(R.string.tx_paymentId)).append(": ");
|
||||||
sb.append(info.paymentId).append("\n");
|
sb.append(info.paymentId).append("\n");
|
||||||
sb.append(getString(R.string.tx_amount)).append(": ");
|
sb.append(getString(R.string.tx_amount)).append(": ");
|
||||||
|
sb.append((info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-"));
|
||||||
sb.append(Wallet.getDisplayAmount(info.amount)).append("\n");
|
sb.append(Wallet.getDisplayAmount(info.amount)).append("\n");
|
||||||
sb.append(getString(R.string.tx_fee)).append(": ");
|
sb.append(getString(R.string.tx_fee)).append(": ");
|
||||||
sb.append(Wallet.getDisplayAmount(info.fee)).append("\n");
|
sb.append(Wallet.getDisplayAmount(info.fee)).append("\n");
|
||||||
|
@ -141,7 +142,13 @@ public class TxFragment extends Fragment {
|
||||||
sb.append(getString(R.string.tx_timestamp)).append(": ");
|
sb.append(getString(R.string.tx_timestamp)).append(": ");
|
||||||
sb.append(TS_FORMATTER.format(new Date(info.timestamp * 1000))).append("\n");
|
sb.append(TS_FORMATTER.format(new Date(info.timestamp * 1000))).append("\n");
|
||||||
sb.append(getString(R.string.tx_blockheight)).append(": ");
|
sb.append(getString(R.string.tx_blockheight)).append(": ");
|
||||||
sb.append(info.blockheight).append("\n");
|
if (info.isPending) {
|
||||||
|
sb.append(getString(R.string.tx_pending)).append("\n");
|
||||||
|
} else if (info.isFailed) {
|
||||||
|
sb.append(getString(R.string.tx_failed)).append("\n");
|
||||||
|
} else {
|
||||||
|
sb.append(info.blockheight).append("\n");
|
||||||
|
}
|
||||||
sb.append(getString(R.string.tx_transfers)).append(": ");
|
sb.append(getString(R.string.tx_transfers)).append(": ");
|
||||||
if (info.transfers != null) {
|
if (info.transfers != null) {
|
||||||
boolean comma = false;
|
boolean comma = false;
|
||||||
|
@ -162,7 +169,7 @@ public class TxFragment extends Fragment {
|
||||||
ClipData clip = ClipData.newPlainText(getString(R.string.tx_copy_label), sb.toString());
|
ClipData clip = ClipData.newPlainText(getString(R.string.tx_copy_label), sb.toString());
|
||||||
clipboardManager.setPrimaryClip(clip);
|
clipboardManager.setPrimaryClip(clip);
|
||||||
Toast.makeText(getActivity(), getString(R.string.tx_copy_message), Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), getString(R.string.tx_copy_message), Toast.LENGTH_SHORT).show();
|
||||||
Log.d(TAG, sb.toString());
|
//Log.d(TAG, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionInfo info = null;
|
TransactionInfo info = null;
|
||||||
|
@ -185,8 +192,15 @@ public class TxFragment extends Fragment {
|
||||||
tvTxId.setText(info.hash);
|
tvTxId.setText(info.hash);
|
||||||
tvTxKey.setText(info.txKey.isEmpty() ? "-" : info.txKey);
|
tvTxKey.setText(info.txKey.isEmpty() ? "-" : info.txKey);
|
||||||
tvTxPaymentId.setText(info.paymentId);
|
tvTxPaymentId.setText(info.paymentId);
|
||||||
tvTxBlockheight.setText("" + info.blockheight);
|
if (info.isPending) {
|
||||||
tvTxAmount.setText(Wallet.getDisplayAmount(info.amount));
|
tvTxBlockheight.setText(getString(R.string.tx_pending));
|
||||||
|
} else if (info.isFailed) {
|
||||||
|
tvTxBlockheight.setText(getString(R.string.tx_failed));
|
||||||
|
} else {
|
||||||
|
tvTxBlockheight.setText("" + info.blockheight);
|
||||||
|
}
|
||||||
|
String sign = (info.direction == TransactionInfo.Direction.Direction_In ? "+" : "-");
|
||||||
|
tvTxAmount.setText(sign + Wallet.getDisplayAmount(info.amount));
|
||||||
tvTxFee.setText(Wallet.getDisplayAmount(info.fee));
|
tvTxFee.setText(Wallet.getDisplayAmount(info.fee));
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
if (info.transfers != null) {
|
if (info.transfers != null) {
|
||||||
|
|
|
@ -45,6 +45,8 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
|
|
||||||
static final int TX_RED = Color.rgb(255, 79, 65);
|
static final int TX_RED = Color.rgb(255, 79, 65);
|
||||||
static final int TX_GREEN = Color.rgb(54, 176, 91);
|
static final int TX_GREEN = Color.rgb(54, 176, 91);
|
||||||
|
static final int TX_PENDING = Color.rgb(72, 53, 176);
|
||||||
|
static final int TX_FAILED = Color.rgb(208, 0, 255);
|
||||||
|
|
||||||
public interface OnInteractionListener {
|
public interface OnInteractionListener {
|
||||||
void onInteraction(View view, TransactionInfo item);
|
void onInteraction(View view, TransactionInfo item);
|
||||||
|
@ -89,6 +91,13 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
Collections.sort(data, new Comparator<TransactionInfo>() {
|
Collections.sort(data, new Comparator<TransactionInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(TransactionInfo o1, TransactionInfo o2) {
|
public int compare(TransactionInfo o1, TransactionInfo o2) {
|
||||||
|
if ((o1.isPending) && (o2.isPending)) {
|
||||||
|
long b1 = o1.timestamp;
|
||||||
|
long b2 = o2.timestamp;
|
||||||
|
return (b1 > b2) ? -1 : (b1 < b2) ? 1 : 0;
|
||||||
|
}
|
||||||
|
if (o1.isPending) return -1;
|
||||||
|
if (o2.isPending) return 1;
|
||||||
long b1 = o1.blockheight;
|
long b1 = o1.blockheight;
|
||||||
long b2 = o2.blockheight;
|
long b2 = o2.blockheight;
|
||||||
return (b1 > b2) ? -1 : (b1 < b2) ? 1 : 0;
|
return (b1 > b2) ? -1 : (b1 < b2) ? 1 : 0;
|
||||||
|
@ -141,7 +150,16 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||||
|
|
||||||
this.tvAmount.setText(amountParts[0]);
|
this.tvAmount.setText(amountParts[0]);
|
||||||
this.tvAmountDecimal.setText(amountParts[1]);
|
this.tvAmountDecimal.setText(amountParts[1]);
|
||||||
if (infoItem.direction == TransactionInfo.Direction.Direction_In) {
|
if (infoItem.isPending) {
|
||||||
|
setTxColour(TX_PENDING);
|
||||||
|
if (infoItem.direction == TransactionInfo.Direction.Direction_Out) {
|
||||||
|
this.tvAmount.setText('-' + amountParts[0]);
|
||||||
|
}
|
||||||
|
} else if (infoItem.isFailed) {
|
||||||
|
this.tvAmount.setText('(' + amountParts[0]);
|
||||||
|
this.tvAmountDecimal.setText(amountParts[1] + ')');
|
||||||
|
setTxColour(TX_FAILED);
|
||||||
|
} else if (infoItem.direction == TransactionInfo.Direction.Direction_In) {
|
||||||
setTxColour(TX_GREEN);
|
setTxColour(TX_GREEN);
|
||||||
} else {
|
} else {
|
||||||
setTxColour(TX_RED);
|
setTxColour(TX_RED);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.os.Parcelable;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
// this is not the TransactionInfo from the API as that is owned by the TransactionHistory
|
// this is not the TransactionInfo from the API as that is owned by the TransactionHistory
|
||||||
// this is a POJO for the TransactionInfoAdapter
|
// this is a POJO for the TransactionInfoAdapter
|
||||||
|
@ -91,6 +92,7 @@ public class TransactionInfo implements Parcelable {
|
||||||
this.confirmations = confirmations;
|
this.confirmations = confirmations;
|
||||||
this.transfers = transfers;
|
this.transfers = transfers;
|
||||||
}
|
}
|
||||||
|
Random rnd = new Random();
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return direction + "@" + blockheight + " " + amount;
|
return direction + "@" + blockheight + " " + amount;
|
||||||
|
|
|
@ -345,6 +345,7 @@ public class WalletService extends Service {
|
||||||
Log.d(TAG, "Wallet store failed: " + myWallet.getErrorString());
|
Log.d(TAG, "Wallet store failed: " + myWallet.getErrorString());
|
||||||
}
|
}
|
||||||
if (observer != null) observer.onWalletStored(rc);
|
if (observer != null) observer.onWalletStored(rc);
|
||||||
|
listener.updated = true;
|
||||||
}
|
}
|
||||||
} else if (cmd.equals(REQUEST_CMD_SETNOTE)) {
|
} else if (cmd.equals(REQUEST_CMD_SETNOTE)) {
|
||||||
Wallet myWallet = getWallet();
|
Wallet myWallet = getWallet();
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
<color name="main_background">#f0eeef</color>
|
<color name="main_background">#f0eeef</color>
|
||||||
<color name="menu_background_color">#1c1c1c</color>
|
<color name="menu_background_color">#1c1c1c</color>
|
||||||
|
|
||||||
|
|
||||||
<color name="tx_green">#36b05b</color>
|
<color name="tx_green">#36b05b</color>
|
||||||
<color name="tx_red">#ff4f41</color>
|
<color name="tx_red">#ff4f41</color>
|
||||||
|
<color name="tx_pending">#FF4081</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -135,6 +135,9 @@
|
||||||
<string name="tx_notes_set">Notes saved</string>
|
<string name="tx_notes_set">Notes saved</string>
|
||||||
<string name="tx_notes_set_failed">Notes saved failed</string>
|
<string name="tx_notes_set_failed">Notes saved failed</string>
|
||||||
|
|
||||||
|
<string name="tx_pending">PENDING</string>
|
||||||
|
<string name="tx_failed">FAILED</string>
|
||||||
|
|
||||||
<string name="big_amount">999999.999999999999</string>
|
<string name="big_amount">999999.999999999999</string>
|
||||||
|
|
||||||
<string-array name="mixin">
|
<string-array name="mixin">
|
||||||
|
|
Loading…
Reference in New Issue