Improve popups

This commit is contained in:
Manfred Karrer 2015-11-16 17:52:01 +01:00
parent cb8761b74e
commit 6f523e02dd
14 changed files with 71 additions and 38 deletions

View File

@ -22,7 +22,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
import javax.crypto.*;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -51,7 +54,7 @@ public class Encryption {
KeyPair keyPair = keyPairGenerator.genKeyPair();
log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts);
return keyPair;
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("Could not create key.");
}
@ -67,8 +70,7 @@ public class Encryption {
Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
return cipher.doFinal(payload);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException
| BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new CryptoException(e);
}
@ -79,8 +81,7 @@ public class Encryption {
Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
return cipher.doFinal(encryptedPayload);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException
| BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) {
} catch (Throwable e) {
throw new CryptoException(e);
}
}
@ -113,7 +114,7 @@ public class Encryption {
}
}
}
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("Could not create hmac");
}
@ -125,7 +126,7 @@ public class Encryption {
try {
byte[] hmacTest = getHmac(message, secretKey);
return Arrays.equals(hmacTest, hmac);
} catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchProviderException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("Could not create cipher");
}
@ -176,8 +177,7 @@ public class Encryption {
Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
return cipher.doFinal(payload);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException
| BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new CryptoException("Couldn't encrypt payload");
}
@ -188,8 +188,7 @@ public class Encryption {
Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
return cipher.doFinal(encryptedPayload);
} catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException
| BadPaddingException | IllegalBlockSizeException | NoSuchProviderException e) {
} catch (Throwable e) {
// errors when trying to decrypt foreign messages are normal
throw new CryptoException(e);
}
@ -259,7 +258,7 @@ public class Encryption {
KeyGenerator keyPairGenerator = KeyGenerator.getInstance(SYM_CIPHER, "BC");
keyPairGenerator.init(256);
return keyPairGenerator.generateKey();
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException("Couldn't generate key");
}

View File

