mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-18 18:51:26 +00:00
added lastUpdateCheck to settings and integrated check in FXApplication start
This commit is contained in:
@@ -26,6 +26,7 @@ import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.NodeOrientation;
|
||||
import java.util.function.Consumer;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class Settings {
|
||||
|
||||
@@ -44,6 +45,7 @@ public class Settings {
|
||||
static final String DEFAULT_KEYCHAIN_PROVIDER = SystemUtils.IS_OS_WINDOWS ? "org.cryptomator.windows.keychain.WindowsProtectedKeychainAccess" : SystemUtils.IS_OS_MAC ? "org.cryptomator.macos.keychain.MacSystemKeychainAccess" : "org.cryptomator.linux.keychain.SecretServiceKeychainAccess";
|
||||
static final String DEFAULT_USER_INTERFACE_ORIENTATION = NodeOrientation.LEFT_TO_RIGHT.name();
|
||||
static final boolean DEFAULT_SHOW_MINIMIZE_BUTTON = false;
|
||||
static final String DEFAULT_LAST_UPDATE_CHECK = "2000-01-01";
|
||||
|
||||
public final ObservableList<VaultSettings> directories;
|
||||
public final BooleanProperty askedForUpdateCheck;
|
||||
@@ -67,6 +69,7 @@ public class Settings {
|
||||
public final StringProperty displayConfiguration;
|
||||
public final StringProperty language;
|
||||
public final StringProperty mountService;
|
||||
public final StringProperty lastUpdateCheck;
|
||||
|
||||
private Consumer<Settings> saveCmd;
|
||||
|
||||
@@ -104,6 +107,7 @@ public class Settings {
|
||||
this.displayConfiguration = new SimpleStringProperty(this, "displayConfiguration", json.displayConfiguration);
|
||||
this.language = new SimpleStringProperty(this, "language", json.language);
|
||||
this.mountService = new SimpleStringProperty(this, "mountService", json.mountService);
|
||||
this.lastUpdateCheck = new SimpleStringProperty(this,"lastUpdateCheck",json.lastUpdateCheck);
|
||||
|
||||
this.directories.addAll(json.directories.stream().map(VaultSettings::new).toList());
|
||||
|
||||
@@ -131,6 +135,7 @@ public class Settings {
|
||||
displayConfiguration.addListener(this::somethingChanged);
|
||||
language.addListener(this::somethingChanged);
|
||||
mountService.addListener(this::somethingChanged);
|
||||
lastUpdateCheck.addListener(this::somethingChanged);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -185,6 +190,7 @@ public class Settings {
|
||||
json.displayConfiguration = displayConfiguration.get();
|
||||
json.language = language.get();
|
||||
json.mountService = mountService.get();
|
||||
json.lastUpdateCheck = lastUpdateCheck.get();
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,4 +83,7 @@ class SettingsJson {
|
||||
@JsonProperty(value = "preferredVolumeImpl", access = JsonProperty.Access.WRITE_ONLY) // WRITE_ONLY means value is "written" into the java object during deserialization. Upvote this: https://github.com/FasterXML/jackson-annotations/issues/233
|
||||
String preferredVolumeImpl;
|
||||
|
||||
@JsonProperty("lastUpdateCheck")
|
||||
String lastUpdateCheck = Settings.DEFAULT_LAST_UPDATE_CHECK;
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javafx.application.Platform;
|
||||
import java.time.LocalDate;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@FxApplicationScoped
|
||||
@@ -67,7 +68,8 @@ public class FxApplication {
|
||||
LOG.error("Failed to show main window", error);
|
||||
return null;
|
||||
});
|
||||
if(!settings.checkForUpdates.getValue()){
|
||||
|
||||
if(LocalDate.parse(settings.lastUpdateCheck.get()).isBefore(LocalDate.now().minusDays(14)) && !settings.checkForUpdates.getValue()){
|
||||
appWindows.showUpdateReminderWindow();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ import javax.inject.Inject;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@UpdateReminderScoped
|
||||
public class UpdateReminderController implements FxController {
|
||||
|
||||
@@ -25,17 +28,20 @@ public class UpdateReminderController implements FxController {
|
||||
|
||||
@FXML
|
||||
public void cancel() {
|
||||
settings.lastUpdateCheck.set(LocalDate.now().format(DateTimeFormatter.ISO_DATE));
|
||||
window.close();
|
||||
}
|
||||
@FXML
|
||||
public void once() {
|
||||
settings.lastUpdateCheck.set(LocalDate.now().format(DateTimeFormatter.ISO_DATE));
|
||||
updateChecker.checkForUpdatesNow();
|
||||
window.close();
|
||||
}
|
||||
@FXML
|
||||
public void automatically() {
|
||||
settings.checkForUpdates.set(true);
|
||||
settings.lastUpdateCheck.set(LocalDate.now().format(DateTimeFormatter.ISO_DATE));
|
||||
updateChecker.checkForUpdatesNow();
|
||||
settings.checkForUpdates.set(true);
|
||||
window.close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user