diff --git a/src/main/java/org/cryptomator/ui/common/SystemBarUtil.java b/src/main/java/org/cryptomator/ui/common/SystemBarUtil.java index 2f676ee43..9faaa60db 100644 --- a/src/main/java/org/cryptomator/ui/common/SystemBarUtil.java +++ b/src/main/java/org/cryptomator/ui/common/SystemBarUtil.java @@ -2,20 +2,48 @@ package org.cryptomator.ui.common; import javafx.stage.Screen; +/** + * Utility class providing methods regarding the OS bar. + */ public class SystemBarUtil { public enum Placement { + /** + * OS Bar placed at the left screen edge + */ LEFT, + /** + * OS Bar placed at the top screen edge + */ TOP, + /** + * OS Bar placed at the right screen edge + */ RIGHT, + /** + * OS Bar placed at the bottom screen edge + */ BOTTOM; } + /** + * Determines the placement of the OS bar on the given screen. + *

+ * Assuming the OS bar fills one screen edge completely, + * this method determines that screen edge by comparing the actual screen bounds with the visual ones. + *

+ * If the screen does not have a system bar, the bottom placement is returned. + * If the screen does have multiple system bars, the first in following priority is returned: + * LEFT, TOP, RIGHT, BOTTOM. + * + * @param screen a {@link Screen} where an OS bar exists + * @return {@link Placement} indicating the screen edge. + */ public static Placement getPlacementOfSystembar(Screen screen) { var bounds = screen.getBounds(); var vBounds = screen.getVisualBounds(); //assumption: the system bar fills a whole screen side - if(bounds.getMinX() != vBounds.getMinX()){ + if (bounds.getMinX() != vBounds.getMinX()) { return Placement.LEFT; } else if (bounds.getMinY() != vBounds.getMinY()) { return Placement.TOP; diff --git a/src/main/java/org/cryptomator/ui/notification/NotificationController.java b/src/main/java/org/cryptomator/ui/notification/NotificationController.java index 229fcb3a9..7bdf52541 100644 --- a/src/main/java/org/cryptomator/ui/notification/NotificationController.java +++ b/src/main/java/org/cryptomator/ui/notification/NotificationController.java @@ -1,6 +1,5 @@ package org.cryptomator.ui.notification; -import org.cryptomator.cryptofs.event.FilesystemEvent; import org.cryptomator.event.VaultEvent; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.fxapp.FxNotificationRadar; @@ -25,6 +24,8 @@ import java.util.concurrent.ExecutorService; @NotificationScoped public class NotificationController implements FxController { + private static final String BUG_MSG = "IF YOU SEE THIS MESSAGE, PLEASE CONTACT THE DEVELOPERS OF CRYPTOMATOR ABOUT A BUG IN THE NOTIFICATION DISPLAY"; + private final Stage window; private final SimpleListProperty notificationsProp; private final IntegerProperty selectionIndex; @@ -42,7 +43,7 @@ public class NotificationController implements FxController { this.selectionIndex = new SimpleIntegerProperty(0); this.selectedEvent = new SimpleObjectProperty<>(); selectionIndex.addListener((_, _, n) -> { - if (! notificationsProp.isEmpty()) { + if (!notificationsProp.isEmpty()) { selectedEvent.setValue(notificationsProp.get(n.intValue())); } }); @@ -61,10 +62,18 @@ public class NotificationController implements FxController { //TODO: Translations! private void adjustTexts(ObservableValue observable, VaultEvent oldEvent, VaultEvent newEvent) { + if (newEvent == null) { + message.set("NO CONTENT"); + description.set(BUG_MSG); + actionText.set(null); + return; + } + switch (newEvent.actualEvent()) { default -> { message.set("NO CONTENT"); - description.set("IF YOU SEE THIS MESSAGE, PLEASE CONTACT THE DEVELOPERS OF CRYPTOMATOR ABOUT A BUG IN THE NOTIFICATION DISPLAY"); + description.set(BUG_MSG); + actionText.set(null); } } } @@ -147,7 +156,7 @@ public class NotificationController implements FxController { } public boolean isButtonVisible() { - return actionText.get() != null; + return actionText.get() != null && !actionText.get().isBlank(); } public ObservableStringValue pagingProperty() {