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

Show DAO news badge #2394

Merged
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
9 changes: 9 additions & 0 deletions core/src/main/java/bisq/core/user/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -121,6 +122,7 @@ public final class Preferences implements PersistedDataHost, BridgeAddressProvid
private final ObservableList<FiatCurrency> fiatCurrenciesAsObservable = FXCollections.observableArrayList();
private final ObservableList<CryptoCurrency> cryptoCurrenciesAsObservable = FXCollections.observableArrayList();
private final ObservableList<TradeCurrency> tradeCurrenciesAsObservable = FXCollections.observableArrayList();
private final ObservableMap<String, Boolean> dontShowAgainMapAsObservable = FXCollections.observableHashMap();

private final Storage<PreferencesPayload> storage;
private final BisqEnvironment bisqEnvironment;
Expand Down Expand Up @@ -251,6 +253,7 @@ public void readPersisted() {

tradeCurrenciesAsObservable.addAll(prefPayload.getFiatCurrencies());
tradeCurrenciesAsObservable.addAll(prefPayload.getCryptoCurrencies());
dontShowAgainMapAsObservable.putAll(getDontShowAgainMap());

// Override settings with options if set
if (useTorFlagFromOptions != null && !useTorFlagFromOptions.isEmpty()) {
Expand Down Expand Up @@ -300,11 +303,13 @@ else if (useTorFlagFromOptions.equals("true"))
public void dontShowAgain(String key, boolean dontShowAgain) {
prefPayload.getDontShowAgainMap().put(key, dontShowAgain);
persist();
dontShowAgainMapAsObservable.put(key, dontShowAgain);
}

public void resetDontShowAgain() {
prefPayload.getDontShowAgainMap().clear();
persist();
dontShowAgainMapAsObservable.clear();
}


Expand Down Expand Up @@ -629,6 +634,10 @@ public ObservableList<TradeCurrency> getTradeCurrenciesAsObservable() {
return tradeCurrenciesAsObservable;
}

public ObservableMap<String, Boolean> getDontShowAgainMapAsObservable() {
return dontShowAgainMapAsObservable;
}

public BlockChainExplorer getBlockChainExplorer() {
if (BisqEnvironment.getBaseCurrencyNetwork().isMainnet())
return prefPayload.getBlockChainExplorerMainNet();
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ shared.interval=Interval
shared.actions=Actions
shared.buyerUpperCase=Buyer
shared.sellerUpperCase=Seller
shared.new=NEW

####################################################################
# UI views
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/main/java/bisq/desktop/bisq.css
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ bg color of non edit textFields: fafafa
-fx-pref-height: 15;
}

.jfx-badge.new .badge-pane {
-fx-pref-width: 30;
}

.jfx-badge .label {
-fx-font-weight: bold;
-fx-font-size: 0.692em;
Expand Down
6 changes: 5 additions & 1 deletion desktop/src/main/java/bisq/desktop/main/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import javafx.geometry.Pos;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;

Expand Down Expand Up @@ -182,6 +183,8 @@ protected void initialize() {

JFXBadge portfolioButtonWithBadge = new JFXBadge(portfolioButton);
JFXBadge disputesButtonWithBadge = new JFXBadge(disputesButton);
JFXBadge daoButtonWithBadge = new JFXBadge(daoButton);
daoButtonWithBadge.getStyleClass().add("new");

root.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
Expand Down Expand Up @@ -246,7 +249,7 @@ protected void initialize() {
HBox.setHgrow(primaryNav, Priority.SOMETIMES);

HBox secondaryNav = new HBox(disputesButtonWithBadge, getNavigationSpacer(), settingsButton,
getNavigationSpacer(), accountButton, getNavigationSpacer(), daoButton);
getNavigationSpacer(), accountButton, getNavigationSpacer(), daoButtonWithBadge);
secondaryNav.getStyleClass().add("nav-secondary");
HBox.setHgrow(secondaryNav, Priority.SOMETIMES);

Expand Down Expand Up @@ -289,6 +292,7 @@ protected void initialize() {

setupBadge(portfolioButtonWithBadge, model.getNumPendingTrades(), model.getShowPendingTradesNotification());
setupBadge(disputesButtonWithBadge, model.getNumOpenDisputes(), model.getShowOpenDisputesNotification());
setupBadge(daoButtonWithBadge, new SimpleStringProperty(Res.get("shared.new")), model.getShowDaoUpdatesNotification());

navigation.addListener(viewPath -> {
if (viewPath.size() != 2 || viewPath.indexOf(MainView.class) != 0)
Expand Down
9 changes: 9 additions & 0 deletions desktop/src/main/java/bisq/desktop/main/MainViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import bisq.desktop.main.overlays.windows.TorNetworkSettingsWindow;
import bisq.desktop.main.overlays.windows.WalletPasswordWindow;
import bisq.desktop.main.overlays.windows.downloadupdate.DisplayUpdateDownloadWindow;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.util.GUIUtil;

import bisq.core.alert.PrivateNotificationManager;
Expand Down Expand Up @@ -89,6 +90,7 @@ public class MainViewModel implements ViewModel, BisqSetup.BisqSetupCompleteList
private final TradePresentation tradePresentation;
private final DisputePresentation disputePresentation;
private final MarketPricePresentation marketPricePresentation;
private final DaoPresentation daoPresentation;
private final P2PService p2PService;
private final TradeManager tradeManager;
private final Preferences preferences;
Expand Down Expand Up @@ -128,6 +130,7 @@ public MainViewModel(BisqSetup bisqSetup,
TradePresentation tradePresentation,
DisputePresentation disputePresentation,
MarketPricePresentation marketPricePresentation,
DaoPresentation daoPresentation,
P2PService p2PService,
TradeManager tradeManager,
Preferences preferences,
Expand All @@ -149,6 +152,7 @@ public MainViewModel(BisqSetup bisqSetup,
this.tradePresentation = tradePresentation;
this.disputePresentation = disputePresentation;
this.marketPricePresentation = marketPricePresentation;
this.daoPresentation = daoPresentation;
this.p2PService = p2PService;
this.tradeManager = tradeManager;
this.preferences = preferences;
Expand Down Expand Up @@ -222,6 +226,7 @@ public void onSetupComplete() {
setupBtcNumPeersWatcher();

marketPricePresentation.setup();
daoPresentation.setup();

if (DevEnv.isDevMode()) {
preferences.setShowOwnOffersInOfferBook(true);
Expand Down Expand Up @@ -563,4 +568,8 @@ IntegerProperty getMarketPriceUpdated() {
public ObservableList<PriceFeedComboBoxItem> getPriceFeedComboBoxItems() {
return marketPricePresentation.getPriceFeedComboBoxItems();
}

public BooleanProperty getShowDaoUpdatesNotification() {
return daoPresentation.getShowDaoUpdatesNotification();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import bisq.desktop.components.BsqAddressTextField;
import bisq.desktop.components.TitledGroupBg;
import bisq.desktop.main.dao.wallet.BsqBalanceUtil;
import bisq.desktop.main.presentation.DaoPresentation;
import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.GUIUtil;
import bisq.desktop.util.Layout;

import bisq.core.app.BisqEnvironment;
import bisq.core.btc.wallet.BsqWalletService;
import bisq.core.locale.Res;
import bisq.core.user.Preferences;
import bisq.core.util.BsqFormatter;

import bisq.common.util.Tuple3;
Expand All @@ -50,17 +52,20 @@ public class BsqReceiveView extends ActivatableView<GridPane, Void> {
private final BsqWalletService bsqWalletService;
private final BsqFormatter bsqFormatter;
private final BsqBalanceUtil bsqBalanceUtil;
private final Preferences preferences;
private int gridRow = 0;

///////////////////////////////////////////////////////////////////////////////////////////
// Constructor, lifecycle
///////////////////////////////////////////////////////////////////////////////////////////

@Inject
private BsqReceiveView(BsqWalletService bsqWalletService, BsqFormatter bsqFormatter, BsqBalanceUtil bsqBalanceUtil) {
private BsqReceiveView(BsqWalletService bsqWalletService, BsqFormatter bsqFormatter, BsqBalanceUtil bsqBalanceUtil,
Preferences preferences) {
this.bsqWalletService = bsqWalletService;
this.bsqFormatter = bsqFormatter;
this.bsqBalanceUtil = bsqBalanceUtil;
this.preferences = preferences;
}

@Override
Expand Down Expand Up @@ -111,6 +116,10 @@ public void initialize() {

@Override
protected void activate() {
// Hide dao new badge if user saw this page
if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
preferences.dontShowAgain(DaoPresentation.DAO_NEWS, true);

if (BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
bsqBalanceUtil.activate();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package bisq.desktop.main.presentation;

import bisq.core.app.BisqEnvironment;
import bisq.core.user.Preferences;

import javax.inject.Inject;

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

import javafx.collections.MapChangeListener;

public class DaoPresentation {

private final Preferences preferences;
public static final String DAO_NEWS = "daoNewsVersion0.9.4";

private final SimpleBooleanProperty showNotification = new SimpleBooleanProperty(false);

@Inject
public DaoPresentation(Preferences preferences) {
this.preferences = preferences;
preferences.getDontShowAgainMapAsObservable().addListener((MapChangeListener<? super String, ? super Boolean>) change -> {
if (change.getKey().equals(DAO_NEWS) && !BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq()) {
showNotification.set(!change.wasAdded());
}
});
}

public BooleanProperty getShowDaoUpdatesNotification() {
return showNotification;
}

public void setup() {
if (!BisqEnvironment.isDAOActivatedAndBaseCurrencySupportingBsq())
showNotification.set(preferences.showAgain(DAO_NEWS));
}
}