diff --git a/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java b/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java index f3ef0e5a9..a29a06e59 100644 --- a/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java +++ b/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java @@ -2,12 +2,10 @@ package org.cryptomator.ui.fxapp; import org.cryptomator.common.Environment; import org.cryptomator.common.settings.Settings; -import org.cryptomator.ui.health.Check; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javax.inject.Named; import javafx.beans.binding.BooleanBinding; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyStringProperty; @@ -19,7 +17,6 @@ import javafx.concurrent.Worker; import javafx.concurrent.WorkerStateEvent; import javafx.util.Duration; import java.time.LocalDateTime; -import java.util.Comparator; @FxApplicationScoped public class UpdateChecker { @@ -98,12 +95,15 @@ public class UpdateChecker { } public String getCurrentVersion() { - return "1.12.3"; //env.getAppVersion(); + return env.getAppVersion(); } public ObjectProperty updateCheckTimeProperty() { return updateCheckTimeProperty; } -public ObjectProperty updateCheckStateProperty() { return state;} + + public ObjectProperty updateCheckStateProperty() { + return state; + } } diff --git a/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java index 93c58f9c0..fb5fd964c 100644 --- a/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java @@ -1,5 +1,6 @@ package org.cryptomator.ui.preferences; +import org.cryptomator.common.Environment; import org.cryptomator.common.SemVerComparator; import org.cryptomator.common.settings.Settings; import org.cryptomator.ui.common.FxController; @@ -16,13 +17,12 @@ import javafx.beans.property.ReadOnlyStringProperty; import javafx.fxml.FXML; import javafx.scene.control.CheckBox; import javafx.scene.control.ContentDisplay; - +import javafx.scene.layout.HBox; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; import java.util.Comparator; import java.util.Locale; -import java.util.ResourceBundle; @PreferencesScoped public class UpdatesPreferencesController implements FxController { @@ -30,8 +30,8 @@ public class UpdatesPreferencesController implements FxController { private static final String DOWNLOADS_URI = "https://cryptomator.org/downloads"; private final Application application; + private final Environment environment; private final Settings settings; - private final ResourceBundle resourceBundle; private final UpdateChecker updateChecker; private final ObjectBinding checkForUpdatesButtonState; private final ReadOnlyStringProperty latestVersion; @@ -44,13 +44,14 @@ public class UpdatesPreferencesController implements FxController { /* FXML */ public CheckBox checkForUpdatesCheckbox; public FormattedLabel updateCheckDateFormattedLabel; - public FormattedLabel statusFormattedLabel; + public HBox checkFailedHBox; + public FormattedLabel latestVersionFormattedLabel; @Inject - UpdatesPreferencesController(Application application, Settings settings, ResourceBundle resourceBundle, UpdateChecker updateChecker) { + UpdatesPreferencesController(Application application, Environment environment, Settings settings, UpdateChecker updateChecker) { this.application = application; + this.environment = environment; this.settings = settings; - this.resourceBundle = resourceBundle; this.updateChecker = updateChecker; this.checkForUpdatesButtonState = Bindings.when(updateChecker.checkingForUpdatesProperty()).then(ContentDisplay.LEFT).otherwise(ContentDisplay.TEXT_ONLY); this.latestVersion = updateChecker.latestVersionProperty(); @@ -70,21 +71,13 @@ public class UpdatesPreferencesController implements FxController { checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault()); - updateCheckDateFormattedLabel.arg1Property().bind(Bindings.createStringBinding(() -> { - return (updateCheckDateProperty.get() != null) ? updateCheckDateProperty.get().format(formatter) : ""; - }, updateCheckDateProperty)); - updateCheckDateFormattedLabel.managedProperty().bind(updateCheckDateProperty.isNotNull()); - updateCheckDateFormattedLabel.visibleProperty().bind(updateCheckDateProperty.isNotNull()); + updateCheckDateFormattedLabel.arg1Property().bind(Bindings.createStringBinding(() -> (updateCheckDateProperty.get() != null) ? updateCheckDateProperty.get().format(formatter) : "-", updateCheckDateProperty)); + + checkFailedHBox.managedProperty().bind(updateCheckStateProperty.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_FAILED)); + checkFailedHBox.visibleProperty().bind(updateCheckStateProperty.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_FAILED)); + + latestVersionFormattedLabel.arg1Property().bind(Bindings.createStringBinding(() -> (latestVersion.get() != null) ? latestVersion.get() : "-", latestVersion)); - statusFormattedLabel.arg1Property().bind(Bindings.createObjectBinding(() ->{ - return switch (updateCheckStateProperty.get()) { - case NOT_CHECKED -> resourceBundle.getString("preferences.updates.status.notChecked"); - case IS_CHECKING -> resourceBundle.getString("preferences.updates.status.isChecking"); - case CHECK_SUCCESSFUL -> resourceBundle.getString("preferences.updates.status.checkSuccessful"); - case CHECK_FAILED -> resourceBundle.getString("preferences.updates.status.checkFailed"); - }; - }, updateCheckStateProperty - )); } @FXML @@ -97,6 +90,11 @@ public class UpdatesPreferencesController implements FxController { application.getHostServices().showDocument(DOWNLOADS_URI); } + @FXML + public void showLogfileDirectory() { + environment.getLogDir().ifPresent(logDirPath -> application.getHostServices().showDocument(logDirPath.toUri().toString())); + } + /* Observable Properties */ public ObjectBinding checkForUpdatesButtonStateProperty() { diff --git a/src/main/resources/fxml/preferences_updates.fxml b/src/main/resources/fxml/preferences_updates.fxml index 6efb3700b..ef037580f 100644 --- a/src/main/resources/fxml/preferences_updates.fxml +++ b/src/main/resources/fxml/preferences_updates.fxml @@ -1,14 +1,16 @@ + + + + - - + + + @@ -28,8 +33,15 @@ - - + + + + + diff --git a/src/main/resources/i18n/strings.properties b/src/main/resources/i18n/strings.properties index b449c2224..0a4c795a0 100644 --- a/src/main/resources/i18n/strings.properties +++ b/src/main/resources/i18n/strings.properties @@ -318,15 +318,12 @@ preferences.volume.feature.readOnly=Read-only mount ## Updates preferences.updates=Updates preferences.updates.currentVersion=Current Version: %s +preferences.updates.latestVersion=Latest Version: %s preferences.updates.autoUpdateCheck=Check for updates automatically preferences.updates.checkNowBtn=Check Now preferences.updates.updateAvailable=Update to version %s available. -preferences.updates.lastUpdateCheck=The last update check was performed on: %s. -preferences.updates.status=Status: %s -preferences.updates.status.notChecked=Not checked -preferences.updates.status.isChecking=Is checking -preferences.updates.status.checkSuccessful=Check successful -preferences.updates.status.checkFailed=Check failed +preferences.updates.lastUpdateCheck=The last update check was performed on: %s +preferences.updates.checkFailed=Check failed ## Contribution preferences.contribute=Support Us