Gaia/System/Keyboard/Layout: Difference between revisions

no edit summary
No edit summary
Line 1: Line 1:
Hello! The goal of this document is to allow people to add keyboard layout of their own language/script on the '''v1 Gaia Keyboard app'''.
Hello! The goal of this document is to allow people to add keyboard layout of their own language/script on the '''v1.2 Gaia Keyboard app'''.


== Status of the Gaia Keyboard app & system architecture ==
== Status of the Gaia Keyboard app & system architecture ==


=== Current version ===
As of Oct 2013, two major features have been recently implemented in Firefox OS.


As of mid-2013, the built-in Gaia keyboard app is the only keyboard app available in Firefox OS. That means, if you would like to add your own keyboard layout, you would have to modify the app itself and push it to your unlocked developer phone.
* A build flag exist to turn on/off keyboard/spellcheck dictionary to include in the build, in the default Gaia Keyboard app (see {{Bug|884752}}).
* An OS-level feature that allow users to install 3rd-party keyboard apps from marketplace. See {{Bug|816869}}.


=== Next version ===
To come up with a new keyboard layout, you could either put a layout file in Gaia, build the keyboard app with a build config, or come up with your own keyboard app and install it to the phone.


We plan to introduce plug-able keyboard/IME architecture directly into the OS in the next version. For details, see [https://bugzilla.mozilla.org/show_bug.cgi?id=816869 bug 816869]. When the feature is released, the users should be able to buy or install their own keyboard app, and use the layouts of those 3rd-party keyboard apps in conjunction with the built-in ones.
== How-tos: make a keyboard app ==


== How-tos ==
You might want to use the built-in keyboard as a template, or fork it. The basic ideas are


The section below assumes that you know how to flash your own Gaia on the phone (i.e., <code>make install-gaia</code>), or update the <code>application.zip</code> of keyboard app for Firefox OS Simulator.
* In the manifest, declare yourself as a keyboard in the <code>role</code> property.
* Make sure you have the <code>keyboard</code> permission.


=== Add a simple layout in the Gaia keyboard app ===
After that, after installation and activation, your keyboard will show up on the bottom half of the screen whenever the user is focused to a input field.


A simple layout refers to, e.g., Qwerty layout for English, where the app simply outputs what the user taps directly (as opposed to having the keys handles in Asian IMEs).
* Use the old, classic <code>window.resize</code> to update the area of your app should occupy.
* Use the new, shiny <code>navigator.mozInputMethod</code> API to mutate the content of the input given, see [[WebAPI/KeboardIME|API page]] for detail.


# Modify [https://github.com/mozilla-b2g/gaia/blob/master/apps/keyboard/js/layout.js layout.js] to add your own layout here. You should be able to figure out the syntax by looking at the definition of other layouts.
(some sample code and/or a small template app will help here)
# Reference your keyboard layout by hard-coding its name [https://github.com/mozilla-b2g/gaia/blob/master/apps/keyboard/js/keyboard.js#L490 here] in the <code>enabledKeyboardNames</code> array. That will enable your layout no matter what you'd choose in the Settings app.


Obviously you would have to do something else in order to make your keyboard layout show up as a setting entry and to make it toggle-able, but this document describes the minimum.
== How-tos: add your layout to your in the Gaia keyboard app ==


=== Add a layout what works with an Asian IME ===
See [https://github.com/mozilla-b2g/gaia/blob/master/apps/keyboard/CONFIGURE apps/keyboard/CONFIGURE] for detail. Depend on the language, you might want to add a dictionary, or include an interactive IME (for Asian languages).
 
=== Spell check / word suggestion dictionary ===
 
(TBA)
 
=== Asian IME ===


==== Introduction ====
==== Introduction ====
Confirmed users
478

edits