Merge remote-tracking branch 'upstream/master' into add-monospace-font-support-roboto

# Conflicts:
#	gui/src/test/java/io/bisq/gui/util/BSFormatterTest.java
This commit is contained in:
Christoph Atteneder 2018-02-19 09:39:32 +01:00
commit ab3903d98d
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
20 changed files with 231 additions and 88 deletions

View file

@ -49,8 +49,8 @@ shared.sell=sell
shared.buying=buying
shared.selling=selling
shared.P2P=P2P
shared.offer=offer
shared.offers=offers
shared.oneOffer=offer
shared.multipleOffers=offers
shared.Offer=Offer
shared.openOffers=open offers
shared.trade=trade
@ -262,10 +262,10 @@ market.tabs.trades=Trades
# OfferBookChartView
market.offerBook.chart.title=Offer book for {0}
market.offerBook.leftButtonAltcoin=I want to buy {0} (sell {1})
market.offerBook.rightButtonAltcoin=I want to sell {0} (buy {1})
market.offerBook.leftButtonFiat=I want to buy {0} with {1}
market.offerBook.rightButtonFiat=I want to sell {0} for {1}
market.offerBook.buyAltcoin=Buy {0} (sell {1})
market.offerBook.sellAltcoin=Sell {0} (buy {1})
market.offerBook.buyWithFiat=Buy {0}
market.offerBook.sellWithFiat=Sell {0}
market.offerBook.sellOffersHeaderLabel=Sell {0} to
market.offerBook.buyOffersHeaderLabel=Buy {0} from
market.offerBook.buy=I want to buy bitcoin

View file

@ -49,7 +49,8 @@ shared.sell=verkaufen
shared.buying=kaufe
shared.selling=verkaufe
shared.P2P=P2P
shared.offers=Angebote
shared.oneOffer=Angebot
shared.multipleOffers=Angebote
shared.Offer=Angebot
shared.openOffers=offene Angebote
shared.trades=Händel
@ -255,10 +256,10 @@ market.tabs.trades=Händel
# OfferBookChartView
market.offerBook.chart.title=Angebotsbuch für {0}
market.offerBook.leftButtonAltcoin=Ich möchte {0} kaufen ({1} verkaufen)
market.offerBook.rightButtonAltcoin=Ich möchte {0} verkaufen ({1} kaufen)
market.offerBook.leftButtonFiat=Ich möchte {0} mit {1} kaufen
market.offerBook.rightButtonFiat=Ich möchte {0} für {1} verkaufen
market.offerBook.buyAltcoin={0} kaufen ({1} verkaufen)
market.offerBook.sellAltcoin={0} verkaufen ({1} kaufen)
market.offerBook.buyWithFiat={0} kaufen
market.offerBook.sellWithFiat={0} verkaufen
market.offerBook.sellOffersHeaderLabel=Verkaufe {0} an
market.offerBook.buyOffersHeaderLabel=Kaufe {0} von
market.offerBook.buy=Ich möchte Bitcoins kaufen

View file

@ -49,7 +49,8 @@ shared.sell=πώληση
shared.buying=αγοράζοντας
shared.selling=πουλώντας
shared.P2P=P2P
shared.offers=προσφορές
shared.oneOffer=προσφορά
shared.multipleOffers=προσφορές
shared.Offer=Προσφορά
shared.openOffers=ανοιχτές προσφορές
shared.trades=συναλλαγές
@ -254,10 +255,10 @@ market.tabs.trades=Συναλλαγές
# OfferBookChartView
market.offerBook.chart.title=Καθολικό προσφορών για {0}
market.offerBook.leftButtonAltcoin=Θέλω να αγοράσω {0} (πώληση {1})
market.offerBook.rightButtonAltcoin=Θέλω να πουλήσω {0} (αγορά {1})
market.offerBook.leftButtonFiat=Θέλω να αγοράσω {0} με {1}
market.offerBook.rightButtonFiat=Θέλω να πουλήσω {0} με {1}
market.offerBook.buyAltcoin=Θέλω να αγοράσω {0} (πώληση {1})
market.offerBook.sellAltcoin=Θέλω να πουλήσω {0} (αγορά {1})
market.offerBook.buyWithFiat=Αγορά {0}
market.offerBook.sellWithFiat=Πώληση {0}
market.offerBook.sellOffersHeaderLabel=Πουλήστε το {0} στο
market.offerBook.buyOffersHeaderLabel=Αγοράστε {0} από
market.offerBook.buy=Θέλω να αγοράσω bitcoin

