Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor buy/sell tabs #1379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions core/src/main/java/haveno/core/locale/CurrencyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,6 @@ public static void setup() {

private static String baseCurrencyCode = "XMR";

private static List<TraditionalCurrency> getTraditionalNonFiatCurrencies() {
return Arrays.asList(
new TraditionalCurrency("XAG", "Silver"),
new TraditionalCurrency("XAU", "Gold"),
new TraditionalCurrency("XGB", "Goldback")
);
}

// Calls to isTraditionalCurrency and isCryptoCurrency are very frequent so we use a cache of the results.
// The main improvement was already achieved with using memoize for the source maps, but
// the caching still reduces performance costs by about 20% for isCryptoCurrency (1752 ms vs 2121 ms) and about 50%
Expand Down Expand Up @@ -124,6 +116,14 @@ public static List<TradeCurrency> getAllTraditionalCurrencies() {
return new ArrayList<>(traditionalCurrencyMapSupplier.get().values());
}

public static List<TraditionalCurrency> getTraditionalNonFiatCurrencies() {
return Arrays.asList(
new TraditionalCurrency("XAG", "Silver"),
new TraditionalCurrency("XAU", "Gold"),
new TraditionalCurrency("XGB", "Goldback")
);
}

public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies(Comparator comparator) {
return (List<TraditionalCurrency>) getAllSortedTraditionalCurrencies().stream()
.sorted(comparator)
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/haveno/core/payment/PaymentAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public boolean isFiat() {
return getSingleTradeCurrency() == null || CurrencyUtil.isFiatCurrency(getSingleTradeCurrency().getCode()); // TODO: check if trade currencies contain fiat
}

public boolean isCryptoCurrency() {
return getSingleTradeCurrency() != null && CurrencyUtil.isCryptoCurrency(getSingleTradeCurrency().getCode());
}


///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/haveno/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,16 @@ public void setSellScreenCryptoCurrencyCode(String sellScreenCurrencyCode) {
requestPersistence();
}

public void setBuyScreenOtherCurrencyCode(String buyScreenCurrencyCode) {
prefPayload.setBuyScreenOtherCurrencyCode(buyScreenCurrencyCode);
requestPersistence();
}

public void setSellScreenOtherCurrencyCode(String sellScreenCurrencyCode) {
prefPayload.setSellScreenOtherCurrencyCode(sellScreenCurrencyCode);
requestPersistence();
}

