Search in sources :

Example 6 with TransientNotification

use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.

the class AbstractChatTabController method showNotificationIfNecessary.

protected void showNotificationIfNecessary(ChatMessage chatMessage) {
    Stage stage = StageHolder.getStage();
    if (stage.isFocused() && stage.isShowing()) {
        return;
    }
    Player player = playerService.getPlayerForUsername(chatMessage.getUsername());
    String identiconSource = player != null ? String.valueOf(player.getId()) : chatMessage.getUsername();
    notificationService.addNotification(new TransientNotification(chatMessage.getUsername(), chatMessage.getMessage(), IdenticonUtil.createIdenticon(identiconSource), event -> {
        eventBus.post(new NavigateEvent(NavigationItem.CHAT));
        stage.toFront();
        getRoot().getTabPane().getSelectionModel().select(getRoot());
    }));
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) EventHandler(javafx.event.EventHandler) Arrays(java.util.Arrays) CHAT_TEXT(com.faforever.client.theme.UiService.CHAT_TEXT) UiService(com.faforever.client.theme.UiService) TextInputControl(javafx.scene.control.TextInputControl) PseudoClass(javafx.css.PseudoClass) URL(java.net.URL) ImageUploadService(com.faforever.client.uploader.ImageUploadService) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) StringUtils(org.apache.commons.lang3.StringUtils) CHAT_CONTAINER(com.faforever.client.theme.UiService.CHAT_CONTAINER) CASE_INSENSITIVE(java.util.regex.Pattern.CASE_INSENSITIVE) NavigateEvent(com.faforever.client.main.event.NavigateEvent) AudioService(com.faforever.client.audio.AudioService) TimeService(com.faforever.client.util.TimeService) TabPane(javafx.scene.control.TabPane) Matcher(java.util.regex.Matcher) CharStreams(com.google.common.io.CharStreams) MINUTES(java.time.temporal.ChronoUnit.MINUTES) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ITEM_AT_INDEX(javafx.scene.AccessibleAttribute.ITEM_AT_INDEX) ChatPrefs(com.faforever.client.preferences.ChatPrefs) SELF(com.faforever.client.chat.SocialStatus.SELF) PlayerService(com.faforever.client.player.PlayerService) HtmlEscapers.htmlEscaper(com.google.common.html.HtmlEscapers.htmlEscaper) ClientProperties(com.faforever.client.config.ClientProperties) JSObject(netscape.javascript.JSObject) RatingUtil.getLeaderboardRating(com.faforever.client.util.RatingUtil.getLeaderboardRating) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) KeyEvent(javafx.scene.input.KeyEvent) Reader(java.io.Reader) NavigationItem(com.faforever.client.main.event.NavigationItem) DismissAction(com.faforever.client.notification.DismissAction) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) StageHolder(com.faforever.client.ui.StageHolder) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) FRIEND(com.faforever.client.chat.SocialStatus.FRIEND) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner) CHAT_ENTRY(com.faforever.client.theme.UiService.CHAT_ENTRY) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) Worker(javafx.concurrent.Worker) RatingUtil.getGlobalRating(com.faforever.client.util.RatingUtil.getGlobalRating) WebEngine(javafx.scene.web.WebEngine) AnchorLocation(javafx.stage.PopupWindow.AnchorLocation) MouseEvent(javafx.scene.input.MouseEvent) ClassPathResource(org.springframework.core.io.ClassPathResource) UserService(com.faforever.client.user.UserService) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) PlatformService(com.faforever.client.fx.PlatformService) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) TabPaneSkin(com.sun.javafx.scene.control.skin.TabPaneSkin) Tooltip(javafx.scene.control.Tooltip) ReportAction(com.faforever.client.notification.ReportAction) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) PopupWindow(javafx.stage.PopupWindow) Logger(org.slf4j.Logger) ClanService(com.faforever.client.clan.ClanService) IdenticonUtil(com.faforever.client.util.IdenticonUtil) Controller(com.faforever.client.fx.Controller) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Node(javafx.scene.Node) ReplayService(com.faforever.client.replay.ReplayService) FOE(com.faforever.client.chat.SocialStatus.FOE) IOException(java.io.IOException) WebViewConfigurer(com.faforever.client.fx.WebViewConfigurer) InputStreamReader(java.io.InputStreamReader) Popup(javafx.stage.Popup) ClanTooltipController(com.faforever.client.clan.ClanTooltipController) Preview(com.faforever.client.chat.UrlPreviewResolver.Preview) Stage(javafx.stage.Stage) Severity(com.faforever.client.notification.Severity) Tab(javafx.scene.control.Tab) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) ContentDisplay(javafx.scene.control.ContentDisplay) Player(com.faforever.client.player.Player) NavigateEvent(com.faforever.client.main.event.NavigateEvent) Stage(javafx.stage.Stage)

