This commit is contained in:
Helium314 2023-12-31 09:40:31 +01:00
parent 296f37c829
commit 30201f91ba
2 changed files with 6 additions and 4 deletions

View file

@ -86,11 +86,12 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
public void updateKeyboardTheme(@NonNull Context displayContext) { public void updateKeyboardTheme(@NonNull Context displayContext) {
final boolean themeUpdated = updateKeyboardThemeAndContextThemeWrapper( final boolean themeUpdated = updateKeyboardThemeAndContextThemeWrapper(
displayContext, KeyboardTheme.getKeyboardTheme(displayContext /* context */)); displayContext, KeyboardTheme.getKeyboardTheme(displayContext));
if (themeUpdated && mKeyboardView != null) { if (themeUpdated) {
Settings settings = Settings.getInstance(); Settings settings = Settings.getInstance();
settings.loadSettings(displayContext, settings.getCurrent().mLocale, settings.getCurrent().mInputAttributes); settings.loadSettings(displayContext, settings.getCurrent().mLocale, settings.getCurrent().mInputAttributes);
mLatinIME.setInputView(onCreateInputView(displayContext, mIsHardwareAcceleratedDrawingEnabled)); if (mKeyboardView != null)
mLatinIME.setInputView(onCreateInputView(displayContext, mIsHardwareAcceleratedDrawingEnabled));
} }
} }
@ -102,6 +103,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
final KeyboardTheme keyboardTheme) { final KeyboardTheme keyboardTheme) {
final boolean nightModeChanged = (mCurrentUiMode & Configuration.UI_MODE_NIGHT_MASK) final boolean nightModeChanged = (mCurrentUiMode & Configuration.UI_MODE_NIGHT_MASK)
!= (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK); != (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK);
Log.d(TAG, "old ui mode "+ mCurrentUiMode+", new ui mode "+context.getResources().getConfiguration().uiMode);
if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme) || nightModeChanged if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme) || nightModeChanged
|| !mThemeContext.getResources().equals(context.getResources()) || !mThemeContext.getResources().equals(context.getResources())
|| Settings.getInstance().getCurrent().mColors.haveColorsChanged(context)) { || Settings.getInstance().getCurrent().mColors.haveColorsChanged(context)) {

View file

@ -815,7 +815,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
@Override @Override
public void onInitializeInterface() { public void onInitializeInterface() {
mDisplayContext = getDisplayContext(); mDisplayContext = getDisplayContext();
Log.d(TAG, "onInitializeInterface -> possibly configuration changed"); Log.d(TAG, "onInitializeInterface");
mKeyboardSwitcher.updateKeyboardTheme(mDisplayContext); mKeyboardSwitcher.updateKeyboardTheme(mDisplayContext);
} }