Skip to content

Commit

Permalink
Hide avoid standby mode feature on *nux OS
Browse files Browse the repository at this point in the history
Displays standby mode button on only on Windows and OSX,
and hides it on Linux and Unix distributions.

TitledGroupBg num rows reduced to 7 when standby mode button
is not displayed.

Formatted source file, resulting in rearranged class
level field declarations.

Fix for Issue bisq-network#3223
  • Loading branch information
ghubstan committed Sep 25, 2019
1 parent 490eaab commit 7c517dd
Showing 1 changed file with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import bisq.common.UserThread;
import bisq.common.app.DevEnv;
import bisq.common.util.Tuple3;
import bisq.common.util.Utilities;

import org.bitcoinj.core.Coin;

Expand Down Expand Up @@ -97,14 +98,22 @@
@FxmlView
public class PreferencesView extends ActivatableViewAndModel<GridPane, PreferencesViewModel> {

private final Preferences preferences;
private final FeeService feeService;
//private final ReferralIdService referralIdService;
private final AssetService assetService;
private final FilterManager filterManager;
//private ComboBox<BaseCurrencyNetwork> selectBaseCurrencyNetworkComboBox;
private final DaoFacade daoFacade;
private final BSFormatter formatter;
private final boolean daoOptionsSet;
private final boolean displayStandbyModeFeature;
// not supported yet
//private ComboBox<String> btcDenominationComboBox;
private ComboBox<BlockChainExplorer> blockChainExplorerComboBox;
private ComboBox<String> userLanguageComboBox;
private ComboBox<Country> userCountryComboBox;
private ComboBox<TradeCurrency> preferredTradeCurrencyComboBox;
//private ComboBox<BaseCurrencyNetwork> selectBaseCurrencyNetworkComboBox;

private ToggleButton showOwnOffersInOfferBook, useAnimations, useDarkMode, sortMarketCurrenciesNumerically,
avoidStandbyMode, useCustomFee;
private int gridRow = 0;
Expand All @@ -114,16 +123,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private ToggleButton isDaoFullNodeToggleButton;
private PasswordTextField rpcPwTextField;
private TitledGroupBg daoOptionsTitledGroupBg;

private ChangeListener<Boolean> transactionFeeFocusedListener;
private final Preferences preferences;
private final FeeService feeService;
//private final ReferralIdService referralIdService;
private final AssetService assetService;
private final FilterManager filterManager;
private final DaoFacade daoFacade;
private final BSFormatter formatter;

private ListView<FiatCurrency> fiatCurrenciesListView;
private ComboBox<FiatCurrency> fiatCurrenciesComboBox;
private ListView<CryptoCurrency> cryptoCurrenciesListView;
Expand All @@ -144,7 +144,6 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private ChangeListener<Boolean> deviationFocusedListener;
private ChangeListener<Boolean> useCustomFeeCheckboxListener;
private ChangeListener<Number> transactionFeeChangeListener;
private final boolean daoOptionsSet;


///////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -170,10 +169,11 @@ public PreferencesView(PreferencesViewModel model,
this.filterManager = filterManager;
this.daoFacade = daoFacade;
this.formatter = formatter;
daoOptionsSet = fullDaoNode != null && !fullDaoNode.isEmpty() &&
this.daoOptionsSet = fullDaoNode != null && !fullDaoNode.isEmpty() &&
rpcUser != null && !rpcUser.isEmpty() &&
rpcPassword != null && !rpcPassword.isEmpty() &&
rpcBlockNotificationPort != null && !rpcBlockNotificationPort.isEmpty();
this.displayStandbyModeFeature = Utilities.isOSX() || Utilities.isWindows();
}

@Override
Expand Down Expand Up @@ -225,7 +225,8 @@ protected void deactivate() {
///////////////////////////////////////////////////////////////////////////////////////////

private void initializeGeneralOptions() {
TitledGroupBg titledGroupBg = addTitledGroupBg(root, gridRow, 8, Res.get("setting.preferences.general"));
int titledGroupBgRowSpan = displayStandbyModeFeature ? 8 : 7;
TitledGroupBg titledGroupBg = addTitledGroupBg(root, gridRow, titledGroupBgRowSpan, Res.get("setting.preferences.general"));
GridPane.setColumnSpan(titledGroupBg, 1);

// selectBaseCurrencyNetwork
Expand Down Expand Up @@ -367,9 +368,11 @@ public BaseCurrencyNetwork fromString(String string) {
}
};

// AvoidStandbyModeService
avoidStandbyMode = addSlideToggleButton(root, ++gridRow,
Res.get("setting.preferences.avoidStandbyMode"));
if (displayStandbyModeFeature) {
// AvoidStandbyModeService feature works only on OSX & Windows
avoidStandbyMode = addSlideToggleButton(root, ++gridRow,
Res.get("setting.preferences.avoidStandbyMode"));
}
}

private void initializeSeparator() {
Expand Down Expand Up @@ -827,8 +830,10 @@ private void activateDisplayPreferences() {

// We use opposite property (useStandbyMode) in preferences to have the default value (false) set as we want it,
// so users who update gets set avoidStandbyMode=true (useStandbyMode=false)
avoidStandbyMode.setSelected(!preferences.isUseStandbyMode());
avoidStandbyMode.setOnAction(e -> preferences.setUseStandbyMode(!avoidStandbyMode.isSelected()));
if (displayStandbyModeFeature) {
avoidStandbyMode.setSelected(!preferences.isUseStandbyMode());
avoidStandbyMode.setOnAction(e -> preferences.setUseStandbyMode(!avoidStandbyMode.isSelected()));
}
}

private void activateDaoPreferences() {
Expand Down Expand Up @@ -950,7 +955,9 @@ private void deactivateDisplayPreferences() {
sortMarketCurrenciesNumerically.setOnAction(null);
showOwnOffersInOfferBook.setOnAction(null);
resetDontShowAgainButton.setOnAction(null);
avoidStandbyMode.setOnAction(null);
if (displayStandbyModeFeature) {
avoidStandbyMode.setOnAction(null);
}
}

private void deactivateDaoPreferences() {
Expand Down

0 comments on commit 7c517dd

Please sign in to comment.