Skip to content

Commit d8bd91f

Browse files
authored
always use 'currency name (code)' format
1 parent da17bcc commit d8bd91f

File tree

5 files changed

+4
-54
lines changed

5 files changed

+4
-54
lines changed

desktop/src/main/java/haveno/desktop/main/offer/offerbook/OfferBookView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ private String asString(TradeCurrency item) {
511511
return Res.get(GUIUtil.SHOW_ALL_FLAG);
512512
if (isSpecialEditItem(item))
513513
return Res.get(GUIUtil.EDIT_FLAG);
514-
return item.getCode() + " - " + item.getName();
514+
return item.getName() + " (" + item.getCode() + ")";
515515
}
516516

517517
private boolean isSpecialShowAllItem(TradeCurrency item) {

desktop/src/main/java/haveno/desktop/main/settings/preferences/PreferencesView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private void initializeDisplayCurrencies() {
315315
preferredTradeCurrencyComboBox.setConverter(new StringConverter<>() {
316316
@Override
317317
public String toString(TradeCurrency object) {
318-
return object.getCode() + " - " + object.getName();
318+
return object.getName() + " (" + object.getCode() + ")";
319319
}
320320

321321
@Override

desktop/src/main/java/haveno/desktop/util/CurrencyListItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public String codeDashNameString() {
6161
if (isSpecialShowAllItem())
6262
return Res.get(GUIUtil.SHOW_ALL_FLAG);
6363
else
64-
return tradeCurrency.getCode() + " - " + tradeCurrency.getName();
64+
return tradeCurrency.getName() + " (" + tradeCurrency.getCode() + ")";
6565
}
6666

6767
private boolean isSpecialShowAllItem() {

desktop/src/main/java/haveno/desktop/util/GUIUtil.java

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ protected void updateItem(TradeCurrency item, boolean empty) {
387387
String code = item.getCode();
388388

389389
AnchorPane pane = new AnchorPane();
390-
Label currency = new AutoTooltipLabel(code + " - " + item.getName());
390+
Label currency = new AutoTooltipLabel(item.getName() + " (" + item.getCode() + ")");
391391
currency.getStyleClass().add("currency-label-selected");
392392
AnchorPane.setLeftAnchor(currency, 0.0);
393393
pane.getChildren().add(currency);
@@ -422,34 +422,6 @@ protected void updateItem(TradeCurrency item, boolean empty) {
422422
};
423423
}
424424

425-
public static StringConverter<TradeCurrency> getTradeCurrencyConverter(String postFixSingle,
426-
String postFixMulti,
427-
Map<String, Integer> offerCounts) {
428-
return new StringConverter<>() {
429-
@Override
430-
public String toString(TradeCurrency tradeCurrency) {
431-
String code = tradeCurrency.getCode();
432-
Optional<Integer> offerCountOptional = Optional.ofNullable(offerCounts.get(code));
433-
final String displayString;
434-
displayString = offerCountOptional
435-
.map(offerCount -> CurrencyUtil.getNameAndCode(code)
436-
+ " - " + offerCount + " " + (offerCount == 1 ? postFixSingle : postFixMulti))
437-
.orElseGet(() -> CurrencyUtil.getNameAndCode(code));
438-
// http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
439-
if (code.equals(GUIUtil.SHOW_ALL_FLAG))
440-
return "▶ " + Res.get("list.currency.showAll");
441-
else if (code.equals(GUIUtil.EDIT_FLAG))
442-
return "▼ " + Res.get("list.currency.editList");
443-
return tradeCurrency.getDisplayPrefix() + displayString;
444-
}
445-
446-
@Override
447-
public TradeCurrency fromString(String s) {
448-
return null;
449-
}
450-
};
451-
}
452-
453425
public static Callback<ListView<TradeCurrency>, ListCell<TradeCurrency>> getTradeCurrencyCellFactory(String postFixSingle,
454426
String postFixMulti,
455427
Map<String, Integer> offerCounts) {

desktop/src/test/java/haveno/desktop/util/GUIUtilTest.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,15 @@
1919

2020
import haveno.core.locale.GlobalSettings;
2121
import haveno.core.locale.Res;
22-
import haveno.core.locale.TradeCurrency;
2322
import haveno.core.trade.HavenoUtils;
2423
import haveno.core.user.DontShowAgainLookup;
2524
import haveno.core.user.Preferences;
26-
import javafx.util.StringConverter;
2725
import org.junit.jupiter.api.BeforeEach;
2826
import org.junit.jupiter.api.Test;
2927

3028
import java.math.BigInteger;
31-
import java.util.HashMap;
3229
import java.util.Locale;
33-
import java.util.Map;
3430

35-
import static haveno.desktop.maker.TradeCurrencyMakers.euro;
36-
import static haveno.desktop.maker.TradeCurrencyMakers.monero;
3731
import static org.junit.jupiter.api.Assertions.assertEquals;
3832
import static org.mockito.Mockito.mock;
3933
import static org.mockito.Mockito.when;
@@ -49,22 +43,6 @@ public void setup() {
4943
Res.setBaseCurrencyName("Bitcoin");
5044
}
5145

52-
@Test
53-
public void testTradeCurrencyConverter() {
54-
Map<String, Integer> offerCounts = new HashMap<>() {{
55-
put("XMR", 11);
56-
put("EUR", 10);
57-
}};
58-
StringConverter<TradeCurrency> tradeCurrencyConverter = GUIUtil.getTradeCurrencyConverter(
59-
Res.get("shared.oneOffer"),
60-
Res.get("shared.multipleOffers"),
61-
offerCounts
62-
);
63-
64-
assertEquals("✦ Monero (XMR) - 11 offers", tradeCurrencyConverter.toString(monero));
65-
assertEquals("★ Euro (EUR) - 10 offers", tradeCurrencyConverter.toString(euro));
66-
}
67-
6846
@Test
6947
public void testOpenURLWithCampaignParameters() {
7048
Preferences preferences = mock(Preferences.class);

0 commit comments

Comments
 (0)