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

Reduce number of decimals shown for monetary fiat prices to 2 #3926

Merged
merged 2 commits into from Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public void setContentForPrivacyPopOver(Node node) {
setActionHandlers(node);
}

public void hideInfoContent() {
currentIcon = null;
hideIcons();
}

public void setIconsRightAligned() {
AnchorPane.clearConstraints(infoIcon);
AnchorPane.clearConstraints(warningIcon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ private void createListeners() {
volumeListener = (observable, oldValue, newValue) -> {
if (!newValue.equals("") && CurrencyUtil.isFiatCurrency(model.tradeCurrencyCode.get())) {
volumeInfoInputTextField.setContentForPrivacyPopOver(createPopoverLabel(Res.get("offerbook.info.roundedFiatVolume")));
} else {
volumeInfoInputTextField.hideInfoContent();
}
};

Expand Down
2 changes: 1 addition & 1 deletion desktop/src/main/java/bisq/desktop/util/DisplayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Slf4j
public class DisplayUtils {
private final static int scale = 3;
private static final MonetaryFormat fiatVolumeFormat = new MonetaryFormat().shift(0).minDecimals(2).repeatOptionalDecimals(0, 0);
private static final MonetaryFormat fiatVolumeFormat = new MonetaryFormat().shift(0).minDecimals(0).repeatOptionalDecimals(0, 0);

public static String formatDateTime(Date date) {
return FormattingUtils.formatDateTime(date, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public void testMaxCharactersForFiatBuyVolume() {

final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, null);
model.activate();
assertEquals(4, model.maxPlacesForBuyVolume.intValue()); //0.01
assertEquals(1, model.maxPlacesForBuyVolume.intValue()); //0
offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
assertEquals(5, model.maxPlacesForBuyVolume.intValue()); //10.00
assertEquals(2, model.maxPlacesForBuyVolume.intValue()); //10
offerBookListItems.addAll(make(btcBuyItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
assertEquals(7, model.maxPlacesForBuyVolume.intValue()); //2212.86
assertEquals(4, model.maxPlacesForBuyVolume.intValue()); //2213
}

@Test
Expand Down Expand Up @@ -199,10 +199,10 @@ public void testMaxCharactersForFiatSellVolume() {

final OfferBookChartViewModel model = new OfferBookChartViewModel(offerBook, empty, service, null, null);
model.activate();
assertEquals(4, model.maxPlacesForSellVolume.intValue()); //0.01
assertEquals(1, model.maxPlacesForSellVolume.intValue()); //0
offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.amount, 100000000L))));
assertEquals(5, model.maxPlacesForSellVolume.intValue()); //10.00
assertEquals(2, model.maxPlacesForSellVolume.intValue()); //10
offerBookListItems.addAll(make(btcSellItem.but(with(OfferBookListItemMaker.amount, 22128600000L))));
assertEquals(7, model.maxPlacesForSellVolume.intValue()); //2212.86
assertEquals(4, model.maxPlacesForSellVolume.intValue()); //2213
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ public void testMaxCharactersForVolume() {
null, null, null, null, coinFormatter, new BsqFormatter());
model.activate();

assertEquals(8, model.maxPlacesForVolume.intValue());
assertEquals(5, model.maxPlacesForVolume.intValue());
offerBookListItems.addAll(make(btcBuyItem.but(with(amount, 2000000000L))));
assertEquals(10, model.maxPlacesForVolume.intValue());
assertEquals(7, model.maxPlacesForVolume.intValue());
}

@Test
Expand All @@ -316,12 +316,12 @@ public void testMaxCharactersForVolumeRange() {
null, null, null, null, coinFormatter, new BsqFormatter());
model.activate();

assertEquals(15, model.maxPlacesForVolume.intValue());
assertEquals(9, model.maxPlacesForVolume.intValue());
offerBookListItems.addAll(make(btcItemWithRange.but(with(amount, 2000000000L))));
assertEquals(17, model.maxPlacesForVolume.intValue());
assertEquals(11, model.maxPlacesForVolume.intValue());
offerBookListItems.addAll(make(btcItemWithRange.but(with(minAmount, 30000000000L),
with(amount, 30000000000L))));
assertEquals(25, model.maxPlacesForVolume.intValue());
assertEquals(19, model.maxPlacesForVolume.intValue());
}

@Test
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public void testFormatAccountAge() {

@Test
public void testFormatVolume() {
assertEquals("1.00", DisplayUtils.formatVolume(make(btcUsdOffer), true, 4));
assertEquals("100.00", DisplayUtils.formatVolume(make(usdVolume)));
assertEquals("1774.62", DisplayUtils.formatVolume(make(usdVolume.but(with(volumeString, "1774.62")))));
assertEquals("1", DisplayUtils.formatVolume(make(btcUsdOffer), true, 4));
assertEquals("100", DisplayUtils.formatVolume(make(usdVolume)));
assertEquals("1775", DisplayUtils.formatVolume(make(usdVolume.but(with(volumeString, "1774.62")))));
}

@Test
Expand Down