Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deposit improvements #4347

Merged
merged 11 commits into from Jul 3, 2020
9 changes: 9 additions & 0 deletions core/src/main/java/bisq/core/util/FormattingUtils.java
Expand Up @@ -211,6 +211,10 @@ public static String formatToPercentWithSymbol(double value) {
return formatToPercent(value) + "%";
}

public static String formatToRoundedPercentWithSymbol(double value) {
return formatToPercent(value, new DecimalFormat("#")) + "%";
}

public static String formatPercentagePrice(double value) {
return formatToPercentWithSymbol(value);
}
Expand All @@ -219,6 +223,11 @@ public static String formatToPercent(double value) {
DecimalFormat decimalFormat = new DecimalFormat("#.##");
decimalFormat.setMinimumFractionDigits(2);
decimalFormat.setMaximumFractionDigits(2);

return formatToPercent(value, decimalFormat);
}

public static String formatToPercent(double value, DecimalFormat decimalFormat) {
return decimalFormat.format(MathUtils.roundDouble(value * 100.0, 2)).replace(",", ".");
}

Expand Down
Expand Up @@ -934,7 +934,7 @@ private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getDepositC
Res.get("offerbook.deposit"),
Res.get("offerbook.deposit.help")) {
{
setMinWidth(80);
setMinWidth(70);
setSortable(true);
}
};
Expand Down Expand Up @@ -977,7 +977,7 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
private TableColumn<OfferBookListItem, OfferBookListItem> getActionColumn() {
TableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.actions")) {
{
setMinWidth(200);
setMinWidth(180);
setSortable(false);
}
};
Expand Down Expand Up @@ -1194,8 +1194,8 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
private AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> getAvatarColumn() {
AutoTooltipTableColumn<OfferBookListItem, OfferBookListItem> column = new AutoTooltipTableColumn<>(Res.get("offerbook.trader")) {
{
setMinWidth(80);
setMaxWidth(80);
setMinWidth(60);
setMaxWidth(60);
setSortable(true);
}
};
Expand Down
Expand Up @@ -645,7 +645,7 @@ private static String getDirectionWithCodeDetailed(OfferPayload.Direction direct
}

public String formatDepositString(Coin deposit, long amount) {
var percentage = FormattingUtils.formatToPercentWithSymbol(deposit.getValue() / (double) amount);
var percentage = FormattingUtils.formatToRoundedPercentWithSymbol(deposit.getValue() / (double) amount);
return btcFormatter.formatCoin(deposit) + " (" + percentage + ")";
}
}