diff --git a/main/ui/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java b/main/ui/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java index c5ee4ff5c..0a735865f 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java +++ b/main/ui/src/main/java/org/cryptomator/ui/fxapp/UpdateCheckerModule.java @@ -2,6 +2,10 @@ package org.cryptomator.ui.fxapp; import dagger.Module; import dagger.Provides; +import javafx.beans.binding.BooleanBinding; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.ReadOnlyBooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; import javafx.concurrent.ScheduledService; @@ -22,6 +26,13 @@ public abstract class UpdateCheckerModule { private static final URI LATEST_VERSION_URI = URI.create("https://api.cryptomator.org/updates/latestVersion.json"); private static final Duration UPDATE_CHECK_INTERVAL = Duration.hours(3); + @Provides + @Named("checkingForUpdates") + @FxApplicationScoped + static ReadOnlyBooleanProperty provideCheckingForUpdates(ScheduledService updateCheckerService) { + return updateCheckerService.runningProperty(); + } + @Provides @Named("latestVersion") @FxApplicationScoped @@ -41,8 +52,7 @@ public abstract class UpdateCheckerModule { String userAgent = String.format("Cryptomator VersionChecker/%s %s %s (%s)", applicationVersion.orElse("SNAPSHOT"), SystemUtils.OS_NAME, SystemUtils.OS_VERSION, SystemUtils.OS_ARCH); return HttpRequest.newBuilder() // .uri(LATEST_VERSION_URI) // - .header("User-Agent", userAgent) - .build(); + .header("User-Agent", userAgent).build(); } @Provides diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java index 9eaaaf085..4b1b2295b 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java @@ -1,24 +1,45 @@ package org.cryptomator.ui.preferences; +import javafx.beans.binding.Bindings; +import javafx.beans.binding.ObjectBinding; +import javafx.beans.property.ReadOnlyBooleanProperty; +import javafx.fxml.FXML; import javafx.scene.control.CheckBox; +import javafx.scene.control.ContentDisplay; import org.cryptomator.common.settings.Settings; import org.cryptomator.ui.common.FxController; import javax.inject.Inject; +import javax.inject.Named; @PreferencesScoped public class UpdatesPreferencesController implements FxController { private final Settings settings; + private final ObjectBinding checkForUpdatesButtonState; public CheckBox checkForUpdatesCheckbox; @Inject - UpdatesPreferencesController(Settings settings) { + UpdatesPreferencesController(Settings settings, @Named("checkingForUpdates") ReadOnlyBooleanProperty checkingForUpdates) { this.settings = settings; + this.checkForUpdatesButtonState = Bindings.when(checkingForUpdates).then(ContentDisplay.LEFT).otherwise(ContentDisplay.TEXT_ONLY); } public void initialize() { checkForUpdatesCheckbox.selectedProperty().bindBidirectional(settings.checkForUpdates()); } + @FXML + public void checkNow() { + } + + /* Getter/Setter */ + + public ObjectBinding checkForUpdatesButtonStateProperty() { + return checkForUpdatesButtonState; + } + + public ContentDisplay getCheckForUpdatesButtonState() { + return checkForUpdatesButtonState.get(); + } } diff --git a/main/ui/src/main/resources/fxml/preferences_updates.fxml b/main/ui/src/main/resources/fxml/preferences_updates.fxml index 7ca9bcc1e..a95565d2c 100644 --- a/main/ui/src/main/resources/fxml/preferences_updates.fxml +++ b/main/ui/src/main/resources/fxml/preferences_updates.fxml @@ -3,6 +3,8 @@ + + + +