mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-04-20 17:46:52 -04:00
add upToDateLabel and fix update indicator issue
This commit is contained in:
@@ -68,9 +68,9 @@ public class UpdateChecker {
|
||||
private void checkSucceeded(WorkerStateEvent event) {
|
||||
String latestVersion = updateCheckerService.getValue();
|
||||
LOG.info("Current version: {}, latest version: {}", getCurrentVersion(), latestVersion);
|
||||
state.set(UpdateCheckState.CHECK_SUCCESSFUL);
|
||||
updateCheckTimeProperty.set(LocalDateTime.now());
|
||||
latestVersionProperty.set(latestVersion);
|
||||
state.set(UpdateCheckState.CHECK_SUCCESSFUL);
|
||||
}
|
||||
|
||||
private void checkFailed(WorkerStateEvent event) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MainWindowTitleController implements FxController {
|
||||
this.appWindows = appWindows;
|
||||
this.trayMenuInitialized = trayMenu.isInitialized();
|
||||
this.updateChecker = updateChecker;
|
||||
this.updateAvailable = updateChecker.latestVersionProperty().isNotNull();
|
||||
this.updateAvailable = updateChecker.updateCheckStateProperty().isEqualTo(UpdateChecker.UpdateCheckState.CHECK_SUCCESSFUL).and(updateChecker.latestVersionProperty().isNotEqualTo(updateChecker.getCurrentVersion()));
|
||||
this.licenseHolder = licenseHolder;
|
||||
this.settings = settings;
|
||||
this.showMinimizeButton = Bindings.createBooleanBinding(this::isShowMinimizeButton, settings.showMinimizeButton, settings.showTrayIcon);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.cryptomator.ui.controls.FormattedLabel;
|
||||
import org.cryptomator.ui.fxapp.UpdateChecker;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
@@ -17,13 +18,17 @@ import javafx.beans.property.ReadOnlyStringProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.ContentDisplay;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.util.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.Comparator;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
|
||||
@PreferencesScoped
|
||||
public class UpdatesPreferencesController implements FxController {
|
||||
|
||||
@@ -46,6 +51,7 @@ public class UpdatesPreferencesController implements FxController {
|
||||
public FormattedLabel updateCheckDateFormattedLabel;
|
||||
public HBox checkFailedHBox;
|
||||
public FormattedLabel latestVersionFormattedLabel;
|
||||
public Label upToDateLabel;
|
||||
|
||||
@Inject
|
||||
UpdatesPreferencesController(Application application, Environment environment, Settings settings, UpdateChecker updateChecker) {
|
||||
@@ -73,11 +79,28 @@ public class UpdatesPreferencesController implements FxController {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.getDefault());
|
||||
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));
|
||||
BooleanBinding isUpdateCheckFailed = updateCheckStateProperty.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_FAILED);
|
||||
checkFailedHBox.managedProperty().bind(isUpdateCheckFailed);
|
||||
checkFailedHBox.visibleProperty().bind(isUpdateCheckFailed);
|
||||
|
||||
latestVersionFormattedLabel.arg1Property().bind(Bindings.createStringBinding(() -> (latestVersion.get() != null) ? latestVersion.get() : "-", latestVersion));
|
||||
|
||||
BooleanBinding isUpdateSuccessfulAndCurrent = updateCheckStateProperty.isEqualTo(UpdateChecker.UpdateCheckState.CHECK_SUCCESSFUL)
|
||||
.and(latestVersion.isEqualTo(currentVersion));
|
||||
|
||||
updateCheckStateProperty.addListener((_, _, _) -> {
|
||||
if (isUpdateSuccessfulAndCurrent.get()) {
|
||||
upToDateLabel.setVisible(true);
|
||||
upToDateLabel.setManaged(true);
|
||||
|
||||
PauseTransition delay = new PauseTransition(Duration.seconds(5));
|
||||
delay.setOnFinished(_ -> {
|
||||
upToDateLabel.setVisible(false);
|
||||
upToDateLabel.setManaged(false);
|
||||
});
|
||||
delay.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
||||
Reference in New Issue
Block a user