Переглянути джерело

adding version number to settings dialogue

Armin Schrenk 5 роки тому
батько
коміт
c961eb0ca0

+ 7 - 0
main/ui/src/main/java/org/cryptomator/ui/fxapp/UpdateChecker.java

@@ -2,6 +2,7 @@ package org.cryptomator.ui.fxapp;
 
 import javafx.beans.binding.BooleanBinding;
 import javafx.beans.property.ReadOnlyStringProperty;
+import javafx.beans.property.SimpleStringProperty;
 import javafx.beans.property.StringProperty;
 import javafx.concurrent.ScheduledService;
 import javafx.concurrent.Worker;
@@ -24,6 +25,7 @@ public class UpdateChecker {
 
 	private final Settings settings;
 	private final Optional<String> applicationVersion;
+	private final StringProperty currentVersionProperty;
 	private final StringProperty latestVersionProperty;
 	private final Comparator<String> semVerComparator;
 	private final ScheduledService<String> updateCheckerService;
@@ -35,6 +37,7 @@ public class UpdateChecker {
 		this.latestVersionProperty = latestVersionProperty;
 		this.semVerComparator = semVerComparator;
 		this.updateCheckerService = updateCheckerService;
+		this.currentVersionProperty = new SimpleStringProperty(applicationVersion.orElse("SNAPSHOT"));
 	}
 
 	public void automaticallyCheckForUpdatesIfEnabled() {
@@ -87,4 +90,8 @@ public class UpdateChecker {
 		return latestVersionProperty;
 	}
 
+	public ReadOnlyStringProperty currentVersionProperty() {
+		return currentVersionProperty;
+	}
+
 }

+ 10 - 1
main/ui/src/main/java/org/cryptomator/ui/preferences/UpdatesPreferencesController.java

@@ -7,7 +7,6 @@ import javafx.beans.property.ReadOnlyStringProperty;
 import javafx.fxml.FXML;
 import javafx.scene.control.CheckBox;
 import javafx.scene.control.ContentDisplay;
-import javafx.util.Duration;
 import org.cryptomator.common.settings.Settings;
 import org.cryptomator.ui.common.FxController;
 import org.cryptomator.ui.fxapp.UpdateChecker;
@@ -21,6 +20,7 @@ public class UpdatesPreferencesController implements FxController {
 	private final UpdateChecker updateChecker;
 	private final ObjectBinding<ContentDisplay> checkForUpdatesButtonState;
 	private final ReadOnlyStringProperty latestVersion;
+	private final ReadOnlyStringProperty currentVersion;
 	private final BooleanBinding updateAvailable;
 	public CheckBox checkForUpdatesCheckbox;
 
@@ -31,6 +31,7 @@ public class UpdatesPreferencesController implements FxController {
 		this.checkForUpdatesButtonState = Bindings.when(updateChecker.checkingForUpdatesProperty()).then(ContentDisplay.LEFT).otherwise(ContentDisplay.TEXT_ONLY);
 		this.latestVersion = updateChecker.latestVersionProperty();
 		this.updateAvailable = latestVersion.isNotNull();
+		this.currentVersion = updateChecker.currentVersionProperty();
 	}
 
 	public void initialize() {
@@ -60,6 +61,14 @@ public class UpdatesPreferencesController implements FxController {
 		return latestVersion.get();
 	}
 
+	public ReadOnlyStringProperty currentVersionProperty() {
+		return currentVersion;
+	}
+
+	public String getCurrentVersion() {
+		return currentVersion.get();
+	}
+
 	public BooleanBinding updateAvailableProperty() {
 		return updateAvailable;
 	}

+ 2 - 0
main/ui/src/main/resources/fxml/preferences_updates.fxml

@@ -14,6 +14,8 @@
 		<Insets topRightBottomLeft="12"/>
 	</padding>
 	<children>
+		<FormattedLabel format="%preferences.updates.currentVersion" arg1="${controller.currentVersion}" textAlignment="CENTER" wrapText="true"/>
+
 		<CheckBox fx:id="checkForUpdatesCheckbox" text="%preferences.updates.autoUpdateCheck"/>
 
 		<VBox alignment="CENTER" spacing="6">

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

@@ -107,6 +107,7 @@ preferences.volume.webdav.port=WebDAV Port
 preferences.volume.webdav.scheme=WebDAV Scheme
 ## Updates
 preferences.updates=Updates
+preferences.updates.currentVersion=Current Version: %s
 preferences.updates.autoUpdateCheck=Check for updates automatically
 preferences.updates.checkNowBtn=Check Now
 preferences.updates.updateAvailable=Update to version %s available.

+ 1 - 0
main/ui/src/main/resources/i18n/strings_de.properties

@@ -95,6 +95,7 @@ preferences.volume.webdav.port=WebDAV-Port
 preferences.volume.webdav.scheme=WebDAV-Schema
 ## Updates
 preferences.updates=Updates
+preferences.updates.currentVersion=Aktuelle Version: %s
 preferences.updates.autoUpdateCheck=Automatisch nach Updates suchen
 preferences.updates.checkNowBtn=Jetzt prüfen
 preferences.updates.updateAvailable=Update auf Version %s verfügbar.