Removed webview

This commit is contained in:
Manfred Karrer 2015-12-28 16:09:52 +01:00
parent 5a6083fec3
commit 3bc1b6f669
13 changed files with 39 additions and 273 deletions

View File

@ -260,6 +260,7 @@ public class Encryption {
return keyPairGenerator.generateKey();
} catch (Throwable e) {
e.printStackTrace();
log.error(e.getMessage());
throw new RuntimeException("Couldn't generate key");
}
}

View File

@ -25,7 +25,6 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gson.*;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
import javafx.scene.web.WebEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -135,29 +134,6 @@ public class Utilities {
log.info("System load (nr. threads/used memory (MB)): " + Thread.activeCount() + "/" + used);
}
// Opens links with http and _blank in default web browser instead of webView
// WebView has not feature to open link in default browser, so we use the hack recommended here:
// https://stackoverflow.com/questions/15555510/javafx-stop-opening-url-in-webview-open-in-browser-instead
public static void setupWebViewPopupHandler(WebEngine webEngine) {
webEngine.setCreatePopupHandler(
config -> {
// grab the last hyperlink that has :hover pseudoclass
Object result = webEngine
.executeScript(
"var list = document.querySelectorAll( ':hover' );"
+ "for (i=list.length-1; i>-1; i--) "
+ "{ if ( list.item(i).getAttribute('href') ) "
+ "{ list.item(i).getAttribute('href'); break; } }");
if (result instanceof String && ((String) result).contains("http")) {
openWebPage((String) result);
return null;
} else {
return webEngine;
}
});
}
public static void openMail(String to, String subject, String body) {
try {
subject = URLEncoder.encode(subject, "UTF-8").replace("+", "%20");

View File

@ -107,6 +107,12 @@ Here are example program arguments for using regtest and using the Tor network:
$ java -jar gui/target/shaded.jar --bitcoin.network=regtest node.port=4442 --devTest=true --app.name=Bitsquare-Tor-Regtest-Bob
### 6. Enable unlimited Strength for cryptographic keys
Bitsquare uses 256 bit length keys which are still not permitted by default.
Get around that ridiculous fact by adding the missing [jars from Oracle](http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html).
Problems?
---------

View File

@ -53,7 +53,6 @@ import javafx.scene.layout.StackPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.bitcoinj.crypto.DRMWorkaround;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.controlsfx.dialog.Dialogs;
import org.reactfx.EventStreams;
@ -118,11 +117,8 @@ public class BitsquareApp extends Application {
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
DRMWorkaround.maybeDisableExportControls();
Security.addProvider(new BouncyCastleProvider());
BitsquareApp.primaryStage = primaryStage;
shutDownHandler = this::stop;

View File

@ -33,7 +33,9 @@ import io.bitsquare.gui.common.model.ViewModel;
import io.bitsquare.gui.components.BalanceTextField;
import io.bitsquare.gui.components.BalanceWithConfirmationTextField;
import io.bitsquare.gui.components.TxIdTextField;
import io.bitsquare.gui.popups.*;
import io.bitsquare.gui.popups.DisplayAlertMessagePopup;
import io.bitsquare.gui.popups.Popup;
import io.bitsquare.gui.popups.WalletPasswordPopup;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.p2p.P2PServiceListener;
@ -349,9 +351,23 @@ class MainViewModel implements ViewModel {
// tac
String text = "1. This software is experimental and provided \"as is\", without warranty of any kind, " +
"express or implied, including but not limited to the warranties of " +
"merchantability, fitness for a particular purpose and non-infringement.\n" +
"In no event shall the authors or copyright holders be liable for any claim, damages or other " +
"liability, whether in an action of contract, tort or otherwise, " +
"arising from, out of or in connection with the software or the use or other dealings in the software.\n\n" +
"2. The user is responsible to use the software in compliance with local laws.\n\n" +
"3. The user confirms that he has read and agreed to the rules defined in our " +
"Wiki regrading the dispute process.";
if (!preferences.getTacAccepted() && !BitsquareApp.DEV_MODE)
new TacPopup().url(WebViewPopup.getLocalUrl("tac")).onAgree(() -> preferences.setTacAccepted(true)).show();
new Popup().headLine("USER AGREEMENT")
.message(text)
.actionButtonText("I agree")
.closeButtonText("Quit")
.onAction(() -> preferences.setTacAccepted(true))
.onClose(() -> BitsquareApp.shutDownHandler.run())
.show();
// update nr of peers in footer
p2PService.getNumAuthenticatedPeers().addListener((observable, oldValue, newValue) -> updateP2pNetworkInfo());

View File

@ -25,8 +25,7 @@ import io.bitsquare.gui.main.MainView;
import io.bitsquare.gui.main.funds.reserved.ReservedView;
import io.bitsquare.gui.main.funds.transactions.TransactionsView;
import io.bitsquare.gui.main.funds.withdrawal.WithdrawalView;
import io.bitsquare.gui.popups.FirstTimeWebViewPopup;
import io.bitsquare.gui.popups.WebViewPopup;
import io.bitsquare.gui.popups.Popup;
import io.bitsquare.user.PopupId;
import io.bitsquare.user.Preferences;
import javafx.beans.value.ChangeListener;
@ -86,8 +85,14 @@ public class FundsView extends ActivatableViewAndModel<TabPane, Activatable> {
navigation.navigateTo(MainView.class, FundsView.class, TransactionsView.class);
String key = PopupId.TRADE_WALLET;
String text = "Bitsquare does not use a single application wallet, but dedicated wallets for every trade.\n" +
"Funding of the wallet will be done when needed, for instance when you create or take an offer.\n" +
"Withdrawing funds can be done after a trade is completed.\n" +
"Dedicated wallets help protect user privacy and prevent leaking information of previous trades to other\n" +
"traders.\n\n" +
"For more background information please see the Bitsquare FAQ on our web page.";
if (preferences.showAgain(key) && !BitsquareApp.DEV_MODE)
new FirstTimeWebViewPopup(preferences).id(key).url(WebViewPopup.getLocalUrl(key)).show();
new Popup().information(text).dontShowAgainId(key, preferences).show();
}
@Override

View File

@ -1,84 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare 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.
*
* Bitsquare 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.popups;
import io.bitsquare.user.Preferences;
import javafx.geometry.Insets;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.GridPane;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Optional;
import static io.bitsquare.gui.util.FormBuilder.addCheckBox;
public class FirstTimeWebViewPopup extends WebViewPopup {
private static final Logger log = LoggerFactory.getLogger(FirstTimeWebViewPopup.class);
private Preferences preferences;
private String id;
///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////
public FirstTimeWebViewPopup(Preferences preferences) {
this.preferences = preferences;
}
@Override
public FirstTimeWebViewPopup url(String url) {
super.url(url);
return this;
}
public FirstTimeWebViewPopup onClose(Runnable closeHandler) {
this.closeHandlerOptional = Optional.of(closeHandler);
return this;
}
public FirstTimeWebViewPopup id(String dontShowAgainId) {
this.id = dontShowAgainId;
return this;
}
@Override
protected void addHtmlContent() {
super.addHtmlContent();
CheckBox dontShowAgain = addCheckBox(gridPane, ++rowIndex, "Don't show again", 10);
dontShowAgain.setOnAction(e -> {
if (dontShowAgain.isSelected())
preferences.dontShowAgain(id);
});
closeButton = new Button("Close");
closeButton.setOnAction(e -> {
hide();
closeHandlerOptional.ifPresent(closeHandler -> closeHandler.run());
});
GridPane.setRowIndex(closeButton, ++rowIndex);
GridPane.setColumnIndex(closeButton, 1);
gridPane.getChildren().add(closeButton);
GridPane.setMargin(closeButton, new Insets(10, 0, 0, 0));
}
}

View File

@ -356,8 +356,8 @@ public class Popup {
}
protected void setTruncatedMessage() {
if (message != null && message.length() > 600)
truncatedMessage = message.substring(0, 600) + "...";
if (message != null && message.length() > 650)
truncatedMessage = message.substring(0, 650) + "...";
else
truncatedMessage = message;
}

View File

@ -1,57 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare 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.
*
* Bitsquare 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.popups;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.common.util.Tuple2;
import javafx.scene.control.Button;
import java.util.Optional;
import static io.bitsquare.gui.util.FormBuilder.add2ButtonsAfterGroup;
public class TacPopup extends WebViewPopup {
private Optional<Runnable> agreeHandlerOptional;
public TacPopup onAgree(Runnable agreeHandler) {
this.agreeHandlerOptional = Optional.of(agreeHandler);
return this;
}
@Override
public TacPopup url(String url) {
super.url(url);
return this;
}
@Override
protected void addHtmlContent() {
super.addHtmlContent();
Tuple2<Button, Button> tuple = add2ButtonsAfterGroup(gridPane, ++rowIndex, "I agree", "Quit");
Button agreeButton = tuple.first;
Button quitButton = tuple.second;
agreeButton.setOnAction(e -> {
agreeHandlerOptional.ifPresent(agreeHandler -> agreeHandler.run());
hide();
});
quitButton.setOnAction(e -> BitsquareApp.shutDownHandler.run());
}
}

View File

@ -1,90 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare 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.
*
* Bitsquare 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 Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.gui.popups;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.common.util.Utilities;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.web.WebView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WebViewPopup extends Popup {
private static final Logger log = LoggerFactory.getLogger(WebViewPopup.class);
protected WebView webView;
protected String url;
public static String getLocalUrl(String htmlFile) {
return WebViewPopup.class.getResource("/html/" + htmlFile + ".html").toExternalForm();
}
public WebViewPopup() {
}
@Override
public WebViewPopup show() {
width = 700;
webView = new WebView();
webView.setPrefHeight(0);
// open links with http and _blank in default web browser instead of webView
Utilities.setupWebViewPopupHandler(webView.getEngine());
webView.getEngine().documentProperty().addListener((observable, oldValue, newValue) -> {
// TODO At linux the heightInPx is screwed up.... need to find a better solution that that ugly html hack
String heightInPx = webView.getEngine()
.executeScript("window.getComputedStyle(document.body, null).getPropertyValue('height')").toString();
double webViewHeight = Math.min(Double.valueOf(heightInPx.replace("px", "")) * 1.2,
BitsquareApp.getPrimaryStage().getHeight() - 200);
double stageHeight = Math.min(webViewHeight + gridPane.getHeight(),
BitsquareApp.getPrimaryStage().getHeight());
webView.setPrefHeight(webViewHeight);
stage.setMinHeight(stageHeight);
stage.setMaxHeight(stageHeight);
centerPopup();
gridPane.setVisible(true);
});
createGridPane();
gridPane.setVisible(false);
addHtmlContent();
createPopup();
return this;
}
public WebViewPopup url(String url) {
this.url = url;
return this;
}
protected void addHtmlContent() {
webView.getEngine().load(url);
GridPane.setHalignment(webView, HPos.LEFT);
GridPane.setHgrow(webView, Priority.ALWAYS);
GridPane.setMargin(webView, new Insets(3, 0, 0, 0));
GridPane.setRowIndex(webView, ++rowIndex);
GridPane.setColumnIndex(webView, 0);
GridPane.setColumnSpan(webView, 2);
gridPane.getChildren().add(webView);
}
}

View File

@ -16,7 +16,7 @@
*/
body {
font-family: sans-serif;
font-family: sans-serif, Helvetica, Arial;
color: #333;
font-size: 14px;
line-height: 1.5;

View File

@ -55,8 +55,8 @@
</dict>
<!-- /Applications/Utilities/defaults write io.bitsquare.Bitsquare NSAppSleepDisabled -bool YES -->
<key>NSAppSleepDisabled</key>
<bool>YES</bool>
<!--<key>NSAppSleepDisabled</key>-->
<!--<bool>YES</bool>-->
</dict>
</plist>

View File

@ -3,7 +3,6 @@ package io.bitsquare.p2p.seed;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.bitsquare.app.BitsquareEnvironment;
import io.bitsquare.common.UserThread;
import org.bitcoinj.crypto.DRMWorkaround;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,8 +42,6 @@ public class SeedNodeMain {
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
DRMWorkaround.maybeDisableExportControls();
Security.addProvider(new BouncyCastleProvider());
UserThread.execute(() -> {