LatinIME: Cause theme reload when dark mode has changed
Fixes icon colors not being updated
Change-Id: Id72ffa3e062a0f180eae6f238625b6bf7c342dbf
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 2b95d4a..b9cfc72 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -17,6 +17,7 @@
package com.android.inputmethod.keyboard;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.util.Log;
import android.view.ContextThemeWrapper;
@@ -67,6 +68,7 @@
private KeyboardTheme mKeyboardTheme;
private Context mThemeContext;
+ private int mActiveUiMode;
private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
@@ -101,10 +103,14 @@
private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
final KeyboardTheme keyboardTheme) {
- if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme)
+ final boolean darkModeChanged = (mActiveUiMode & Configuration.UI_MODE_NIGHT_MASK)
+ != (context.getResources().getConfiguration().uiMode
+ & Configuration.UI_MODE_NIGHT_MASK);
+ if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme) || darkModeChanged
|| !mThemeContext.getResources().equals(context.getResources())) {
mKeyboardTheme = keyboardTheme;
mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
+ mActiveUiMode = context.getResources().getConfiguration().uiMode;
KeyboardLayoutSet.onKeyboardThemeChanged();
return true;
}