Skip to content

Commit

Permalink
Account Signing: Improve signed state notificaton (#3388)
Browse files Browse the repository at this point in the history
* Remove new badge from Altcoin instant feature

* Remove new badge from percentage user deposit feature

* Fix line break issues in received payment confirmation popup

* Check if received payload fulfills signing state condition and not any personal witness

* Show additional badge for account sections to guide user to check out new signing states
  • Loading branch information
ripcurlx authored and sqrrm committed Oct 10, 2019
1 parent b714c83 commit cda5dcc
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 70 deletions.
13 changes: 5 additions & 8 deletions core/src/main/java/bisq/core/app/BisqSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import bisq.core.account.sign.SignedWitness;
import bisq.core.account.sign.SignedWitnessService;
import bisq.core.account.witness.AccountAgeWitness;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.alert.Alert;
import bisq.core.alert.AlertManager;
Expand Down Expand Up @@ -106,6 +105,7 @@
import java.io.IOException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -773,15 +773,12 @@ private boolean isSignedWitnessOfMineWithState(PersistableNetworkPayload payload
if (payload instanceof SignedWitness && user.getPaymentAccounts() != null) {
// We know at this point that it is already added to the signed witness list
// Check if new signed witness is for one of my own accounts

return user.getPaymentAccounts().stream()
.filter(a -> PaymentMethod.hasChargebackRisk(a.getPaymentMethod(), a.getTradeCurrencies()))
.anyMatch(a -> {
AccountAgeWitness myWitness = accountAgeWitnessService.getMyWitness(a.getPaymentAccountPayload());
AccountAgeWitnessService.SignState signState = accountAgeWitnessService.getSignState(myWitness);

return (signState.equals(state));
});
.filter(a -> Arrays.equals(((SignedWitness) payload).getWitnessHash(),
accountAgeWitnessService.getMyWitness(a.getPaymentAccountPayload()).getHash()))
.anyMatch(a -> accountAgeWitnessService.getSignState(accountAgeWitnessService.getMyWitness(
a.getPaymentAccountPayload())).equals(state));
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ portfolio.pending.step3_seller.westernUnion=The buyer has to send you the MTCN (
portfolio.pending.step3_seller.halCash=The buyer has to send you the HalCash code as text message. Beside that you will receive a message from HalCash with the required information to withdraw the EUR from a HalCash supporting ATM.\n\n\
After you have picked up the money from the ATM please confirm here the receipt of the payment!

portfolio.pending.step3_seller.bankCheck=\n\nPlease also verify that the sender's name in your bank statement matches that one from the trade contract:\nSender's name: {0}\n\n\
portfolio.pending.step3_seller.bankCheck=\n\nPlease also verify that the sender''s name in your bank statement matches that one from the trade contract:\nSender''s name: {0}\n\n\
If the name is not the same as the one displayed here, {1}
portfolio.pending.step3_seller.openDispute=please don't confirm but open a dispute by entering \"alt + o\" or \"option + o\".
portfolio.pending.step3_seller.openDispute=please don't confirm but open a dispute by entering \"alt + o\" or \"option + o\".\n\n
portfolio.pending.step3_seller.confirmPaymentReceipt=Confirm payment receipt
portfolio.pending.step3_seller.amountToReceive=Amount to receive
portfolio.pending.step3_seller.yourAddress=Your {0} address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

package bisq.desktop.components.paymentmethods;

import bisq.desktop.components.InputTextField;
import bisq.desktop.components.NewBadge;
import bisq.desktop.components.AutocompleteComboBox;
import bisq.desktop.components.InputTextField;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout;
Expand Down Expand Up @@ -48,12 +47,9 @@
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;

import javafx.geometry.Insets;
import javafx.geometry.Pos;

import javafx.util.StringConverter;

Expand Down Expand Up @@ -120,19 +116,10 @@ public void addFormForAddAccount() {
new Popup<>().information(Res.get("payment.altcoin.tradeInstant.popup")).show();
});

// add new badge for this new feature for this release
// TODO: remove it with 0.9.6+
gridPane.getChildren().remove(tradeInstantCheckBox);
tradeInstantCheckBox.setPadding(new Insets(0, 40, 0, 0));

NewBadge instantTradeNewsBadge = new NewBadge(tradeInstantCheckBox, INSTANT_TRADE_NEWS, preferences);
instantTradeNewsBadge.setAlignment(Pos.CENTER_LEFT);
instantTradeNewsBadge.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);

GridPane.setRowIndex(instantTradeNewsBadge, gridRow);
GridPane.setHgrow(instantTradeNewsBadge, Priority.NEVER);
GridPane.setMargin(instantTradeNewsBadge, new Insets(10, 0, 0, 0));
gridPane.getChildren().add(instantTradeNewsBadge);
gridPane.getChildren().add(tradeInstantCheckBox);

addressInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow,
Res.get("payment.altcoin.address"));
Expand Down
9 changes: 6 additions & 3 deletions desktop/src/main/java/bisq/desktop/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import bisq.core.dao.monitoring.DaoStateMonitoringService;
import bisq.core.exceptions.BisqException;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.LanguageUtil;
import bisq.core.locale.Res;
import bisq.core.util.BSFormatter;
import bisq.core.locale.LanguageUtil;

import bisq.common.Timer;
import bisq.common.UserThread;
Expand Down Expand Up @@ -82,9 +82,9 @@
import javafx.scene.text.TextAlignment;

import javafx.geometry.Insets;
import javafx.geometry.NodeOrientation;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.geometry.NodeOrientation;

import javafx.beans.binding.ObjectBinding;
import javafx.beans.property.BooleanProperty;
Expand Down Expand Up @@ -194,6 +194,8 @@ protected void initialize() {
JFXBadge supportButtonWithBadge = new JFXBadge(supportButton);
JFXBadge daoButtonWithBadge = new JFXBadge(daoButton);
daoButtonWithBadge.getStyleClass().add("new");
JFXBadge accountButtonWithBadge = new JFXBadge(accountButton);
accountButtonWithBadge.getStyleClass().add("new");

Locale locale = GlobalSettings.getLocale();
DecimalFormat currencyFormat = (DecimalFormat) NumberFormat.getNumberInstance(locale);
Expand Down Expand Up @@ -322,7 +324,7 @@ protected Tooltip computeValue() {
HBox.setHgrow(primaryNav, Priority.SOMETIMES);

HBox secondaryNav = new HBox(supportButtonWithBadge, getNavigationSpacer(), settingsButton,
getNavigationSpacer(), accountButton, getNavigationSpacer(), daoButtonWithBadge);
getNavigationSpacer(), accountButtonWithBadge, getNavigationSpacer(), daoButtonWithBadge);
secondaryNav.getStyleClass().add("nav-secondary");
HBox.setHgrow(secondaryNav, Priority.SOMETIMES);

Expand Down Expand Up @@ -366,6 +368,7 @@ protected Tooltip computeValue() {
setupBadge(portfolioButtonWithBadge, model.getNumPendingTrades(), model.getShowPendingTradesNotification());
setupBadge(supportButtonWithBadge, model.getNumOpenSupportTickets(), model.getShowOpenSupportTicketsNotification());
setupBadge(daoButtonWithBadge, new SimpleStringProperty(Res.get("shared.new")), model.getShowDaoUpdatesNotification());
setupBadge(accountButtonWithBadge, new SimpleStringProperty(Res.get("shared.new")), model.getShowAccountUpdatesNotification());

navigation.addListener(viewPath -> {
if (viewPath.size() != 2 || viewPath.indexOf(MainView.class) != 0)
Expand Down
50 changes: 17 additions & 33 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
import bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow;
import bisq.desktop.main.presentation.AccountPresentation;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.main.presentation.MarketPricePresentation;
import bisq.desktop.main.shared.PriceFeedComboBoxItem;
Expand Down Expand Up @@ -105,6 +106,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupCompleteList
private final SupportTicketsPresentation supportTicketsPresentation;
private final MarketPricePresentation marketPricePresentation;
private final DaoPresentation daoPresentation;
private final AccountPresentation accountPresentation;
private final P2PService p2PService;
private final TradeManager tradeManager;
@Getter
Expand Down Expand Up @@ -146,7 +148,7 @@ public MainViewModel(BisqSetup bisqSetup,
SupportTicketsPresentation supportTicketsPresentation,
MarketPricePresentation marketPricePresentation,
DaoPresentation daoPresentation,
P2PService p2PService,
AccountPresentation accountPresentation, P2PService p2PService,
TradeManager tradeManager,
Preferences preferences,
PrivateNotificationManager privateNotificationManager,
Expand All @@ -167,6 +169,7 @@ public MainViewModel(BisqSetup bisqSetup,
this.supportTicketsPresentation = supportTicketsPresentation;
this.marketPricePresentation = marketPricePresentation;
this.daoPresentation = daoPresentation;
this.accountPresentation = accountPresentation;
this.p2PService = p2PService;
this.tradeManager = tradeManager;
this.preferences = preferences;
Expand Down Expand Up @@ -241,6 +244,7 @@ public void onSetupComplete() {

marketPricePresentation.setup();
daoPresentation.setup();
accountPresentation.setup();

if (DevEnv.isDevMode()) {
preferences.setShowOwnOffersInOfferBook(true);
Expand Down Expand Up @@ -350,38 +354,14 @@ private void setupHandlers() {
popupQueue.add(popup);
}
});
bisqSetup.setDisplaySignedByArbitratorHandler(key -> {
if (!DevEnv.isDevMode()) {
preferences.dontShowAgain(key, true);
new Popup<>().information(Res.get("popup.accountSigning.signedByArbitrator",
Res.get("popup.accountSigning.generalInformation")))
.show();
}
});
bisqSetup.setDisplaySignedByPeerHandler(key -> {
if (!DevEnv.isDevMode()) {
preferences.dontShowAgain(key, true);
new Popup<>().information(Res.get("popup.accountSigning.signedByPeer",
Res.get("popup.accountSigning.generalInformation")))
.show();
}
});
bisqSetup.setDisplayPeerLimitLiftedHandler(key -> {
if (!DevEnv.isDevMode()) {
preferences.dontShowAgain(key, true);
new Popup<>().information(Res.get("popup.accountSigning.peerLimitLifted",
Res.get("popup.accountSigning.generalInformation")))
.show();
}
});
bisqSetup.setDisplayPeerSignerHandler(key -> {
if (!DevEnv.isDevMode()) {
preferences.dontShowAgain(key, true);
new Popup<>().information(Res.get("popup.accountSigning.peerSigner",
Res.get("popup.accountSigning.generalInformation")))
.show();
}
});
bisqSetup.setDisplaySignedByArbitratorHandler(key -> accountPresentation.showOneTimeAccountSigningPopup(
key, "popup.accountSigning.signedByArbitrator"));
bisqSetup.setDisplaySignedByPeerHandler(key -> accountPresentation.showOneTimeAccountSigningPopup(
key, "popup.accountSigning.signedByPeer"));
bisqSetup.setDisplayPeerLimitLiftedHandler(key -> accountPresentation.showOneTimeAccountSigningPopup(
key, "popup.accountSigning.peerLimitLifted"));
bisqSetup.setDisplayPeerSignerHandler(key -> accountPresentation.showOneTimeAccountSigningPopup(
key, "popup.accountSigning.peerSigner"));

bisqSetup.setWrongOSArchitectureHandler(msg -> new Popup<>().warning(msg).show());

Expand Down Expand Up @@ -636,6 +616,10 @@ public BooleanProperty getShowDaoUpdatesNotification() {
return daoPresentation.getShowDaoUpdatesNotification();
}

public BooleanProperty getShowAccountUpdatesNotification() {
return accountPresentation.getShowAccountUpdatesNotification();
}

private void maybeAddDaoLaunchWindowToQueue() {
if (DevEnv.isDaoActivated()) {
String daoLaunchPopupKey = "daoLaunchPopup";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import bisq.desktop.main.account.register.mediator.MediatorRegistrationView;
import bisq.desktop.main.account.register.refundagent.RefundAgentRegistrationView;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.presentation.AccountPresentation;

import bisq.core.locale.Res;
import bisq.core.user.DontShowAgainLookup;

import bisq.common.app.DevEnv;
import bisq.common.util.Utilities;
Expand Down Expand Up @@ -206,6 +208,9 @@ private void onRefundAgentRegistrationTabRemoved() {

@Override
protected void activate() {
// Hide account new badge if user saw this section
DontShowAgainLookup.dontShowAgain(AccountPresentation.ACCOUNT_NEWS, true);

navigation.addListener(navigationListener);

root.getSelectionModel().selectedItemProperty().addListener(tabChangeListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import bisq.desktop.components.FundsTextField;
import bisq.desktop.components.InfoInputTextField;
import bisq.desktop.components.InputTextField;
import bisq.desktop.components.NewBadge;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.main.MainView;
import bisq.desktop.main.account.AccountView;
Expand Down Expand Up @@ -1037,13 +1036,7 @@ private void addOptionsGroup() {
GridPane.setMargin(advancedOptionsBox, new Insets(Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(advancedOptionsBox);

// add new badge for this new feature for this release
// TODO: remove it with 0.9.6+
NewBadge securityDepositBoxWithNewBadge = new NewBadge(getBuyerSecurityDepositBox(),
BUYER_SECURITY_DEPOSIT_NEWS, preferences);

advancedOptionsBox.getChildren().addAll(securityDepositBoxWithNewBadge, getTradeFeeFieldsBox());

advancedOptionsBox.getChildren().addAll(getBuyerSecurityDepositBox(), getTradeFeeFieldsBox());

Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(gridPane, ++gridRow,
Res.get("shared.nextStep"), Res.get("shared.cancel"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ else if (paymentAccountPayload instanceof F2FAccountPayload)

Optional<String> optionalHolderName = getOptionalHolderName();
if (optionalHolderName.isPresent()) {
message = message + Res.get("portfolio.pending.step3_seller.bankCheck", optionalHolderName.get(), part);
message += Res.get("portfolio.pending.step3_seller.bankCheck", optionalHolderName.get(), part);
}

if (model.isSignWitnessTrade(true)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* This file is part of Bisq.
*
* Bisq 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.
*
* Bisq 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 Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.desktop.main.presentation;

import bisq.desktop.main.overlays.popups.Popup;

import bisq.core.locale.Res;
import bisq.core.user.DontShowAgainLookup;
import bisq.core.user.Preferences;

import bisq.common.app.DevEnv;

import javax.inject.Inject;
import javax.inject.Singleton;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;

import javafx.collections.MapChangeListener;


@Singleton
public class AccountPresentation {

public static final String ACCOUNT_NEWS = "accountNews";

private Preferences preferences;

private final SimpleBooleanProperty showNotification = new SimpleBooleanProperty(false);

@Inject
public AccountPresentation(Preferences preferences) {

this.preferences = preferences;

preferences.getDontShowAgainMapAsObservable().addListener((MapChangeListener<? super String, ? super Boolean>) change -> {
if (change.getKey().equals(ACCOUNT_NEWS)) {
showNotification.set(!change.wasAdded());
}
});
}

///////////////////////////////////////////////////////////////////////////////////////////
// Public
///////////////////////////////////////////////////////////////////////////////////////////

public BooleanProperty getShowAccountUpdatesNotification() {
return showNotification;
}

public void setup() {
showNotification.set(preferences.showAgain(ACCOUNT_NEWS));
}

public void showOneTimeAccountSigningPopup(String key, String s) {
if (!DevEnv.isDevMode()) {

DontShowAgainLookup.dontShowAgain(ACCOUNT_NEWS, false);
showNotification.set(true);

DontShowAgainLookup.dontShowAgain(key, true);
new Popup<>().information(Res.get(s,
Res.get("popup.accountSigning.generalInformation")))
.show();
}
}
}

0 comments on commit cda5dcc

Please sign in to comment.