Browse Source

implement hideable notification bars

Jan-Peter Klein 1 year ago
parent
commit
8ff06a3efd

+ 52 - 0
src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java

@@ -14,10 +14,13 @@ import org.slf4j.LoggerFactory;
 
 
 import javax.inject.Inject;
 import javax.inject.Inject;
 import javafx.beans.Observable;
 import javafx.beans.Observable;
+import javafx.beans.binding.Bindings;
 import javafx.beans.binding.BooleanBinding;
 import javafx.beans.binding.BooleanBinding;
+import javafx.beans.property.BooleanProperty;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.ReadOnlyBooleanProperty;
 import javafx.beans.property.ReadOnlyBooleanProperty;
 import javafx.beans.property.ReadOnlyObjectProperty;
 import javafx.beans.property.ReadOnlyObjectProperty;
+import javafx.beans.property.SimpleBooleanProperty;
 import javafx.fxml.FXML;
 import javafx.fxml.FXML;
 import javafx.scene.layout.StackPane;
 import javafx.scene.layout.StackPane;
 import javafx.stage.Stage;
 import javafx.stage.Stage;
@@ -33,6 +36,10 @@ public class MainWindowController implements FxController {
 	private final FxApplicationWindows appWindows;
 	private final FxApplicationWindows appWindows;
 	private final BooleanBinding updateAvailable;
 	private final BooleanBinding updateAvailable;
 	private final LicenseHolder licenseHolder;
 	private final LicenseHolder licenseHolder;
+	private final BooleanProperty hideSupportNotificationClicked = new SimpleBooleanProperty(false);
+	private final BooleanProperty supportNotificationHidden = new SimpleBooleanProperty();
+	private final BooleanProperty hideUpdateNotificationClicked = new SimpleBooleanProperty(false);
+	private final BooleanProperty updateNotificationHidden = new SimpleBooleanProperty();
 
 
 	public StackPane root;
 	public StackPane root;
 
 
@@ -69,6 +76,9 @@ public class MainWindowController implements FxController {
 		window.heightProperty().addListener((_, _, _) -> savePositionalSettings());
 		window.heightProperty().addListener((_, _, _) -> savePositionalSettings());
 		window.xProperty().addListener((_, _, _) -> savePositionalSettings());
 		window.xProperty().addListener((_, _, _) -> savePositionalSettings());
 		window.yProperty().addListener((_, _, _) -> savePositionalSettings());
 		window.yProperty().addListener((_, _, _) -> savePositionalSettings());
+
+		supportNotificationHidden.bind(Bindings.createBooleanBinding(() -> !licenseHolder.isValidLicense() && !hideSupportNotificationClicked.get(), hideSupportNotificationClicked));
+		updateNotificationHidden.bind(Bindings.createBooleanBinding(() -> updateAvailable.get() && !hideUpdateNotificationClicked.get(), hideUpdateNotificationClicked));
 	}
 	}
 
 
 	private boolean neverTouched() {
 	private boolean neverTouched() {
@@ -105,6 +115,16 @@ public class MainWindowController implements FxController {
 		appWindows.showPreferencesWindow(SelectedPreferencesTab.UPDATES);
 		appWindows.showPreferencesWindow(SelectedPreferencesTab.UPDATES);
 	}
 	}
 
 
+	@FXML
+	public void hideSupportNotification() {
+		this.hideSupportNotificationClicked.setValue(true);
+	}
+
+	@FXML
+	public void hideUpdateNotification() {
+		this.hideUpdateNotificationClicked.setValue(true);
+	}
+
 	public LicenseHolder getLicenseHolder() {
 	public LicenseHolder getLicenseHolder() {
 		return licenseHolder;
 		return licenseHolder;
 	}
 	}
@@ -125,4 +145,36 @@ public class MainWindowController implements FxController {
 		return updateAvailable.get();
 		return updateAvailable.get();
 	}
 	}
 
 
+	public BooleanProperty hideSupportNotificationClickedProperty() {
+		return hideSupportNotificationClicked;
+	}
+
+	public boolean isHideSupportNotificationClicked() {
+		return hideSupportNotificationClicked.get();
+	}
+
+	public BooleanProperty supportNotificationHiddenProperty() {
+		return supportNotificationHidden;
+	}
+
+	public boolean isSupportNotificationHidden() {
+		return supportNotificationHidden.get();
+	}
+
+	public BooleanProperty hideUpdateNotificationClickedProperty() {
+		return hideUpdateNotificationClicked;
+	}
+
+	public boolean isHideUpdateNotificationClicked() {
+		return hideUpdateNotificationClicked.get();
+	}
+
+	public BooleanProperty updateNotificationHiddenProperty() {
+		return updateNotificationHidden;
+	}
+
+	public boolean isUpdateNotificationHidden() {
+		return updateNotificationHidden.get();
+	}
+
 }
 }

+ 14 - 4
src/main/resources/fxml/main_window.fxml

@@ -5,24 +5,34 @@
 <?import javafx.scene.layout.VBox?>
 <?import javafx.scene.layout.VBox?>
 <?import javafx.scene.layout.HBox?>
 <?import javafx.scene.layout.HBox?>
 <?import javafx.scene.control.Label?>
 <?import javafx.scene.control.Label?>
