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

Add supported languages icon in offer message #2250

Merged
merged 3 commits into from
Jun 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public final class BisqEasyOfferbookController extends ChatController<BisqEasyOf
private final FavouriteMarketsService favouriteMarketsService;
private final BisqEasyOfferbookModel bisqEasyOfferbookModel;
private final SetChangeListener<Market> favouriteMarketsListener;
private Pin offerOnlySettingsPin, bisqEasyPrivateTradeChatChannelsPin, selectedChannelPin,
marketPriceByCurrencyMapPin, favouriteMarketsPin, offerMessagesPin, showBuyOffersPin,
showOfferListExpandedSettingsPin, showMarketSelectionListCollapsedSettingsPin;
private Pin bisqEasyPrivateTradeChatChannelsPin, selectedChannelPin, marketPriceByCurrencyMapPin,
favouriteMarketsPin, offerMessagesPin, showBuyOffersPin, showOfferListExpandedSettingsPin,
showMarketSelectionListCollapsedSettingsPin;
private Subscription marketSelectorSearchPin, selectedMarketFilterPin, selectedMarketSortTypePin,
showBuyOffersFromModelPin;

Expand Down Expand Up @@ -127,7 +127,6 @@ public void onActivate() {

model.getMarketSelectorSearchText().set("");

offerOnlySettingsPin = FxBindings.bindBiDir(model.getOfferOnly()).to(settingsService.getOffersOnly());
showBuyOffersPin = FxBindings.bindBiDir(model.getShowBuyOffers()).to(settingsService.getShowBuyOffers());
showOfferListExpandedSettingsPin = FxBindings.bindBiDir(model.getShowOfferListExpanded()).to(settingsService.getShowOfferListExpanded());
showMarketSelectionListCollapsedSettingsPin = FxBindings.bindBiDir(model.getShowMarketSelectionListCollapsed())
Expand Down Expand Up @@ -231,7 +230,6 @@ public void onDeactivate() {
offerMessagesPin.unbind();
}

offerOnlySettingsPin.unbind();
showBuyOffersPin.unbind();
showOfferListExpandedSettingsPin.unbind();
showMarketSelectionListCollapsedSettingsPin.unbind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
@Slf4j
@Getter
public final class BisqEasyOfferbookModel extends ChatModel {
private final BooleanProperty offerOnly = new SimpleBooleanProperty();
private final BooleanProperty isTradeChannelVisible = new SimpleBooleanProperty();
private final BooleanProperty shouldShowAppliedFilters = new SimpleBooleanProperty();
private final ObservableList<MarketChannelItem> marketChannelItems = FXCollections.observableArrayList(p -> new Observable[]{p.getNumOffers()});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public final class BisqEasyOfferbookView extends ChatView<BisqEasyOfferbookView,
private SortAndFilterMarketsDropdownMenuItem<MarketSortType> sortByMostOffers, sortByNameAZ, sortByNameZA;
private SortAndFilterMarketsDropdownMenuItem<MarketFilter> filterShowAll, filterWithOffers, filterFavourites;
private DropdownMenuItem buyFromOffers, sellToOffers;
private CheckBox hideUserMessagesCheckbox;
private Label channelHeaderIcon, marketPrice, removeWithOffersFilter, removeFavouritesFilter,
offerListByDirectionFilter, collapsedOfferListTitle, offerListTitle, collapsedMarketSelectionListTitle,
marketSelectionListTitle;
Expand Down Expand Up @@ -137,7 +136,6 @@ protected void onViewAttached() {
favouritesTableView.initialize();
marketsTableView.initialize();

hideUserMessagesCheckbox.selectedProperty().bindBidirectional(getModel().getOfferOnly());
marketSelectorSearchBox.textProperty().bindBidirectional(getModel().getMarketSelectorSearchText());
marketPrice.textProperty().bind(getModel().getMarketPrice());
withOffersDisplayHint.visibleProperty().bind(getModel().getSelectedMarketsFilter().isEqualTo(MarketFilter.WITH_OFFERS));
Expand Down Expand Up @@ -247,7 +245,6 @@ protected void onViewDetached() {
marketsTableView.dispose();
favouritesTableView.dispose();

hideUserMessagesCheckbox.selectedProperty().unbindBidirectional(getModel().getOfferOnly());
marketSelectorSearchBox.textProperty().unbindBidirectional(getModel().getMarketSelectorSearchText());
marketPrice.textProperty().unbind();
withOffersDisplayHint.visibleProperty().unbind();
Expand Down Expand Up @@ -517,14 +514,8 @@ private void addChatBox() {
centerVBox.setSpacing(0);
centerVBox.setFillWidth(true);

Label label = new Label(Res.get("bisqEasy.topPane.filter.hideUserMessages"));
hideUserMessagesCheckbox = new CheckBox();
HBox hideUserMessagesHBox = new HBox(5, label, hideUserMessagesCheckbox);
hideUserMessagesHBox.getStyleClass().add("offerbook-subheader-checkbox");
hideUserMessagesHBox.setAlignment(Pos.CENTER);

searchBox.getStyleClass().add("offerbook-search-box");
HBox subheaderContent = new HBox(30, searchBox, Spacer.fillHBox(), hideUserMessagesHBox);
HBox subheaderContent = new HBox(30, searchBox, Spacer.fillHBox());
subheaderContent.getStyleClass().add("offerbook-subheader-content");
HBox.setHgrow(subheaderContent, Priority.ALWAYS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@ private void doSendMessage(String text) {
}

if (chatChannel instanceof BisqEasyOfferbookChannel) {
String dontShowAgainId = "sendMsgOfferOnlyWarn";
if (settingsService.getOffersOnly().get()) {
new Popup().information(Res.get("chat.message.send.offerOnly.warn"))
.actionButtonText(Res.get("confirmation.yes"))
.onAction(() -> settingsService.getOffersOnly().set(false))
.closeButtonText(Res.get("confirmation.no"))
.dontShowAgainId(dontShowAgainId)
.show();
}
chatService.getBisqEasyOfferbookChannelService().publishChatMessage(text, citation, (BisqEasyOfferbookChannel) chatChannel, userIdentity);
} else if (chatChannel instanceof BisqEasyOpenTradeChannel) {
if (settingsService.getTradeRulesConfirmed().get() || ((BisqEasyOpenTradeChannel) chatChannel).isMediator()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public class ChatMessagesListController implements bisq.desktop.common.view.Cont
private final Optional<ResendMessageService> resendMessageService;
private final BisqEasyService bisqEasyService;
private final MarketPriceService marketPriceService;
private Pin selectedChannelPin, chatMessagesPin, offerOnlySettingsPin;
private Pin selectedChannelPin, chatMessagesPin;
private Subscription selectedChannelSubscription, focusSubscription, scrollValuePin, scrollBarVisiblePin,
layoutChildrenDonePin;

Expand Down Expand Up @@ -125,8 +125,6 @@ public ChatMessagesListController(ServiceProvider serviceProvider,
public void onActivate() {
model.getSortedChatMessages().setComparator(ChatMessageListItem::compareTo);

offerOnlySettingsPin = FxBindings.subscribe(settingsService.getOffersOnly(), offerOnly -> UIThread.run(this::applyPredicate));

if (selectedChannelPin != null) {
selectedChannelPin.unbind();
}
Expand Down Expand Up @@ -156,9 +154,6 @@ public void onActivate() {

@Override
public void onDeactivate() {
if (offerOnlySettingsPin != null) {
offerOnlySettingsPin.unbind();
}
if (selectedChannelPin != null) {
selectedChannelPin.unbind();
selectedChannelPin = null;
Expand Down Expand Up @@ -547,7 +542,6 @@ private void createAndSelectTwoPartyPrivateChatChannel(UserProfile peer) {
}

private void applyPredicate() {
boolean offerOnly = settingsService.getOffersOnly().get();
Predicate<ChatMessageListItem<? extends ChatMessage, ? extends ChatChannel<? extends ChatMessage>>> predicate = item -> {
Optional<UserProfile> senderUserProfile = item.getSenderUserProfile();
if (senderUserProfile.isEmpty()) {
Expand All @@ -557,20 +551,13 @@ private void applyPredicate() {
bannedUserService.isUserProfileBanned(senderUserProfile.get())) {
return false;
}

boolean offerOnlyPredicate = true;
if (item.getChatMessage() instanceof BisqEasyOfferbookMessage) {
BisqEasyOfferbookMessage bisqEasyOfferbookMessage = (BisqEasyOfferbookMessage) item.getChatMessage();
offerOnlyPredicate = !offerOnly || bisqEasyOfferbookMessage.hasBisqEasyOffer();
}
// We do not display the take offer message as it has no text and is used only for sending the offer
// to the peer and signalling the take offer event.
if (item.getChatMessage().getChatMessageType() == ChatMessageType.TAKE_BISQ_EASY_OFFER) {
return false;
}

return offerOnlyPredicate &&
!userProfileService.getIgnoredUserProfileIds().contains(senderUserProfile.get().getId()) &&
return !userProfileService.getIgnoredUserProfileIds().contains(senderUserProfile.get().getId()) &&
userProfileService.findUserProfile(senderUserProfile.get().getId()).isPresent();
};
model.getFilteredChatMessages().setPredicate(item -> model.getSearchPredicate().test(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import bisq.chat.bisqeasy.offerbook.BisqEasyOfferbookMessage;
import bisq.desktop.common.Icons;
import bisq.desktop.common.utils.ClipboardUtil;
import bisq.desktop.common.utils.ImageUtil;
import bisq.desktop.components.controls.BisqTooltip;
import bisq.desktop.main.content.chat.message_container.list.ChatMessageListItem;
import bisq.desktop.main.content.chat.message_container.list.ChatMessagesListController;
Expand Down Expand Up @@ -157,8 +158,8 @@ public void cleanup() {
private Label createAndGetSupportedLanguagesLabel() {
Label label = new Label();
if (item.isBisqEasyPublicChatMessageWithOffer()) {
label.setGraphic(ImageUtil.getImageViewById("language-grey"));
BisqEasyOfferbookMessage chatMessage = (BisqEasyOfferbookMessage) item.getChatMessage();
label.setText(item.getSupportedLanguageCodes(chatMessage));
label.setTooltip(new BisqTooltip(item.getSupportedLanguageCodesForTooltip(chatMessage)));
}
return label;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public MyOfferMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends Ch
messageBgHBox.setMaxWidth(Control.USE_PREF_SIZE);

// Reactions
HBox.setMargin(supportedLanguages, new Insets(5, 0, -5, 0));
HBox.setMargin(copyIcon, new Insets(4, 10, -4, 0));
reactionsHBox.getChildren().setAll(Spacer.fillHBox(), supportedLanguages, copyIcon);

contentVBox.setAlignment(Pos.CENTER_RIGHT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ protected void setUpReactions() {
editIcon = getIconWithToolTip(AwesomeIcon.EDIT, Res.get("action.edit"));
copyIcon = getIconWithToolTip(AwesomeIcon.COPY, Res.get("action.copyToClipboard"));
deleteIcon = getIconWithToolTip(AwesomeIcon.REMOVE_SIGN, Res.get("action.delete"));
HBox.setMargin(editIcon, new Insets(1, 0, 0, 0));
HBox.setMargin(editIcon, new Insets(1, 0, -1, 0));
HBox.setMargin(copyIcon, new Insets(1, 0, -1, 0));
HBox.setMargin(deleteIcon, new Insets(1, 0, -1, 0));
reactionsHBox.setVisible(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public PeerOfferMessageBox(ChatMessageListItem<? extends ChatMessage, ? extends
ChatMessagesListController controller, ChatMessagesListModel model) {
super(item, list, controller, model);

reactionsHBox.getChildren().setAll(replyIcon, pmIcon, moreOptionsIcon, supportedLanguages, Spacer.fillHBox());
HBox.setMargin(supportedLanguages, new Insets(5, 0, -5, 0));
reactionsHBox.getChildren().setAll(replyIcon, pmIcon, supportedLanguages, moreOptionsIcon, Spacer.fillHBox());

VBox.setMargin(userNameAndDateHBox, new Insets(-5, 0, 5, 10));
contentVBox.getChildren().setAll(userNameAndDateHBox, messageBgHBox, reactionsHBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ protected void setUpReactions() {
pmIcon = getIconWithToolTip(AwesomeIcon.COMMENT_ALT, Res.get("chat.message.privateMessage"));
moreOptionsIcon = getIconWithToolTip(AwesomeIcon.ELLIPSIS_HORIZONTAL, Res.get("chat.message.moreOptions"));
HBox.setMargin(replyIcon, new Insets(4, 0, -4, 10));
HBox.setMargin(pmIcon, new Insets(4, 0, -4, 0));
HBox.setMargin(moreOptionsIcon, new Insets(6, 0, -6, 0));
HBox.setMargin(pmIcon, new Insets(3, 0, -3, 0));
HBox.setMargin(moreOptionsIcon, new Insets(5, 0, -5, 0));
reactionsHBox.setVisible(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class PreferencesController implements Controller {
private final MinRequiredReputationScoreService minRequiredReputationScoreService;
private final DontShowAgainService dontShowAgainService;

private Pin chatNotificationTypePin, useAnimationsPin, preventStandbyModePin, offerOnlyPin, closeMyOfferWhenTakenPin,
private Pin chatNotificationTypePin, useAnimationsPin, preventStandbyModePin, closeMyOfferWhenTakenPin,
supportedLanguageCodesPin, minRequiredReputationScorePin, ignoreDiffAdjustmentFromSecManagerPin,
mostRecentDifficultyAdjustmentFactorOrDefaultPin, difficultyAdjustmentFactorPin, ignoreMinRequiredReputationScoreFromSecManagerPin,
mostRecentMinRequiredReputationScoreOrDefaultPin, maxTradePriceDeviationPin;
Expand Down Expand Up @@ -103,8 +103,6 @@ public void onActivate() {
}
});

offerOnlyPin = FxBindings.bindBiDir(model.getOfferOnly())
.to(settingsService.getOffersOnly());
closeMyOfferWhenTakenPin = FxBindings.bindBiDir(model.getCloseMyOfferWhenTaken())
.to(settingsService.getCloseMyOfferWhenTaken());
supportedLanguageCodesPin = FxBindings.<String, String>bind(model.getSelectedSupportedLanguageCodes())
Expand Down Expand Up @@ -156,7 +154,6 @@ public void onActivate() {
public void onDeactivate() {
chatNotificationTypePin.unbind();
useAnimationsPin.unbind();
offerOnlyPin.unbind();
closeMyOfferWhenTakenPin.unbind();
preventStandbyModePin.unbind();
supportedLanguageCodesPin.unbind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@

import bisq.desktop.common.view.Model;
import bisq.settings.ChatNotificationType;
import javafx.beans.property.*;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
Expand All @@ -41,7 +50,6 @@ public class PreferencesModel implements Model {
private final BooleanProperty minRequiredReputationScoreEditable = new SimpleBooleanProperty();
private final StringProperty minRequiredReputationScoreDescriptionText = new SimpleStringProperty();
private final BooleanProperty ignoreMinRequiredReputationScoreFromSecManager = new SimpleBooleanProperty();
private final BooleanProperty offerOnly = new SimpleBooleanProperty();
private final BooleanProperty closeMyOfferWhenTaken = new SimpleBooleanProperty();
private final DoubleProperty difficultyAdjustmentFactor = new SimpleDoubleProperty();
private final BooleanProperty difficultyAdjustmentFactorEditable = new SimpleBooleanProperty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class PreferencesView extends View<VBox, PreferencesModel, PreferencesCon
private static final double TEXT_FIELD_WIDTH = 500;

private final Button resetDontShowAgain, clearNotifications, addLanguageButton;
private final Switch useAnimations, preventStandbyMode, offersOnlySwitch, closeMyOfferWhenTaken, notifyForPreRelease,
private final Switch useAnimations, preventStandbyMode, closeMyOfferWhenTaken, notifyForPreRelease,
useTransientNotifications, ignoreDiffAdjustFromSecManagerSwitch,
ignoreMinRequiredReputationScoreFromSecManagerSwitch;
private final ToggleGroup notificationsToggleGroup = new ToggleGroup();
Expand Down Expand Up @@ -197,7 +197,6 @@ public String fromString(String string) {
Label tradeHeadline = new Label(Res.get("settings.preferences.trade.headline"));
tradeHeadline.getStyleClass().add("large-thin-headline");

offersOnlySwitch = new Switch(Res.get("bisqEasy.topPane.filter.offersOnly"));
closeMyOfferWhenTaken = new Switch(Res.get("settings.preferences.trade.closeMyOfferWhenTaken"));

maxTradePriceDeviation = new MaterialTextField(Res.get("settings.preferences.trade.maxTradePriceDeviation"),
Expand All @@ -215,7 +214,6 @@ public String fromString(String string) {

VBox tradeVBox = new VBox(10,
closeMyOfferWhenTaken,
offersOnlySwitch,
maxTradePriceDeviation,
minRequiredReputationScore, ignoreMinRequiredReputationScoreFromSecManagerSwitch
);
Expand Down Expand Up @@ -261,7 +259,6 @@ protected void onViewAttached() {
useTransientNotifications.setManaged(model.isUseTransientNotificationsVisible());
useAnimations.selectedProperty().bindBidirectional(model.getUseAnimations());
preventStandbyMode.selectedProperty().bindBidirectional(model.getPreventStandbyMode());
offersOnlySwitch.selectedProperty().bindBidirectional(model.getOfferOnly());
ignoreDiffAdjustFromSecManagerSwitch.selectedProperty().bindBidirectional(model.getIgnoreDiffAdjustmentFromSecManager());
ignoreMinRequiredReputationScoreFromSecManagerSwitch.selectedProperty().bindBidirectional(model.getIgnoreMinRequiredReputationScoreFromSecManager());
closeMyOfferWhenTaken.selectedProperty().bindBidirectional(model.getCloseMyOfferWhenTaken());
Expand Down Expand Up @@ -322,7 +319,6 @@ protected void onViewDetached() {
useTransientNotifications.selectedProperty().unbindBidirectional(model.getUseTransientNotifications());
useAnimations.selectedProperty().unbindBidirectional(model.getUseAnimations());
preventStandbyMode.selectedProperty().unbindBidirectional(model.getPreventStandbyMode());
offersOnlySwitch.selectedProperty().unbindBidirectional(model.getOfferOnly());
ignoreDiffAdjustFromSecManagerSwitch.selectedProperty().unbindBidirectional(model.getIgnoreDiffAdjustmentFromSecManager());
ignoreMinRequiredReputationScoreFromSecManagerSwitch.selectedProperty().unbindBidirectional(model.getIgnoreMinRequiredReputationScoreFromSecManager());
closeMyOfferWhenTaken.selectedProperty().unbindBidirectional(model.getCloseMyOfferWhenTaken());
Expand Down
12 changes: 12 additions & 0 deletions apps/desktop/desktop/src/main/resources/css/images.css
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,18 @@
-fx-image: url("/images/icons/market/market-grey.png");
}

#language-green {
-fx-image: url("/images/icons/language/language_green.png");
}

#language-grey {
-fx-image: url("/images/icons/language/language_grey.png");
}

#language-white {
-fx-image: url("/images/icons/language/language_white.png");
}


/* ------------------------------------------------------------------------------------ */
/* Chat */
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading