소스 검색

integrating changes proposed by comments in commit e808db51a5b71f6ec29ffa9e8f1c437f05b4c370

infeo 7 년 전
부모
커밋
da31a9d2a0
1개의 변경된 파일23개의 추가작업 그리고 24개의 파일을 삭제
  1. 23 24
      main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java

+ 23 - 24
main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockController.java

@@ -2,7 +2,7 @@
  * Copyright (c) 2014, 2017 Sebastian Stenzel
  * All rights reserved.
  * This program and the accompanying materials are made available under the terms of the accompanying LICENSE file.
- * 
+ *
  * Contributors:
  *     Sebastian Stenzel - initial API and implementation
  ******************************************************************************/
@@ -178,9 +178,9 @@ public class UnlockController implements ViewController {
 		advancedOptions.setVisible(false);
 		advancedOptionsButton.setText(localization.getString("unlock.button.advancedOptions.show"));
 		progressIndicator.setVisible(false);
-		successMessage.setVisible(didChange(state));
-		if (successMessage.isVisible()) {
-			successMessage.setText(localization.getString(state.successMessage()));
+		successMessage.setVisible(state.shouldShowStatusMessage());
+		if (successMessage.isVisible() && state.successMessage().isPresent()) {
+			successMessage.setText(localization.getString(state.successMessage().get()));
 		}
 		if (SystemUtils.IS_OS_WINDOWS) {
 			winDriveLetter.valueProperty().removeListener(driveLetterChangeListener);
@@ -397,15 +397,6 @@ public class UnlockController implements ViewController {
 		}).run();
 	}
 
-	private boolean didChange(State state) {
-		switch (state) {
-			case UNLOCKING:
-				return false;
-			default:
-				return true;
-		}
-	}
-
 	/* callback */
 
 	public void setListener(UnlockListener listener) {
@@ -414,30 +405,38 @@ public class UnlockController implements ViewController {
 
 	@FunctionalInterface
 	interface UnlockListener {
+
 		void didUnlock(Vault vault);
 	}
 
 	/* state */
 
 	public enum State {
-		UNLOCKING(empty()),
-		INITIALIZED("unlock.successLabel.vaultCreated"),
-		PASSWORD_CHANGED("unlock.successLabel.passwordChanged"),
-		UPGRADED("unlock.successLabel.upgraded");
+		UNLOCKING(false),
+		INITIALIZED("unlock.successLabel.vaultCreated", true),
+		PASSWORD_CHANGED("unlock.successLabel.passwordChanged", true),
+		UPGRADED("unlock.successLabel.upgraded", true);
 
-		private static String empty() {
-			return "";
-		}
+		private Optional<String> successMessage;
+		private boolean shouldShowStatusMessage;
 
-		private String successMessage;
+		State(boolean shouldShowStatusMessage) {
+			this.successMessage = Optional.empty();
+			this.shouldShowStatusMessage = shouldShowStatusMessage;
+		}
 
-		State(String successMessage) {
-			this.successMessage = successMessage;
+		State(String successMessage, boolean shouldShowStatusMessage) {
+			this.successMessage = Optional.of(successMessage);
+			this.shouldShowStatusMessage = shouldShowStatusMessage;
 		}
 
-		public String successMessage() {
+		public Optional<String> successMessage() {
 			return successMessage;
 		}
+
+		public boolean shouldShowStatusMessage() {
+			return shouldShowStatusMessage;
+		}
 	}
 
 }