View file

@ -49,7 +49,8 @@ shared.sell=vender
shared.buying=Comprando
shared.selling=Vendiendo
shared.P2P=P2P
shared.offers=ofertas
shared.oneOffer=oferta
shared.multipleOffers=ofertas
shared.Offer=Oferta
shared.openOffers=ofertas abiertas
shared.trades=Intercambios
@ -254,10 +255,10 @@ market.tabs.trades=Intercambios
# OfferBookChartView
market.offerBook.chart.title=Libro de ofertas para {0}
market.offerBook.leftButtonAltcoin=Quiero comprar {0} (vender {1})
market.offerBook.rightButtonAltcoin=Quiero vender {0} (comprar {1})
market.offerBook.leftButtonFiat=Quiero comprar {0} con {1}
market.offerBook.rightButtonFiat=Quiero vender {0} por {1}
market.offerBook.buyAltcoin=Quiero comprar {0} (vender {1})
market.offerBook.sellAltcoin=Quiero vender {0} (comprar {1})
market.offerBook.buyWithFiat=Comprar {0}
market.offerBook.sellWithFiat=Vender {0}
market.offerBook.sellOffersHeaderLabel=Vender {0} a
market.offerBook.buyOffersHeaderLabel=Compre {0} desde
market.offerBook.buy=Quiero comprar bitcoin

View file

@ -49,7 +49,8 @@ shared.sell=árulj
shared.buying=vásárlás
shared.selling=eladás
shared.P2P=P2P
shared.offers=ajánlatok
shared.oneOffer=ajánlat
shared.multipleOffers=ajánlatok
shared.Offer=Ajánlat
shared.openOffers=nyitott ajánlatok
shared.trades=tranzakciók
@ -254,10 +255,10 @@ market.tabs.trades=Tranzakciók
# OfferBookChartView
market.offerBook.chart.title=Ajánlati könyv {0}-nak:
market.offerBook.leftButtonAltcoin=Vásárolni szeretnék {0} (eladni való {1})
market.offerBook.rightButtonAltcoin=Eladni szeretnék {0} ({1} vétel)
market.offerBook.leftButtonFiat=Vásárolni szeretnék {0}-ot {1}-ért
market.offerBook.rightButtonFiat=Eladni szeretnék {0} cserébe {1}-ért
market.offerBook.buyAltcoin=Vásárolni szeretnék {0} (eladni való {1})
market.offerBook.sellAltcoin=Eladni szeretnék {0} ({1} vétel)
market.offerBook.buyWithFiat=Vásárlás {0}
market.offerBook.sellWithFiat=Eladás {0}
market.offerBook.sellOffersHeaderLabel={0} eladni
market.offerBook.buyOffersHeaderLabel=Vásároljon {0} -tól
market.offerBook.buy=Vásárolni szeretnék bitcoinot

View file

@ -49,7 +49,8 @@ shared.sell=vender
shared.buying=comprando
shared.selling=vendendo
shared.P2P=P2P
shared.offers=ofertas
shared.oneOffer=oferta
shared.multipleOffers=ofertas
shared.Offer=Oferta
shared.openOffers=abrir ofertas
shared.trades=negociações
@ -254,10 +255,10 @@ market.tabs.trades=Negociações
# OfferBookChartView
market.offerBook.chart.title=Livro de ofertas para {0}
market.offerBook.leftButtonAltcoin=Eu quero comprar {0} (vender {1})
market.offerBook.rightButtonAltcoin=Eu quero vender {0} (comprar {1})
market.offerBook.leftButtonFiat=Eu quero comprar {0} com {1}
market.offerBook.rightButtonFiat=Eu quero vender {0} por {1}
market.offerBook.buyAltcoin=Eu quero comprar {0} (vender {1})
market.offerBook.sellAltcoin=Eu quero vender {0} (comprar {1})
market.offerBook.buyWithFiat=Compre {0}
market.offerBook.sellWithFiat=Vender {0}
market.offerBook.sellOffersHeaderLabel=Vender {0} para
market.offerBook.buyOffersHeaderLabel=Compre {0} de
market.offerBook.buy=Eu quero comprar bitcoin

