Skip to content
Snippets Groups Projects
Commit 057308b5 authored by Nick's avatar Nick :v:
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 340c27a4
No related branches found
No related tags found
No related merge requests found
......@@ -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,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private KeyboardTheme mKeyboardTheme;
private Context mThemeContext;
// 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();
......@@ -102,9 +106,11 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
final KeyboardTheme keyboardTheme) {
if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme)
|| !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();
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