Temporary delete QR code scanner

used for mobile notification pairing because of missing current macOS support by currently used webcam library
This commit is contained in:
Christoph Atteneder 2021-04-20 10:20:58 +02:00
parent f862fc2097
commit b5beea58db
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
6 changed files with 2 additions and 228 deletions

View File

@ -73,7 +73,6 @@ configure(subprojects) {
protocVersion = protobufVersion
pushyVersion = '0.13.2'
qrgenVersion = '1.3'
sarxosVersion = '0.3.12'
slf4jVersion = '1.7.30'
sparkVersion = '2.5.2'
springBootVersion = '1.5.10.RELEASE'
@ -412,7 +411,6 @@ configure(project(':desktop')) {
compile "de.jensd:fontawesomefx-materialdesignfont:$fontawesomefxMaterialdesignfontVersion"
compile "com.google.guava:guava:$guavaVersion"
compile "com.googlecode.jcsv:jcsv:$jcsvVersion"
compile "com.github.sarxos:webcam-capture:$sarxosVersion"
compile "org.openjfx:javafx-controls:$javafxVersion:$os"
compile "org.openjfx:javafx-fxml:$javafxVersion:$os"
compile "org.openjfx:javafx-swing:$javafxVersion:$os"

View File

@ -311,9 +311,7 @@ task packageInstallers {
" libprism_es2.dylib" +
" libdecora_sse.dylib" +
" libprism_sw.dylib" +
" org/bridj/lib/darwin_universal/libbridj.dylib" +
" META-INF/native/libio_grpc_netty_shaded_netty_tcnative_osx_x86_64.jnilib" +
" com/github/sarxos/webcam/ds/buildin/lib/darwin_universal/libOpenIMAJGrabber.dylib"
" META-INF/native/libio_grpc_netty_shaded_netty_tcnative_osx_x86_64.jnilib"
)
// macOS step 1: Sign dylibs and replace them in the shadow jar

View File

@ -23,7 +23,6 @@ import bisq.desktop.components.InfoInputTextField;
import bisq.desktop.components.InputTextField;
import bisq.desktop.main.PriceUtil;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.WebCamWindow;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Layout;
@ -90,15 +89,12 @@ public class MobileNotificationsView extends ActivatableView<GridPane, Void> {
private final MarketAlerts marketAlerts;
private final MobileNotificationService mobileNotificationService;
private WebCamWindow webCamWindow;
private QrCodeReader qrCodeReader;
private TextField tokenInputTextField;
private InputTextField priceAlertHighInputTextField, priceAlertLowInputTextField, marketAlertTriggerInputTextField;
private ToggleButton useSoundToggleButton, tradeToggleButton, marketToggleButton, priceToggleButton;
private ComboBox<TradeCurrency> currencyComboBox;
private ComboBox<PaymentAccount> paymentAccountsComboBox;
private Button downloadButton, webCamButton, noWebCamButton, eraseButton, setPriceAlertButton,
private Button downloadButton, eraseButton, setPriceAlertButton,
removePriceAlertButton, addMarketAlertButton, manageAlertsButton /*,testMsgButton*/;
private ChangeListener<Boolean> useSoundCheckBoxListener, tradeCheckBoxListener, marketCheckBoxListener,
@ -149,8 +145,6 @@ public class MobileNotificationsView extends ActivatableView<GridPane, Void> {
// setup
tokenInputTextField.textProperty().addListener(tokenInputTextFieldListener);
downloadButton.setOnAction(e -> onDownload());
webCamButton.setOnAction(e -> onOpenWebCam());
noWebCamButton.setOnAction(e -> onNoWebCam());
// testMsgButton.setOnAction(e -> onSendTestMsg());
eraseButton.setOnAction(e -> onErase());
@ -203,8 +197,6 @@ public class MobileNotificationsView extends ActivatableView<GridPane, Void> {
// setup
tokenInputTextField.textProperty().removeListener(tokenInputTextFieldListener);
downloadButton.setOnAction(null);
webCamButton.setOnAction(null);
noWebCamButton.setOnAction(null);
//testMsgButton.setOnAction(null);
eraseButton.setOnAction(null);
@ -243,45 +235,6 @@ public class MobileNotificationsView extends ActivatableView<GridPane, Void> {
GUIUtil.openWebPage("https://bisq.network/downloads");
}
private void onOpenWebCam() {
webCamButton.setDisable(true);
log.info("Start WebCamLauncher");
new WebCamLauncher(webCam -> {
log.info("webCam available");
webCamWindow = new WebCamWindow(webCam.getViewSize().width, webCam.getViewSize().height)
.onClose(() -> {
webCamButton.setDisable(false);
qrCodeReader.close();
});
webCamWindow.show();
qrCodeReader = new QrCodeReader(webCam, webCamWindow.getImageView(), qrCode -> {
log.info("Qr code available");
webCamWindow.hide();
webCamButton.setDisable(false);
reset();
tokenInputTextField.setText(qrCode);
updateMarketAlertFields();
updatePriceAlertFields();
});
}, throwable -> {
if (throwable instanceof NoWebCamFoundException) {
new Popup().warning(Res.get("account.notifications.noWebCamFound.warning")).show();
webCamButton.setDisable(false);
onNoWebCam();
} else {
log.error(throwable.toString());
new Popup().error(throwable.toString()).show();
}
});
}
private void onNoWebCam() {
setPairingTokenFieldsVisible();
noWebCamButton.setManaged(false);
noWebCamButton.setVisible(false);
}
private void onErase() {
try {
mobileNotificationService.sendEraseMessage();
@ -401,18 +354,10 @@ public class MobileNotificationsView extends ActivatableView<GridPane, Void> {
Res.get("account.notifications.download.label"),
Layout.TWICE_FIRST_ROW_DISTANCE);
Tuple3<Label, Button, Button> tuple = addTopLabel2Buttons(root, ++gridRow,
Res.get("account.notifications.webcam.label"),
Res.get("account.notifications.webcam.button"), Res.get("account.notifications.noWebcam.button"), 0);
webCamButton = tuple.second;
noWebCamButton = tuple.third;
tokenInputTextField = addInputTextField(root, ++gridRow,
Res.get("account.notifications.email.label"));
tokenInputTextField.setPromptText(Res.get("account.notifications.email.prompt"));
tokenInputTextFieldListener = (observable, oldValue, newValue) -> applyKeyAndToken(newValue);
tokenInputTextField.setManaged(false);
tokenInputTextField.setVisible(false);
/*testMsgButton = FormBuilder.addTopLabelButton(root, ++gridRow, Res.get("account.notifications.testMsg.label"),
Res.get("account.notifications.testMsg.title")).second;

View File

@ -1,101 +0,0 @@
/*
* 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.main.account.content.notifications;
import bisq.common.UserThread;
import javafx.scene.image.ImageView;
import javafx.scene.image.WritableImage;
import javafx.geometry.Point3D;
import java.awt.image.BufferedImage;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
import com.github.sarxos.webcam.Webcam;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
import javafx.embed.swing.SwingFXUtils;
@Slf4j
// Must not be UI thread
class QrCodeReader extends Thread {
private final Webcam webCam;
private final ImageView imageView;
private final Consumer<String> resultHandler;
private boolean isRunning;
QrCodeReader(Webcam webCam, ImageView imageView, Consumer<String> resultHandler) {
this.webCam = webCam;
this.imageView = imageView;
this.resultHandler = resultHandler;
start();
}
@Override
public void run() {
try {
if (!webCam.isOpen())
webCam.open();
isRunning = true;
Result result;
BufferedImage bufferedImage;
while (isRunning) {
bufferedImage = webCam.getImage();
if (bufferedImage != null) {
WritableImage writableImage = SwingFXUtils.toFXImage(bufferedImage, null);
imageView.setImage(writableImage);
imageView.setRotationAxis(new Point3D(0.0, 1.0, 0.0));
imageView.setRotate(180.0);
LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
result = new MultiFormatReader().decode(bitmap);
isRunning = false;
String qrCode = result.getText();
UserThread.execute(() -> resultHandler.accept(qrCode));
} catch (NotFoundException ignore) {
// No qr code in image...
}
}
}
} catch (Throwable t) {
log.error(t.toString());
} finally {
webCam.close();
}
}
public void close() {
isRunning = false;
}
}

View File

@ -1,64 +0,0 @@
/*
* 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.main.account.content.notifications;
import bisq.common.UserThread;
import bisq.common.handlers.ExceptionHandler;
import java.awt.Dimension;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
import com.github.sarxos.webcam.Webcam;
@Slf4j
// Must not be UI thread
class WebCamLauncher extends Thread {
private final Consumer<Webcam> resultHandler;
private final ExceptionHandler exceptionHandler;
WebCamLauncher(Consumer<Webcam> resultHandler, ExceptionHandler exceptionHandler) {
this.resultHandler = resultHandler;
this.exceptionHandler = exceptionHandler;
start();
}
@Override
public void run() {
try {
Webcam webCam = Webcam.getDefault(1000); // one second timeout - the default is too long
if (webCam != null) {
Dimension[] sizes = webCam.getViewSizes();
Dimension size = sizes[sizes.length - 1]; // the largest size
webCam.setViewSize(size);
UserThread.execute(() -> resultHandler.accept(webCam));
} else {
UserThread.execute(() -> exceptionHandler.handleException(new NoWebCamFoundException("No webcam found.")));
}
} catch (TimeoutException e) {
log.error(e.toString());
UserThread.execute(() -> exceptionHandler.handleException(e));
}
}
}

View File

@ -31,7 +31,6 @@ dependencyVerification {
'com.github.bisq-network:bitcoinj:65ed08fa5777ea4a08599bdd575e7dc1f4ba2d4d5835472551439d6f6252e68a',
'com.github.bisq-network:jsonrpc4j:842b4a660440ef53cd436da2e21c3e1fed939b620a3fc7542307deb3e77fdeb6',
'com.github.ravn:jsocks:3c71600af027b2b6d4244e4ad14d98ff2352a379410daebefff5d8cd48d742a4',
'com.github.sarxos:webcam-capture:d960b7ea8ec3ddf2df0725ef214c3fccc9699ea7772df37f544e1f8e4fd665f6',
'com.google.android:annotations:ba734e1e84c09d615af6a09d33034b4f0442f8772dec120efb376d86a565ae15',
'com.google.api.grpc:proto-google-common-protos:bd60cd7a423b00fb824c27bdd0293aaf4781be1daba6ed256311103fb4b84108',
'com.google.code.findbugs:jsr305:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
@ -47,7 +46,6 @@ dependencyVerification {
'com.google.zxing:javase:0ec23e2ec12664ddd6347c8920ad647bb3b9da290f897a88516014b56cc77eb9',
'com.googlecode.jcsv:jcsv:73ca7d715e90c8d2c2635cc284543b038245a34f70790660ed590e157b8714a2',
'com.jfoenix:jfoenix:8060235fec5eb49617ec8d81d379e8c945f6cc722d0645e97190045100de2084',
'com.nativelibs4java:bridj:101bcd9b6637e6bc16e56deb3daefba62b1f5e8e9e37e1b3e56e3b5860d659cf',
'commons-codec:commons-codec:61f7a3079e92b9fdd605238d0295af5fd11ac411a0a0af48deace1f6c5ffa072',
'commons-io:commons-io:f877d304660ac2a142f3865badfc971dec7ed73c747c7f8d5d2f5139ca736513',
'commons-logging:commons-logging:daddea1ea0be0f56978ab3006b8ac92834afeefbd9b7e4e6316fca57df0fa636',