Skip to content

Commit

Permalink
Only show approval icon for accounts that are able to sign (#3552)
Browse files Browse the repository at this point in the history
  • Loading branch information
ripcurlx authored and sqrrm committed Nov 6, 2019
1 parent b976bec commit 70abd27
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions desktop/src/main/java/bisq/desktop/util/GUIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 70abd27

Please sign in to comment.