diff --git a/main/pom.xml b/main/pom.xml index 3e08109a5..60e5a9721 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -32,7 +32,6 @@ 1.0.10 12 - 4.7.0-9.1.2 2.6 3.8.1 @@ -52,16 +51,6 @@ - - ossrh-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - false - - - true - - jcenter http://jcenter.bintray.com @@ -140,11 +129,6 @@ javafx-fxml ${javafx.version} - - de.jensd - fontawesomefx-fontawesome - ${fontawesomefx.version} - diff --git a/main/ui/pom.xml b/main/ui/pom.xml index 43ea42672..23d67cc0e 100644 --- a/main/ui/pom.xml +++ b/main/ui/pom.xml @@ -36,10 +36,6 @@ org.openjfx javafx-fxml - - de.jensd - fontawesomefx-fontawesome - diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java new file mode 100644 index 000000000..6d159414e --- /dev/null +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5Icon.java @@ -0,0 +1,30 @@ +package org.cryptomator.ui.controls; + +/** + * Inspired by de.jensd:fontawesomefx-fontawesome + */ +public enum FontAwesome5Icon { + ANCHOR("\uF13D"), // + COGS("\uF085"), // + EXCLAMATION_TRIANGLE("\uF071"), // + FOLDER_OPEN("\uF07C"), // + HDD("\uF0A0"), // + LOCK_ALT("\uF30D"), // + LOCK_OPEN_ALT("\uF3C2"), // + MINUS("\uF068"), // + PLUS("\uF067"), // + SPINNER("\uF110"), // + SYNC("\uF021"), // + TIMES("\uF00D"), // + ; + + private final String unicode; + + FontAwesome5Icon(String unicode) { + this.unicode = unicode; + } + + public String unicode() { + return unicode; + } +} diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5IconView.java b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5IconView.java new file mode 100644 index 000000000..f10cf3342 --- /dev/null +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/FontAwesome5IconView.java @@ -0,0 +1,88 @@ +package org.cryptomator.ui.controls; + +import com.google.common.base.Preconditions; +import javafx.beans.property.DoubleProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.value.ObservableValue; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; + +/** + * Inspired by de.jensd:fontawesomefx-fontawesome + */ +public class FontAwesome5IconView extends Text { + + private static final Logger LOG = LoggerFactory.getLogger(FontAwesome5IconView.class); + private static final FontAwesome5Icon DEFAULT_GLYPH = FontAwesome5Icon.ANCHOR; + private static final double DEFAULT_GLYPH_SIZE = 12.0; + private static final String FONT_PATH = "/css/fontawesome5-pro-solid.otf"; + private static final Font FONT; + + private ObjectProperty glyph = new SimpleObjectProperty<>(this, "glyph", DEFAULT_GLYPH); + private DoubleProperty glyphSize = new SimpleDoubleProperty(this, "glyphSize", DEFAULT_GLYPH_SIZE); + + static { + try (InputStream in = FontAwesome5IconView.class.getResourceAsStream(FONT_PATH)) { + Preconditions.checkNotNull(in, "Resource not found: " + FONT_PATH); + FONT = Font.loadFont(in, DEFAULT_GLYPH_SIZE); + if (FONT != null) { + LOG.debug("Loaded family: {}", FONT.getFamily()); + } else { + throw new IllegalStateException("Failed to load font."); + } + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + public FontAwesome5IconView() { + getStyleClass().addAll("glyph-icon"); + glyphProperty().addListener(this::glyphChanged); + glyphSizeProperty().addListener(this::glyphSizeChanged); + setFont(FONT); + setGlyph(DEFAULT_GLYPH); + setGlyphSize(DEFAULT_GLYPH_SIZE); + } + + private void glyphChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") FontAwesome5Icon oldValue, FontAwesome5Icon newValue) { + setText(newValue.unicode()); + } + + private void glyphSizeChanged(@SuppressWarnings("unused") ObservableValue observable, @SuppressWarnings("unused") Number oldValue, Number newValue) { + setFont(new Font(FONT.getFamily(), newValue.doubleValue())); + } + + /* Getter/Setter */ + + public ObjectProperty glyphProperty() { + return glyph; + } + + public void setGlyph(FontAwesome5Icon glyph) { + this.glyph.set(glyph == null ? DEFAULT_GLYPH : glyph); + } + + public FontAwesome5Icon getGlyph() { + return glyph.get(); + } + + public DoubleProperty glyphSizeProperty() { + return glyphSize; + } + + public void setGlyphSize(double glyphSize) { + this.glyphSize.set(glyphSize); + } + + public double getGlyphSize() { + return glyphSize.get(); + } +} diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java index c590d61ce..7942a9b77 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java @@ -5,6 +5,7 @@ import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import org.cryptomator.ui.common.FxController; import org.cryptomator.common.vaults.Vault; +import org.cryptomator.ui.controls.FontAwesome5Icon; import org.fxmisc.easybind.EasyBind; import javax.inject.Inject; @@ -13,33 +14,33 @@ import javax.inject.Inject; public class VaultListCellController implements FxController { private final ObjectProperty vault = new SimpleObjectProperty<>(); - private final Binding glyph; + private final Binding glyph; @Inject VaultListCellController() { - this.glyph = EasyBind.select(vault).selectObject(Vault::stateProperty).map(this::getGlyphForVaultState).orElse("WARNING"); + this.glyph = EasyBind.select(vault).selectObject(Vault::stateProperty).map(this::getGlyphForVaultState).orElse(FontAwesome5Icon.EXCLAMATION_TRIANGLE); } - private String getGlyphForVaultState(Vault.State state) { + private FontAwesome5Icon getGlyphForVaultState(Vault.State state) { switch (state) { case LOCKED: - return "LOCK"; + return FontAwesome5Icon.LOCK_ALT; case PROCESSING: - return "SPINNER"; + return FontAwesome5Icon.SPINNER; case UNLOCKED: - return "UNLOCK"; + return FontAwesome5Icon.LOCK_OPEN_ALT; default: - return "WARNING"; + return FontAwesome5Icon.EXCLAMATION_TRIANGLE; } } /* Getter/Setter */ - public Binding glyphProperty() { + public Binding glyphProperty() { return glyph; } - public String getGlyph() { + public FontAwesome5Icon getGlyph() { return glyph.getValue(); } diff --git a/main/ui/src/main/resources/css/dark_theme.css b/main/ui/src/main/resources/css/dark_theme.css index eb76a57d1..b7de471cb 100644 --- a/main/ui/src/main/resources/css/dark_theme.css +++ b/main/ui/src/main/resources/css/dark_theme.css @@ -35,7 +35,7 @@ -fx-text-fill: TEXT_FILL; } -.fa-icon { +.glyph-icon { -fx-fill: TEXT_FILL; } @@ -78,7 +78,7 @@ -fx-padding: 0; } -.main-window .title .button .fa-icon { +.main-window .title .button .glyph-icon { -fx-fill: white; } @@ -91,7 +91,7 @@ -fx-background-color: none; } -.main-window .title .button:armed .fa-icon { +.main-window .title .button:armed .glyph-icon { -fx-fill: CONTROL_WHITE_BG_ARMED; } @@ -194,10 +194,6 @@ -fx-background-color: CONTROL_BG_ARMED; } -.list-cell .lock-icon { - -fx-fill: TEXT_FILL; -} - .list-cell .detail-label { -fx-text-fill: TEXT_FILL_SECONDARY; -fx-font-size: 0.8em; diff --git a/main/ui/src/main/resources/css/fontawesome-webfont.ttf b/main/ui/src/main/resources/css/fontawesome-webfont.ttf deleted file mode 100644 index 35acda2fa..000000000 Binary files a/main/ui/src/main/resources/css/fontawesome-webfont.ttf and /dev/null differ diff --git a/main/ui/src/main/resources/css/fontawesome5-pro-solid.otf b/main/ui/src/main/resources/css/fontawesome5-pro-solid.otf new file mode 100644 index 000000000..66ce2e49f Binary files /dev/null and b/main/ui/src/main/resources/css/fontawesome5-pro-solid.otf differ diff --git a/main/ui/src/main/resources/css/ionicons.ttf b/main/ui/src/main/resources/css/ionicons.ttf deleted file mode 100644 index 180ce515f..000000000 Binary files a/main/ui/src/main/resources/css/ionicons.ttf and /dev/null differ diff --git a/main/ui/src/main/resources/css/light_theme.css b/main/ui/src/main/resources/css/light_theme.css index 7403fc441..6cb495be1 100644 --- a/main/ui/src/main/resources/css/light_theme.css +++ b/main/ui/src/main/resources/css/light_theme.css @@ -35,7 +35,7 @@ -fx-text-fill: TEXT_FILL; } -.fa-icon { +.glyph-icon { -fx-fill: TEXT_FILL; } @@ -78,7 +78,7 @@ -fx-padding: 0; } -.main-window .title .button .fa-icon { +.main-window .title .button .glyph-icon { -fx-fill: white; } @@ -91,7 +91,7 @@ -fx-background-color: none; } -.main-window .title .button:armed .fa-icon { +.main-window .title .button:armed .glyph-icon { -fx-fill: CONTROL_WHITE_BG_ARMED; } @@ -194,10 +194,6 @@ -fx-background-color: CONTROL_BG_ARMED; } -.list-cell .lock-icon { - -fx-fill: TEXT_FILL; -} - .list-cell .detail-label { -fx-text-fill: TEXT_FILL_SECONDARY; -fx-font-size: 0.8em; diff --git a/main/ui/src/main/resources/fxml/addvault_new_location.fxml b/main/ui/src/main/resources/fxml/addvault_new_location.fxml index 8539ceb8e..2d76215a1 100644 --- a/main/ui/src/main/resources/fxml/addvault_new_location.fxml +++ b/main/ui/src/main/resources/fxml/addvault_new_location.fxml @@ -10,7 +10,7 @@ - + diff --git a/main/ui/src/main/resources/fxml/main_window.fxml b/main/ui/src/main/resources/fxml/main_window.fxml index e1dde4ffd..85414195e 100644 --- a/main/ui/src/main/resources/fxml/main_window.fxml +++ b/main/ui/src/main/resources/fxml/main_window.fxml @@ -1,6 +1,5 @@ - @@ -10,6 +9,7 @@ + - + @@ -34,7 +34,7 @@