removed state label and reorganized ui elements

This commit is contained in:
Jan-Peter Klein
2024-03-05 10:15:11 +01:00
parent 4064b61cd7
commit 8064d75102
4 changed files with 42 additions and 35 deletions
@@ -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;
}
}
@@ -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());
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));
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
));
}
@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() {