From b0e9b1d2605c903fc55f288a401e8b53ef801d77 Mon Sep 17 00:00:00 2001 From: Morph21 <38075691+Morph21@users.noreply.github.com> Date: Fri, 20 Dec 2024 23:18:31 +0100 Subject: [PATCH] Release 1.3.9 --- .../com/mercury/platform/core/ChatHelper.java | 11 +++- .../platform/core/MercuryConstants.java | 2 +- .../mercury/platform/core/ProdStarter.java | 1 + .../mercury/platform/shared/IconConst.java | 4 ++ .../shared/store/MercuryStoreCore.java | 1 + .../com/mercury/platform/TranslationKey.java | 2 + app-shared/src/main/resources/lang/en.lang | 2 + app-shared/src/main/resources/lang/pl.lang | 8 ++- app-shared/src/main/resources/lang/ru.lang | 6 +- .../ui/components/ComponentsFactory.java | 53 +++++++++++------- .../CurrencyTradeIncNotificationPanel.java | 6 +- .../ItemTradeIncNotificationPanel.java | 6 +- .../ItemTradeOutNotificationPanel.java | 7 ++- .../notification/TradeNotificationPanel.java | 23 ++++---- .../NotificationIncomingController.java | 15 ----- .../taskbar/MercuryTaskBarController.java | 12 ++++ .../panel/taskbar/TaskBarController.java | 4 ++ .../panel/taskbar/TaskBarPanel.java | 32 +++++++++++ .../ui/frame/movable/NotificationFrame.java | 13 ++++- .../ui/frame/movable/TaskBarFrame.java | 10 ++++ .../platform/ui/misc/ToggleAdapter.java | 31 ++++++++++ .../resources/app/notifications-disable.png | Bin 0 -> 1447 bytes .../resources/app/notifications-enable.png | Bin 0 -> 1521 bytes .../notes/patch/patch-notes-new.json | 30 ++++++++++ release_files/release_config.xml | 8 +-- 25 files changed, 224 insertions(+), 63 deletions(-) create mode 100644 app-ui/src/main/java/com/mercury/platform/ui/misc/ToggleAdapter.java create mode 100644 app-ui/src/main/resources/app/notifications-disable.png create mode 100644 app-ui/src/main/resources/app/notifications-enable.png diff --git a/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java b/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java index 5e9edc7b..627be428 100644 --- a/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java +++ b/app-core/src/main/java/com/mercury/platform/core/ChatHelper.java @@ -15,6 +15,8 @@ import com.sun.jna.platform.win32.WinUser; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import javax.swing.*; import java.awt.*; @@ -29,6 +31,7 @@ public class ChatHelper implements AsSubscriber { private Robot robot; private static boolean clipboardMessageOn = true; + private final static Logger logger = LogManager.getLogger(ChatHelper.class); public ChatHelper() { subscribe(); @@ -177,7 +180,13 @@ private void findInStashTab(String toBeFound) { this.gameToFront(); StringSelection selection = new StringSelection(toBeFound); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + System.out.println(toBeFound); clipboard.setContents(selection, null); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + logger.error("Unexpected expection while waiting till clipboard contents will set", e); + } MercuryStoreCore.blockHotkeySubject.onNext(true); robot.keyRelease(KeyEvent.VK_ALT); @@ -269,6 +278,6 @@ private String removeCharactersThatBreakTheSearch(String textToSearch) { if (StringUtils.isBlank(textToSearch)) { return StringUtils.EMPTY; } - return textToSearch.replace(",", StringUtils.EMPTY); + return textToSearch.replaceAll(",", StringUtils.EMPTY); } } diff --git a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java index 765485b5..e186bc3e 100644 --- a/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java +++ b/app-core/src/main/java/com/mercury/platform/core/MercuryConstants.java @@ -1,7 +1,7 @@ package com.mercury.platform.core; public class MercuryConstants { - public static final String APP_VERSION = "1.3.8"; + public static final String APP_VERSION = "1.3.9"; public static final String SERVER_HOST = "exslims.ddns.net"; public static final int PORT = 5555; } \ No newline at end of file diff --git a/app-core/src/main/java/com/mercury/platform/core/ProdStarter.java b/app-core/src/main/java/com/mercury/platform/core/ProdStarter.java index 233a90af..de976dba 100644 --- a/app-core/src/main/java/com/mercury/platform/core/ProdStarter.java +++ b/app-core/src/main/java/com/mercury/platform/core/ProdStarter.java @@ -75,6 +75,7 @@ public void run() { } APP_STATUS = FrameVisibleState.SHOW; MercuryStoreCore.frameVisibleSubject.onNext(FrameVisibleState.SHOW); + MercuryStoreCore.showMessageHideButton.onNext(true); } } } diff --git a/app-core/src/main/java/com/mercury/platform/shared/IconConst.java b/app-core/src/main/java/com/mercury/platform/shared/IconConst.java index 61626169..b3d5fac4 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/IconConst.java +++ b/app-core/src/main/java/com/mercury/platform/shared/IconConst.java @@ -30,5 +30,9 @@ public class IconConst { public final static String APP_ICON = PREFIX + "app-icon.png"; public final static String PUSHBULLET_NOTIFICATION = PREFIX + "notification.png"; public final static String PUSHBULLET_NOTIFICATION_OFF = PREFIX + "notification_off.png"; + public final static String MESSAGE_NOTIFICATION_OFF = PREFIX + "notifications-disable.png"; + public final static String MESSAGE_NOTIFICATION_ON = PREFIX + "notifications-enable.png"; + + } diff --git a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java index 3e25f6d5..dc9f29e1 100644 --- a/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java +++ b/app-core/src/main/java/com/mercury/platform/shared/store/MercuryStoreCore.java @@ -69,4 +69,5 @@ public class MercuryStoreCore { public static final PublishSubject vulkanSupportSubject = PublishSubject.create(); public static final PublishSubject checkForUpdatesSubject = PublishSubject.create(); + public static final PublishSubject showMessageHideButton = PublishSubject.create(); } diff --git a/app-shared/src/main/java/com/mercury/platform/TranslationKey.java b/app-shared/src/main/java/com/mercury/platform/TranslationKey.java index f0b7d533..391935a3 100644 --- a/app-shared/src/main/java/com/mercury/platform/TranslationKey.java +++ b/app-shared/src/main/java/com/mercury/platform/TranslationKey.java @@ -236,6 +236,8 @@ public enum TranslationKey { russian("russian"), choose_language("Choose language"), language_change_requires_application_restart("Language change requires application restart."), + hide_notifications("Hide notifications until next incoming or manually shown"), + show_notifications("Show notifications") ; private String defaultValue; diff --git a/app-shared/src/main/resources/lang/en.lang b/app-shared/src/main/resources/lang/en.lang index 281d56a5..7ec57f0b 100644 --- a/app-shared/src/main/resources/lang/en.lang +++ b/app-shared/src/main/resources/lang/en.lang @@ -233,3 +233,5 @@ russian = russian polish = polish choose_language = Choose language language_change_requires_application_restart = Language change requires application restart. +hide_notifications = Hide notifications until next incoming or manually shown +show_notifications = Show notifications \ No newline at end of file diff --git a/app-shared/src/main/resources/lang/pl.lang b/app-shared/src/main/resources/lang/pl.lang index 53ea1e39..4217f8cc 100644 --- a/app-shared/src/main/resources/lang/pl.lang +++ b/app-shared/src/main/resources/lang/pl.lang @@ -247,7 +247,7 @@ create = stwórz // Is it Quad? is_it_quad = Czy to jest Quad? // Find in stashtab -find_in_stashtab = Znajdź w zakładce +find_in_stashtab = Znajdź w skrytce // App version app_version = Wersja aplikacji // Taskbar will be hidden until you hover onto it @@ -467,4 +467,8 @@ polish = polski // Choose language choose_language = Wybierz język // Language change requires application restart. -language_change_requires_application_restart = Zmiana języka wymaga restartu aplikacji. \ No newline at end of file +language_change_requires_application_restart = Zmiana języka wymaga restartu aplikacji. +// Hide notifications until next incoming or manually shown +hide_notifications = Ukryj powiadomienia do następnej wiadomości +// Show notifications +show_notifications = Pokaż powiadomienia \ No newline at end of file diff --git a/app-shared/src/main/resources/lang/ru.lang b/app-shared/src/main/resources/lang/ru.lang index aa497778..5a6457a3 100644 --- a/app-shared/src/main/resources/lang/ru.lang +++ b/app-shared/src/main/resources/lang/ru.lang @@ -467,4 +467,8 @@ polish = польский // Choose language choose_language = Выберите язык // Language change requires application restart. -language_change_requires_application_restart = Изменение языка требует перезагрузки приложения. \ No newline at end of file +language_change_requires_application_restart = Изменение языка требует перезагрузки приложения. +// Hide notifications until next incoming or manually shown +hide_notifications = Скрыть уведомления до следующего сообщения +// Show notifications +show_notifications = Показать уведомления \ No newline at end of file diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java index 26ecdcf3..402e88eb 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/ComponentsFactory.java @@ -11,6 +11,7 @@ import com.mercury.platform.ui.components.panel.misc.ToggleCallback; import com.mercury.platform.ui.misc.AppThemeColor; import com.mercury.platform.ui.misc.MercuryStoreUI; +import com.mercury.platform.ui.misc.ToggleAdapter; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -132,6 +133,10 @@ private void loadFonts() { } } + public JButton getButton(FontStyle fontStyle, Color background, Border border, String text, float fontSize) { + return getButton(fontStyle, background, border, text, fontSize, null); + } + /** * Get button with custom params * @@ -142,7 +147,7 @@ private void loadFonts() { * @param fontSize font size * @return JButton object */ - public JButton getButton(FontStyle fontStyle, Color background, Border border, String text, float fontSize) { + public JButton getButton(FontStyle fontStyle, Color background, Border border, String text, float fontSize, String tooltip) { JButton button = new JButton(text) { @Override protected void paintBorder(Graphics g) { @@ -150,6 +155,11 @@ protected void paintBorder(Graphics g) { super.paintBorder(g); } } + @Override + public JToolTip createToolTip() { + JToolTip tip = ComponentsFactory.this.createTooltip(tooltip); + return tip; + } }; button.setBackground(background); button.setForeground(AppThemeColor.TEXT_DEFAULT); @@ -193,13 +203,23 @@ public void mouseExited(MouseEvent e) { * @param text text on button * @return Default app button */ - public JButton getButton(String text) { + public JButton getButton(String text, String tooltip) { CompoundBorder compoundBorder = BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT, 1), BorderFactory.createLineBorder(AppThemeColor.BUTTON, 3) ); - return getButton(FontStyle.BOLD, AppThemeColor.BUTTON, compoundBorder, text, scale * 14f); + return getButton(FontStyle.BOLD, AppThemeColor.BUTTON, compoundBorder, text, scale * 14f, tooltip); + } + + /** + * Get button with default properties + * + * @param text text on button + * @return Default app button + */ + public JButton getButton(String text) { + return getButton(text, null); } /** @@ -240,23 +260,18 @@ public Component setUpToggleCallbacks(Component button, ToggleCallback firstState, ToggleCallback secondState, boolean initialState) { - button.addMouseListener(new MouseAdapter() { - private boolean state = initialState; - - @Override - public void mouseClicked(MouseEvent e) { - if (state) { - firstState.onToggle(); - state = false; - } else { - secondState.onToggle(); - state = true; - } - } - }); + button.addMouseListener(createListenerForToggleCallbacks(button, firstState, secondState, initialState)); return button; } + public ToggleAdapter createListenerForToggleCallbacks(Component button, + ToggleCallback firstState, + ToggleCallback secondState, + boolean initialState) { + ToggleAdapter listener = new ToggleAdapter(firstState, secondState, initialState); + return listener; + } + public JButton getIconButton(String iconPath, float iconSize, Color background, String tooltip) { int i = iconPath.lastIndexOf("/"); String temp = iconPath.substring(i + 1); @@ -365,7 +380,7 @@ public JToolTip createTooltip(String text) { return toolTip; } - private String wrapTextWithPadding(String text) { + public String wrapTextWithPadding(String text) { StringBuilder b = new StringBuilder(); b.append(""); b.append("
"); @@ -999,7 +1014,7 @@ public String getTooltipMessageForChatHistory(NotificationDescriptor source) { b.append("

"); b.append(d.isIncoming() ? "> " : ""); b.append(d.getMessage()); - b.append("
"); + //b.append("
"); b.append("

"); }); return b.toString(); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java index dd68d647..82c01f3b 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/CurrencyTradeIncNotificationPanel.java @@ -56,12 +56,13 @@ private JPanel getFromPanel() { itemsPanel.setBorder(new EmptyBorder(0, 0, 2, 0)); this.data.getItems().forEach((item) -> { - JButton itemBtn = this.componentsFactory.getButton(item); + JButton itemBtn = this.componentsFactory.getButton(item, TranslationKey.find_in_stashtab.value()); itemBtn.setBackground(AppThemeColor.FRAME); itemBtn.setBorder(new EmptyBorder(4, 4, 4, 4)); itemBtn.addActionListener(action -> { MercuryStoreCore.findInStashTab.onNext(item); }); + itemBtn.setToolTipText(TranslationKey.find_in_stashtab.value()); itemsPanel.add(itemBtn); }); fromPanel.add(itemsPanel, BorderLayout.LINE_START); @@ -73,12 +74,13 @@ private JPanel getFromPanel() { JPanel itemsPanel = new JPanel(); itemsPanel.setBackground(AppThemeColor.FRAME); itemsPanel.setLayout(new BoxLayout(itemsPanel, BoxLayout.Y_AXIS)); - JButton itemBtn = this.componentsFactory.getButton(this.data.getCurrForSaleCount().intValue() + " " + this.data.getCurrForSaleTitle()); + JButton itemBtn = this.componentsFactory.getButton(this.data.getCurrForSaleCount().intValue() + " " + this.data.getCurrForSaleTitle(), TranslationKey.find_in_stashtab.value()); itemBtn.setBackground(AppThemeColor.FRAME); itemBtn.setBorder(new EmptyBorder(4, 4, 4, 4)); itemBtn.addActionListener(action -> { MercuryStoreCore.findInStashTab.onNext(this.data.getCurrForSaleTitle()); }); + itemBtn.setToolTipText(TranslationKey.find_in_stashtab.value()); itemsPanel.add(itemBtn); fromPanel.add(itemsPanel, BorderLayout.LINE_START); } else { diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java index c7b96f28..c28c05c7 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeIncNotificationPanel.java @@ -55,7 +55,7 @@ public JPanel getItemsPanel() { itemsPanel.setBorder(new EmptyBorder(0, 0, 2, 0)); itemsWanted.forEach((item) -> { - JButton btn = this.componentsFactory.getButton(item); + JButton btn = this.componentsFactory.getButton(item, TranslationKey.find_in_stashtab.value()); btn.setForeground(AppThemeColor.TEXT_IMPORTANT); btn.setBackground(AppThemeColor.FRAME); btn.setBorder(new EmptyBorder(4,4,4,4)); @@ -63,6 +63,7 @@ public JPanel getItemsPanel() { this.controller.showITH(); MercuryStoreCore.findInStashTab.onNext(item); }); + btn.setToolTipText(TranslationKey.find_in_stashtab.value()); itemsPanel.add(btn); }); @@ -71,7 +72,7 @@ public JPanel getItemsPanel() { itemsPanel.setBackground(AppThemeColor.FRAME); itemsPanel.setLayout(new BoxLayout(itemsPanel, BoxLayout.Y_AXIS)); itemsPanel.setBorder(new EmptyBorder(0, 0, 2, 0)); - JButton btn = this.componentsFactory.getButton(this.data.getItemName()); + JButton btn = this.componentsFactory.getButton(this.data.getItemName(), TranslationKey.find_in_stashtab.value()); btn.setForeground(AppThemeColor.TEXT_IMPORTANT); btn.setBackground(AppThemeColor.FRAME); btn.setBorder(new EmptyBorder(4,4,4,4)); @@ -79,6 +80,7 @@ public JPanel getItemsPanel() { this.controller.showITH(); MercuryStoreCore.findInStashTab.onNext(this.data.getItemName()); }); + btn.setToolTipText(TranslationKey.find_in_stashtab.value()); itemsPanel.add(btn); } return itemsPanel; diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java index 4ecbc0d1..4a9c31e6 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/ItemTradeOutNotificationPanel.java @@ -1,5 +1,6 @@ package com.mercury.platform.ui.components.panel.notification; +import com.mercury.platform.TranslationKey; import com.mercury.platform.shared.config.descriptor.HotKeyType; import com.mercury.platform.shared.entity.message.ItemTradeNotificationDescriptor; import com.mercury.platform.shared.store.MercuryStoreCore; @@ -53,10 +54,11 @@ public JPanel getItemsPanel() { itemsPanel.setBorder(new EmptyBorder(0, 0, 2, 0)); itemsWanted.forEach((item) -> { - JButton btn = this.componentsFactory.getButton(item); + JButton btn = this.componentsFactory.getButton(item, TranslationKey.find_in_stashtab.value()); btn.addActionListener((action) -> { MercuryStoreCore.findInStashTab.onNext(item); }); + btn.setToolTipText(TranslationKey.find_in_stashtab.value()); btn.setForeground(AppThemeColor.INC_PANEL_ARROW); btn.setBackground(AppThemeColor.FRAME); btn.setBorder(new EmptyBorder(4,4,4,4)); @@ -68,10 +70,11 @@ public JPanel getItemsPanel() { itemsPanel.setBackground(AppThemeColor.FRAME); itemsPanel.setLayout(new BoxLayout(itemsPanel, BoxLayout.Y_AXIS)); itemsPanel.setBorder(new EmptyBorder(0, 0, 2, 0)); - JButton btn = this.componentsFactory.getButton(this.data.getItemName()); + JButton btn = this.componentsFactory.getButton(this.data.getItemName(), TranslationKey.find_in_stashtab.value()); btn.addActionListener((action) -> { MercuryStoreCore.findInStashTab.onNext(this.data.getItemName()); }); + btn.setToolTipText(TranslationKey.find_in_stashtab.value()); btn.setForeground(AppThemeColor.INC_PANEL_ARROW); btn.setBackground(AppThemeColor.FRAME); btn.setBorder(new EmptyBorder(4,4,4,4)); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java index 88f6f048..2a9e8846 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/TradeNotificationPanel.java @@ -1,6 +1,7 @@ package com.mercury.platform.ui.components.panel.notification; +import com.mercury.platform.TranslationKey; import com.mercury.platform.shared.IconConst; import com.mercury.platform.shared.config.descriptor.ResponseButtonDescriptor; import com.mercury.platform.shared.entity.message.TradeNotificationDescriptor; @@ -110,7 +111,9 @@ public void subscribe() { super.subscribe(); this.chatSubscription = MercuryStoreCore.plainMessageSubject.subscribe(message -> { if (this.data.getWhisperNickname().equals(message.getNickName())) { - this.data.getRelatedMessages().add(message); + if (StringUtils.isNotBlank(message.getMessage())) { + this.data.getRelatedMessages().add(message); + } } }); this.playerJoinSubscription = MercuryStoreCore.playerJoinSubject.subscribe(nickname -> { @@ -146,6 +149,7 @@ public void mouseEntered(MouseEvent e) { BorderFactory.createLineBorder(AppThemeColor.ADR_SELECTED_BORDER), BorderFactory.createEmptyBorder(3, 3, 3, 3))); chatHistory.setCursor(new Cursor(Cursor.HAND_CURSOR)); + chatHistory.setToolTipText(componentsFactory.wrapTextWithPadding(componentsFactory.getTooltipMessageForChatHistory(data))); // MercuryStoreUI.showChatHistorySubject.onNext(new ChatHistoryDefinition(data.getRelatedMessages(), // e.getLocationOnScreen())); } @@ -205,10 +209,11 @@ protected JPanel getCurrencyPanel(Double curCount, String curIconPath) { String.valueOf(curCount); } if (!Objects.equals(curCountStr, "") && curIconPath != null) { - JButton currencyButton = componentsFactory.getIconButton("currency/" + curIconPath + ".png", 24, AppThemeColor.TRANSPARENT, "Find in stashtab"); + JButton currencyButton = componentsFactory.getIconButton("currency/" + curIconPath + ".png", 24, AppThemeColor.TRANSPARENT, TranslationKey.find_in_stashtab.value()); currencyButton.addActionListener((action) -> { MercuryStoreCore.findInStashTab.onNext(curIconPath); }); + currencyButton.setToolTipText(TranslationKey.find_in_stashtab.value()); JPanel curPanel = this.componentsFactory.getJPanel(new GridBagLayout(), AppThemeColor.MSG_HEADER); curPanel.setAlignmentX(SwingConstants.LEFT); JLabel countLabel = this.componentsFactory.getTextLabel(curCountStr, FontStyle.BOLD, 17f); @@ -241,30 +246,22 @@ protected String getNicknameText() { if (this.notificationConfig.get().isShowLeague()) { if (data.getLeague() != null) { String league = data.getLeague().trim(); - if (league.length() == 0) { + if (league.isEmpty()) { return result; } if (league.contains("Hardcore")) { if (league.equals("Hardcore")) { result = "HC " + result; } else { - result = String.valueOf(league.split(" ")[1].charAt(0)) + "HC " + result; + result = league.split(" ")[1].charAt(0) + "HC " + result; } } else if (league.contains("Standard")) { result = "Standard " + result; } else { - result = String.valueOf(league.charAt(0)) + "SC " + result; + result = league.charAt(0) + "SC " + result; } } } return result; } - - private void waitForNextAction() { - try { - Thread.sleep(50); - } catch (InterruptedException e) { - //silence in case of error and go on - } - } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java index 2a61b2eb..83ec499e 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/notification/controller/NotificationIncomingController.java @@ -63,27 +63,12 @@ public void performHide() { public void showITH() { if (notificationDescriptor instanceof ItemTradeNotificationDescriptor) { - this.copyItemNameToClipboard(((ItemTradeNotificationDescriptor) notificationDescriptor).getItemName()); if (((ItemTradeNotificationDescriptor) notificationDescriptor).getTabName() != null) { MercuryStoreUI.showItemGridSubject.onNext((ItemTradeNotificationDescriptor) notificationDescriptor); } } } - private void copyItemNameToClipboard(@NonNull String itemName) { - Timer timer = new Timer(30, action -> { - try { - StringSelection selection = new StringSelection(itemName); - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - clipboard.setContents(selection, null); - } catch (IllegalStateException e) { - MercuryStoreCore.errorHandlerSubject.onNext(new MercuryError(e)); - } - }); - timer.setRepeats(false); - timer.start(); - } - private void closeMessagePanel() { Timer timer = new Timer(30, action -> { MercuryStoreCore.removeNotificationSubject.onNext(notificationDescriptor); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java index 6a58aee7..514ef252 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/MercuryTaskBarController.java @@ -3,7 +3,9 @@ import com.mercury.platform.TranslationKey; import com.mercury.platform.shared.store.MercuryStoreCore; import com.mercury.platform.ui.frame.movable.ItemsGridFrame; +import com.mercury.platform.ui.frame.movable.NotificationFrame; import com.mercury.platform.ui.frame.movable.TaskBarFrame; +import com.mercury.platform.ui.frame.other.NotificationAlertFrame; import com.mercury.platform.ui.frame.titled.ChatScannerFrame; import com.mercury.platform.ui.frame.titled.HistoryFrame; import com.mercury.platform.ui.frame.titled.SettingsFrame; @@ -86,4 +88,14 @@ public void showSettings() { public void exit() { FramesManager.INSTANCE.exit(); } + + @Override + public void hideMessageNotifications() { + FramesManager.INSTANCE.hideFrame(NotificationFrame.class); + } + + @Override + public void showMessageNotifications() { + FramesManager.INSTANCE.showFrame(NotificationFrame.class); + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarController.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarController.java index d5d51c50..df65ce07 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarController.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarController.java @@ -29,4 +29,8 @@ public interface TaskBarController { void showSettings(); void exit(); + + void hideMessageNotifications(); + + void showMessageNotifications(); } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java index bb827aea..79ed8c51 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/components/panel/taskbar/TaskBarPanel.java @@ -13,6 +13,7 @@ import com.mercury.platform.ui.frame.movable.TaskBarFrame; import com.mercury.platform.ui.manager.FramesManager; import com.mercury.platform.ui.misc.AppThemeColor; +import com.mercury.platform.ui.misc.ToggleAdapter; import com.mercury.platform.ui.misc.TooltipConstants; import lombok.NonNull; @@ -57,6 +58,16 @@ public void onViewInit() { this.setBackground(AppThemeColor.FRAME); this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + JButton messageNotificationsHide = componentsFactory.getIconButton( + IconConst.MESSAGE_NOTIFICATION_ON, + 24, + AppThemeColor.FRAME, + TranslationKey.hide_notifications.value()); + ToggleAdapter toggleAdapter = createToggleAdapter(messageNotificationsHide); + MercuryStoreCore.showMessageHideButton.subscribe(a -> showHideMessageNotificationSubscribe(messageNotificationsHide, toggleAdapter)); + messageNotificationsHide.addMouseListener(toggleAdapter); + messageNotificationsHide.addMouseListener(taskBarFrameMouseListener); + JButton visibleMode = componentsFactory.getIconButton( IconConst.VISIBLE_ALWAYS_MODE, 24, @@ -228,6 +239,8 @@ public void mousePressed(MouseEvent e) { this.add(Box.createRigidArea(new Dimension(3, 4))); this.add(chatFilter); this.add(Box.createRigidArea(new Dimension(3, 4))); + this.add(messageNotificationsHide); + this.add(Box.createRigidArea(new Dimension(2, 4))); this.add(visibleMode); this.add(Box.createRigidArea(new Dimension(2, 4))); this.add(pushbulletNotification); @@ -262,4 +275,23 @@ public int getWidthOf(int elementCount) { int size = this.getPreferredSize().width / (this.getComponentCount() / 2); return size * elementCount + 3; } + + private void showHideMessageNotificationSubscribe(JButton messageNotificationsHide, ToggleAdapter toggleAdapter) { + toggleAdapter.setState(true); + messageNotificationsHide.setIcon(componentsFactory.getIcon(IconConst.MESSAGE_NOTIFICATION_ON, 24)); + } + + private ToggleAdapter createToggleAdapter(JButton messageNotificationsHide) { + return componentsFactory.createListenerForToggleCallbacks(messageNotificationsHide, + () -> { + messageNotificationsHide.setIcon(componentsFactory.getIcon(IconConst.MESSAGE_NOTIFICATION_OFF, 24)); + controller.hideMessageNotifications(); + }, + () -> { + messageNotificationsHide.setIcon(componentsFactory.getIcon(IconConst.MESSAGE_NOTIFICATION_ON, 24)); + controller.showMessageNotifications(); + }, + true + ); + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java index 36706337..76a1e334 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/NotificationFrame.java @@ -127,6 +127,7 @@ public void subscribe() { PushBulletManager.INSTANCE.sendPush(notification.getSourceString(), notification.getWhisperNickname()); } this.addNotification(notificationPanel); + showFrame(); } }); }); @@ -138,6 +139,7 @@ public void subscribe() { .build(); PushBulletManager.INSTANCE.sendPush(message.getMessage().replaceAll("\\<[^>]*>", ""), message.getNickName()); this.addNotification(notificationPanel); + showFrame(); }); }); MercuryStoreCore.removeNotificationSubject.subscribe(notification -> { @@ -207,7 +209,6 @@ private void validateContainer() { private void addNotification(NotificationPanel notificationPanel) { this.notificationPanels.add(notificationPanel); - this.setVisible(true); if (this.flowDirections.equals(FlowDirections.UPWARDS)) { this.container.add( this.componentsFactory.wrapToSlide( @@ -410,4 +411,14 @@ private JPanel getExpandPanel() { root.add(expandButton, BorderLayout.CENTER); return this.componentsFactory.wrapToSlide(root, AppThemeColor.TRANSPARENT, 1, 1, 1, 1); } + public void showFrame() { + if (!this.dnd) { + if (!this.notificationPanels.isEmpty()) { + if (ProdStarter.APP_STATUS.equals(FrameVisibleState.SHOW)) { + MercuryStoreCore.showMessageHideButton.onNext(true); + this.setVisible(true); + } + } + } + } } diff --git a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java index 99aecb69..1c3a1a8d 100644 --- a/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java +++ b/app-ui/src/main/java/com/mercury/platform/ui/frame/movable/TaskBarFrame.java @@ -241,6 +241,16 @@ public void showSettings() { @Override public void exit() { } + + @Override + public void hideMessageNotifications() { + + } + + @Override + public void showMessageNotifications() { + + } }; JPanel panel = factory.getTransparentPanel(new BorderLayout()); TaskBarPanel taskBarPanel = new TaskBarPanel(controller, factory, createHideListener()); diff --git a/app-ui/src/main/java/com/mercury/platform/ui/misc/ToggleAdapter.java b/app-ui/src/main/java/com/mercury/platform/ui/misc/ToggleAdapter.java new file mode 100644 index 00000000..e8a12583 --- /dev/null +++ b/app-ui/src/main/java/com/mercury/platform/ui/misc/ToggleAdapter.java @@ -0,0 +1,31 @@ +package com.mercury.platform.ui.misc; + +import com.mercury.platform.ui.components.panel.misc.ToggleCallback; +import lombok.Setter; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +public class ToggleAdapter extends MouseAdapter { + ToggleCallback firstState; + ToggleCallback secondState; + @Setter + private boolean state; + + public ToggleAdapter(ToggleCallback firstState, ToggleCallback secondState, boolean initialState) { + this.firstState = firstState; + this.secondState = secondState; + this.state = initialState; + } + + @Override + public void mouseClicked(MouseEvent e) { + if (state) { + firstState.onToggle(); + state = false; + } else { + secondState.onToggle(); + state = true; + } + } +} diff --git a/app-ui/src/main/resources/app/notifications-disable.png b/app-ui/src/main/resources/app/notifications-disable.png new file mode 100644 index 0000000000000000000000000000000000000000..d05d067903b9da0e78f5ea45b341d99fdb80ad0d GIT binary patch literal 1447 zcmV;Y1z7rtP)EX>4Tx04R}tkv&MmKpe$iQ>7vmhh`9Q$WWauNELCEDi*;)X)CnqU~=gfG%+M8 zE{=k0!NHHks)LKOt`4q(Aou~|?BJy6A|?JWDYS_3;J6>}?mh0_0YbCJG^=L<&~)3( zBok7;up)(C5r&8eLWs-EGE&)v9DK*uJpz2ai}5V~bAOHjwP-OQAQ8_p!?cOliKjPh zgY!PI$SSf*d`>)W(glehxvqHp#<}dWz%xZNmzg6LiKTKED_zVgrbawP991=)@`b#| zD(5ZETCL97_v9}O7xm>V*J+L*iAAK4h6Dw5R8fPC7_B-f7BaM-@bM43{xrE1a#g{| zF^>&skX=9cAN=mtDow_{q;LZ0eQ}(RQ6RJnv>J}{ee5``6Cn5uT(Ud*lat9cCGGtSBr65hAR07`5=$i^a_CX>@2HM@dakSAh-}000A$ zNkl?d_jCesGtz&UnvX}6oi2YQ|heK zF%-u91Kd`fV_VZCy_`R2yEwaO+f-+BU+52^$0gs-J-K`CX^)JaIn5DcNr<@;!Hdbl zImmKipbdLo19O$PzXG^@<0`V56o^Cy8i4O}WYSkK^K5qK6__kc#KJrPND{$;Y#Nh= zb2||r%d}am{$1pom+01yBK00BS%5C8-K0YCr{00e+Is&DnL z!o)ZXU4^13kmUpt2?{Dnkf;QS5D-ED5-7lM4$e7z&fzm3%=gh~FnC@AuIr*^JE+Vr z>`wrvPM$#C%)v!Z0)#h6d~Y9c*sZu(tXI?-t)j55UlMT$(zMY&Hc+l6o>;vWguU z{axFVRRpCJ2eN5o(n*+R4lm1ZP_yl508Cw&Kt7*?rl~!Tc9{9*_nr11Y+tg9$mKG) zdHoXB*49yeJ>T0hczLRTk>NwoG!=}ozMAi}-Ci&lW6(4eBg2Pqd8*KT1dNZ3!ZdS` z75Tp^mrp-@+5%~sIgF2uVqx(^=MgYGWI~C^{O(b892XC!pR_)X<3<(*!Dvtv8N)+n zcdtM)srPM^9zC83y^d00K0*N`5_B-q-4Gw402&Q85CFn_gaX*!w)^%__wL>by^d00 zK0;T4mDMVAUF~XZZZ{zXCpJ}8B1?$ECSKR|u(De14#2|V2c(h)@@5Vts|dzeYl+#< zvhLpjr4*j)p;}$va|!&TMCe7if=?@-QLj6ol=hsYMA>eyQKyumUU%?m)&qiS-gK{uP!#FxZo~VkBGlB<@<%K!$G9fgPW^b;en|W- zAOHve0)PM@00;mAfB+x>2mk_r03ZMe00KbllmGzFW8gjqk)p5T?MHE+!}Hiq1k6?D z@pWSp+~=_{|8-*%bCvIZogu-~<8eGYOyYig{u_wNj$l^m)HeVC002ovPDHLkV1lGZ BjRXJy literal 0 HcmV?d00001 diff --git a/app-ui/src/main/resources/app/notifications-enable.png b/app-ui/src/main/resources/app/notifications-enable.png new file mode 100644 index 0000000000000000000000000000000000000000..c19b73dc048a6690f77ea4358527503d99efb645 GIT binary patch literal 1521 zcmV0004lX+uL$Nkc;* zaB^>EX>4Tx04R}tkv&MmKpe$iQ>7vmhh`9Q$WWauNELCEDi*;)X)CnqU~=gfG%+M8 zE{=k0!NHHks)LKOt`4q(Aou~|?BJy6A|?JWDYS_3;J6>}?mh0_0YbCJG^=L<&~)3( zBok7;up)(C5r&8eLWs-EGE&)v9DK*uJpz2ai}5V~bAOHjwP-OQAQ8_p!?cOliKjPh zgY!PI$SSf*d`>)W(glehxvqHp#<}dWz%xZNmzg6LiKTKED_zVgrbawP991=)@`b#| zD(5ZETCL97_v9}O7xm>V*J+L*iAAK4h6Dw5R8fPC7_B-f7BaM-@bM43{xrE1a#g{| zF^>&skX=9cAN=mtDow_{q;LZ0eQ}(RQ6RJnv>J}{ee5``6Cn5uT(Ud*lat9cCGGtSBr65hAR07`5=$i^a_CX>@2HM@dakSAh-}000Br zNklzbzRe6g9f`#givTKBVf%%Xwf3zj zDis7kJdvv2ZoPcvZX_Bn008XUV;7Kn0Dv5o*6rNZxNpbe3}`eM?cQQ@2m*j4a1@nl zH0pohA%*}D00KY&2mk>f00e*l5Ma$qNMe8$eg0KHOSwwU{;-%5*xd zMDmwGL?RJ_h!I4LqB0CC%Ia;ubjt4!PE39Akz)@Y4fzA%l>$)6WvAO5l{T}Gir=d*v}#>)80zYvSFl4m=i5E*pTo+IrNn*Jd+gDkV?HS;`uR zBye+u(Oh9{I#@>#@4E3pkJrZwK#dh%Jb&C?vsGEB$jdrO;D5FIy8}o9$5hI?UE8aw zte(*~?N{%GsVEl!=h244t-DP|L%tzrbx;4E%Q(z2B!M^Vwj0a!4<0>tcR$N-8Ere! z;&L{dj0TGOu`KR$>0L@fQ9n#ZgUi|6cA_PZ8K|zRIMiIP(`ncIMN3WHF&g_&b3O6) zgZI_@oMyn~Y$_`);ov?qz!Q_x7Mo*B)e(!$F)=yKZ4#KNC@U>-Ih%65g{+p1{Darn zas~j9o||XdJjLpY9iX^awG5lQxPZ0IS*)(u$DNt^&i{IJ?3cDVi`5l7fRFsl|9bsB zH<;MdZJuIv#l8x4x%-6MfvVNoO_oB9>a>p#;3a6 zy&auBd8ZQY?q^R1M(A9KVaPET;B)gZ=SHG2UbzqeAWTKip1YZujnbp%n3i$g2dVFo z<;g~AdAvT4*OyrjWCfT{J&^e|m6~0VdVp3ep1gM5&03Lh$PO6I&ZbwXB4gwagm2$@ zDBzknOML?#z|RDHF9ZP~00e*l5C8%|00;m9AOHmTF98q$Kqy2d5-Ajw@+oasS&2j{ z6rvVqpnq`W-Dfile.encoding=UTF-8 - 1.3.8.0 - 1.3.8 + 1.3.9.0 + 1.3.9 MercuryTrade Morph21 - 1.3.8.0 - 1.3.8 + 1.3.9.0 + 1.3.9 MercuryTrade Morph MercuryTrade