View file

@ -49,8 +49,8 @@ shared.sell=vinde
shared.buying=cumpărând
shared.selling=vânzând
shared.P2P=P2P
shared.offer=oferă
shared.offers=oferte
shared.oneOffer=ofertă
shared.multipleOffers=oferte
shared.Offer=Ofertă
shared.openOffers=oferte deschise
shared.trade=tranzacționează
@ -260,10 +260,10 @@ market.tabs.trades=Tranzacții
# OfferBookChartView
market.offerBook.chart.title=Cartea de oferte pentru {0}
market.offerBook.leftButtonAltcoin=Doresc să cumpăr {0} (vând {1})
market.offerBook.rightButtonAltcoin=Doresc să vând {0} (cumpăr {1})
market.offerBook.leftButtonFiat=Doresc să cumpăr {0} cu {1}
market.offerBook.rightButtonFiat=Doresc să vând {0} contra {1}
market.offerBook.buyAltcoin=Doresc să cumpăr {0} (vând {1})
market.offerBook.sellAltcoin=Doresc să vând {0} (cumpăr {1})
market.offerBook.buyWithFiat=Cumpără {0}
market.offerBook.sellWithFiat=Vindem {0}
market.offerBook.sellOffersHeaderLabel=Vindem {0} la
market.offerBook.buyOffersHeaderLabel=Cumpărați {0} de la
market.offerBook.buy=Doresc să cumpăr bitcoin

View file

@ -49,7 +49,8 @@ shared.sell=продать
shared.buying=покупка
shared.selling=продажа
shared.P2P=P2P
shared.offers=предложения
shared.oneOffer=предложение
shared.multipleOffers=предложения
shared.Offer=Предложение
shared.openOffers=открыть предложения
shared.trades=сделок
@ -254,10 +255,10 @@ market.tabs.trades=Сделки
# OfferBookChartView
market.offerBook.chart.title=Книга предложений на {0}
market.offerBook.leftButtonAltcoin=Я хочу купить {0} (продать {1})
market.offerBook.rightButtonAltcoin=Я хочу продать {0} (купить {1})
market.offerBook.leftButtonFiat=Я хочу купить {0} за {1}
market.offerBook.rightButtonFiat=Я хочу продать {0} за {1}
market.offerBook.buyAltcoin=Я хочу купить {0} (продать {1})
market.offerBook.sellAltcoin=Я хочу продать {0} (купить {1})
market.offerBook.buyWithFiat=Купить {0}
market.offerBook.sellWithFiat=Продать {0}
market.offerBook.sellOffersHeaderLabel=Продать {0} до
market.offerBook.buyOffersHeaderLabel=Купите {0} из
market.offerBook.buy=Я хочу купить Биткоин

View file

@ -49,7 +49,8 @@ shared.sell=prodaj
shared.buying=kupujem
shared.selling=prodajem
shared.P2P=P2P
shared.offers=ponude
shared.oneOffer=ponuda
shared.multipleOffers=ponude
shared.Offer=Ponuda
shared.openOffers=otvorene ponude
shared.trades=trgovine
@ -254,10 +255,10 @@ market.tabs.trades=Trgovine
# OfferBookChartView
market.offerBook.chart.title=Knjiga ponuda za {0}
market.offerBook.leftButtonAltcoin=Želim da kupim {0} (prodaja {1})
market.offerBook.rightButtonAltcoin=Želim da prodam {0} (kupovina {1})
market.offerBook.leftButtonFiat=Želim da kupim {0} sa {1}
market.offerBook.rightButtonFiat=Želim da prodam {0} za {1}
market.offerBook.buyAltcoin=Želim da kupim {0} (prodaja {1})
market.offerBook.sellAltcoin=Želim da prodam {0} (kupovina {1})
market.offerBook.buyWithFiat=Kupi {0}
market.offerBook.sellWithFiat=Prodaj {0}
market.offerBook.sellOffersHeaderLabel=Prodaj {0} u
market.offerBook.buyOffersHeaderLabel=Kupite {0} iz
market.offerBook.buy=Želim da kupim bitkoin

