From d379ada10074bd114a1e0e540af53b2886567521 Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Wed, 26 Jun 2024 15:13:28 +0200 Subject: [PATCH 1/9] addded debug, update and support notification bar --- .../ui/mainwindow/MainWindowController.java | 62 +++++++++++++++++-- src/main/resources/css/dark_theme.css | 29 +++++++++ src/main/resources/css/light_theme.css | 29 +++++++++ src/main/resources/fxml/main_window.fxml | 11 ++++ src/main/resources/i18n/strings.properties | 4 ++ 5 files changed, 130 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java index a09c3afba..3b73b4338 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java @@ -1,16 +1,22 @@ package org.cryptomator.ui.mainwindow; import org.apache.commons.lang3.SystemUtils; +import org.cryptomator.common.LicenseHolder; import org.cryptomator.common.settings.Settings; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultListManager; import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.fxapp.FxApplicationWindows; +import org.cryptomator.ui.fxapp.UpdateChecker; +import org.cryptomator.ui.preferences.SelectedPreferencesTab; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; import javafx.beans.Observable; +import javafx.beans.binding.BooleanBinding; import javafx.beans.property.ObjectProperty; +import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.fxml.FXML; import javafx.scene.layout.StackPane; @@ -24,14 +30,25 @@ public class MainWindowController implements FxController { private final Stage window; private final ReadOnlyObjectProperty selectedVault; private final Settings settings; + private final FxApplicationWindows appWindows; + private final BooleanBinding updateAvailable; + private final LicenseHolder licenseHolder; public StackPane root; @Inject - public MainWindowController(@MainWindow Stage window, ObjectProperty selectedVault, Settings settings) { + public MainWindowController(@MainWindow Stage window, // + ObjectProperty selectedVault, // + Settings settings, // + FxApplicationWindows appWindows, // + UpdateChecker updateChecker, // + LicenseHolder licenseHolder) { this.window = window; this.selectedVault = selectedVault; this.settings = settings; + this.appWindows = appWindows; + this.updateAvailable = updateChecker.updateAvailableProperty(); + this.licenseHolder = licenseHolder; } @FXML @@ -48,10 +65,10 @@ public class MainWindowController implements FxController { window.setX(settings.windowXPosition.get()); window.setY(settings.windowYPosition.get()); } - window.widthProperty().addListener((_,_,_) -> savePositionalSettings()); - window.heightProperty().addListener((_,_,_) -> savePositionalSettings()); - window.xProperty().addListener((_,_,_) -> savePositionalSettings()); - window.yProperty().addListener((_,_,_) -> savePositionalSettings()); + window.widthProperty().addListener((_, _, _) -> savePositionalSettings()); + window.heightProperty().addListener((_, _, _) -> savePositionalSettings()); + window.xProperty().addListener((_, _, _) -> savePositionalSettings()); + window.yProperty().addListener((_, _, _) -> savePositionalSettings()); } private boolean neverTouched() { @@ -73,4 +90,39 @@ public class MainWindowController implements FxController { } } + @FXML + public void showGeneralPreferences() { + appWindows.showPreferencesWindow(SelectedPreferencesTab.GENERAL); + } + + @FXML + public void showContributePreferences() { + appWindows.showPreferencesWindow(SelectedPreferencesTab.CONTRIBUTE); + } + + @FXML + public void showUpdatePreferences() { + appWindows.showPreferencesWindow(SelectedPreferencesTab.UPDATES); + } + + public LicenseHolder getLicenseHolder() { + return licenseHolder; + } + + public ReadOnlyBooleanProperty debugModeEnabledProperty() { + return settings.debugMode; + } + + public boolean isDebugModeEnabled() { + return debugModeEnabledProperty().get(); + } + + public BooleanBinding updateAvailableProperty() { + return updateAvailable; + } + + public boolean isUpdateAvailable() { + return updateAvailable.get(); + } + } diff --git a/src/main/resources/css/dark_theme.css b/src/main/resources/css/dark_theme.css index bba91cb11..61270eeab 100644 --- a/src/main/resources/css/dark_theme.css +++ b/src/main/resources/css/dark_theme.css @@ -362,6 +362,35 @@ -fx-border-width: 1px 0 0 0; } +/******************************************************************************* + * * + * NotificationBar * + * * + ******************************************************************************/ + +.notification-label { + -fx-text-fill: white; + -fx-font-weight: bold; +} + +.notification-debug { + -fx-min-height:24px; + -fx-max-height:24px; + -fx-background-color: RED_5; +} + +.notification-update { + -fx-min-height:24px; + -fx-max-height:24px; + -fx-background-color: YELLOW_5; +} + +.notification-support { + -fx-min-height:24px; + -fx-max-height:24px; + -fx-background-color: PRIMARY; +} + /******************************************************************************* * * * ScrollBar * diff --git a/src/main/resources/css/light_theme.css b/src/main/resources/css/light_theme.css index d000c0464..c8b7eaf79 100644 --- a/src/main/resources/css/light_theme.css +++ b/src/main/resources/css/light_theme.css @@ -360,6 +360,35 @@ -fx-border-width: 1px 0 0 0; } +/******************************************************************************* + * * + * NotificationBar * + * * + ******************************************************************************/ + +.notification-label { + -fx-text-fill: white; + -fx-font-weight: bold; +} + +.notification-debug { + -fx-min-height:24px; + -fx-max-height:24px; + -fx-background-color: RED_5; +} + +.notification-update { + -fx-min-height:24px; + -fx-max-height:24px; + -fx-background-color: YELLOW_5; +} + +.notification-support { + -fx-min-height:24px; + -fx-max-height:24px; + -fx-background-color: PRIMARY; +} + /******************************************************************************* * * * ScrollBar * diff --git a/src/main/resources/fxml/main_window.fxml b/src/main/resources/fxml/main_window.fxml index cefa18e58..eed8fc695 100644 --- a/src/main/resources/fxml/main_window.fxml +++ b/src/main/resources/fxml/main_window.fxml @@ -3,15 +3,26 @@ + + + + + + + + diff --git a/src/main/resources/i18n/strings.properties b/src/main/resources/i18n/strings.properties index 4309351b5..5e79550b5 100644 --- a/src/main/resources/i18n/strings.properties +++ b/src/main/resources/i18n/strings.properties @@ -392,6 +392,10 @@ main.vaultlist.contextMenu.reveal=Reveal Drive main.vaultlist.addVaultBtn=Add Vault main.vaultlist.addVaultBtn.menuItemNew=New Vault... main.vaultlist.addVaultBtn.menuItemExisting=Existing Vault... +##Notificaition +main.notification.updateAvailable=Update is available. +main.notification.support=Support Cryptomator. +main.notification.debugMode=DEBUG MODE ## Vault Detail ### Welcome main.vaultDetail.welcomeOnboarding=Thanks for choosing Cryptomator to protect your files. If you need any assistance, check out our getting started guides: From 8ff06a3efd5eeceb6cac54a45422e0b53558b7d7 Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Tue, 2 Jul 2024 12:43:27 +0200 Subject: [PATCH 2/9] implement hideable notification bars --- .../ui/mainwindow/MainWindowController.java | 52 +++++++++++++++++++ src/main/resources/fxml/main_window.fxml | 18 +++++-- src/main/resources/i18n/strings.properties | 1 - 3 files changed, 66 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java index 3b73b4338..ee16205f3 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java @@ -14,10 +14,13 @@ import org.slf4j.LoggerFactory; import javax.inject.Inject; import javafx.beans.Observable; +import javafx.beans.binding.Bindings; import javafx.beans.binding.BooleanBinding; +import javafx.beans.property.BooleanProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyBooleanProperty; import javafx.beans.property.ReadOnlyObjectProperty; +import javafx.beans.property.SimpleBooleanProperty; import javafx.fxml.FXML; import javafx.scene.layout.StackPane; import javafx.stage.Stage; @@ -33,6 +36,10 @@ public class MainWindowController implements FxController { private final FxApplicationWindows appWindows; private final BooleanBinding updateAvailable; 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; @@ -69,6 +76,9 @@ public class MainWindowController implements FxController { window.heightProperty().addListener((_, _, _) -> savePositionalSettings()); window.xProperty().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() { @@ -105,6 +115,16 @@ public class MainWindowController implements FxController { appWindows.showPreferencesWindow(SelectedPreferencesTab.UPDATES); } + @FXML + public void hideSupportNotification() { + this.hideSupportNotificationClicked.setValue(true); + } + + @FXML + public void hideUpdateNotification() { + this.hideUpdateNotificationClicked.setValue(true); + } + public LicenseHolder getLicenseHolder() { return licenseHolder; } @@ -125,4 +145,36 @@ public class MainWindowController implements FxController { 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(); + } + } diff --git a/src/main/resources/fxml/main_window.fxml b/src/main/resources/fxml/main_window.fxml index eed8fc695..29e9ea36a 100644 --- a/src/main/resources/fxml/main_window.fxml +++ b/src/main/resources/fxml/main_window.fxml @@ -5,24 +5,34 @@ + + - + + +