From 70abd272d4bce8b59095b4a718b748e392643ade Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Wed, 6 Nov 2019 14:32:38 +0100 Subject: [PATCH] Only show approval icon for accounts that are able to sign (#3552) --- .../paymentmethods/PaymentMethodForm.java | 16 +++++----------- .../account/content/PaymentAccountsView.java | 13 ++----------- .../main/offer/offerbook/OfferBookView.java | 9 +++++---- .../src/main/java/bisq/desktop/util/GUIUtil.java | 6 ++++++ 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java index f35dd71a95d..1e5a2ca85c1 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java @@ -23,6 +23,7 @@ import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.FormBuilder; +import bisq.desktop.util.GUIUtil; import bisq.desktop.util.Layout; import bisq.core.account.witness.AccountAgeWitness; @@ -220,19 +221,12 @@ else if (!paymentAccount.getTradeCurrencies().isEmpty()) Res.get("offerbook.timeSinceSigning.daysSinceSigning", daysSinceSigning)); - switch (signState) { - case PEER_SIGNER: - case ARBITRATOR: - icon = MaterialDesignIcon.APPROVAL; - accountSigningStateText += " / " + timeSinceSigning; - break; - case PEER_INITIAL: - case PEER_LIMIT_LIFTED: - accountSigningStateText += " / " + timeSinceSigning; - default: - icon = MaterialDesignIcon.ALERT_CIRCLE_OUTLINE; + if (!signState.equals(AccountAgeWitnessService.SignState.UNSIGNED)) { + accountSigningStateText += " / " + timeSinceSigning; } + icon = GUIUtil.getIconForSignState(signState); + InfoTextField accountSigningField = addCompactTopLabelInfoTextField(gridPane, ++gridRow, Res.get("shared.accountSigningState"), accountSigningStateText).second; //TODO: add additional information regarding account signing diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/PaymentAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/PaymentAccountsView.java index 983b817acf2..92e674e457a 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/PaymentAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/PaymentAccountsView.java @@ -6,6 +6,7 @@ import bisq.desktop.components.AutoTooltipLabel; import bisq.desktop.components.InfoAutoTooltipLabel; import bisq.desktop.main.overlays.popups.Popup; +import bisq.desktop.util.GUIUtil; import bisq.desktop.util.ImageUtil; import bisq.core.account.sign.SignedWitnessService; @@ -18,8 +19,6 @@ import org.apache.commons.lang3.StringUtils; -import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; - import javafx.scene.Node; import javafx.scene.control.Button; import javafx.scene.control.ContentDisplay; @@ -126,15 +125,7 @@ public void updateItem(final PaymentAccount item, boolean empty) { item.paymentAccountPayload)); String info = StringUtils.capitalize(signState.getPresentation()); - - switch (signState) { - case PEER_SIGNER: - case ARBITRATOR: - label.setIcon(MaterialDesignIcon.APPROVAL, info); - break; - default: - label.setIcon(MaterialDesignIcon.ALERT_CIRCLE_OUTLINE, info); - } + label.setIcon(GUIUtil.getIconForSignState(signState), info); } else { label.hideIcon(); } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index f407050f026..0f3bb4d935e 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -1084,9 +1084,10 @@ public void updateItem(final OfferBookListItem item, boolean empty) { String timeSinceSigning; if (accountAgeWitnessService.hasSignedWitness(item.getOffer())) { - icon = MaterialDesignIcon.APPROVAL; + AccountAgeWitnessService.SignState signState = accountAgeWitnessService.getSignState(item.getOffer()); + icon = GUIUtil.getIconForSignState(signState); info = Res.get("offerbook.timeSinceSigning.info", - accountAgeWitnessService.getSignState(item.getOffer()).getPresentation()); + signState.getPresentation()); long daysSinceSigning = TimeUnit.MILLISECONDS.toDays( accountAgeWitnessService.getWitnessSignAge(item.getOffer(), new Date())); timeSinceSigning = Res.get("offerbook.timeSinceSigning.daysSinceSigning", @@ -1095,10 +1096,10 @@ public void updateItem(final OfferBookListItem item, boolean empty) { boolean needsSigning = PaymentMethod.hasChargebackRisk( item.getOffer().getPaymentMethod(), item.getOffer().getCurrencyCode()); if (needsSigning) { - icon = MaterialDesignIcon.ALERT_CIRCLE_OUTLINE; - AccountAgeWitnessService.SignState signState = accountAgeWitnessService.getSignState(item.getOffer()); + icon = GUIUtil.getIconForSignState(signState); + if (!signState.equals(AccountAgeWitnessService.SignState.UNSIGNED)) { info = Res.get("offerbook.timeSinceSigning.info", signState.getPresentation()); long daysSinceSigning = TimeUnit.MILLISECONDS.toDays( diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index d68605233bd..0add2cfa429 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -1098,4 +1098,10 @@ public static String getBsqInUsd(Price bsqPrice, Volume volumeByAmount = usdPrice.getVolumeByAmount(requiredBtc); return DisplayUtils.formatVolumeWithCode(volumeByAmount); } + + public static MaterialDesignIcon getIconForSignState(AccountAgeWitnessService.SignState state) { + return (state.equals(AccountAgeWitnessService.SignState.ARBITRATOR) || + state.equals(AccountAgeWitnessService.SignState.PEER_SIGNER)) ? + MaterialDesignIcon.APPROVAL : MaterialDesignIcon.ALERT_CIRCLE_OUTLINE; + } }