"UI refactoring", preparation for #73

This commit is contained in:
Sebastian Stenzel
2016-03-02 22:23:40 +01:00
parent e57ee67208
commit 890a0c4408
15 changed files with 213 additions and 110 deletions

View File

@@ -72,7 +72,9 @@ public class MainApplication extends Application {
final ResourceBundle rb = ResourceBundle.getBundle("localization");
primaryStage.titleProperty().bind(mainCtrl.windowTitle());
primaryStage.setResizable(false);
primaryStage.getIcons().add(new Image(MainApplication.class.getResourceAsStream("/window_icon.png")));
if (SystemUtils.IS_OS_WINDOWS) {
primaryStage.getIcons().add(new Image(MainApplication.class.getResourceAsStream("/window_icon.png")));
}
primaryStage.show();
ActiveWindowStyleSupport.startObservingFocus(primaryStage);

View File

@@ -161,7 +161,7 @@ public class MainController extends AbstractFXMLViewController {
if (addVaultContextMenu.isShowing()) {
addVaultContextMenu.hide();
} else {
addVaultContextMenu.show(addVaultButton, Side.RIGHT, 0.0, 0.0);
addVaultContextMenu.show(addVaultButton, Side.BOTTOM, 0.0, 0.0);
}
}

View File

@@ -293,13 +293,11 @@ public class UnlockController extends AbstractFXMLViewController {
messageText.setText(resourceBundle.getString("unlock.errorMessage.unsupportedVersion.softwareOlderThanVault") + " ");
}
});
} catch (FrontendCreationFailedException e) {
} catch (FrontendCreationFailedException | CommandFailedException e) {
LOG.error("Decryption failed for technical reasons.", e);
Platform.runLater(() -> {
messageText.setText(resourceBundle.getString("unlock.errorMessage.decryptionFailed"));
messageText.setText(resourceBundle.getString("unlock.errorMessage.mountingFailed"));
});
} catch (CommandFailedException e) {
LOG.error("Failed to reveal mounted vault", e);
} finally {
Platform.runLater(() -> {
passwordField.swipe();

View File

@@ -31,11 +31,15 @@ import javafx.collections.ListChangeListener;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.geometry.Side;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.chart.XYChart.Series;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.ToggleButton;
import javafx.stage.PopupWindow.AnchorLocation;
import javafx.stage.Stage;
import javafx.util.Duration;
@@ -68,12 +72,19 @@ public class UnlockedController extends AbstractFXMLViewController {
@FXML
private NumberAxis xAxis;
@FXML
private ToggleButton moreOptionsButton;
@FXML
private ContextMenu moreOptionsMenu;
@Override
public void initialize() {
macWarningsController.initStage(macWarningsWindow);
ActiveWindowStyleSupport.startObservingFocus(macWarningsWindow);
EasyBind.subscribe(vault, this::vaultChanged);
EasyBind.subscribe(moreOptionsMenu.showingProperty(), moreOptionsButton::setSelected);
}
@Override
@@ -106,20 +117,7 @@ public class UnlockedController extends AbstractFXMLViewController {
}
@FXML
private void didClickRevealVault(ActionEvent event) {
exec.submit(() -> {
try {
vault.get().reveal();
} catch (CommandFailedException e) {
Platform.runLater(() -> {
messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
});
}
});
}
@FXML
private void didClickCloseVault(ActionEvent event) {
private void didClickLockVault(ActionEvent event) {
exec.submit(() -> {
try {
vault.get().unmount();
@@ -134,6 +132,29 @@ public class UnlockedController extends AbstractFXMLViewController {
});
}
@FXML
private void didClickMoreOptions(ActionEvent event) {
if (moreOptionsMenu.isShowing()) {
moreOptionsMenu.hide();
} else {
moreOptionsMenu.setAnchorLocation(AnchorLocation.CONTENT_TOP_RIGHT);
moreOptionsMenu.show(moreOptionsButton, Side.BOTTOM, moreOptionsButton.getWidth(), 0.0);
}
}
@FXML
private void didClickRevealVault(ActionEvent event) {
exec.submit(() -> {
try {
vault.get().reveal();
} catch (CommandFailedException e) {
Platform.runLater(() -> {
messageLabel.setText(resourceBundle.getString("unlocked.label.revealFailed"));
});
}
});
}
// ****************************************
// MAC Auth Warnings
// ****************************************

View File

@@ -53,6 +53,19 @@ public class WelcomeController extends AbstractFXMLViewController {
private static final Logger LOG = LoggerFactory.getLogger(WelcomeController.class);
private final Application app;
private final Settings settings;
private final Comparator<String> semVerComparator;
private final ExecutorService executor;
@Inject
public WelcomeController(Application app, Settings settings, @Named("SemVer") Comparator<String> semVerComparator, ExecutorService executor) {
this.app = app;
this.settings = settings;
this.semVerComparator = semVerComparator;
this.executor = executor;
}
@FXML
private ImageView botImageView;
@@ -68,17 +81,15 @@ public class WelcomeController extends AbstractFXMLViewController {
@FXML
private Hyperlink updateLink;
private final Application app;
private final Settings settings;
private final Comparator<String> semVerComparator;
private final ExecutorService executor;
@Inject
public WelcomeController(Application app, Settings settings, @Named("SemVer") Comparator<String> semVerComparator, ExecutorService executor) {
this.app = app;
this.settings = settings;
this.semVerComparator = semVerComparator;
this.executor = executor;
@Override
public void initialize() {
botImageView.setImage(new Image(getClass().getResource("/bot_welcome.png").toString()));
if (areUpdatesManagedExternally()) {
checkForUpdatesContainer.setVisible(false);
checkForUpdatesContainer.setManaged(false);
} else if (settings.isCheckForUpdatesEnabled()) {
executor.execute(this::checkForUpdates);
}
}
@Override
@@ -91,17 +102,6 @@ public class WelcomeController extends AbstractFXMLViewController {
return ResourceBundle.getBundle("localization");
}
@Override
public void initialize() {
botImageView.setImage(new Image(getClass().getResource("/bot_welcome.png").toString()));
if (areUpdatesManagedExternally()) {
checkForUpdatesContainer.setVisible(false);
checkForUpdatesContainer.setManaged(false);
} else if (settings.isCheckForUpdatesEnabled()) {
executor.execute(this::checkForUpdates);
}
}
// ****************************************
// Check for updates
// ****************************************

View File

@@ -38,7 +38,7 @@
/****************************************************************************
* *
* Labels *
* Labels & Fonts *
* *
****************************************************************************/
@@ -46,6 +46,10 @@
-fx-text-fill: COLOR_TEXT;
}
.ionicons {
-fx-font-family: Ionicons;
}
/****************************************************************************
* *
* Hyperlinks *
@@ -67,30 +71,51 @@
* *
****************************************************************************/
.button {
.button,
.toggle-button {
-fx-pref-height: 25px;
-fx-background-color: COLOR_BORDER, COLOR_VGRAD_LIGHT;
-fx-background-insets: 0, 1;
-fx-padding: 0.4em 0.8em 0.4em 0.8em;
-fx-padding: 4px 8px 4px 8px;
-fx-text-fill: COLOR_TEXT;
-fx-alignment: CENTER;
}
.button:hover,
.button:default:hover {
.button:default:hover,
.toggle-button:hover {
-fx-background-color: COLOR_BORDER, COLOR_VGRAD_MEDIUM;
}
.button:armed,
.button:default:armed {
.button:default:armed,
.toggle-button:armed {
-fx-background-color: COLOR_BORDER_DARK, COLOR_VGRAD_DARK;
}
.button:disabled,
.button:default:disabled {
.button:default:disabled,
.toggle-button:disabled {
-fx-background-color: COLOR_BORDER, COLOR_VGRAD_LIGHT;
-fx-text-fill: COLOR_TEXT_DISABLED;
}
/****************************************************************************
* *
* Segmented Buttons *
* *
****************************************************************************/
.segmented-button-bar .button,
.segmented-button-bar .toggle-button {
-fx-background-insets: 0, 1;
}
.segmented-button-bar .button.last,
.segmented-button-bar .toggle-button.last {
-fx-background-insets: 0, 1 1 1 0;
}
/****************************************************************************
* *
* Text Fields *
@@ -179,7 +204,7 @@
.tool-bar.list-related-toolbar .toggle-button,
.tool-bar.list-related-toolbar .button {
-fx-font-family: Ionicons;
-fx-pref-height: 30px;
-fx-font-size: 1.8em;
-fx-text-fill: COLOR_TEXT;
-fx-padding: 0.2em 0.8em 0.2em 0.8em;

View File

@@ -37,7 +37,7 @@
/****************************************************************************
* *
* Labels *
* Labels & Fonts *
* *
****************************************************************************/
@@ -45,6 +45,10 @@
-fx-text-fill: COLOR_TEXT;
}
.ionicons {
-fx-font-family: Ionicons;
}
/****************************************************************************
* *
* Hyperlinks *
@@ -66,11 +70,13 @@
* *
****************************************************************************/
.button {
.button,
.toggle-button {
-fx-pref-height: 21px;
-fx-background-color: COLOR_HGRAD_BTN_BORDER, #FFF;
-fx-background-insets: 0, 1;
-fx-background-radius: 4;
-fx-padding: 0.2em 0.8em 0.2em 0.8em;
-fx-padding: 2px 12px 3px 12px;
-fx-text-fill: COLOR_TEXT;
-fx-alignment: CENTER;
-fx-focus-traversable: false;
@@ -84,6 +90,7 @@
.button:disabled,
.button:default:disabled,
.toggle-button:disabled,
.root.active-window .button:default:disabled {
-fx-background-color: COLOR_HGRAD_BTN_BORDER_DIS, #F2F2F2;
-fx-background-insets: 0, 1;
@@ -97,6 +104,34 @@
-fx-text-fill: #FFF;
}
.toggle-button:armed,
.toggle-button:selected {
-fx-background-color: linear-gradient(to bottom, #C0C0C0 0%, #ADADAD 100%);
}
/****************************************************************************
* *
* Segmented Buttons *
* *
****************************************************************************/
.segmented-button-bar .button,
.segmented-button-bar .toggle-button {
-fx-background-radius: 0;
-fx-background-insets: 0, 1 1 1 0;
}
.segmented-button-bar .button.first,
.segmented-button-bar .toggle-button.first {
-fx-background-radius: 4 0 0 4;
-fx-background-insets: 0, 1;
}
.segmented-button-bar .button.last,
.segmented-button-bar .toggle-button.last {
-fx-background-radius: 0 4 4 0;
}
/****************************************************************************
* *
* Text Fields *
@@ -227,6 +262,7 @@
****************************************************************************/
.tool-bar.list-related-toolbar {
-fx-font-size: 1.4em;
-fx-background-color: COLOR_BORDER, #F7F7F7;
-fx-background-insets: 0, 0 1 1 1;
-fx-padding: 0;
@@ -241,8 +277,7 @@
.tool-bar.list-related-toolbar .toggle-button,
.tool-bar.list-related-toolbar .button {
-fx-font-family: Ionicons;
-fx-font-size: 1.4em;
-fx-pref-height: 25px;
-fx-text-fill: COLOR_TEXT;
-fx-background-color: transparent;
-fx-padding: 0.1em 0.6em 0.1em 0.6em;

View File

@@ -30,7 +30,7 @@
/****************************************************************************
* *
* Labels *
* Labels & Fonts *
* *
****************************************************************************/
@@ -38,6 +38,10 @@
-fx-text-fill: COLOR_TEXT;
}
.ionicons {
-fx-font-family: Ionicons;
}
/****************************************************************************
* *
* Hyperlinks *
@@ -61,10 +65,10 @@
.button,
.toggle-button {
-fx-pref-height: 25px;
-fx-background-color: COLOR_BORDER, linear-gradient(to bottom, #F0F0F0 0%, #E5E5E5 100%);
-fx-background-insets: 0, 1;
-fx-background-radius: 0, 0;
-fx-padding: 0.1em 0.6em 0.1em 0.6em;
-fx-padding: 2px 12px 2px 12px;
-fx-text-fill: COLOR_TEXT;
-fx-alignment: CENTER;
-fx-border-color: transparent;
@@ -83,18 +87,34 @@
.button:armed,
.button:default:armed,
.toggle-button:armed {
.toggle-button:armed,
.toggle-button:selected {
-fx-background-color: COLOR_BORDER_FOCUS, linear-gradient(to bottom, #DAECFC 0%, #C4E0FC 100%);
}
.button:focused,
.toggle-button:focused,
.toggle-button:focused {
-fx-border-color: black;
-fx-border-insets: 2px;
-fx-border-style: dotted inside;
}
/****************************************************************************
* *
* Segmented Buttons *
* *
****************************************************************************/
.segmented-button-bar .button,
.segmented-button-bar .toggle-button {
-fx-background-insets: 0, 1;
}
.segmented-button-bar .button.last,
.segmented-button-bar .toggle-button.last {
-fx-background-insets: 0, 1 1 1 0;
}
/****************************************************************************
* *
* Text Fields *
@@ -232,14 +252,13 @@
.tool-bar.list-related-toolbar {
-fx-background-color: transparent;
-fx-padding: 0.1em 0 0.1em 0;
-fx-padding: 0.4em 0 0 0;
-fx-spacing: 1px;
-fx-alignment: CENTER_LEFT;
}
.tool-bar.list-related-toolbar .toggle-button,
.tool-bar.list-related-toolbar .button {
-fx-font-family: Ionicons;
-fx-font-size: 1.4em;
-fx-text-fill: COLOR_TEXT;
}

View File

@@ -24,7 +24,7 @@
<GridPane vgap="12.0" hgap="12.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<padding>
<Insets top="24.0" right="24.0" bottom="24.0" left="24.0" />
<Insets top="24.0" right="12.0" bottom="24.0" left="12.0" />
</padding>
<columnConstraints>

View File

@@ -18,7 +18,7 @@
<GridPane vgap="12.0" hgap="12.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<padding>
<Insets top="24.0" right="24.0" bottom="24.0" left="24.0" />
<Insets top="24.0" right="12.0" bottom="24.0" left="12.0" />
</padding>
<columnConstraints>

View File

@@ -20,7 +20,7 @@
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Separator?>
<HBox fx:id="rootPane" prefHeight="440.0" prefWidth="640.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<HBox fx:id="rootPane" prefHeight="440.0" prefWidth="652.0" spacing="12.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<padding><Insets top="20" right="20" bottom="20" left="20.0"/></padding>
@@ -39,23 +39,19 @@
</ContextMenu>
</fx:define>
<children>
<VBox prefWidth="200.0" cacheShape="true" cache="true">
<children>
<ListView fx:id="vaultList" VBox.vgrow="ALWAYS" focusTraversable="false" cacheShape="true" cache="true"/>
<ToolBar VBox.vgrow="NEVER" styleClass="list-related-toolbar" cacheShape="true" cache="true">
<items>
<ToggleButton text="&#xf489;" fx:id="addVaultButton" onAction="#didClickAddVault" focusTraversable="false" cacheShape="true" cache="true"/>
<Button text="&#xf462;" fx:id="removeVaultButton" onAction="#didClickRemoveSelectedEntry" focusTraversable="false" cacheShape="true" cache="true"/>
<Pane HBox.hgrow="ALWAYS" styleClass="spacer" />
<!-- future use: -->
<ToggleButton text="&#xf43c;" fx:id="settingsButton" onAction="#didClickShowSettings" focusTraversable="false" cacheShape="true" cache="true"/>
</items>
</ToolBar>
</children>
</VBox>
<Pane fx:id="contentPane" cacheShape="true" cache="true"/>
</children>
<VBox prefWidth="200.0" cacheShape="true" cache="true">
<ListView fx:id="vaultList" VBox.vgrow="ALWAYS" focusTraversable="false" cacheShape="true" cache="true"/>
<ToolBar VBox.vgrow="NEVER" styleClass="list-related-toolbar" cacheShape="true" cache="true">
<items>
<ToggleButton text="&#xf489;" styleClass="ionicons" fx:id="addVaultButton" onAction="#didClickAddVault" focusTraversable="false" cacheShape="true" cache="true"/>
<Button text="&#xf462;" styleClass="ionicons" fx:id="removeVaultButton" onAction="#didClickRemoveSelectedEntry" focusTraversable="false" cacheShape="true" cache="true"/>
<Pane HBox.hgrow="ALWAYS" styleClass="spacer" />
<!-- future use: -->
<ToggleButton text="&#xf43c;" styleClass="ionicons" fx:id="settingsButton" onAction="#didClickShowSettings" focusTraversable="false" cacheShape="true" cache="true"/>
</items>
</ToolBar>
</VBox>
<Pane fx:id="contentPane" prefWidth="400.0" cacheShape="true" cache="true"/>
</HBox>

View File

@@ -19,7 +19,7 @@
<VBox prefWidth="400.0" alignment="TOP_CENTER" spacing="12.0" cacheShape="true" cache="true">
<GridPane VBox.vgrow="ALWAYS" vgap="12.0" hgap="12.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<padding>
<Insets top="24.0" right="24.0" bottom="24.0" left="24.0" />
<Insets top="24.0" right="12.0" bottom="24.0" left="12.0" />
</padding>
<columnConstraints>

View File

@@ -27,7 +27,7 @@
<GridPane vgap="12.0" hgap="12.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<padding>
<Insets top="24.0" right="24.0" bottom="24.0" left="24.0" />
<Insets top="24.0" right="12.0" bottom="24.0" left="12.0" />
</padding>
<columnConstraints>

View File

@@ -17,32 +17,38 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.control.ContextMenu?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.Pane?>
<GridPane vgap="12.0" hgap="12.0" prefWidth="400.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<padding>
<Insets top="24.0" right="24.0" bottom="24.0" left="24.0" />
</padding>
<VBox prefWidth="400.0" prefHeight="400.0" spacing="6.0" xmlns:fx="http://javafx.com/fxml" cacheShape="true" cache="true">
<fx:define>
<ContextMenu fx:id="moreOptionsMenu">
<items>
<MenuItem text="%unlocked.moreOptions.reveal" onAction="#didClickRevealVault"/>
<!-- Future use: -->
<MenuItem text="%unlocked.moreOptions.copyUrl" disable="true"/>
</items>
</ContextMenu>
</fx:define>
<LineChart fx:id="ioGraph" VBox.vgrow="ALWAYS" animated="false" createSymbols="false" prefHeight="340.0" legendVisible="true" legendSide="BOTTOM" verticalZeroLineVisible="false" verticalGridLinesVisible="false" horizontalGridLinesVisible="true" cacheShape="true" cache="true" cacheHint="SPEED">
<xAxis><NumberAxis fx:id="xAxis" forceZeroInRange="false" tickMarkVisible="false" minorTickVisible="false" tickLabelsVisible="false" autoRanging="false" cacheShape="true" cache="true" /></xAxis>
<yAxis><NumberAxis label="%unlocked.ioGraph.yAxis.label" autoRanging="true" forceZeroInRange="true" cacheShape="true" cache="true" /></yAxis>
</LineChart>
<columnConstraints>
<ColumnConstraints percentWidth="38.2"/>
<ColumnConstraints percentWidth="61.8"/>
</columnConstraints>
<children>
<!-- Row 0 -->
<LineChart fx:id="ioGraph" GridPane.rowIndex="0" GridPane.columnIndex="0" GridPane.columnSpan="2" animated="false" createSymbols="false" prefHeight="340.0" legendVisible="true" legendSide="BOTTOM" verticalZeroLineVisible="false" verticalGridLinesVisible="false" horizontalGridLinesVisible="true" cacheShape="true" cache="true" cacheHint="SPEED">
<xAxis><NumberAxis fx:id="xAxis" forceZeroInRange="false" tickMarkVisible="false" minorTickVisible="false" tickLabelsVisible="false" autoRanging="false" cacheShape="true" cache="true" /></xAxis>
<yAxis><NumberAxis label="%unlocked.ioGraph.yAxis.label" autoRanging="true" forceZeroInRange="true" cacheShape="true" cache="true" /></yAxis>
</LineChart>
<!-- Row 1 -->
<Label fx:id="messageLabel" GridPane.rowIndex="1" GridPane.columnIndex="0" cacheShape="true" cache="true" />
<HBox GridPane.rowIndex="1" GridPane.columnIndex="1" spacing="6.0" alignment="CENTER_RIGHT" cacheShape="true" cache="true">
<Button text="%unlocked.button.reveal" prefWidth="100.0" onAction="#didClickRevealVault" focusTraversable="false" cacheShape="true" cache="true"/>
<Button text="%unlocked.button.lock" prefWidth="100.0" onAction="#didClickCloseVault" focusTraversable="false" cacheShape="true" cache="true"/>
<HBox VBox.vgrow="NEVER">
<Pane HBox.hgrow="ALWAYS">
<Label fx:id="messageLabel" cacheShape="true" cache="true" />
</Pane>
<HBox styleClass="segmented-button-bar" HBox.hgrow="NEVER" alignment="CENTER_RIGHT" cacheShape="true" cache="true">
<Button text="%unlocked.button.lock" styleClass="first" onAction="#didClickLockVault" focusTraversable="false" cacheShape="true" cache="true"/>
<ToggleButton text="&#xf104;" styleClass="last,ionicons" focusTraversable="false" fx:id="moreOptionsButton" onAction="#didClickMoreOptions" />
</HBox>
</children>
</GridPane>
</HBox>
</VBox>

View File

@@ -39,7 +39,7 @@ unlock.button.advancedOptions.show=More options
unlock.button.advancedOptions.hide=Less options
unlock.choicebox.winDriveLetter.auto=Assign automatically
unlock.errorMessage.wrongPassword=Wrong password.
unlock.errorMessage.decryptionFailed=Decryption failed.
unlock.errorMessage.mountingFailed=Mounting failed.
unlock.errorMessage.unsupportedKeyLengthInstallJCE=Decryption failed. Please install Oracle JCE Unlimited Strength Policy.
unlock.errorMessage.unsupportedVersion.vaultOlderThanSoftware=Unsupported vault. This vault has been created with an older version of Cryptomator.
unlock.errorMessage.unsupportedVersion.softwareOlderThanVault=Unsupported vault. This vault has been created with a newer version of Cryptomator.
@@ -59,8 +59,9 @@ changePassword.errorMessage.unsupportedVersion.softwareOlderThanVault=Unsupporte
changePassword.infoMessage.success=Password changed.
# unlocked.fxml
unlocked.button.reveal=Reveal drive
unlocked.button.lock=Lock vault
unlocked.moreOptions.reveal=Reveal drive
unlocked.moreOptions.copyUrl=Copy WebDAV URL
unlocked.label.revealFailed=Command failed.
unlocked.label.unmountFailed=Ejecting drive failed.
unlocked.ioGraph.yAxis.label=Throughput (MiB/s)
@@ -75,7 +76,7 @@ macWarnings.whitelistButton=Decrypt selected anyway
settings.checkForUpdates.label=Check for updates
settings.port.label=WebDAV Port *
settings.port.prompt=0 = Choose automatically
settings.requiresRestartLabel=* Restart required
settings.requiresRestartLabel=* Cryptomator needs to restart
# tray icon
tray.menu.open=Open