Skip to content
Snippets Groups Projects
Commit b77cdc71 authored by Nick's avatar Nick :v: Committed by Dhina17
Browse files

LatinIME: recreate keyboard theme when configuration changes

* checking if resources object is equal is not enough
* fixes Material You accent not updating when switching light/dark mode

Change-Id: I798041cdcbf6b7bbcdc69f4edbb9d0bf392bbb69
parent 7d2782ae
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private KeyboardTheme mKeyboardTheme;
private Context mThemeContext;
private int mActiveUiMode;
// Cache the configuration to detect changes, Context/Resources changes it in real time,
// we need to keep the one used for creation to detect changes
private Configuration mThemeConfig;
private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
......@@ -107,9 +110,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
!= (context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK);
if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme) || darkModeChanged
|| !mThemeContext.getResources().equals(context.getResources())) {
|| !mThemeContext.getResources().equals(context.getResources())
|| !mThemeConfig.equals(context.getResources().getConfiguration())) {
mKeyboardTheme = keyboardTheme;
mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
mThemeConfig = mThemeContext.getResources().getConfiguration();
mActiveUiMode = context.getResources().getConfiguration().uiMode;
KeyboardLayoutSet.onKeyboardThemeChanged();
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment