Skip to content

Commit

Permalink
Merge pull request #4814 from jmacxx/improve_account_aging_column
Browse files Browse the repository at this point in the history
Improve UI/UX for account aging column in 'Offers' section of GUI
  • Loading branch information
ripcurlx authored Nov 18, 2020
2 parents 71b6259 + f7fac0f commit 29b2c33
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public enum SignState {

private String presentation;
private String hash = "";
private long daysUntilLimitLifted = 0;

SignState(String presentation) {
this.presentation = presentation;
Expand All @@ -114,11 +115,16 @@ public SignState addHash(String hash) {
return this;
}

public SignState setDaysUntilLimitLifted(long days) {
this.daysUntilLimitLifted = days;
return this;
}

public String getPresentation() {
if (!hash.isEmpty()) { // Only showing in DEBUG mode
return presentation + " " + hash;
}
return presentation;
return String.format(presentation, daysUntilLimitLifted);
}

}
Expand Down Expand Up @@ -806,7 +812,8 @@ public SignState getSignState(AccountAgeWitness accountAgeWitness) {
case ONE_TO_TWO_MONTHS:
return SignState.PEER_SIGNER.addHash(hash);
case LESS_ONE_MONTH:
return SignState.PEER_INITIAL.addHash(hash);
return SignState.PEER_INITIAL.addHash(hash)
.setDaysUntilLimitLifted(30 - TimeUnit.MILLISECONDS.toDays(accountSignAge));
case UNVERIFIED:
default:
return SignState.UNSIGNED.addHash(hash);
Expand Down
11 changes: 7 additions & 4 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ offerbook.offerersAcceptedBankSeats=Accepted seat of bank countries (taker):\n {
offerbook.availableOffers=Available offers
offerbook.filterByCurrency=Filter by currency
offerbook.filterByPaymentMethod=Filter by payment method
offerbook.timeSinceSigning=Signed since
offerbook.timeSinceSigning=Account info
offerbook.timeSinceSigning.info=This account was verified and {0}
offerbook.timeSinceSigning.info.arbitrator=signed by an arbitrator and can sign peer accounts
offerbook.timeSinceSigning.info.peer=signed by a peer, waiting for limits to be lifted
offerbook.timeSinceSigning.info.peer=signed by a peer, waiting %d days for limits to be lifted
offerbook.timeSinceSigning.info.peerLimitLifted=signed by a peer and limits were lifted
offerbook.timeSinceSigning.info.signer=signed by peer and can sign peer accounts (limits lifted)
offerbook.timeSinceSigning.info.banned=account was banned
Expand All @@ -354,9 +354,12 @@ offerbook.xmrAutoConf=Is auto-confirm enabled
offerbook.timeSinceSigning.help=When you successfully complete a trade with a peer who has a signed payment account, your payment account is signed.\n\
{0} days later, the initial limit of {1} is lifted and your account can sign other peers'' payment accounts.
offerbook.timeSinceSigning.notSigned=Not signed yet
offerbook.timeSinceSigning.notSigned.ageDays={0} days
offerbook.timeSinceSigning.notSigned.noNeed=N/A
shared.notSigned=This account hasn't been signed yet
shared.notSigned.noNeed=This account type doesn't use signing
shared.notSigned=This account has not been signed yet and was created {0} days ago
shared.notSigned.noNeed=This account type does not require signing
shared.notSigned.noNeedDays=This account type does not require signing and was created {0} days ago
shared.notSigned.noNeedAlts=Altcoin accounts do not feature signing or aging

offerbook.nrOffers=No. of offers: {0}
offerbook.volume={0} (min - max)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ protected void activate() {
private void updateSigningStateColumn() {
if (model.hasSelectionAccountSigning()) {
if (!tableView.getColumns().contains(signingStateColumn)) {
tableView.getColumns().add(tableView.getColumns().indexOf(paymentMethodColumn) + 1, signingStateColumn);
tableView.getColumns().add(tableView.getColumns().indexOf(depositColumn) + 1, signingStateColumn);
}
} else {
tableView.getColumns().remove(signingStateColumn);
Expand Down Expand Up @@ -1112,6 +1112,7 @@ public void updateItem(final OfferBookListItem item, boolean empty) {

if (needsSigning) {
if (accountAgeWitnessService.hasSignedWitness(item.getOffer())) {
// either signed & limits lifted, or waiting for limits to be lifted
AccountAgeWitnessService.SignState signState = accountAgeWitnessService.getSignState(item.getOffer());
icon = GUIUtil.getIconForSignState(signState);
info = Res.get("offerbook.timeSinceSigning.info",
Expand All @@ -1121,26 +1122,32 @@ public void updateItem(final OfferBookListItem item, boolean empty) {
timeSinceSigning = Res.get("offerbook.timeSinceSigning.daysSinceSigning",
daysSinceSigning);
} else {
// either banned, unsigned
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(
accountAgeWitnessService.getWitnessSignAge(item.getOffer(), new Date()));
timeSinceSigning = Res.get("offerbook.timeSinceSigning.daysSinceSigning",
daysSinceSigning);
} else {
info = Res.get("shared.notSigned");
timeSinceSigning = Res.get("offerbook.timeSinceSigning.notSigned");
long accountAge = TimeUnit.MILLISECONDS.toDays(accountAgeWitnessService.getAccountAge(item.getOffer()));
info = Res.get("shared.notSigned", accountAge);
timeSinceSigning = Res.get("offerbook.timeSinceSigning.notSigned", accountAge);
}
}

} else {
icon = MaterialDesignIcon.INFORMATION_OUTLINE;
info = Res.get("shared.notSigned.noNeed");
timeSinceSigning = Res.get("offerbook.timeSinceSigning.notSigned.noNeed");
if (CurrencyUtil.isFiatCurrency(item.getOffer().getCurrencyCode())) {
icon = MaterialDesignIcon.CHECKBOX_MARKED_OUTLINE;
long days = TimeUnit.MILLISECONDS.toDays(accountAgeWitnessService.getAccountAge(item.getOffer()));
info = Res.get("shared.notSigned.noNeedDays", days);
timeSinceSigning = Res.get("offerbook.timeSinceSigning.notSigned.ageDays", days);
} else { // altcoins
icon = MaterialDesignIcon.INFORMATION_OUTLINE;
info = Res.get("shared.notSigned.noNeedAlts");
timeSinceSigning = Res.get("offerbook.timeSinceSigning.notSigned.noNeed");
}
}

InfoAutoTooltipLabel label = new InfoAutoTooltipLabel(timeSinceSigning, icon, ContentDisplay.RIGHT, info);
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/main/java/bisq/desktop/util/GUIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,10 @@ public static String getBsqInUsd(Price bsqPrice,
}

public static MaterialDesignIcon getIconForSignState(AccountAgeWitnessService.SignState state) {
if (state.equals(AccountAgeWitnessService.SignState.PEER_INITIAL)) {
return MaterialDesignIcon.CLOCK;
}

return (state.equals(AccountAgeWitnessService.SignState.ARBITRATOR) ||
state.equals(AccountAgeWitnessService.SignState.PEER_SIGNER)) ?
MaterialDesignIcon.APPROVAL : MaterialDesignIcon.ALERT_CIRCLE_OUTLINE;
Expand Down

0 comments on commit 29b2c33

Please sign in to comment.