Browse Source

removed state label and reorganized ui elements

Jan-Peter Klein 1 năm trước cách đây
mục cha
commit
8064d75102

+ 5 - 5
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<LocalDateTime> updateCheckTimeProperty() {
 		return updateCheckTimeProperty;
 	}
-public ObjectProperty<UpdateCheckState> updateCheckStateProperty() { return state;}
+
+	public ObjectProperty<UpdateCheckState> updateCheckStateProperty() {
+		return state;
+	}
 
 }

+ 19 - 21
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<ContentDisplay> 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());
-
-		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
-				));
+		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));
+
 	}
 
 	@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<ContentDisplay> checkForUpdatesButtonStateProperty() {

+ 16 - 4
src/main/resources/fxml/preferences_updates.fxml

@@ -1,14 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
+<?import org.cryptomator.ui.controls.FontAwesome5IconView?>
+<?import org.cryptomator.ui.controls.FontAwesome5Spinner?>
 <?import org.cryptomator.ui.controls.FormattedLabel?>
 <?import org.cryptomator.ui.controls.FormattedString?>
 <?import javafx.geometry.Insets?>
 <?import javafx.scene.control.Button?>
 <?import javafx.scene.control.CheckBox?>
 <?import javafx.scene.control.Hyperlink?>
+<?import javafx.scene.control.Label?>
+<?import javafx.scene.layout.HBox?>
 <?import javafx.scene.layout.VBox?>
-<?import org.cryptomator.ui.controls.FontAwesome5Spinner?>
-
 <VBox xmlns:fx="http://javafx.com/fxml"
 	  xmlns="http://javafx.com/javafx"
 	  fx:controller="org.cryptomator.ui.preferences.UpdatesPreferencesController"
@@ -20,6 +22,9 @@
 		<Insets topRightBottomLeft="24"/>
 	</padding>
 	<FormattedLabel format="%preferences.updates.currentVersion" arg1="${controller.currentVersion}" textAlignment="CENTER" wrapText="true"/>
+	<FormattedLabel fx:id="latestVersionFormattedLabel" format="%preferences.updates.latestVersion" arg1="-" textAlignment="CENTER" wrapText="true"/>
+	<FormattedLabel fx:id="updateCheckDateFormattedLabel" format="%preferences.updates.lastUpdateCheck" arg1="-" textAlignment="CENTER" wrapText="true"/>
+
 	<CheckBox fx:id="checkForUpdatesCheckbox" text="%preferences.updates.autoUpdateCheck"/>
 
 	<VBox alignment="CENTER" spacing="12">
@@ -28,8 +33,15 @@
 				<FontAwesome5Spinner glyphSize="12"/>
 			</graphic>
 		</Button>
-		<FormattedLabel fx:id="statusFormattedLabel" format="%preferences.updates.status" wrapText="true"/>
-		<FormattedLabel fx:id="updateCheckDateFormattedLabel" format="%preferences.updates.lastUpdateCheck" textAlignment="CENTER" wrapText="true"/>
+
+		<HBox fx:id="checkFailedHBox" spacing="12" alignment="CENTER">
+			<Label text="%preferences.updates.checkFailed" wrapText="true">
+				<graphic>
+					<FontAwesome5IconView glyphSize="12" styleClass="glyph-icon-orange" glyph="EXCLAMATION_TRIANGLE"/>
+				</graphic>
+			</Label>
+			<Hyperlink styleClass="hyperlink-underline" text="%preferences.general.debugDirectory" onAction="#showLogfileDirectory"/>
+		</HBox>
 		<Hyperlink text="${linkLabel.value}" onAction="#visitDownloadsPage" textAlignment="CENTER" wrapText="true" styleClass="hyperlink-underline" visible="${controller.updateAvailable}" managed="${controller.updateAvailable}"/>
 	</VBox>
 </VBox>

+ 3 - 6
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