mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-22 04:31:27 +00:00
Implementing new settings and locking after a certain amount of minutes
This commit is contained in:
@@ -15,9 +15,9 @@ import org.cryptomator.common.settings.UiTheme;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
import org.cryptomator.common.vaults.VaultListManager;
|
||||
import org.cryptomator.common.vaults.Volume;
|
||||
import org.cryptomator.integrations.autolock.AutoLockException;
|
||||
import org.cryptomator.integrations.autolock.AutoLockProvider;
|
||||
import org.cryptomator.integrations.autolock.SystemState;
|
||||
//import org.cryptomator.integrations.autolock.AutoLockException;
|
||||
//import org.cryptomator.integrations.autolock.AutoLockProvider;
|
||||
//import org.cryptomator.integrations.autolock.SystemState;
|
||||
import org.cryptomator.integrations.tray.TrayIntegrationProvider;
|
||||
import org.cryptomator.integrations.uiappearance.Theme;
|
||||
import org.cryptomator.integrations.uiappearance.UiAppearanceException;
|
||||
@@ -36,8 +36,7 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import java.awt.desktop.QuitResponse;
|
||||
import java.awt.desktop.SystemSleepEvent;
|
||||
import java.awt.desktop.SystemSleepListener;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
@@ -61,10 +60,12 @@ public class FxApplication extends Application {
|
||||
private final BooleanBinding hasVisibleWindows;
|
||||
private final UiAppearanceListener systemInterfaceThemeListener = this::systemInterfaceThemeChanged;
|
||||
private final VaultListManager vaultListManager;
|
||||
private final Optional<AutoLockProvider> autoLockProvider;
|
||||
//private final Optional<AutoLockProvider> autoLockProvider;
|
||||
|
||||
@Inject
|
||||
FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, Provider<UnlockComponent.Builder> unlockWindowBuilderProvider, Provider<LockComponent.Builder> lockWindowBuilderProvider, Lazy<QuitComponent> quitWindow, Optional<TrayIntegrationProvider> trayIntegration, Optional<UiAppearanceProvider> appearanceProvider, VaultService vaultService, LicenseHolder licenseHolder, VaultListManager vaultListManager, Optional<AutoLockProvider> autoLockProvider) {
|
||||
//FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, Provider<UnlockComponent.Builder> unlockWindowBuilderProvider, Provider<LockComponent.Builder> lockWindowBuilderProvider, Lazy<QuitComponent> quitWindow, Optional<TrayIntegrationProvider> trayIntegration, Optional<UiAppearanceProvider> appearanceProvider, VaultService vaultService, LicenseHolder licenseHolder, VaultListManager vaultListManager, Optional<AutoLockProvider> autoLockProvider) {
|
||||
FxApplication(Settings settings, Lazy<MainWindowComponent> mainWindow, Lazy<PreferencesComponent> preferencesWindow, Provider<UnlockComponent.Builder> unlockWindowBuilderProvider, Provider<LockComponent.Builder> lockWindowBuilderProvider, Lazy<QuitComponent> quitWindow, Optional<TrayIntegrationProvider> trayIntegration, Optional<UiAppearanceProvider> appearanceProvider, VaultService vaultService, LicenseHolder licenseHolder, VaultListManager vaultListManager) {
|
||||
|
||||
this.settings = settings;
|
||||
this.mainWindow = mainWindow;
|
||||
this.preferencesWindow = preferencesWindow;
|
||||
@@ -78,7 +79,7 @@ public class FxApplication extends Application {
|
||||
this.visibleWindows = Stage.getWindows().filtered(Window::isShowing);
|
||||
this.hasVisibleWindows = Bindings.isNotEmpty(visibleWindows);
|
||||
this.vaultListManager = vaultListManager;
|
||||
this.autoLockProvider = autoLockProvider;
|
||||
//this.autoLockProvider = autoLockProvider;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
@@ -89,7 +90,7 @@ public class FxApplication extends Application {
|
||||
|
||||
settings.theme().addListener(this::appThemeChanged);
|
||||
loadSelectedStyleSheet(settings.theme().get());
|
||||
applySystemListener();
|
||||
//applySystemListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,6 +129,7 @@ public class FxApplication extends Application {
|
||||
unlockWindowBuilderProvider.get().vault(vault).owner(owner).build().startUnlockWorkflow();
|
||||
LOG.debug("Showing UnlockWindow for {}", vault.getDisplayName());
|
||||
});
|
||||
checkAutolock(vault, owner);
|
||||
}
|
||||
|
||||
public void startLockWorkflow(Vault vault, Optional<Stage> owner) {
|
||||
@@ -204,7 +206,7 @@ public class FxApplication extends Application {
|
||||
});
|
||||
}
|
||||
|
||||
private void applySystemListener() {
|
||||
/*private void applySystemListener() {
|
||||
autoLockProvider.ifPresent(autoLockProvider -> {
|
||||
try {
|
||||
autoLockProvider.addListener(this::systemInterfaceStateChanged);
|
||||
@@ -229,5 +231,21 @@ public class FxApplication extends Application {
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
public void checkAutolock(Vault vault, Optional<Stage> owner){
|
||||
if (vault.getVaultSettings().lockAfterTime().get()){ //TODO: this is lock after a fixed amount of minutes
|
||||
LOG.info("Locking after {} minutes", vault.getVaultSettings().lockTimeInMinutes().get());
|
||||
new java.util.Timer().schedule(
|
||||
new java.util.TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
startLockWorkflow(vault, owner);
|
||||
}
|
||||
},
|
||||
new Date(System.currentTimeMillis() + Integer.parseInt(vault.getVaultSettings().lockTimeInMinutes().get()) * 60 * 1000)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,13 +19,14 @@ public class AutoLockVaultOptionsController implements FxController {
|
||||
private final Stage window;
|
||||
public CheckBox lockOnSleepCheckbox;
|
||||
public CheckBox lockAfterIdleTimeCheckbox;
|
||||
public CheckBox lockAfterTimeCheckbox;
|
||||
public TextField lockIdleTimeInMinutesTextField;
|
||||
public TextField lockTimeInMinutesTextField;
|
||||
|
||||
@Inject
|
||||
AutoLockVaultOptionsController(@VaultOptionsWindow Stage window, @VaultOptionsWindow Vault vault, ResourceBundle resourceBundle) {
|
||||
this.window = window;
|
||||
this.vault = vault;
|
||||
//this.resourceBundle = resourceBundle;
|
||||
}
|
||||
|
||||
@FXML
|
||||
@@ -33,5 +34,7 @@ public class AutoLockVaultOptionsController implements FxController {
|
||||
lockOnSleepCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().lockOnSleep());
|
||||
lockAfterIdleTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().lockAfterIdleTime());
|
||||
lockIdleTimeInMinutesTextField.textProperty().bindBidirectional(vault.getVaultSettings().lockIdleTimeInMinutes());
|
||||
lockAfterTimeCheckbox.selectedProperty().bindBidirectional(vault.getVaultSettings().lockAfterTime());
|
||||
lockTimeInMinutesTextField.textProperty().bindBidirectional(vault.getVaultSettings().lockTimeInMinutes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,19 @@
|
||||
<Insets topRightBottomLeft="12"/>
|
||||
</padding>
|
||||
<children>
|
||||
<TextFlow styleClass="text-flow" prefWidth="-Infinity">
|
||||
<CheckBox text="%vaultOptions.autoLock.lockAfterTimePart1" fx:id="lockAfterTimeCheckbox"/>
|
||||
<Text text=" "/>
|
||||
<TextField fx:id="lockTimeInMinutesTextField" prefWidth="50"/>
|
||||
<Text text=" "/>
|
||||
<FormattedLabel format="%vaultOptions.autoLock.lockAfterTimePart2"/>
|
||||
</TextFlow>
|
||||
|
||||
<CheckBox text="%vaultOptions.autoLock.lockOnSleep" fx:id="lockOnSleepCheckbox"/>
|
||||
<TextFlow styleClass="text-flow" prefWidth="-Infinity">
|
||||
<CheckBox text="%vaultOptions.autoLock.lockAfterIdleTimePart1" fx:id="lockAfterIdleTimeCheckbox"/>
|
||||
<Text text=" "/>
|
||||
<TextField fx:id="lockIdleTimeInMinutesTextField" prefWidth="50"/> <!--prefWidth="${controller.calculatedWidthForTextfield}"/>-->
|
||||
<TextField fx:id="lockIdleTimeInMinutesTextField" prefWidth="50"/>
|
||||
<Text text=" "/>
|
||||
<FormattedLabel format="%vaultOptions.autoLock.lockAfterIdleTimePart2"/>
|
||||
</TextFlow>
|
||||
|
||||
@@ -297,7 +297,8 @@ vaultOptions.autoLock=Auto-Lock
|
||||
vaultOptions.autoLock.lockOnSleep=Lock on sleep
|
||||
vaultOptions.autoLock.lockAfterIdleTimePart1=Lock after computer is idle for
|
||||
vaultOptions.autoLock.lockAfterIdleTimePart2=minutes.
|
||||
vaultOptions.autoLock.lockAfterAmountOfIdleTime=Following minutes are set:
|
||||
vaultOptions.autoLock.lockAfterTimePart1=Lock after
|
||||
vaultOptions.autoLock.lockAfterTimePart2=minutes.
|
||||
|
||||
# Recovery Key
|
||||
recoveryKey.title=Recovery Key
|
||||
|
||||
Reference in New Issue
Block a user