Android Input Method Framework

Source: Internet
Author: User

 

The android Input Method Framework has a complex price comparison. From the process perspective, the related functions are mainly distributed in the following three locations:

A client application is an application that contains a graphical interface, such as an address book. The graphic interface contains an editing box that can receive input, such as textview.
The input method module provides a soft keyboard to convert users' key input on the soft keyboard into words based on a certain algorithm (such as Zi, T9, Guo pen, and so on), and then deliver the words to the client application. The directory development/samples/softkeyboard provides an instance of the input method module. If you want to implement a Chinese Input Method, refer to this example.
The platform provides some management functions to load an input method module, start the module, and terminate the module.
The relevant code is mainly located in the following locations. The code in the, and directories is the most noteworthy.
1. Frameworks/base/CORE/Java/COM/Android/Internal/View
This directory defines several important IDL interfaces.
Iinputmethod. aidl defines the iinputmethod IDL Interface, which is used to operate the inputmethod interface across processes on the client.
Iinputmethodsession. aidl defines the iinputmethodsession interface, which is a secondary interface of iinputmethod. This interface is used to operate inputmethodsession across processes on the client.

Iinputmethodcallback. aidl defines a helper interface, which is implemented by the client. The iinputmethod. aidl and iinputmethodsession. aidl instances can call different methods in this interface respectively.

Iinputmethodmanager. aidl defines the service interface of the Input Method Manager. The client calls this service through inputmethodmanager interface.
Inputmethodmanagerservic

E. Java implements the iinputmethodmanager. aidl Interface

Iinputmethodclient. aidl defines the interface to identify the customer of an Input Method Manager. This service is implemented on the client and provided to the server for calling.

Iinputcontext. aidl defines an interface, which is used by the inputmethod provided by the client. Inputmethod can interact with the client and call the callback provided by the client.
Iinputconnectionwrapper. Java implements the iinputcontext interface.
Iinputcontextcallback. aidl defines an interface, defines a set of callback functions to call the iinputcontext. aidl instance, and returns information to inputmethod from the client.
Inputconnectionwrapper. Java implements the iinputcontextcallback interface.

2. Frameworks/base/services/Java/COM/Android/Server
Inputmethodmanagerservice. Java implements the iinputmethodmanager. aidl Interface
3. Frameworks/base/CORE/Java/Android/View/inputmethod
This directory defines several important interfaces and classes.
Inputmethodmanager. Java implements the inputmethodmanager class. This class calls the iinputmethodmanager. aidl interface function, while the iinputmethodmanager. aidl interface function is implemented by inputmethodmanagerservice. Java and runs in a server process different from the client process.
Inputconnection. Java defines the inputconnection interface. The inputconnection interface establishes a connection between the input method and the client. The input method can be used to obtain or send information to the client. The inputconnection instance is created by the client and passed to the input method. Baseinputconnection. Java implements a base class of the inputconnection interface: baseinputconnection. Editableinputconnection. Java implements a derived class

Inputbinding. Java defines the class inputbinding, which implements the parcelable interface. The member variables of this class contain information that the client transmits to the server.

Inputmethod. Java defines the inputmethod interface. The inputmethodservice. Java class inputmethodimpl implements this interface. This interface defines a set of methods for manipulating an input method. Such as createsession and startinput. To write a specific input method, you need to derive this interface.
Inputmethodsession. Java defines the inputmethodsession interface. The inputmethodservice. Java class inputmethodsessionimpl implements this interface. Inputmethodsession is a secondary interface of inputmethod. It is used to interact with an input method client.
Completioninfo. Java class describes a text completion.
The editorinfo. Java class describes the attributes of a view that receives input, such as text, digit, and etc ).
The extractedtext. Java class describes the text attributes that are extracted from the view and passed to the input method.
4. Frameworks/base/CORE/Java/COM/Android/Internal/widget
Editableinputconnection. Java implements a derived class of baseinputconnection.
5. Frameworks/base/CORE/Java/Android/inputmethodservice
The code in this directory provides a framework class for implementing a specific input method. A custom input method can be derived from these classes.
The softinputwindow class in softinputwindow. Java is a dialog subclass. It represents the top-level window of an input method (managed by the window manager). The top-down window includes extractarea, candidatesarea, and inputarea.
Keyboard. the keyboard class in Java loads and parses an XML file (such as development/samples/softkeyboard/RES/XML) that describes the soft keyboard and stores the properties of the keyboard, for example, the virtual keyboard contains multiple upstream keys and keys on each line.
The keyboardview class in keyboardview. Java is a view subclass. It draws a virtual keyboard on the Screen Based on the keyboard data structure. This virtual keyboard is the inputarea in softinputwindow.

Abstractinputmethodservice is a derived class of service and implements the keyevent. Callback interface. The base classes of inputmethod and inputmethodsession are implemented. The dispatchkeyevent function transmits the received key event to the corresponding key processing function (implemented in the derived class ). When the service is bound to the client, its onbind () function returns an iinputmethodwrapper instance to the client, which implements the iinputmethod IDL Interface. The client can use the functions of this interface.
Iinputmethodwrapper. Java implements the iinputmethod IDL Interface. After receiving a cross-process command from the client, this class calls inputmethod to complete the corresponding function.
Iinputmethodsessionwrapper. Java implements the iinputmethodsession IDL Interface. After receiving a cross-process command from the client, this class calls inputmethodsession to complete the corresponding function.
6. Frameworks/base/CORE/RES/Layout
Some system resources are stored in this directory. Where,
Input_method.xml describes the layout of an input window (that is, softinputwindow). The la s include extractarea, candidatesarea, and inputarea.
Input_method_extract_view.xml.

7. Development/samples/softkeyboard
The Code under this directory implements an Input Method Instance-soft keyboard English/Digital Input Method. The classes implemented here are mostly derived from the classes in frameworks/base/CORE/Java/Android/inputmethodservice.
Androidmanifest. xml: the service provided by the .apk and some information about the input method.
The res/XML/directory stores several XML files describing different virtual keyboards.
The latinkeyboard class in latinkeyboard. Java is a subclass of the keyboard.
The latinkeyboardview class in latinkeyboardview. Java is a subclass of keyboardview.
8. Frameworks/base/CORE/Java/Android/widget
Textview. Java is the client that uses the Input Method Framework (IMF. Textview creates an inputmethodmanager instance and calls its restartinput function.
The inputmethodmanager: restartinput function creates an inputconnection instance and calls iinputmethodmanager: startinput.
The iinputmethodmanager: startinput function uses mcontext. bindservice to start an inputmethod service, such as sample soft keyboard.
9. Frameworks/base/CORE/Java/COM/Android/Internal/widget

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.