- Use the text provider from the OS to handle the texts within the apps from the keyboard.
- TextDocumentProxy on iOS.
- InputMethodService on Android.
- Loading must be fast (ressources might not be reused each time the keyboard appears).
- Always dispose objects you don't need at runtime.
- Consider extendable predictions system.
- Allows a developer to add many systems.
- Allows to enable/disable a predictions system on the fly.
- Consider running the predictions computation in threads (or thread pool).
- Use cancellable threads to stop predictions computation on new input.
- Always wait (joining threads) for all predictions threads to finish before showing the results to the user.
- SQLite dictionaries to store words are fine.
- 20k words per language is enough on mobile.
- If needed, load words for only one language at at time.
- At startup, show the keyboard even if the predictions systems are still loading. The user will type and predictions will show up when ready.
- For a good user experience, predictions should not take more than 200 ms to compute.
- On mobile/tablet, proposing 5 predictions is enough.
- Consider multiple layouts (qwertz/azerty/...).
- Consider theming.
- Build your layout by code and not use a resource file to define it. It will often be lighter in memory and it is espcially recommended to do so in iOS.
- Consider supporting multiple screen orientations (landscape/portrait) and sizes.
- Use relative sizes if possible.
- Memory usage for keyboard extensions is usually limited to around 30 Mb in memory. The system will trigger a warning when the extension reaches this limit. This threshold is not fixed and depends on what the system can provide.
- Each time the keyboard appears and dissappears, all the ressources are loaded and disposed.
WARNING: This section is a work in progress!
- Main thread (UI) launches.
- Load preferences.
- Load and show interface.
- Launch second thread.
- Load dictionary.
- Load predictions systems.
- Set keyboard as ready.
- User types an input.
- A timer waits 200 ms and is reseted each time a key is pressed.
- When the 200 ms have elapsed, pass the input to the predictions systems.
- Run the predictions.
- Cancel the running predictions if necessary.
- Run the predictions in threads with the last input.
- Join the prediction threads (wait them to finish).
- Return all results.
- Sort the predictions by
- Occurencies.
- Frequency.
- ...
- Show the predictions.
- User selects a prediction.
- Increment its frequency in the dictionary.
- Replace the current word by the selected prediction.
- The users quit the application (close the keyboard).
- Normalize the frequency of the words in the dictionary.
- Free all ressources.
- Exit.