Merge pull request #4814 from jmacxx/improve_account_aging_column

Improve UI/UX for account aging column in 'Offers' section of GUI
This commit is contained in:
Christoph Atteneder 2020-11-18 10:41:10 +01:00 committed by GitHub
commit 29b2c33222
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 15 deletions

View file

@ -104,6 +104,7 @@ public class AccountAgeWitnessService {
private String presentation;
private String hash = "";
private long daysUntilLimitLifted = 0;
SignState(String presentation) {
this.presentation = presentation;
@ -114,11 +115,16 @@ public class AccountAgeWitnessService {
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);
}
}
@ -806,7 +812,8 @@ public class AccountAgeWitnessService {
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);

View file

@ -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
@ -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)

View file

@ -376,7 +376,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
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);
@ -1112,6 +1112,7 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
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",
@ -1121,10 +1122,9 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
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(
@ -1132,15 +1132,22 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
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);

View file

@ -1115,6 +1115,10 @@ public class GUIUtil {
}
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;