Defined theme specific icon folders, renamed icon loading method
@ -93,6 +93,15 @@ public class Settings {
|
|||||||
*/
|
*/
|
||||||
public void setCurrentTheme(String themeName) { ((SettingsItem<String>) items.get("currentTheme")).set(themeName); }
|
public void setCurrentTheme(String themeName) { ((SettingsItem<String>) items.get("currentTheme")).set(themeName); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if the currently used theme is one of the default themes
|
||||||
|
* @since Envoy Client v0.1-beta
|
||||||
|
*/
|
||||||
|
public boolean isUsingDefaultTheme() {
|
||||||
|
final var theme = getCurrentTheme();
|
||||||
|
return theme.equals("dark") || theme.equals("light");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {@code true}, if pressing the {@code Enter} key suffices to send a
|
* @return {@code true}, if pressing the {@code Enter} key suffices to send a
|
||||||
* message. Otherwise it has to be pressed in conjunction with the
|
* message. Otherwise it has to be pressed in conjunction with the
|
||||||
|
@ -47,7 +47,7 @@ public class ClearableTextField extends GridPane {
|
|||||||
public ClearableTextField(String text, int size) {
|
public ClearableTextField(String text, int size) {
|
||||||
// initializing the textField and the button
|
// initializing the textField and the button
|
||||||
textField = new TextField(text);
|
textField = new TextField(text);
|
||||||
clearButton = new Button("", new ImageView(IconUtil.loadDefaultThemeSensitive("clear_button_", size)));
|
clearButton = new Button("", new ImageView(IconUtil.loadIconThemeSensitive("clear_button", size)));
|
||||||
clearButton.setOnAction(e -> textField.clear());
|
clearButton.setOnAction(e -> textField.clear());
|
||||||
clearButton.setFocusTraversable(false);
|
clearButton.setFocusTraversable(false);
|
||||||
clearButton.getStyleClass().clear();
|
clearButton.getStyleClass().clear();
|
||||||
|
@ -66,23 +66,23 @@ public class IconUtil {
|
|||||||
* folder and scales it to 16px.<br>
|
* folder and scales it to 16px.<br>
|
||||||
* The suffix {@code .png} is automatically appended.
|
* The suffix {@code .png} is automatically appended.
|
||||||
*
|
*
|
||||||
* @param name the image name without the .png - suffix
|
* @param name the image name without the .png suffix
|
||||||
* @return the loaded image
|
* @return the loaded image
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
* @apiNote let's take a sample image {@code abc.png} in the folder
|
* @apiNote let's take a sample image {@code abc.png} in the folder
|
||||||
* {@code /icons/}.
|
* {@code /icons/}.
|
||||||
* <br>
|
* <br>
|
||||||
* To do that, we only have to call
|
* To do that, we only have to call
|
||||||
* {@code IconUtil.loadDefault("abc")}
|
* {@code IconUtil.loadIcon("abc")}
|
||||||
*/
|
*/
|
||||||
public static Image loadDefault(String name) { return load("/icons/" + name + ".png"); }
|
public static Image loadIcon(String name) { return load("/icons/" + name + ".png"); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a {@code .png} icon from the sub-folder {@code /icons/} of the resource
|
* Loads a {@code .png} icon from the sub-folder {@code /icons/} of the resource
|
||||||
* folder and scales it to a given size.<br>
|
* folder and scales it to a given size.<br>
|
||||||
* The suffix {@code .png} is automatically appended.
|
* The suffix {@code .png} is automatically appended.
|
||||||
*
|
*
|
||||||
* @param name the image name without the .png - suffix
|
* @param name the image name without the .png suffix
|
||||||
* @param size the size of the image to scale to
|
* @param size the size of the image to scale to
|
||||||
* @return the loaded image
|
* @return the loaded image
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
@ -90,9 +90,9 @@ public class IconUtil {
|
|||||||
* {@code /icons/} and load it in size 16.
|
* {@code /icons/} and load it in size 16.
|
||||||
* <br>
|
* <br>
|
||||||
* To do that, we only have to call
|
* To do that, we only have to call
|
||||||
* {@code IconUtil.loadDefault("abc", 16)}
|
* {@code IconUtil.loadIcon("abc", 16)}
|
||||||
*/
|
*/
|
||||||
public static Image loadDefault(String name, int size) { return load("/icons/" + name + ".png", size); }
|
public static Image loadIcon(String name, int size) { return load("/icons/" + name + ".png", size); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a {@code .png} icon whose design depends on the currently active theme
|
* Loads a {@code .png} icon whose design depends on the currently active theme
|
||||||
@ -104,16 +104,16 @@ public class IconUtil {
|
|||||||
* The suffix {@code .png} is automatically appended.
|
* The suffix {@code .png} is automatically appended.
|
||||||
*
|
*
|
||||||
* @param name the image name without the "black" or "white" suffix and without
|
* @param name the image name without the "black" or "white" suffix and without
|
||||||
* the .png - suffix
|
* the .png suffix
|
||||||
* @return the loaded image
|
* @return the loaded image
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
* @apiNote let's take two sample images {@code abc_black.png} and
|
* @apiNote let's take two sample images {@code abc_black.png} and
|
||||||
* {@code abc_white.png} in the folder {@code /icons/} and load them.
|
* {@code abc_white.png} in the folder {@code /icons/} and load them.
|
||||||
* <br>
|
* <br>
|
||||||
* To do that theme sensitve, we only have to call
|
* To do that theme sensitve, we only have to call
|
||||||
* {@code IconUtil.loadDefaultThemeSensitive("abc_")}
|
* {@code IconUtil.loadIconThemeSensitive("abc_")}
|
||||||
*/
|
*/
|
||||||
public static Image loadDefaultThemeSensitive(String name) { return loadDefault(name + themeSpecificSuffix()); }
|
public static Image loadIconThemeSensitive(String name) { return loadIcon(themeSpecificSubFolder() + name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a {@code .png} icon whose design depends on the currently active theme
|
* Loads a {@code .png} icon whose design depends on the currently active theme
|
||||||
@ -125,7 +125,7 @@ public class IconUtil {
|
|||||||
* <p>
|
* <p>
|
||||||
* The suffix {@code .png} is automatically appended.
|
* The suffix {@code .png} is automatically appended.
|
||||||
*
|
*
|
||||||
* @param name the image name without the .png - suffix
|
* @param name the image name without the .png suffix
|
||||||
* @param size the size of the image to scale to
|
* @param size the size of the image to scale to
|
||||||
* @return the loaded image
|
* @return the loaded image
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
@ -134,9 +134,9 @@ public class IconUtil {
|
|||||||
* size 16.
|
* size 16.
|
||||||
* <br>
|
* <br>
|
||||||
* To do that theme sensitve, we only have to call
|
* To do that theme sensitve, we only have to call
|
||||||
* {@code IconUtil.loadDefaultThemeSensitive("abc_", 16)}
|
* {@code IconUtil.loadIconThemeSensitive("abc_", 16)}
|
||||||
*/
|
*/
|
||||||
public static Image loadDefaultThemeSensitive(String name, int size) { return loadDefault(name + themeSpecificSuffix(), size); }
|
public static Image loadIconThemeSensitive(String name, int size) { return loadIcon(themeSpecificSubFolder() + name, size); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -163,11 +163,13 @@ public class IconUtil {
|
|||||||
/**
|
/**
|
||||||
* This method should be called if the display of an icon depends upon the
|
* This method should be called if the display of an icon depends upon the
|
||||||
* currently active theme.<br>
|
* currently active theme.<br>
|
||||||
* In case of the dark theme, the suffix {@code "white"} will be appended, else
|
* In case of a default theme, the string returned will be
|
||||||
* the suffix {@code "black"} will be appended.
|
* returned ({@code dark/} or {@code light/}), else it will be empty.
|
||||||
*
|
*
|
||||||
* @return the theme specific suffix
|
* @return the theme specific folder
|
||||||
* @since Envoy Client v0.1-beta
|
* @since Envoy Client v0.1-beta
|
||||||
*/
|
*/
|
||||||
public static String themeSpecificSuffix() { return Settings.getInstance().getCurrentTheme().equals("dark") ? "white" : "black"; }
|
public static String themeSpecificSubFolder() {
|
||||||
|
return Settings.getInstance().isUsingDefaultTheme() ? Settings.getInstance().getCurrentTheme() + "/" : "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public final class Startup extends Application {
|
|||||||
messageStatusCache = new Cache<>();
|
messageStatusCache = new Cache<>();
|
||||||
|
|
||||||
stage.setTitle("Envoy");
|
stage.setTitle("Envoy");
|
||||||
stage.getIcons().add(IconUtil.loadDefault("envoy_logo"));
|
stage.getIcons().add(IconUtil.loadIcon("envoy_logo"));
|
||||||
|
|
||||||
final var sceneContext = new SceneContext(stage);
|
final var sceneContext = new SceneContext(stage);
|
||||||
sceneContext.load(SceneInfo.LOGIN_SCENE);
|
sceneContext.load(SceneInfo.LOGIN_SCENE);
|
||||||
|
@ -110,8 +110,8 @@ public final class ChatScene implements Restorable {
|
|||||||
messageList.setCellFactory(MessageListCellFactory::new);
|
messageList.setCellFactory(MessageListCellFactory::new);
|
||||||
userList.setCellFactory(ContactListCellFactory::new);
|
userList.setCellFactory(ContactListCellFactory::new);
|
||||||
|
|
||||||
settingsButton.setGraphic(new ImageView(IconUtil.loadDefault("settings", 16)));
|
settingsButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("settings", 16)));
|
||||||
voiceButton.setGraphic(new ImageView(IconUtil.loadDefaultThemeSensitive("", 24)));
|
voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", 20)));
|
||||||
|
|
||||||
// Listen to received messages
|
// Listen to received messages
|
||||||
eventBus.register(MessageCreationEvent.class, e -> {
|
eventBus.register(MessageCreationEvent.class, e -> {
|
||||||
@ -265,17 +265,17 @@ public final class ChatScene implements Restorable {
|
|||||||
recording = true;
|
recording = true;
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
voiceButton.setText("Recording");
|
voiceButton.setText("Recording");
|
||||||
voiceButton.setGraphic(new ImageView(IconUtil.loadDefault("microphone_recording", 24)));
|
voiceButton.setGraphic(new ImageView(IconUtil.loadIcon("microphone_recording", 24)));
|
||||||
});
|
});
|
||||||
recorder.start();
|
recorder.start();
|
||||||
} else {
|
} else {
|
||||||
pendingAttachment = new Attachment(recorder.finish(), AttachmentType.VOICE);
|
pendingAttachment = new Attachment(recorder.finish(), AttachmentType.VOICE);
|
||||||
recording = false;
|
recording = false;
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
voiceButton.setGraphic(new ImageView(IconUtil.loadDefaultThemeSensitive("microphone_", 24)));
|
voiceButton.setGraphic(new ImageView(IconUtil.loadIconThemeSensitive("microphone", 20)));
|
||||||
voiceButton.setText(null);
|
voiceButton.setText(null);
|
||||||
checkPostConditions(false);
|
checkPostConditions(false);
|
||||||
attachmentView.setImage(IconUtil.loadDefaultThemeSensitive("attachment_present_", 20));
|
attachmentView.setImage(IconUtil.loadIconThemeSensitive("attachment_present", 20));
|
||||||
attachmentView.setVisible(true);
|
attachmentView.setVisible(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 28 KiB |