notifications preference

This commit is contained in:
Craig Raw 2020-08-07 10:26:26 +02:00
parent 08498b1b71
commit 8aed206a34
4 changed files with 48 additions and 22 deletions

View file

@ -926,6 +926,7 @@ public class AppController implements Initializable {
@Subscribe @Subscribe
public void newWalletTransactions(NewWalletTransactionsEvent event) { public void newWalletTransactions(NewWalletTransactionsEvent event) {
if(Config.get().isNotifyNewTransactions()) {
String text = "New " + (event.getBlockTransactions().size() > 1 ? "transactions: " : "transaction: "); String text = "New " + (event.getBlockTransactions().size() > 1 ? "transactions: " : "transaction: ");
BitcoinUnit unit = Config.get().getBitcoinUnit(); BitcoinUnit unit = Config.get().getBitcoinUnit();
@ -951,6 +952,7 @@ public class AppController implements Initializable {
notificationBuilder.show(); notificationBuilder.show();
} }
}
@Subscribe @Subscribe
public void statusUpdated(StatusEvent event) { public void statusUpdated(StatusEvent event) {

View file

@ -21,6 +21,7 @@ public class Config {
private ExchangeSource exchangeSource; private ExchangeSource exchangeSource;
private boolean groupByAddress = true; private boolean groupByAddress = true;
private boolean includeMempoolChange = true; private boolean includeMempoolChange = true;
private boolean notifyNewTransactions = true;
private Integer keyDerivationPeriod; private Integer keyDerivationPeriod;
private File hwi; private File hwi;
private String electrumServer; private String electrumServer;
@ -123,6 +124,15 @@ public class Config {
flush(); flush();
} }
public boolean isNotifyNewTransactions() {
return notifyNewTransactions;
}
public void setNotifyNewTransactions(boolean notifyNewTransactions) {
this.notifyNewTransactions = notifyNewTransactions;
flush();
}
public Integer getKeyDerivationPeriod() { public Integer getKeyDerivationPeriod() {
return keyDerivationPeriod; return keyDerivationPeriod;
} }

View file

@ -35,6 +35,9 @@ public class GeneralPreferencesController extends PreferencesDetailController {
@FXML @FXML
private UnlabeledToggleSwitch includeMempoolChange; private UnlabeledToggleSwitch includeMempoolChange;
@FXML
private UnlabeledToggleSwitch notifyNewTransactions;
private final ChangeListener<Currency> fiatCurrencyListener = new ChangeListener<Currency>() { private final ChangeListener<Currency> fiatCurrencyListener = new ChangeListener<Currency>() {
@Override @Override
public void changed(ObservableValue<? extends Currency> observable, Currency oldValue, Currency newValue) { public void changed(ObservableValue<? extends Currency> observable, Currency oldValue, Currency newValue) {
@ -78,6 +81,11 @@ public class GeneralPreferencesController extends PreferencesDetailController {
includeMempoolChange.selectedProperty().addListener((observableValue, oldValue, newValue) -> { includeMempoolChange.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
config.setIncludeMempoolChange(newValue); config.setIncludeMempoolChange(newValue);
}); });
notifyNewTransactions.setSelected(config.isNotifyNewTransactions());
notifyNewTransactions.selectedProperty().addListener((observableValue, oldValue, newValue) -> {
config.setNotifyNewTransactions(newValue);
});
} }
private void updateCurrencies(ExchangeSource exchangeSource) { private void updateCurrencies(ExchangeSource exchangeSource) {

View file

@ -68,5 +68,11 @@
<HelpLabel helpText="Allow a wallet to spend UTXOs that are still in the mempool where all their inputs are from that wallet"/> <HelpLabel helpText="Allow a wallet to spend UTXOs that are still in the mempool where all their inputs are from that wallet"/>
</Field> </Field>
</Fieldset> </Fieldset>
<Fieldset inputGrow="SOMETIMES" text="Notifications" styleClass="wideLabelFieldSet">
<Field text="New transactions:">
<UnlabeledToggleSwitch fx:id="notifyNewTransactions" />
<HelpLabel helpText="Show system notifications on new wallet transactions"/>
</Field>
</Fieldset>
</Form> </Form>
</GridPane> </GridPane>