mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-20 22:29:10 +00:00
reload theme on orientation change
should actually happen anyway, but possibly not for newer android versions? could help with #401
This commit is contained in:
parent
08f194a369
commit
4a9dc6bff6
1 changed files with 6 additions and 3 deletions
|
@ -71,6 +71,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
private KeyboardTheme mKeyboardTheme;
|
private KeyboardTheme mKeyboardTheme;
|
||||||
private Context mThemeContext;
|
private Context mThemeContext;
|
||||||
private int mCurrentUiMode;
|
private int mCurrentUiMode;
|
||||||
|
private int mCurrentOrientation;
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak") // this is a keyboard, we want to keep it alive in background
|
@SuppressLint("StaticFieldLeak") // this is a keyboard, we want to keep it alive in background
|
||||||
private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
|
private static final KeyboardSwitcher sInstance = new KeyboardSwitcher();
|
||||||
|
@ -111,14 +112,16 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
|
||||||
|
|
||||||
private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
|
private boolean updateKeyboardThemeAndContextThemeWrapper(final Context context,
|
||||||
final KeyboardTheme keyboardTheme) {
|
final KeyboardTheme keyboardTheme) {
|
||||||
final boolean nightModeChanged = (mCurrentUiMode & Configuration.UI_MODE_NIGHT_MASK)
|
if (mThemeContext == null
|
||||||
!= (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK);
|
|| !keyboardTheme.equals(mKeyboardTheme)
|
||||||
if (mThemeContext == null || !keyboardTheme.equals(mKeyboardTheme) || nightModeChanged
|
|| mCurrentOrientation != context.getResources().getConfiguration().orientation
|
||||||
|
|| (mCurrentUiMode & Configuration.UI_MODE_NIGHT_MASK) != (context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||||
|| !mThemeContext.getResources().equals(context.getResources())
|
|| !mThemeContext.getResources().equals(context.getResources())
|
||||||
|| Settings.getInstance().getCurrent().mColors.haveColorsChanged(context)) {
|
|| Settings.getInstance().getCurrent().mColors.haveColorsChanged(context)) {
|
||||||
mKeyboardTheme = keyboardTheme;
|
mKeyboardTheme = keyboardTheme;
|
||||||
mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
|
mThemeContext = new ContextThemeWrapper(context, keyboardTheme.mStyleId);
|
||||||
mCurrentUiMode = context.getResources().getConfiguration().uiMode;
|
mCurrentUiMode = context.getResources().getConfiguration().uiMode;
|
||||||
|
mCurrentOrientation = context.getResources().getConfiguration().orientation;
|
||||||
KeyboardLayoutSet.onKeyboardThemeChanged();
|
KeyboardLayoutSet.onKeyboardThemeChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue