Parcourir la source

cr related changes

Jan-Peter Klein il y a 1 an
Parent
commit
5519eefcfa

+ 4 - 3
src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java

@@ -8,6 +8,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
+import javafx.beans.binding.Bindings;
 import javafx.beans.binding.BooleanBinding;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.ReadOnlyStringProperty;
@@ -33,7 +34,7 @@ public class UpdateChecker {
 	private final StringProperty latestVersion = new SimpleStringProperty();
 	private final ScheduledService<String> updateCheckerService;
 	private final ObjectProperty<UpdateCheckState> state = new SimpleObjectProperty<>(UpdateCheckState.NOT_CHECKED);
-	private final ObjectProperty<Instant> lastSuccessfulUpdateCheck = new SimpleObjectProperty<>();
+	private final ObjectProperty<Instant> lastSuccessfulUpdateCheck;
 	private final Comparator<String> versionComparator = new SemVerComparator();
 	private final ObservableValue<Boolean> updateAvailable;
 	private final ObservableValue<Boolean> checkFailed;
@@ -45,9 +46,9 @@ public class UpdateChecker {
 		this.env = env;
 		this.settings = settings;
 		this.updateCheckerService = updateCheckerService;
-		this.lastSuccessfulUpdateCheck.bindBidirectional(settings.lastSuccessfulUpdateCheck);
+		this.lastSuccessfulUpdateCheck = settings.lastSuccessfulUpdateCheck;
 		this.updateAvailable = ObservableUtil.mapWithDefault(latestVersion, latest -> versionComparator.compare(getCurrentVersion(), latest) < 0, false);
-		this.checkFailed = state.map(UpdateCheckState.CHECK_FAILED::equals);
+		this.checkFailed = Bindings.equal(UpdateCheckState.CHECK_FAILED, state);
 	}
 
 	public void automaticallyCheckForUpdatesIfEnabled() {

+ 6 - 4
src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java

@@ -11,6 +11,7 @@ import javafx.application.Application;
 import javafx.beans.binding.Bindings;
 import javafx.beans.binding.BooleanBinding;
 import javafx.beans.binding.ObjectBinding;
+import javafx.beans.binding.StringBinding;
 import javafx.beans.property.BooleanProperty;
 import javafx.beans.property.ReadOnlyStringProperty;
 import javafx.beans.property.SimpleBooleanProperty;
@@ -41,6 +42,7 @@ public class UpdatesPreferencesController implements FxController {
 	private final ObjectBinding<ContentDisplay> checkForUpdatesButtonState;
 	private final ReadOnlyStringProperty latestVersion;
 	private final ObservableValue<Instant> lastSuccessfulUpdateCheck;
+	private final StringBinding lastUpdateCheckMessage;
 	private final ObservableValue<String> timeDifferenceMessage;
 	private final String currentVersion;
 	private final ObservableValue<Boolean> updateAvailable;
@@ -68,6 +70,7 @@ public class UpdatesPreferencesController implements FxController {
 		this.formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault());
 		this.upToDate = updateChecker.updateCheckStateProperty().isEqualTo(UpdateChecker.UpdateCheckState.CHECK_SUCCESSFUL).and(latestVersion.isEqualTo(currentVersion));
 		this.checkFailed = updateChecker.checkFailedProperty();
+		this.lastUpdateCheckMessage = Bindings.createStringBinding(this::getLastUpdateCheckMessage, lastSuccessfulUpdateCheck);
 	}
 
 	public void initialize() {
@@ -120,11 +123,10 @@ public class UpdatesPreferencesController implements FxController {
 		return currentVersion;
 	}
 
-	public ObservableValue<Instant> lastSuccessfulUpdateCheckProperty() {
-		return lastSuccessfulUpdateCheck;
+	public StringBinding lastUpdateCheckMessageProperty() {
+		return lastUpdateCheckMessage;
 	}
-
-	public String getLastSuccessfulUpdateCheck() {
+	public String getLastUpdateCheckMessage() {
 		Instant lastCheck = lastSuccessfulUpdateCheck.getValue();
 		if (lastCheck != null && !lastCheck.equals(Settings.DEFAULT_TIMESTAMP)) {
 			return formatter.format(LocalDateTime.ofInstant(lastCheck, ZoneId.systemDefault()));

+ 1 - 1
src/main/resources/fxml/preferences_updates.fxml

@@ -44,7 +44,7 @@
 		</TextFlow>
 		<FormattedLabel format="%preferences.updates.lastUpdateCheck" arg1="${controller.timeDifferenceMessage}" textAlignment="CENTER" wrapText="true">
 			<tooltip>
-				<Tooltip text="${controller.lastSuccessfulUpdateCheck}" showDelay="10ms"/>
+				<Tooltip text="${controller.lastUpdateCheckMessage}" showDelay="10ms"/>
 			</tooltip>
 		</FormattedLabel>
 		<Label text="%preferences.updates.upToDate" visible="${controller.upToDateLabelVisible}" managed="${controller.upToDateLabelVisible}">