Example 7 with TransientNotification

use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.

the class FriendJoinedGameNotifier method onFriendJoinedGame.

@Subscribe
public void onFriendJoinedGame(FriendJoinedGameEvent event) {
    Player player = event.getPlayer();
    Game game = event.getGame();
    audioService.playFriendJoinsGameSound();
    if (preferencesService.getPreferences().getNotification().isFriendJoinsGameToastEnabled()) {
        notificationService.addNotification(new TransientNotification(i18n.get("friend.joinedGameNotification.title", player.getUsername(), game.getTitle()), i18n.get("friend.joinedGameNotification.action"), IdenticonUtil.createIdenticon(player.getId()), event1 -> joinGameHelper.join(player.getGame())));
    }
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) PreferencesService(com.faforever.client.preferences.PreferencesService) IdenticonUtil(com.faforever.client.util.IdenticonUtil) JoinGameHelper(com.faforever.client.game.JoinGameHelper) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) AudioService(com.faforever.client.audio.AudioService) Component(org.springframework.stereotype.Component) PostConstruct(javax.annotation.PostConstruct) FriendJoinedGameEvent(com.faforever.client.player.event.FriendJoinedGameEvent) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) Game(com.faforever.client.game.Game) Game(com.faforever.client.game.Game) Subscribe(com.google.common.eventbus.Subscribe)

Example 8 with TransientNotification

use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.

the class FriendOnlineNotifier method onUserOnline.

@Subscribe
public void onUserOnline(UserOnlineEvent event) {
    String username = event.getUsername();
    Player player = playerService.getPlayerForUsername(username);
    if (player != null && player.getSocialStatus() == SocialStatus.FRIEND) {
        audioService.playFriendOnlineSound();
        notificationService.addNotification(new TransientNotification(i18n.get("friend.nowOnlineNotification.title", username), i18n.get("friend.nowOnlineNotification.action"), IdenticonUtil.createIdenticon(player.getId()), actionEvent -> {
            eventBus.post(new NavigateEvent(NavigationItem.CHAT));
            eventBus.post(new InitiatePrivateChatEvent(username));
        }));
    }
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) IdenticonUtil(com.faforever.client.util.IdenticonUtil) SocialStatus(com.faforever.client.chat.SocialStatus) InitiatePrivateChatEvent(com.faforever.client.chat.InitiatePrivateChatEvent) NavigationItem(com.faforever.client.main.event.NavigationItem) NavigateEvent(com.faforever.client.main.event.NavigateEvent) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) AudioService(com.faforever.client.audio.AudioService) Component(org.springframework.stereotype.Component) PostConstruct(javax.annotation.PostConstruct) Subscribe(com.google.common.eventbus.Subscribe) I18n(com.faforever.client.i18n.I18n) NavigateEvent(com.faforever.client.main.event.NavigateEvent) InitiatePrivateChatEvent(com.faforever.client.chat.InitiatePrivateChatEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 9 with TransientNotification

use of com.faforever.client.notification.TransientNotification in project downlords-faf-client by FAForever.

the class FriendOfflineNotifier method onUserOnline.

@Subscribe
public void onUserOnline(UserOfflineEvent event) {
    String username = event.getUsername();
    Player player = playerService.getPlayerForUsername(username);
    if (player != null && player.getSocialStatus() == SocialStatus.FRIEND) {
        audioService.playFriendOfflineSound();
        notificationService.addNotification(new TransientNotification(i18n.get("friend.nowOfflineNotification.title", username), "", IdenticonUtil.createIdenticon(player.getId())));
    }
}
Also used : TransientNotification(com.faforever.client.notification.TransientNotification) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

TransientNotification (com.faforever.client.notification.TransientNotification)9 I18n (com.faforever.client.i18n.I18n)5 NotificationService (com.faforever.client.notification.NotificationService)5 EventBus (com.google.common.eventbus.EventBus)5 Subscribe (com.google.common.eventbus.Subscribe)5 Inject (javax.inject.Inject)5 Component (org.springframework.stereotype.Component)4 AudioService (com.faforever.client.audio.AudioService)3 ClientProperties (com.faforever.client.config.ClientProperties)3 PlatformService (com.faforever.client.fx.PlatformService)3 Game (com.faforever.client.game.Game)3 NavigateEvent (com.faforever.client.main.event.NavigateEvent)3 NavigationItem (com.faforever.client.main.event.NavigationItem)3 PreferencesService (com.faforever.client.preferences.PreferencesService)3 IdenticonUtil (com.faforever.client.util.IdenticonUtil)3 NoCatch.noCatch (com.github.nocatch.NoCatch.noCatch)3 PostConstruct (javax.annotation.PostConstruct)3 Controller (com.faforever.client.fx.Controller)2 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)2 GameService (com.faforever.client.game.GameService)2