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.

Fixes bisq-network#3223

Replaces PR bisq-network#3322 -- rejected because source file reformat
rearanged class level field declarations, making review
more difficult.
  • Loading branch information
ghubstan committed Nov 5, 2019
1 parent 00183db commit ba0acd4
Showing 1 changed file with 17 additions and 8 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 @@ -144,7 +145,7 @@ public class PreferencesView extends ActivatableViewAndModel<GridPane, Preferenc
private ChangeListener<Boolean> useCustomFeeCheckboxListener;
private ChangeListener<Number> transactionFeeChangeListener;
private final boolean daoOptionsSet;

private final boolean displayStandbyModeFeature;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, initialisation
Expand Down Expand Up @@ -173,6 +174,7 @@ public PreferencesView(PreferencesViewModel model,
rpcUser != null && !rpcUser.isEmpty() &&
rpcPassword != null && !rpcPassword.isEmpty() &&
rpcBlockNotificationPort != null && !rpcBlockNotificationPort.isEmpty();
this.displayStandbyModeFeature = Utilities.isOSX() || Utilities.isWindows();
}

@Override
Expand Down Expand Up @@ -224,7 +226,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);

userLanguageComboBox = addComboBox(root, gridRow,
Expand Down Expand Up @@ -346,9 +349,11 @@ private void initializeGeneralOptions() {
}
};

// 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 @@ -806,8 +811,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 @@ -929,7 +936,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 ba0acd4

Please sign in to comment.