Currently, the HTML content displayed in the application does not adapt to the look and feel (LaF) of the enclosing Java application. Users should have the option to specify if the HTML part should turn dark when they choose a dark LaF or remain light. This feature will enhance the user experience by ensuring visual consistency across the application.
Acceptance Criteria:
Users can choose whether the HTML content should follow the application’s LaF or stay light.
When the user selects a dark LaF and opts for HTML to follow the LaF, the HTML content should switch to a dark theme.
When the user selects a light LaF or opts for the HTML to stay light, the HTML content should remain in a light theme.
User preferences for HTML LaF settings should be saved and persisted across sessions.
Tasks:
Add a setting in the user configuration to allow HTML content to follow the application’s LaF.
Retrieve the current LaF using UIManager.
Inject appropriate CSS into the HTML content based on the selected LaF and user preference.
Update the method responsible for generating HTML content (getEntryHeadline) to include the dynamic CSS.
Provide a user interface component (e.g., a checkbox) to allow users to select their preference for HTML styling.
Save and load user preferences for this setting.
Additional Information:
Ensure that the CSS for both light and dark themes is defined and applied correctly.
Test the implementation with various LaFs to ensure consistent behavior.
Update documentation to include information about the new setting.
Example:
// Define CSS for light and dark themes
String lightCss = "body { background-color: white; color: black; }";
String darkCss = "body { background-color: black; color: white; }";
// Determine current LaF and user setting
String currentLaF = UIManager.getLookAndFeel().getName();
boolean isHtmlFollowLaF = settingsObj.isHtmlFollowLaF();
// Choose CSS based on LaF and user preference
String css = isHtmlFollowLaF && currentLaF.contains("Dark") ? darkCss : lightCss;
// Inject CSS into HTML content
StringBuilder htmlContent = new StringBuilder();
htmlContent.append("<html><head><style>").append(css).append("</style></head><body>");
// Add HTML content
htmlContent.append("</body></html>");
Currently, the HTML content displayed in the application does not adapt to the look and feel (LaF) of the enclosing Java application. Users should have the option to specify if the HTML part should turn dark when they choose a dark LaF or remain light. This feature will enhance the user experience by ensuring visual consistency across the application.
Acceptance Criteria:
Tasks:
UIManager
.getEntryHeadline
) to include the dynamic CSS.Additional Information:
Example: