Search in sources :

Example 1 with AppReopenedListener

use of java.awt.desktop.AppReopenedListener in project cryptomator by cryptomator.

the class UiLauncher method launch.

private void launch(boolean withTrayIcon, boolean hidden) {
    // start hidden, minimized or normal?
    if (withTrayIcon && hidden) {
        LOG.debug("Hiding application...");
        trayIntegration.ifPresent(TrayIntegrationProvider::minimizedToTray);
    } else if (!withTrayIcon && hidden) {
        LOG.debug("Minimizing application...");
        showMainWindowAsync(true);
    } else {
        LOG.debug("Showing application...");
        showMainWindowAsync(false);
    }
    // register app reopen listener
    Desktop.getDesktop().addAppEventListener((AppReopenedListener) e -> showMainWindowAsync(false));
    // auto unlock
    Collection<Vault> vaultsToAutoUnlock = vaults.filtered(this::shouldAttemptAutoUnlock);
    if (!vaultsToAutoUnlock.isEmpty()) {
        fxApplicationStarter.get().thenAccept(app -> {
            for (Vault vault : vaultsToAutoUnlock) {
                app.startUnlockWorkflow(vault, Optional.empty());
            }
        });
    }
    launchEventHandler.startHandlingLaunchEvents();
}
Also used : Desktop(java.awt.Desktop) AppReopenedListener(java.awt.desktop.AppReopenedListener) Logger(org.slf4j.Logger) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) FxApplication(org.cryptomator.ui.fxapp.FxApplication) TrayMenuComponent(org.cryptomator.ui.traymenu.TrayMenuComponent) Singleton(javax.inject.Singleton) Lazy(dagger.Lazy) Inject(javax.inject.Inject) Vault(org.cryptomator.common.vaults.Vault) TrayIntegrationProvider(org.cryptomator.integrations.tray.TrayIntegrationProvider) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) SystemTray(java.awt.SystemTray) Settings(org.cryptomator.common.settings.Settings) TrayIntegrationProvider(org.cryptomator.integrations.tray.TrayIntegrationProvider) Vault(org.cryptomator.common.vaults.Vault)

Aggregations

Lazy (dagger.Lazy)1 Desktop (java.awt.Desktop)1 SystemTray (java.awt.SystemTray)1 AppReopenedListener (java.awt.desktop.AppReopenedListener)1 Collection (java.util.Collection)1 Optional (java.util.Optional)1 ObservableList (javafx.collections.ObservableList)1 Inject (javax.inject.Inject)1 Singleton (javax.inject.Singleton)1 Settings (org.cryptomator.common.settings.Settings)1 Vault (org.cryptomator.common.vaults.Vault)1 TrayIntegrationProvider (org.cryptomator.integrations.tray.TrayIntegrationProvider)1 FxApplication (org.cryptomator.ui.fxapp.FxApplication)1 TrayMenuComponent (org.cryptomator.ui.traymenu.TrayMenuComponent)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1