@ -472,9 +472,10 @@ public class TradeWalletService {
// Check if OP_RETURN output with contract hash matches the one from the offerer
TransactionOutput contractHashOutput = new TransactionOutput(params, offerersDepositTx, Coin.ZERO,
ScriptBuilder.createOpReturnScript(contractHash).getProgram());
log.debug("contractHashOutput " + contractHashOutput);
TransactionOutput offerersContractHashOutput = offerersDepositTx.getOutputs().get(1);
if (!offerersContractHashOutput.equals(contractHashOutput))
log.debug("offerersContractHashOutput " + offerersContractHashOutput);
if (!offerersContractHashOutput.getScriptPubKey().equals(contractHashOutput.getScriptPubKey()))
throw new TransactionVerificationException("Offerers transaction output for the contract hash is not matching takers version.");
// Add all outputs from offerersDepositTx to depositTx

View File

@ -41,6 +41,11 @@ public class SignAndPublishDepositTxAsBuyer extends TradeTask {
try {
runInterceptHook();
log.debug("getContractAsJson");
log.debug("----------");
log.debug(trade.getContractAsJson());
log.debug("----------");
byte[] contractHash = Hash.getHash(trade.getContractAsJson());
trade.setContractHash(contractHash);
processModel.getTradeWalletService().takerSignsAndPublishesDepositTx(

View File

@ -44,6 +44,7 @@ public class SignAndPublishDepositTxAsSeller extends TradeTask {
log.debug("----------");
log.debug(trade.getContractAsJson());
log.debug("----------");
byte[] contractHash = Hash.getHash(trade.getContractAsJson());
trade.setContractHash(contractHash);
processModel.getTradeWalletService().takerSignsAndPublishesDepositTx(

View File

@ -348,7 +348,13 @@ public class Preferences implements Serializable {
}
public boolean showAgain(String key) {
return getShowAgainMap().containsKey(key) && getShowAgainMap().get(key);
// if we add new and those are not in our stored map we display by default the new popup
if (!getShowAgainMap().containsKey(key)) {
showAgainMap.put(key, true);
storage.queueUpForSave();
}
return showAgainMap.get(key);
}
public boolean getTacAccepted() {

View File

@ -354,4 +354,8 @@ class CreateOfferDataModel extends ActivatableDataModel {
public boolean getShowPlaceOfferConfirmation() {
return preferences.getShowPlaceOfferConfirmation();
}
public Preferences getPreferences() {
return preferences;
}
}

View File

@ -20,6 +20,7 @@ package io.bitsquare.gui.main.offer.createoffer;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.util.Tuple2;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.gui.Navigation;
@ -36,6 +37,7 @@ import io.bitsquare.gui.main.account.settings.AccountSettingsView;
import io.bitsquare.gui.main.offer.OfferView;
import io.bitsquare.gui.main.portfolio.PortfolioView;
import io.bitsquare.gui.main.portfolio.openoffer.OpenOffersView;
import io.bitsquare.gui.main.portfolio.pendingtrades.PendingTradesView;
import io.bitsquare.gui.popups.OfferDetailsPopup;
import io.bitsquare.gui.popups.Popup;
import io.bitsquare.gui.util.BSFormatter;
@ -59,6 +61,7 @@ import javafx.util.StringConverter;
import org.controlsfx.control.PopOver;
import javax.inject.Inject;
import java.util.concurrent.TimeUnit;
import static io.bitsquare.gui.util.FormBuilder.*;
import static javafx.beans.binding.Bindings.createStringBinding;
@ -428,11 +431,17 @@ public class CreateOfferView extends ActivatableViewAndModel<AnchorPane, CreateO
navigation.navigateTo(MainView.class, PortfolioView.class, OpenOffersView.class);
}
if (newValue)
new Popup().headLine(BSResources.get("createOffer.success.headline"))
.message(BSResources.get("createOffer.success.info"))
.onClose(() -> close())
.show();
if (newValue) {
UserThread.runAfter(() -> {
new Popup().headLine(BSResources.get("createOffer.success.headline"))
.message(BSResources.get("createOffer.success.info"))
.onClose(() -> {
navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class);
close();
})
.show();
}, 300, TimeUnit.MILLISECONDS);
}
};
}

View File

@ -318,4 +318,8 @@ class TakeOfferDataModel extends ActivatableDataModel {
public List<Arbitrator> getArbitrators() {
return user.getAcceptedArbitrators();
}
public Preferences getPreferences() {
return preferences;
}
}

View File

@ -20,6 +20,7 @@ package io.bitsquare.gui.main.offer.takeoffer;
import de.jensd.fx.fontawesome.AwesomeDude;
import de.jensd.fx.fontawesome.AwesomeIcon;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.util.Tuple2;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.gui.Navigation;
@ -63,6 +64,7 @@ import org.fxmisc.easybind.Subscription;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import static io.bitsquare.gui.util.FormBuilder.*;
import static javafx.beans.binding.Bindings.createStringBinding;
@ -220,13 +222,16 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class);
}
if (newValue && model.getTrade() != null && model.getTrade().errorMessageProperty().get() == null)
new Popup().information(BSResources.get("takeOffer.success.info"))
.onClose(() -> {
navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class);
close();
})
.show();
if (newValue && model.getTrade() != null && model.getTrade().errorMessageProperty().get() == null) {
UserThread.runAfter(() -> {
new Popup().information(BSResources.get("takeOffer.success.info"))
.onClose(() -> {
navigation.navigateTo(MainView.class, PortfolioView.class, PendingTradesView.class);
close();
})
.show();
}, 300, TimeUnit.MILLISECONDS);
}
});
if (model.getPossiblePaymentAccounts().size() > 1) {
@ -318,8 +323,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
Offer offer = model.getOffer();
if (model.getShowTakeOfferConfirmation()) {
offerDetailsPopup.onTakeOffer(() -> model.onTakeOffer()).show(offer);
}
else {
} else {
if (model.hasAcceptedArbitrators()) {
model.onTakeOffer();
} else {

View File

@ -73,8 +73,8 @@ public class StartPaymentView extends TradeStepDetailsView {
if (preferences.showAgain(key) && !BitsquareApp.DEV_MODE) {
new Popup().information("You need to transfer now the agreed amount to your trading partner.\n" +
"Please take care that you use the exact data presented here, including the reference text\n" +
"Please do not click the \"Payment started\" button if you have before you have completed the transfer.\n" +
"Take care that you make the transfer soon to not miss the exceed trading period.")
"Please do not click the \"Payment started\" button before you have completed the transfer.\n" +
"Take care that you make the transfer soon to not exceed the trading period.")
.onClose(() -> preferences.dontShowAgain(key))
.show();
}

View File

@ -193,7 +193,7 @@ public class OfferDetailsPopup extends Popup {
});
CheckBox checkBox = addCheckBox(gridPane, ++rowIndex, "Don't show again", 5);
checkBox.setPadding(new Insets(10, 0, 15, 0));
checkBox.setPadding(new Insets(20, 0, 25, 0));
checkBox.setSelected(!preferences.getShowTakeOfferConfirmation());
checkBox.setOnAction(e -> preferences.setShowTakeOfferConfirmation(!checkBox.isSelected()));
} else {

View File

@ -52,7 +52,7 @@ public class WebViewPopup extends Popup {
webView.getEngine().documentProperty().addListener((observable, oldValue, newValue) -> {
String heightInPx = webView.getEngine()
.executeScript("window.getComputedStyle(document.body, null).getPropertyValue('height')").toString();
double height = Double.valueOf(heightInPx.replace("px", ""));
double height = Double.valueOf(heightInPx.replace("px", "")) * 1.2;
webView.setPrefHeight(height);
stage.setMinHeight(height + gridPane.getHeight());
centerPopup();

View File

@ -19,7 +19,7 @@ body {
font-family: sans-serif;
color: #333;
font-size: 14px;
line-height: 2;
line-height: 1.5;
}
a {

View File

@ -76,7 +76,7 @@ createOffer.advancedBox.county=Payments account country:
createOffer.advancedBox.info=Your trading partners must fulfill your offer restrictions. You can edit the accepted countries, languages and arbitrators in the settings. The payments account details are used from your current selected payments account (if you have multiple payments accounts).
createOffer.success.headline=Your offer has been published to the offerbook.
createOffer.success.info=In the portfolio screen you can manage your open offers.
createOffer.success.info=You can manage your open offers in the \"Portfolio\" screen under \"Open offers\".
createOffer.error.message=An error occurred when placing the offer.\n\n{0}
@ -136,8 +136,8 @@ takeOffer.advancedBox.info=These are the offer restrictions your trading partner
takeOffer.success.headline=Your have successfully published the deposit.
takeOffer.success.info=You need to wait now for the Bitcoin buyer to transfer the money to you. \nYou will get a \
notification when he has started the EUR payment. You can see the status of your trade in the <portfolio> screen \
under open trades.
notification when he has started the EUR payment. You can see the status of your trade in the \"Portfolio\" screen \
under \"Open trades\".
takeOffer.error.message=An error occurred when taking the offer.\n\n{0}
# Payment methods