mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2024-11-25 00:33:24 +01:00
Update guidelines about adding layouts
to reflect the recent changes. Also, change `gen_layouts.py` to not generate warnings for file that are known not to be layouts.
This commit is contained in:
parent
15c608b8cd
commit
de6c3b024d
@ -77,16 +77,22 @@ make installd
|
||||
|
||||
### Adding a layout
|
||||
|
||||
Layouts are defined in XML, see `res/xml/qwerty.xml`.
|
||||
Layouts are defined in XML, see `res/xml/latn_qwerty_us.xml`.
|
||||
An online tool for editing layout files written by @Lixquid is available
|
||||
[here](https://unexpected-keyboard-layout-editor.lixquid.com/).
|
||||
|
||||
An entry must be added to the layout option in `res/values/arrays.xml`, to both
|
||||
`pref_layout_values` (correspond to the file name) and `pref_layout_entries`
|
||||
(display name).
|
||||
Makes sure to specify the `name` attribute like in `latn_qwerty_us.xml`,
|
||||
otherwise the layout won't be added to the app.
|
||||
|
||||
The layout must also be referenced in `srcs/juloo.keyboard2/Config.java` in
|
||||
`layout_of_string`.
|
||||
The layout file must be placed in the `res/xml/` directory and named according to:
|
||||
- script (`latn` for latin, etc..)
|
||||
- layout name (eg. the name of a standard)
|
||||
- country code (or language code if more adequate)
|
||||
|
||||
Then, run `make gen_layouts` to add the layout to the app.
|
||||
|
||||
The last step will update the file `res/values/layouts.xml`, that you should
|
||||
not edit directly.
|
||||
|
||||
Run `make check_layouts` to check some properties about your layout. This will
|
||||
change the file `check_layout.output`, which you should commit.
|
||||
|
@ -11,6 +11,11 @@ import xml.etree.ElementTree as XML
|
||||
# are sorted alphabetically.
|
||||
FIRST_LAYOUTS = [ "latn_qwerty_us", "latn_colemak", "latn_dvorak" ]
|
||||
|
||||
# File names that are known not to be layouts. Avoid warning about them.
|
||||
KNOWN_NOT_LAYOUT = set([
|
||||
"number_row", "numpad", "pin", "bottom_row", "settings", "method",
|
||||
"greekmath", "numeric" ])
|
||||
|
||||
# Read a layout from a file. Returns [None] if [fname] is not a layout.
|
||||
def read_layout(fname):
|
||||
root = XML.parse(fname).getroot()
|
||||
@ -23,7 +28,9 @@ def read_layouts(files):
|
||||
for layout_file in files:
|
||||
layout_id, _ = os.path.splitext(os.path.basename(layout_file))
|
||||
layout = read_layout(layout_file)
|
||||
if layout == None:
|
||||
if layout_id in KNOWN_NOT_LAYOUT:
|
||||
continue
|
||||
elif layout == None:
|
||||
print("Not a layout file: %s" % layout_file)
|
||||
elif layout["name"] == None:
|
||||
print("Layout doesn't have a name: %s" % layout_id)
|
||||
|
Loading…
Reference in New Issue
Block a user