+<?import javafx.scene.layout.Region?>
+<?import javafx.scene.control.Button?>
 <StackPane xmlns:fx="http://javafx.com/fxml"
 <StackPane xmlns:fx="http://javafx.com/fxml"
 		   xmlns="http://javafx.com/javafx"
 		   xmlns="http://javafx.com/javafx"
 		   fx:id="root"
 		   fx:id="root"
 		   fx:controller="org.cryptomator.ui.mainwindow.MainWindowController"
 		   fx:controller="org.cryptomator.ui.mainwindow.MainWindowController"
 		   styleClass="main-window">
 		   styleClass="main-window">
 	<VBox minWidth="650">
 	<VBox minWidth="650">
-		<HBox onMouseClicked="#showUpdatePreferences" alignment="CENTER" styleClass="notification-update" VBox.vgrow="ALWAYS" visible="${controller.updateAvailable}" managed="${controller.updateAvailable}">
+		<HBox onMouseClicked="#showUpdatePreferences" alignment="CENTER" styleClass="notification-update" VBox.vgrow="ALWAYS" visible="${controller.updateNotificationHidden}" managed="${controller.updateNotificationHidden}">
+			<Region minWidth="40"/>
+			<Region HBox.hgrow="ALWAYS"/>
 			<Label text="%main.notification.updateAvailable" styleClass="notification-label" />
 			<Label text="%main.notification.updateAvailable" styleClass="notification-label" />
+			<Region HBox.hgrow="ALWAYS"/>
+			<Button minWidth="40" text="X" onMouseClicked="#hideUpdateNotification" style="-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;"/>
 		</HBox>
 		</HBox>
-		<HBox onMouseClicked="#showContributePreferences" alignment="CENTER" styleClass="notification-support" VBox.vgrow="ALWAYS" visible="${!controller.licenseHolder.validLicense}" managed="${!controller.licenseHolder.validLicense}">
-			<Label text="%main.notification.support" styleClass="notification-label"/>
+		<HBox onMouseClicked="#showContributePreferences" alignment="CENTER" styleClass="notification-support" VBox.vgrow="ALWAYS" visible="${controller.supportNotificationHidden}" managed="${controller.supportNotificationHidden}">
+			<Region minWidth="40"/>
+			<Region HBox.hgrow="ALWAYS"/>
+			<Label text="%main.notification.support" styleClass="notification-label" />
+			<Region HBox.hgrow="ALWAYS"/>
+			<Button minWidth="40" text="X" onMouseClicked="#hideSupportNotification" style="-fx-background-color: transparent; -fx-text-fill: white; -fx-font-weight: bold;"/>
 		</HBox>
 		</HBox>
 		<SplitPane dividerPositions="0.33" orientation="HORIZONTAL" VBox.vgrow="ALWAYS">
 		<SplitPane dividerPositions="0.33" orientation="HORIZONTAL" VBox.vgrow="ALWAYS">
 			<fx:include source="vault_list.fxml" SplitPane.resizableWithParent="false"/>
 			<fx:include source="vault_list.fxml" SplitPane.resizableWithParent="false"/>
 			<fx:include source="vault_detail.fxml" SplitPane.resizableWithParent="true"/>
 			<fx:include source="vault_detail.fxml" SplitPane.resizableWithParent="true"/>
 		</SplitPane>
 		</SplitPane>
 		<HBox onMouseClicked="#showGeneralPreferences" alignment="CENTER" styleClass="notification-debug" VBox.vgrow="ALWAYS" visible="${controller.debugModeEnabled}" managed="${controller.debugModeEnabled}">
 		<HBox onMouseClicked="#showGeneralPreferences" alignment="CENTER" styleClass="notification-debug" VBox.vgrow="ALWAYS" visible="${controller.debugModeEnabled}" managed="${controller.debugModeEnabled}">
-			<Label text="%main.notification.debugMode" styleClass="notification-label"/>
+			<Label text="DEBUG MODE" styleClass="notification-label"/>
 		</HBox>
 		</HBox>
 	</VBox>
 	</VBox>
 </StackPane>
 </StackPane>

+ 0 - 1
src/main/resources/i18n/strings.properties

@@ -395,7 +395,6 @@ main.vaultlist.addVaultBtn.menuItemExisting=Existing Vault...
 ##Notificaition
 ##Notificaition
 main.notification.updateAvailable=Update is available.
 main.notification.updateAvailable=Update is available.
 main.notification.support=Support Cryptomator.
 main.notification.support=Support Cryptomator.
-main.notification.debugMode=DEBUG MODE
 ## Vault Detail
 ## Vault Detail
 ### Welcome
 ### Welcome
 main.vaultDetail.welcomeOnboarding=Thanks for choosing Cryptomator to protect your files. If you need any assistance, check out our getting started guides:
 main.vaultDetail.welcomeOnboarding=Thanks for choosing Cryptomator to protect your files. If you need any assistance, check out our getting started guides: