mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-17 10:11:27 +00:00
Added hyperlink to downloads page in updates notification window
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package org.cryptomator.ui.controls;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.StringBinding;
|
||||
import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class FormattedString {
|
||||
|
||||
private final StringProperty format = new SimpleStringProperty("");
|
||||
private final ObjectProperty<Object> arg1 = new SimpleObjectProperty<>();
|
||||
// add arg2, arg3, ... on demand
|
||||
private final StringBinding value;
|
||||
|
||||
public FormattedString() {
|
||||
this.value = Bindings.createStringBinding(this::computeValue, format, arg1);
|
||||
}
|
||||
|
||||
protected String computeValue() {
|
||||
return String.format(format.get(), arg1.get());
|
||||
}
|
||||
|
||||
/* Observables */
|
||||
|
||||
public StringProperty formatProperty() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
return format.get();
|
||||
}
|
||||
|
||||
public void setFormat(String format) {
|
||||
this.format.set(format);
|
||||
}
|
||||
|
||||
public ObjectProperty<Object> arg1Property() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
public Object getArg1() {
|
||||
return arg1.get();
|
||||
}
|
||||
|
||||
public void setArg1(Object arg1) {
|
||||
this.arg1.set(arg1);
|
||||
}
|
||||
|
||||
public StringBinding valueProperty() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value.get();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.cryptomator.ui.preferences;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.binding.BooleanBinding;
|
||||
import javafx.beans.binding.ObjectBinding;
|
||||
@@ -16,6 +17,9 @@ import javax.inject.Inject;
|
||||
@PreferencesScoped
|
||||
public class UpdatesPreferencesController implements FxController {
|
||||
|
||||
private static final String DOWNLOADS_URI = "https://cryptomator.org/downloads";
|
||||
|
||||
private final Application application;
|
||||
private final Settings settings;
|
||||
private final UpdateChecker updateChecker;
|
||||
private final ObjectBinding<ContentDisplay> checkForUpdatesButtonState;
|
||||
@@ -25,7 +29,8 @@ public class UpdatesPreferencesController implements FxController {
|
||||
public CheckBox checkForUpdatesCheckbox;
|
||||
|
||||
@Inject
|
||||
UpdatesPreferencesController(Settings settings, UpdateChecker updateChecker) {
|
||||
UpdatesPreferencesController(Application application, Settings settings, UpdateChecker updateChecker) {
|
||||
this.application = application;
|
||||
this.settings = settings;
|
||||
this.updateChecker = updateChecker;
|
||||
this.checkForUpdatesButtonState = Bindings.when(updateChecker.checkingForUpdatesProperty()).then(ContentDisplay.LEFT).otherwise(ContentDisplay.TEXT_ONLY);
|
||||
@@ -43,6 +48,11 @@ public class UpdatesPreferencesController implements FxController {
|
||||
updateChecker.checkForUpdatesNow();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void visitDownloadsPage() {
|
||||
application.getHostServices().showDocument(DOWNLOADS_URI);
|
||||
}
|
||||
|
||||
/* Observable Properties */
|
||||
|
||||
public ObjectBinding<ContentDisplay> checkForUpdatesButtonStateProperty() {
|
||||
|
||||
@@ -3,13 +3,18 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.CheckBox?>
|
||||
<?import javafx.scene.control.Hyperlink?>
|
||||
<?import javafx.scene.control.ProgressIndicator?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.cryptomator.ui.controls.FormattedLabel?>
|
||||
<?import org.cryptomator.ui.controls.FormattedString?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="org.cryptomator.ui.preferences.UpdatesPreferencesController"
|
||||
spacing="6">
|
||||
<fx:define>
|
||||
<FormattedString fx:id="linkLabel" format="%preferences.updates.updateAvailable" arg1="${controller.latestVersion}"/>
|
||||
</fx:define>
|
||||
<padding>
|
||||
<Insets topRightBottomLeft="12"/>
|
||||
</padding>
|
||||
@@ -24,8 +29,8 @@
|
||||
<ProgressIndicator progress="-1" prefWidth="12" prefHeight="12"/>
|
||||
</graphic>
|
||||
</Button>
|
||||
|
||||
<FormattedLabel format="%preferences.updates.updateAvailable" arg1="${controller.latestVersion}" textAlignment="CENTER" wrapText="true" visible="${controller.updateAvailable}"/>
|
||||
|
||||
<Hyperlink text="${linkLabel.value}" onAction="#visitDownloadsPage" textAlignment="CENTER" wrapText="true" styleClass="hyperlink-underline" visible="${controller.updateAvailable}"/>
|
||||
</VBox>
|
||||
</children>
|
||||
</VBox>
|
||||
|
||||
Reference in New Issue
Block a user