mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 22:45:21 +01:00
Extract DisplayUtils from BSFormatter
All methods that are only used in the desktop project are removed from BSFormatter to DisplayUtils. This reduces the entanglement between the desktop and core project by reducing the surface area of the coupling.
This commit is contained in:
parent
be21535a4b
commit
fe33a80de5
49 changed files with 610 additions and 490 deletions
|
@ -181,7 +181,7 @@ public class MarketAlerts {
|
|||
String msg = Res.get("account.notifications.marketAlert.message.msg",
|
||||
direction,
|
||||
BSFormatter.getCurrencyPair(currencyCode),
|
||||
formatter.formatPrice(offerPrice),
|
||||
BSFormatter.formatPrice(offerPrice),
|
||||
BSFormatter.formatToPercentWithSymbol(ratio / 10000d),
|
||||
marketDir,
|
||||
Res.get(offer.getPaymentMethod().getId()),
|
||||
|
|
|
@ -306,17 +306,6 @@ public class OfferUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static String getFeeWithFiatAmount(Coin makerFeeAsCoin, Optional<Volume> optionalFeeInFiat, BSFormatter formatter) {
|
||||
String fee = makerFeeAsCoin != null ? formatter.formatCoinWithCode(makerFeeAsCoin) : Res.get("shared.na");
|
||||
String feeInFiatAsString;
|
||||
if (optionalFeeInFiat != null && optionalFeeInFiat.isPresent()) {
|
||||
feeInFiatAsString = formatter.formatVolumeWithCode(optionalFeeInFiat.get());
|
||||
} else {
|
||||
feeInFiatAsString = Res.get("shared.na");
|
||||
}
|
||||
return Res.get("feeOptionWindow.fee", fee, feeInFiatAsString);
|
||||
}
|
||||
|
||||
|
||||
public static Map<String, String> getExtraDataMap(AccountAgeWitnessService accountAgeWitnessService,
|
||||
ReferralIdService referralIdService,
|
||||
|
|
|
@ -23,8 +23,6 @@ import bisq.core.locale.GlobalSettings;
|
|||
import bisq.core.locale.Res;
|
||||
import bisq.core.monetary.Altcoin;
|
||||
import bisq.core.monetary.Price;
|
||||
import bisq.core.monetary.Volume;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OfferPayload;
|
||||
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
|
@ -63,8 +61,6 @@ import org.jetbrains.annotations.NotNull;
|
|||
public class BSFormatter {
|
||||
public final static String RANGE_SEPARATOR = " - ";
|
||||
|
||||
protected final static int scale = 3;
|
||||
|
||||
// We don't support localized formatting. Format is always using "." as decimal mark and no grouping separator.
|
||||
// Input of "," as decimal mark (like in german locale) will be replaced with ".".
|
||||
// Input of a group separator (1,123,45) lead to an validation error.
|
||||
|
@ -74,8 +70,7 @@ public class BSFormatter {
|
|||
|
||||
// protected String currencyCode = CurrencyUtil.getDefaultFiatCurrencyAsCode();
|
||||
|
||||
protected static final MonetaryFormat fiatPriceFormat = new MonetaryFormat().shift(0).minDecimals(4).repeatOptionalDecimals(0, 0);
|
||||
protected static final MonetaryFormat fiatVolumeFormat = new MonetaryFormat().shift(0).minDecimals(2).repeatOptionalDecimals(0, 0);
|
||||
public static final MonetaryFormat fiatPriceFormat = new MonetaryFormat().shift(0).minDecimals(4).repeatOptionalDecimals(0, 0);
|
||||
protected static final MonetaryFormat altcoinFormat = new MonetaryFormat().shift(0).minDecimals(8).repeatOptionalDecimals(0, 0);
|
||||
protected static final DecimalFormat decimalFormat = new DecimalFormat("#.#");
|
||||
|
||||
|
@ -177,45 +172,12 @@ public class BSFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to a coin with max. 4 decimal places. Last place gets rounded.
|
||||
* 0.01234 -> 0.0123
|
||||
* 0.01235 -> 0.0124
|
||||
*
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
public Coin parseToCoinWith4Decimals(String input) {
|
||||
try {
|
||||
return Coin.valueOf(new BigDecimal(parseToCoin(cleanDoubleInput(input)).value).setScale(-scale - 1,
|
||||
BigDecimal.ROUND_HALF_UP).setScale(scale + 1, BigDecimal.ROUND_HALF_UP).toBigInteger().longValue());
|
||||
} catch (Throwable t) {
|
||||
if (input != null && input.length() > 0)
|
||||
log.warn("Exception at parseToCoinWith4Decimals: " + t.toString());
|
||||
return Coin.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasBtcValidDecimals(String input) {
|
||||
return parseToCoin(input).equals(parseToCoinWith4Decimals(input));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a coin with the properties defined in the format (used to reduce decimal places)
|
||||
*
|
||||
* @param coin The coin which should be transformed
|
||||
* @return The transformed coin
|
||||
*/
|
||||
public Coin reduceTo4Decimals(Coin coin) {
|
||||
return parseToCoin(formatCoin(coin));
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FIAT
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static String formatFiat(Fiat fiat, MonetaryFormat format, boolean appendCurrencyCode) {
|
||||
public static String formatFiat(Fiat fiat, MonetaryFormat format, boolean appendCurrencyCode) {
|
||||
if (fiat != null) {
|
||||
try {
|
||||
final String res = format.noCode().format(fiat).toString();
|
||||
|
@ -296,19 +258,6 @@ public class BSFormatter {
|
|||
// Volume
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String formatVolume(Offer offer, Boolean decimalAligned, int maxNumberOfDigits) {
|
||||
return formatVolume(offer, decimalAligned, maxNumberOfDigits, true);
|
||||
}
|
||||
|
||||
public String formatVolume(Offer offer, Boolean decimalAligned, int maxNumberOfDigits, boolean showRange) {
|
||||
String formattedVolume = offer.isRange() && showRange ? formatVolume(offer.getMinVolume()) + RANGE_SEPARATOR + formatVolume(offer.getVolume()) : formatVolume(offer.getVolume());
|
||||
|
||||
if (decimalAligned) {
|
||||
formattedVolume = fillUpPlacesWithEmptyStrings(formattedVolume, maxNumberOfDigits);
|
||||
}
|
||||
return formattedVolume;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String fillUpPlacesWithEmptyStrings(String formattedNumber, int maxNumberOfDigits) {
|
||||
//FIXME: temporary deactivate adding spaces in front of numbers as we don't use a monospace font right now.
|
||||
|
@ -319,27 +268,7 @@ public class BSFormatter {
|
|||
return formattedNumber;
|
||||
}
|
||||
|
||||
public String formatVolume(Volume volume) {
|
||||
return formatVolume(volume, fiatVolumeFormat, false);
|
||||
}
|
||||
|
||||
public String formatVolumeWithCode(Volume volume) {
|
||||
return formatVolume(volume, fiatVolumeFormat, true);
|
||||
}
|
||||
|
||||
private static String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) {
|
||||
if (volume != null) {
|
||||
Monetary monetary = volume.getMonetary();
|
||||
if (monetary instanceof Fiat)
|
||||
return formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode);
|
||||
else
|
||||
return formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static String formatAltcoinVolume(Altcoin altcoin, boolean appendCurrencyCode) {
|
||||
public static String formatAltcoinVolume(Altcoin altcoin, boolean appendCurrencyCode) {
|
||||
if (altcoin != null) {
|
||||
try {
|
||||
// TODO quick hack...
|
||||
|
@ -361,40 +290,6 @@ public class BSFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
public static String formatVolumeLabel(String currencyCode) {
|
||||
return formatVolumeLabel(currencyCode, "");
|
||||
}
|
||||
|
||||
public static String formatVolumeLabel(String currencyCode, String postFix) {
|
||||
return Res.get("formatter.formatVolumeLabel",
|
||||
currencyCode, postFix);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Amount
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String formatAmount(Offer offer) {
|
||||
return formatAmount(offer, false);
|
||||
}
|
||||
|
||||
public String formatAmount(Offer offer, boolean decimalAligned) {
|
||||
String formattedAmount = offer.isRange() ? formatCoin(offer.getMinAmount()) + RANGE_SEPARATOR + formatCoin(offer.getAmount()) : formatCoin(offer.getAmount());
|
||||
if (decimalAligned) {
|
||||
formattedAmount = fillUpPlacesWithEmptyStrings(formattedAmount, 15);
|
||||
}
|
||||
return formattedAmount;
|
||||
}
|
||||
|
||||
public String formatAmount(Offer offer, int decimalPlaces, boolean decimalAligned, int maxPlaces) {
|
||||
String formattedAmount = offer.isRange() ? formatCoin(offer.getMinAmount(), decimalPlaces) + RANGE_SEPARATOR + formatCoin(offer.getAmount(), decimalPlaces) : formatCoin(offer.getAmount(), decimalPlaces);
|
||||
|
||||
if (decimalAligned) {
|
||||
formattedAmount = fillUpPlacesWithEmptyStrings(formattedAmount, maxPlaces);
|
||||
}
|
||||
return formattedAmount;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Price
|
||||
|
@ -413,23 +308,14 @@ public class BSFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
public String formatPrice(Price price, boolean appendCurrencyCode) {
|
||||
public static String formatPrice(Price price, boolean appendCurrencyCode) {
|
||||
return formatPrice(price, fiatPriceFormat, true);
|
||||
}
|
||||
|
||||
public String formatPrice(Price price) {
|
||||
public static String formatPrice(Price price) {
|
||||
return formatPrice(price, fiatPriceFormat, false);
|
||||
}
|
||||
|
||||
public String formatPrice(Price price, Boolean decimalAligned, int maxPlaces) {
|
||||
String formattedPrice = formatPrice(price);
|
||||
|
||||
if (decimalAligned) {
|
||||
formattedPrice = fillUpPlacesWithEmptyStrings(formattedPrice, maxPlaces);
|
||||
}
|
||||
return formattedPrice;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Market price
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -456,13 +342,6 @@ public class BSFormatter {
|
|||
return decimalFormat.format(MathUtils.roundDouble(value, precision)).replace(",", ".");
|
||||
}
|
||||
|
||||
public static String getDirectionWithCode(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyCurrency", Res.getBaseCurrencyCode()) : Res.get("shared.sellCurrency", Res.getBaseCurrencyCode());
|
||||
else
|
||||
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyCurrency", currencyCode) : Res.get("shared.sellCurrency", currencyCode);
|
||||
}
|
||||
|
||||
public static String getDirectionWithCodeDetailed(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyingBTCWith", currencyCode) : Res.get("shared.sellingBTCFor", currencyCode);
|
||||
|
@ -474,12 +353,8 @@ public class BSFormatter {
|
|||
return nodeAddresses.stream().map(NodeAddress::getFullAddress).collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
public static String formatDateTime(Date date) {
|
||||
return formatDateTime(date, true);
|
||||
}
|
||||
|
||||
public static String formatDateTime(Date date, boolean useLocaleAndLocalTimezone) {
|
||||
Locale locale = useLocaleAndLocalTimezone ? getLocale() : Locale.US;
|
||||
Locale locale = useLocaleAndLocalTimezone ? GlobalSettings.getLocale() : Locale.US;
|
||||
DateFormat dateInstance = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
|
||||
DateFormat timeInstance = DateFormat.getTimeInstance(DateFormat.DEFAULT, locale);
|
||||
if (!useLocaleAndLocalTimezone) {
|
||||
|
@ -497,34 +372,6 @@ public class BSFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
public static String formatDateTimeSpan(Date dateFrom, Date dateTo) {
|
||||
if (dateFrom != null && dateTo != null) {
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale());
|
||||
DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale());
|
||||
return dateFormatter.format(dateFrom) + " " + timeFormatter.format(dateFrom) + RANGE_SEPARATOR + timeFormatter.format(dateTo);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatTime(Date date) {
|
||||
if (date != null) {
|
||||
DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale());
|
||||
return timeFormatter.format(date);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
if (date != null) {
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale());
|
||||
return dateFormatter.format(date);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatToPercentWithSymbol(double value) {
|
||||
return formatToPercent(value) + "%";
|
||||
}
|
||||
|
@ -579,7 +426,7 @@ public class BSFormatter {
|
|||
return input.replace(",", ".");
|
||||
}
|
||||
|
||||
protected static String cleanDoubleInput(String input) {
|
||||
public static String cleanDoubleInput(String input) {
|
||||
input = convertCharsForNumber(input);
|
||||
if (input.equals("."))
|
||||
input = input.replace(".", "0.");
|
||||
|
@ -594,14 +441,6 @@ public class BSFormatter {
|
|||
return input;
|
||||
}
|
||||
|
||||
public static String formatAccountAge(long durationMillis) {
|
||||
durationMillis = Math.max(0, durationMillis);
|
||||
String day = Res.get("time.day").toLowerCase();
|
||||
String days = Res.get("time.days");
|
||||
String format = "d\' " + days + "\'";
|
||||
return StringUtils.replaceOnce(DurationFormatUtils.formatDuration(durationMillis, format), "1 " + days, "1 " + day);
|
||||
}
|
||||
|
||||
public static String formatDurationAsWords(long durationMillis) {
|
||||
return formatDurationAsWords(durationMillis, false, true);
|
||||
}
|
||||
|
@ -646,76 +485,6 @@ public class BSFormatter {
|
|||
return duration.trim();
|
||||
}
|
||||
|
||||
public static String booleanToYesNo(boolean value) {
|
||||
return value ? Res.get("shared.yes") : Res.get("shared.no");
|
||||
}
|
||||
|
||||
public static String getDirectionBothSides(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
currencyCode = Res.getBaseCurrencyCode();
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
|
||||
} else {
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDirectionForBuyer(boolean isMyOffer, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String code = Res.getBaseCurrencyCode();
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.buying"), code, Res.get("shared.selling"), code) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.buying"), code, Res.get("shared.selling"), code);
|
||||
} else {
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), currencyCode) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), currencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDirectionForSeller(boolean isMyOffer, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String code = Res.getBaseCurrencyCode();
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.selling"), code, Res.get("shared.buying"), code) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.selling"), code, Res.get("shared.buying"), code);
|
||||
} else {
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), currencyCode) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), currencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDirectionForTakeOffer(OfferPayload.Direction direction, String currencyCode) {
|
||||
String baseCurrencyCode = Res.getBaseCurrencyCode();
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.youAre", Res.get("shared.selling"), baseCurrencyCode, Res.get("shared.buying"), currencyCode) :
|
||||
Res.get("formatter.youAre", Res.get("shared.buying"), baseCurrencyCode, Res.get("shared.selling"), currencyCode);
|
||||
} else {
|
||||
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.youAre", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), baseCurrencyCode) :
|
||||
Res.get("formatter.youAre", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), baseCurrencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOfferDirectionForCreateOffer(OfferPayload.Direction direction, String currencyCode) {
|
||||
String baseCurrencyCode = Res.getBaseCurrencyCode();
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.buy"), baseCurrencyCode) :
|
||||
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.sell"), baseCurrencyCode);
|
||||
} else {
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.buy"), currencyCode, Res.get("shared.selling"), baseCurrencyCode) :
|
||||
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.sell"), currencyCode, Res.get("shared.buying"), baseCurrencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRole(boolean isBuyerMakerAndSellerTaker, boolean isMaker, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String baseCurrencyCode = Res.getBaseCurrencyCode();
|
||||
|
@ -776,8 +545,4 @@ public class BSFormatter {
|
|||
else
|
||||
return Res.get(translationKey, currencyCode, Res.getBaseCurrencyCode());
|
||||
}
|
||||
|
||||
private static Locale getLocale() {
|
||||
return GlobalSettings.getLocale();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package bisq.desktop.components;
|
||||
|
||||
import bisq.desktop.main.overlays.editor.PeerInfoWithTagEditor;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.alert.PrivateNotificationManager;
|
||||
|
@ -141,7 +142,7 @@ public class PeerInfoIcon extends Group {
|
|||
boolean isFiatCurrency = CurrencyUtil.isFiatCurrency(offer.getCurrencyCode());
|
||||
|
||||
String accountAge = isFiatCurrency ?
|
||||
peersAccountAge > -1 ? Res.get("peerInfoIcon.tooltip.age", BSFormatter.formatAccountAge(peersAccountAge)) :
|
||||
peersAccountAge > -1 ? Res.get("peerInfoIcon.tooltip.age", DisplayUtils.formatAccountAge(peersAccountAge)) :
|
||||
Res.get("peerInfoIcon.tooltip.unknownAge") :
|
||||
"";
|
||||
tooltipText = hasTraded ?
|
||||
|
@ -268,7 +269,7 @@ public class PeerInfoIcon extends Group {
|
|||
long makersAccountAge) {
|
||||
final String accountAgeTagEditor = isFiatCurrency ?
|
||||
makersAccountAge > -1 ?
|
||||
BSFormatter.formatAccountAge(makersAccountAge) :
|
||||
DisplayUtils.formatAccountAge(makersAccountAge) :
|
||||
Res.get("peerInfo.unknownAge") :
|
||||
null;
|
||||
setOnMouseClicked(e -> new PeerInfoWithTagEditor(privateNotificationManager, offer, preferences, useDevPrivilegeKeys)
|
||||
|
|
|
@ -21,6 +21,7 @@ import bisq.desktop.components.AutoTooltipCheckBox;
|
|||
import bisq.desktop.components.InfoTextField;
|
||||
import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
|
@ -182,7 +183,7 @@ public abstract class PaymentMethodForm {
|
|||
Res.get("payment.maxPeriodAndLimit",
|
||||
getTimeText(hours),
|
||||
formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrency.getCode()))),
|
||||
BSFormatter.formatAccountAge(accountAge));
|
||||
DisplayUtils.formatAccountAge(accountAge));
|
||||
|
||||
if (isDisplayForm)
|
||||
addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), limitationsText);
|
||||
|
|
|
@ -24,6 +24,7 @@ import bisq.desktop.components.BusyAnimation;
|
|||
import bisq.desktop.components.TableGroupHeadline;
|
||||
import bisq.desktop.components.TextFieldWithIcon;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.arbitration.Attachment;
|
||||
|
@ -404,7 +405,7 @@ public class Chat extends AnchorPane {
|
|||
AnchorPane.setLeftAnchor(statusHBox, padding);
|
||||
}
|
||||
AnchorPane.setBottomAnchor(statusHBox, 7d);
|
||||
headerLabel.setText(BSFormatter.formatDateTime(new Date(message.getDate())));
|
||||
headerLabel.setText(DisplayUtils.formatDateTime(new Date(message.getDate())));
|
||||
messageLabel.setText(message.getMessage());
|
||||
attachmentsBox.getChildren().clear();
|
||||
if (allowAttachments &&
|
||||
|
|
|
@ -37,6 +37,7 @@ import bisq.desktop.main.offer.SellOfferView;
|
|||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.portfolio.PortfolioView;
|
||||
import bisq.desktop.main.settings.SettingsView;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Transitions;
|
||||
|
||||
import bisq.core.dao.monitoring.DaoStateMonitoringService;
|
||||
|
@ -522,14 +523,14 @@ public class MainView extends InitializableView<StackPane, MainViewModel>
|
|||
res = Res.get("mainView.marketPrice.tooltip",
|
||||
"https://bitcoinaverage.com",
|
||||
"",
|
||||
formatter.formatTime(model.getPriceFeedService().getLastRequestTimeStampBtcAverage()),
|
||||
DisplayUtils.formatTime(model.getPriceFeedService().getLastRequestTimeStampBtcAverage()),
|
||||
model.getPriceFeedService().getProviderNodeAddress());
|
||||
} else {
|
||||
String altcoinExtra = "\n" + Res.get("mainView.marketPrice.tooltip.altcoinExtra");
|
||||
res = Res.get("mainView.marketPrice.tooltip",
|
||||
"https://poloniex.com",
|
||||
altcoinExtra,
|
||||
formatter.formatTime(model.getPriceFeedService().getLastRequestTimeStampPoloniex()),
|
||||
DisplayUtils.formatTime(model.getPriceFeedService().getLastRequestTimeStampPoloniex()),
|
||||
model.getPriceFeedService().getProviderNodeAddress());
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -32,6 +32,7 @@ import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
|
|||
import bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow;
|
||||
import bisq.desktop.main.presentation.DaoPresentation;
|
||||
import bisq.desktop.main.presentation.MarketPricePresentation;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -218,7 +219,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupCompleteList
|
|||
DontShowAgainLookup.dontShowAgain(key, true);
|
||||
new Popup<>().warning(Res.get("popup.warning.tradePeriod.halfReached",
|
||||
trade.getShortId(),
|
||||
BSFormatter.formatDateTime(maxTradePeriodDate)))
|
||||
DisplayUtils.formatDateTime(maxTradePeriodDate)))
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
|
@ -228,7 +229,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupCompleteList
|
|||
DontShowAgainLookup.dontShowAgain(key, true);
|
||||
new Popup<>().warning(Res.get("popup.warning.tradePeriod.ended",
|
||||
trade.getShortId(),
|
||||
BSFormatter.formatDateTime(maxTradePeriodDate)))
|
||||
DisplayUtils.formatDateTime(maxTradePeriodDate)))
|
||||
.show();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
package bisq.desktop.main.dao.bonding.bonds;
|
||||
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.dao.governance.bond.Bond;
|
||||
import bisq.core.dao.governance.bond.BondState;
|
||||
import bisq.core.dao.governance.bond.role.BondedRole;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
|
@ -59,7 +60,7 @@ class BondListItem {
|
|||
bondDetails = Utilities.bytesAsHexString(bond.getBondedAsset().getHash());
|
||||
}
|
||||
lockupTxId = bond.getLockupTxId();
|
||||
lockupDateString = bond.getLockupDate() > 0 ? BSFormatter.formatDateTime(new Date(bond.getLockupDate())) : "-";
|
||||
lockupDateString = bond.getLockupDate() > 0 ? DisplayUtils.formatDateTime(new Date(bond.getLockupDate())) : "-";
|
||||
bondState = bond.getBondState();
|
||||
bondStateString = Res.get("dao.bond.bondState." + bond.getBondState().name());
|
||||
}
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
package bisq.desktop.main.dao.bonding.reputation;
|
||||
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.dao.governance.bond.BondState;
|
||||
import bisq.core.dao.governance.bond.reputation.MyBondedReputation;
|
||||
import bisq.core.dao.governance.bond.reputation.MyReputation;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
|
@ -58,7 +59,7 @@ class MyReputationListItem {
|
|||
txId = myBondedReputation.getLockupTxId();
|
||||
amount = bsqFormatter.formatCoin(Coin.valueOf(myBondedReputation.getAmount()));
|
||||
lockupDate = new Date(myBondedReputation.getLockupDate());
|
||||
lockupDateString = BSFormatter.formatDateTime(lockupDate);
|
||||
lockupDateString = DisplayUtils.formatDateTime(lockupDate);
|
||||
lockTime = Integer.toString(myBondedReputation.getLockTime());
|
||||
lockupTxId = myBondedReputation.getLockupTxId();
|
||||
bondState = myBondedReputation.getBondState();
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
package bisq.desktop.main.dao.bonding.roles;
|
||||
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
|
||||
import bisq.core.dao.DaoFacade;
|
||||
import bisq.core.dao.state.model.governance.BondedRoleType;
|
||||
import bisq.core.dao.state.model.governance.RoleProposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
@ -98,6 +98,6 @@ class RoleDetailsWindow extends Overlay<RoleDetailsWindow> {
|
|||
bondedRoleType.getLink(), bondedRoleType.getLink(), 0);
|
||||
|
||||
FormBuilder.addTopLabelTextField(gridPane, ++rowIndex, Res.get("dao.bond.details.isSingleton"),
|
||||
BSFormatter.booleanToYesNo(bondedRoleType.isAllowMultipleHolders()));
|
||||
DisplayUtils.booleanToYesNo(bondedRoleType.isAllowMultipleHolders()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
|
||||
package bisq.desktop.main.dao.burnbsq.proofofburn;
|
||||
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.dao.governance.proofofburn.MyProofOfBurn;
|
||||
import bisq.core.dao.governance.proofofburn.ProofOfBurnService;
|
||||
import bisq.core.dao.state.model.blockchain.Tx;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
|
@ -53,7 +54,7 @@ class MyProofOfBurnListItem {
|
|||
if (optionalTx.isPresent()) {
|
||||
Tx tx = optionalTx.get();
|
||||
date = new Date(tx.getTime());
|
||||
dateAsString = BSFormatter.formatDateTime(date);
|
||||
dateAsString = DisplayUtils.formatDateTime(date);
|
||||
amount = proofOfBurnService.getAmount(tx);
|
||||
amountAsString = bsqFormatter.formatCoinWithCode(Coin.valueOf(amount));
|
||||
txId = tx.getId();
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
|
||||
package bisq.desktop.main.dao.burnbsq.proofofburn;
|
||||
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.dao.governance.proofofburn.ProofOfBurnService;
|
||||
import bisq.core.dao.state.model.blockchain.Tx;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Utilities;
|
||||
|
@ -47,6 +48,6 @@ class ProofOfBurnListItem {
|
|||
hashAsHex = Utilities.bytesAsHexString(proofOfBurnService.getHashFromOpReturnData(tx));
|
||||
pubKey = Utilities.bytesAsHexString(proofOfBurnService.getPubKey(txId));
|
||||
date = new Date(tx.getTime());
|
||||
dateAsString = BSFormatter.formatDateTime(date);
|
||||
dateAsString = DisplayUtils.formatDateTime(date);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
Optional<Price> optionalBsqPrice = priceFeedService.getBsqPrice();
|
||||
if (optionalBsqPrice.isPresent()) {
|
||||
Price bsqPrice = optionalBsqPrice.get();
|
||||
marketPriceLabel.setText(bsqFormatter.formatPrice(bsqPrice) + " BSQ/BTC");
|
||||
marketPriceLabel.setText(BSFormatter.formatPrice(bsqPrice) + " BSQ/BTC");
|
||||
|
||||
marketCapTextField.setText(bsqFormatter.formatMarketCap(priceFeedService.getMarketPrice("BSQ"),
|
||||
priceFeedService.getMarketPrice(preferences.getPreferredTradeCurrency().getCode()),
|
||||
|
|
|
@ -30,6 +30,7 @@ import bisq.desktop.components.TxIdTextField;
|
|||
import bisq.desktop.main.dao.governance.PhasesView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.overlays.windows.SelectProposalWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
import bisq.desktop.util.validation.BsqValidator;
|
||||
|
@ -718,7 +719,7 @@ public class ProposalsView extends ActivatableView<GridPane, Void> implements Bs
|
|||
public void updateItem(final ProposalsListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(BSFormatter.formatDateTime(item.getProposal().getCreationDateAsDate()));
|
||||
setText(DisplayUtils.formatDateTime(item.getProposal().getCreationDateAsDate()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import bisq.desktop.components.TableGroupHeadline;
|
|||
import bisq.desktop.main.dao.governance.PhasesView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.overlays.windows.ProposalResultsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
@ -57,7 +58,6 @@ import bisq.core.dao.state.model.governance.Role;
|
|||
import bisq.core.dao.state.model.governance.RoleProposal;
|
||||
import bisq.core.dao.state.model.governance.Vote;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.UserThread;
|
||||
|
@ -638,7 +638,7 @@ public class VoteResultView extends ActivatableView<GridPane, Void> implements D
|
|||
public void updateItem(final ProposalListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(BSFormatter.formatDateTime(item.getProposal().getCreationDateAsDate()));
|
||||
setText(DisplayUtils.formatDateTime(item.getProposal().getCreationDateAsDate()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import bisq.desktop.components.AutoTooltipLabel;
|
|||
import bisq.desktop.components.AutoTooltipTableColumn;
|
||||
import bisq.desktop.components.HyperlinkWithIcon;
|
||||
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
|
@ -38,7 +39,6 @@ import bisq.core.dao.state.model.blockchain.TxType;
|
|||
import bisq.core.dao.state.model.governance.IssuanceType;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.Timer;
|
||||
|
@ -368,7 +368,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
setText(BSFormatter.formatDateTime(item.getDate()));
|
||||
setText(DisplayUtils.formatDateTime(item.getDate()));
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
style = "dao-tx-type-issuance-icon";
|
||||
int issuanceBlockHeight = daoFacade.getIssuanceBlockHeight(txId);
|
||||
long blockTime = daoFacade.getBlockTime(issuanceBlockHeight);
|
||||
String formattedDate = BSFormatter.formatDateTime(new Date(blockTime));
|
||||
String formattedDate = DisplayUtils.formatDateTime(new Date(blockTime));
|
||||
toolTipText = Res.get("dao.tx.issuanceFromCompReq.tooltip", formattedDate);
|
||||
} else {
|
||||
awesomeIcon = AwesomeIcon.FILE_TEXT;
|
||||
|
@ -645,7 +645,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
style = "dao-tx-type-issuance-icon";
|
||||
int issuanceBlockHeight = daoFacade.getIssuanceBlockHeight(txId);
|
||||
long blockTime = daoFacade.getBlockTime(issuanceBlockHeight);
|
||||
String formattedDate = BSFormatter.formatDateTime(new Date(blockTime));
|
||||
String formattedDate = DisplayUtils.formatDateTime(new Date(blockTime));
|
||||
toolTipText = Res.get("dao.tx.issuanceFromReimbursement.tooltip", formattedDate);
|
||||
} else {
|
||||
awesomeIcon = AwesomeIcon.FILE_TEXT;
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.desktop.main.disputes.trader.TraderDisputeView;
|
|||
import bisq.desktop.main.overlays.windows.ContractWindow;
|
||||
import bisq.desktop.main.overlays.windows.DisputeSummaryWindow;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.alert.PrivateNotificationManager;
|
||||
|
@ -79,7 +80,7 @@ public class ArbitratorDisputeView extends TraderDisputeView {
|
|||
// If in arbitrator view we must only display disputes where we are selected as arbitrator (must not receive others anyway)
|
||||
filteredList.setPredicate(dispute -> {
|
||||
boolean matchesTradeId = dispute.getTradeId().contains(filterString);
|
||||
boolean matchesDate = formatter.formatDate(dispute.getOpeningDate()).contains(filterString);
|
||||
boolean matchesDate = DisplayUtils.formatDate(dispute.getOpeningDate()).contains(filterString);
|
||||
boolean isBuyerOnion = dispute.getContract().getBuyerNodeAddress().getFullAddress().contains(filterString);
|
||||
boolean isSellerOnion = dispute.getContract().getSellerNodeAddress().getFullAddress().contains(filterString);
|
||||
boolean matchesBuyersPaymentAccountData = dispute.getContract().getBuyerPaymentAccountPayload().getPaymentDetails().contains(filterString);
|
||||
|
|
|
@ -30,6 +30,7 @@ import bisq.desktop.main.overlays.windows.ContractWindow;
|
|||
import bisq.desktop.main.overlays.windows.DisputeSummaryWindow;
|
||||
import bisq.desktop.main.overlays.windows.SendPrivateNotificationWindow;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -257,7 +258,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
|||
.append(dispute0.getTradeId())
|
||||
.append("\n")
|
||||
.append("## Date: ")
|
||||
.append(BSFormatter.formatDateTime(dispute0.getOpeningDate()))
|
||||
.append(DisplayUtils.formatDateTime(dispute0.getOpeningDate()))
|
||||
.append("\n")
|
||||
.append("## Is support ticket: ")
|
||||
.append(dispute0.isSupportTicket())
|
||||
|
@ -582,7 +583,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
|||
public void updateItem(final Dispute item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty)
|
||||
setText(BSFormatter.formatDateTime(item.getOpeningDate()));
|
||||
setText(DisplayUtils.formatDateTime(item.getOpeningDate()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
|
@ -693,7 +694,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
|||
if (buyerNodeAddress != null) {
|
||||
String nrOfDisputes = disputeManager.getNrOfDisputes(true, contract);
|
||||
long accountAge = accountAgeWitnessService.getAccountAge(contract.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing());
|
||||
String age = BSFormatter.formatAccountAge(accountAge);
|
||||
String age = DisplayUtils.formatAccountAge(accountAge);
|
||||
String postFix = CurrencyUtil.isFiatCurrency(item.getContract().getOfferPayload().getCurrencyCode()) ? " / " + age : "";
|
||||
return buyerNodeAddress.getHostNameWithoutPostFix() + " (" + nrOfDisputes + postFix + ")";
|
||||
} else
|
||||
|
@ -710,7 +711,7 @@ public class TraderDisputeView extends ActivatableView<VBox, Void> {
|
|||
if (sellerNodeAddress != null) {
|
||||
String nrOfDisputes = disputeManager.getNrOfDisputes(false, contract);
|
||||
long accountAge = accountAgeWitnessService.getAccountAge(contract.getSellerPaymentAccountPayload(), contract.getSellerPubKeyRing());
|
||||
String age = BSFormatter.formatAccountAge(accountAge);
|
||||
String age = DisplayUtils.formatAccountAge(accountAge);
|
||||
String postFix = CurrencyUtil.isFiatCurrency(item.getContract().getOfferPayload().getCurrencyCode()) ? " / " + age : "";
|
||||
return sellerNodeAddress.getHostNameWithoutPostFix() + " (" + nrOfDisputes + postFix + ")";
|
||||
} else
|
||||
|
|
|
@ -23,6 +23,7 @@ import bisq.desktop.components.AutoTooltipLabel;
|
|||
import bisq.desktop.components.HyperlinkWithIcon;
|
||||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.listeners.BalanceListener;
|
||||
|
@ -228,7 +229,7 @@ public class LockedView extends ActivatableView<VBox, Void> {
|
|||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
if (getTradable(item).isPresent())
|
||||
setGraphic(new AutoTooltipLabel(BSFormatter.formatDateTime(getTradable(item).get().getDate())));
|
||||
setGraphic(new AutoTooltipLabel(DisplayUtils.formatDateTime(getTradable(item).get().getDate())));
|
||||
else
|
||||
setGraphic(new AutoTooltipLabel(Res.get("shared.noDateAvailable")));
|
||||
} else {
|
||||
|
|
|
@ -23,6 +23,7 @@ import bisq.desktop.components.AutoTooltipLabel;
|
|||
import bisq.desktop.components.HyperlinkWithIcon;
|
||||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.listeners.BalanceListener;
|
||||
|
@ -228,7 +229,7 @@ public class ReservedView extends ActivatableView<VBox, Void> {
|
|||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
if (getTradable(item).isPresent())
|
||||
setGraphic(new AutoTooltipLabel(BSFormatter.formatDateTime(getTradable(item).get().getDate())));
|
||||
setGraphic(new AutoTooltipLabel(DisplayUtils.formatDateTime(getTradable(item).get().getDate())));
|
||||
else
|
||||
setGraphic(new AutoTooltipLabel(Res.get("shared.noDateAvailable")));
|
||||
} else {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package bisq.desktop.main.funds.transactions;
|
||||
|
||||
import bisq.desktop.components.indicator.TxConfidenceIndicator;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.btc.listeners.TxConfidenceListener;
|
||||
|
@ -239,7 +240,7 @@ class TransactionsListItem {
|
|||
}
|
||||
// Use tx.getIncludedInBestChainAt() when available, otherwise use tx.getUpdateTime()
|
||||
date = transaction.getIncludedInBestChainAt() != null ? transaction.getIncludedInBestChainAt() : transaction.getUpdateTime();
|
||||
dateString = BSFormatter.formatDateTime(date);
|
||||
dateString = DisplayUtils.formatDateTime(date);
|
||||
|
||||
isDustAttackTx = received && valueSentToMe.value < ignoreDustThreshold;
|
||||
if (isDustAttackTx) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import bisq.desktop.main.market.trades.TradesChartsView;
|
|||
import bisq.desktop.main.offer.offerbook.OfferBook;
|
||||
import bisq.desktop.main.offer.offerbook.OfferBookListItem;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.offer.OfferPayload;
|
||||
|
@ -183,11 +184,11 @@ public class MarketView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
.map(trade -> {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Trade ID: ").append(trade.getOfferId()).append("\n")
|
||||
.append("Date: ").append(BSFormatter.formatDateTime(trade.getTradeDate())).append("\n")
|
||||
.append("Date: ").append(DisplayUtils.formatDateTime(trade.getTradeDate())).append("\n")
|
||||
.append("Market: ").append(BSFormatter.getCurrencyPair(trade.getCurrencyCode())).append("\n")
|
||||
.append("Price: ").append(formatter.formatPrice(trade.getTradePrice())).append("\n")
|
||||
.append("Price: ").append(BSFormatter.formatPrice(trade.getTradePrice())).append("\n")
|
||||
.append("Amount: ").append(formatter.formatCoin(trade.getTradeAmount())).append("\n")
|
||||
.append("Volume: ").append(formatter.formatVolume(trade.getTradeVolume())).append("\n")
|
||||
.append("Volume: ").append(DisplayUtils.formatVolume(trade.getTradeVolume())).append("\n")
|
||||
.append("Payment method: ").append(Res.get(trade.getOfferPaymentMethod())).append("\n")
|
||||
.append("ReferralID: ").append(trade.getExtraDataMap().get(OfferPayload.REFERRAL_ID));
|
||||
return sb.toString();
|
||||
|
@ -206,8 +207,8 @@ public class MarketView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
sb.append("Offer ID: ").append(offer.getId()).append("\n")
|
||||
.append("Type: ").append(offer.getDirection().name()).append("\n")
|
||||
.append("Market: ").append(BSFormatter.getCurrencyPair(offer.getCurrencyCode())).append("\n")
|
||||
.append("Price: ").append(formatter.formatPrice(offer.getPrice())).append("\n")
|
||||
.append("Amount: ").append(formatter.formatAmount(offer)).append(" BTC\n")
|
||||
.append("Price: ").append(BSFormatter.formatPrice(offer.getPrice())).append("\n")
|
||||
.append("Amount: ").append(DisplayUtils.formatAmount(offer, formatter)).append(" BTC\n")
|
||||
.append("Payment method: ").append(Res.get(offer.getPaymentMethod().getId())).append("\n")
|
||||
.append("ReferralID: ").append(offer.getOfferPayload().getExtraDataMap().get(OfferPayload.REFERRAL_ID));
|
||||
return sb.toString();
|
||||
|
|
|
@ -26,6 +26,7 @@ import bisq.desktop.main.settings.SettingsView;
|
|||
import bisq.desktop.main.settings.preferences.PreferencesView;
|
||||
import bisq.desktop.util.CurrencyList;
|
||||
import bisq.desktop.util.CurrencyListItem;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -254,7 +255,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
}
|
||||
|
||||
private String formatPrice(Offer offer, boolean decimalAligned) {
|
||||
return formatter.formatPrice(offer.getPrice(), decimalAligned, offer.isBuyOffer() ? maxPlacesForBuyPrice.get() : maxPlacesForSellPrice.get());
|
||||
return DisplayUtils.formatPrice(offer.getPrice(), decimalAligned, offer.isBuyOffer() ? maxPlacesForBuyPrice.get() : maxPlacesForSellPrice.get());
|
||||
}
|
||||
|
||||
public String getVolume(Offer offer) {
|
||||
|
@ -262,7 +263,7 @@ class OfferBookChartViewModel extends ActivatableViewModel {
|
|||
}
|
||||
|
||||
private String formatVolume(Offer offer, boolean decimalAligned) {
|
||||
return formatter.formatVolume(offer, decimalAligned, offer.isBuyOffer() ? maxPlacesForBuyVolume.get() : maxPlacesForSellVolume.get(), false);
|
||||
return DisplayUtils.formatVolume(offer, decimalAligned, offer.isBuyOffer() ? maxPlacesForBuyVolume.get() : maxPlacesForSellVolume.get(), false);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -27,6 +27,7 @@ import bisq.desktop.components.ColoredDecimalPlacesWithZerosText;
|
|||
import bisq.desktop.main.market.trades.charts.price.CandleStickChart;
|
||||
import bisq.desktop.main.market.trades.charts.volume.VolumeChart;
|
||||
import bisq.desktop.util.CurrencyListItem;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
|
@ -347,7 +348,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
final double value = MathUtils.scaleDownByPowerOf10(doubleValue, 8);
|
||||
return BSFormatter.formatRoundedDoubleWithPrecision(value, 8);
|
||||
} else {
|
||||
return formatter.formatPrice(Price.valueOf(currencyCode, MathUtils.doubleToLong(doubleValue)));
|
||||
return BSFormatter.formatPrice(Price.valueOf(currencyCode, MathUtils.doubleToLong(doubleValue)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +365,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
final double value = MathUtils.scaleDownByPowerOf10((long) object, 8);
|
||||
return BSFormatter.formatRoundedDoubleWithPrecision(value, 8);
|
||||
} else {
|
||||
return formatter.formatPrice(Price.valueOf(model.getCurrencyCode(), (long) object));
|
||||
return BSFormatter.formatPrice(Price.valueOf(model.getCurrencyCode(), (long) object));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -480,9 +481,9 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
long index = MathUtils.doubleToLong((double) object);
|
||||
long time = model.getTimeFromTickIndex(index);
|
||||
if (model.tickUnit.ordinal() <= TradesChartsViewModel.TickUnit.DAY.ordinal())
|
||||
return index % 4 == 0 ? formatter.formatDate(new Date(time)) : "";
|
||||
return index % 4 == 0 ? DisplayUtils.formatDate(new Date(time)) : "";
|
||||
else
|
||||
return index % 3 == 0 ? formatter.formatTime(new Date(time)) : "";
|
||||
return index % 3 == 0 ? DisplayUtils.formatTime(new Date(time)) : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -568,7 +569,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
public void updateItem(final TradeStatistics2 item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(BSFormatter.formatDateTime(item.getTradeDate()));
|
||||
setText(DisplayUtils.formatDateTime(item.getTradeDate()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
|
@ -621,7 +622,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
public void updateItem(final TradeStatistics2 item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(formatter.formatPrice(item.getTradePrice()));
|
||||
setText(BSFormatter.formatPrice(item.getTradePrice()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
|
@ -671,8 +672,8 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
super.updateItem(item, empty);
|
||||
if (item != null)
|
||||
setText(model.showAllTradeCurrenciesProperty.get() ?
|
||||
formatter.formatVolumeWithCode(item.getTradeVolume()) :
|
||||
formatter.formatVolume(item.getTradeVolume()));
|
||||
DisplayUtils.formatVolumeWithCode(item.getTradeVolume()) :
|
||||
DisplayUtils.formatVolume(item.getTradeVolume()));
|
||||
else
|
||||
setText("");
|
||||
}
|
||||
|
@ -744,7 +745,7 @@ public class TradesChartsView extends ActivatableViewAndModel<VBox, TradesCharts
|
|||
|
||||
@NotNull
|
||||
private String getDirectionLabel(TradeStatistics2 item) {
|
||||
return BSFormatter.getDirectionWithCode(OfferPayload.Direction.valueOf(item.getDirection().name()), item.getCurrencyCode());
|
||||
return DisplayUtils.getDirectionWithCode(OfferPayload.Direction.valueOf(item.getDirection().name()), item.getCurrencyCode());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.desktop.main.settings.SettingsView;
|
|||
import bisq.desktop.main.settings.preferences.PreferencesView;
|
||||
import bisq.desktop.util.CurrencyList;
|
||||
import bisq.desktop.util.CurrencyListItem;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.locale.CryptoCurrency;
|
||||
|
@ -345,12 +346,12 @@ class TradesChartsViewModel extends ActivatableViewModel {
|
|||
final Date dateFrom = new Date(getTimeFromTickIndex(tick));
|
||||
final Date dateTo = new Date(getTimeFromTickIndex(tick + 1));
|
||||
String dateString = tickUnit.ordinal() > TickUnit.DAY.ordinal() ?
|
||||
formatter.formatDateTimeSpan(dateFrom, dateTo) :
|
||||
formatter.formatDate(dateFrom) + " - " + formatter.formatDate(dateTo);
|
||||
DisplayUtils.formatDateTimeSpan(dateFrom, dateTo) :
|
||||
DisplayUtils.formatDate(dateFrom) + " - " + DisplayUtils.formatDate(dateTo);
|
||||
return new CandleData(tick, open, close, high, low, averagePrice, medianPrice, accumulatedAmount, accumulatedVolume,
|
||||
numTrades, isBullish, dateString);
|
||||
}
|
||||
|
||||
|
||||
Long findMedian(Long[] prices) {
|
||||
int middle = prices.length / 2;
|
||||
long median;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package bisq.desktop.main.offer;
|
||||
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeRestrictions;
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.arbitration.Arbitrator;
|
||||
|
@ -646,7 +648,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
|
|||
!price.get().isZero() &&
|
||||
allowAmountUpdate) {
|
||||
try {
|
||||
Coin value = btcFormatter.reduceTo4Decimals(price.get().getAmountByVolume(volume.get()));
|
||||
Coin value = DisplayUtils.reduceTo4Decimals(price.get().getAmountByVolume(volume.get()), btcFormatter);
|
||||
if (isHalCashAccount())
|
||||
value = OfferUtil.getAdjustedAmountForHalCash(value, price.get(), getMaxTradeLimit());
|
||||
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.desktop.main.funds.deposit.DepositView;
|
|||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.settings.SettingsView;
|
||||
import bisq.desktop.main.settings.preferences.PreferencesView;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.validation.AltcoinValidator;
|
||||
import bisq.desktop.util.validation.BsqValidator;
|
||||
|
@ -441,7 +442,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
priceListener = (ov, oldValue, newValue) -> {
|
||||
ignorePriceStringListener = true;
|
||||
if (newValue != null)
|
||||
price.set(btcFormatter.formatPrice(newValue));
|
||||
price.set(BSFormatter.formatPrice(newValue));
|
||||
else
|
||||
price.set("");
|
||||
|
||||
|
@ -451,7 +452,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
volumeListener = (ov, oldValue, newValue) -> {
|
||||
ignoreVolumeStringListener = true;
|
||||
if (newValue != null)
|
||||
volume.set(btcFormatter.formatVolume(newValue));
|
||||
volume.set(DisplayUtils.formatVolume(newValue));
|
||||
else
|
||||
volume.set("");
|
||||
|
||||
|
@ -492,7 +493,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
Coin makerFeeInBtc = dataModel.getMakerFeeInBtc();
|
||||
Optional<Volume> optionalBtcFeeInFiat = OfferUtil.getFeeInUserFiatCurrency(makerFeeInBtc,
|
||||
true, preferences, priceFeedService, bsqFormatter);
|
||||
String btcFeeWithFiatAmount = OfferUtil.getFeeWithFiatAmount(makerFeeInBtc, optionalBtcFeeInFiat, btcFormatter);
|
||||
String btcFeeWithFiatAmount = DisplayUtils.getFeeWithFiatAmount(makerFeeInBtc, optionalBtcFeeInFiat, btcFormatter);
|
||||
if (DevEnv.isDaoActivated()) {
|
||||
tradeFeeInBtcWithFiat.set(btcFeeWithFiatAmount);
|
||||
} else {
|
||||
|
@ -502,14 +503,14 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
Coin makerFeeInBsq = dataModel.getMakerFeeInBsq();
|
||||
Optional<Volume> optionalBsqFeeInFiat = OfferUtil.getFeeInUserFiatCurrency(makerFeeInBsq,
|
||||
false, preferences, priceFeedService, bsqFormatter);
|
||||
String bsqFeeWithFiatAmount = OfferUtil.getFeeWithFiatAmount(makerFeeInBsq, optionalBsqFeeInFiat, bsqFormatter);
|
||||
String bsqFeeWithFiatAmount = DisplayUtils.getFeeWithFiatAmount(makerFeeInBsq, optionalBsqFeeInFiat, bsqFormatter);
|
||||
if (DevEnv.isDaoActivated()) {
|
||||
tradeFeeInBsqWithFiat.set(bsqFeeWithFiatAmount);
|
||||
} else {
|
||||
// Before DAO is enabled we show fee as fiat and % in second line
|
||||
String feeInFiatAsString;
|
||||
if (optionalBtcFeeInFiat != null && optionalBtcFeeInFiat.isPresent()) {
|
||||
feeInFiatAsString = btcFormatter.formatVolumeWithCode(optionalBtcFeeInFiat.get());
|
||||
feeInFiatAsString = DisplayUtils.formatVolumeWithCode(optionalBtcFeeInFiat.get());
|
||||
} else {
|
||||
feeInFiatAsString = Res.get("shared.na");
|
||||
}
|
||||
|
@ -757,7 +758,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
|
||||
if (dataModel.getMinVolume().get() != null) {
|
||||
InputValidator.ValidationResult minVolumeResult = isVolumeInputValid(
|
||||
btcFormatter.formatVolume(dataModel.getMinVolume().get()));
|
||||
DisplayUtils.formatVolume(dataModel.getMinVolume().get()));
|
||||
|
||||
volumeValidationResult.set(minVolumeResult);
|
||||
|
||||
|
@ -788,7 +789,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
setPriceToModel();
|
||||
ignorePriceStringListener = true;
|
||||
if (dataModel.getPrice().get() != null)
|
||||
price.set(btcFormatter.formatPrice(dataModel.getPrice().get()));
|
||||
price.set(BSFormatter.formatPrice(dataModel.getPrice().get()));
|
||||
ignorePriceStringListener = false;
|
||||
dataModel.calculateVolume();
|
||||
dataModel.calculateAmount();
|
||||
|
@ -836,7 +837,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
|
||||
volume = OfferUtil.getRoundedFiatVolume(volume);
|
||||
|
||||
this.volume.set(btcFormatter.formatVolume(volume));
|
||||
this.volume.set(DisplayUtils.formatVolume(volume));
|
||||
}
|
||||
|
||||
ignoreVolumeStringListener = false;
|
||||
|
@ -1062,7 +1063,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
|
||||
private void setAmountToModel() {
|
||||
if (amount.get() != null && !amount.get().isEmpty()) {
|
||||
Coin amount = btcFormatter.parseToCoinWith4Decimals(this.amount.get());
|
||||
Coin amount = DisplayUtils.parseToCoinWith4Decimals(this.amount.get(), btcFormatter);
|
||||
|
||||
long maxTradeLimit = dataModel.getMaxTradeLimit();
|
||||
Price price = dataModel.getPrice().get();
|
||||
|
@ -1086,7 +1087,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
|
||||
private void setMinAmountToModel() {
|
||||
if (minAmount.get() != null && !minAmount.get().isEmpty()) {
|
||||
Coin minAmount = btcFormatter.parseToCoinWith4Decimals(this.minAmount.get());
|
||||
Coin minAmount = DisplayUtils.parseToCoinWith4Decimals(this.minAmount.get(), btcFormatter);
|
||||
|
||||
Price price = dataModel.getPrice().get();
|
||||
long maxTradeLimit = dataModel.getMaxTradeLimit();
|
||||
|
@ -1188,7 +1189,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
dataModel.getPrice().get() != null &&
|
||||
dataModel.getPrice().get().getValue() != 0 &&
|
||||
isVolumeInputValid(volume.get()).isValid &&
|
||||
isVolumeInputValid(btcFormatter.formatVolume(dataModel.getMinVolume().get())).isValid &&
|
||||
isVolumeInputValid(DisplayUtils.formatVolume(dataModel.getMinVolume().get())).isValid &&
|
||||
dataModel.isMinAmountLessOrEqualAmount();
|
||||
|
||||
isNextButtonDisabled.set(!inputDataValid);
|
||||
|
@ -1207,4 +1208,5 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
|
|||
private BSFormatter getFormatterForMakerFee() {
|
||||
return dataModel.isCurrencyForMakerFeeBtc() ? btcFormatter : bsqFormatter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import bisq.desktop.main.funds.withdrawal.WithdrawalView;
|
|||
import bisq.desktop.main.offer.OfferView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
@ -573,7 +574,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
|
|||
final long tradeLimit = model.accountAgeWitnessService.getMyTradeLimit(account.get(), offer.getCurrencyCode());
|
||||
new Popup<>()
|
||||
.warning(Res.get("offerbook.warning.tradeLimitNotMatching",
|
||||
BSFormatter.formatAccountAge(model.accountAgeWitnessService.getMyAccountAge(account.get().getPaymentAccountPayload())),
|
||||
DisplayUtils.formatAccountAge(model.accountAgeWitnessService.getMyAccountAge(account.get().getPaymentAccountPayload())),
|
||||
formatter.formatCoinWithCode(Coin.valueOf(tradeLimit)),
|
||||
formatter.formatCoinWithCode(offer.getMinAmount())))
|
||||
.show();
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.desktop.common.model.ActivatableViewModel;
|
|||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.settings.SettingsView;
|
||||
import bisq.desktop.main.settings.preferences.PreferencesView;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -341,7 +342,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
}
|
||||
|
||||
private String formatAmount(Offer offer, boolean decimalAligned) {
|
||||
return formatter.formatAmount(offer, GUIUtil.AMOUNT_DECIMALS, decimalAligned, maxPlacesForAmount.get());
|
||||
return DisplayUtils.formatAmount(offer, GUIUtil.AMOUNT_DECIMALS, decimalAligned, maxPlacesForAmount.get(), formatter);
|
||||
}
|
||||
|
||||
|
||||
|
@ -363,7 +364,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
}
|
||||
|
||||
private String formatPrice(Offer offer, boolean decimalAligned) {
|
||||
return formatter.formatPrice(offer.getPrice(), decimalAligned, maxPlacesForPrice.get());
|
||||
return DisplayUtils.formatPrice(offer.getPrice(), decimalAligned, maxPlacesForPrice.get());
|
||||
}
|
||||
|
||||
private String formatMarketPriceMargin(Offer offer, boolean decimalAligned) {
|
||||
|
@ -390,7 +391,7 @@ class OfferBookViewModel extends ActivatableViewModel {
|
|||
if (offerVolume != null && minOfferVolume != null) {
|
||||
String postFix = showAllTradeCurrenciesProperty.get() ? " " + offer.getCurrencyCode() : "";
|
||||
decimalAligned = decimalAligned && !showAllTradeCurrenciesProperty.get();
|
||||
return formatter.formatVolume(offer, decimalAligned, maxPlacesForVolume.get()) + postFix;
|
||||
return DisplayUtils.formatVolume(offer, decimalAligned, maxPlacesForVolume.get()) + postFix;
|
||||
} else {
|
||||
return Res.get("shared.na");
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import bisq.desktop.main.MainView;
|
|||
import bisq.desktop.main.funds.FundsView;
|
||||
import bisq.desktop.main.funds.deposit.DepositView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.validation.BtcValidator;
|
||||
|
||||
|
@ -205,7 +206,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
}
|
||||
|
||||
amountRange = btcFormatter.formatCoin(offer.getMinAmount()) + " - " + btcFormatter.formatCoin(offer.getAmount());
|
||||
price = btcFormatter.formatPrice(dataModel.tradePrice);
|
||||
price = BSFormatter.formatPrice(dataModel.tradePrice);
|
||||
marketPriceMargin = BSFormatter.formatToPercent(offer.getMarketPriceMargin());
|
||||
paymentLabel = Res.get("takeOffer.fundsBox.paymentLabel", offer.getShortId());
|
||||
|
||||
|
@ -288,7 +289,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
Coin makerFeeInBtc = dataModel.getTakerFeeInBtc();
|
||||
Optional<Volume> optionalBtcFeeInFiat = OfferUtil.getFeeInUserFiatCurrency(makerFeeInBtc,
|
||||
true, preferences, priceFeedService, bsqFormatter);
|
||||
String btcFeeWithFiatAmount = OfferUtil.getFeeWithFiatAmount(makerFeeInBtc, optionalBtcFeeInFiat, btcFormatter);
|
||||
String btcFeeWithFiatAmount = DisplayUtils.getFeeWithFiatAmount(makerFeeInBtc, optionalBtcFeeInFiat, btcFormatter);
|
||||
if (DevEnv.isDaoActivated()) {
|
||||
tradeFeeInBtcWithFiat.set(btcFeeWithFiatAmount);
|
||||
} else {
|
||||
|
@ -298,14 +299,14 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
Coin makerFeeInBsq = dataModel.getTakerFeeInBsq();
|
||||
Optional<Volume> optionalBsqFeeInFiat = OfferUtil.getFeeInUserFiatCurrency(makerFeeInBsq,
|
||||
false, preferences, priceFeedService, bsqFormatter);
|
||||
String bsqFeeWithFiatAmount = OfferUtil.getFeeWithFiatAmount(makerFeeInBsq, optionalBsqFeeInFiat, bsqFormatter);
|
||||
String bsqFeeWithFiatAmount = DisplayUtils.getFeeWithFiatAmount(makerFeeInBsq, optionalBsqFeeInFiat, bsqFormatter);
|
||||
if (DevEnv.isDaoActivated()) {
|
||||
tradeFeeInBsqWithFiat.set(bsqFeeWithFiatAmount);
|
||||
} else {
|
||||
// Before DAO is enabled we show fee as fiat and % in second line
|
||||
String feeInFiatAsString;
|
||||
if (optionalBtcFeeInFiat != null && optionalBtcFeeInFiat.isPresent()) {
|
||||
feeInFiatAsString = btcFormatter.formatVolumeWithCode(optionalBtcFeeInFiat.get());
|
||||
feeInFiatAsString = DisplayUtils.formatVolumeWithCode(optionalBtcFeeInFiat.get());
|
||||
} else {
|
||||
feeInFiatAsString = Res.get("shared.na");
|
||||
}
|
||||
|
@ -334,7 +335,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
InputValidator.ValidationResult result = isBtcInputValid(amount.get());
|
||||
amountValidationResult.set(result);
|
||||
if (result.isValid) {
|
||||
showWarningInvalidBtcDecimalPlaces.set(!btcFormatter.hasBtcValidDecimals(userInput));
|
||||
showWarningInvalidBtcDecimalPlaces.set(!DisplayUtils.hasBtcValidDecimals(userInput, btcFormatter));
|
||||
// only allow max 4 decimal places for btc values
|
||||
setAmountToModel();
|
||||
// reformat input
|
||||
|
@ -503,7 +504,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void addBindings() {
|
||||
volume.bind(createStringBinding(() -> btcFormatter.formatVolume(dataModel.volume.get()), dataModel.volume));
|
||||
volume.bind(createStringBinding(() -> DisplayUtils.formatVolume(dataModel.volume.get()), dataModel.volume));
|
||||
|
||||
if (dataModel.getDirection() == OfferPayload.Direction.SELL) {
|
||||
volumeDescriptionLabel.set(Res.get("createOffer.amountPriceBox.buy.volumeDescription", dataModel.getCurrencyCode()));
|
||||
|
@ -626,7 +627,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
|
|||
|
||||
private void setAmountToModel() {
|
||||
if (amount.get() != null && !amount.get().isEmpty()) {
|
||||
Coin amount = btcFormatter.parseToCoinWith4Decimals(this.amount.get());
|
||||
Coin amount = DisplayUtils.parseToCoinWith4Decimals(this.amount.get(), btcFormatter);
|
||||
long maxTradeLimit = dataModel.getMaxTradeLimit();
|
||||
Price price = dataModel.tradePrice;
|
||||
if (price != null) {
|
||||
|
|
|
@ -20,6 +20,7 @@ package bisq.desktop.main.overlays.windows;
|
|||
import bisq.desktop.components.BisqTextArea;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -133,16 +134,16 @@ public class ContractWindow extends Overlay<ContractWindow> {
|
|||
addConfirmationLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.offerId"), offer.getId(),
|
||||
Layout.TWICE_FIRST_ROW_DISTANCE).second.setMouseTransparent(false);
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("contractWindow.dates"),
|
||||
BSFormatter.formatDateTime(offer.getDate()) + " / " + BSFormatter.formatDateTime(dispute.getTradeDate()));
|
||||
DisplayUtils.formatDateTime(offer.getDate()) + " / " + DisplayUtils.formatDateTime(dispute.getTradeDate()));
|
||||
String currencyCode = offer.getCurrencyCode();
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.offerType"),
|
||||
BSFormatter.getDirectionBothSides(offer.getDirection(), currencyCode));
|
||||
DisplayUtils.getDirectionBothSides(offer.getDirection(), currencyCode));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
|
||||
formatter.formatPrice(contract.getTradePrice()));
|
||||
BSFormatter.formatPrice(contract.getTradePrice()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
|
||||
formatter.formatCoinWithCode(contract.getTradeAmount()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, BSFormatter.formatVolumeLabel(currencyCode, ":"),
|
||||
formatter.formatVolumeWithCode(contract.getTradeVolume()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, DisplayUtils.formatVolumeLabel(currencyCode, ":"),
|
||||
DisplayUtils.formatVolumeWithCode(contract.getTradeVolume()));
|
||||
String securityDeposit = Res.getWithColAndCap("shared.buyer") +
|
||||
" " +
|
||||
formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) +
|
||||
|
@ -261,7 +262,7 @@ public class ContractWindow extends Overlay<ContractWindow> {
|
|||
private String getAccountAge(PaymentAccountPayload paymentAccountPayload, PubKeyRing pubKeyRing, String currencyCode) {
|
||||
long age = accountAgeWitnessService.getAccountAge(paymentAccountPayload, pubKeyRing);
|
||||
return CurrencyUtil.isFiatCurrency(currencyCode) ?
|
||||
age > -1 ? Res.get("peerInfoIcon.tooltip.age", BSFormatter.formatAccountAge(age)) :
|
||||
age > -1 ? Res.get("peerInfoIcon.tooltip.age", DisplayUtils.formatAccountAge(age)) :
|
||||
Res.get("peerInfoIcon.tooltip.unknownAge") :
|
||||
"";
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import bisq.desktop.components.BisqTextArea;
|
|||
import bisq.desktop.components.InputTextField;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.arbitration.Dispute;
|
||||
|
@ -249,7 +250,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
|||
addTitledGroupBg(gridPane, ++rowIndex, 17, Res.get("disputeSummaryWindow.title")).getStyleClass().add("last");
|
||||
addConfirmationLabelLabel(gridPane, rowIndex, Res.get("shared.tradeId"), dispute.getShortTradeId(),
|
||||
Layout.TWICE_FIRST_ROW_DISTANCE);
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.openDate"), BSFormatter.formatDateTime(dispute.getOpeningDate()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("disputeSummaryWindow.openDate"), DisplayUtils.formatDateTime(dispute.getOpeningDate()));
|
||||
if (dispute.isDisputeOpenerIsMaker()) {
|
||||
if (dispute.isDisputeOpenerIsBuyer())
|
||||
role = Res.get("support.buyerOfferer");
|
||||
|
@ -265,9 +266,9 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
|||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeAmount"),
|
||||
formatter.formatCoinWithCode(contract.getTradeAmount()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
|
||||
formatter.formatPrice(contract.getTradePrice()));
|
||||
BSFormatter.formatPrice(contract.getTradePrice()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradeVolume"),
|
||||
formatter.formatVolumeWithCode(contract.getTradeVolume()));
|
||||
DisplayUtils.formatVolumeWithCode(contract.getTradeVolume()));
|
||||
String securityDeposit = Res.getWithColAndCap("shared.buyer") +
|
||||
" " +
|
||||
formatter.formatCoinWithCode(contract.getOfferPayload().getBuyerSecurityDeposit()) +
|
||||
|
@ -566,13 +567,13 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
|||
disputeResult.setLoserPublisher(isLoserPublisherCheckBox.isSelected());
|
||||
disputeResult.setCloseDate(new Date());
|
||||
String text = Res.get("disputeSummaryWindow.close.msg",
|
||||
BSFormatter.formatDateTime(disputeResult.getCloseDate()),
|
||||
DisplayUtils.formatDateTime(disputeResult.getCloseDate()),
|
||||
role,
|
||||
BSFormatter.booleanToYesNo(disputeResult.tamperProofEvidenceProperty().get()),
|
||||
DisplayUtils.booleanToYesNo(disputeResult.tamperProofEvidenceProperty().get()),
|
||||
role,
|
||||
BSFormatter.booleanToYesNo(disputeResult.idVerificationProperty().get()),
|
||||
DisplayUtils.booleanToYesNo(disputeResult.idVerificationProperty().get()),
|
||||
role,
|
||||
BSFormatter.booleanToYesNo(disputeResult.screenCastProperty().get()),
|
||||
DisplayUtils.booleanToYesNo(disputeResult.screenCastProperty().get()),
|
||||
formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()),
|
||||
formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()),
|
||||
disputeResult.summaryNotesProperty().get());
|
||||
|
|
|
@ -22,6 +22,7 @@ import bisq.desktop.components.AutoTooltipButton;
|
|||
import bisq.desktop.components.BusyAnimation;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.locale.BankUtil;
|
||||
|
@ -170,49 +171,49 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
|
|||
double firstRowDistance = Layout.TWICE_FIRST_ROW_DISTANCE;
|
||||
if (takeOfferHandlerOptional.isPresent()) {
|
||||
addConfirmationLabelLabel(gridPane, rowIndex, offerTypeLabel,
|
||||
BSFormatter.getDirectionForTakeOffer(direction, currencyCode), firstRowDistance);
|
||||
DisplayUtils.getDirectionForTakeOffer(direction, currencyCode), firstRowDistance);
|
||||
fiatDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
|
||||
btcDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
|
||||
} else if (placeOfferHandlerOptional.isPresent()) {
|
||||
addConfirmationLabelLabel(gridPane, rowIndex, offerTypeLabel,
|
||||
BSFormatter.getOfferDirectionForCreateOffer(direction, currencyCode), firstRowDistance);
|
||||
DisplayUtils.getOfferDirectionForCreateOffer(direction, currencyCode), firstRowDistance);
|
||||
fiatDirectionInfo = direction == OfferPayload.Direction.SELL ? toReceive : toSpend;
|
||||
btcDirectionInfo = direction == OfferPayload.Direction.BUY ? toReceive : toSpend;
|
||||
} else {
|
||||
addConfirmationLabelLabel(gridPane, rowIndex, offerTypeLabel,
|
||||
BSFormatter.getDirectionBothSides(direction, currencyCode), firstRowDistance);
|
||||
DisplayUtils.getDirectionBothSides(direction, currencyCode), firstRowDistance);
|
||||
}
|
||||
String btcAmount = Res.get("shared.btcAmount");
|
||||
if (takeOfferHandlerOptional.isPresent()) {
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, btcAmount + btcDirectionInfo,
|
||||
formatter.formatCoinWithCode(tradeAmount));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, formatter.formatVolumeLabel(currencyCode) + fiatDirectionInfo,
|
||||
formatter.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount)));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, DisplayUtils.formatVolumeLabel(currencyCode) + fiatDirectionInfo,
|
||||
DisplayUtils.formatVolumeWithCode(offer.getVolumeByAmount(tradeAmount)));
|
||||
} else {
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, btcAmount + btcDirectionInfo,
|
||||
formatter.formatCoinWithCode(offer.getAmount()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("offerDetailsWindow.minBtcAmount"),
|
||||
formatter.formatCoinWithCode(offer.getMinAmount()));
|
||||
String volume = formatter.formatVolumeWithCode(offer.getVolume());
|
||||
String volume = DisplayUtils.formatVolumeWithCode(offer.getVolume());
|
||||
String minVolume = "";
|
||||
if (offer.getVolume() != null && offer.getMinVolume() != null &&
|
||||
!offer.getVolume().equals(offer.getMinVolume()))
|
||||
minVolume = " " + Res.get("offerDetailsWindow.min", formatter.formatVolumeWithCode(offer.getMinVolume()));
|
||||
minVolume = " " + Res.get("offerDetailsWindow.min", DisplayUtils.formatVolumeWithCode(offer.getMinVolume()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex,
|
||||
formatter.formatVolumeLabel(currencyCode) + fiatDirectionInfo, volume + minVolume);
|
||||
DisplayUtils.formatVolumeLabel(currencyCode) + fiatDirectionInfo, volume + minVolume);
|
||||
}
|
||||
|
||||
String priceLabel = Res.get("shared.price");
|
||||
if (takeOfferHandlerOptional.isPresent()) {
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(tradePrice));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, priceLabel, BSFormatter.formatPrice(tradePrice));
|
||||
} else {
|
||||
Price price = offer.getPrice();
|
||||
if (offer.isUseMarketBasedPrice()) {
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(price) +
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, priceLabel, BSFormatter.formatPrice(price) +
|
||||
" " + Res.get("offerDetailsWindow.distance",
|
||||
BSFormatter.formatPercentagePrice(offer.getMarketPriceMargin())));
|
||||
} else {
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, priceLabel, formatter.formatPrice(price));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, priceLabel, BSFormatter.formatPrice(price));
|
||||
}
|
||||
}
|
||||
final PaymentMethod paymentMethod = offer.getPaymentMethod();
|
||||
|
@ -307,7 +308,7 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
|
|||
addConfirmationLabelTextFieldWithCopyIcon(gridPane, ++rowIndex, Res.get("offerDetailsWindow.makersOnion"),
|
||||
offer.getMakerNodeAddress().getFullAddress());
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("offerDetailsWindow.creationDate"),
|
||||
BSFormatter.formatDateTime(offer.getDate()));
|
||||
DisplayUtils.formatDateTime(offer.getDate()));
|
||||
String value = Res.getWithColAndCap("shared.buyer") +
|
||||
" " +
|
||||
formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) +
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.desktop.components.TableGroupHeadline;
|
|||
import bisq.desktop.main.dao.governance.ProposalDisplay;
|
||||
import bisq.desktop.main.dao.governance.result.VoteListItem;
|
||||
import bisq.desktop.main.overlays.TabbedOverlay;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
|
@ -34,7 +35,6 @@ import bisq.core.dao.state.model.governance.EvaluatedProposal;
|
|||
import bisq.core.dao.state.model.governance.Proposal;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.user.Preferences;
|
||||
import bisq.core.util.BSFormatter;
|
||||
import bisq.core.util.BsqFormatter;
|
||||
|
||||
import bisq.common.util.Tuple2;
|
||||
|
@ -241,7 +241,7 @@ public class ProposalResultsWindow extends TabbedOverlay<ProposalResultsWindow>
|
|||
super.updateItem(item, empty);
|
||||
|
||||
if (item != null && !empty) {
|
||||
setText(BSFormatter.formatDateTime(item.getBlindVoteDate()));
|
||||
setText(DisplayUtils.formatDateTime(item.getBlindVoteDate()));
|
||||
} else {
|
||||
setText("");
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import bisq.desktop.components.BisqTextArea;
|
|||
import bisq.desktop.components.TextFieldWithCopyIcon;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.overlays.Overlay;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -134,12 +135,12 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
String offerType = Res.get("shared.offerType");
|
||||
if (tradeManager.isBuyer(offer)) {
|
||||
addConfirmationLabelLabel(gridPane, rowIndex, offerType,
|
||||
BSFormatter.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.TWICE_FIRST_ROW_DISTANCE);
|
||||
DisplayUtils.getDirectionForBuyer(myOffer, offer.getCurrencyCode()), Layout.TWICE_FIRST_ROW_DISTANCE);
|
||||
fiatDirectionInfo = toSpend;
|
||||
btcDirectionInfo = toReceive;
|
||||
} else {
|
||||
addConfirmationLabelLabel(gridPane, rowIndex, offerType,
|
||||
BSFormatter.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.TWICE_FIRST_ROW_DISTANCE);
|
||||
DisplayUtils.getDirectionForSeller(myOffer, offer.getCurrencyCode()), Layout.TWICE_FIRST_ROW_DISTANCE);
|
||||
fiatDirectionInfo = toReceive;
|
||||
btcDirectionInfo = toSpend;
|
||||
}
|
||||
|
@ -147,10 +148,10 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.btcAmount") + btcDirectionInfo,
|
||||
formatter.formatCoinWithCode(trade.getTradeAmount()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex,
|
||||
formatter.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo,
|
||||
formatter.formatVolumeWithCode(trade.getTradeVolume()));
|
||||
DisplayUtils.formatVolumeLabel(offer.getCurrencyCode()) + fiatDirectionInfo,
|
||||
DisplayUtils.formatVolumeWithCode(trade.getTradeVolume()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.tradePrice"),
|
||||
formatter.formatPrice(trade.getTradePrice()));
|
||||
BSFormatter.formatPrice(trade.getTradePrice()));
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("shared.paymentMethod"),
|
||||
Res.get(offer.getPaymentMethod().getId()));
|
||||
|
||||
|
@ -198,7 +199,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
addConfirmationLabelTextFieldWithCopyIcon(gridPane, rowIndex, Res.get("shared.tradeId"),
|
||||
trade.getId(), Layout.TWICE_FIRST_ROW_AND_GROUP_DISTANCE);
|
||||
addConfirmationLabelLabel(gridPane, ++rowIndex, Res.get("tradeDetailsWindow.tradeDate"),
|
||||
BSFormatter.formatDateTime(trade.getDate()));
|
||||
DisplayUtils.formatDateTime(trade.getDate()));
|
||||
String securityDeposit = Res.getWithColAndCap("shared.buyer") +
|
||||
" " +
|
||||
formatter.formatCoinWithCode(offer.getBuyerSecurityDeposit()) +
|
||||
|
@ -226,7 +227,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
String paymentDetails = buyerPaymentAccountPayload.getPaymentDetails();
|
||||
long age = accountAgeWitnessService.getAccountAge(buyerPaymentAccountPayload, contract.getBuyerPubKeyRing());
|
||||
buyersAccountAge = CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ?
|
||||
age > -1 ? Res.get("peerInfoIcon.tooltip.age", BSFormatter.formatAccountAge(age)) :
|
||||
age > -1 ? Res.get("peerInfoIcon.tooltip.age", DisplayUtils.formatAccountAge(age)) :
|
||||
Res.get("peerInfoIcon.tooltip.unknownAge") :
|
||||
"";
|
||||
|
||||
|
@ -240,7 +241,7 @@ public class TradeDetailsWindow extends Overlay<TradeDetailsWindow> {
|
|||
String paymentDetails = sellerPaymentAccountPayload.getPaymentDetails();
|
||||
long age = accountAgeWitnessService.getAccountAge(sellerPaymentAccountPayload, contract.getSellerPubKeyRing());
|
||||
sellersAccountAge = CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ?
|
||||
age > -1 ? Res.get("peerInfoIcon.tooltip.age", BSFormatter.formatAccountAge(age)) :
|
||||
age > -1 ? Res.get("peerInfoIcon.tooltip.age", DisplayUtils.formatAccountAge(age)) :
|
||||
Res.get("peerInfoIcon.tooltip.unknownAge") :
|
||||
"";
|
||||
String postFix = sellersAccountAge.isEmpty() ? "" : " / " + sellersAccountAge;
|
||||
|
|
|
@ -26,6 +26,7 @@ import bisq.desktop.components.InputTextField;
|
|||
import bisq.desktop.components.PeerInfoIcon;
|
||||
import bisq.desktop.main.overlays.windows.OfferDetailsWindow;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.alert.PrivateNotificationManager;
|
||||
|
@ -317,7 +318,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
|
|||
|
||||
Offer offer = item.getTradable().getOffer();
|
||||
boolean matchesId = offer.getId().contains(filterString);
|
||||
boolean matchesOfferDate = formatter.formatDate(offer.getDate()).contains(filterString);
|
||||
boolean matchesOfferDate = DisplayUtils.formatDate(offer.getDate()).contains(filterString);
|
||||
boolean isMakerOnion = offer.getMakerNodeAddress().getFullAddress().contains(filterString);
|
||||
|
||||
if (item.getTradable() instanceof Trade) {
|
||||
|
@ -327,7 +328,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
|
|||
boolean matchesSellersPaymentAccountData = false;
|
||||
|
||||
Trade trade = (Trade) item.getTradable();
|
||||
boolean matchesTradeDate = formatter.formatDate(trade.getTakeOfferDate()).contains(filterString);
|
||||
boolean matchesTradeDate = DisplayUtils.formatDate(trade.getTakeOfferDate()).contains(filterString);
|
||||
Contract contract = trade.getContract();
|
||||
if (contract != null) {
|
||||
isBuyerOnion = contract.getBuyerNodeAddress().getFullAddress().contains(filterString);
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.main.portfolio.closedtrades;
|
|||
|
||||
import bisq.desktop.common.model.ActivatableWithDataModel;
|
||||
import bisq.desktop.common.model.ViewModel;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
import bisq.core.locale.Res;
|
||||
|
@ -68,14 +69,14 @@ class ClosedTradesViewModel extends ActivatableWithDataModel<ClosedTradesDataMod
|
|||
return "";
|
||||
Tradable tradable = item.getTradable();
|
||||
if (tradable instanceof Trade)
|
||||
return formatter.formatPrice(((Trade) tradable).getTradePrice());
|
||||
return BSFormatter.formatPrice(((Trade) tradable).getTradePrice());
|
||||
else
|
||||
return formatter.formatPrice(tradable.getOffer().getPrice());
|
||||
return BSFormatter.formatPrice(tradable.getOffer().getPrice());
|
||||
}
|
||||
|
||||
String getVolume(ClosedTradableListItem item) {
|
||||
if (item != null && item.getTradable() instanceof Trade)
|
||||
return formatter.formatVolumeWithCode(((Trade) item.getTradable()).getTradeVolume());
|
||||
return DisplayUtils.formatVolumeWithCode(((Trade) item.getTradable()).getTradeVolume());
|
||||
else if (item != null && item.getTradable() instanceof OpenOffer)
|
||||
return "-";
|
||||
else
|
||||
|
@ -123,11 +124,11 @@ class ClosedTradesViewModel extends ActivatableWithDataModel<ClosedTradesDataMod
|
|||
}
|
||||
|
||||
String getDirectionLabel(ClosedTradableListItem item) {
|
||||
return (item != null) ? BSFormatter.getDirectionWithCode(dataModel.getDirection(item.getTradable().getOffer()), item.getTradable().getOffer().getCurrencyCode()) : "";
|
||||
return (item != null) ? DisplayUtils.getDirectionWithCode(dataModel.getDirection(item.getTradable().getOffer()), item.getTradable().getOffer().getCurrencyCode()) : "";
|
||||
}
|
||||
|
||||
String getDate(ClosedTradableListItem item) {
|
||||
return BSFormatter.formatDateTime(item.getTradable().getDate());
|
||||
return DisplayUtils.formatDateTime(item.getTradable().getDate());
|
||||
}
|
||||
|
||||
String getMarketLabel(ClosedTradableListItem item) {
|
||||
|
|
|
@ -77,8 +77,8 @@ class EditOfferViewModel extends MutableOfferViewModel<EditOfferDataModel> {
|
|||
}
|
||||
|
||||
public void onInvalidatePrice() {
|
||||
price.set(btcFormatter.formatPrice(null));
|
||||
price.set(btcFormatter.formatPrice(dataModel.getPrice().get()));
|
||||
price.set(BSFormatter.formatPrice(null));
|
||||
price.set(BSFormatter.formatPrice(dataModel.getPrice().get()));
|
||||
}
|
||||
|
||||
public boolean isSecurityDepositValid() {
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.main.portfolio.failedtrades;
|
|||
|
||||
import bisq.desktop.common.model.ActivatableWithDataModel;
|
||||
import bisq.desktop.common.model.ViewModel;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
|
@ -54,18 +55,18 @@ class FailedTradesViewModel extends ActivatableWithDataModel<FailedTradesDataMod
|
|||
}
|
||||
|
||||
String getPrice(FailedTradesListItem item) {
|
||||
return (item != null) ? formatter.formatPrice(item.getTrade().getTradePrice()) : "";
|
||||
return (item != null) ? BSFormatter.formatPrice(item.getTrade().getTradePrice()) : "";
|
||||
}
|
||||
|
||||
String getVolume(FailedTradesListItem item) {
|
||||
if (item != null && item.getTrade() != null)
|
||||
return formatter.formatVolumeWithCode(item.getTrade().getTradeVolume());
|
||||
return DisplayUtils.formatVolumeWithCode(item.getTrade().getTradeVolume());
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
String getDirectionLabel(FailedTradesListItem item) {
|
||||
return (item != null) ? BSFormatter.getDirectionWithCode(dataModel.getDirection(item.getTrade().getOffer()), item.getTrade().getOffer().getCurrencyCode()) : "";
|
||||
return (item != null) ? DisplayUtils.getDirectionWithCode(dataModel.getDirection(item.getTrade().getOffer()), item.getTrade().getOffer().getCurrencyCode()) : "";
|
||||
}
|
||||
|
||||
String getMarketLabel(FailedTradesListItem item) {
|
||||
|
@ -76,7 +77,7 @@ class FailedTradesViewModel extends ActivatableWithDataModel<FailedTradesDataMod
|
|||
}
|
||||
|
||||
String getDate(FailedTradesListItem item) {
|
||||
return BSFormatter.formatDateTime(item.getTrade().getDate());
|
||||
return DisplayUtils.formatDateTime(item.getTrade().getDate());
|
||||
}
|
||||
|
||||
String getState(FailedTradesListItem item) {
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.main.portfolio.openoffer;
|
|||
|
||||
import bisq.desktop.common.model.ActivatableWithDataModel;
|
||||
import bisq.desktop.common.model.ViewModel;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.monetary.Price;
|
||||
|
@ -71,7 +72,7 @@ class OpenOffersViewModel extends ActivatableWithDataModel<OpenOffersDataModel>
|
|||
}
|
||||
|
||||
String getAmount(OpenOfferListItem item) {
|
||||
return (item != null) ? formatter.formatAmount(item.getOffer()) : "";
|
||||
return (item != null) ? DisplayUtils.formatAmount(item.getOffer(), formatter) : "";
|
||||
}
|
||||
|
||||
String getPrice(OpenOfferListItem item) {
|
||||
|
@ -84,21 +85,21 @@ class OpenOffersViewModel extends ActivatableWithDataModel<OpenOffersDataModel>
|
|||
String postFix = "";
|
||||
if (offer.isUseMarketBasedPrice())
|
||||
postFix = " (" + BSFormatter.formatPercentagePrice(offer.getMarketPriceMargin()) + ")";
|
||||
return formatter.formatPrice(price) + postFix;
|
||||
return BSFormatter.formatPrice(price) + postFix;
|
||||
} else {
|
||||
return Res.get("shared.na");
|
||||
}
|
||||
}
|
||||
|
||||
String getVolume(OpenOfferListItem item) {
|
||||
return (item != null) ? formatter.formatVolume(item.getOffer(), false, 0) + " " + item.getOffer().getCurrencyCode() : "";
|
||||
return (item != null) ? DisplayUtils.formatVolume(item.getOffer(), false, 0) + " " + item.getOffer().getCurrencyCode() : "";
|
||||
}
|
||||
|
||||
String getDirectionLabel(OpenOfferListItem item) {
|
||||
if ((item == null))
|
||||
return "";
|
||||
|
||||
return BSFormatter.getDirectionWithCode(dataModel.getDirection(item.getOffer()), item.getOffer().getCurrencyCode());
|
||||
return DisplayUtils.getDirectionWithCode(dataModel.getDirection(item.getOffer()), item.getOffer().getCurrencyCode());
|
||||
}
|
||||
|
||||
String getMarketLabel(OpenOfferListItem item) {
|
||||
|
@ -109,7 +110,7 @@ class OpenOffersViewModel extends ActivatableWithDataModel<OpenOffersDataModel>
|
|||
}
|
||||
|
||||
String getDate(OpenOfferListItem item) {
|
||||
return BSFormatter.formatDateTime(item.getOffer().getDate());
|
||||
return DisplayUtils.formatDateTime(item.getOffer().getDate());
|
||||
}
|
||||
|
||||
boolean isDeactivated(OpenOfferListItem item) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import bisq.desktop.main.Chat.Chat;
|
|||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.overlays.windows.TradeDetailsWindow;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.FormBuilder;
|
||||
import bisq.desktop.util.CssTheme;
|
||||
|
||||
|
@ -493,7 +494,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
public void updateItem(final PendingTradesListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty) {
|
||||
setGraphic(new AutoTooltipLabel(BSFormatter.formatDateTime(item.getTrade().getDate())));
|
||||
setGraphic(new AutoTooltipLabel(DisplayUtils.formatDateTime(item.getTrade().getDate())));
|
||||
} else {
|
||||
setGraphic(null);
|
||||
}
|
||||
|
@ -536,7 +537,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
public void updateItem(final PendingTradesListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty)
|
||||
setGraphic(new AutoTooltipLabel(formatter.formatPrice(item.getPrice())));
|
||||
setGraphic(new AutoTooltipLabel(BSFormatter.formatPrice(item.getPrice())));
|
||||
else
|
||||
setGraphic(null);
|
||||
}
|
||||
|
@ -557,7 +558,7 @@ public class PendingTradesView extends ActivatableViewAndModel<VBox, PendingTrad
|
|||
public void updateItem(final PendingTradesListItem item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (item != null && !empty)
|
||||
setGraphic(new AutoTooltipLabel(formatter.formatVolumeWithCode(item.getTrade().getTradeVolume())));
|
||||
setGraphic(new AutoTooltipLabel(DisplayUtils.formatVolumeWithCode(item.getTrade().getTradeVolume())));
|
||||
else
|
||||
setGraphic(null);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.main.portfolio.pendingtrades;
|
|||
|
||||
import bisq.desktop.common.model.ActivatableWithDataModel;
|
||||
import bisq.desktop.common.model.ViewModel;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.GUIUtil;
|
||||
|
||||
import bisq.core.account.witness.AccountAgeWitnessService;
|
||||
|
@ -233,7 +234,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
}
|
||||
|
||||
public String getDateForOpenDispute() {
|
||||
return BSFormatter.formatDateTime(new Date(new Date().getTime() + getRemainingTradeDuration()));
|
||||
return DisplayUtils.formatDateTime(new Date(new Date().getTime() + getRemainingTradeDuration()));
|
||||
}
|
||||
|
||||
public boolean showWarning() {
|
||||
|
@ -278,7 +279,7 @@ public class PendingTradesViewModel extends ActivatableWithDataModel<PendingTrad
|
|||
}
|
||||
|
||||
public String getFiatVolume() {
|
||||
return dataModel.getTrade() != null ? btcFormatter.formatVolumeWithCode(dataModel.getTrade().getTradeVolume()) : "";
|
||||
return dataModel.getTrade() != null ? DisplayUtils.formatVolumeWithCode(dataModel.getTrade().getTradeVolume()) : "";
|
||||
}
|
||||
|
||||
public String getTxFee() {
|
||||
|
|
|
@ -49,6 +49,7 @@ import bisq.desktop.components.paymentmethods.WesternUnionForm;
|
|||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.steps.TradeStepView;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
|
@ -500,7 +501,7 @@ public class BuyerStep2View extends TradeStepView {
|
|||
String fees = Res.get("portfolio.pending.step2_buyer.fees");
|
||||
String id = trade.getShortId();
|
||||
String paddedId = " " + id + " ";
|
||||
String amount = model.btcFormatter.formatVolumeWithCode(trade.getTradeVolume());
|
||||
String amount = DisplayUtils.formatVolumeWithCode(trade.getTradeVolume());
|
||||
if (paymentAccountPayload instanceof AssetsAccountPayload) {
|
||||
//noinspection UnusedAssignment
|
||||
message += Res.get("portfolio.pending.step2_buyer.altcoin",
|
||||
|
|
|
@ -23,6 +23,7 @@ import bisq.desktop.components.TitledGroupBg;
|
|||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesViewModel;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.steps.TradeStepView;
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
import bisq.desktop.util.Layout;
|
||||
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
|
@ -320,7 +321,7 @@ public class SellerStep3View extends TradeStepView {
|
|||
//noinspection UnusedAssignment
|
||||
String key = "confirmPayment" + trade.getId();
|
||||
String message = "";
|
||||
String tradeVolumeWithCode = model.btcFormatter.formatVolumeWithCode(trade.getTradeVolume());
|
||||
String tradeVolumeWithCode = DisplayUtils.formatVolumeWithCode(trade.getTradeVolume());
|
||||
String currencyName = CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode());
|
||||
String part1 = Res.get("portfolio.pending.step3_seller.part", currencyName);
|
||||
String id = trade.getShortId();
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package bisq.desktop.main.settings.network;
|
||||
|
||||
import bisq.desktop.util.DisplayUtils;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.util.BSFormatter;
|
||||
|
||||
|
@ -118,7 +120,7 @@ public class P2pNetworkListItem {
|
|||
}
|
||||
|
||||
public String getCreationDate() {
|
||||
return BSFormatter.formatDateTime(statistic.getCreationDate());
|
||||
return DisplayUtils.formatDateTime(statistic.getCreationDate());
|
||||
}
|
||||
|
||||
public String getOnionAddress() {
|
||||
|
|
291
desktop/src/main/java/bisq/desktop/util/DisplayUtils.java
Normal file
291
desktop/src/main/java/bisq/desktop/util/DisplayUtils.java
Normal file
|
@ -0,0 +1,291 @@
|
|||
package bisq.desktop.util;
|
||||
|
||||
import bisq.core.locale.CurrencyUtil;
|
||||
import bisq.core.locale.GlobalSettings;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.monetary.Altcoin;
|
||||
import bisq.core.monetary.Price;
|
||||
import bisq.core.monetary.Volume;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OfferPayload;
|
||||
import bisq.core.util.BSFormatter;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.Monetary;
|
||||
import org.bitcoinj.utils.Fiat;
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.time.DurationFormatUtils;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class DisplayUtils {
|
||||
private final static int scale = 3;
|
||||
private static final MonetaryFormat fiatVolumeFormat = new MonetaryFormat().shift(0).minDecimals(2).repeatOptionalDecimals(0, 0);
|
||||
|
||||
public static String formatDateTime(Date date) {
|
||||
return BSFormatter.formatDateTime(date, true);
|
||||
}
|
||||
|
||||
public static String formatDateTimeSpan(Date dateFrom, Date dateTo) {
|
||||
if (dateFrom != null && dateTo != null) {
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, GlobalSettings.getLocale());
|
||||
DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, GlobalSettings.getLocale());
|
||||
return dateFormatter.format(dateFrom) + " " + timeFormatter.format(dateFrom) + BSFormatter.RANGE_SEPARATOR + timeFormatter.format(dateTo);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatTime(Date date) {
|
||||
if (date != null) {
|
||||
DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, GlobalSettings.getLocale());
|
||||
return timeFormatter.format(date);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDate(Date date) {
|
||||
if (date != null) {
|
||||
DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, GlobalSettings.getLocale());
|
||||
return dateFormatter.format(date);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatAccountAge(long durationMillis) {
|
||||
durationMillis = Math.max(0, durationMillis);
|
||||
String day = Res.get("time.day").toLowerCase();
|
||||
String days = Res.get("time.days");
|
||||
String format = "d\' " + days + "\'";
|
||||
return StringUtils.replaceOnce(DurationFormatUtils.formatDuration(durationMillis, format), "1 " + days, "1 " + day);
|
||||
}
|
||||
|
||||
public static String booleanToYesNo(boolean value) {
|
||||
return value ? Res.get("shared.yes") : Res.get("shared.no");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Volume
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String formatVolume(Offer offer, Boolean decimalAligned, int maxNumberOfDigits) {
|
||||
return formatVolume(offer, decimalAligned, maxNumberOfDigits, true);
|
||||
}
|
||||
|
||||
public static String formatVolume(Offer offer, Boolean decimalAligned, int maxNumberOfDigits, boolean showRange) {
|
||||
String formattedVolume = offer.isRange() && showRange ? formatVolume(offer.getMinVolume()) + BSFormatter.RANGE_SEPARATOR + formatVolume(offer.getVolume()) : formatVolume(offer.getVolume());
|
||||
|
||||
if (decimalAligned) {
|
||||
formattedVolume = BSFormatter.fillUpPlacesWithEmptyStrings(formattedVolume, maxNumberOfDigits);
|
||||
}
|
||||
return formattedVolume;
|
||||
}
|
||||
|
||||
public static String formatVolume(Volume volume) {
|
||||
return formatVolume(volume, fiatVolumeFormat, false);
|
||||
}
|
||||
|
||||
private static String formatVolume(Volume volume, MonetaryFormat fiatVolumeFormat, boolean appendCurrencyCode) {
|
||||
if (volume != null) {
|
||||
Monetary monetary = volume.getMonetary();
|
||||
if (monetary instanceof Fiat)
|
||||
return BSFormatter.formatFiat((Fiat) monetary, fiatVolumeFormat, appendCurrencyCode);
|
||||
else
|
||||
return BSFormatter.formatAltcoinVolume((Altcoin) monetary, appendCurrencyCode);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatVolumeWithCode(Volume volume) {
|
||||
return formatVolume(volume, fiatVolumeFormat, true);
|
||||
}
|
||||
|
||||
public static String formatVolumeLabel(String currencyCode) {
|
||||
return formatVolumeLabel(currencyCode, "");
|
||||
}
|
||||
|
||||
public static String formatVolumeLabel(String currencyCode, String postFix) {
|
||||
return Res.get("formatter.formatVolumeLabel",
|
||||
currencyCode, postFix);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Offer direction
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String getDirectionWithCode(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode))
|
||||
return (direction == OfferPayload.Direction.BUY) ? Res.get("shared.buyCurrency", Res.getBaseCurrencyCode()) : Res.get("shared.sellCurrency", Res.getBaseCurrencyCode());
|
||||
else
|
||||
return (direction == OfferPayload.Direction.SELL) ? Res.get("shared.buyCurrency", currencyCode) : Res.get("shared.sellCurrency", currencyCode);
|
||||
}
|
||||
|
||||
public static String getDirectionBothSides(OfferPayload.Direction direction, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
currencyCode = Res.getBaseCurrencyCode();
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
|
||||
} else {
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.buyer"), currencyCode, Res.get("shared.seller")) :
|
||||
Res.get("formatter.makerTaker", currencyCode, Res.get("shared.seller"), currencyCode, Res.get("shared.buyer"));
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDirectionForBuyer(boolean isMyOffer, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String code = Res.getBaseCurrencyCode();
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.buying"), code, Res.get("shared.selling"), code) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.buying"), code, Res.get("shared.selling"), code);
|
||||
} else {
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), currencyCode) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), currencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDirectionForSeller(boolean isMyOffer, String currencyCode) {
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
String code = Res.getBaseCurrencyCode();
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.selling"), code, Res.get("shared.buying"), code) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.selling"), code, Res.get("shared.buying"), code);
|
||||
} else {
|
||||
return isMyOffer ?
|
||||
Res.get("formatter.youAreAsMaker", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), currencyCode) :
|
||||
Res.get("formatter.youAreAsTaker", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), currencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getDirectionForTakeOffer(OfferPayload.Direction direction, String currencyCode) {
|
||||
String baseCurrencyCode = Res.getBaseCurrencyCode();
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.youAre", Res.get("shared.selling"), baseCurrencyCode, Res.get("shared.buying"), currencyCode) :
|
||||
Res.get("formatter.youAre", Res.get("shared.buying"), baseCurrencyCode, Res.get("shared.selling"), currencyCode);
|
||||
} else {
|
||||
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.youAre", Res.get("shared.selling"), currencyCode, Res.get("shared.buying"), baseCurrencyCode) :
|
||||
Res.get("formatter.youAre", Res.get("shared.buying"), currencyCode, Res.get("shared.selling"), baseCurrencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOfferDirectionForCreateOffer(OfferPayload.Direction direction, String currencyCode) {
|
||||
String baseCurrencyCode = Res.getBaseCurrencyCode();
|
||||
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
|
||||
return direction == OfferPayload.Direction.BUY ?
|
||||
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.buy"), baseCurrencyCode) :
|
||||
Res.get("formatter.youAreCreatingAnOffer.fiat", Res.get("shared.sell"), baseCurrencyCode);
|
||||
} else {
|
||||
return direction == OfferPayload.Direction.SELL ?
|
||||
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.buy"), currencyCode, Res.get("shared.selling"), baseCurrencyCode) :
|
||||
Res.get("formatter.youAreCreatingAnOffer.altcoin", Res.get("shared.sell"), currencyCode, Res.get("shared.buying"), baseCurrencyCode);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Amount
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String formatAmount(Offer offer, BSFormatter formatter) {
|
||||
return formatAmount(offer, false, formatter);
|
||||
}
|
||||
|
||||
private static String formatAmount(Offer offer, boolean decimalAligned, BSFormatter bsFormatter) {
|
||||
String formattedAmount = offer.isRange() ? bsFormatter.formatCoin(offer.getMinAmount()) + BSFormatter.RANGE_SEPARATOR + bsFormatter.formatCoin(offer.getAmount()) : bsFormatter.formatCoin(offer.getAmount());
|
||||
if (decimalAligned) {
|
||||
formattedAmount = BSFormatter.fillUpPlacesWithEmptyStrings(formattedAmount, 15);
|
||||
}
|
||||
return formattedAmount;
|
||||
}
|
||||
|
||||
public static String formatAmount(Offer offer,
|
||||
int decimalPlaces,
|
||||
boolean decimalAligned,
|
||||
int maxPlaces,
|
||||
BSFormatter bsFormatter) {
|
||||
String formattedAmount = offer.isRange() ? bsFormatter.formatCoin(offer.getMinAmount(), decimalPlaces) + BSFormatter.RANGE_SEPARATOR + bsFormatter.formatCoin(offer.getAmount(), decimalPlaces) : bsFormatter.formatCoin(offer.getAmount(), decimalPlaces);
|
||||
|
||||
if (decimalAligned) {
|
||||
formattedAmount = BSFormatter.fillUpPlacesWithEmptyStrings(formattedAmount, maxPlaces);
|
||||
}
|
||||
return formattedAmount;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Other
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public static String formatPrice(Price price, Boolean decimalAligned, int maxPlaces) {
|
||||
String formattedPrice = BSFormatter.formatPrice(price);
|
||||
|
||||
if (decimalAligned) {
|
||||
formattedPrice = BSFormatter.fillUpPlacesWithEmptyStrings(formattedPrice, maxPlaces);
|
||||
}
|
||||
return formattedPrice;
|
||||
}
|
||||
|
||||
public static String getFeeWithFiatAmount(Coin makerFeeAsCoin,
|
||||
Optional<Volume> optionalFeeInFiat,
|
||||
BSFormatter formatter) {
|
||||
String fee = makerFeeAsCoin != null ? formatter.formatCoinWithCode(makerFeeAsCoin) : Res.get("shared.na");
|
||||
String feeInFiatAsString;
|
||||
if (optionalFeeInFiat != null && optionalFeeInFiat.isPresent()) {
|
||||
feeInFiatAsString = formatVolumeWithCode(optionalFeeInFiat.get());
|
||||
} else {
|
||||
feeInFiatAsString = Res.get("shared.na");
|
||||
}
|
||||
return Res.get("feeOptionWindow.fee", fee, feeInFiatAsString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts to a coin with max. 4 decimal places. Last place gets rounded.
|
||||
* 0.01234 -> 0.0123
|
||||
* 0.01235 -> 0.0124
|
||||
*
|
||||
* @param input
|
||||
* @param bsFormatter
|
||||
* @return
|
||||
*/
|
||||
public static Coin parseToCoinWith4Decimals(String input, BSFormatter bsFormatter) {
|
||||
try {
|
||||
return Coin.valueOf(new BigDecimal(bsFormatter.parseToCoin(BSFormatter.cleanDoubleInput(input)).value).setScale(-scale - 1,
|
||||
BigDecimal.ROUND_HALF_UP).setScale(scale + 1, BigDecimal.ROUND_HALF_UP).toBigInteger().longValue());
|
||||
} catch (Throwable t) {
|
||||
if (input != null && input.length() > 0)
|
||||
log.warn("Exception at parseToCoinWith4Decimals: " + t.toString());
|
||||
return Coin.ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBtcValidDecimals(String input, BSFormatter bsFormatter) {
|
||||
return bsFormatter.parseToCoin(input).equals(parseToCoinWith4Decimals(input, bsFormatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a coin with the properties defined in the format (used to reduce decimal places)
|
||||
*
|
||||
* @param coin The coin which should be transformed
|
||||
* @param bsFormatter
|
||||
* @return The transformed coin
|
||||
*/
|
||||
public static Coin reduceTo4Decimals(Coin coin, BSFormatter bsFormatter) {
|
||||
return bsFormatter.parseToCoin(bsFormatter.formatCoin(coin));
|
||||
}
|
||||
}
|
|
@ -59,17 +59,6 @@ public class BSFormatterTest {
|
|||
Res.setBaseCurrencyName("Bitcoin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsValid() {
|
||||
assertEquals("0 days", BSFormatter.formatAccountAge(TimeUnit.HOURS.toMillis(23)));
|
||||
assertEquals("0 days", BSFormatter.formatAccountAge(0));
|
||||
assertEquals("0 days", BSFormatter.formatAccountAge(-1));
|
||||
assertEquals("1 day", BSFormatter.formatAccountAge(TimeUnit.DAYS.toMillis(1)));
|
||||
assertEquals("2 days", BSFormatter.formatAccountAge(TimeUnit.DAYS.toMillis(2)));
|
||||
assertEquals("30 days", BSFormatter.formatAccountAge(TimeUnit.DAYS.toMillis(30)));
|
||||
assertEquals("60 days", BSFormatter.formatAccountAge(TimeUnit.DAYS.toMillis(60)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatDurationAsWords() {
|
||||
long oneDay = TimeUnit.DAYS.toMillis(1);
|
||||
|
@ -98,8 +87,8 @@ public class BSFormatterTest {
|
|||
|
||||
@Test
|
||||
public void testFormatPrice() {
|
||||
assertEquals("100.0000", formatter.formatPrice(make(usdPrice)));
|
||||
assertEquals("7098.4700", formatter.formatPrice(make(usdPrice.but(with(priceString, "7098.4700")))));
|
||||
assertEquals("100.0000", BSFormatter.formatPrice(make(usdPrice)));
|
||||
assertEquals("7098.4700", BSFormatter.formatPrice(make(usdPrice.but(with(priceString, "7098.4700")))));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -110,90 +99,4 @@ public class BSFormatterTest {
|
|||
assertEquals("0.000001", formatter.formatCoin(make(a(CoinMaker.Coin).but(with(satoshis, 100L)))));
|
||||
assertEquals("0.00000001", formatter.formatCoin(make(a(CoinMaker.Coin).but(with(satoshis, 1L)))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatVolume() {
|
||||
assertEquals("1.00", formatter.formatVolume(make(btcUsdOffer), true, 4));
|
||||
assertEquals("100.00", formatter.formatVolume(make(usdVolume)));
|
||||
assertEquals("1774.62", formatter.formatVolume(make(usdVolume.but(with(volumeString, "1774.62")))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatSameVolume() {
|
||||
Offer offer = mock(Offer.class);
|
||||
Volume btc = Volume.parse("0.10", "BTC");
|
||||
when(offer.getMinVolume()).thenReturn(btc);
|
||||
when(offer.getVolume()).thenReturn(btc);
|
||||
|
||||
assertEquals("0.10000000", formatter.formatVolume(offer.getVolume()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatDifferentVolume() {
|
||||
Offer offer = mock(Offer.class);
|
||||
Volume btcMin = Volume.parse("0.10", "BTC");
|
||||
Volume btcMax = Volume.parse("0.25", "BTC");
|
||||
when(offer.isRange()).thenReturn(true);
|
||||
when(offer.getMinVolume()).thenReturn(btcMin);
|
||||
when(offer.getVolume()).thenReturn(btcMax);
|
||||
|
||||
assertEquals("0.10000000 - 0.25000000", formatter.formatVolume(offer, false, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatNullVolume() {
|
||||
Offer offer = mock(Offer.class);
|
||||
when(offer.getMinVolume()).thenReturn(null);
|
||||
when(offer.getVolume()).thenReturn(null);
|
||||
|
||||
assertEquals("", formatter.formatVolume(offer.getVolume()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatSameAmount() {
|
||||
Offer offer = mock(Offer.class);
|
||||
when(offer.getMinAmount()).thenReturn(Coin.valueOf(10000000));
|
||||
when(offer.getAmount()).thenReturn(Coin.valueOf(10000000));
|
||||
|
||||
assertEquals("0.10", formatter.formatAmount(offer));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatDifferentAmount() {
|
||||
OfferPayload offerPayload = mock(OfferPayload.class);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
when(offerPayload.getMinAmount()).thenReturn(10000000L);
|
||||
when(offerPayload.getAmount()).thenReturn(20000000L);
|
||||
|
||||
assertEquals("0.10 - 0.20", formatter.formatAmount(offer));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatAmountWithAlignmenWithDecimals() {
|
||||
OfferPayload offerPayload = mock(OfferPayload.class);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
when(offerPayload.getMinAmount()).thenReturn(10000000L);
|
||||
when(offerPayload.getAmount()).thenReturn(20000000L);
|
||||
|
||||
assertEquals("0.1000 - 0.2000", formatter.formatAmount(offer, 4, true, 15));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatAmountWithAlignmenWithDecimalsNoRange() {
|
||||
OfferPayload offerPayload = mock(OfferPayload.class);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
when(offerPayload.getMinAmount()).thenReturn(10000000L);
|
||||
when(offerPayload.getAmount()).thenReturn(10000000L);
|
||||
|
||||
assertEquals("0.1000", formatter.formatAmount(offer, 4, true, 15));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatNullAmount() {
|
||||
Offer offer = mock(Offer.class);
|
||||
when(offer.getMinAmount()).thenReturn(null);
|
||||
when(offer.getAmount()).thenReturn(null);
|
||||
|
||||
assertEquals("", formatter.formatAmount(offer));
|
||||
}
|
||||
}
|
||||
|
|
132
desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java
Normal file
132
desktop/src/test/java/bisq/desktop/util/DisplayUtilsTest.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
package bisq.desktop.util;
|
||||
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.monetary.Volume;
|
||||
import bisq.core.offer.Offer;
|
||||
import bisq.core.offer.OfferPayload;
|
||||
import bisq.core.util.BSFormatter;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static bisq.desktop.maker.OfferMaker.btcUsdOffer;
|
||||
import static bisq.desktop.maker.VolumeMaker.usdVolume;
|
||||
import static bisq.desktop.maker.VolumeMaker.volumeString;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.make;
|
||||
import static com.natpryce.makeiteasy.MakeItEasy.with;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class DisplayUtilsTest {
|
||||
private final BSFormatter formatter = new BSFormatter();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
Locale.setDefault(new Locale("en", "US"));
|
||||
Res.setBaseCurrencyCode("BTC");
|
||||
Res.setBaseCurrencyName("Bitcoin");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatAccountAge() {
|
||||
assertEquals("0 days", DisplayUtils.formatAccountAge(TimeUnit.HOURS.toMillis(23)));
|
||||
assertEquals("0 days", DisplayUtils.formatAccountAge(0));
|
||||
assertEquals("0 days", DisplayUtils.formatAccountAge(-1));
|
||||
assertEquals("1 day", DisplayUtils.formatAccountAge(TimeUnit.DAYS.toMillis(1)));
|
||||
assertEquals("2 days", DisplayUtils.formatAccountAge(TimeUnit.DAYS.toMillis(2)));
|
||||
assertEquals("30 days", DisplayUtils.formatAccountAge(TimeUnit.DAYS.toMillis(30)));
|
||||
assertEquals("60 days", DisplayUtils.formatAccountAge(TimeUnit.DAYS.toMillis(60)));
|
||||
}
|
||||
|
||||
@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")))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatSameVolume() {
|
||||
Offer offer = mock(Offer.class);
|
||||
Volume btc = Volume.parse("0.10", "BTC");
|
||||
when(offer.getMinVolume()).thenReturn(btc);
|
||||
when(offer.getVolume()).thenReturn(btc);
|
||||
|
||||
assertEquals("0.10000000", DisplayUtils.formatVolume(offer.getVolume()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatDifferentVolume() {
|
||||
Offer offer = mock(Offer.class);
|
||||
Volume btcMin = Volume.parse("0.10", "BTC");
|
||||
Volume btcMax = Volume.parse("0.25", "BTC");
|
||||
when(offer.isRange()).thenReturn(true);
|
||||
when(offer.getMinVolume()).thenReturn(btcMin);
|
||||
when(offer.getVolume()).thenReturn(btcMax);
|
||||
|
||||
assertEquals("0.10000000 - 0.25000000", DisplayUtils.formatVolume(offer, false, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatNullVolume() {
|
||||
Offer offer = mock(Offer.class);
|
||||
when(offer.getMinVolume()).thenReturn(null);
|
||||
when(offer.getVolume()).thenReturn(null);
|
||||
|
||||
assertEquals("", DisplayUtils.formatVolume(offer.getVolume()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatSameAmount() {
|
||||
Offer offer = mock(Offer.class);
|
||||
when(offer.getMinAmount()).thenReturn(Coin.valueOf(10000000));
|
||||
when(offer.getAmount()).thenReturn(Coin.valueOf(10000000));
|
||||
|
||||
assertEquals("0.10", DisplayUtils.formatAmount(offer, formatter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatDifferentAmount() {
|
||||
OfferPayload offerPayload = mock(OfferPayload.class);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
when(offerPayload.getMinAmount()).thenReturn(10000000L);
|
||||
when(offerPayload.getAmount()).thenReturn(20000000L);
|
||||
|
||||
assertEquals("0.10 - 0.20", DisplayUtils.formatAmount(offer, formatter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatAmountWithAlignmenWithDecimals() {
|
||||
OfferPayload offerPayload = mock(OfferPayload.class);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
when(offerPayload.getMinAmount()).thenReturn(10000000L);
|
||||
when(offerPayload.getAmount()).thenReturn(20000000L);
|
||||
|
||||
assertEquals("0.1000 - 0.2000", DisplayUtils.formatAmount(offer, 4, true, 15, formatter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatAmountWithAlignmenWithDecimalsNoRange() {
|
||||
OfferPayload offerPayload = mock(OfferPayload.class);
|
||||
Offer offer = new Offer(offerPayload);
|
||||
when(offerPayload.getMinAmount()).thenReturn(10000000L);
|
||||
when(offerPayload.getAmount()).thenReturn(10000000L);
|
||||
|
||||
assertEquals("0.1000", DisplayUtils.formatAmount(offer, 4, true, 15, formatter));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFormatNullAmount() {
|
||||
Offer offer = mock(Offer.class);
|
||||
when(offer.getMinAmount()).thenReturn(null);
|
||||
when(offer.getAmount()).thenReturn(null);
|
||||
|
||||
assertEquals("", DisplayUtils.formatAmount(offer, formatter));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue