mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Refactor Settings model to 2 separate models
This commit is contained in:
parent
9751a5206e
commit
33085b5c2c
18 changed files with 335 additions and 197 deletions
|
@ -15,7 +15,7 @@
|
|||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.settings;
|
||||
package io.bitsquare.account;
|
||||
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.locale.Country;
|
||||
|
@ -30,26 +30,24 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.OptionalLong;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class Settings implements Serializable {
|
||||
public class AccountSettings implements Serializable {
|
||||
private static final long serialVersionUID = 7995048077355006861L;
|
||||
|
||||
private List<Locale> acceptedLanguageLocales = new ArrayList<>();
|
||||
private List<Country> acceptedCountryLocales = new ArrayList<>();
|
||||
private List<Arbitrator> acceptedArbitrators = new ArrayList<>();
|
||||
|
||||
private Boolean useAnimations = true;
|
||||
// needed for persistence
|
||||
private String btcDenominationString = MonetaryFormat.CODE_BTC;
|
||||
final transient StringProperty btcDenomination = new SimpleStringProperty(MonetaryFormat.CODE_BTC);
|
||||
private Boolean useAnimationsBoolean = true;
|
||||
private Boolean useEffectsBoolean = true;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public Settings() {
|
||||
public AccountSettings() {
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,12 +55,11 @@ public class Settings implements Serializable {
|
|||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void applyPersistedSettings(Settings persistedSettings) {
|
||||
public void applyPersistedAccountSettings(AccountSettings persistedSettings) {
|
||||
if (persistedSettings != null) {
|
||||
acceptedLanguageLocales = persistedSettings.getAcceptedLanguageLocales();
|
||||
acceptedCountryLocales = persistedSettings.getAcceptedCountries();
|
||||
acceptedArbitrators = persistedSettings.getAcceptedArbitrators();
|
||||
setBtcDenomination(persistedSettings.getBtcDenominationString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,30 +115,4 @@ public class Settings implements Serializable {
|
|||
return result.isPresent() ? Coin.valueOf(result.getAsLong()) : Coin.ZERO;
|
||||
}
|
||||
|
||||
public String getBtcDenomination() {
|
||||
return btcDenomination.get();
|
||||
}
|
||||
|
||||
public StringProperty btcDenominationProperty() {
|
||||
return btcDenomination;
|
||||
}
|
||||
|
||||
public void setBtcDenomination(String btcDenomination) {
|
||||
btcDenominationString = btcDenomination;
|
||||
this.btcDenomination.set(btcDenomination);
|
||||
}
|
||||
|
||||
public String getBtcDenominationString() {
|
||||
return btcDenominationString;
|
||||
}
|
||||
|
||||
public Boolean getUseAnimations() {
|
||||
return useAnimations;
|
||||
}
|
||||
|
||||
public void setUseAnimations(boolean useAnimations) {
|
||||
this.useAnimations = useAnimations;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -18,13 +18,14 @@
|
|||
package io.bitsquare.app.gui;
|
||||
|
||||
import io.bitsquare.BitsquareException;
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.SystemTray;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.gui.components.Popups;
|
||||
import io.bitsquare.gui.util.ImageUtil;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
@ -81,14 +82,18 @@ public class BitsquareApp extends Application {
|
|||
// load and apply any stored settings
|
||||
|
||||
User user = injector.getInstance(User.class);
|
||||
Settings settings = injector.getInstance(Settings.class);
|
||||
ApplicationPreferences applicationPreferences = injector.getInstance(ApplicationPreferences.class);
|
||||
AccountSettings accountSettings = injector.getInstance(AccountSettings.class);
|
||||
Persistence persistence = injector.getInstance(Persistence.class);
|
||||
persistence.init();
|
||||
|
||||
User persistedUser = (User) persistence.read(user);
|
||||
user.applyPersistedUser(persistedUser);
|
||||
|
||||
settings.applyPersistedSettings((Settings) persistence.read(settings.getClass().getName()));
|
||||
applicationPreferences.applyPersistedSettings((ApplicationPreferences) persistence
|
||||
.read(applicationPreferences.getClass().getName()));
|
||||
accountSettings.applyPersistedAccountSettings((AccountSettings) persistence
|
||||
.read(accountSettings.getClass().getName()));
|
||||
|
||||
|
||||
// load the main view and create the main scene
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package io.bitsquare.app.gui;
|
||||
|
||||
import io.bitsquare.BitsquareModule;
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.btc.BitcoinModule;
|
||||
import io.bitsquare.crypto.CryptoModule;
|
||||
import io.bitsquare.gui.GuiModule;
|
||||
|
@ -26,7 +27,7 @@ import io.bitsquare.msg.tomp2p.TomP2PMessageModule;
|
|||
import io.bitsquare.offer.OfferModule;
|
||||
import io.bitsquare.offer.tomp2p.TomP2POfferModule;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
import io.bitsquare.trade.TradeModule;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
|
@ -52,7 +53,8 @@ class BitsquareAppModule extends BitsquareModule {
|
|||
@Override
|
||||
protected void configure() {
|
||||
bind(User.class).asEagerSingleton();
|
||||
bind(Settings.class).asEagerSingleton();
|
||||
bind(ApplicationPreferences.class).asEagerSingleton();
|
||||
bind(AccountSettings.class).asEagerSingleton();
|
||||
|
||||
File persistenceDir = new File(env.getRequiredProperty(Persistence.DIR_KEY));
|
||||
bind(File.class).annotatedWith(named(Persistence.DIR_KEY)).toInstance(persistenceDir);
|
||||
|
|
|
@ -22,6 +22,7 @@ import io.bitsquare.gui.components.Popups;
|
|||
import io.bitsquare.gui.main.help.Help;
|
||||
import io.bitsquare.gui.main.trade.offerbook.OfferBook;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.gui.util.validation.BankAccountNumberValidator;
|
||||
import io.bitsquare.gui.util.validation.BtcValidator;
|
||||
import io.bitsquare.gui.util.validation.FiatValidator;
|
||||
|
@ -55,6 +56,7 @@ public class GuiModule extends BitsquareModule {
|
|||
bind(FiatValidator.class).asEagerSingleton();
|
||||
bind(InputValidator.class).asEagerSingleton();
|
||||
bind(PasswordValidator.class).asEagerSingleton();
|
||||
bind(Transitions.class).asEagerSingleton();
|
||||
|
||||
bind(Stage.class).toInstance(primaryStage);
|
||||
Popups.primaryStage = primaryStage;
|
||||
|
|
|
@ -26,7 +26,6 @@ import io.bitsquare.gui.components.Popups;
|
|||
import io.bitsquare.gui.components.SystemNotification;
|
||||
import io.bitsquare.gui.util.Profiler;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
|
||||
import java.net.URL;
|
||||
|
@ -36,7 +35,6 @@ import java.util.ResourceBundle;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
|
@ -58,7 +56,7 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
private final Navigation navigation;
|
||||
private final OverlayManager overlayManager;
|
||||
private final ToggleGroup navButtonsGroup = new ToggleGroup();
|
||||
private final Settings settings;
|
||||
private Transitions transitions;
|
||||
private final String title;
|
||||
|
||||
private BorderPane baseApplicationContainer;
|
||||
|
@ -77,12 +75,13 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
|
||||
@Inject
|
||||
private MainViewCB(MainPM presentationModel, Navigation navigation, OverlayManager overlayManager,
|
||||
TradeManager tradeManager, Settings settings, @Named(TITLE_KEY) String title) {
|
||||
TradeManager tradeManager, Transitions transitions,
|
||||
@Named(TITLE_KEY) String title) {
|
||||
super(presentationModel);
|
||||
|
||||
this.navigation = navigation;
|
||||
this.overlayManager = overlayManager;
|
||||
this.settings = settings;
|
||||
this.transitions = transitions;
|
||||
this.title = title;
|
||||
|
||||
tradeManager.featureNotImplementedWarningProperty().addListener((ov, oldValue, newValue) -> {
|
||||
|
@ -118,14 +117,12 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
overlayManager.addListener(new OverlayManager.OverlayListener() {
|
||||
@Override
|
||||
public void onBlurContentRequested() {
|
||||
if (settings.getUseAnimations())
|
||||
Transitions.blur(baseApplicationContainer);
|
||||
transitions.blur(baseApplicationContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveBlurContentRequested() {
|
||||
if (settings.getUseAnimations())
|
||||
Transitions.removeBlur(baseApplicationContainer);
|
||||
transitions.removeBlur(baseApplicationContainer);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -230,7 +227,7 @@ public class MainViewCB extends ViewCB<MainPM> {
|
|||
|
||||
private void onContentAdded() {
|
||||
Profiler.printMsgWithTime("MainController.onContentAdded");
|
||||
Transitions.fadeOutAndRemove(splashScreen, 1500).setInterpolator(Interpolator.EASE_IN);
|
||||
transitions.fadeOutAndRemove(splashScreen, 1500);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.account.arbitrator.browser;
|
||||
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
|
@ -27,7 +28,6 @@ import io.bitsquare.locale.LanguageUtil;
|
|||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.msg.listeners.ArbitratorListener;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -51,7 +51,7 @@ import org.slf4j.LoggerFactory;
|
|||
public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorListener {
|
||||
private static final Logger log = LoggerFactory.getLogger(ArbitratorBrowserViewCB.class);
|
||||
|
||||
private final Settings settings;
|
||||
private final AccountSettings accountSettings;
|
||||
private final Persistence persistence;
|
||||
private final MessageFacade messageFacade;
|
||||
|
||||
|
@ -68,8 +68,9 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorBrowserViewCB(Settings settings, Persistence persistence, MessageFacade messageFacade) {
|
||||
this.settings = settings;
|
||||
public ArbitratorBrowserViewCB(AccountSettings accountSettings, Persistence persistence,
|
||||
MessageFacade messageFacade) {
|
||||
this.accountSettings = accountSettings;
|
||||
this.persistence = persistence;
|
||||
this.messageFacade = messageFacade;
|
||||
}
|
||||
|
@ -199,8 +200,8 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
|
|||
|
||||
@FXML
|
||||
public void onSelect() {
|
||||
settings.addAcceptedArbitrator(currentArbitrator);
|
||||
persistence.write(settings);
|
||||
accountSettings.addAcceptedArbitrator(currentArbitrator);
|
||||
persistence.write(accountSettings);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
|
@ -21,7 +21,7 @@ import io.bitsquare.arbitrator.Arbitrator;
|
|||
import io.bitsquare.gui.CachedViewCB;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import javafx.scene.control.*;
|
|||
// TODO Arbitration is very basic yet
|
||||
public class ArbitratorProfileViewCB extends CachedViewCB {
|
||||
|
||||
private final Settings settings;
|
||||
private final ApplicationPreferences settings;
|
||||
|
||||
private final Persistence persistence;
|
||||
private final BSFormatter formatter;
|
||||
|
@ -53,7 +53,7 @@ public class ArbitratorProfileViewCB extends CachedViewCB {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public ArbitratorProfileViewCB(Settings settings, Persistence persistence, BSFormatter formatter) {
|
||||
public ArbitratorProfileViewCB(ApplicationPreferences settings, Persistence persistence, BSFormatter formatter) {
|
||||
this.settings = settings;
|
||||
this.persistence = persistence;
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.account.content.fiat;
|
||||
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.bank.BankAccountType;
|
||||
import io.bitsquare.gui.UIModel;
|
||||
|
@ -25,7 +26,6 @@ import io.bitsquare.locale.CountryUtil;
|
|||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.locale.Region;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
@ -48,7 +48,7 @@ class FiatAccountModel extends UIModel {
|
|||
private static final Logger log = LoggerFactory.getLogger(FiatAccountModel.class);
|
||||
|
||||
private final User user;
|
||||
private final Settings settings;
|
||||
private final AccountSettings accountSettings;
|
||||
private final Persistence persistence;
|
||||
|
||||
final StringProperty title = new SimpleStringProperty();
|
||||
|
@ -75,10 +75,10 @@ class FiatAccountModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
FiatAccountModel(User user, Persistence persistence, Settings settings) {
|
||||
FiatAccountModel(User user, Persistence persistence, AccountSettings accountSettings) {
|
||||
this.persistence = persistence;
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
this.accountSettings = accountSettings;
|
||||
}
|
||||
|
||||
|
||||
|
@ -127,7 +127,7 @@ class FiatAccountModel extends UIModel {
|
|||
user.setBankAccount(bankAccount);
|
||||
saveUser();
|
||||
allBankAccounts.setAll(user.getBankAccounts());
|
||||
countryNotInAcceptedCountriesList.set(!settings.getAcceptedCountries().contains(country.get()));
|
||||
countryNotInAcceptedCountriesList.set(!accountSettings.getAcceptedCountries().contains(country.get()));
|
||||
reset();
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class FiatAccountModel extends UIModel {
|
|||
// We ask the user if he likes to add his own bank account country to the accepted country list if he has not
|
||||
// already added it before
|
||||
void addCountryToAcceptedCountriesList() {
|
||||
settings.addAcceptedCountry(country.get());
|
||||
accountSettings.addAcceptedCountry(country.get());
|
||||
saveSettings();
|
||||
countryNotInAcceptedCountriesList.set(false);
|
||||
}
|
||||
|
@ -225,6 +225,6 @@ class FiatAccountModel extends UIModel {
|
|||
}
|
||||
|
||||
private void saveSettings() {
|
||||
persistence.write(settings);
|
||||
persistence.write(accountSettings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.account.content.irc;
|
||||
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.arbitrator.Reputation;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
|
@ -29,7 +30,6 @@ import io.bitsquare.locale.LanguageUtil;
|
|||
import io.bitsquare.locale.Region;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
|
@ -58,7 +58,7 @@ class IrcAccountModel extends UIModel {
|
|||
private static final Logger log = LoggerFactory.getLogger(IrcAccountModel.class);
|
||||
|
||||
private final User user;
|
||||
private final Settings settings;
|
||||
private final AccountSettings accountSettings;
|
||||
private final MessageFacade messageFacade;
|
||||
private final Persistence persistence;
|
||||
|
||||
|
@ -78,10 +78,10 @@ class IrcAccountModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
IrcAccountModel(User user, Persistence persistence, Settings settings, MessageFacade messageFacade) {
|
||||
IrcAccountModel(User user, Persistence persistence, AccountSettings accountSettings, MessageFacade messageFacade) {
|
||||
this.persistence = persistence;
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
this.accountSettings = accountSettings;
|
||||
this.messageFacade = messageFacade;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ class IrcAccountModel extends UIModel {
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
if (settings.getAcceptedArbitrators().isEmpty())
|
||||
if (accountSettings.getAcceptedArbitrators().isEmpty())
|
||||
addMockArbitrator();
|
||||
}
|
||||
|
||||
|
@ -175,11 +175,11 @@ class IrcAccountModel extends UIModel {
|
|||
}
|
||||
|
||||
private void saveSettings() {
|
||||
persistence.write(settings);
|
||||
persistence.write(accountSettings);
|
||||
}
|
||||
|
||||
private void addMockArbitrator() {
|
||||
if (settings.getAcceptedArbitrators().isEmpty() && user.getMessageKeyPair() != null) {
|
||||
if (accountSettings.getAcceptedArbitrators().isEmpty() && user.getMessageKeyPair() != null) {
|
||||
String pubKeyAsHex = Utils.HEX.encode(new ECKey().getPubKey());
|
||||
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
|
||||
List<Locale> languages = new ArrayList<>();
|
||||
|
@ -202,8 +202,8 @@ class IrcAccountModel extends UIModel {
|
|||
"http://bitsquare.io/",
|
||||
"Bla bla...");
|
||||
|
||||
settings.addAcceptedArbitrator(arbitrator);
|
||||
persistence.write(settings);
|
||||
accountSettings.addAcceptedArbitrator(arbitrator);
|
||||
persistence.write(accountSettings);
|
||||
|
||||
messageFacade.addArbitrator(arbitrator);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.account.content.restrictions;
|
||||
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.arbitrator.Reputation;
|
||||
import io.bitsquare.gui.UIModel;
|
||||
|
@ -26,7 +27,6 @@ import io.bitsquare.locale.LanguageUtil;
|
|||
import io.bitsquare.locale.Region;
|
||||
import io.bitsquare.msg.MessageFacade;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.user.User;
|
||||
import io.bitsquare.util.DSAKeyUtil;
|
||||
|
||||
|
@ -50,7 +50,7 @@ class RestrictionsModel extends UIModel {
|
|||
private static final Logger log = LoggerFactory.getLogger(RestrictionsModel.class);
|
||||
|
||||
private final User user;
|
||||
private final Settings settings;
|
||||
private final AccountSettings accountSettings;
|
||||
private final Persistence persistence;
|
||||
private final MessageFacade messageFacade;
|
||||
|
||||
|
@ -67,9 +67,10 @@ class RestrictionsModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private RestrictionsModel(User user, Settings settings, Persistence persistence, MessageFacade messageFacade) {
|
||||
private RestrictionsModel(User user, AccountSettings accountSettings, Persistence persistence,
|
||||
MessageFacade messageFacade) {
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
this.accountSettings = accountSettings;
|
||||
this.persistence = persistence;
|
||||
this.messageFacade = messageFacade;
|
||||
}
|
||||
|
@ -83,9 +84,9 @@ class RestrictionsModel extends UIModel {
|
|||
public void initialize() {
|
||||
super.initialize();
|
||||
|
||||
Settings persistedSettings = (Settings) persistence.read(settings);
|
||||
if (persistedSettings != null) {
|
||||
settings.applyPersistedSettings(persistedSettings);
|
||||
AccountSettings persistedAccountSettings = (AccountSettings) persistence.read(accountSettings);
|
||||
if (persistedAccountSettings != null) {
|
||||
accountSettings.applyPersistedAccountSettings(persistedAccountSettings);
|
||||
}
|
||||
else {
|
||||
if (Locale.getDefault() != null) {
|
||||
|
@ -103,9 +104,9 @@ class RestrictionsModel extends UIModel {
|
|||
@Override
|
||||
public void activate() {
|
||||
super.activate();
|
||||
languageList.setAll(settings.getAcceptedLanguageLocales());
|
||||
countryList.setAll(settings.getAcceptedCountries());
|
||||
arbitratorList.setAll(settings.getAcceptedArbitrators());
|
||||
languageList.setAll(accountSettings.getAcceptedLanguageLocales());
|
||||
countryList.setAll(accountSettings.getAcceptedCountries());
|
||||
arbitratorList.setAll(accountSettings.getAcceptedArbitrators());
|
||||
}
|
||||
|
||||
@SuppressWarnings("EmptyMethod")
|
||||
|
@ -131,26 +132,26 @@ class RestrictionsModel extends UIModel {
|
|||
}
|
||||
|
||||
void updateArbitratorList() {
|
||||
arbitratorList.setAll(settings.getAcceptedArbitrators());
|
||||
arbitratorList.setAll(accountSettings.getAcceptedArbitrators());
|
||||
}
|
||||
|
||||
void addLanguage(Locale locale) {
|
||||
if (locale != null && !languageList.contains(locale)) {
|
||||
languageList.add(locale);
|
||||
settings.addAcceptedLanguageLocale(locale);
|
||||
accountSettings.addAcceptedLanguageLocale(locale);
|
||||
}
|
||||
}
|
||||
|
||||
void removeLanguage(Locale locale) {
|
||||
languageList.remove(locale);
|
||||
settings.removeAcceptedLanguageLocale(locale);
|
||||
accountSettings.removeAcceptedLanguageLocale(locale);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void addCountry(Country country) {
|
||||
if (!countryList.contains(country) && country != null) {
|
||||
countryList.add(country);
|
||||
settings.addAcceptedCountry(country);
|
||||
accountSettings.addAcceptedCountry(country);
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
|
@ -158,21 +159,21 @@ class RestrictionsModel extends UIModel {
|
|||
ObservableList<Country> getListWithAllEuroCountries() {
|
||||
// TODO use Set instead of List
|
||||
// In addAcceptedCountry there is a check to no add duplicates, so it works correctly for now
|
||||
CountryUtil.getAllEuroCountries().stream().forEach(settings::addAcceptedCountry);
|
||||
countryList.setAll(settings.getAcceptedCountries());
|
||||
CountryUtil.getAllEuroCountries().stream().forEach(accountSettings::addAcceptedCountry);
|
||||
countryList.setAll(accountSettings.getAcceptedCountries());
|
||||
saveSettings();
|
||||
return countryList;
|
||||
}
|
||||
|
||||
void removeCountry(Country country) {
|
||||
countryList.remove(country);
|
||||
settings.removeAcceptedCountry(country);
|
||||
accountSettings.removeAcceptedCountry(country);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void removeArbitrator(Arbitrator arbitrator) {
|
||||
arbitratorList.remove(arbitrator);
|
||||
settings.removeAcceptedArbitrator(arbitrator);
|
||||
accountSettings.removeAcceptedArbitrator(arbitrator);
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
@ -182,12 +183,12 @@ class RestrictionsModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void saveSettings() {
|
||||
persistence.write(settings);
|
||||
persistence.write(accountSettings);
|
||||
}
|
||||
|
||||
// TODO Remove mock later
|
||||
private void addMockArbitrator() {
|
||||
if (settings.getAcceptedArbitrators().isEmpty() && user.getMessageKeyPair() != null) {
|
||||
if (accountSettings.getAcceptedArbitrators().isEmpty() && user.getMessageKeyPair() != null) {
|
||||
String pubKeyAsHex = Utils.HEX.encode(new ECKey().getPubKey());
|
||||
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
|
||||
List<Locale> languages = new ArrayList<>();
|
||||
|
@ -211,8 +212,8 @@ class RestrictionsModel extends UIModel {
|
|||
"Bla bla...");
|
||||
|
||||
arbitratorList.add(arbitrator);
|
||||
settings.addAcceptedArbitrator(arbitrator);
|
||||
persistence.write(settings);
|
||||
accountSettings.addAcceptedArbitrator(arbitrator);
|
||||
persistence.write(accountSettings);
|
||||
|
||||
messageFacade.addArbitrator(arbitrator);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import io.bitsquare.gui.CachedViewCB;
|
|||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.ViewCB;
|
||||
import io.bitsquare.gui.ViewLoader;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class PreferencesViewCB extends CachedViewCB {
|
|||
private static final Logger log = LoggerFactory.getLogger(PreferencesViewCB.class);
|
||||
|
||||
private final Navigation navigation;
|
||||
private Settings settings;
|
||||
private ApplicationPreferences settings;
|
||||
|
||||
private Navigation.Listener navigationListener;
|
||||
private ChangeListener<Tab> tabChangeListener;
|
||||
|
@ -55,7 +55,7 @@ public class PreferencesViewCB extends CachedViewCB {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
PreferencesViewCB(Navigation navigation, Settings settings) {
|
||||
PreferencesViewCB(Navigation navigation, ApplicationPreferences settings) {
|
||||
super();
|
||||
|
||||
this.navigation = navigation;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.gui.main.trade.createoffer;
|
||||
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.arbitrator.Arbitrator;
|
||||
import io.bitsquare.bank.BankAccount;
|
||||
import io.bitsquare.btc.AddressEntry;
|
||||
|
@ -28,7 +29,7 @@ import io.bitsquare.gui.util.BSFormatter;
|
|||
import io.bitsquare.locale.Country;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
|
@ -68,7 +69,8 @@ class CreateOfferModel extends UIModel {
|
|||
|
||||
private final TradeManager tradeManager;
|
||||
private final WalletFacade walletFacade;
|
||||
private final Settings settings;
|
||||
private final AccountSettings accountSettings;
|
||||
private ApplicationPreferences applicationPreferences;
|
||||
private final User user;
|
||||
private final Persistence persistence;
|
||||
private final BSFormatter formatter;
|
||||
|
@ -110,11 +112,13 @@ class CreateOfferModel extends UIModel {
|
|||
|
||||
// non private for testing
|
||||
@Inject
|
||||
public CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, User user,
|
||||
Persistence persistence, BSFormatter formatter) {
|
||||
public CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, AccountSettings accountSettings,
|
||||
ApplicationPreferences applicationPreferences, User user, Persistence persistence,
|
||||
BSFormatter formatter) {
|
||||
this.tradeManager = tradeManager;
|
||||
this.walletFacade = walletFacade;
|
||||
this.settings = settings;
|
||||
this.accountSettings = accountSettings;
|
||||
this.applicationPreferences = applicationPreferences;
|
||||
this.user = user;
|
||||
this.persistence = persistence;
|
||||
this.formatter = formatter;
|
||||
|
@ -151,12 +155,12 @@ class CreateOfferModel extends UIModel {
|
|||
applyBankAccount(user.getCurrentBankAccount());
|
||||
}
|
||||
|
||||
if (settings != null)
|
||||
btcCode.bind(settings.btcDenominationProperty());
|
||||
if (accountSettings != null)
|
||||
btcCode.bind(applicationPreferences.btcDenominationProperty());
|
||||
|
||||
// we need to set it here already as initWithData is called before activate
|
||||
if (settings != null)
|
||||
securityDepositAsCoin.set(settings.getSecurityDeposit());
|
||||
if (accountSettings != null)
|
||||
securityDepositAsCoin.set(accountSettings.getSecurityDeposit());
|
||||
|
||||
super.initialize();
|
||||
}
|
||||
|
@ -166,14 +170,14 @@ class CreateOfferModel extends UIModel {
|
|||
super.activate();
|
||||
|
||||
// might be changed after screen change
|
||||
if (settings != null) {
|
||||
if (accountSettings != null) {
|
||||
// set it here again to cover the case of an securityDeposit change after a screen change
|
||||
if (settings != null)
|
||||
securityDepositAsCoin.set(settings.getSecurityDeposit());
|
||||
if (accountSettings != null)
|
||||
securityDepositAsCoin.set(accountSettings.getSecurityDeposit());
|
||||
|
||||
acceptedCountries.setAll(settings.getAcceptedCountries());
|
||||
acceptedLanguages.setAll(settings.getAcceptedLanguageLocales());
|
||||
acceptedArbitrators.setAll(settings.getAcceptedArbitrators());
|
||||
acceptedCountries.setAll(accountSettings.getAcceptedCountries());
|
||||
acceptedLanguages.setAll(accountSettings.getAcceptedLanguageLocales());
|
||||
acceptedArbitrators.setAll(accountSettings.getAcceptedArbitrators());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import io.bitsquare.locale.Country;
|
|||
import io.bitsquare.locale.CurrencyUtil;
|
||||
import io.bitsquare.offer.Direction;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
import io.bitsquare.user.User;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class OfferBookModel extends UIModel {
|
|||
|
||||
private final User user;
|
||||
private final OfferBook offerBook;
|
||||
private final Settings settings;
|
||||
private final ApplicationPreferences settings;
|
||||
private final BSFormatter formatter;
|
||||
private final TradeManager tradeManager;
|
||||
|
||||
|
@ -85,7 +85,7 @@ class OfferBookModel extends UIModel {
|
|||
OfferBookModel(User user,
|
||||
TradeManager tradeManager,
|
||||
OfferBook offerBook,
|
||||
Settings settings,
|
||||
ApplicationPreferences settings,
|
||||
BSFormatter formatter) {
|
||||
this.tradeManager = tradeManager;
|
||||
this.user = user;
|
||||
|
|
|
@ -24,7 +24,7 @@ import io.bitsquare.btc.listeners.BalanceListener;
|
|||
import io.bitsquare.gui.UIModel;
|
||||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
import io.bitsquare.trade.Trade;
|
||||
import io.bitsquare.trade.TradeManager;
|
||||
|
||||
|
@ -56,7 +56,7 @@ class TakeOfferModel extends UIModel {
|
|||
|
||||
private final TradeManager tradeManager;
|
||||
private final WalletFacade walletFacade;
|
||||
private final Settings settings;
|
||||
private final ApplicationPreferences settings;
|
||||
private final Persistence persistence;
|
||||
|
||||
private Offer offer;
|
||||
|
@ -83,7 +83,8 @@ class TakeOfferModel extends UIModel {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
TakeOfferModel(TradeManager tradeManager, WalletFacade walletFacade, Settings settings, Persistence persistence) {
|
||||
TakeOfferModel(TradeManager tradeManager, WalletFacade walletFacade, ApplicationPreferences settings,
|
||||
Persistence persistence) {
|
||||
this.tradeManager = tradeManager;
|
||||
this.walletFacade = walletFacade;
|
||||
this.settings = settings;
|
||||
|
|
|
@ -17,7 +17,12 @@
|
|||
|
||||
package io.bitsquare.gui.util;
|
||||
|
||||
import io.bitsquare.preferences.ApplicationPreferences;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
|
@ -33,107 +38,130 @@ import org.slf4j.LoggerFactory;
|
|||
public class Transitions {
|
||||
private static final Logger log = LoggerFactory.getLogger(Transitions.class);
|
||||
|
||||
public static final int DURATION = 400;
|
||||
private static Timeline removeBlurTimeline;
|
||||
public final static int DEFAULT_DURATION = 400;
|
||||
|
||||
public static void fadeIn(Node node) {
|
||||
fadeIn(node, DURATION);
|
||||
private ApplicationPreferences settings;
|
||||
private Timeline removeBlurTimeLine;
|
||||
|
||||
@Inject
|
||||
public Transitions(ApplicationPreferences settings) {
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public static FadeTransition fadeIn(Node node, int duration) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(duration), node);
|
||||
fade.setFromValue(node.getOpacity());
|
||||
fade.setToValue(1.0);
|
||||
fade.play();
|
||||
return fade;
|
||||
private int evaluateDuration(int duration) {
|
||||
return settings.getUseAnimations() ? duration : 1;
|
||||
}
|
||||
|
||||
public static FadeTransition fadeOut(Node node) {
|
||||
return fadeOut(node, DURATION);
|
||||
// Fade
|
||||
public void fadeIn(Node node) {
|
||||
fadeIn(node, DEFAULT_DURATION);
|
||||
}
|
||||
|
||||
public static FadeTransition fadeOut(Node node, int duration) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(duration), node);
|
||||
public void fadeIn(Node node, int duration) {
|
||||
if (settings.getUseEffects()) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(evaluateDuration(duration)), node);
|
||||
fade.setFromValue(node.getOpacity());
|
||||
fade.setToValue(1.0);
|
||||
fade.play();
|
||||
}
|
||||
}
|
||||
|
||||
public FadeTransition fadeOut(Node node) {
|
||||
return fadeOut(node, DEFAULT_DURATION);
|
||||
}
|
||||
|
||||
public FadeTransition fadeOut(Node node, int duration) {
|
||||
if (!settings.getUseEffects())
|
||||
duration = 1;
|
||||
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(evaluateDuration(duration)), node);
|
||||
fade.setFromValue(node.getOpacity());
|
||||
fade.setToValue(0.0);
|
||||
fade.play();
|
||||
return fade;
|
||||
}
|
||||
|
||||
public static FadeTransition fadeOutAndRemove(Node node) {
|
||||
return fadeOutAndRemove(node, DURATION);
|
||||
public void fadeOutAndRemove(Node node) {
|
||||
fadeOutAndRemove(node, DEFAULT_DURATION);
|
||||
}
|
||||
|
||||
public static FadeTransition fadeOutAndRemove(Node node, int duration) {
|
||||
FadeTransition fade = fadeOut(node, duration);
|
||||
public void fadeOutAndRemove(Node node, int duration) {
|
||||
if (!settings.getUseEffects())
|
||||
duration = 1;
|
||||
|
||||
FadeTransition fade = fadeOut(node, evaluateDuration(duration));
|
||||
fade.setInterpolator(Interpolator.EASE_IN);
|
||||
fade.setOnFinished(actionEvent -> {
|
||||
((Pane) (node.getParent())).getChildren().remove(node);
|
||||
Profiler.printMsgWithTime("fadeOutAndRemove");
|
||||
});
|
||||
return fade;
|
||||
}
|
||||
|
||||
public static void blur(Node node) {
|
||||
blur(node, DURATION, true, false);
|
||||
// Blur
|
||||
public void blur(Node node) {
|
||||
blur(node, DEFAULT_DURATION, true, false);
|
||||
}
|
||||
|
||||
public static Timeline blur(Node node, int duration, boolean useDarken, boolean removeNode) {
|
||||
if (removeBlurTimeline != null)
|
||||
removeBlurTimeline.stop();
|
||||
public void blur(Node node, int duration, boolean useDarken, boolean removeNode) {
|
||||
if (settings.getUseEffects()) {
|
||||
if (removeBlurTimeLine != null)
|
||||
removeBlurTimeLine.stop();
|
||||
|
||||
GaussianBlur blur = new GaussianBlur(0.0);
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue kv1 = new KeyValue(blur.radiusProperty(), 15.0);
|
||||
KeyFrame kf1 = new KeyFrame(Duration.millis(duration), kv1);
|
||||
GaussianBlur blur = new GaussianBlur(0.0);
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue kv1 = new KeyValue(blur.radiusProperty(), 15.0);
|
||||
KeyFrame kf1 = new KeyFrame(Duration.millis(evaluateDuration(duration)), kv1);
|
||||
|
||||
if (useDarken) {
|
||||
ColorAdjust darken = new ColorAdjust();
|
||||
darken.setBrightness(0.0);
|
||||
blur.setInput(darken);
|
||||
if (useDarken) {
|
||||
ColorAdjust darken = new ColorAdjust();
|
||||
darken.setBrightness(0.0);
|
||||
blur.setInput(darken);
|
||||
|
||||
KeyValue kv2 = new KeyValue(darken.brightnessProperty(), -0.1);
|
||||
KeyFrame kf2 = new KeyFrame(Duration.millis(duration), kv2);
|
||||
timeline.getKeyFrames().addAll(kf1, kf2);
|
||||
KeyValue kv2 = new KeyValue(darken.brightnessProperty(), -0.1);
|
||||
KeyFrame kf2 = new KeyFrame(Duration.millis(evaluateDuration(duration)), kv2);
|
||||
timeline.getKeyFrames().addAll(kf1, kf2);
|
||||
}
|
||||
else {
|
||||
timeline.getKeyFrames().addAll(kf1);
|
||||
}
|
||||
node.setEffect(blur);
|
||||
if (removeNode) timeline.setOnFinished(actionEvent -> Platform.runLater(() -> ((Pane) (node.getParent()))
|
||||
.getChildren().remove(node)));
|
||||
timeline.play();
|
||||
}
|
||||
else {
|
||||
timeline.getKeyFrames().addAll(kf1);
|
||||
}
|
||||
node.setEffect(blur);
|
||||
if (removeNode) timeline.setOnFinished(actionEvent -> Platform.runLater(() -> ((Pane) (node.getParent()))
|
||||
.getChildren().remove(node)));
|
||||
timeline.play();
|
||||
return timeline;
|
||||
}
|
||||
|
||||
public static void removeBlur(Node node) {
|
||||
removeBlur(node, DURATION, false);
|
||||
public void removeBlur(Node node) {
|
||||
removeBlur(node, DEFAULT_DURATION, false);
|
||||
}
|
||||
|
||||
public static void removeBlur(Node node, int duration, boolean useDarken) {
|
||||
if (node != null) {
|
||||
GaussianBlur blur = (GaussianBlur) node.getEffect();
|
||||
if (blur != null) {
|
||||
removeBlurTimeline = new Timeline();
|
||||
KeyValue kv1 = new KeyValue(blur.radiusProperty(), 0.0);
|
||||
KeyFrame kf1 = new KeyFrame(Duration.millis(DURATION), kv1);
|
||||
public void removeBlur(Node node, int duration, boolean useDarken) {
|
||||
if (settings.getUseEffects()) {
|
||||
if (node != null) {
|
||||
GaussianBlur blur = (GaussianBlur) node.getEffect();
|
||||
if (blur != null) {
|
||||
removeBlurTimeLine = new Timeline();
|
||||
KeyValue kv1 = new KeyValue(blur.radiusProperty(), 0.0);
|
||||
KeyFrame kf1 = new KeyFrame(Duration.millis(evaluateDuration(duration)), kv1);
|
||||
|
||||
|
||||
if (useDarken) {
|
||||
ColorAdjust darken = (ColorAdjust) blur.getInput();
|
||||
if (useDarken) {
|
||||
ColorAdjust darken = (ColorAdjust) blur.getInput();
|
||||
|
||||
KeyValue kv2 = new KeyValue(darken.brightnessProperty(), 0.0);
|
||||
KeyFrame kf2 = new KeyFrame(Duration.millis(duration), kv2);
|
||||
removeBlurTimeline.getKeyFrames().addAll(kf1, kf2);
|
||||
KeyValue kv2 = new KeyValue(darken.brightnessProperty(), 0.0);
|
||||
KeyFrame kf2 = new KeyFrame(Duration.millis(evaluateDuration(duration)), kv2);
|
||||
removeBlurTimeLine.getKeyFrames().addAll(kf1, kf2);
|
||||
}
|
||||
else {
|
||||
removeBlurTimeLine.getKeyFrames().addAll(kf1);
|
||||
}
|
||||
|
||||
removeBlurTimeLine.setOnFinished(actionEvent -> {
|
||||
node.setEffect(null);
|
||||
removeBlurTimeLine = null;
|
||||
});
|
||||
removeBlurTimeLine.play();
|
||||
}
|
||||
else {
|
||||
removeBlurTimeline.getKeyFrames().addAll(kf1);
|
||||
}
|
||||
|
||||
removeBlurTimeline.setOnFinished(actionEvent -> {
|
||||
node.setEffect(null);
|
||||
removeBlurTimeline = null;
|
||||
});
|
||||
removeBlurTimeline.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.preferences;
|
||||
|
||||
import org.bitcoinj.utils.MonetaryFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class ApplicationPreferences implements Serializable {
|
||||
private static final long serialVersionUID = 7995048077355006861L;
|
||||
|
||||
// Needed for persistence as Property objects are transient (not serializable)
|
||||
// Will be probably removed when we have another persistence solution in place
|
||||
private String btcDenominationString = MonetaryFormat.CODE_BTC;
|
||||
private Boolean useAnimationsBoolean = true;
|
||||
private Boolean useEffectsBoolean = true;
|
||||
|
||||
final transient StringProperty btcDenomination = new SimpleStringProperty(btcDenominationString);
|
||||
final transient BooleanProperty useAnimations = new SimpleBooleanProperty(useAnimationsBoolean);
|
||||
final transient BooleanProperty useEffects = new SimpleBooleanProperty(useEffectsBoolean);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public ApplicationPreferences() {
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Public API
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void applyPersistedSettings(ApplicationPreferences persistedSettings) {
|
||||
if (persistedSettings != null) {
|
||||
setBtcDenomination(persistedSettings.getBtcDenominationString());
|
||||
setUseAnimations(persistedSettings.getUseAnimationsBooleanBoolean());
|
||||
setUseEffects(persistedSettings.getUseEffectsBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Setters/Getters
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// btcDenomination
|
||||
public String getBtcDenomination() {
|
||||
return btcDenomination.get();
|
||||
}
|
||||
|
||||
public StringProperty btcDenominationProperty() {
|
||||
return btcDenomination;
|
||||
}
|
||||
|
||||
public void setBtcDenomination(String btcDenomination) {
|
||||
btcDenominationString = btcDenomination;
|
||||
this.btcDenomination.set(btcDenomination);
|
||||
}
|
||||
|
||||
// for persistence
|
||||
public String getBtcDenominationString() {
|
||||
return btcDenominationString;
|
||||
}
|
||||
|
||||
|
||||
// useAnimations
|
||||
public boolean getUseAnimations() {
|
||||
return useAnimations.get();
|
||||
}
|
||||
|
||||
public BooleanProperty useAnimationsProperty() {
|
||||
return useAnimations;
|
||||
}
|
||||
|
||||
public void setUseAnimations(boolean useAnimations) {
|
||||
useAnimationsBoolean = useAnimations;
|
||||
this.useAnimations.set(useAnimations);
|
||||
}
|
||||
|
||||
// for persistence
|
||||
public boolean getUseAnimationsBooleanBoolean() {
|
||||
return useAnimationsBoolean;
|
||||
}
|
||||
|
||||
// useEffects
|
||||
public boolean getUseEffects() {
|
||||
return useEffects.get();
|
||||
}
|
||||
|
||||
public BooleanProperty useEffectsProperty() {
|
||||
return useEffects;
|
||||
}
|
||||
|
||||
public void setUseEffects(boolean useEffects) {
|
||||
useEffectsBoolean = useEffects;
|
||||
this.useEffects.set(useEffects);
|
||||
}
|
||||
|
||||
// for persistence
|
||||
public boolean getUseEffectsBoolean() {
|
||||
return useEffectsBoolean;
|
||||
}
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package io.bitsquare.trade;
|
||||
|
||||
import io.bitsquare.account.AccountSettings;
|
||||
import io.bitsquare.btc.BlockChainFacade;
|
||||
import io.bitsquare.btc.WalletFacade;
|
||||
import io.bitsquare.crypto.CryptoFacade;
|
||||
|
@ -27,7 +28,6 @@ import io.bitsquare.offer.Direction;
|
|||
import io.bitsquare.offer.Offer;
|
||||
import io.bitsquare.offer.OfferRepository;
|
||||
import io.bitsquare.persistence.Persistence;
|
||||
import io.bitsquare.settings.Settings;
|
||||
import io.bitsquare.trade.handlers.TransactionResultHandler;
|
||||
import io.bitsquare.trade.protocol.createoffer.CreateOfferCoordinator;
|
||||
import io.bitsquare.trade.protocol.trade.TradeMessage;
|
||||
|
@ -73,7 +73,7 @@ public class TradeManager {
|
|||
private static final Logger log = LoggerFactory.getLogger(TradeManager.class);
|
||||
|
||||
private final User user;
|
||||
private final Settings settings;
|
||||
private final AccountSettings accountSettings;
|
||||
private final Persistence persistence;
|
||||
private final MessageFacade messageFacade;
|
||||
private final BlockChainFacade blockChainFacade;
|
||||
|
@ -99,11 +99,12 @@ public class TradeManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public TradeManager(User user, Settings settings, Persistence persistence, MessageFacade messageFacade,
|
||||
public TradeManager(User user, AccountSettings accountSettings, Persistence persistence,
|
||||
MessageFacade messageFacade,
|
||||
BlockChainFacade blockChainFacade, WalletFacade walletFacade, CryptoFacade cryptoFacade,
|
||||
OfferRepository offerRepository) {
|
||||
this.user = user;
|
||||
this.settings = settings;
|
||||
this.accountSettings = accountSettings;
|
||||
this.persistence = persistence;
|
||||
this.messageFacade = messageFacade;
|
||||
this.blockChainFacade = blockChainFacade;
|
||||
|
@ -161,10 +162,10 @@ public class TradeManager {
|
|||
user.getCurrentBankAccount().getCurrency(),
|
||||
user.getCurrentBankAccount().getCountry(),
|
||||
user.getCurrentBankAccount().getUid(),
|
||||
settings.getAcceptedArbitrators(),
|
||||
settings.getSecurityDeposit(),
|
||||
settings.getAcceptedCountries(),
|
||||
settings.getAcceptedLanguageLocales());
|
||||
accountSettings.getAcceptedArbitrators(),
|
||||
accountSettings.getSecurityDeposit(),
|
||||
accountSettings.getAcceptedCountries(),
|
||||
accountSettings.getAcceptedLanguageLocales());
|
||||
|
||||
CreateOfferCoordinator createOfferCoordinator = new CreateOfferCoordinator(
|
||||
offer,
|
||||
|
|
|
@ -48,7 +48,7 @@ public class CreateOfferPMTest {
|
|||
BSFormatter formatter = new BSFormatter(new User());
|
||||
formatter.setLocale(Locale.US);
|
||||
formatter.setFiatCurrencyCode("USD");
|
||||
model = new CreateOfferModel(null, null, null, null, null, formatter);
|
||||
model = new CreateOfferModel(null, null, null, null, null, null, formatter);
|
||||
|
||||
presenter = new CreateOfferPM(model, new FiatValidator(null), new BtcValidator(), formatter);
|
||||
presenter.initialize();
|
||||
|
|
Loading…
Add table
Reference in a new issue