View file

@ -49,7 +49,8 @@ shared.sell=卖
shared.buying=买入
shared.selling=卖出
shared.P2P=P2P
shared.offers=委托
shared.oneOffer=委托
shared.multipleOffers=委托
shared.Offer=委托
shared.openOffers=发布中委托
shared.trades=交易
@ -254,10 +255,10 @@ market.tabs.trades=行情图
# OfferBookChartView
market.offerBook.chart.title={0} 的委托列表
market.offerBook.leftButtonAltcoin=我想要买入 {0} (卖出 {1})
market.offerBook.rightButtonAltcoin=我想要卖出 {0} (买入 {1})
market.offerBook.leftButtonFiat=我想要用 {1} 买入 {0}
market.offerBook.rightButtonFiat=我想要用 {1} 卖出 {0}
market.offerBook.buyAltcoin=我想要买入 {0} (卖出 {1})
market.offerBook.sellAltcoin=我想要卖出 {0} (买入 {1})
market.offerBook.buyWithFiat=购买{0}
market.offerBook.sellWithFiat=出售 {0}
market.offerBook.sellOffersHeaderLabel=出售 {0} 到
market.offerBook.buyOffersHeaderLabel=从中购买 {0}
market.offerBook.buy=我想要买入比特币

View file

@ -253,7 +253,8 @@ shared.sellingCurrency=Vendre {0} (Acheter des bitcoins)
shared.buying=acheter
shared.selling=vendre
shared.P2P=De pair à pair
shared.offers=Offres
shared.oneOffer=offre
shared.multipleOffers=offres
shared.Offer=Offre
shared.openOffers=Ouvrir les offres
shared.openTrades=Opérations ouvertes
@ -430,10 +431,10 @@ market.tabs.offerBook=Livre d'offre
market.tabs.spread=Distribution
market.tabs.trades=Échanges
market.offerBook.chart.title=Livre d'offre pour {0}
market.offerBook.leftButtonAltcoin=Je veux acheter {0} (vendre {1})
market.offerBook.rightButtonAltcoin=Je veux vendre {0} (buy {1})
market.offerBook.leftButtonFiat=Je veux acheter {0} avec {1}
market.offerBook.rightButtonFiat=Je veux vendre {0} pour {1}
market.offerBook.buyAltcoin=Je veux acheter {0} (vendre {1})
market.offerBook.sellAltcoin=Je veux vendre {0} (buy {1})
market.offerBook.buyWithFiat=Acheter {0}
market.offerBook.sellWithFiat=Vendre {0}
market.offerBook.sellOffersHeaderLabel=Vendre {0} à
market.offerBook.buyOffersHeaderLabel=Acheter {0} à partir de
market.offerBook.buy=Je veux acheter du bitcoin

View file

@ -270,6 +270,10 @@ public class Offer implements NetworkPayload, PersistablePayload {
return Coin.valueOf(offerPayload.getMinAmount());
}
public boolean isRange() {
return offerPayload.getAmount() != offerPayload.getMinAmount();
}
public Date getDate() {
return new Date(offerPayload.getDate());
}

View file

@ -0,0 +1,36 @@
package io.bisq.core.offer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest(OfferPayload.class)
public class OfferTest {
@Test
public void testHasNoRange() {
OfferPayload payload = mock(OfferPayload.class);
when(payload.getMinAmount()).thenReturn(1000L);
when(payload.getAmount()).thenReturn(1000L);
Offer offer = new Offer(payload);
assertFalse(offer.isRange());
}
@Test
public void testHasRange() {
OfferPayload payload = mock(OfferPayload.class);
when(payload.getMinAmount()).thenReturn(1000L);
when(payload.getAmount()).thenReturn(2000L);
Offer offer = new Offer(payload);
assertTrue(offer.isRange());
}
}

View file

