From 3b0dd512cb7ec93292d607ecb15a73806600d782 Mon Sep 17 00:00:00 2001 From: Cian Ormond Date: Tue, 5 Apr 2022 15:28:00 -0700 Subject: [PATCH 1/3] Use alternate new version dialogue if meta.install_method is AUR Signed-off-by: Cian Ormond --- .../map/data/ConfigFilePreferences.java | 1 + .../map/view/preloader/PreloaderView.java | 35 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java b/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java index 140ed6e7..28598435 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java +++ b/src/main/java/net/marvk/fs/vatsim/map/data/ConfigFilePreferences.java @@ -63,6 +63,7 @@ public ConfigFilePreferences(@Named("userConfigDir") final Path path, @Named("co booleanProperty("general.prereleases", false); booleanProperty("general.delete_old_logs", true); stringProperty("meta.version", "0.0.0"); + stringProperty("meta.install_method", "default"); booleanProperty("ui.auto_color", true); booleanProperty("ui.auto_shade", true); diff --git a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java index 486dfe02..17ce113c 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java +++ b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java @@ -2,6 +2,7 @@ import de.saxsys.mvvmfx.FxmlView; import de.saxsys.mvvmfx.InjectViewModel; +import de.saxsys.mvvmfx.internal.viewloader.DependencyInjector; import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.scene.input.MouseButton; @@ -10,11 +11,14 @@ import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Window; +import lombok.extern.log4j.Log4j2; import net.marvk.fs.vatsim.map.api.VersionResponse; +import net.marvk.fs.vatsim.map.data.Preferences; import java.time.LocalDate; import java.util.Base64; +@Log4j2 public class PreloaderView implements FxmlView { @FXML private Label header; @@ -67,7 +71,11 @@ public void initialize() { viewModel.versionResponseProperty().addListener((observable, oldValue, response) -> { if (response != null && response.getResult() == VersionResponse.Result.OUTDATED) { - showNewVersionDialog(response); + final Preferences prefs = DependencyInjector.getInstance().getInstanceOf(Preferences.class); + switch (prefs.stringProperty("meta.install_method").get()) { + case "aur" -> showNewVersionDialog(response, "the Arch User Repository"); + default -> showNewVersionDialog(response); + } } }); @@ -81,7 +89,7 @@ private void showNewVersionDialog(final VersionResponse response) { final Alert alert = new Alert(Alert.AlertType.INFORMATION); alert.initOwner(taskHolder.getScene().getWindow()); alert.setTitle("New Version Available!"); - alert.setHeaderText("A new Version of VATprism (%s) is available.".formatted(response.getLatestVersion())); + alert.setHeaderText("A new version of VATprism (%s) is available.".formatted(response.getLatestVersion())); alert.setContentText("Would you like to download the latest version?"); alert.getButtonTypes().setAll(download, postpone); final TextArea textArea = new TextArea(response.getChangelog()); @@ -104,6 +112,29 @@ private void showNewVersionDialog(final VersionResponse response) { .ifPresent(e -> viewModel.downloadNewVersion()); } + private void showNewVersionDialog(final VersionResponse response, final String alt) { + final ButtonType close = new ButtonType("Close"); + + final Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.initOwner(taskHolder.getScene().getWindow()); + alert.setTitle("New Version Available!"); + alert.setHeaderText("A new version of VATprism (%s) is available.".formatted(response.getLatestVersion())); + alert.setContentText("Please update using " + alt + "."); + alert.getButtonTypes().setAll(close); + final TextArea textArea = new TextArea(response.getChangelog()); + textArea.setEditable(false); + textArea.setWrapText(true); + textArea.setPrefHeight(100); + final VBox changelogBox = new VBox(new Label("Changelog:"), textArea); + alert.getDialogPane().setExpandableContent(changelogBox); + alert.getDialogPane().setExpanded(true); + final Window window = alert.getDialogPane().getScene().getWindow(); + window.setOnCloseRequest(e -> window.hide()); + + ((Button) alert.getDialogPane().lookupButton(close)).setDefaultButton(true); + alert.showAndWait(); + } + @FXML private void goToIssuePage(final MouseEvent event) { if (event.getButton() == MouseButton.PRIMARY) { From d431025ea940f14bba130685ed1aa142420fe43d Mon Sep 17 00:00:00 2001 From: Cian Ormond Date: Tue, 5 Apr 2022 21:52:02 -0700 Subject: [PATCH 2/3] Detect if installed via the AUR Signed-off-by: Cian Ormond --- .../vatsim/map/view/preloader/PreloaderView.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java index 17ce113c..af8c2b19 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java +++ b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java @@ -15,6 +15,7 @@ import net.marvk.fs.vatsim.map.api.VersionResponse; import net.marvk.fs.vatsim.map.data.Preferences; +import java.io.File; import java.time.LocalDate; import java.util.Base64; @@ -51,6 +52,8 @@ public class PreloaderView implements FxmlView { private PreloaderViewModel viewModel; public void initialize() { + final Preferences prefs = DependencyInjector.getInstance().getInstanceOf(Preferences.class); + viewModel.progressPropertyWritable().bindBidirectional(progressBar.progressProperty()); task.textProperty().bind(viewModel.taskDescriptionProperty()); error.textProperty().bind(viewModel.errorProperty()); @@ -69,9 +72,10 @@ public void initialize() { }); versionAndName.setText(viewModel.getVersionAndName()); + checkInstallMethod(prefs); + viewModel.versionResponseProperty().addListener((observable, oldValue, response) -> { if (response != null && response.getResult() == VersionResponse.Result.OUTDATED) { - final Preferences prefs = DependencyInjector.getInstance().getInstanceOf(Preferences.class); switch (prefs.stringProperty("meta.install_method").get()) { case "aur" -> showNewVersionDialog(response, "the Arch User Repository"); default -> showNewVersionDialog(response); @@ -159,4 +163,14 @@ private void checkSpecial() { private static String decode(final String s) { return new String(Base64.getDecoder().decode(s)); } + + private void checkInstallMethod(Preferences prefs) { + final String os = System.getProperty("os.name"); + String method = "default"; + if (os.contains("nix") || os.contains("nux")) { + method = new File("/etc/vatprism/aur").exists() ? "aur" : "default"; + } + prefs.stringProperty("meta.install_method").set(method); + log.info(method); + } } From fd1bee05e873c1ce5ef5fb964467505cb67725c9 Mon Sep 17 00:00:00 2001 From: Cian Ormond Date: Tue, 5 Apr 2022 22:02:18 -0700 Subject: [PATCH 3/3] Update README and fix logging Signed-off-by: Cian Ormond --- README.md | 19 ++++++++++++++++--- .../map/view/preloader/PreloaderView.java | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 94922aa3..29d735c0 100644 --- a/README.md +++ b/README.md @@ -70,11 +70,24 @@ the future, see the [corresponding issue](https://github.com/marvk/vatprism/issu #### Linux -Currently, there is no support for native linux binaries. It is still possible to run VATprism, though you are going to +If you are using Arch Linux or any derivatives, you can use the third-party [vatprism](https://aur.archlinux.org/packages/vatprism) +package on the AUR. + +Using `yay` as your AUR helper... +``` +yay -Sy vatprism +``` + +Using no AUR helper... +``` +git clone https://aur.archlinux.org/vatprism.git && cd vatprism +makepkg -si +``` +It is still possible to run VATprism on other distros, though you are going to have to compile it yourself. For this, please refer to the [Build](#build) section of this readme. -If there is demand for Linux native binaries in the future, I will think about adding support. Feel free to -request [Linux](https://github.com/marvk/vatprism/issues/31) builds via the linked issue. +If there is demand for more Linux native binaries in the future, I will think about adding support. Feel free to +request different [Linux](https://github.com/marvk/vatprism/issues/31) builds via the linked issue. ## Build diff --git a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java index af8c2b19..7e3df2cc 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java +++ b/src/main/java/net/marvk/fs/vatsim/map/view/preloader/PreloaderView.java @@ -171,6 +171,6 @@ private void checkInstallMethod(Preferences prefs) { method = new File("/etc/vatprism/aur").exists() ? "aur" : "default"; } prefs.stringProperty("meta.install_method").set(method); - log.info(method); + log.info("Install method - " + method); } }