Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve wallet UI #620

Merged
merged 10 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ private static Config from(com.typesafe.config.Config config, String[] args) {
}

boolean devMode = config.getBoolean("devMode");
boolean isWalletEnabled = config.getBoolean("wallet.enabled");

String dataDir = null;
for (String arg : args) {
Expand All @@ -81,25 +80,22 @@ private static Config from(com.typesafe.config.Config config, String[] args) {

String version = config.getString("version");

return new Config(appDir, appName, version, devMode, isWalletEnabled);
return new Config(appDir, appName, version, devMode);
}

private final String baseDir;
private final String appName;
private final String version;
private final boolean devMode;
private final boolean isWalletEnabled;

public Config(String baseDir,
String appName,
String version,
boolean devMode,
boolean isWalletEnabled) {
boolean devMode) {
this.baseDir = baseDir;
this.appName = appName;
this.version = version;
this.devMode = devMode;
this.isWalletEnabled = isWalletEnabled;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public enum State {
}

private final SecurityService securityService;
private final ElectrumWalletService walletService;
private final ElectrumWalletService electrumWalletService;
private final NetworkService networkService;
private final IdentityService identityService;
private final OracleService oracleService;
Expand All @@ -83,7 +83,8 @@ public enum State {
public DefaultApplicationService(String[] args) {
super("default", args);
securityService = new SecurityService(persistenceService);
walletService = new ElectrumWalletService(config.isWalletEnabled(), Path.of(config.getBaseDir()));
electrumWalletService = new ElectrumWalletService(ElectrumWalletService.Config.from(getConfig("electrumWallet")),
Path.of(config.getBaseDir()));

networkService = new NetworkService(NetworkServiceConfig.from(config.getBaseDir(), getConfig("network")),
persistenceService,
Expand Down Expand Up @@ -128,7 +129,7 @@ public CompletableFuture<Boolean> initialize() {
setState(State.INITIALIZE_NETWORK);

CompletableFuture<Boolean> networkFuture = networkService.initialize();
CompletableFuture<Boolean> walletFuture = walletService.initialize();
CompletableFuture<Boolean> walletFuture = electrumWalletService.initialize();

networkFuture.whenComplete((r, throwable) -> {
if (throwable != null) {
Expand Down Expand Up @@ -188,7 +189,7 @@ public CompletableFuture<Boolean> shutdown() {
.thenCompose(result -> oracleService.shutdown())
.thenCompose(result -> identityService.shutdown())
.thenCompose(result -> networkService.shutdown())
.thenCompose(result -> walletService.shutdown())
.thenCompose(result -> electrumWalletService.shutdown())
.thenCompose(result -> securityService.shutdown())
.orTimeout(10, TimeUnit.SECONDS)
.handle((result, throwable) -> throwable == null)
Expand Down
2 changes: 1 addition & 1 deletion application/src/main/resources/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ application {
}
}

wallet = {
electrumWallet = {
enabled = true
}
}
2 changes: 1 addition & 1 deletion common/src/main/java/bisq/common/monetary/Coin.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static Coin of(long value, String code, int precision) {
}

private Coin(double value, String code, int precision) {
super(code + " [crypto]", value, code, precision, precision);
super(code + " [crypto]", value, code, precision, code.equals("BSQ") ? 2 : 4);
}

private Coin(String id, long value, String code, int precision, int minPrecision) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ public enum NavigationTarget {
REGISTER_MODERATOR(ROLES_TABS, false),
REGISTER_ORACLE(ROLES_TABS, false),

WALLET(CONTENT);
WALLET(CONTENT),
WALLET_DASHBOARD(WALLET),
WALLET_SEND(WALLET),
WALLET_RECEIVE(WALLET),
WALLET_TXS(WALLET),
WALLET_SETTINGS(WALLET);

@Getter
private final Optional<NavigationTarget> parent;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.components.controls;

import bisq.desktop.common.threading.UIThread;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextInputControl;
import javafx.scene.control.skin.TextFieldSkin;

import javax.annotation.Nullable;

public class MaterialPasswordField extends MaterialTextField {
public MaterialPasswordField() {
this(null, null, null);
}

public MaterialPasswordField(String description) {
this(description, null, null);
}

public MaterialPasswordField(String description, String prompt) {
this(description, prompt, null);
}

public MaterialPasswordField(@Nullable String description, @Nullable String prompt, @Nullable String help) {
super(description, prompt, help);
}

@Override
protected TextInputControl createTextInputControl() {
PasswordField passwordField = new PasswordField();
passwordField.setSkin(new VisiblePasswordFieldSkin(passwordField, this));

return passwordField;
}

static class VisiblePasswordFieldSkin extends TextFieldSkin {
private boolean isMasked = true;

public VisiblePasswordFieldSkin(PasswordField textField, MaterialPasswordField materialPasswordField) {
super(textField);

// iconButton is not created when we get called, so we delay it to next render frame
UIThread.runOnNextRenderFrame(() -> {
BisqIconButton iconButton = materialPasswordField.getIconButton();
materialPasswordField.setIcon(AwesomeIcon.EYE_OPEN);
iconButton.setOnAction(e -> {
iconButton.setIcon(isMasked ? AwesomeIcon.EYE_CLOSE : AwesomeIcon.EYE_OPEN);
isMasked = !isMasked;

// TODO if binding is used we don't get the text updated. With bi-dir binding it works
textField.setText(textField.getText());
textField.end();
/* if(!textField.textProperty().isBound()){
textField.setText(textField.getText());
textField.end();
}*/
});
});
}

@Override
protected String maskText(String txt) {
if (getSkinnable() instanceof PasswordField && isMasked) {
return "•".repeat(txt.length());
} else {
return txt;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
import bisq.desktop.primary.main.content.trade.TradeController;
import bisq.desktop.primary.main.content.trade.bisqEasy.BisqEasyController;
import bisq.desktop.primary.main.content.trade.bsqSwap.BsqSwapController;
import bisq.desktop.primary.main.content.trade.lightning.LightningController;
import bisq.desktop.primary.main.content.trade.liquidSwap.LiquidSwapController;
import bisq.desktop.primary.main.content.trade.multiSig.MultiSigController;
import bisq.desktop.primary.main.content.trade.xmrSwap.XmrSwapController;
import bisq.desktop.primary.main.content.wallet.WalletController;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.text.DateFormat;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -1026,7 +1027,7 @@ public ChatMessageListItem(T chatMessage, UserProfileService userProfileService,
String editPostFix = chatMessage.isWasEdited() ? EDITED_POST_FIX : "";
message = chatMessage.getText() + editPostFix;
quotedMessage = chatMessage.getQuotation();
date = DateFormatter.formatDateTimeV2(new Date(chatMessage.getDate()));
date = DateFormatter.formatDateTime(new Date(chatMessage.getDate()), DateFormat.MEDIUM, DateFormat.SHORT, true, " " + Res.get("at") + " ");

nym = senderUserProfile.map(UserProfile::getNym).orElse("");
nickName = senderUserProfile.map(UserProfile::getNickName).orElse("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ public void onActivate() {
}

updateRegistrationState();

model.getPrivateKeyDisplay().set("•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
});
}

Expand Down Expand Up @@ -148,8 +146,4 @@ void onRemoveRegistration() {
void onCopy() {
ClipboardUtil.copyToClipboard(model.getPublicKey().get());
}

void onShowPrivateKey() {
model.getPrivateKeyDisplay().set(model.getPrivateKey().get());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class RoleRegistrationModel implements Model {
private final StringProperty selectedProfileUserName = new SimpleStringProperty();
private final StringProperty privateKey = new SimpleStringProperty();
private final StringProperty publicKey = new SimpleStringProperty();
private final StringProperty privateKeyDisplay = new SimpleStringProperty();
private final BooleanProperty registrationDisabled = new SimpleBooleanProperty();
private final BooleanProperty removeRegistrationVisible = new SimpleBooleanProperty();
private final RoleType roleType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@

import bisq.desktop.common.view.View;
import bisq.desktop.components.containers.Spacer;
import bisq.desktop.components.controls.BisqIconButton;
import bisq.desktop.components.controls.MaterialPasswordField;
import bisq.desktop.components.controls.MaterialTextField;
import bisq.desktop.components.controls.MultiLineLabel;
import bisq.i18n.Res;
import de.jensd.fx.fontawesome.AwesomeIcon;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
Expand All @@ -38,8 +37,9 @@ public class RoleRegistrationView extends View<VBox, RoleRegistrationModel, Role
private final Button copyButton, registrationButton, removeRegistrationButton;
private final Hyperlink learnMore;
private final Label info;
private final MaterialTextField selectedProfile, privateKey, publicKey;
private final BisqIconButton showPrivateKeyIcon;
private final MaterialTextField selectedProfile, publicKey;
private final MaterialPasswordField privateKey;


public RoleRegistrationView(RoleRegistrationModel model,
RoleRegistrationController controller) {
Expand All @@ -55,10 +55,8 @@ public RoleRegistrationView(RoleRegistrationModel model,
selectedProfile = new MaterialTextField(Res.get("roles.registration.selectedProfile"));
selectedProfile.setEditable(false);

privateKey = new MaterialTextField(Res.get("roles.registration.privateKey"));
privateKey = new MaterialPasswordField(Res.get("roles.registration.privateKey"));
privateKey.setEditable(false);
privateKey.setIcon(AwesomeIcon.EYE_OPEN);
showPrivateKeyIcon = privateKey.getIconButton();

publicKey = new MaterialTextField(Res.get("roles.registration.publicKey"));
publicKey.setEditable(false);
Expand All @@ -81,8 +79,8 @@ public RoleRegistrationView(RoleRegistrationModel model,
@Override
protected void onViewAttached() {
selectedProfile.textProperty().bind(model.getSelectedProfileUserName());
privateKey.textProperty().bind(model.getPrivateKeyDisplay());
publicKey.textProperty().bind(model.getPublicKey());
privateKey.textProperty().bindBidirectional(model.getPrivateKey());
publicKey.textProperty().bindBidirectional(model.getPublicKey());
registrationButton.disableProperty().bind(model.getRegistrationDisabled());
removeRegistrationButton.managedProperty().bind(model.getRemoveRegistrationVisible());
removeRegistrationButton.visibleProperty().bind(model.getRemoveRegistrationVisible());
Expand All @@ -91,18 +89,13 @@ protected void onViewAttached() {
removeRegistrationButton.setOnAction(e -> controller.onRemoveRegistration());
learnMore.setOnAction(e -> controller.onLearnMore());
copyButton.setOnAction(e -> controller.onCopy());
showPrivateKeyIcon.setOnAction(e -> {
controller.onShowPrivateKey();
showPrivateKeyIcon.setVisible(false);
});
showPrivateKeyIcon.setVisible(true);
}

@Override
protected void onViewDetached() {
selectedProfile.textProperty().unbind();
privateKey.textProperty().unbind();
publicKey.textProperty().unbind();
privateKey.textProperty().unbindBidirectional(model.getPrivateKey());
publicKey.textProperty().unbindBidirectional(model.getPublicKey());
registrationButton.disableProperty().unbind();
removeRegistrationButton.managedProperty().unbind();
removeRegistrationButton.visibleProperty().unbind();
Expand All @@ -111,6 +104,5 @@ protected void onViewDetached() {
removeRegistrationButton.setOnAction(null);
learnMore.setOnAction(null);
copyButton.setOnAction(null);
showPrivateKeyIcon.setOnAction(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ public class UserProfileView extends View<HBox, UserProfileModel, UserProfileCon
private Subscription reputationScorePin, selectedChatUserIdentityPin;

public UserProfileView(UserProfileModel model, UserProfileController controller) {
super(new HBox(), model, controller);
super(new HBox(20), model, controller);

root.setSpacing(20);
root.setPadding(new Insets(40, 0, 0, 0));

roboIconImageView = new ImageView();
Expand Down
Loading