@ -118,8 +118,8 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
currencyComboBox = new ComboBox<>();
currencyComboBox.setPromptText(Res.get("list.currency.select"));
currencyComboBox.setConverter(GUIUtil.getCurrencyListItemConverter(Res.get("shared.offer"),
Res.get("shared.offers"),
currencyComboBox.setConverter(GUIUtil.getCurrencyListItemConverter(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"),
model.preferences));
Label currencyLabel = new AutoTooltipLabel(Res.getWithCol("shared.currency"));
@ -213,10 +213,10 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
}
leftHeaderLabel.setText(Res.get("market.offerBook.buyOffersHeaderLabel", code));
leftButton.setText(Res.get("market.offerBook.leftButtonAltcoin", code, Res.getBaseCurrencyCode()));
leftButton.setText(Res.get("market.offerBook.buyAltcoin", code, Res.getBaseCurrencyCode()));
rightHeaderLabel.setText(Res.get("market.offerBook.sellOffersHeaderLabel", code));
rightButton.setText(Res.get("market.offerBook.rightButtonAltcoin", code, Res.getBaseCurrencyCode()));
rightButton.setText(Res.get("market.offerBook.sellAltcoin", code, Res.getBaseCurrencyCode()));
priceColumnLabel.set(Res.get("shared.priceWithCur", Res.getBaseCurrencyCode()));
} else {
@ -226,10 +226,10 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
}
leftHeaderLabel.setText(Res.get("market.offerBook.sellOffersHeaderLabel", Res.getBaseCurrencyCode()));
leftButton.setText(Res.get("market.offerBook.rightButtonFiat", Res.getBaseCurrencyCode(), code));
leftButton.setText(Res.get("market.offerBook.sellWithFiat", Res.getBaseCurrencyCode(), code));
rightHeaderLabel.setText(Res.get("market.offerBook.buyOffersHeaderLabel", Res.getBaseCurrencyCode()));
rightButton.setText(Res.get("market.offerBook.leftButtonFiat", Res.getBaseCurrencyCode(), code));
rightButton.setText(Res.get("market.offerBook.buyWithFiat", Res.getBaseCurrencyCode(), code));
priceColumnLabel.set(Res.get("shared.priceWithCur", code));
}
@ -430,7 +430,7 @@ public class OfferBookChartView extends ActivatableViewAndModel<VBox, OfferBookC
tableView.getColumns().add(priceColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.offers")));
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);

View file

@ -168,7 +168,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
tableView.getSortOrder().add(priceColumn);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.offers")));
Label placeholder = new AutoTooltipLabel(Res.get("table.placeholder.noItems", Res.get("shared.multipleOffers")));
placeholder.setWrapText(true);
tableView.setPlaceholder(placeholder);
@ -222,8 +222,8 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
protected void activate() {
currencyComboBox.setItems(model.getTradeCurrencies());
currencyComboBox.setConverter(GUIUtil.getTradeCurrencyConverter(
Res.get("shared.offer"),
Res.get("shared.offers"),
Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"),
(model.getDirection() == OfferPayload.Direction.BUY ? model.getSellOfferCounts() : model.getBuyOfferCounts())));
currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
currencyComboBox.setOnAction(e -> model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem()));

View file

