From 7a913c89c93536b9583da3ca22b227231401164c Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Thu, 12 Sep 2024 11:36:14 +0200 Subject: [PATCH 1/7] condensed vault list implemented --- .../org/cryptomator/common/settings/Settings.java | 4 ++++ .../cryptomator/common/settings/SettingsJson.java | 3 +++ .../ui/mainwindow/VaultListCellController.java | 14 +++++++++++++- .../ui/mainwindow/VaultListController.java | 9 ++++++++- .../InterfacePreferencesController.java | 2 ++ src/main/resources/fxml/preferences_interface.fxml | 1 + src/main/resources/fxml/vault_list_cell.fxml | 2 +- src/main/resources/i18n/strings.properties | 1 + 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cryptomator/common/settings/Settings.java b/src/main/java/org/cryptomator/common/settings/Settings.java index 04facdcd0..8b99f62e6 100644 --- a/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/src/main/java/org/cryptomator/common/settings/Settings.java @@ -60,6 +60,7 @@ public class Settings { public final ObjectProperty userInterfaceOrientation; public final StringProperty licenseKey; public final BooleanProperty showTrayIcon; + public final BooleanProperty useCondensedMode; public final IntegerProperty windowXPosition; public final IntegerProperty windowYPosition; public final IntegerProperty windowWidth; @@ -96,6 +97,7 @@ public class Settings { this.userInterfaceOrientation = new SimpleObjectProperty<>(this, "userInterfaceOrientation", parseEnum(json.uiOrientation, NodeOrientation.class, NodeOrientation.LEFT_TO_RIGHT)); this.licenseKey = new SimpleStringProperty(this, "licenseKey", json.licenseKey); this.showTrayIcon = new SimpleBooleanProperty(this, "showTrayIcon", json.showTrayIcon); + this.useCondensedMode = new SimpleBooleanProperty(this, "useCondensedMode", json.useCondensedMode); this.windowXPosition = new SimpleIntegerProperty(this, "windowXPosition", json.windowXPosition); this.windowYPosition = new SimpleIntegerProperty(this, "windowYPosition", json.windowYPosition); this.windowWidth = new SimpleIntegerProperty(this, "windowWidth", json.windowWidth); @@ -122,6 +124,7 @@ public class Settings { userInterfaceOrientation.addListener(this::somethingChanged); licenseKey.addListener(this::somethingChanged); showTrayIcon.addListener(this::somethingChanged); + useCondensedMode.addListener(this::somethingChanged); windowXPosition.addListener(this::somethingChanged); windowYPosition.addListener(this::somethingChanged); windowWidth.addListener(this::somethingChanged); @@ -175,6 +178,7 @@ public class Settings { json.uiOrientation = userInterfaceOrientation.get().name(); json.licenseKey = licenseKey.get(); json.showTrayIcon = showTrayIcon.get(); + json.useCondensedMode = useCondensedMode.get(); json.windowXPosition = windowXPosition.get(); json.windowYPosition = windowYPosition.get(); json.windowWidth = windowWidth.get(); diff --git a/src/main/java/org/cryptomator/common/settings/SettingsJson.java b/src/main/java/org/cryptomator/common/settings/SettingsJson.java index 1dd68e02a..8cbda3dc2 100644 --- a/src/main/java/org/cryptomator/common/settings/SettingsJson.java +++ b/src/main/java/org/cryptomator/common/settings/SettingsJson.java @@ -54,6 +54,9 @@ class SettingsJson { @JsonProperty("showTrayIcon") boolean showTrayIcon; + @JsonProperty("useCondensedMode") + boolean useCondensedMode; + @JsonProperty("startHidden") boolean startHidden = Settings.DEFAULT_START_HIDDEN; diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java index 6374d7ae3..b842cdd2c 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListCellController.java @@ -1,5 +1,6 @@ package org.cryptomator.ui.mainwindow; +import org.cryptomator.common.settings.Settings; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultState; import org.cryptomator.ui.common.Animations; @@ -9,6 +10,8 @@ import org.cryptomator.ui.controls.FontAwesome5Icon; import org.cryptomator.ui.controls.FontAwesome5IconView; import javax.inject.Inject; +import javafx.beans.binding.Bindings; +import javafx.beans.binding.BooleanBinding; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableValue; @@ -18,6 +21,7 @@ public class VaultListCellController implements FxController { private final ObjectProperty vault = new SimpleObjectProperty<>(); private final ObservableValue glyph; + private final BooleanBinding useCondensedMode; private AutoAnimator spinAnimation; @@ -25,8 +29,9 @@ public class VaultListCellController implements FxController { public FontAwesome5IconView vaultStateView; @Inject - VaultListCellController() { + VaultListCellController(Settings settings) { this.glyph = vault.flatMap(Vault::stateProperty).map(this::getGlyphForVaultState); + this.useCondensedMode = Bindings.createBooleanBinding(settings.useCondensedMode::get, settings.useCondensedMode); } public void initialize() { @@ -68,6 +73,13 @@ public class VaultListCellController implements FxController { return vault.get(); } + public BooleanBinding useCondensedModeProperty() { + return useCondensedMode; + } + public boolean isUseCondensedMode() { + return useCondensedMode.get(); + } + public void setVault(Vault value) { vault.set(value); } diff --git a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index 5cd4c38ef..d18cb8cd9 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -1,6 +1,7 @@ package org.cryptomator.ui.mainwindow; import org.apache.commons.lang3.SystemUtils; +import org.cryptomator.common.settings.Settings; import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultListManager; import org.cryptomator.cryptofs.CryptoFileSystemProvider; @@ -71,6 +72,7 @@ public class VaultListController implements FxController { private final BooleanProperty draggingVaultOver = new SimpleBooleanProperty(); private final ResourceBundle resourceBundle; private final FxApplicationWindows appWindows; + private final BooleanBinding useCondensedMode; public ListView vaultList; public VBox vbox; @@ -89,7 +91,8 @@ public class VaultListController implements FxController { RemoveVaultComponent.Builder removeVaultDialogue, // VaultListManager vaultListManager, // ResourceBundle resourceBundle, // - FxApplicationWindows appWindows) { + FxApplicationWindows appWindows, // + Settings settings) { this.mainWindow = mainWindow; this.vaults = vaults; this.selectedVault = selectedVault; @@ -102,6 +105,7 @@ public class VaultListController implements FxController { this.appWindows = appWindows; this.emptyVaultList = Bindings.isEmpty(vaults); + this.useCondensedMode = Bindings.createBooleanBinding(settings.useCondensedMode::get, settings.useCondensedMode); selectedVault.addListener(this::selectedVaultDidChange); } @@ -110,6 +114,9 @@ public class VaultListController implements FxController { vaultList.setItems(vaults); vaultList.setCellFactory(cellFactory); + vaultList.fixedCellSizeProperty().bind(Bindings.createDoubleBinding(() -> + useCondensedMode.get() ? 30.0 : 60.0, useCondensedMode)); + selectedVault.bind(vaultList.getSelectionModel().selectedItemProperty()); vaults.addListener((ListChangeListener.Change c) -> { while (c.next()) { diff --git a/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java b/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java index 937431571..d90241c15 100644 --- a/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java +++ b/src/main/java/org/cryptomator/ui/preferences/InterfacePreferencesController.java @@ -37,6 +37,7 @@ public class InterfacePreferencesController implements FxController { private final SupportedLanguages supportedLanguages; public ChoiceBox themeChoiceBox; public CheckBox showTrayIconCheckbox; + public CheckBox useCondensedModeCheckbox; public ChoiceBox preferredLanguageChoiceBox; public ToggleGroup nodeOrientation; public RadioButton nodeOrientationLtr; @@ -63,6 +64,7 @@ public class InterfacePreferencesController implements FxController { themeChoiceBox.setConverter(new UiThemeConverter(resourceBundle)); showTrayIconCheckbox.selectedProperty().bindBidirectional(settings.showTrayIcon); + useCondensedModeCheckbox.selectedProperty().bindBidirectional(settings.useCondensedMode); preferredLanguageChoiceBox.getItems().addAll(supportedLanguages.getLanguageTags()); preferredLanguageChoiceBox.valueProperty().bindBidirectional(settings.language); diff --git a/src/main/resources/fxml/preferences_interface.fxml b/src/main/resources/fxml/preferences_interface.fxml index 990b66c8c..a48493bc7 100644 --- a/src/main/resources/fxml/preferences_interface.fxml +++ b/src/main/resources/fxml/preferences_interface.fxml @@ -38,5 +38,6 @@ + diff --git a/src/main/resources/fxml/vault_list_cell.fxml b/src/main/resources/fxml/vault_list_cell.fxml index aedb18b06..579754eca 100644 --- a/src/main/resources/fxml/vault_list_cell.fxml +++ b/src/main/resources/fxml/vault_list_cell.fxml @@ -23,7 +23,7 @@ diff --git a/src/main/resources/fxml/vault_list_cell.fxml b/src/main/resources/fxml/vault_list_cell.fxml index 579754eca..c6cc8cf24 100644 --- a/src/main/resources/fxml/vault_list_cell.fxml +++ b/src/main/resources/fxml/vault_list_cell.fxml @@ -23,7 +23,7 @@