Skip to content

Commit 2c6ac85

Browse files
NmurtasDevclaude
andcommitted
Fix log accordion colors for dark theme compatibility
- Replace hardcoded colors with UIManager system colors - Add isDarkTheme() method to detect dark/light themes - Set TextArea background, foreground, and caret colors from system - Adjust header background based on theme (brighter for dark, darker for light) - Ensure Label foreground uses system text color Fixes white-on-white text issue on Gnome dark themes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent af40558 commit 2c6ac85

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

src/main/java/net/nicolamurtas/android/emulator/AndroidEmulatorManager.java

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,23 @@ private JPanel createAvdPanel() {
167167

168168
private JPanel createLogAccordion() {
169169
logPanel = new JPanel(new BorderLayout());
170-
logPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
170+
logPanel.setBorder(BorderFactory.createLineBorder(UIManager.getColor("Panel.background").darker(), 1));
171171

172-
// Header panel with toggle button
172+
// Header panel with toggle button - use system colors
173173
JPanel headerPanel = new JPanel(new BorderLayout());
174-
headerPanel.setBackground(new Color(240, 240, 240));
174+
// Use slightly darker/lighter version of panel background for contrast
175+
Color panelBg = UIManager.getColor("Panel.background");
176+
Color headerBg = panelBg != null ?
177+
(isDarkTheme() ? panelBg.brighter() : panelBg.darker()) :
178+
new Color(240, 240, 240);
179+
headerPanel.setBackground(headerBg);
175180
headerPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
176181

177182
JLabel logLabel = new JLabel("▶ Log");
178183
logLabel.setFont(logLabel.getFont().deriveFont(Font.BOLD, 13f));
179184
logLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
185+
// Ensure label uses system text color
186+
logLabel.setForeground(UIManager.getColor("Label.foreground"));
180187

181188
JButton clearButton = new JButton("Clear");
182189
clearButton.setFont(clearButton.getFont().deriveFont(10f));
@@ -187,10 +194,14 @@ private JPanel createLogAccordion() {
187194
headerPanel.add(logLabel, BorderLayout.WEST);
188195
headerPanel.add(clearButton, BorderLayout.EAST);
189196

190-
// Log content panel (initially hidden)
197+
// Log content panel (initially hidden) - use system colors
191198
logArea = new JTextArea(10, 0);
192199
logArea.setEditable(false);
193200
logArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
201+
// Set text area colors to match system theme
202+
logArea.setBackground(UIManager.getColor("TextArea.background"));
203+
logArea.setForeground(UIManager.getColor("TextArea.foreground"));
204+
logArea.setCaretColor(UIManager.getColor("TextArea.caretForeground"));
194205

195206
logScrollPane = new JScrollPane(logArea);
196207
logScrollPane.setPreferredSize(new Dimension(0, 0));
@@ -617,6 +628,24 @@ private void log(String message) {
617628
});
618629
}
619630

631+
/**
632+
* Detects if the current system theme is dark.
633+
* Uses panel background brightness to determine theme.
634+
*/
635+
private boolean isDarkTheme() {
636+
Color bg = UIManager.getColor("Panel.background");
637+
if (bg == null) {
638+
return false;
639+
}
640+
// Calculate perceived brightness using standard formula
641+
int brightness = (int) Math.sqrt(
642+
bg.getRed() * bg.getRed() * 0.241 +
643+
bg.getGreen() * bg.getGreen() * 0.691 +
644+
bg.getBlue() * bg.getBlue() * 0.068
645+
);
646+
return brightness < 130; // Dark theme if brightness < 130
647+
}
648+
620649
private void onClosing() {
621650
if (emulatorService != null && !emulatorService.getRunningEmulators().isEmpty()) {
622651
int result = JOptionPane.showConfirmDialog(this,

0 commit comments

Comments
 (0)