Skip to content

Commit

Permalink
Merge branch 'master' into rc_v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ManfredKarrer committed Apr 12, 2019
2 parents 0179cfc + 813365d commit cc255c2
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 56 deletions.
21 changes: 0 additions & 21 deletions desktop/src/main/java/bisq/desktop/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,17 @@
import bisq.desktop.main.offer.BuyOfferView;
import bisq.desktop.main.offer.SellOfferView;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.DaoLaunchWindow;
import bisq.desktop.main.portfolio.PortfolioView;
import bisq.desktop.main.settings.SettingsView;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Transitions;

import bisq.core.exceptions.BisqException;
import bisq.core.locale.GlobalSettings;
import bisq.core.locale.Res;
import bisq.core.user.DontShowAgainLookup;
import bisq.core.util.BSFormatter;

import bisq.common.Timer;
import bisq.common.UserThread;
import bisq.common.app.DevEnv;
import bisq.common.app.Version;
import bisq.common.util.Tuple2;
import bisq.common.util.Utilities;
Expand Down Expand Up @@ -81,7 +77,6 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment;

import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
Expand Down Expand Up @@ -388,22 +383,6 @@ protected Tooltip computeValue() {

transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> {
disposeSplashScreen();

if (DevEnv.isDaoActivated()) {
String daoLaunchPopupKey = "daoLaunchPopup";

if (DontShowAgainLookup.showAgain(daoLaunchPopupKey)) {
new DaoLaunchWindow()
.headLine(Res.get("popup.dao.launch.headline"))
.closeButtonText(Res.get("shared.dismiss"))
.actionButtonText(Res.get("shared.learnMore"))
.onAction(() -> GUIUtil.openWebPage("https://docs.bisq.network/dao.html"))
.buttonAlignment(HPos.CENTER)
.show();

DontShowAgainLookup.dontShowAgain(daoLaunchPopupKey, true);
}
}
});
}
});
Expand Down
48 changes: 45 additions & 3 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
import bisq.desktop.common.model.ViewModel;
import bisq.desktop.components.BalanceWithConfirmationTextField;
import bisq.desktop.components.TxIdTextField;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.notifications.NotificationCenter;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.overlays.windows.DaoLaunchWindow;
import bisq.desktop.main.overlays.windows.DisplayAlertMessageWindow;
import bisq.desktop.main.overlays.windows.TacWindow;
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
Expand Down Expand Up @@ -64,6 +66,8 @@

import com.google.inject.Inject;

import javafx.geometry.HPos;

import org.fxmisc.easybind.EasyBind;
import org.fxmisc.easybind.monadic.MonadicBinding;

Expand All @@ -79,7 +83,10 @@

import javafx.collections.ObservableList;

import java.util.Comparator;
import java.util.Date;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;

import lombok.Getter;
Expand Down Expand Up @@ -120,6 +127,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupCompleteList
private Timer checkNumberOfP2pNetworkPeersTimer;
@SuppressWarnings("FieldCanBeLocal")
private MonadicBinding<Boolean> tradesAndUIReady;
private Queue<Overlay> popupQueue = new PriorityQueue<>(Comparator.comparing(Overlay::getDisplayOrderPriority));


///////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -255,6 +263,9 @@ void onSplashScreenRemoved() {
// Delay that as we want to know what is the current path of the navigation which is set
// in MainView showAppScreen handler
notificationCenter.onAllServicesAndViewsInitialized();

maybeAddDaoLaunchWindowToQueue();
maybeShowPopupsFromQueue();
}

