diff --git a/app/src/main/java/com/termux/app/terminal/TermuxTerminalSessionActivityClient.java b/app/src/main/java/com/termux/app/terminal/TermuxTerminalSessionActivityClient.java index cd38163116..e55fcef5f4 100644 --- a/app/src/main/java/com/termux/app/terminal/TermuxTerminalSessionActivityClient.java +++ b/app/src/main/java/com/termux/app/terminal/TermuxTerminalSessionActivityClient.java @@ -26,6 +26,7 @@ import com.termux.app.TermuxService; import com.termux.shared.termux.settings.properties.TermuxPropertyConstants; import com.termux.shared.termux.terminal.io.BellHandler; +import com.termux.shared.theme.ThemeUtils; import com.termux.shared.logger.Logger; import com.termux.terminal.TerminalColors; import com.termux.terminal.TerminalSession; @@ -296,6 +297,7 @@ public void setCurrentSession(TerminalSession session) { if (mActivity.getTerminalView().attachSession(session)) { // notify about switched session if not already displaying the session notifyOfSessionChange(); + checkForFontAndColors(); } // We call the following even when the session is already being displayed since config may @@ -503,7 +505,7 @@ public void checkForFontAndColors() { } } - TerminalColors.COLOR_SCHEME.updateWith(props); + TerminalColors.COLOR_SCHEME.updateWith(props, !ThemeUtils.shouldEnableDarkTheme(mActivity)); TerminalSession session = mActivity.getCurrentSession(); if (session != null && session.getEmulator() != null) { session.getEmulator().mColors.reset(); diff --git a/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java b/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java index 4088781805..57d75885c0 100644 --- a/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java +++ b/terminal-emulator/src/main/java/com/termux/terminal/TerminalColorScheme.java @@ -69,11 +69,29 @@ private void reset() { System.arraycopy(DEFAULT_COLORSCHEME, 0, mDefaultColors, 0, TextStyle.NUM_INDEXED_COLORS); } - public void updateWith(Properties props) { + void logEx(Exception e) { + throw new IllegalArgumentException(e.toString()+e.getMessage()); + } + + public void updateWith(Properties props, boolean isDay) { reset(); boolean cursorPropExists = false; for (Map.Entry entries : props.entrySet()) { String key = (String) entries.getKey(); + +try { + if (key.contains(".")) { + String prefix = key.split("\\.")[0]; + boolean useDay = isDay && prefix.equals("day"); + boolean useNight = !isDay && prefix.equals("night"); + + if (useDay || useNight) + key = key.split("\\.")[1]; + else + continue; + } +} catch (Exception e) { logEx(e); } + String value = (String) entries.getValue(); int colorIndex;