From cd40731b5fda666012d70c48c1eba0a5a37b432e Mon Sep 17 00:00:00 2001 From: Jan-Peter Klein Date: Fri, 19 Jan 2024 12:30:56 +0100 Subject: [PATCH] implemented open hub feature optimized fxml files and img --- .../ui/sharevault/ShareVaultController.java | 34 +++++++++-- src/main/resources/fxml/share_vault.fxml | 56 +++++++++++------- .../resources/fxml/vault_detail_locked.fxml | 12 ++-- src/main/resources/i18n/strings.properties | 6 +- src/main/resources/img/group-magic.png | Bin 0 -> 35293 bytes src/main/resources/img/group-magic@2x.png | Bin 0 -> 64238 bytes src/main/resources/img/share-hub-logo.png | Bin 32480 -> 0 bytes src/main/resources/img/share-hub-logo@2x.png | Bin 83234 -> 0 bytes 8 files changed, 74 insertions(+), 34 deletions(-) create mode 100644 src/main/resources/img/group-magic.png create mode 100644 src/main/resources/img/group-magic@2x.png delete mode 100644 src/main/resources/img/share-hub-logo.png delete mode 100644 src/main/resources/img/share-hub-logo@2x.png diff --git a/src/main/java/org/cryptomator/ui/sharevault/ShareVaultController.java b/src/main/java/org/cryptomator/ui/sharevault/ShareVaultController.java index c8a5abc5f..63230cbbf 100644 --- a/src/main/java/org/cryptomator/ui/sharevault/ShareVaultController.java +++ b/src/main/java/org/cryptomator/ui/sharevault/ShareVaultController.java @@ -9,28 +9,36 @@ import javax.inject.Inject; import javafx.application.Application; import javafx.fxml.FXML; import javafx.stage.Stage; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.net.URI; +import java.net.URISyntaxException; @ShareVaultScoped public class ShareVaultController implements FxController { + + private static final String SCHEME_PREFIX = "hub+"; private static final String VISIT_HUB_URL = "https://cryptomator.org/hub/"; - private static final String OPEN_HUB_URL = "https://cryptomator.org/hub/"; + private static final String BEST_PRACTICES_URL = "https://docs.cryptomator.org/en/latest/security/best-practices/#sharing-of-vaults"; private final Stage window; private final Lazy application; + private final Vault vault; private final Boolean hubVault; @Inject ShareVaultController(@ShareVaultWindow Stage window, // Lazy application, // - @ShareVaultWindow Vault vault){ + @ShareVaultWindow Vault vault) { this.window = window; this.application = application; + this.vault = vault; var vaultScheme = vault.getVaultConfigCache().getUnchecked().getKeyId().getScheme(); this.hubVault = (vaultScheme.equals(HubKeyLoadingStrategy.SCHEME_HUB_HTTP) || vaultScheme.equals(HubKeyLoadingStrategy.SCHEME_HUB_HTTPS)); } @FXML - public void close(){ + public void close() { window.close(); } @@ -38,9 +46,27 @@ public class ShareVaultController implements FxController { public void visitHub() { application.get().getHostServices().showDocument(VISIT_HUB_URL); } + @FXML public void openHub() { - application.get().getHostServices().showDocument(OPEN_HUB_URL); + application.get().getHostServices().showDocument(getHubUri(vault).toString()); + } + + @FXML + public void visitBestPractices() { + application.get().getHostServices().showDocument(BEST_PRACTICES_URL); + } + + private static URI getHubUri(Vault vault) { + try { + var keyID = new URI(vault.getVaultConfigCache().get().getKeyId().toString()); + assert keyID.getScheme().startsWith(SCHEME_PREFIX); + return new URI(keyID.getScheme().substring(SCHEME_PREFIX.length()) + "://" + keyID.getHost() + "/app/vaults"); + } catch (IOException e) { + throw new UncheckedIOException(e); + } catch (URISyntaxException e) { + throw new IllegalStateException("URI constructed from params known to be valid", e); + } } public boolean isHubVault() { diff --git a/src/main/resources/fxml/share_vault.fxml b/src/main/resources/fxml/share_vault.fxml index df9d7dcc8..6fd1782f0 100644 --- a/src/main/resources/fxml/share_vault.fxml +++ b/src/main/resources/fxml/share_vault.fxml @@ -12,20 +12,27 @@ - + + + + spacing="12"> - + - - + + + + + + + - - - - + + + + + - - - - - - -