mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-16 23:12:47 +00:00
call readAttributes in the right builders directly
This commit is contained in:
parent
0d83ea4112
commit
89f8c44cfc
3 changed files with 13 additions and 15 deletions
|
@ -266,7 +266,8 @@ public final class MoreKeysKeyboard extends Keyboard {
|
||||||
final boolean isSingleMoreKeyWithPreview, final int keyPreviewVisibleWidth,
|
final boolean isSingleMoreKeyWithPreview, final int keyPreviewVisibleWidth,
|
||||||
final int keyPreviewVisibleHeight, final Paint paintToMeasure) {
|
final int keyPreviewVisibleHeight, final Paint paintToMeasure) {
|
||||||
super(context, new MoreKeysKeyboardParams());
|
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.
|
// TODO: More keys keyboard's vertical gap is currently calculated heuristically.
|
||||||
// Should revise the algorithm.
|
// Should revise the algorithm.
|
||||||
|
|
|
@ -67,16 +67,19 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
return this
|
return this
|
||||||
|
|
||||||
// todo: further plan
|
// 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)
|
// next release, and possibly don't continue working here for a while (should allow finding more regressions)
|
||||||
// remove the old parser
|
// remove the old parser
|
||||||
// then finally the spanish/german/swiss/nordic layouts can be removed and replaced by some hasExtraKeys parameter
|
// 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
|
// 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...
|
// 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)
|
// 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?)
|
// 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
|
// 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
|
// write up how things work for users, also regarding language more keys
|
||||||
|
@ -137,13 +140,6 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
|
|
||||||
fun loadFromXml(xmlId: Int, id: KeyboardId): KeyboardBuilder<KP> {
|
fun loadFromXml(xmlId: Int, id: KeyboardId): KeyboardBuilder<KP> {
|
||||||
if (Settings.getInstance().current.mUseNewKeyboardParsing) {
|
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) {
|
if (id.mElementId >= KeyboardId.ELEMENT_EMOJI_RECENTS && id.mElementId <= KeyboardId.ELEMENT_EMOJI_CATEGORY16) {
|
||||||
mParams.mId = id
|
mParams.mId = id
|
||||||
readAttributes(R.xml.kbd_emoji_category1) // all the same anyway, gridRows are ignored
|
readAttributes(R.xml.kbd_emoji_category1) // all the same anyway, gridRows are ignored
|
||||||
|
@ -176,8 +172,8 @@ open class KeyboardBuilder<KP : KeyboardParams>(protected val mContext: Context,
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: remnant of old parser, replace it
|
// todo: remnant of old parser, replace it if reasonably simple
|
||||||
private fun readAttributes(@XmlRes xmlId: Int) {
|
protected fun readAttributes(@XmlRes xmlId: Int) {
|
||||||
val parser = mResources.getXml(xmlId)
|
val parser = mResources.getXml(xmlId)
|
||||||
while (parser.eventType != XmlPullParser.END_DOCUMENT) {
|
while (parser.eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
val event = parser.next()
|
val event = parser.next()
|
||||||
|
|
|
@ -181,7 +181,8 @@ public final class MoreSuggestions extends Keyboard {
|
||||||
final int maxWidth, final int minWidth, final int maxRow,
|
final int maxWidth, final int minWidth, final int maxRow,
|
||||||
final Keyboard parentKeyboard) {
|
final Keyboard parentKeyboard) {
|
||||||
final int xmlId = R.xml.kbd_suggestions_pane_template;
|
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;
|
mParams.mVerticalGap = mParams.mTopPadding = parentKeyboard.mVerticalGap / 2;
|
||||||
mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight);
|
mPaneView.updateKeyboardGeometry(mParams.mDefaultRowHeight);
|
||||||
final int count = mParams.layout(suggestedWords, fromIndex, maxWidth, minWidth, maxRow,
|
final int count = mParams.layout(suggestedWords, fromIndex, maxWidth, minWidth, maxRow,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue