refactor offer tabs to fiat, bitcoin, other (with gold and silver)

This commit is contained in:
woodser 2023-05-19 14:08:53 -04:00
parent a31b73d676
commit 5aba26ff82
36 changed files with 204 additions and 148 deletions

View File

@ -73,6 +73,18 @@ public class CurrencyUtil {
CurrencyUtil.baseCurrencyCode = baseCurrencyCode;
}
public static Collection<TraditionalCurrency> getAllSortedFiatCurrencies(Comparator comparator) {
return getAllSortedTraditionalCurrencies(comparator).stream()
.filter(currency -> CurrencyUtil.isFiatCurrency(currency.getCode()))
.collect(Collectors.toList()); // sorted by currency name
}
public static List<TradeCurrency> getAllFiatCurrencies() {
return getAllTraditionalCurrencies().stream()
.filter(currency -> CurrencyUtil.isFiatCurrency(currency.getCode()))
.collect(Collectors.toList()); // sorted by currency name
}
public static Collection<TraditionalCurrency> getAllSortedTraditionalCurrencies() {
return traditionalCurrencyMapSupplier.get().values(); // sorted by currency name
}
@ -98,8 +110,7 @@ public class CurrencyUtil {
.collect(Collectors.toMap(TradeCurrency::getCode, Function.identity(), (x, y) -> x, LinkedHashMap::new));
}
public static List<TraditionalCurrency> getMainTraditionalCurrencies() {
TradeCurrency defaultTradeCurrency = getDefaultTradeCurrency();
public static List<TraditionalCurrency> getMainFiatCurrencies() {
List<TraditionalCurrency> list = new ArrayList<>();
list.add(new TraditionalCurrency("USD"));
list.add(new TraditionalCurrency("EUR"));
@ -109,18 +120,28 @@ public class CurrencyUtil {
list.add(new TraditionalCurrency("RUB"));
list.add(new TraditionalCurrency("INR"));
list.add(new TraditionalCurrency("NGN"));
postProcessTraditionalCurrenciesList(list);
return list;
}
public static List<TraditionalCurrency> getMainTraditionalCurrencies() {
List<TraditionalCurrency> list = getMainFiatCurrencies();
list.add(new TraditionalCurrency("XAG"));
list.add(new TraditionalCurrency("XAU"));
postProcessTraditionalCurrenciesList(list);
return list;
}
private static void postProcessTraditionalCurrenciesList(List<TraditionalCurrency> list) {
list.sort(TradeCurrency::compareTo);
TradeCurrency defaultTradeCurrency = getDefaultTradeCurrency();
TraditionalCurrency defaultTraditionalCurrency =
defaultTradeCurrency instanceof TraditionalCurrency ? (TraditionalCurrency) defaultTradeCurrency : null;
if (defaultTraditionalCurrency != null && list.contains(defaultTraditionalCurrency)) {
list.remove(defaultTradeCurrency);
list.add(0, defaultTraditionalCurrency);
}
return list;
}
public static Collection<CryptoCurrency> getAllSortedCryptoCurrencies() {

View File

@ -30,7 +30,7 @@ import java.util.List;
public final class CashDepositAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
public CashDepositAccount() {
super(PaymentMethod.CASH_DEPOSIT);

View File

@ -32,7 +32,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public final class NationalBankAccount extends CountryBasedPaymentAccount implements SameCountryRestrictedBankAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
public NationalBankAccount() {
super(PaymentMethod.NATIONAL_BANK);

View File

@ -117,6 +117,10 @@ public abstract class PaymentAccount implements PersistablePayload {
paymentAccountPayload = payload;
}
public boolean isFiat() {
return getSingleTradeCurrency() == null || CurrencyUtil.isFiatCurrency(getSingleTradeCurrency().getCode()); // TODO: check if trade currencies contain fiat
}
///////////////////////////////////////////////////////////////////////////////////////////
// PROTO BUFFER

View File

@ -32,7 +32,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public final class SameBankAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
public SameBankAccount() {
super(PaymentMethod.SAME_BANK);

View File

@ -32,7 +32,7 @@ import java.util.List;
@EqualsAndHashCode(callSuper = true)
public final class SpecificBanksAccount extends CountryBasedPaymentAccount implements BankNameRestrictedBankAccount, SameCountryRestrictedBankAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
public SpecificBanksAccount() {
super(PaymentMethod.SPECIFIC_BANKS);

View File

@ -18,6 +18,7 @@
package haveno.core.payment;
import haveno.core.api.model.PaymentAccountFormField;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.TradeCurrency;
import haveno.core.payment.payload.PaymentAccountPayload;
import haveno.core.payment.payload.PaymentMethod;
@ -28,13 +29,12 @@ import lombok.NonNull;
import java.util.ArrayList;
import java.util.List;
import static haveno.core.locale.CurrencyUtil.getAllSortedTraditionalCurrencies;
import static java.util.Comparator.comparing;
@EqualsAndHashCode(callSuper = true)
public final class SwiftAccount extends PaymentAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = new ArrayList<>(getAllSortedTraditionalCurrencies(comparing(TradeCurrency::getCode)));
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = new ArrayList<>(CurrencyUtil.getAllSortedFiatCurrencies(comparing(TradeCurrency::getCode)));
private static final List<PaymentAccountFormField.FieldId> INPUT_FIELD_IDS = List.of(
PaymentAccountFormField.FieldId.ACCOUNT_NAME,

View File

@ -29,7 +29,7 @@ import java.util.List;
public final class WesternUnionAccount extends CountryBasedPaymentAccount {
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllTraditionalCurrencies();
public static final List<TradeCurrency> SUPPORTED_CURRENCIES = CurrencyUtil.getAllFiatCurrencies();
public WesternUnionAccount() {
super(PaymentMethod.WESTERN_UNION);

View File

@ -387,6 +387,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable<Payme
private final long maxTradeLimit;
// list of asset codes the payment method supports
@Getter
private List<String> supportedAssetCodes;

View File

@ -225,7 +225,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
GlobalSettings.setUseAnimations(prefPayload.isUseAnimations());
TradeCurrency preferredTradeCurrency = checkNotNull(prefPayload.getPreferredTradeCurrency(), "preferredTradeCurrency must not be null");
setPreferredTradeCurrency(preferredTradeCurrency);
setFiatCurrencies(prefPayload.getTraditionalCurrencies());
setTraditionalCurrencies(prefPayload.getTraditionalCurrencies());
setCryptoCurrencies(prefPayload.getCryptoCurrencies());
GlobalSettings.setDefaultTradeCurrency(preferredTradeCurrency);
@ -255,7 +255,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
}
prefPayload.setPreferredTradeCurrency(preferredTradeCurrency);
setFiatCurrencies(CurrencyUtil.getMainTraditionalCurrencies());
setTraditionalCurrencies(CurrencyUtil.getMainFiatCurrencies());
setCryptoCurrencies(CurrencyUtil.getMainCryptoCurrencies());
BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork();
@ -608,9 +608,9 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
requestPersistence();
}
private void setFiatCurrencies(List<TraditionalCurrency> currencies) {
public void setTraditionalCurrencies(List<TraditionalCurrency> currencies) {
traditionalCurrenciesAsObservable.setAll(currencies.stream()
.map(fiatCurrency -> new TraditionalCurrency(fiatCurrency.getCurrency()))
.map(traditionalCurrency -> new TraditionalCurrency(traditionalCurrency.getCurrency()))
.distinct().collect(Collectors.toList()));
requestPersistence();
}
@ -909,7 +909,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
void setPayFeeInXmr(boolean payFeeInXmr);
void setFiatCurrencies(List<TraditionalCurrency> currencies);
void setTraditionalCurrencies(List<TraditionalCurrency> currencies);
void setCryptoCurrencies(List<CryptoCurrency> currencies);

View File

@ -200,8 +200,9 @@ shared.makerTxFee=Maker: {0}
shared.takerTxFee=Taker: {0}
shared.iConfirm=I confirm
shared.openURL=Open {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Crypto
shared.traditional=Traditional
shared.otherAssets=other assets
shared.other=Other
shared.all=All
@ -1243,12 +1244,12 @@ setting.preferences.ignorePeers=Ignored peers [onion address:port]
setting.preferences.ignoreDustThreshold=Min. non-dust output value
setting.preferences.currenciesInList=Currencies in market price feed list
setting.preferences.prefCurrency=Preferred currency
setting.preferences.displayFiat=Display national currencies
setting.preferences.noFiat=There are no national currencies selected
setting.preferences.displayTraditional=Display traditional currencies
setting.preferences.noTraditional=There are no traditional currencies selected
setting.preferences.cannotRemovePrefCurrency=You cannot remove your selected preferred display currency
setting.preferences.displayCryptos=Display cryptos
setting.preferences.displayCryptos=Display cryptose
setting.preferences.noCryptos=There are no cryptos selected
setting.preferences.addFiat=Add national currency
setting.preferences.addTraditional=Add traditional currency
setting.preferences.addCrypto=Add cryptocurrency
setting.preferences.displayOptions=Display options
setting.preferences.showOwnOffers=Show my own offers in offer book
@ -1402,7 +1403,7 @@ account.tab.mediatorRegistration=Mediator registration
account.tab.refundAgentRegistration=Refund agent registration
account.tab.signing=Signing
account.menu.paymentAccount=National currency accounts
account.menu.paymentAccount=Traditional currency accounts
account.menu.altCoinsAccountView=Cryptocurrency accounts
account.menu.password=Wallet password
account.menu.seedWords=Wallet seed

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Tvůrce: {0}
shared.takerTxFee=Příjemce: {0}
shared.iConfirm=Potvrzuji
shared.openURL=Otevřené {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Krypto
shared.all=Vše
shared.edit=Upravit
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Ignorované peer uzly [onion addresa:port]
setting.preferences.ignoreDustThreshold=Min. hodnota výstupu bez drobných
setting.preferences.currenciesInList=Měny v seznamu zdrojů tržních cen
setting.preferences.prefCurrency=Preferovaná měna
setting.preferences.displayFiat=Zobrazit národní měny
setting.preferences.noFiat=Nejsou vybrány žádné národní měny
setting.preferences.displayTraditional=Zobrazit národní měny
setting.preferences.noTraditional=Nejsou vybrány žádné národní měny
setting.preferences.cannotRemovePrefCurrency=Vybranou zobrazovanou měnu nelze odebrat.
setting.preferences.displayCryptos=Zobrazit cryptoy
setting.preferences.noCryptos=Nejsou vybrány žádné cryptoy
setting.preferences.addFiat=Přidejte národní měnu
setting.preferences.addTraditional=Přidejte národní měnu
setting.preferences.addCrypto=Přidejte crypto
setting.preferences.displayOptions=Zobrazit možnosti
setting.preferences.showOwnOffers=Zobrazit mé vlastní nabídky v seznamu nabídek

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Ersteller: {0}
shared.takerTxFee=Abnehmer: {0}
shared.iConfirm=Ich bestätige
shared.openURL=Öffne {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Crypto
shared.all=Alle
shared.edit=Bearbeiten
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Ignorierte Peers [Onion Adresse:Port]
setting.preferences.ignoreDustThreshold=Min. nicht-dust Ausgabewert
setting.preferences.currenciesInList=Währungen in Liste der Marktpreise
setting.preferences.prefCurrency=Bevorzugte Währung
setting.preferences.displayFiat=Nationale Währungen anzeigen
setting.preferences.noFiat=Es wurden keine nationalen Währungen ausgewählt
setting.preferences.displayTraditional=Nationale Währungen anzeigen
setting.preferences.noTraditional=Es wurden keine nationalen Währungen ausgewählt
setting.preferences.cannotRemovePrefCurrency=Sie können Ihre ausgewählte bevorzugte Anzeigewährung nicht entfernen
setting.preferences.displayCryptos=Cryptos anzeigen
setting.preferences.noCryptos=Es sind keine Cryptos ausgewählt
setting.preferences.addFiat=Nationale Währung hinzufügen
setting.preferences.addTraditional=Nationale Währung hinzufügen
setting.preferences.addCrypto=Crypto hinzufügen
setting.preferences.displayOptions=Darstellungsoptionen
setting.preferences.showOwnOffers=Eigenen Angebote im Angebotsbuch zeigen

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Creador: {0}
shared.takerTxFee=Tomador: {0}
shared.iConfirm=Confirmo
shared.openURL=Abrir {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Cripto
shared.all=Todos
shared.edit=Editar
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Pares ignorados [dirección onion:puerto]
setting.preferences.ignoreDustThreshold=Valor mínimo de output que no sea dust
setting.preferences.currenciesInList=Monedas en lista para precio de mercado
setting.preferences.prefCurrency=Moneda preferida
setting.preferences.displayFiat=Mostrar monedas nacionales
setting.preferences.noFiat=No hay monedas nacionales seleccionadas
setting.preferences.displayTraditional=Mostrar monedas nacionales
setting.preferences.noTraditional=No hay monedas nacionales seleccionadas
setting.preferences.cannotRemovePrefCurrency=No puede eliminar su moneda preferida para mostrar seleccionada
setting.preferences.displayCryptos=Mostrar cryptos
setting.preferences.noCryptos=No hay cryptos seleccionadas
setting.preferences.addFiat=Añadir moneda nacional
setting.preferences.addTraditional=Añadir moneda nacional
setting.preferences.addCrypto=Añadir crypto
setting.preferences.displayOptions=Mostrar opciones
setting.preferences.showOwnOffers=Mostrar mis propias ofertas en el libro de ofertas

View File

@ -190,7 +190,7 @@ shared.makerTxFee=سفارش گذار: {0}
shared.takerTxFee=پذیرنده سفارش: {0}
shared.iConfirm=تایید می‌کنم
shared.openURL=باز {0}
shared.traditional=فیات
shared.fiat=فیات
shared.crypto=کریپتو
shared.all=همه
shared.edit=ویرایش
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Ignored peers [onion address:port]
setting.preferences.ignoreDustThreshold=Min. non-dust output value
setting.preferences.currenciesInList=ارزها در لیست قیمت روز بازار
setting.preferences.prefCurrency=ارز مطلوب
setting.preferences.displayFiat=نمایش ارزهای ملی
setting.preferences.noFiat=هیچ ارز ملی انتخاب نشده است
setting.preferences.displayTraditional=نمایش ارزهای ملی
setting.preferences.noTraditional=هیچ ارز ملی انتخاب نشده است
setting.preferences.cannotRemovePrefCurrency=شما نمی‌توانید ارز مطلوب انتخاب شده‌ی خود را حذف کنید
setting.preferences.displayCryptos=نمایش آلت‌کوین‌ها
setting.preferences.noCryptos=هیچ آلتکوینی انتخاب نشده است
setting.preferences.addFiat=افزودن ارز ملی
setting.preferences.addTraditional=افزودن ارز ملی
setting.preferences.addCrypto=افزودن آلتکوین
setting.preferences.displayOptions=نمایش گزینه‌ها
setting.preferences.showOwnOffers=نمایش پیشنهادهای من در دفتر پیشنهاد

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Maker: {0}
shared.takerTxFee=Taker: {0}
shared.iConfirm=Je confirme
shared.openURL=Ouvert {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Crypto
shared.all=Tout
shared.edit=Modifier
@ -996,12 +996,12 @@ setting.preferences.ignorePeers=Pairs ignorés [adresse onion:port]
setting.preferences.ignoreDustThreshold=Valeur de l'output considérée comme "non-dust" minimale
setting.preferences.currenciesInList=Devises disponibles dans le flux de cotation du marché
setting.preferences.prefCurrency=Devise privilégiée
setting.preferences.displayFiat=Afficher les monnaies nationales
setting.preferences.noFiat=Il n'y a pas de devise nationale sélectionnée
setting.preferences.displayTraditional=Afficher les monnaies nationales
setting.preferences.noTraditional=Il n'y a pas de devise nationale sélectionnée
setting.preferences.cannotRemovePrefCurrency=Vous ne pouvez pas enlever la devise choisie pour l'affichage.
setting.preferences.displayCryptos=Afficher les cryptos
setting.preferences.noCryptos=Il n'y a pas d'cryptos sélectionnés
setting.preferences.addFiat=Ajouter une devise nationale
setting.preferences.addTraditional=Ajouter une devise nationale
setting.preferences.addCrypto=Ajouter un crypto
setting.preferences.displayOptions=Afficher les options
setting.preferences.showOwnOffers=Montrer mes ordres dans le livre des ordres

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Maker: {0}
shared.takerTxFee=Taker: {0}
shared.iConfirm=Confermo
shared.openURL=Aperti {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Crypto
shared.all=Tutti
shared.edit=Modifica
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Peer ignorati [indirizzo:porta onion]
setting.preferences.ignoreDustThreshold=Valore minimo di output non-dust
setting.preferences.currenciesInList=Valute nell'elenco dei feed dei prezzi di mercato
setting.preferences.prefCurrency=Valuta preferita
setting.preferences.displayFiat=Mostra valute nazionali
setting.preferences.noFiat=Non ci sono valute nazionali selezionate
setting.preferences.displayTraditional=Mostra valute nazionali
setting.preferences.noTraditional=Non ci sono valute nazionali selezionate
setting.preferences.cannotRemovePrefCurrency=Non è possibile rimuovere la valuta di visualizzazione preferita selezionata
setting.preferences.displayCryptos=Visualizza crypto
setting.preferences.noCryptos=Non ci sono crypto selezionate
setting.preferences.addFiat=Aggiungi valuta nazionale
setting.preferences.addTraditional=Aggiungi valuta nazionale
setting.preferences.addCrypto=Aggiungi crypto
setting.preferences.displayOptions=Mostra opzioni
setting.preferences.showOwnOffers=Mostra le mie offerte nel libro delle offerte

View File

@ -190,7 +190,7 @@ shared.makerTxFee=メイカー: {0}
shared.takerTxFee=テイカー: {0}
shared.iConfirm=確認します
shared.openURL={0} をオープン
shared.traditional=法定通貨
shared.fiat=法定通貨
shared.crypto=暗号通貨
shared.all=全て
shared.edit=編集
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=無視されたピア [onion アドレス:ポー
setting.preferences.ignoreDustThreshold=最小の非ダストアウトプット値
setting.preferences.currenciesInList=市場価格フィードリストの通貨
setting.preferences.prefCurrency=希望する通貨
setting.preferences.displayFiat=各国通貨の表示
setting.preferences.noFiat=各国通貨が選択されていません
setting.preferences.displayTraditional=各国通貨の表示
setting.preferences.noTraditional=各国通貨が選択されていません
setting.preferences.cannotRemovePrefCurrency=選択した希望の表示通貨は削除できません
setting.preferences.displayCryptos=アルトコインの表示
setting.preferences.noCryptos=選択されたアルトコインがありません
setting.preferences.addFiat=各国通貨を追加する
setting.preferences.addTraditional=各国通貨を追加する
setting.preferences.addCrypto=アルトコインを追加する
setting.preferences.displayOptions=表示設定
setting.preferences.showOwnOffers=オファーブックに自分のオファーを表示

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Ofertante: {0}
shared.takerTxFee=Aceitador: {0}
shared.iConfirm=Eu confirmo
shared.openURL=Aberto {0}
shared.traditional=Traditional
shared.fiat=Fiat
shared.crypto=Cripto
shared.all=Todos
shared.edit=Editar
@ -998,12 +998,12 @@ setting.preferences.ignorePeers=Pares ignorados [endereço onion:porta]
setting.preferences.ignoreDustThreshold=Mín. valor de output não-poeira
setting.preferences.currenciesInList=Moedas na lista de preços de mercado
setting.preferences.prefCurrency=Moeda de preferência
setting.preferences.displayFiat=Exibir moedas nacionais
setting.preferences.noFiat=Não há moedas nacionais selecionadas
setting.preferences.displayTraditional=Exibir moedas nacionais
setting.preferences.noTraditional=Não há moedas nacionais selecionadas
setting.preferences.cannotRemovePrefCurrency=Você não pode remover a moeda preferencial de exibição selecionada
setting.preferences.displayCryptos=Exibir cryptos
setting.preferences.noCryptos=Não há cryptos selecionadas
setting.preferences.addFiat=Adicionar moeda nacional
setting.preferences.addTraditional=Adicionar moeda nacional
setting.preferences.addCrypto=Adicionar crypto
setting.preferences.displayOptions=Opções de exibição
setting.preferences.showOwnOffers=Exibir minhas ofertas no livro de ofertas

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Ofertante: {0}
shared.takerTxFee=Aceitador: {0}
shared.iConfirm=Eu confirmo
shared.openURL=Abrir {0}
shared.traditional=Moeda fiduciária
shared.fiat=Moeda fiduciária
shared.crypto=Cripto
shared.all=Tudo
shared.edit=Editar
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Pares ignorados [endereço onion:porta]
setting.preferences.ignoreDustThreshold=Mín. valor de output não-poeira
setting.preferences.currenciesInList=Moedas na lista de feed de preço de mercado
setting.preferences.prefCurrency=Moeda preferrida
setting.preferences.displayFiat=Mostrar moedas nacionais
setting.preferences.noFiat=Não há moedas nacionais selecionadas
setting.preferences.displayTraditional=Mostrar moedas nacionais
setting.preferences.noTraditional=Não há moedas nacionais selecionadas
setting.preferences.cannotRemovePrefCurrency=Você não pode remover a moeda preferida de exibição selecionada
setting.preferences.displayCryptos=Mostrar cryptos
setting.preferences.noCryptos=Não há cryptos selecionadas
setting.preferences.addFiat=Adicionar moeda nacional
setting.preferences.addTraditional=Adicionar moeda nacional
setting.preferences.addCrypto=Adicionar crypto
setting.preferences.displayOptions=Mostrar opções
setting.preferences.showOwnOffers=Mostrar as minhas próprias ofertas no livro de ofertas

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Мейкер: {0}
shared.takerTxFee=Тейкер: {0}
shared.iConfirm=Подтверждаю
shared.openURL=Открыть {0}
shared.traditional=Нац. валюта
shared.fiat=Нац. валюта
shared.crypto=Криптовалюта
shared.all=Все
shared.edit=Редактировать
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Игнорируемые пиры [onion-адр
setting.preferences.ignoreDustThreshold=Мин. значение, не являющееся «пылью»
setting.preferences.currenciesInList=Валюты в перечне источника рыночного курса
setting.preferences.prefCurrency=Предпочитаемая валюта
setting.preferences.displayFiat=Показать нац. валюты
setting.preferences.noFiat=Национальные валюты не выбраны
setting.preferences.displayTraditional=Показать нац. валюты
setting.preferences.noTraditional=Национальные валюты не выбраны
setting.preferences.cannotRemovePrefCurrency=Нельзя удалить выбранную предпочитаемую валюту
setting.preferences.displayCryptos=Показать альткойны
setting.preferences.noCryptos=Альткойны не выбраны
setting.preferences.addFiat=Добавить национальную валюту
setting.preferences.addTraditional=Добавить национальную валюту
setting.preferences.addCrypto=Добавить альткойн
setting.preferences.displayOptions=Параметры отображения
setting.preferences.showOwnOffers=Показать мои предложения в списке предложений

View File

@ -190,7 +190,7 @@ shared.makerTxFee=ผู้ทำ: {0}
shared.takerTxFee=ผู้รับ: {0}
shared.iConfirm=ฉันยืนยัน
shared.openURL=เปิด {0}
shared.traditional=คำสั่ง
shared.fiat=คำสั่ง
shared.crypto=คริปโต
shared.all=ทั้งหมด
shared.edit=แก้ไข
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=Ignored peers [onion address:port]
setting.preferences.ignoreDustThreshold=Min. non-dust output value
setting.preferences.currenciesInList=สกุลเงินอยู่ในหน้ารายการราคาตลาด
setting.preferences.prefCurrency=สกุลเงินที่ต้องการ
setting.preferences.displayFiat=แสดงสกุลเงินของประเทศ
setting.preferences.noFiat=ไม่มีสกุลเงินประจำชาติที่เลือกไว้
setting.preferences.displayTraditional=แสดงสกุลเงินของประเทศ
setting.preferences.noTraditional=ไม่มีสกุลเงินประจำชาติที่เลือกไว้
setting.preferences.cannotRemovePrefCurrency=คุณไม่สามารถลบสกุลเงินในการแสดงผลที่เลือกไว้ได้
setting.preferences.displayCryptos=แสดง cryptos
setting.preferences.noCryptos=ไม่มี cryptos ที่เลือก
setting.preferences.addFiat=เพิ่มสกุลเงินประจำชาติ
setting.preferences.addTraditional=เพิ่มสกุลเงินประจำชาติ
setting.preferences.addCrypto=เพิ่ม crypto
setting.preferences.displayOptions=แสดงตัวเลือกเพิ่มเติม
setting.preferences.showOwnOffers=แสดงข้อเสนอของฉันเองในสมุดข้อเสนอ

View File

@ -190,7 +190,7 @@ shared.makerTxFee=Người tạo: {0}
shared.takerTxFee=Người nhận: {0}
shared.iConfirm=Tôi xác nhận
shared.openURL=Mở {0}
shared.traditional=Tiền pháp định
shared.fiat=Tiền pháp định
shared.crypto=Tiền mã hóa
shared.all=Tất cả
shared.edit=Chỉnh sửa
@ -997,12 +997,12 @@ setting.preferences.ignorePeers=Bỏ qua đối tác[địa chỉ onion:cổng]
setting.preferences.ignoreDustThreshold=Giá trị đầu ra tối thiểu không phải số dư nhỏ
setting.preferences.currenciesInList=Tiền tệ trong danh sách cung cấp giá thị trường
setting.preferences.prefCurrency=Tiền tệ ưu tiên
setting.preferences.displayFiat=Hiển thị tiền tệ các nước
setting.preferences.noFiat=Không có tiền tệ nước nào được chọn
setting.preferences.displayTraditional=Hiển thị tiền tệ các nước
setting.preferences.noTraditional=Không có tiền tệ nước nào được chọn
setting.preferences.cannotRemovePrefCurrency=Bạn không thể gỡ bỏ tiền tệ ưu tiên được chọn
setting.preferences.displayCryptos=Hiển thị crypto
setting.preferences.noCryptos=Không có crypto nào được chọn
setting.preferences.addFiat=Bổ sung tiền tệ các nước
setting.preferences.addTraditional=Bổ sung tiền tệ các nước
setting.preferences.addCrypto=Bổ sung crypto
setting.preferences.displayOptions=Hiển thị các phương án
setting.preferences.showOwnOffers=Hiển thị Báo giá của tôi trong danh mục Báo giá

View File

@ -190,7 +190,7 @@ shared.makerTxFee=卖家:{0}
shared.takerTxFee=买家:{0}
shared.iConfirm=我确认
shared.openURL=打开 {0}
shared.traditional=法定货币
shared.fiat=法定货币
shared.crypto=加密
shared.all=全部
shared.edit=编辑
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=忽略节点 [洋葱地址:端口]
setting.preferences.ignoreDustThreshold=最小无零头输出值
setting.preferences.currenciesInList=市场价的货币列表
setting.preferences.prefCurrency=首选货币
setting.preferences.displayFiat=显示国家货币
setting.preferences.noFiat=没有选定国家货币
setting.preferences.displayTraditional=显示国家货币
setting.preferences.noTraditional=没有选定国家货币
setting.preferences.cannotRemovePrefCurrency=您不能删除您选定的首选货币
setting.preferences.displayCryptos=显示数字货币
setting.preferences.noCryptos=没有选定数字货币
setting.preferences.addFiat=添加法定货币
setting.preferences.addTraditional=添加法定货币
setting.preferences.addCrypto=添加数字货币
setting.preferences.displayOptions=显示选项
setting.preferences.showOwnOffers=在报价列表中显示我的报价

View File

@ -190,7 +190,7 @@ shared.makerTxFee=賣家:{0}
shared.takerTxFee=買家:{0}
shared.iConfirm=我確認
shared.openURL=打開 {0}
shared.traditional=法定貨幣
shared.fiat=法定貨幣
shared.crypto=加密
shared.all=全部
shared.edit=編輯
@ -995,12 +995,12 @@ setting.preferences.ignorePeers=忽略節點 [洋葱地址:端口]
setting.preferences.ignoreDustThreshold=最小無零頭輸出值
setting.preferences.currenciesInList=市場價的貨幣列表
setting.preferences.prefCurrency=首選貨幣
setting.preferences.displayFiat=顯示國家貨幣
setting.preferences.noFiat=沒有選定國家貨幣
setting.preferences.displayTraditional=顯示國家貨幣
setting.preferences.noTraditional=沒有選定國家貨幣
setting.preferences.cannotRemovePrefCurrency=您不能刪除您選定的首選貨幣
setting.preferences.displayCryptos=顯示數字貨幣
setting.preferences.noCryptos=沒有選定數字貨幣
setting.preferences.addFiat=添加法定貨幣
setting.preferences.addTraditional=添加法定貨幣
setting.preferences.addCrypto=添加數字貨幣
setting.preferences.displayOptions=顯示選項
setting.preferences.showOwnOffers=在報價列表中顯示我的報價

View File

@ -574,9 +574,9 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
final boolean isBuy = dataModel.getDirection() == OfferDirection.BUY;
boolean isFiatCurrency = CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode());
boolean isTraditionalCurrency = CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode());
if (isFiatCurrency) {
if (isTraditionalCurrency) {
amountDescription = Res.get("createOffer.amountPriceBox.amountDescription",
isBuy ? Res.get("shared.buy") : Res.get("shared.sell"));
} else {

View File

@ -33,7 +33,7 @@ import haveno.desktop.common.view.View;
import haveno.desktop.common.view.ViewLoader;
import haveno.desktop.main.MainView;
import haveno.desktop.main.offer.createoffer.CreateOfferView;
import haveno.desktop.main.offer.offerbook.BtcOfferBookView;
import haveno.desktop.main.offer.offerbook.XmrOfferBookView;
import haveno.desktop.main.offer.offerbook.OfferBookView;
import haveno.desktop.main.offer.offerbook.OtherOfferBookView;
import haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView;
@ -50,9 +50,9 @@ import java.util.Optional;
public abstract class OfferView extends ActivatableView<TabPane, Void> {
private OfferBookView<?, ?> btcOfferBookView, topCryptoOfferBookView, otherOfferBookView;
private OfferBookView<?, ?> xmrOfferBookView, topCryptoOfferBookView, otherOfferBookView;
private Tab btcOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab;
private Tab xmrOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab;
private final ViewLoader viewLoader;
private final Navigation navigation;
@ -95,11 +95,11 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
tabChangeListener = (observableValue, oldValue, newValue) -> {
UserThread.execute(() -> {
if (newValue != null) {
if (newValue.equals(btcOfferBookTab)) {
if (btcOfferBookView != null) {
btcOfferBookView.onTabSelected(true);
if (newValue.equals(xmrOfferBookTab)) {
if (xmrOfferBookView != null) {
xmrOfferBookView.onTabSelected(true);
} else {
loadView(BtcOfferBookView.class, null, null);
loadView(XmrOfferBookView.class, null, null);
}
} else if (newValue.equals(topCryptoOfferBookTab)) {
if (topCryptoOfferBookView != null) {
@ -116,8 +116,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
}
}
if (oldValue != null) {
if (oldValue.equals(btcOfferBookTab) && btcOfferBookView != null) {
btcOfferBookView.onTabSelected(false);
if (oldValue.equals(xmrOfferBookTab) && xmrOfferBookView != null) {
xmrOfferBookView.onTabSelected(false);
} else if (oldValue.equals(topCryptoOfferBookTab) && topCryptoOfferBookView != null) {
topCryptoOfferBookView.onTabSelected(false);
} else if (oldValue.equals(otherOfferBookTab) && otherOfferBookView != null) {
@ -154,14 +154,14 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
navigation.addListener(navigationListener);
if (btcOfferBookView == null) {
navigation.navigateTo(MainView.class, this.getClass(), BtcOfferBookView.class);
if (xmrOfferBookView == null) {
navigation.navigateTo(MainView.class, this.getClass(), XmrOfferBookView.class);
}
GUIUtil.updateTopCrypto(preferences);
if (topCryptoOfferBookTab != null) {
topCryptoOfferBookTab.setText(GUIUtil.TOP_CRYPTO.getCode());
topCryptoOfferBookTab.setText(GUIUtil.TOP_CRYPTO.getName().toUpperCase());
}
}
@ -179,15 +179,15 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
if (OfferBookView.class.isAssignableFrom(viewClass)) {
if (viewClass == BtcOfferBookView.class && btcOfferBookTab != null && btcOfferBookView != null) {
if (viewClass == XmrOfferBookView.class && xmrOfferBookTab != null && xmrOfferBookView != null) {
if (childViewClass == null) {
btcOfferBookTab.setContent(btcOfferBookView.getRoot());
xmrOfferBookTab.setContent(xmrOfferBookView.getRoot());
} else if (childViewClass == TakeOfferView.class) {
loadTakeViewClass(viewClass, childViewClass, btcOfferBookTab);
loadTakeViewClass(viewClass, childViewClass, xmrOfferBookTab);
} else {
loadCreateViewClass(btcOfferBookView, viewClass, childViewClass, btcOfferBookTab, (PaymentMethod) data);
loadCreateViewClass(xmrOfferBookView, viewClass, childViewClass, xmrOfferBookTab, (PaymentMethod) data);
}
tabPane.getSelectionModel().select(btcOfferBookTab);
tabPane.getSelectionModel().select(xmrOfferBookTab);
} else if (viewClass == TopCryptoOfferBookView.class && topCryptoOfferBookTab != null && topCryptoOfferBookView != null) {
if (childViewClass == null) {
topCryptoOfferBookTab.setContent(topCryptoOfferBookView.getRoot());
@ -215,23 +215,23 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
}
tabPane.getSelectionModel().select(otherOfferBookTab);
} else {
if (btcOfferBookTab == null) {
btcOfferBookTab = new Tab(Res.getBaseCurrencyName().toUpperCase());
btcOfferBookTab.setClosable(false);
topCryptoOfferBookTab = new Tab(GUIUtil.TOP_CRYPTO.getCode());
if (xmrOfferBookTab == null) {
xmrOfferBookTab = new Tab(Res.getBaseCurrencyName().toUpperCase());
xmrOfferBookTab.setClosable(false);
topCryptoOfferBookTab = new Tab(GUIUtil.TOP_CRYPTO.getName().toUpperCase());
topCryptoOfferBookTab.setClosable(false);
otherOfferBookTab = new Tab(Res.get("shared.other").toUpperCase());
otherOfferBookTab.setClosable(false);
tabPane.getTabs().addAll(btcOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab);
tabPane.getTabs().addAll(xmrOfferBookTab, topCryptoOfferBookTab, otherOfferBookTab);
}
if (viewClass == BtcOfferBookView.class) {
btcOfferBookView = (BtcOfferBookView) viewLoader.load(BtcOfferBookView.class);
btcOfferBookView.setOfferActionHandler(offerActionHandler);
btcOfferBookView.setDirection(direction);
btcOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(btcOfferBookTab);
btcOfferBookTab.setContent(btcOfferBookView.getRoot());
if (viewClass == XmrOfferBookView.class) {
xmrOfferBookView = (XmrOfferBookView) viewLoader.load(XmrOfferBookView.class);
xmrOfferBookView.setOfferActionHandler(offerActionHandler);
xmrOfferBookView.setDirection(direction);
xmrOfferBookView.onTabSelected(true);
tabPane.getSelectionModel().select(xmrOfferBookTab);
xmrOfferBookTab.setContent(xmrOfferBookView.getRoot());
} else if (viewClass == TopCryptoOfferBookView.class) {
topCryptoOfferBookView = (TopCryptoOfferBookView) viewLoader.load(TopCryptoOfferBookView.class);
topCryptoOfferBookView.setOfferActionHandler(offerActionHandler);
@ -323,8 +323,8 @@ public abstract class OfferView extends ActivatableView<TabPane, Void> {
@NotNull
private Class<? extends OfferBookView<?, ?>> getOfferBookViewClassFor(String currencyCode) {
Class<? extends OfferBookView<?, ?>> offerBookViewClass;
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
offerBookViewClass = BtcOfferBookView.class;
if (CurrencyUtil.isFiatCurrency(currencyCode)) {
offerBookViewClass = XmrOfferBookView.class;
} else if (currencyCode.equals(GUIUtil.TOP_CRYPTO.getCode())) {
offerBookViewClass = TopCryptoOfferBookView.class;
} else {

View File

@ -30,7 +30,7 @@ import haveno.desktop.Navigation;
import haveno.desktop.components.AutoTooltipButton;
import haveno.desktop.components.AutoTooltipLabel;
import haveno.desktop.components.HyperlinkWithIcon;
import haveno.desktop.main.offer.offerbook.BtcOfferBookView;
import haveno.desktop.main.offer.offerbook.XmrOfferBookView;
import haveno.desktop.main.offer.offerbook.OfferBookView;
import haveno.desktop.main.offer.offerbook.OtherOfferBookView;
import haveno.desktop.main.offer.offerbook.TopCryptoOfferBookView;
@ -127,7 +127,7 @@ public class OfferViewUtil {
public static Class<? extends OfferBookView<?, ?>> getOfferBookViewClass(String currencyCode) {
Class<? extends OfferBookView<?, ?>> offerBookViewClazz;
if (CurrencyUtil.isTraditionalCurrency(currencyCode)) {
offerBookViewClazz = BtcOfferBookView.class;
offerBookViewClazz = XmrOfferBookView.class;
} else if (currencyCode.equals(GUIUtil.TOP_CRYPTO.getCode())) {
offerBookViewClazz = TopCryptoOfferBookView.class;
} else {

View File

@ -55,7 +55,7 @@ public class CreateOfferView extends MutableOfferView<CreateOfferViewModel> {
TradeCurrency tradeCurrency,
OfferView.OfferActionHandler offerActionHandler) {
// Invert direction for non-Fiat trade currencies -> BUY BSQ is to SELL Bitcoin
OfferDirection offerDirection = CurrencyUtil.isTraditionalCurrency(tradeCurrency.getCode()) ? direction :
OfferDirection offerDirection = CurrencyUtil.isFiatCurrency(tradeCurrency.getCode()) ? direction :
direction == OfferDirection.BUY ? OfferDirection.SELL : OfferDirection.BUY;
super.initWithData(offerDirection, tradeCurrency, offerActionHandler);
}
@ -66,11 +66,10 @@ public class CreateOfferView extends MutableOfferView<CreateOfferViewModel> {
paymentAccounts.stream().filter(paymentAccount -> {
if (model.getTradeCurrency().equals(GUIUtil.TOP_CRYPTO)) {
return Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO);
} else if (CurrencyUtil.isTraditionalCurrency(model.getTradeCurrency().getCode())) {
return !paymentAccount.getPaymentMethod().isCrypto();
} else if (CurrencyUtil.isFiatCurrency(model.getTradeCurrency().getCode())) {
return paymentAccount.isFiat();
} else {
return paymentAccount.getPaymentMethod().isCrypto() &&
!Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO);
return !paymentAccount.isFiat() && !Objects.equals(paymentAccount.getSingleTradeCurrency(), GUIUtil.TOP_CRYPTO);
}
}).collect(Collectors.toList()));
}

View File

@ -24,6 +24,7 @@ import haveno.core.locale.CryptoCurrency;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.GlobalSettings;
import haveno.core.locale.TradeCurrency;
import haveno.core.locale.TraditionalCurrency;
import haveno.core.offer.Offer;
import haveno.core.offer.OfferDirection;
import haveno.core.offer.OfferFilterService;
@ -82,7 +83,14 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
@Override
protected ObservableList<PaymentMethod> filterPaymentMethods(ObservableList<PaymentMethod> list,
TradeCurrency selectedTradeCurrency) {
return FXCollections.observableArrayList(list.stream().filter(PaymentMethod::isBlockchain).collect(Collectors.toList()));
return FXCollections.observableArrayList(list.stream().filter(paymentMethod -> {
if (paymentMethod.isBlockchain()) return true;
if (paymentMethod.getSupportedAssetCodes() == null) return true;
for (String assetCode : paymentMethod.getSupportedAssetCodes()) {
if (!CurrencyUtil.isFiatCurrency(assetCode)) return true;
}
return false;
}).collect(Collectors.toList()));
}
@Override
@ -93,12 +101,18 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
tradeCurrencies.addAll(preferences.getCryptoCurrenciesAsObservable().stream()
.filter(withoutTopCrypto())
.collect(Collectors.toList()));
tradeCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream()
.filter(withoutFiatCurrency())
.collect(Collectors.toList()));
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
allCurrencies.addAll(CurrencyUtil.getAllSortedCryptoCurrencies().stream()
.filter(withoutTopCrypto())
.collect(Collectors.toList()));
allCurrencies.addAll(CurrencyUtil.getMainTraditionalCurrencies().stream()
.filter(withoutFiatCurrency())
.collect(Collectors.toList()));
allCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
}
@ -107,9 +121,9 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
TradeCurrency selectedTradeCurrency) {
return offerBookListItem -> {
Offer offer = offerBookListItem.getOffer();
// BUY Crypto is actually SELL Bitcoin
// BUY Crypto is actually SELL Monero
boolean directionResult = offer.getDirection() == direction;
boolean currencyResult = CurrencyUtil.isCryptoCurrency(offer.getCurrencyCode()) &&
boolean currencyResult = !CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) &&
((showAllTradeCurrenciesProperty.get() &&
!offer.getCurrencyCode().equals(GUIUtil.TOP_CRYPTO.getCode())) ||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode()));
@ -156,4 +170,10 @@ public class OtherOfferBookViewModel extends OfferBookViewModel {
return cryptoCurrency ->
!cryptoCurrency.equals(GUIUtil.TOP_CRYPTO);
}
@NotNull
private Predicate<TraditionalCurrency> withoutFiatCurrency() {
return fiatCurrency ->
!CurrencyUtil.isFiatCurrency(fiatCurrency.getCode());
}
}

View File

@ -19,7 +19,7 @@
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<GridPane fx:id="root" fx:controller="haveno.desktop.main.offer.offerbook.BtcOfferBookView"
<GridPane fx:id="root" fx:controller="haveno.desktop.main.offer.offerbook.XmrOfferBookView"
hgap="5.0" vgap="5"
xmlns:fx="http://javafx.com/fxml">

View File

@ -34,10 +34,10 @@ import javax.inject.Inject;
import javax.inject.Named;
@FxmlView
public class BtcOfferBookView extends OfferBookView<GridPane, BtcOfferBookViewModel> {
public class XmrOfferBookView extends OfferBookView<GridPane, XmrOfferBookViewModel> {
@Inject
BtcOfferBookView(BtcOfferBookViewModel model,
XmrOfferBookView(XmrOfferBookViewModel model,
Navigation navigation,
OfferDetailsWindow offerDetailsWindow,
@Named(FormattingUtils.BTC_FORMATTER_KEY) CoinFormatter formatter,
@ -51,8 +51,8 @@ public class BtcOfferBookView extends OfferBookView<GridPane, BtcOfferBookViewMo
@Override
protected String getMarketTitle() {
return model.getDirection().equals(OfferDirection.BUY) ?
Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.traditional")) :
Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.traditional"));
Res.get("offerbook.availableOffersToBuy", Res.getBaseCurrencyCode(), Res.get("shared.fiat")) :
Res.get("offerbook.availableOffersToSell", Res.getBaseCurrencyCode(), Res.get("shared.fiat"));
}

View File

@ -24,6 +24,7 @@ import haveno.core.locale.CryptoCurrency;
import haveno.core.locale.CurrencyUtil;
import haveno.core.locale.GlobalSettings;
import haveno.core.locale.TradeCurrency;
import haveno.core.locale.TraditionalCurrency;
import haveno.core.offer.Offer;
import haveno.core.offer.OfferDirection;
import haveno.core.offer.OfferFilterService;
@ -49,10 +50,10 @@ import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class BtcOfferBookViewModel extends OfferBookViewModel {
public class XmrOfferBookViewModel extends OfferBookViewModel {
@Inject
public BtcOfferBookViewModel(User user,
public XmrOfferBookViewModel(User user,
OpenOfferManager openOfferManager,
OfferBook offerBook,
Preferences preferences,
@ -97,11 +98,15 @@ public class BtcOfferBookViewModel extends OfferBookViewModel {
ObservableList<TradeCurrency> allCurrencies) {
// Used for ignoring filter (show all)
tradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
tradeCurrencies.addAll(preferences.getTraditionalCurrenciesAsObservable());
tradeCurrencies.addAll(preferences.getTraditionalCurrenciesAsObservable().stream()
.filter(withFiatCurrency())
.collect(Collectors.toList()));
tradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
allCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, ""));
allCurrencies.addAll(CurrencyUtil.getAllSortedTraditionalCurrencies());
allCurrencies.addAll(CurrencyUtil.getAllSortedTraditionalCurrencies().stream()
.filter(withFiatCurrency())
.collect(Collectors.toList()));
allCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, ""));
}
@ -111,7 +116,7 @@ public class BtcOfferBookViewModel extends OfferBookViewModel {
return offerBookListItem -> {
Offer offer = offerBookListItem.getOffer();
boolean directionResult = offer.getDirection() != direction;
boolean currencyResult = (showAllTradeCurrenciesProperty.get() && offer.isTraditionalOffer()) ||
boolean currencyResult = (showAllTradeCurrenciesProperty.get() && offer.isFiatOffer()) ||
offer.getCurrencyCode().equals(selectedTradeCurrency.getCode());
boolean paymentMethodResult = showAllPaymentMethods ||
offer.getPaymentMethod().equals(selectedPaymentMethod);
@ -145,9 +150,14 @@ public class BtcOfferBookViewModel extends OfferBookViewModel {
@Override
String getCurrencyCodeFromPreferences(OfferDirection direction) {
// validate if previous stored currencies are Fiat ones
// validate if previous stored currencies are Traditional ones
String currencyCode = direction == OfferDirection.BUY ? preferences.getBuyScreenCurrencyCode() : preferences.getSellScreenCurrencyCode();
return CurrencyUtil.isTraditionalCurrency(currencyCode) ? currencyCode : null;
}
private Predicate<TraditionalCurrency> withFiatCurrency() {
return fiatCurrency ->
CurrencyUtil.isFiatCurrency(fiatCurrency.getCode());
}
}

View File

@ -332,7 +332,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
FXCollections.emptyObservableMap()));
Tuple3<Label, ListView<TraditionalCurrency>, VBox> traditionalTuple = addTopLabelListView(root, displayCurrenciesGridRowIndex,
Res.get("setting.preferences.displayFiat"));
Res.get("setting.preferences.displayTraditional"));
int listRowSpan = 6;
GridPane.setColumnIndex(traditionalTuple.third, 2);
@ -343,7 +343,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
traditionalCurrenciesListView = traditionalTuple.second;
traditionalCurrenciesListView.setMinHeight(9 * Layout.LIST_ROW_HEIGHT + 2);
traditionalCurrenciesListView.setPrefHeight(10 * Layout.LIST_ROW_HEIGHT + 2);
Label placeholder = new AutoTooltipLabel(Res.get("setting.preferences.noFiat"));
Label placeholder = new AutoTooltipLabel(Res.get("setting.preferences.noTraditional"));
placeholder.setWrapText(true);
traditionalCurrenciesListView.setPlaceholder(placeholder);
traditionalCurrenciesListView.setCellFactory(new Callback<>() {
@ -445,7 +445,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
traditionalCurrenciesComboBox = addComboBox(root, displayCurrenciesGridRowIndex + listRowSpan);
GridPane.setColumnIndex(traditionalCurrenciesComboBox, 2);
GridPane.setValignment(traditionalCurrenciesComboBox, VPos.TOP);
traditionalCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addFiat"));
traditionalCurrenciesComboBox.setPromptText(Res.get("setting.preferences.addTraditional"));
traditionalCurrenciesComboBox.setButtonCell(new ListCell<>() {
@Override
protected void updateItem(final TraditionalCurrency item, boolean empty) {
@ -453,7 +453,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
this.setVisible(item != null || !empty);
if (empty || item == null) {
setText(Res.get("setting.preferences.addFiat"));
setText(Res.get("setting.preferences.addTraditional"));
} else {
setText(item.getNameAndCode());
}

View File

@ -139,7 +139,7 @@ public class GUIUtil {
private static Preferences preferences;
public static TradeCurrency TOP_CRYPTO = CurrencyUtil.getTradeCurrency("ETH").get();
public static TradeCurrency TOP_CRYPTO = CurrencyUtil.getTradeCurrency("BTC").get();
public static void setPreferences(Preferences preferences) {
GUIUtil.preferences = preferences;
@ -509,7 +509,7 @@ public class GUIUtil {
HBox box = new HBox();
box.setSpacing(20);
Label paymentType = new AutoTooltipLabel(
method.isCrypto() ? Res.get("shared.crypto") : Res.get("shared.traditional"));
method.isTraditional() ? Res.get("shared.traditional") : Res.get("shared.crypto"));
paymentType.getStyleClass().add("currency-label-small");
Label paymentMethod = new AutoTooltipLabel(Res.get(id));

View File

@ -241,7 +241,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForAmount.intValue());
}
@ -255,7 +255,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate();
@ -273,7 +273,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate();
@ -292,7 +292,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForVolume.intValue());
}
@ -306,7 +306,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate();
@ -324,7 +324,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate();
@ -343,7 +343,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForPrice.intValue());
}
@ -357,7 +357,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate();
@ -375,7 +375,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
final OfferBookViewModel model = new BtcOfferBookViewModel(null, null, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(null, null, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
assertEquals(0, model.maxPlacesForMarketPriceMargin.intValue());
}
@ -410,7 +410,7 @@ public class OfferBookViewModelTest {
item4.getOffer().setPriceFeedService(priceFeedService);
offerBookListItems.addAll(item1, item2);
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, priceFeedService,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, priceFeedService,
null, null, null, getPriceUtil(), null, coinFormatter, null);
model.activate();
@ -431,7 +431,7 @@ public class OfferBookViewModelTest {
when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);
when(priceFeedService.getMarketPrice(anyString())).thenReturn(new MarketPrice("USD", 12684.0450, Instant.now().getEpochSecond(), true));
final OfferBookViewModel model = new BtcOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
final OfferBookViewModel model = new XmrOfferBookViewModel(user, openOfferManager, offerBook, empty, null, null, null,
null, null, null, getPriceUtil(), null, coinFormatter, null);
final OfferBookListItem item = make(xmrBuyItem.but(