From 128176db1f84ea6ab200a2b3a0dd66e9a90e02e4 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Thu, 26 Mar 2020 15:09:29 +0100 Subject: [PATCH] Added posibility to add build number to "about" dialog --- .../java/org/cryptomator/common/Environment.java | 8 ++++++-- .../ui/preferences/AboutController.java | 15 +++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/Environment.java b/main/commons/src/main/java/org/cryptomator/common/Environment.java index 8dfb56ef2..890840b7d 100644 --- a/main/commons/src/main/java/org/cryptomator/common/Environment.java +++ b/main/commons/src/main/java/org/cryptomator/common/Environment.java @@ -39,6 +39,7 @@ public class Environment { LOG.debug("cryptomator.logDir: {}", System.getProperty("cryptomator.logDir")); LOG.debug("cryptomator.mountPointsDir: {}", System.getProperty("cryptomator.mountPointsDir")); LOG.debug("cryptomator.minPwLength: {}", System.getProperty("cryptomator.minPwLength")); + LOG.debug("cryptomator.buildNumber: {}", System.getProperty("cryptomator.buildNumber")); } public boolean useCustomLogbackConfig() { @@ -65,6 +66,10 @@ public class Environment { return getPath("cryptomator.mountPointsDir").map(this::replaceHomeDir); } + public Optional getBuildNumber() { + return Optional.ofNullable(System.getProperty("cryptomator.buildNumber")); + } + public int getMinPwLength() { return getInt("cryptomator.minPwLength", DEFAULT_MIN_PW_LENGTH); } @@ -82,8 +87,8 @@ public class Environment { String value = System.getProperty(propertyName); return Optional.ofNullable(value).map(Paths::get); } - // visible for testing + Stream getPaths(String propertyName) { Stream rawSettingsPaths = getRawList(propertyName, PATH_LIST_SEP); return rawSettingsPaths.filter(Predicate.not(Strings::isNullOrEmpty)).map(Paths::get).map(this::replaceHomeDir); @@ -107,5 +112,4 @@ public class Environment { return StreamSupport.stream(spliter, false); } } - } diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/AboutController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/AboutController.java index 97599cf7a..758e0113b 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/AboutController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/AboutController.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.preferences; import com.google.common.io.CharStreams; +import org.cryptomator.common.Environment; import org.cryptomator.ui.common.FxController; import org.cryptomator.ui.fxapp.UpdateChecker; import org.slf4j.Logger; @@ -13,18 +14,20 @@ import java.io.InputStreamReader; @PreferencesScoped public class AboutController implements FxController { - + private static final Logger LOG = LoggerFactory.getLogger(AboutController.class); - + private final String thirdPartyLicenseText; private final String applicationVersion; @Inject - AboutController(UpdateChecker updateChecker) { + AboutController(UpdateChecker updateChecker, Environment environment) { this.thirdPartyLicenseText = loadThirdPartyLicenseFile(); - this.applicationVersion = updateChecker.currentVersionProperty().get(); + StringBuilder sb = new StringBuilder(updateChecker.currentVersionProperty().get()); + environment.getBuildNumber().ifPresent(s -> sb.append(" (").append(s).append(')')); + this.applicationVersion = sb.toString(); } - + private static String loadThirdPartyLicenseFile() { try (InputStream in = AboutController.class.getResourceAsStream("/license/THIRD-PARTY.txt")) { return CharStreams.toString(new InputStreamReader(in)); @@ -33,7 +36,7 @@ public class AboutController implements FxController { return ""; } } - + /* Getter */ public String getThirdPartyLicenseText() {