void onOpenDownloadWindow() {
Expand Down Expand Up @@ -342,9 +353,10 @@ private void setupHandlers() {
.show());
bisqSetup.setDisplayLocalhostHandler(key -> {
if (!DevEnv.isDevMode()) {
new Popup<>().backgroundInfo(Res.get("popup.bitcoinLocalhostNode.msg"))
.dontShowAgainId(key)
.show();
Overlay popup = new Popup<>().backgroundInfo(Res.get("popup.bitcoinLocalhostNode.msg"))
.dontShowAgainId(key);
popup.setDisplayOrderPriority(5);
popupQueue.add(popup);
}
});

Expand Down Expand Up @@ -603,4 +615,34 @@ public ObservableList<PriceFeedComboBoxItem> getPriceFeedComboBoxItems() {
public BooleanProperty getShowDaoUpdatesNotification() {
return daoPresentation.getShowDaoUpdatesNotification();
}

private void maybeAddDaoLaunchWindowToQueue() {
if (DevEnv.isDaoActivated()) {
String daoLaunchPopupKey = "daoLaunchPopup";
if (DontShowAgainLookup.showAgain(daoLaunchPopupKey)) {
DaoLaunchWindow daoLaunchWindow = new DaoLaunchWindow()
.headLine(Res.get("popup.dao.launch.headline"))
.closeButtonText(Res.get("shared.dismiss"))
.actionButtonText(Res.get("shared.learnMore"))
.onAction(() -> GUIUtil.openWebPage("https://docs.bisq.network/dao.html"))
.buttonAlignment(HPos.CENTER);
daoLaunchWindow.setDisplayOrderPriority(1);
popupQueue.add(daoLaunchWindow);

DontShowAgainLookup.dontShowAgain(daoLaunchPopupKey, true);
}
}
}

private void maybeShowPopupsFromQueue() {
if (!popupQueue.isEmpty()) {
Overlay overlay = popupQueue.poll();
overlay.getIsHiddenProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
UserThread.runAfter(this::maybeShowPopupsFromQueue, 2);
}
});
overlay.show();
}
}
}
15 changes: 14 additions & 1 deletion desktop/src/main/java/bisq/desktop/main/overlays/Overlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
import javafx.geometry.Insets;
import javafx.geometry.Pos;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;

import javafx.collections.ObservableList;
Expand All @@ -84,6 +86,8 @@
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
Expand Down Expand Up @@ -134,7 +138,6 @@ protected enum Type {
}

protected final static double DEFAULT_WIDTH = 668;

protected Stage stage;
protected GridPane gridPane;
protected Pane owner;
Expand All @@ -147,6 +150,15 @@ protected enum Type {
private boolean showBusyAnimation;
protected boolean hideCloseButton;
protected boolean isDisplayed;

@Getter
protected BooleanProperty isHiddenProperty = new SimpleBooleanProperty();

// Used when a priority queue is used for displaying order of popups. Higher numbers mean lower priority
@Setter
@Getter
protected Integer displayOrderPriority = Integer.MAX_VALUE;

protected boolean useAnimation = true;

protected Label headlineIcon, headLineLabel, messageLabel;
Expand Down Expand Up @@ -207,6 +219,7 @@ public void hide() {
animateHide();
}
isDisplayed = false;
isHiddenProperty.set(true);
}

protected void animateHide() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,33 @@