public void setIgnoreTradersList(List<String> ignoreTradersList) {
prefPayload.setIgnoreTradersList(ignoreTradersList);
requestPersistence();
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/java/haveno/core/user/PreferencesPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public final class PreferencesPayload implements PersistableEnvelope {
private String buyScreenCryptoCurrencyCode;
@Nullable
private String sellScreenCryptoCurrencyCode;
@Nullable
private String buyScreenOtherCurrencyCode;
@Nullable
private String sellScreenOtherCurrencyCode;
private int tradeStatisticsTickUnitIndex = 3;
private boolean resyncSpvRequested;
private boolean sortMarketCurrenciesNumerically = true;
Expand Down Expand Up @@ -212,6 +216,8 @@ public Message toProtoMessage() {
Optional.ofNullable(sellScreenCurrencyCode).ifPresent(builder::setSellScreenCurrencyCode);
Optional.ofNullable(buyScreenCryptoCurrencyCode).ifPresent(builder::setBuyScreenCryptoCurrencyCode);
Optional.ofNullable(sellScreenCryptoCurrencyCode).ifPresent(builder::setSellScreenCryptoCurrencyCode);
Optional.ofNullable(buyScreenOtherCurrencyCode).ifPresent(builder::setBuyScreenOtherCurrencyCode);
Optional.ofNullable(sellScreenOtherCurrencyCode).ifPresent(builder::setSellScreenOtherCurrencyCode);
Optional.ofNullable(selectedPaymentAccountForCreateOffer).ifPresent(
account -> builder.setSelectedPaymentAccountForCreateOffer(selectedPaymentAccountForCreateOffer.toProtoMessage()));
Optional.ofNullable(bridgeAddresses).ifPresent(builder::addAllBridgeAddresses);
Expand Down Expand Up @@ -260,6 +266,8 @@ public static PreferencesPayload fromProto(protobuf.PreferencesPayload proto, Co
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCryptoCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getSellScreenCryptoCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getBuyScreenOtherCurrencyCode()),
ProtoUtil.stringOrNullFromProto(proto.getSellScreenOtherCurrencyCode()),
proto.getTradeStatisticsTickUnitIndex(),
proto.getResyncSpvRequested(),
proto.getSortMarketCurrenciesNumerically(),
Expand Down
9 changes: 6 additions & 3 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ shared.crypto=Crypto
shared.traditional=Traditional
shared.otherAssets=other assets
shared.other=Other
shared.preciousMetals=Precious Metals
shared.all=All
shared.edit=Edit
shared.advancedOptions=Advanced options
Expand Down Expand Up @@ -245,8 +246,8 @@ shared.taker=Taker
####################################################################

mainView.menu.market=Market
mainView.menu.buy=Buy
mainView.menu.sell=Sell
mainView.menu.buyXmr=Buy XMR
mainView.menu.sellXmr=Sell XMR
mainView.menu.portfolio=Portfolio
mainView.menu.funds=Funds
mainView.menu.support=Support
Expand Down Expand Up @@ -375,6 +376,8 @@ offerbook.timeSinceSigning.tooltip.checkmark.buyXmr=buy XMR from a signed accoun
offerbook.timeSinceSigning.tooltip.checkmark.wait=wait a minimum of {0} days
offerbook.timeSinceSigning.tooltip.learnMore=Learn more
offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.buyXmrWith=Buy XMR with:
offerbook.sellXmrFor=Sell XMR for:

offerbook.timeSinceSigning.help=When you successfully complete a trade with a peer who has a signed payment account, your payment account is signed.\n\
{0} days later, the initial limit of {1} is lifted and your account can sign other peers'' payment accounts.
Expand All @@ -389,7 +392,7 @@ offerbook.volume={0} (min - max)
offerbook.deposit=Deposit XMR (%)
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.

offerbook.createNewOffer=Create new offer to {0} {1}
offerbook.createNewOffer=Create offer to {0} {1}
offerbook.createOfferDisabled.tooltip=You can only create one offer at a time

offerbook.takeOfferButton.tooltip=Take offer for {0}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_cs.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Potvrzuji
shared.openURL=Otevřené {0}
shared.fiat=Fiat
shared.crypto=Krypto
shared.preciousMetals=Drahé kovy
shared.all=Vše
shared.edit=Upravit
shared.advancedOptions=Pokročilé možnosti
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=účet byl zablokován
offerbook.timeSinceSigning.daysSinceSigning={0} dní
offerbook.timeSinceSigning.daysSinceSigning.long={0} od podpisu
offerbook.xmrAutoConf=Je automatické potvrzení povoleno
offerbook.buyXmrWith=Kupte XMR za:
offerbook.sellXmrFor=Prodat XMR za:

offerbook.timeSinceSigning.help=Když úspěšně dokončíte obchod s uživatelem, který má podepsaný platební účet, je váš platební účet podepsán.\n{0} dní později se počáteční limit {1} zruší a váš účet může podepisovat platební účty ostatních uživatelů.
offerbook.timeSinceSigning.notSigned=Dosud nepodepsáno
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=Počet nabídek: {0}
offerbook.volume={0} (min - max)
offerbook.deposit=Kauce XMR (%)
offerbook.deposit.help=Kauce zaplacená každým obchodníkem k zajištění obchodu. Bude vrácena po dokončení obchodu.
offerbook.createNewOffer=Vytvořit nabídku pro {0} {1}

offerbook.createOfferToBuy=Vytvořit novou nabídku k nákupu {0}
offerbook.createOfferToSell=Vytvořit novou nabídku k prodeji {0}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Ich bestätige
shared.openURL=Öffne {0}
shared.fiat=Fiat
shared.crypto=Crypto
shared.preciousMetals=Edelmetalle
shared.all=Alle
shared.edit=Bearbeiten
shared.advancedOptions=Erweiterte Optionen
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=Konto wurde geblockt
offerbook.timeSinceSigning.daysSinceSigning={0} Tage
offerbook.timeSinceSigning.daysSinceSigning.long={0} seit der Unterzeichnung
offerbook.xmrAutoConf=Automatische Bestätigung aktiviert
offerbook.buyXmrWith=XMR kaufen mit:
offerbook.sellXmrFor=XMR verkaufen für:

offerbook.timeSinceSigning.help=Wenn Sie einen Trade mit einem Partner erfolgreich abschließen, der ein unterzeichnetes Zahlungskonto hat, wird Ihr Zahlungskonto unterzeichnet.\n{0} Tage später wird das anfängliche Limit von {1} aufgehoben und Ihr Konto kann die Zahlungskonten anderer Partner unterzeichnen.
offerbook.timeSinceSigning.notSigned=Noch nicht unterzeichnet
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=Anzahl der Angebote: {0}
offerbook.volume={0} (min - max)
offerbook.deposit=Kaution XMR (%)
offerbook.deposit.help=Kaution die von beiden Handelspartnern bezahlt werden muss, um den Handel abzusichern. Wird zurückgezahlt, wenn der Handel erfolgreich abgeschlossen wurde.
offerbook.createNewOffer=Erstelle Angebot an {0} {1}

offerbook.createOfferToBuy=Neues Angebot erstellen, um {0} zu kaufen
offerbook.createOfferToSell=Neues Angebot erstellen, um {0} zu verkaufen
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Confirmo
shared.openURL=Abrir {0}
shared.fiat=Fiat
shared.crypto=Cripto
shared.preciousMetals=Metales Preciosos
shared.all=Todos
shared.edit=Editar
shared.advancedOptions=Opciones avanzadas
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=La cuenta fue bloqueada
offerbook.timeSinceSigning.daysSinceSigning={0} días
offerbook.timeSinceSigning.daysSinceSigning.long={0} desde el firmado
offerbook.xmrAutoConf=¿Está habilitada la confirmación automática?
offerbook.buyXmrWith=Compra XMR con:
offerbook.sellXmrFor=Vender XMR por:

offerbook.timeSinceSigning.help=Cuando complete con éxito un intercambio con un par que tenga una cuenta de pago firmada, su cuenta de pago es firmada.\n{0} días después, el límite inicial de {1} se eleva y su cuenta puede firmar tras cuentas de pago.
offerbook.timeSinceSigning.notSigned=No firmada aún
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=Número de ofertas: {0}
offerbook.volume={0} (min - max)
offerbook.deposit=Depósito en XMR (%)
offerbook.deposit.help=Depósito pagado por cada comerciante para garantizar el intercambio. Será devuelto al acabar el intercambio.
offerbook.createNewOffer=Crear oferta a {0} {1}

offerbook.createOfferToBuy=Crear nueva oferta para comprar {0}
offerbook.createOfferToSell=Crear nueva oferta para vender {0}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_fa.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=تایید می‌کنم
shared.openURL=باز {0}
shared.fiat=فیات
shared.crypto=کریپتو
shared.preciousMetals=فلزات گرانبها
shared.all=همه
shared.edit=ویرایش
shared.advancedOptions=گزینه‌های پیشرفته
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=account was banned
offerbook.timeSinceSigning.daysSinceSigning={0} روز
offerbook.timeSinceSigning.daysSinceSigning.long={0} since signing
offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.buyXmrWith=با XMR خرید کنید:
offerbook.sellXmrFor=فروش XMR برای:

offerbook.timeSinceSigning.help=When you successfully complete a trade with a peer who has a signed payment account, your payment account is signed.\n{0} days later, the initial limit of {1} is lifted and your account can sign other peers'' payment accounts.
offerbook.timeSinceSigning.notSigned=Not signed yet
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=تعداد پیشنهادها: {0}
offerbook.volume={0} (حداقل - حداکثر)
offerbook.deposit=Deposit XMR (%)
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.
offerbook.createNewOffer=پیشنهاد ایجاد کنید به {0} {1}

offerbook.createOfferToBuy=پیشنهاد جدید برای خرید {0} ایجاد کن
offerbook.createOfferToSell=پیشنهاد جدید برای فروش {0} ایجاد کن
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Je confirme
shared.openURL=Ouvert {0}
shared.fiat=Fiat
shared.crypto=Crypto
shared.preciousMetals=Métaux précieux
shared.all=Tout
shared.edit=Modifier
shared.advancedOptions=Options avancées
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=Ce compte a été banni
offerbook.timeSinceSigning.daysSinceSigning={0} jours
offerbook.timeSinceSigning.daysSinceSigning.long={0} depuis la signature
offerbook.xmrAutoConf=Est-ce-que la confirmation automatique est activée
offerbook.buyXmrWith=Acheter XMR avec :
offerbook.sellXmrFor=Vendre XMR pour :

offerbook.timeSinceSigning.help=Lorsque vous effectuez avec succès une transaction avec un pair disposant d''un compte de paiement signé, votre compte de paiement est signé.\n{0} Jours plus tard, la limite initiale de {1} est levée et votre compte peut signer les comptes de paiement d''un autre pair.
offerbook.timeSinceSigning.notSigned=Pas encore signé
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=Nombre d''ordres: {0}
offerbook.volume={0} (min - max)
offerbook.deposit=Déposer XMR (%)
offerbook.deposit.help=Les deux parties à la transaction ont payé un dépôt pour assurer que la transaction se déroule normalement. Ce montant sera remboursé une fois la transaction terminée.
offerbook.createNewOffer=Créer une offre à {0} {1}

offerbook.createOfferToBuy=Créer un nouvel ordre d''achat pour {0}
offerbook.createOfferToSell=Créer un nouvel ordre de vente pour {0}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Confermo
shared.openURL=Aperti {0}
shared.fiat=Fiat
shared.crypto=Crypto
shared.preciousMetals=Metalli Preziosi
shared.all=Tutti
shared.edit=Modifica
shared.advancedOptions=Opzioni avanzate
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned= \nl'account è stato bannato
offerbook.timeSinceSigning.daysSinceSigning={0} giorni
offerbook.timeSinceSigning.daysSinceSigning.long={0} dalla firma
offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.buyXmrWith=Compra XMR con:
offerbook.sellXmrFor=Vendi XMR per:

offerbook.timeSinceSigning.help=Quando completi correttamente un'operazione con un peer che ha un account di pagamento firmato, il tuo account di pagamento viene firmato.\n{0} giorni dopo, il limite iniziale di {1} viene alzato e il tuo account può firmare account di pagamento di altri peer.
offerbook.timeSinceSigning.notSigned=Non ancora firmato
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=N. di offerte: {0}
offerbook.volume={0} (min - max)
offerbook.deposit=Deposit XMR (%)
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.
offerbook.createNewOffer=Crea offerta per {0} {1}

offerbook.createOfferToBuy=Crea una nuova offerta per comprare {0}
offerbook.createOfferToSell=Crea una nuova offerta per vendere {0}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_ja.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=確認します
shared.openURL={0} をオープン
shared.fiat=法定通貨
shared.crypto=暗号通貨
shared.preciousMetals=貴金属
shared.all=全て
shared.edit=編集
shared.advancedOptions=高度なオプション
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=このアカウントは禁止されま
offerbook.timeSinceSigning.daysSinceSigning={0}日
offerbook.timeSinceSigning.daysSinceSigning.long=署名する後から {0}
offerbook.xmrAutoConf=自動確認は有効されますか?
offerbook.buyXmrWith=XMRを購入:
offerbook.sellXmrFor=XMRを売る:

offerbook.timeSinceSigning.help=署名された支払いアカウントを持っているピアと成功にトレードすると、自身の支払いアカウントも署名されることになります。\n{0} 日後に、{1} という初期の制限は解除され、他のピアの支払いアカウントを署名できるようになります。
offerbook.timeSinceSigning.notSigned=まだ署名されていません
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=オファー数: {0}
offerbook.volume={0} (下限 - 上限)
offerbook.deposit=XMRの敷金(%)
offerbook.deposit.help=トレードを保証するため、両方の取引者が支払う敷金。トレードが完了されたら、返還されます。
offerbook.createNewOffer={0} {1}にオファーを作成する

offerbook.createOfferToBuy={0} を購入するオファーを作成
offerbook.createOfferToSell={0} を売却するオファーを作成
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Eu confirmo
shared.openURL=Aberto {0}
shared.fiat=Fiat
shared.crypto=Cripto
shared.preciousMetals=Metais Preciosos
shared.all=Todos
shared.edit=Editar
shared.advancedOptions=Opções avançadas
Expand Down Expand Up @@ -351,6 +352,8 @@ offerbook.timeSinceSigning.info.banned=conta foi banida
offerbook.timeSinceSigning.daysSinceSigning={0} dias
offerbook.timeSinceSigning.daysSinceSigning.long={0} desde a assinatura
offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.buyXmrWith=Compre XMR com:
offerbook.sellXmrFor=Venda XMR por:

offerbook.timeSinceSigning.help=Quando você completa uma negociação bem sucedida com um par que tem uma conta de pagamento assinada, a sua conta de pagamento é assinada.\n{0} dias depois, o limite inicial de {1} é levantado e sua conta pode assinar as contas de pagamento de outros pares.
offerbook.timeSinceSigning.notSigned=Ainda não assinada
Expand All @@ -365,6 +368,7 @@ offerbook.nrOffers=N.º de ofertas: {0}
offerbook.volume={0} (mín. - máx.)
offerbook.deposit=Deposit XMR (%)
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.
offerbook.createNewOffer=Criar oferta para {0} {1}

offerbook.createOfferToBuy=Criar oferta para comprar {0}
offerbook.createOfferToSell=Criar oferta para vender {0}
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/resources/i18n/displayStrings_pt.properties
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shared.iConfirm=Eu confirmo
shared.openURL=Abrir {0}
shared.fiat=Moeda fiduciária
shared.crypto=Cripto
shared.preciousMetals=TODO
shared.all=Tudo
shared.edit=Editar
shared.advancedOptions=Opções avançadas
Expand Down Expand Up @@ -348,6 +349,8 @@ offerbook.timeSinceSigning.info.banned=account was banned
offerbook.timeSinceSigning.daysSinceSigning={0} dias
offerbook.timeSinceSigning.daysSinceSigning.long={0} desde a assinatura
offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.buyXmrWith=Compre XMR com:
offerbook.sellXmrFor=Venda XMR por:

offerbook.timeSinceSigning.help=Quando você completa com sucesso um negócio com um par que tenha uma conta de pagamento assinada, a sua conta de pagamento é assinada .\n{0} dias depois, o limite inicial de {1} é aumentado e a sua conta pode assinar contas de pagamento de outros pares.
offerbook.timeSinceSigning.notSigned=Ainda não assinada
Expand All @@ -362,6 +365,7 @@ offerbook.nrOffers=Nº de ofertas: {0}
offerbook.volume={0} (mín - máx)
offerbook.deposit=Deposit XMR (%)
offerbook.deposit.help=Deposit paid by each trader to guarantee the trade. Will be returned when the trade is completed.
offerbook.createNewOffer=Criar oferta para {0} {1}

offerbook.createOfferToBuy=Criar nova oferta para comprar {0}
offerbook.createOfferToSell=Criar nova oferta para vender {0}
Expand Down
Loading
Loading