diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MoreKeysKeyboard.java b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MoreKeysKeyboard.java index a6b9ecb41..d600e3c14 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MoreKeysKeyboard.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/MoreKeysKeyboard.java @@ -266,7 +266,8 @@ public final class MoreKeysKeyboard extends Keyboard { final boolean isSingleMoreKeyWithPreview, final int keyPreviewVisibleWidth, final int keyPreviewVisibleHeight, final Paint paintToMeasure) { super(context, new MoreKeysKeyboardParams()); - loadFromXml(keyboard.mMoreKeysTemplate, keyboard.mId); + mParams.mId = keyboard.mId; + readAttributes(keyboard.mMoreKeysTemplate); // TODO: More keys keyboard's vertical gap is currently calculated heuristically. // Should revise the algorithm. diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt index 1a307305d..f1924c545 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt +++ b/app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardBuilder.kt @@ -67,16 +67,19 @@ open class KeyboardBuilder(protected val mContext: Context, return this // todo: further plan - // some keyboard_layout_set have supportedScript that is enum synced with script id in ScriptUtils - // that's one more reason for using language tags... - // currently it's still read from xml outside the keyboard parser, but should still go to some other place - // maybe use scriptUtils to determine, just make sure it's correct (also for hindi and serbian!) // next release, and possibly don't continue working here for a while (should allow finding more regressions) // remove the old parser // then finally the spanish/german/swiss/nordic layouts can be removed and replaced by some hasExtraKeys parameter // also the eo check could then be removed // and maybe the language -> layout thing could be moved to assets? and maybe even here the extra keys could be defined... // should be either both in method.xml, or both in assets (actually method might be more suitable) + // go through a lot of todos in parsers, key, keyboardlayoutset, ... as a lot of things should only change after old parser is removed + // also remove the keybpard_layout_set files? + // they are still in use e.g. for enableProximityCharsCorrection and supportedScript + // but ideally this should be replaced + // enableProximityCharsCorrection should be in LayoutInfos + // supportedScript could be determined using ScriptUtils, but first make sure that there is less latin fallback happening + // or use locale to store script, but that's only possible starting at api 21 // allow users to define their own layouts (maybe do everything else first?) // need to solve the scaling issue with number row and 5 row keyboards // write up how things work for users, also regarding language more keys @@ -137,13 +140,6 @@ open class KeyboardBuilder(protected val mContext: Context, fun loadFromXml(xmlId: Int, id: KeyboardId): KeyboardBuilder { if (Settings.getInstance().current.mUseNewKeyboardParsing) { - if (this::class != KeyboardBuilder::class) { - // for MoreSuggestions and MoreKeys we only need to read the attributes - // but not the default ones, do it like the old parser (for now) - mParams.mId = id - readAttributes(xmlId) - return this - } if (id.mElementId >= KeyboardId.ELEMENT_EMOJI_RECENTS && id.mElementId <= KeyboardId.ELEMENT_EMOJI_CATEGORY16) { mParams.mId = id readAttributes(R.xml.kbd_emoji_category1) // all the same anyway, gridRows are ignored @@ -176,8 +172,8 @@ open class KeyboardBuilder(protected val mContext: Context, return this } - // todo: remnant of old parser, replace it - private fun readAttributes(@XmlRes xmlId: Int) { + // todo: remnant of old parser, replace it if reasonably simple + protected fun readAttributes(@XmlRes xmlId: Int) { val parser = mResources.getXml(xmlId) while (parser.eventType != XmlPullParser.END_DOCUMENT) { val event = parser.next() diff --git a/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/MoreSuggestions.java b/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/MoreSuggestions.java index 1117a4a8c..ea000971f 100644 --- a/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/MoreSuggestions.java +++ b/app/src/main/java/org/dslul/openboard/inputmethod/latin/suggestions/MoreSuggestions.java @@ -181,7 +181,8 @@ public final class MoreSuggestions extends Keyboard { final int maxWidth, final int minWidth, final int maxRow, final Keyboard parentKeyboard) { final int xmlId = R.xml.kbd_suggestions_pane_template; - loadFromXml(xmlId, parentKeyboard.mId); + mParams.mId = parentKeyboard.mId; + readAttributes(xmlId); mParams.mVerticalGap = mParams.mTopPadding = parentKeyboard.mVerticalGap / 2; mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight); final int count = mParams.layout(suggestedWords, fromIndex, maxWidth, minWidth, maxRow,