@Slf4j
public class DaoLaunchWindow extends Overlay<DaoLaunchWindow> {
private static final double DURATION = 400;

private ImageView sectionScreenshot;
private ToggleGroup sectionButtonsGroup;
private ArrayList<Section> sections = new ArrayList<>();
private IntegerProperty currentSectionIndex = new SimpleIntegerProperty(0);
private Label sectionDescriptionLabel;
private Timeline autoPlayTimeline;
private Timeline slideTimeline;
private Timeline autoPlayTimeline, slideInTimeline, slideOutTimeline;
private Section selectedSection;
private boolean showSlideInAnimation = true;


///////////////////////////////////////////////////////////////////////////////////////////
// Public API
///////////////////////////////////////////////////////////////////////////////////////////


@Override
public void show() {
width = 1003;
super.show();
}


///////////////////////////////////////////////////////////////////////////////////////////
// Protected
///////////////////////////////////////////////////////////////////////////////////////////


@Override
protected void createGridPane() {
super.createGridPane();
Expand All @@ -110,7 +112,6 @@ protected void addHeadLine() {

@Override
protected void addMessage() {

sections.add(new Section(Res.get("popup.dao.launch.governance.title"), Res.get("popup.dao.launch.governance"),
"dao-screenshot-governance"));
sections.add(new Section(Res.get("popup.dao.launch.trading.title"), Res.get("popup.dao.launch.trading"),
Expand All @@ -123,20 +124,18 @@ protected void addMessage() {

addListeners();

createSlideAnimation();
createSlideAnimations();
startAutoSectionChange();
}

@Override
protected void onShow() {
display();

Timeline timeline = new Timeline(new KeyFrame(
Duration.millis(500),
ae -> slideTimeline.playFromStart()
));

timeline.play();
new Timeline(new KeyFrame(
Duration.millis(300),
ae -> slideInTimeline.playFrom(Duration.millis(DURATION))
)).play();
}

@Override
Expand All @@ -154,6 +153,7 @@ private void addListeners() {
currentSectionIndex.addListener((observable, oldValue, newValue) -> {
if (!newValue.equals(oldValue)) {
ObservableList<Toggle> toggles = sectionButtonsGroup.getToggles();

Toggle toggleToSelect = toggles.get(newValue.intValue() % toggles.size());
if (sectionButtonsGroup.getSelectedToggle() != toggleToSelect)
sectionButtonsGroup.selectToggle(toggleToSelect);
Expand All @@ -165,7 +165,10 @@ private void addListeners() {
int index = ((SectionButton) newValue).index;
selectedSection = sections.get(index);

slideTimeline.playFromStart();
if (showSlideInAnimation)
slideInTimeline.playFromStart();
else
slideOutTimeline.playFromStart();

currentSectionIndex.set(index);
}
Expand All @@ -183,7 +186,6 @@ private void startAutoSectionChange() {
}

private void createSlideControls() {

sectionButtonsGroup = new ToggleGroup();

HBox slideButtons = new HBox();
Expand Down Expand Up @@ -213,10 +215,7 @@ private void createContent() {
Button prevButton = getIconButton(MaterialDesignIcon.ARROW_LEFT, "dao-launch-paging-button");
prevButton.setOnAction(event -> {
autoPlayTimeline.stop();
if (currentSectionIndex.get() == 0)
currentSectionIndex.set(sections.size() - 1);
else
currentSectionIndex.set(currentSectionIndex.get() - 1);
goToPrevSection();
});
Button nextButton = getIconButton(MaterialDesignIcon.ARROW_RIGHT, "dao-launch-paging-button");
nextButton.setOnAction(event -> {
Expand Down Expand Up @@ -250,24 +249,39 @@ private void createContent() {
gridPane.getChildren().add(slidingContentWithPagingBox);
}

private void goToPrevSection() {
showSlideInAnimation = false;

if (currentSectionIndex.get() == 0)
currentSectionIndex.set(sections.size() - 1);
else
currentSectionIndex.set(currentSectionIndex.get() - 1);
}

private void goToNextSection() {
showSlideInAnimation = true;
currentSectionIndex.set(currentSectionIndex.get() + 1);
}

private void createSlideAnimation() {
slideTimeline = new Timeline();
private void createSlideAnimations() {
slideInTimeline = new Timeline();
slideOutTimeline = new Timeline();

double imageWidth = 534;

double duration = 400;
createSlideAnimation(slideInTimeline, imageWidth);
createSlideAnimation(slideOutTimeline, -imageWidth);
}

private void createSlideAnimation(Timeline timeline, double imageWidth) {
Interpolator interpolator = Interpolator.EASE_OUT;
ObservableList<KeyFrame> keyFrames = slideTimeline.getKeyFrames();
ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();

double imageWidth = 534;
double endX = -imageWidth;
keyFrames.add(new KeyFrame(Duration.millis(0),
new KeyValue(sectionScreenshot.opacityProperty(), 1, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), 0, interpolator)));
keyFrames.add(new KeyFrame(Duration.millis(duration),
keyFrames.add(new KeyFrame(Duration.millis(DURATION),
event -> {
sectionDescriptionLabel.setText(selectedSection.description);
sectionScreenshot.setId(selectedSection.imageId);
Expand All @@ -277,22 +291,19 @@ private void createSlideAnimation() {

double startX = imageWidth;

keyFrames.add(new KeyFrame(Duration.millis(duration),
keyFrames.add(new KeyFrame(Duration.millis(DURATION),
new KeyValue(sectionScreenshot.opacityProperty(), 0, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), startX, interpolator)));
duration += 400;
keyFrames.add(new KeyFrame(Duration.millis(duration),
keyFrames.add(new KeyFrame(Duration.millis(DURATION * 2),
new KeyValue(sectionScreenshot.opacityProperty(), 1, interpolator),
new KeyValue(sectionScreenshot.translateXProperty(), 0, interpolator)));

}

protected double getDuration(double duration) {
return useAnimation && GlobalSettings.getUseAnimations() ? duration : 1;
}

private class SectionButton extends AutoTooltipToggleButton {

int index;

SectionButton(String title, int index) {
Expand All @@ -304,9 +315,11 @@ private class SectionButton extends AutoTooltipToggleButton {

this.selectedProperty().addListener((ov, oldValue, newValue) -> this.setMouseTransparent(newValue));

this.setOnAction(event -> autoPlayTimeline.stop());
this.setOnAction(event -> {
autoPlayTimeline.stop();
showSlideInAnimation = true;
});
}

}

private class Section {
Expand Down

0 comments on commit cc255c2

Please sign in to comment.