@ -87,14 +87,14 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
private ScrollPane scrollPane;
private GridPane gridPane;
private TitledGroupBg payFundsPane, paymentAccountTitledGroupBg;
private VBox priceAsPercentageInputBox;
private VBox priceAsPercentageInputBox, amountRangeBox;
private HBox fundingHBox;
private ComboBox<PaymentAccount> paymentAccountsComboBox;
private Label directionLabel, amountDescriptionLabel, addressLabel, balanceLabel, totalToPayLabel,
paymentAccountsLabel, paymentMethodLabel,
priceCurrencyLabel, priceAsPercentageLabel,
volumeCurrencyLabel, priceDescriptionLabel, volumeDescriptionLabel,
waitingForFundsLabel, offerAvailabilityLabel;
waitingForFundsLabel, offerAvailabilityLabel, amountCurrency;
private InputTextField amountTextField;
private TextField paymentMethodTextField, currencyTextField, priceTextField, priceAsPercentageTextField,
volumeTextField, amountRangeTextField;
@ -116,7 +116,6 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
private boolean offerDetailsWindowDisplayed, clearXchangeWarningDisplayed;
private SimpleBooleanProperty errorPopupDisplayed;
///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
///////////////////////////////////////////////////////////////////////////////////////////
@ -197,6 +196,10 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
balanceTextField.setTargetAmount(model.dataModel.totalToPayAsCoin.get());
maybeShowClearXchangeWarning();
if (!model.isRange()) {
showNextStepAfterAmountIsSet();
}
}
private void showInsufficientBsqFundsForBtcFeePaymentPopup() {
@ -278,7 +281,17 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
currencyTextField.setText(model.dataModel.getCurrencyNameAndCode());
directionLabel.setText(model.getDirectionLabel());
amountDescriptionLabel.setText(model.getAmountDescription());
amountRangeTextField.setText(model.getAmountRange());
if (model.isRange()) {
amountRangeTextField.setText(model.getAmountRange());
amountRangeBox.setVisible(true);
} else {
amountTextField.setMouseTransparent(true);
amountTextField.setEditable(false);
amountTextField.setFocusTraversable(false);
amountCurrency.setId("currency-info-label-disabled");
}
priceTextField.setText(model.getPrice());
priceAsPercentageTextField.setText(model.marketPriceMargin);
addressTextField.setPaymentLabel(model.getPaymentLabel());
@ -726,10 +739,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
nextButton = new AutoTooltipButton(Res.get("shared.nextStep"));
nextButton.setDefaultButton(true);
nextButton.setOnAction(e -> {
if (DevEnv.DAO_TRADING_ACTIVATED)
showFeeOption();
else
onShowPayFundsScreen();
showNextStepAfterAmountIsSet();
});
cancelButton1 = new AutoTooltipButton(Res.get("shared.cancel"));
@ -741,6 +751,13 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
});
}
private void showNextStepAfterAmountIsSet() {
if (DevEnv.DAO_TRADING_ACTIVATED)
showFeeOption();
else
onShowPayFundsScreen();
}
private void showFeeOption() {
Coin makerFee = model.dataModel.getTakerFee(false);
String missingBsq = null;
@ -892,6 +909,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
Tuple3<HBox, InputTextField, Label> amountValueCurrencyBoxTuple = getAmountCurrencyBox(Res.get("takeOffer.amount.prompt"));
HBox amountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
amountTextField = amountValueCurrencyBoxTuple.second;
amountCurrency = amountValueCurrencyBoxTuple.third;
Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(amountValueCurrencyBox, model.getAmountDescription());
amountDescriptionLabel = amountInputBoxTuple.first;
VBox amountBox = amountInputBoxTuple.second;
@ -951,12 +969,14 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
priceAsPercentageLabel.getStyleClass().add("percentage-label");
Tuple3<HBox, TextField, Label> amountValueCurrencyBoxTuple = getNonEditableValueCurrencyBox();
HBox amountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
amountRangeTextField = amountValueCurrencyBoxTuple.second;
Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(amountValueCurrencyBox,
Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox( amountValueCurrencyBoxTuple.first,
Res.get("takeOffer.amountPriceBox.amountRangeDescription"));
amountRangeBox = amountInputBoxTuple.second;
amountRangeBox.setVisible(false);
Label xLabel = new AutoTooltipLabel("x");
xLabel.setFont(Font.font("Helvetica-Bold", 20));
xLabel.setPadding(new Insets(14, 3, 0, 3));
@ -965,7 +985,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setAlignment(Pos.CENTER_LEFT);
hBox.getChildren().addAll(amountInputBoxTuple.second, xLabel, priceAsPercentageInputBox);
hBox.getChildren().addAll(amountRangeBox, xLabel, priceAsPercentageInputBox);
GridPane.setRowIndex(hBox, ++gridRow);
GridPane.setColumnIndex(hBox, 1);

View file

@ -555,6 +555,8 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
return dataModel.getOffer();
}
public boolean isRange() {return dataModel.getOffer().isRange(); }
public String getAmountRange() {
return amountRange;
}

View file

@ -334,7 +334,7 @@ public class BSFormatter {
}
public String formatMinVolumeAndVolume(Offer offer) {
return formatVolume(offer.getMinVolume()) + " - " + formatVolume(offer.getVolume());
return offer.isRange() ? formatVolume(offer.getMinVolume()) + " - " + formatVolume(offer.getVolume()) : formatVolume(offer.getVolume());
}
@ -347,7 +347,7 @@ public class BSFormatter {
}
public String formatAmountWithMinAmount(Offer offer) {
return formatCoin(offer.getMinAmount()) + " - " + formatCoin(offer.getAmount());
return offer.isRange() ? formatCoin(offer.getMinAmount()) + " - " + formatCoin(offer.getAmount()) : formatCoin(offer.getAmount());
}

View file

@ -18,8 +18,16 @@
package io.bisq.gui.util;
import io.bisq.common.locale.Res;
import io.bisq.common.monetary.Volume;
import io.bisq.core.offer.Offer;
import io.bisq.core.offer.OfferPayload;
import org.bitcoinj.core.Coin;
import org.bitcoinj.core.CoinMaker;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
@ -29,16 +37,21 @@ import static io.bisq.common.monetary.PriceMaker.priceString;
import static io.bisq.common.monetary.PriceMaker.usdPrice;
import static io.bisq.common.monetary.VolumeMaker.usdVolume;
import static io.bisq.common.monetary.VolumeMaker.volumeString;
import static org.bitcoinj.core.CoinMaker.*;
import static org.bitcoinj.core.CoinMaker.oneBitcoin;
import static org.bitcoinj.core.CoinMaker.satoshis;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({Offer.class,OfferPayload.class})
public class BSFormatterTest {
private BSFormatter formatter;
@Before
public void setup() {
public void setUp() {
Locale.setDefault(new Locale("en", "US"));
formatter = new BSFormatter();
Res.setBaseCurrencyCode("BTC");
@ -85,8 +98,8 @@ public class BSFormatterTest {
public void testFormatCoin() {
assertEquals("1.00", formatter.formatCoin(oneBitcoin));
assertEquals("1.0000", formatter.formatCoin(oneBitcoin, 4));
assertEquals("0.000001", formatter.formatCoin(make(a(Coin).but(with(satoshis, 100L)))));
assertEquals("0.00000001", formatter.formatCoin(make(a(Coin).but(with(satoshis, 1L)))));
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
@ -95,4 +108,63 @@ public class BSFormatterTest {
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.formatMinVolumeAndVolume(offer));
}
@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.formatMinVolumeAndVolume(offer));
}
@Test
public void testFormatNullVolume() {
Offer offer = mock(Offer.class);
when(offer.getMinVolume()).thenReturn(null);
when(offer.getVolume()).thenReturn(null);
assertEquals("", formatter.formatMinVolumeAndVolume(offer));
}
@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.formatAmountWithMinAmount(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.formatAmountWithMinAmount(offer));
}
@Test
public void testFormatNullAmount() {
Offer offer = mock(Offer.class);
when(offer.getMinAmount()).thenReturn(null);
when(offer.getAmount()).thenReturn(null);
assertEquals("", formatter.formatAmountWithMinAmount(offer));
}
}

View file

@ -32,8 +32,8 @@ public class GUIUtilTest {
put("EUR", 10);
}};
StringConverter<TradeCurrency> tradeCurrencyConverter = GUIUtil.getTradeCurrencyConverter(
Res.get("shared.offer"),
Res.get("shared.offers"),
Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"),
offerCounts
);
@ -45,8 +45,8 @@ public class GUIUtilTest {
public void testCurrencyListWithOffersConverter() {
Res.setBaseCurrencyCode("BTC");
Res.setBaseCurrencyName("Bitcoin");
StringConverter<CurrencyListItem> currencyListItemConverter = GUIUtil.getCurrencyListItemConverter(Res.get("shared.offer"),
Res.get("shared.offers"),
StringConverter<CurrencyListItem> currencyListItemConverter = GUIUtil.getCurrencyListItemConverter(Res.get("shared.oneOffer"),
Res.get("shared.multipleOffers"),
empty);
assertEquals("✦ BTC (BTC) - 10 offers", currencyListItemConverter.toString(make(bitcoinItem.but(with(numberOfTrades,10)))));