From 5ef7a3e76d746716a291a0a4a50246a2ac2fdb7d Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 21 Apr 2020 14:15:56 +0200 Subject: [PATCH 01/29] Updated Build Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a8a7248cd..ce58046c7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![cryptomator](cryptomator.png)](https://cryptomator.org/) -[![Build Status](https://travis-ci.org/cryptomator/cryptomator.svg?branch=master)](https://travis-ci.org/cryptomator/cryptomator) +[![Build](https://github.com/cryptomator/cryptomator/workflows/Build/badge.svg)](https://github.com/cryptomator/cryptomator/actions?query=workflow%3ABuild) [![Known Vulnerabilities](https://snyk.io/test/github/cryptomator/cryptomator/badge.svg?targetFile=main%2Fpom.xml)](https://snyk.io/test/github/cryptomator/cryptomator?targetFile=main%2Fpom.xml) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/2a0adf3cec6a4143b91035d3924178f1)](https://www.codacy.com/app/cryptomator/cryptomator?utm_source=github.com&utm_medium=referral&utm_content=cryptomator/cryptomator&utm_campaign=Badge_Grade) [![Twitter](https://img.shields.io/badge/twitter-@Cryptomator-blue.svg?style=flat)](http://twitter.com/Cryptomator) From 2902479fc1cf76f94891af4d10bfc30ccfa59eef Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Tue, 21 Apr 2020 14:27:42 +0200 Subject: [PATCH 02/29] Speed up build, make cache more efficient --- .github/workflows/build.yml | 42 +++++++++++-------------------------- 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31b43f7cd..c38d20dc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,25 +4,24 @@ on: [push] jobs: - test: - name: Run Tests + build: + name: Build and Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 14 - uses: actions/setup-java@v1 + - uses: actions/setup-java@v1 with: java-version: 14 - uses: actions/cache@v1 with: path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ github.run_id }} + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-maven- - name: Ensure to use tagged version run: mvn versions:set --file main/pom.xml -DnewVersion=${GITHUB_REF##*/} # use shell parameter expansion to strip of 'refs/tags' if: startsWith(github.ref, 'refs/tags/') - - name: Build with Maven + - name: Build and Test run: mvn -B install --file main/pom.xml -Pcoverage - name: Run Codacy Coverage Reporter run: | @@ -34,25 +33,7 @@ jobs: $JAVA_HOME/bin/java -jar ~/codacy-coverage-reporter.jar final env: CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} - - assemble-build-kit: - name: Assemble Build Kit - runs-on: ubuntu-latest - needs: test - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 14 - uses: actions/setup-java@v1 - with: - java-version: 14 - - uses: actions/cache@v1 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ github.run_id }} - - name: Ensure to use tagged version - run: mvn versions:set --file main/pom.xml -DnewVersion=${GITHUB_REF##*/} # use shell parameter expansion to strip of 'refs/tags' - if: startsWith(github.ref, 'refs/tags/') - - name: Build with Maven + - name: Assemble Buildkit run: mvn -B package -DskipTests --file main/pom.xml --resume-from=buildkit -Prelease - name: Upload buildkit-linux.zip uses: actions/upload-artifact@v1 @@ -70,10 +51,10 @@ jobs: name: buildkit-win.zip path: main/buildkit/target/buildkit-win.zip - github-release: + release: name: Draft a Release on GitHub Releases runs-on: ubuntu-latest - needs: assemble-build-kit + needs: build if: startsWith(github.ref, 'refs/tags/') steps: - name: Download buildkit-linux.zip @@ -91,7 +72,8 @@ jobs: with: name: buildkit-win.zip path: . - - id: create_release + - name: Create Release + id: create_release uses: actions/create-release@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -99,9 +81,9 @@ jobs: tag_name: ${{ github.ref }} release_name: ${{ github.ref }} body: | - TODO + :construction: Work in Progress draft: true - prerelease: true + prerelease: false - name: Upload buildkit-linux.zip to GitHub Releases uses: actions/upload-release-asset@v1.0.1 env: From 37fcae8f0ef15c8f54d013010352825b2641ef12 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Thu, 23 Apr 2020 14:21:41 +0200 Subject: [PATCH 03/29] replaced some "old" switch statements by switch expressions --- .../cryptomator/common/vaults/VaultStats.java | 17 +++++------ .../org/cryptomator/common/vaults/Volume.java | 15 +++------- .../ui/mainwindow/VaultDetailController.java | 16 ++++------- .../mainwindow/VaultListCellController.java | 18 +++++------- .../ui/mainwindow/VaultListController.java | 11 ++------ .../ui/migration/MigrationRunController.java | 28 ++++++------------- .../ui/preferences/PreferencesController.java | 23 ++++++--------- .../ui/traymenu/TrayImageFactory.java | 10 +++---- .../ui/unlock/UnlockController.java | 10 +++---- 9 files changed, 52 insertions(+), 96 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java b/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java index c5062e6f3..69564b876 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/VaultStats.java @@ -41,16 +41,13 @@ public class VaultStats { } private void vaultStateChanged(@SuppressWarnings("unused") Observable observable) { - switch (state.get()) { - case UNLOCKED: - assert fs.get() != null; - LOG.debug("start recording stats"); - updateService.restart(); - break; - default: - LOG.debug("stop recording stats"); - updateService.cancel(); - break; + if (VaultState.UNLOCKED.equals(state.get())) { + assert fs.get() != null; + LOG.debug("start recording stats"); + updateService.restart(); + } else { + LOG.debug("stop recording stats"); + updateService.cancel(); } } diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java index 05efa5ef9..a0aa11be8 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Volume.java @@ -43,17 +43,10 @@ public interface Volume { } static VolumeImpl[] getCurrentSupportedAdapters() { - return Stream.of(VolumeImpl.values()).filter(impl -> { - switch (impl) { - case WEBDAV: - return WebDavVolume.isSupportedStatic(); - case DOKANY: - return DokanyVolume.isSupportedStatic(); - case FUSE: - return FuseVolume.isSupportedStatic(); - default: - return false;//throw new IllegalStateException("Adapter not implemented."); - } + return Stream.of(VolumeImpl.values()).filter(impl -> switch (impl) { + case WEBDAV -> WebDavVolume.isSupportedStatic(); + case DOKANY -> DokanyVolume.isSupportedStatic(); + case FUSE -> FuseVolume.isSupportedStatic(); }).toArray(VolumeImpl[]::new); } diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailController.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailController.java index 7f25bdf62..36a746039 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultDetailController.java @@ -31,16 +31,12 @@ public class VaultDetailController implements FxController { } private FontAwesome5Icon getGlyphForVaultState(VaultState state) { - switch (state) { - case LOCKED: - return FontAwesome5Icon.LOCK; - case PROCESSING: - return FontAwesome5Icon.SPINNER; - case UNLOCKED: - return FontAwesome5Icon.LOCK_OPEN; - default: - return FontAwesome5Icon.EXCLAMATION_TRIANGLE; - } + return switch (state) { + case LOCKED -> FontAwesome5Icon.LOCK; + case PROCESSING -> FontAwesome5Icon.SPINNER; + case UNLOCKED -> FontAwesome5Icon.LOCK_OPEN; + case NEEDS_MIGRATION, MISSING, ERROR -> FontAwesome5Icon.EXCLAMATION_TRIANGLE; + }; } @FXML 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 ec553c329..6703ec674 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 @@ -3,9 +3,9 @@ package org.cryptomator.ui.mainwindow; import javafx.beans.binding.Binding; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; +import org.cryptomator.common.vaults.Vault; import org.cryptomator.common.vaults.VaultState; import org.cryptomator.ui.common.FxController; -import org.cryptomator.common.vaults.Vault; import org.cryptomator.ui.controls.FontAwesome5Icon; import org.fxmisc.easybind.EasyBind; @@ -23,16 +23,12 @@ public class VaultListCellController implements FxController { } private FontAwesome5Icon getGlyphForVaultState(VaultState state) { - switch (state) { - case LOCKED: - return FontAwesome5Icon.LOCK; - case PROCESSING: - return FontAwesome5Icon.SPINNER; - case UNLOCKED: - return FontAwesome5Icon.LOCK_OPEN; - default: - return FontAwesome5Icon.EXCLAMATION_TRIANGLE; - } + return switch (state) { + case LOCKED -> FontAwesome5Icon.LOCK; + case PROCESSING -> FontAwesome5Icon.SPINNER; + case UNLOCKED -> FontAwesome5Icon.LOCK_OPEN; + case NEEDS_MIGRATION, MISSING, ERROR -> FontAwesome5Icon.EXCLAMATION_TRIANGLE; + }; } /* Getter/Setter */ diff --git a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java index 625a10e65..de39719bc 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/mainwindow/VaultListController.java @@ -66,9 +66,7 @@ public class VaultListController implements FxController { } VaultState reportedState = newValue.getState(); switch (reportedState) { - case LOCKED: - case NEEDS_MIGRATION: - case MISSING: + case LOCKED, NEEDS_MIGRATION, MISSING: try { VaultState determinedState = VaultListManager.determineVaultState(newValue.getPath()); newValue.setState(determinedState); @@ -78,11 +76,8 @@ public class VaultListController implements FxController { newValue.setLastKnownException(e); } break; - case ERROR: - case UNLOCKED: - case PROCESSING: - default: - // no-op + case ERROR, UNLOCKED, PROCESSING: + break; // no-op } } diff --git a/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationRunController.java b/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationRunController.java index d7340618d..08cba8b5c 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationRunController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationRunController.java @@ -142,19 +142,11 @@ public class MigrationRunController implements FxController { // Called by a background task. We can not directly modify observable properties from here private void migrationProgressChanged(MigrationProgressListener.ProgressState state, double progress) { - switch (state) { - case INITIALIZING: - volatileMigrationProgress = -1.0; - break; - case MIGRATING: - volatileMigrationProgress = progress; - break; - case FINALIZING: - volatileMigrationProgress = 1.0; - break; - default: - throw new IllegalStateException("Unexpted state " + state); - } + volatileMigrationProgress = switch (state) { + case INITIALIZING -> -1.0; + case MIGRATING -> progress; + case FINALIZING -> 1.0; + }; } private void loadStoredPassword() { @@ -194,12 +186,10 @@ public class MigrationRunController implements FxController { } public ContentDisplay getMigrateButtonContentDisplay() { - switch (vault.getState()) { - case PROCESSING: - return ContentDisplay.LEFT; - default: - return ContentDisplay.TEXT_ONLY; - } + return switch (vault.getState()) { + case PROCESSING -> ContentDisplay.LEFT; + default -> ContentDisplay.TEXT_ONLY; + }; } public ReadOnlyDoubleProperty migrationProgressProperty() { diff --git a/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java b/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java index ea525cc90..2b58eda30 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/preferences/PreferencesController.java @@ -49,21 +49,14 @@ public class PreferencesController implements FxController { } private Tab getTabToSelect(SelectedPreferencesTab selectedTab) { - switch (selectedTab) { - case UPDATES: - return updatesTab; - case VOLUME: - return volumeTab; - case DONATION_KEY: - return donationKeyTab; - case GENERAL: - return generalTab; - case ABOUT: - return aboutTab; - case ANY: - default: - return updateAvailable.get() ? updatesTab : generalTab; - } + return switch (selectedTab) { + case UPDATES -> updatesTab; + case VOLUME -> volumeTab; + case DONATION_KEY -> donationKeyTab; + case GENERAL -> generalTab; + case ABOUT -> aboutTab; + case ANY -> updateAvailable.get() ? updatesTab : generalTab; + }; } private void selectedTabChanged() { diff --git a/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayImageFactory.java b/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayImageFactory.java index 7d5031937..a76c8b1e3 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayImageFactory.java +++ b/main/ui/src/main/java/org/cryptomator/ui/traymenu/TrayImageFactory.java @@ -29,12 +29,10 @@ class TrayImageFactory { MacApplicationUiInterfaceStyle interfaceStyle = macFunctions.map(MacFunctions::uiAppearance) // .map(MacApplicationUiAppearance::getCurrentInterfaceStyle) // .orElse(MacApplicationUiInterfaceStyle.LIGHT); - switch (interfaceStyle) { - case DARK: - return "/tray_icon_mac_white.png"; - default: - return "/tray_icon_mac_black.png"; - } + return switch (interfaceStyle) { + case DARK -> "/tray_icon_mac_white.png"; + case LIGHT -> "/tray_icon_mac_black.png"; + }; } private String getWinOrLinuxResourceName() { diff --git a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java index d725fd0ea..936c451dc 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java +++ b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockController.java @@ -174,12 +174,10 @@ public class UnlockController implements FxController { } public ContentDisplay getUnlockButtonState() { - switch (vault.getState()) { - case PROCESSING: - return ContentDisplay.LEFT; - default: - return ContentDisplay.TEXT_ONLY; - } + return switch (vault.getState()) { + case PROCESSING -> ContentDisplay.LEFT; + default -> ContentDisplay.TEXT_ONLY; + }; } public ReadOnlyBooleanProperty unlockButtonDisabledProperty() { From 0469e99baa23fe55b5ed6b7e7892aae101e5b362 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Thu, 23 Apr 2020 14:22:24 +0200 Subject: [PATCH 04/29] Updated build dependencies --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce58046c7..1a0879259 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ For more information on the security details visit [cryptomator.org](https://doc ### Dependencies -* JDK 11 (we recommend to use the latest version) +* JDK 14 (e.g. adoptopenjdk) * Maven 3 * Optional: OS-dependent build tools for native packaging (see [Windows](https://github.com/cryptomator/cryptomator-win), [OS X](https://github.com/cryptomator/cryptomator-osx), [Linux](https://github.com/cryptomator/builder-containers)) From db29513376645970db68dd530fcdbc3f90c35e46 Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Thu, 23 Apr 2020 14:36:41 +0200 Subject: [PATCH 05/29] one more switch expression --- .../cryptomator/ui/controls/SecurePasswordField.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java index 24cb8b8e9..eb3019102 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java @@ -74,12 +74,10 @@ public class SecurePasswordField extends TextField { } public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) { - switch(attribute) { - case TEXT: - return null; - default: - return super.queryAccessibleAttribute(attribute, parameters); - } + return switch (attribute) { + case TEXT -> null; + default -> super.queryAccessibleAttribute(attribute, parameters); + }; } private void handleDragOver(DragEvent event) { From 186ed5c11593d6a70a5627125d0a1d0fb6cd9441 Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Thu, 23 Apr 2020 22:16:23 +0200 Subject: [PATCH 06/29] set title to vault name in unlock screen for improved compatibility with password managers --- .../main/java/org/cryptomator/ui/unlock/UnlockModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java index 8cca1c1cc..a6e5202d8 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java +++ b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockModule.java @@ -8,6 +8,7 @@ import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.stage.Modality; import javafx.stage.Stage; +import org.cryptomator.common.vaults.Vault; import org.cryptomator.ui.common.DefaultSceneFactory; import org.cryptomator.ui.common.FXMLLoaderFactory; import org.cryptomator.ui.common.FxController; @@ -35,9 +36,9 @@ abstract class UnlockModule { @Provides @UnlockWindow @UnlockScoped - static Stage provideStage(ResourceBundle resourceBundle, @Named("windowIcons") List windowIcons) { + static Stage provideStage(@UnlockWindow Vault vault, @Named("windowIcons") List windowIcons) { Stage stage = new Stage(); - stage.setTitle(resourceBundle.getString("unlock.title")); + stage.setTitle(vault.getDisplayableName()); stage.setResizable(false); stage.initModality(Modality.APPLICATION_MODAL); stage.getIcons().addAll(windowIcons); From b882296c199b2014edbf9f69ba73b825e083366d Mon Sep 17 00:00:00 2001 From: Tobias Hagemann Date: Fri, 24 Apr 2020 11:21:59 +0200 Subject: [PATCH 07/29] fixes #1123 --- .../common/vaults/WindowsDriveLetters.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/WindowsDriveLetters.java b/main/commons/src/main/java/org/cryptomator/common/vaults/WindowsDriveLetters.java index c873e9f3f..016c39a3a 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/WindowsDriveLetters.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/WindowsDriveLetters.java @@ -7,8 +7,6 @@ package org.cryptomator.common.vaults; import com.google.common.collect.Sets; import org.apache.commons.lang3.SystemUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Singleton; @@ -22,12 +20,11 @@ import java.util.stream.StreamSupport; @Singleton public final class WindowsDriveLetters { - private static final Logger LOG = LoggerFactory.getLogger(WindowsDriveLetters.class); - private static final Set A_TO_Z; + private static final Set C_TO_Z; static { - try (IntStream stream = IntStream.rangeClosed('A', 'Z')) { - A_TO_Z = stream.mapToObj(i -> String.valueOf((char) i)).collect(Collectors.toSet()); + try (IntStream stream = IntStream.rangeClosed('C', 'Z')) { + C_TO_Z = stream.mapToObj(i -> String.valueOf((char) i)).collect(Collectors.toSet()); } } @@ -36,7 +33,7 @@ public final class WindowsDriveLetters { } public Set getAllDriveLetters() { - return A_TO_Z; + return C_TO_Z; } public Set getOccupiedDriveLetters() { @@ -44,12 +41,12 @@ public final class WindowsDriveLetters { return Set.of(); } else { Iterable rootDirs = FileSystems.getDefault().getRootDirectories(); - return StreamSupport.stream(rootDirs.spliterator(), false).map(p -> p.toString().substring(0,1)).collect(Collectors.toSet()); + return StreamSupport.stream(rootDirs.spliterator(), false).map(p -> p.toString().substring(0, 1)).collect(Collectors.toSet()); } } public Set getAvailableDriveLetters() { - return Sets.difference(A_TO_Z, getOccupiedDriveLetters()); + return Sets.difference(C_TO_Z, getOccupiedDriveLetters()); } } From c204ed2601cd4f85ab560533f02609155cf675e3 Mon Sep 17 00:00:00 2001 From: jellemdekker Date: Fri, 24 Apr 2020 14:30:19 +0200 Subject: [PATCH 08/29] Allow password field to be cleared with Ctrl/Command + backspace, implements #885. --- .../org/cryptomator/ui/controls/SecurePasswordField.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java index eb3019102..23bcf22bb 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java @@ -22,6 +22,8 @@ import javafx.scene.control.TextField; import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyCodeCombination; +import javafx.scene.input.KeyCombination; import javafx.scene.input.KeyEvent; import javafx.scene.input.TransferMode; @@ -43,6 +45,7 @@ public class SecurePasswordField extends TextField { private static final int GROW_BUFFER_SIZE = 50; private static final String DEFAULT_PLACEHOLDER = "●"; private static final String STYLE_CLASS = "secure-password-field"; + private static final KeyCodeCombination SHORTCUT_BACKSPACE = new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.SHORTCUT_DOWN); private final String placeholderChar; private final BooleanProperty capsLocked = new SimpleBooleanProperty(); @@ -100,6 +103,9 @@ public class SecurePasswordField extends TextField { if (e.getCode() == KeyCode.CAPS) { updateCapsLocked(); } + if (SHORTCUT_BACKSPACE.match(e)) { + swipe(); + } } private void revealPasswordChanged(@SuppressWarnings("unused") Observable observable) { From 96990788d949c2cc197b2d1e29b86988d1f10dfc Mon Sep 17 00:00:00 2001 From: jellemdekker Date: Fri, 24 Apr 2020 15:22:33 +0200 Subject: [PATCH 09/29] Indent using tabs instead of spaces. --- .../org/cryptomator/ui/controls/SecurePasswordField.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java index 23bcf22bb..f34c71eb1 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java @@ -45,7 +45,7 @@ public class SecurePasswordField extends TextField { private static final int GROW_BUFFER_SIZE = 50; private static final String DEFAULT_PLACEHOLDER = "●"; private static final String STYLE_CLASS = "secure-password-field"; - private static final KeyCodeCombination SHORTCUT_BACKSPACE = new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.SHORTCUT_DOWN); + private static final KeyCodeCombination SHORTCUT_BACKSPACE = new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.SHORTCUT_DOWN); private final String placeholderChar; private final BooleanProperty capsLocked = new SimpleBooleanProperty(); @@ -103,9 +103,9 @@ public class SecurePasswordField extends TextField { if (e.getCode() == KeyCode.CAPS) { updateCapsLocked(); } - if (SHORTCUT_BACKSPACE.match(e)) { - swipe(); - } + if (SHORTCUT_BACKSPACE.match(e)) { + swipe(); + } } private void revealPasswordChanged(@SuppressWarnings("unused") Observable observable) { From f6c834fee2b8db790f1aa931ff80c3db2ccd0a3f Mon Sep 17 00:00:00 2001 From: jellemdekker Date: Fri, 24 Apr 2020 15:23:08 +0200 Subject: [PATCH 10/29] Merged if-statements. --- .../java/org/cryptomator/ui/controls/SecurePasswordField.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java index f34c71eb1..f5aa6dbd5 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java +++ b/main/ui/src/main/java/org/cryptomator/ui/controls/SecurePasswordField.java @@ -102,8 +102,7 @@ public class SecurePasswordField extends TextField { private void handleKeyEvent(KeyEvent e) { if (e.getCode() == KeyCode.CAPS) { updateCapsLocked(); - } - if (SHORTCUT_BACKSPACE.match(e)) { + } else if (SHORTCUT_BACKSPACE.match(e)) { swipe(); } } From 113b74505069ebcee73b5f2f9ad0aba5df29617c Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Mon, 27 Apr 2020 10:55:34 +0200 Subject: [PATCH 11/29] add missing translation keys --- main/ui/src/main/resources/i18n/strings.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/ui/src/main/resources/i18n/strings.properties b/main/ui/src/main/resources/i18n/strings.properties index 66d0fdf54..1fbcfba4e 100644 --- a/main/ui/src/main/resources/i18n/strings.properties +++ b/main/ui/src/main/resources/i18n/strings.properties @@ -116,6 +116,8 @@ migration.error.missingFileSystemCapabilities.title=Unsupported File System migration.error.missingFileSystemCapabilities.description=Migration was not started, because your vault is located on an inadequate file system. migration.error.missingFileSystemCapabilities.reason.LONG_FILENAMES=The file system does not support long file names. migration.error.missingFileSystemCapabilities.reason.LONG_PATHS=The file system does not support long paths. +migration.error.missingFileSystemCapabilities.reason.READ_ACCESS=The file system does not allow to be read. +migration.error.missingFileSystemCapabilities.reason.WRITE_ACCESS=The file system does not allow to be written to. # Preferences preferences.title=Preferences From fcdbc7a6cc47e9508d0c9de5a4c94391748e9b50 Mon Sep 17 00:00:00 2001 From: Armin Schrenk Date: Mon, 27 Apr 2020 11:58:45 +0200 Subject: [PATCH 12/29] Add migration impossible dialogue --- .../org/cryptomator/ui/common/FxmlFile.java | 1 + .../MigrationImpossibleController.java | 35 ++++++++++++++++++ .../ui/migration/MigrationModule.java | 13 ++++++- .../resources/fxml/migration_impossible.fxml | 37 +++++++++++++++++++ .../main/resources/i18n/strings.properties | 2 + 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 main/ui/src/main/java/org/cryptomator/ui/migration/MigrationImpossibleController.java create mode 100644 main/ui/src/main/resources/fxml/migration_impossible.fxml diff --git a/main/ui/src/main/java/org/cryptomator/ui/common/FxmlFile.java b/main/ui/src/main/java/org/cryptomator/ui/common/FxmlFile.java index 9798a9a0f..262af2283 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/common/FxmlFile.java +++ b/main/ui/src/main/java/org/cryptomator/ui/common/FxmlFile.java @@ -13,6 +13,7 @@ public enum FxmlFile { FORGET_PASSWORD("/fxml/forget_password.fxml"), // MAIN_WINDOW("/fxml/main_window.fxml"), // MIGRATION_CAPABILITY_ERROR("/fxml/migration_capability_error.fxml"), // + MIGRATION_IMPOSSIBLE("/fxml/migration_impossible.fxml"), MIGRATION_RUN("/fxml/migration_run.fxml"), // MIGRATION_START("/fxml/migration_start.fxml"), // MIGRATION_SUCCESS("/fxml/migration_success.fxml"), // diff --git a/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationImpossibleController.java b/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationImpossibleController.java new file mode 100644 index 000000000..22f62fef2 --- /dev/null +++ b/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationImpossibleController.java @@ -0,0 +1,35 @@ +package org.cryptomator.ui.migration; + +import javafx.fxml.FXML; +import javafx.stage.Stage; +import org.cryptomator.common.vaults.Vault; +import org.cryptomator.ui.common.FxController; +import org.cryptomator.ui.fxapp.FxApplication; + +import javax.inject.Inject; + +public class MigrationImpossibleController implements FxController { + + private final FxApplication fxApplication; + private final Stage window; + private final Vault vault; + + @Inject + MigrationImpossibleController(FxApplication fxApplication, @MigrationWindow Stage window, @MigrationWindow Vault vault) { + this.fxApplication = fxApplication; + this.window = window; + this.vault = vault; + } + + @FXML + public void close() { + window.close(); + } + + /* Getter/Setters */ + + public Vault getVault() { + return vault; + } + +} diff --git a/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationModule.java b/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationModule.java index 508777364..0c36818a2 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationModule.java +++ b/main/ui/src/main/java/org/cryptomator/ui/migration/MigrationModule.java @@ -83,6 +83,13 @@ abstract class MigrationModule { return fxmlLoaders.createScene("/fxml/migration_capability_error.fxml"); } + @Provides + @FxmlScene(FxmlFile.MIGRATION_IMPOSSIBLE) + @MigrationScoped + static Scene provideMigrationImpossibleScene(@MigrationWindow FXMLLoaderFactory fxmlLoaders) { + return fxmlLoaders.createScene("/fxml/migration_impossible.fxml"); + } + // ------------------ @Binds @@ -104,5 +111,9 @@ abstract class MigrationModule { @IntoMap @FxControllerKey(MigrationCapabilityErrorController.class) abstract FxController bindMigrationCapabilityErrorController(MigrationCapabilityErrorController controller); - + + @Binds + @IntoMap + @FxControllerKey(MigrationImpossibleController.class) + abstract FxController bindMigrationImpossibleController(MigrationImpossibleController controller); } diff --git a/main/ui/src/main/resources/fxml/migration_impossible.fxml b/main/ui/src/main/resources/fxml/migration_impossible.fxml new file mode 100644 index 000000000..174a8c365 --- /dev/null +++ b/main/ui/src/main/resources/fxml/migration_impossible.fxml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +