chore(developer): Merge branch 'master' into test/developer/kmcmplib-compiler-unit-tests-5

This commit is contained in:
Dr Mark C. Sinclair 2024-11-26 03:19:16 +00:00
commit 6dbd9cfab4
1073 changed files with 138241 additions and 612 deletions

View file

@ -116,7 +116,7 @@ jobs:
strategy:
fail-fast: true
matrix:
dist: [focal, jammy, noble]
dist: [focal, jammy, noble, oracular]
steps:
- name: Checkout
@ -142,7 +142,7 @@ jobs:
strategy:
fail-fast: true
matrix:
dist: [oracular]
dist: [plucky]
steps:
- name: Checkout

View file

@ -1,5 +1,75 @@
# Keyman Version History
## 18.0.144 alpha 2024-11-25
* chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 in /developer/src/server/src/win32/trayicon/addon-src (#12687)
* chore(developer): make package subfile description fully optional (#12665)
* fix(developer): box package compiler info fields (#12666)
* fix(developer): correct whitespace handling in virtual keys and remove partially implemented virtual key series in kmcmplib compiler (#12604)
## 18.0.143 alpha 2024-11-22
* chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 (#12685)
## 18.0.142 alpha 2024-11-20
* chore(common): Update CODEOWNERS (#12680)
## 18.0.141 alpha 2024-11-15
* chore(linux): add support for Ubuntu 25.04 Plucky Puffin (#12675)
## 18.0.140 alpha 2024-11-13
* chore(common): Add 17.0.330 - 17.0.332 to version history (#12663)
* fix(developer): reconnect `--full-test` in kmcmplib build and enable for CI (#12631)
* docs(developer): kmc-generate (#12647)
## 18.0.139 alpha 2024-11-12
* fix(windows): help links updated (#12646)
## 18.0.138 alpha 2024-11-08
* fix(common): check for invalid markers (#12613)
* chore: update minimum versions (#12632)
* fix(windows): correct path to output file in publish step for fv keyboards (#12637)
* chore(core): move API docs from help.keyman.com (#12642)
* feat(developer): kmc generate (#11014)
* feat(developer): kmc-copy (#12555)
* feat(developer): add GitHub and Cloud support to kmc-copy (#12586)
## 18.0.137 alpha 2024-11-07
* fix(windows): correct engine help source path for upload (#12625)
* fix(developer): use 'N' for nomatch store debug strings (regression in #12107) (#12629)
* chore(developer): skip masaram_gondi in kmcmplib full test (#12630)
* feat(developer): analyze osk-char-use merge with existing mapping file (#12622)
* feat(developer): Report key 'address' in validation failures in layout compiler (#12588)
## 18.0.136 alpha 2024-11-06
* fix(developer): handle merge commits when checking git log date (#12627)
## 18.0.135 alpha 2024-11-05
* fix(developer): handle paste of TSV into Wordlist grid (#12594)
* fix(developer): handle missing files in kmc-kmn (#12595)
* fix(developer): handle missing files in kmc-model (#12596)
* refactor(android): move Android Engine help in-repo (#12598)
* refactor(ios): move ios Engine help in-repo (#12599)
* refactor(windows): move windows Engine help in-repo (#12600)
* refactor(web): move web engine help to app repo (#12601)
* docs: Update websites readme with debug info (#12602)
* fix(developer): create Server config directory before options save (#12608)
* chore(linux): add support for Ubuntu 25.04 Plucky Puffin (#12614)
* fix(linux): properly check for missing dependencies (#12615)
* fix(linux): set environment variable for rendering of downloads dialog (#12616)
## 18.0.134 alpha 2024-11-04
* (#12606)
## 18.0.133 alpha 2024-11-01
* test(developer): kmcmplib compiler unit tests 4 (#12489)
@ -917,6 +987,27 @@
* chore(common): move to 18.0 alpha (#10713)
* chore: move to 18.0 alpha
## 17.0.332 stable 2024-11-06
* fix(developer): create Server config directory before options save (#12609)
* fix(developer): handle merge commits when checking git log date (#12628)
* fix(linux): set environment variable for rendering of downloads dialog (#12617)
## 17.0.331 stable 2024-10-30
* fix(android): Hide suggestion banner on password fields (#12466)
* fix(common): declare dep on @keymanapp/ldml-keyboard-constants (#12475)
* fix(oem/fv): Update keyboard versions and names for fv_all.kmp (#12504)
* chore(ios): renew certificate (#12513)
* fix(developer): prevent invalid string ids (#12524)
* fix(developer): ignore excess whitespace in `<row keys>` attribute (#12523)
## 17.0.330 stable 2024-09-16
* refactor(android): Move Sentry and APK to publish task (#12392)
* fix(developer): rewrite ldml visual keyboard compiler (#12406)
* fix(developer): check vars string usage before definition (#12407)
## 17.0.329 stable 2024-09-09
* chore(android,ios): Add ojibwa ifinal/rdot keyboards to FirstVoices (#12020)

View file

@ -1 +1 @@
18.0.134
18.0.145

View file

@ -27,8 +27,8 @@ yes | ~/Library/Android/sdk/tools/bin/sdkmanager --licenses
### Crash Reporting
Keyman for Android uses [Sentry](https://sentry.io) for crash reporting. The
analytics for Debug are associated with an App Bundle ID
Keyman for Android uses [Sentry](https://sentry.io) for crash reporting. The
analytics for Debug are associated with an App Bundle ID
`com.tavultesoft.kmapro.debug`.
### Compiling From Command Line
@ -79,7 +79,7 @@ analytics for Debug are associated with an App Bundle ID
Replace `SERIAL` with the device serial number listed in step 2.
### Compiling the app's offline help
Keyman for Android help is maintained in the Markdown files in android/help/.
Keyman for Android help is maintained in the Markdown files in android/docs/.
The script `/resources/build/build-help.inc.sh` uses the `pandoc` tool to convert the Markdown files into html.
```bash

View file

@ -45,6 +45,12 @@ if builder_start_action clean; then
fi
builder_run_child_actions configure build test
builder_run_action test:help check-markdown "$KEYMAN_ROOT/android/docs/help"
function do_test_help() {
check-markdown "$KEYMAN_ROOT/android/docs/help"
check-markdown "$KEYMAN_ROOT/android/docs/engine"
}
builder_run_action test:help do_test_help
builder_run_child_actions publish

View file

@ -0,0 +1,30 @@
---
title: KMKeyboard class
---
## Summary
The **`KMKeyboard`** class provides Keyman's methods for extending an Android WebView
## Syntax
```java
KMKeyboard.methodName()
```
## Description
The KMKeyboard is the core class which provides most of the methods you will need to develop an in-app or system keyboard with Keyman Engine
<!-- Fill in examples of how to use, etc. -->
## Methods
`getShouldShowHelpBubble()`
: get the stored preference whether to show the help bubble on the globe key
`setShouldShowHelpBubble()`
: sets the stored preference whether to show the help bubble on the globe key
`initKMKeyboard()`
: initialize the KMKeyboard WebView

View file

@ -0,0 +1,108 @@
---
title: KMManager.addKeyboard()
---
## Summary
The **`addKeyboard()`** method adds a keyboard into the keyboards list.
## Syntax
``` javascript
KMManager.addKeyboard(Context context, Keyboard keyboardInfo)
```
### Parameters
`context`
: The context.
`keyboardInfo`
: A `Keyboard` type of keyboard information.
### Returns
Returns `true` if the keyboard was added successfully, `false`
otherwise.
## Description
Use this method to include a keyboard in the keyboards list so that it
can be selected from the keyboards menu. If the keyboard with same
keyboard ID and language ID exists, it updates the existing keyboard
info.
------------------------------------------------------------------------
## Syntax (Deprecated)
``` javascript
KMManager.addKeyboard(Context context, HashMap<String, String> keyboardInfo)
```
### Parameters
`context`
: The context.
`keyboardInfo`
: A dictionary of keyboard information with keys and values defined as
`HashMap<String key, String value>`.
### Returns
Returns `true` if the keyboard was added successfully, `false`
otherwise.
## Description
Use this method to include a keyboard in the keyboards list so that it
can be selected from the keyboards menu. If the keyboard with same
keyboard ID and language ID exists, it updates the existing keyboard
info.
------------------------------------------------------------------------
## Examples
### Example: Using `addKeyboard()`
The following script illustrate the use of `addKeyboard()`:
``` javascript
// Add a custom keyboard
Keyboard kbInfo = new Keyboard(
"basic_kbdtam99", // Package ID - filename of the .kmp file
"basic_kbdtam99", // Keyboard ID - filename of the .js file
"Tamil 99 Basic", // Keyboard Name
"ta", // Language ID
"Tamil", // Language Name
"1.0", // Keyboard Version
null, // URL to help documentation if available
null, // URL to latest .kmp file
true, // Boolean to show this is a new keyboard in the keyboard picker
// Font information of the .ttf font to use in KMSample2 (for example "aava1.ttf").
// basic_kbdtam99 doesn't include a font. Can set blank "" or KMManager.KMDefault_KeyboardFont
// KMEA will use the font for the OSK, but the Android device determines the system font used for keyboard output
KMManager.KMDefault_KeyboardFont, // Font for KMSample2
KMManager.KMDefault_KeyboardFont); // Font for OSK
KMManager.addKeyboard(this, kbInfo);
```
## History
Added syntax using Keyboard type parameter in Keyman Engine for Android
14.0.
Deprecated syntax using the HashMap&lt;String key, String value&gt;
parameter in Keyman Engine for Android 14.0
## See also
- [`removeKeyboard()`](removeKeyboard)

View file

@ -0,0 +1,46 @@
---
title: KMManager.addKeyboardDownloadEventListener()
---
## Summary
The **`addKeyboardDownloadEventListener()`** method adds the specified
listener into the list of keyboard download event listeners.
## Syntax
``` javascript
KMManager.addKeyboardDownloadEventListener(OnKeyboardDownloadEventListener listener)
```
### Parameters
`listener`
: The listener to receive keyboard download event notifications.
## Description
Use this method to add a listener to receive keyboard download event
notifications. The listener must implement
`KMManager.OnKeyboardDownloadEventListener` interface.
## Examples
### Example: Using `addKeyboardDownloadEventListener()`
The following script illustrate the use of
`addKeyboardDownloadEventListener()`:
``` javascript
@Override
protected void onResume() {
super.onResume();
// ...
KMManager.addKeyboardDownloadEventListener(this);
// ...
}
```
## See also
- [`removeKeyboardDownloadEventListener()`](removeKeyboardDownloadEventListener)

View file

@ -0,0 +1,45 @@
---
title: KMManager.addKeyboardEventListener()
---
## Summary
The **`addKeyboardEventListener()`** method adds the specified listener
into the list of keyboard event listeners.
## Syntax
``` javascript
KMManager.addKeyboardEventListener(OnKeyboardEventListener listener)
```
### Parameters
`listener`
: The listener to receive keyboard event notifications.
## Description
Use this method to add a listener to receive keyboard event
notifications. The listener must implement
KMManager.OnKeyboardEventListener interface.
## Examples
### Example: Using `addKeyboardEventListener()`
The following script illustrate the use of `addKeyboardEventListener()`:
``` javascript
@Override
protected void onResume() {
super.onResume();
// ...
KMManager.addKeyboardEventListener(this);
// ...
}
```
## See also
- [`removeKeyboardEventListener()`](removeKeyboardEventListener)

View file

@ -0,0 +1,49 @@
---
title: KMManager.addLexicalModel()
---
## Summary
The **addLexicalModel()** method adds a lexical model into the lexical models list.
## Syntax
```javascript
KMManager.addLexicalModel(Context context, HashMap<String, String> lexicalModelInfo)
```
### Parameters
`context`
: The context.
`lexicalModelInfo`
: A dictionary of lexical model information with keys and values defined as `HashMap<String key, String value)`.
### Returns
Returns `true` if the lexical model was added successfully, `false` otherwise.
## Description
Use this method to include a lexical model in the lexical models list. If the lexical model with the same
package ID, language ID, and lexical model ID exists, it updates the existing lexical model info.
After a lexical model has been added, call [registerLexicalModel()](registerLexicalModel) when you want the lexical model
to generate suggestions with an associated keyboard of a matching language.
## Examples
### Example: Using `addLexicalModel()`
The following script illustrates the use of `addLexicalModel()`:
```java
HashMap<String, String>lexicalModelInfo = new HashMap<String, String>();
lexicalModelInfo.put(KMManager.KMKey_PackageID, "example.ta.wordlist");
lexicalModelInfo.put(KMManager.KMKey_LanguageID, "ta");
lexicalModelInfo.put(KMManager.KMKey_LexicalModelID, "example.ta.wordlist");
lexicalModelInfo.put(KMManager.KMKey_LexicalModelVersion, "1.0");
KMManager.addLexicalModel(this, lexicalModelInfo);
KMManager.registerLexicalModel(lexicalModelInfo);
```
## See also
* [registerLexicalModel()](registerLexicalModel)

View file

@ -0,0 +1,31 @@
---
title: KMManager.advanceToNextInputMode()
---
## Summary
The **advanceToNextInputMode()** method switches to the next system keyboard input mode.
## Syntax
```javascript
KMManager.advanceToNextInputMode()
```
## Description
Use this method to switch to the next system keyboard.
## Examples
### Example: Using `advanceToNextInputMode()`
The following script illustrates the use of `advanceToNextInputMode()`:
```java
// Remove the second keyboard in the list
KMManager.removeKeyboard(this, 1);
KMManager.advanceToNextInputMode();
```
## See also
* [advanceToPreviousInputMethod()](advanceToPreviousInputMethod)

View file

@ -0,0 +1,32 @@
---
title: KMManager.advanceToPreviousInputMethod()
---
## Summary
The **advanceToPreviousInputMethod()** method switches to the previous system keyboard input mode.
## Syntax
```javascript
KMManager.advanceToPreviousInputMethod()
```
## Description
Use this method to switch to the previous system keyboard.
When only 1 Keyman keyboard is installed, this is the default action for pressing the globe key.
## Examples
### Example: Using `advanceToPreviousInputMethod()`
The following script illustrates the use of `advanceToPreviousInputMethod()`:
```java
// Remove the second keyboard in the list
KMManager.removeKeyboard(this, 1);
KMManager.advanceToPreviousInputMethod();
```
## See also
* [advanceToNextInputMode()](advanceToNextInputMode)

View file

@ -0,0 +1,54 @@
---
title: KMManager.applyKeyboardHeight()
---
## Summary
The **applyKeyboardHeight()** method sets the height of the keyboard frame for
the device's current [screen orientation](https://developer.android.com/training/multiscreen/screensizes#TaskUseOriQuali)
(portrait vs landscape).
## Syntax
```java
KMManager.applyKeyboardHeight(Context context, int height)
```
### Parameters
`context`
: The context
`height`
: The height of the keyboard frame in *density-independent pixels (dp)*
## Description
Use this method when you want to increase or decrease the keyboard height for
the device in the current screen orientation. This height is independent from
the height of the suggestion banner frame.
For reference, here's a table of the default Keyman keyboard heights for various devices and screen orientation.
Device Type and Screen Orientation | Default height (dp) |
|-----------------------------------|---------------------|
| Default handset in portrait | 205 |
| Default handset in landscape | 150 |
| 7" tablet in portrait | 305 |
| 7" tablet in landscape | 200 |
| 10" tablet in portrait | 405 |
| 10" tablet in landscape | 300 |
**Note:** This new keyboard height would be applied for all platforms, so an
adjusted keyboard height for a phone would appear too small for a tablet.
## Examples
### Example: Using `applyKeyboardHeight()`
The following script illustrates the use of `applyKeyboardHeight()`:
```java
// Increase the Keyman keyboard height (default Keyman value for most phones is 205dp)
int newKeyboardHeight = 300;
KMManager.applyKeyboardHeight(this, newKeyboardHeight);
```
## See also
* [getKeyboardHeight()](getKeyboardHeight)

View file

@ -0,0 +1,40 @@
---
title: KMManager.canAddNewKeyboard()
---
## Summary
The **`canAddNewKeyboard()`** method returns whether adding a new
keyboard is enabled.
## Syntax
``` javascript
KMManager.canAddNewKeyboard()
```
### Returns
Returns `true` if adding a new keyboard is enabled, `false` otherwise.
## Description
Use this method to check if additional keyboards can be added.
## Examples
### Example: Using `canAddNewKeyboard()`
The following script illustrate the use of `canAddNewKeyboard()`:
``` javascript
Keyboard kbInfo = ...; // Keyboard information
if (KMManager.canAddNewKeyboard()) {
KMManager.addKeyboard(this, kbInfo);
}
```
## See also
- [`canRemoveKeyboard`](canRemoveKeyboard)
- [`setCanAddNewKeyboard`](setCanAddNewKeyboard)

View file

@ -0,0 +1,33 @@
---
title: KMManager.canRemoveKeyboard()
---
## Summary
The **canRemoveKeyboard()** method returns whether removing a keyboard is enabled, like in the keyboard picker menu.
## Syntax
```javascript
KMManager.canRemoveKeyboard()
```
## Returns
Returns `true` if removing a keyboard is enabled, `false` otherwise.
## Description
Use this method to check if a keyboard can be removed. If enabled, you can long-press on a row in the keyboard picker menu to remove a keyboard.
## Examples
### Example: Using `canRemoveKeyboard()`
The following script illustrates the use of `canRemoveKeyboard()`:
```java
if (KeyboardController.getInstance().get().size() > 1 && KMManager.canRemoveKeyboard()) {
// Remove the second keyboard
KMManager.removeKeyboard(this, 1);
}
```
## See also
* [canAddNewKeyboard()](canAddNewKeyboard)

View file

@ -0,0 +1,44 @@
---
title: KMManager.copyHTMLBannerAssets
---
## Summary
The **copyHTMLBannerAssets()** method copies a folder of HTML banner assets so it's available for your keyboard app's resources.
## Syntax
```javascript
KMManager.copyHTMLBannerAssets(Context context, String path)
```
### Parameters
`context`
: The context.
`path`
: Relative to the /assets folder, the folder which contains the HTML assets to display when suggestions aren't available.
### Returns
Returns `true` if HTML assets were copied, `false` otherwise.
## Description
When suggestions aren't available for a keyboard, an HTML banner is displayed instead.
Use this method to specify any HTML assets the banner will use to theme your keyboard app. Some examples of assets would be .svg images or .css files used in your banner.
This can be called towards the end of `SystemKeyboard.onCreate()`.
You still need to call [setHTMLBanner()](setHTMLBanner) for Keyman Engine to assign the HTML banner for in-app and system keyboards.
## Examples
### Example: Using `copyHTMLBannerAssets()`
The following script illustrates the use of `copyHTMLBannerAssets()`:
```javascript
// Copies HTML banner assets located in /assets/banner/
KMManager.copyHTMLBannerAssets(this, "banner");
```
## See also
* [setHTMLBanner()](setHTMLBanner)

View file

@ -0,0 +1,58 @@
---
title: KMManager.createInputView()
---
## Summary
The **`createInputView()`** creates the input view to be used in
InputMethodService.
## Syntax
``` javascript
KMManager.createInputView(InputMethodService inputMethodService)
```
### Parameters
`inputMethodService`
: The InputMethodService.
### Returns
Returns the input view created.
## Description
Use this method to create the input view in response to an
InputMethodService's `onCreateInputView()` method.
## Examples
### Example: Using `createInputView()`
The following script illustrate the use of `createInputView()`:
``` javascript
private static View inputView = null;
@Override
public View onCreateInputView() {
// create the inputView only once
if (inputView == null)
inputView = KMManager.createInputView(this);
// we must remove the inputView from its previous parent before returning it
ViewGroup parent = (ViewGroup) inputView.getParent();
if (parent != null)
parent.removeView(inputView);
return inputView;
}
```
## See also
- [`onStartInput()`](onStartInput)
- [`onConfigurationChanged()`](onConfigurationChanged)
- [`onDestroy()`](onDestroy)

View file

@ -0,0 +1,35 @@
---
title: KMManager.deregisterLexicalModel()
---
## Summary
The **deregisterLexicalModel()** method deregisters the specified lexical model from the LMLayer so it isn't used.
## Syntax
```javascript
KMManager.degisterLexicalModel(String modelID)
```
### Parameters
`modelID`
: The ID of the lexical model to deregister
### Returns
`true`
## Description
Use this method when you want the lexical model to stop generating suggestions.
## Examples
### Example: Using `deregisterLexicalModel()`
The following script illustrates the use of `dergisterLexicalModel()`:
```java
String lexicalModelID = "example.ta.wordlist";
KMManager.deregisterLexicalModel(lexicalModelID);
```
## See also
* [registerLexicalModel()](registerLexicalModel)

View file

@ -0,0 +1,63 @@
---
title: KMManager.executeHardwareKeystroke()
---
## Summary
The **executeHardwareKeystroke()** method passes the keystroke generated from a physical keyboard to the KeymanWeb engine to handle.
## Syntax
```java
bool KMManager.executeHardwareKeystroke(int code, int shift, KeyboardType keyboard, int lstates, int eventModifiers)
```
### Parameters
`code`
: key identifier
`shift`
: shift state
| Flag | Value | Description |
|--------------|----------|----------------------------------------|
| Left Ctrl | `0x01` | Left Control Flag |
| Right Ctrl | `0x02` | Right Control Flag |
| Left Alt | `0x04` | Left Alt Flag |
| Right Alt | `0x08` | Right Alt Flag |
| Shift | `0x10` | Shift Flag |
| Ctrl | `0x20` | Control Flag |
| Alt | `0x40` | Alt Flag |
`keyboard`
: `KeyboardType.KEYBOARD_TYPE_INAPP` or `KeyboardType.KEYBOARD_TYPE_SYSTEM`
`lstates`
: lock state. If neither the on or off state is specified for a lock key, then it is treated as unknown state for keyboard rule matching.
| Value | Description |
|--------|----------------|
| `0x0100` | Caps lock |
| `0x0200` | No caps lock |
| `0x0400` | Num lock |
| `0x0800` | No Num lock |
| `0x1000` | Scroll |
| `0x2000` | No scroll lock |
`eventModifiers`
: [KeyEvent Flags](https://developer.android.com/reference/android/view/KeyEvent#getMetaState\(\)) indicating which meta keys are currently pressed.
### Returns
Returns `true` if the keyboard was initialized and executed the keystroke, `false` otherwise.
## Description
Use this method to pass a hardware keystroke to KeymanWeb Engine to process. The KeymanWeb Engine also factors in modifier and meta keys.
## Examples
### Example: Using `executeHardwareKeystroke()`
The following script illustrate the use of `executeHardwareKeystroke()`:
```java
// Send keystroke to KeymanWeb for processing: will return true to swallow the keystroke
return KMManager.executeHardwareKeystroke(code, keymanModifiers, keyboardType, Lstates, androidModifiers);
```

View file

@ -0,0 +1,39 @@
---
title: KMManager.getAssociatedLexicalModel()
---
## Summary
The **getAssociatedLexicalModel()** method searches the installed lexical models list and see if there's an associated model for a given language
## Syntax
```java
HashMap<String, String> getAssociatedLexicalModel(String langId)
```
### Parameters
`langId`
: The language ID
### Returns
A dictionary of the associated lexical model information with keys and values defined as
`HashMap<String key, String value)`.
`null` if there's no associated lexical model for a language `langId`.
## Description
Use this method to search the installed lexical models list and see if there's an associated model for a given language ID.
## Examples
### Example: Using `getAssociatedLexicalModel()`
The following script illustrates the use of `getAssociatedLexicalModel()`:
```java
String langId = "ta";
HashMap<String, String> lexModelMap = KMManager.getAssociatedLexicalModel(langId);
```
## See also
* [addLexicalModel()](addLexicalModel)
* [registerLexicalModel()](registerLexicalModel)

View file

@ -0,0 +1,38 @@
---
title: KMManager.getBannerHeight()
---
## Summary
The **`getBannerHeight()`** method returns the height of the suggestion
banner.
## Syntax
``` javascript
KMManager.getBannerHeight(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the height of the suggestion banner frame in
*density-independent pixel (dp)*.
## Description
Use this method to get the height of the suggestion banner frame.
## Examples
### Example: Using `getBannerHeight()`
The following script illustrate the use of `getBannerHeight()`:
``` javascript
int bannerHeight = KMManager.getBannerHeight(this);
```

View file

@ -0,0 +1,47 @@
---
title: KMManager.getCurrentKeyboardIndex()
---
## Summary
The **`getCurrentKeyboardIndex()`** method returns index number of the
current keyboard in keyboards list.
## Syntax
``` javascript
KMManager.getCurrentKeyboardIndex(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns 0-based index number of the current keyboard if exists in
keyboards list, -1 otherwise.
## Description
Use this method to get the index number of the currently selected
keyboard if it exists in keyboards list.
## Examples
### Example: Using `getCurrentKeyboardIndex()`
The following script illustrate the use of `getCurrentKeyboardIndex()`:
``` javascript
int index = KMManager.getCurrentKeyboardIndex(this);
```
## See also
- [`getCurrentKeyboardInfo()`](getCurrentKeyboardInfo)
- [`getKeyboardIndex()`](getKeyboardIndex)
- [`getKeyboardInfo()`](getKeyboardInfo)
- [`getKeyboardsList()`](getKeyboardsList)
- [`keyboardExists()`](keyboardExists)

View file

@ -0,0 +1,96 @@
---
title: KMManager.getCurrentKeyboardInfo()
---
## Summary
The **`getCurrentKeyboardInfo()`** method returns keyboard information
of the current keyboard.
## Syntax
``` javascript
KMManager.getCurrentKeyboardInfo(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the current keyboard information of `Keyboard` type.
## Description
Use this method to get details of the currently selected keyboard.
Details include package ID, keyboard ID, language ID, keyboard name,
language name and fonts.
------------------------------------------------------------------------
## Syntax (Deprecated)
``` javascript
KMManager.getCurrentKeyboardInfo(Context context)
```
### Parameters
`context`
: The context.
### Returns
(Deprecated) Returns an information dictionary of the current keyboard
with keys and values defined as `HashMap<String key, String value>`.
## Description
Use this method to get details of the currently selected keyboard.
Details include keyboard ID, language ID, keyboard name, language name
and fonts.
------------------------------------------------------------------------
## Examples
### Example: Using `getCurrentKeyboardInfo()`
The following script illustrate the use of `getCurrentKeyboardInfo()`:
``` javascript
Keyboard keyboardInfo = KMManager.getCurrentKeyboardInfo(this);
if (keyboardInfo != null) {
String packageID = keyboardInfo.getPackageID();
String keyboardId = keyboardInfo.getKeyboardID();
String keyboardName = keyboardInfo.getKeyboardName();
String languageId = keyboardInfo.getLanguageID();
String languageName = keyboardInfo.getLanguageName();
String version = keyboardInfo.getVersion();
String font = keyboardInfo.getFont();
String oskFont = keyboardInfo.getOSKFont();
//
}
```
## History
Added syntax for returning Keyboard type in Keyman Engine for Android
14.0.
Deprecated syntax for returning HashMap&lt;String key, String value&gt;
in Keyman Engine for Android 14.0
## See also
- [`getCurrentKeyboardIndex()`](getCurrentKeyboardIndex)
- [`getKeyboardIndex()`](getKeyboardIndex)
- [`getKeyboardInfo()`](getKeyboardInfo)
- [`getKeyboardsList()`](getKeyboardsList)
- [`keyboardExists()`](keyboardExists)

View file

@ -0,0 +1,29 @@
---
title: KMManager.getDefaultKeyboard()
---
## Summary
The `getDefaultKeyboard()` method returns the keyboard information for the fallback keyboard.
## Syntax
```java
KMManager.getDefaultKeyboard()
```
### Returns
Returns `Keyboard` type for the fallback keyboard. If not specified, this defaults to keyboard information for sil_euro_latin.
## Description
The `getDefaultKeyboard()` method returns the keyboard information for the fallback keyboard. If Keyman Engine
has issues with a current keyboard, KMManager will switch to this fallback keyboard.
## Examples
### Example: Using getDefaultKeyboard()
The following script illustrates the use of `getDefaultKeyboard()`:
```java
Keyboard kbd = KMManager.getDefaultKeyboard();
```
## See also
* [setDefaultKeyboard](setDefaultKeyboard)

View file

@ -0,0 +1,51 @@
---
title: KMManager.getFontTypeface()
---
## Summary
The **`getFontTypeface()`** method creates a new typeface from the
specified font filename.
## Syntax
``` javascript
KMManager.getFontTypeface(Context context, String fontFilename)
```
### Parameters
`context`
: The context.
`fontFilename`
: The filename of the font.
### Returns
Returns the new typeface created from font file with specified filename
if it exists, `null` otherwise.
## Description
Use this method to create a new typeface from the font file with
specified filename if it exists in `assets/fonts/` folder.
## Examples
### Example: Using `getFontTypeface()`
The following script illustrate the use of `getFontTypeface()`:
``` javascript
KMTextView textView = (KMTextView) findViewById(R.id.kmTextView);
Typeface fontTypeface = KMManager.getFontTypeface(this, "aava1.ttf");
textView.setTypeface(fontTypeface);
```
## See also
- [`getKeyboardTextFontTypeface()`](getKeyboardTextFontTypeface)
- [`getKeyboardOskFontTypeface()`](getKeyboardOskFontTypeface)
- [`getKeyboardTextFontFilename()`](getKeyboardTextFontFilename)
- [`getKeyboardOskFontFilename()`](getKeyboardOskFontFilename)

View file

@ -0,0 +1,35 @@
---
title: KMManager.getGlobeKeyAction()
---
## Summary
The **getGlobeKeyAction()** method returns the short-press action type of the 'Globe' key.
## Syntax
```java
KMManager.getGlobeKeyAction(KeyboardType kbType)
```
### Parameters
kbType
: The keyboard type. `KEYBOARD_TYPE_INAPP` or `KEYBOARD_TYPE_SYSTEM`
### Returns
Returns the action type of the short-press 'Globe' key as one of
`GLOBE_KEY_ACTION_SHOW_MENU`, `GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD`,
`GLOBE_KEY_ACTION_ADVANCE_TO_PREVIOUS_SYSTEM_KEYBOARD`, `GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD`,
`GLOBE_KEY_ACTION_SHOW_SYSTEM_KEYBOARDS`, or `GLOBE_KEY_ACTION_DO_NOTHING`.
## Description
Use this method to get the short-press action type of the 'Globe' key.
## Examples
### Example: Using getGlobeKeyAction()
The following script illustrate the use of `getGlobeKeyAction()`:
```java
GlobeKeyAction action = KMManager.getGlobeKeyAction(KeyboardType.KEYBOARD_TYPE_SYSTEM);
```
## See also
* [setGlobeKeyAction()](setGlobeKeyAction)

View file

@ -0,0 +1,23 @@
---
title: KMManager.getHapticFeedback()
---
## Summary
The **getHapticFeedback()** method returns whether the device vibrates as the user types.
## Syntax
```java
KMManager.getHapticFeedback()
```
### Returns
Returns `true` if the device vibrates as the user types, `false` otherwise.
## Description
Use this method to check if the device is currently configured to provide haptic feedback. Default is `false`.
## History
Keyman Engine for Android 15.0: New function.
## See also
* [setHapticFeedback](setHapticFeedback)

View file

@ -0,0 +1,28 @@
---
title: KMManager.getKMKeyboard()
---
## Summary
The `getKMKeyboard()` method returns the [KMKeyboard](../KMKeyboard) type depending whether it's an in-app or system keyboard.
## Syntax
```java
KMKeyboard KMManager.getKMKeyboard(KeyboardType type)
```
### Parameters
type
: `KeyboardType.KEYBOARD_TYPE_INAPP` or `KeyboardType.KEYBOARD_TYPE_SYSTEM`
### Returns
Returns the KMKeyboard object.
## Description
The `getKMKeyboard()` method returns the KMKeyboard for the specified keyboard type.
## Examples
### Example: Using getKMKeyboard()
The following script illustrates the use of `getKMKeyboard()`:
```java
KMKeyboard keyboard = KMManager.getKMKeyboard(KeyboardType.KEYBOARD_TYPE_SYSTEM);
```

View file

@ -0,0 +1,38 @@
---
title: KMManager.getKeyboardFontFilename() (Deprecated)
---
## Summary
(Deprecated) The **`getKeyboardFontFilename()`** method returns the
selected keyboard's font filename.
## Syntax
``` javascript
KMManager.getKeyboardFontFilename()
```
### Returns
Returns the selected keyboard's font filename as `String` if it has any,
empty string otherwise.
## Description
Use this method to get the font filename of the selected keyboard.
## Examples
### Example: Using `getKeyboardFontFilename()`
The following script illustrate the use of `getKeyboardFontFilename()`:
``` javascript
String fontFilename = KMManager.getKeyboardFontFilename();
```
## See also
- [`getKeyboardFontTypeface()` (Deprecated)](getKeyboardFontTypeface)
- [`getFontTypeface()`](getFontTypeface)

View file

@ -0,0 +1,46 @@
---
title: KMManager.getKeyboardFontTypeface() (Deprecated)
---
## Summary
(Deprecated) The **`getKeyboardFontTypeface()`** method creates a new
typeface from the selected keyboard's font.
## Syntax
``` javascript
KMManager.getKeyboardFontTypeface(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the new typeface created from the selected keyboard's font if it
exists, `null` otherwise.
## Description
Use this method to create a new typeface from the selected keyboard's
font if it has any.
## Examples
### Example: Using `getKeyboardFontTypeface()`
The following script illustrate the use of `getKeyboardFontTypeface()`:
``` javascript
KMTextView textView = (KMTextView) findViewById(R.id.kmTextView);
Typeface fontTypeface = KMManager.getKeyboardFontTypeface(this);
textView.setTypeface(fontTypeface);
```
## See also
- [`getFontTypeface()`](getFontTypeface)
- [`getKeyboardFontFilename()` (Deprecated)](getKeyboardFontFilename)

View file

@ -0,0 +1,42 @@
---
title: KMManager.getKeyboardHeight()
---
## Summary
The **`getKeyboardHeight()`** method returns the height of the keyboard
frame.
## Syntax
``` javascript
KMManager.getKeyboardHeight(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the height of the keyboard frame in *density-independent pixels
(dp)*.
## Description
Use this method to get the height of the keyboard frame.
## Examples
### Example: Using `getKeyboardHeight()`
The following script illustrate the use of `getKeyboardHeight()`:
``` javascript
int keyboardHeight = KMManager.getKeyboardHeight(this);
```
## See also
- [applyKeyboardHeight](applyKeyboardHeight)

View file

@ -0,0 +1,53 @@
---
title: KMManager.getKeyboardIndex()
---
## Summary
The **`getKeyboardIndex()`** method returns index number of the
specified keyboard in keyboards list.
## Syntax
``` javascript
KMManager.getKeyboardIndex(Context context, String keyboardID, String languageID)
```
### Parameters
`context`
: The context.
`keyboardID`
: ID of the keyboard.
`languageID`
: ID of the associated language.
### Returns
Returns 0-based index number of the specified keyboard if exists in
keyboards list, -1 otherwise.
## Description
Use this method to get the index number of the keyboard with given
keyboard ID and language ID if it exists in keyboards list.
## Examples
### Example: Using `getKeyboardIndex()`
The following script illustrate the use of `getKeyboardIndex()`:
``` javascript
int index = KMManager.getKeyboardIndex(this, "tamil99m", "ta");
```
## See also
- [`getCurrentKeyboardIndex()`](getCurrentKeyboardIndex)
- [`getCurrentKeyboardInfo()`](getCurrentKeyboardInfo)
- [`getKeyboardInfo()`](getKeyboardInfo)
- [`getKeyboardsList()`](getKeyboardsList)
- [`keyboardExists()`](keyboardExists)

View file

@ -0,0 +1,98 @@
---
title: KMManager.getKeyboardInfo()
---
## Summary
The **`getKeyboardInfo()`** method returns information of the specified
keyboard.
## Syntax
``` javascript
KMManager.getKeyboardInfo(Context context, int index)
```
### Parameters
`context`
: The context.
`index`
: 0-based position of the keyboard in keyboards list.
### Returns
Returns an information `Keyboard` type of the specified keyboard.
## Description
Use this method to get details of the keyboard at given position in
keyboards list. Details include keyboard ID, language ID, keyboard name,
language name and fonts.
------------------------------------------------------------------------
## Syntax (Deprecated)
``` javascript
KMManager.getKeyboardInfo(Context context, int index)
```
### Parameters
`context`
: The context.
`index`
: 0-based position of the keyboard in keyboards list.
### Returns
(Deprecated) Returns an information dictionary of the specified keyboard
with keys and values defined as `HashMap<String key, String value>`.
## Description
Use this method to get details of the keyboard at given position in
keyboards list. Details include keyboard ID, language ID, keyboard name,
language name and fonts.
## Examples
### Example: Using `getKeyboardInfo()`
The following script illustrate the use of `getKeyboardInfo()`:
``` javascript
Keyboard keyboardInfo = KMManager.getKeyboardInfo(this, 1);
if (keyboardInfo != null) {
String packageID = keyboardInfo.getPackageID();
String keyboardId = keyboardInfo.getKeyboardID();
String keyboardName = keyboardInfo.getKeyboardName();
String languageId = keyboardInfo.getLanguageID();
String languageName = keyboardInfo.getLanguageName();
String version = keyboardInfo.getVersion();
String font = keyboardInfo.getFont();
String oskFont = keyboardInfo.getOSKFont();
//
}
```
## History
Added syntax for returning Keyboard type in Keyman Engine for Android
14.0.
Deprecated syntax for returning the HashMap&lt;String key, String
value&gt; in Keyman Engine for Android 14.0
## See also
- [`getCurrentKeyboardIndex()`](getCurrentKeyboardIndex)
- [`getCurrentKeyboardInfo()`](getCurrentKeyboardInfo)
- [`getKeyboardIndex()`](getKeyboardIndex)
- [`getKeyboardsList()`](getKeyboardsList)
- [`keyboardExists()`](keyboardExists)

View file

@ -0,0 +1,41 @@
---
title: KMManager.getKeyboardOskFontFilename()
---
## Summary
The **`getKeyboardOskFontFilename()`** method returns the selected
keyboard's OSK font filename.
## Syntax
``` javascript
KMManager.getKeyboardOskFontFilename()
```
### Returns
Returns the selected keyboard's OSK font filename as `String` if it has
any, empty string otherwise.
## Description
Use this method to get the OSK font filename of the selected keyboard.
## Examples
### Example: Using `getKeyboardOskFontFilename()`
The following script illustrate the use of
`getKeyboardOskFontFilename()`:
``` javascript
String oskFontFilename = KMManager.getKeyboardOskFontFilename();
```
## See also
- [`getKeyboardTextFontFilename()`](getKeyboardTextFontFilename)
- [`getKeyboardOskFontTypeface()`](getKeyboardOskFontTypeface)
- [`getKeyboardTextFontTypeface()`](getKeyboardTextFontTypeface)
- [`getFontTypeface()`](getFontTypeface)

View file

@ -0,0 +1,47 @@
---
title: KMManager.getKeyboardOskFontTypeface()
---
## Summary
The **`getKeyboardOskFontTypeface()`** method creates a new typeface
from the selected keyboard's OSK font.
## Syntax
``` javascript
KMManager.getKeyboardOskFontTypeface(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the new typeface created from the selected keyboard's OSK font
if it exists, `null` otherwise.
## Description
Use this method to create a new typeface from the selected keyboard's
OSK font if it has any.
## Examples
### Example: Using `getKeyboardOskFontTypeface()`
The following script illustrate the use of
`getKeyboardOskFontTypeface()`:
``` javascript
Typeface oskFontTypeface = KMManager.getKeyboardOskFontTypeface(this);
```
## See also
- [`getKeyboardTextFontTypeface()`](getKeyboardTextFontTypeface)
- [`getKeyboardOskFontFilename()`](getKeyboardOskFontFilename)
- [`getKeyboardTextFontFilename()`](getKeyboardTextFontFilename)
- [`getFontTypeface()`](getFontTypeface)

View file

@ -0,0 +1,68 @@
---
title: KMManager.getKeyboardState()
---
## Summary
The **`getKeyboardState()`** method returns the specified keyboard's
state.
## Syntax
``` javascript
KMManager.getKeyboardState(Context context, String keyboardID, String languageID)
```
### Parameters
`context`
: The context.
`keyboardID`
: ID of the keyboard.
`languageID`
: ID of the associated language.
### Returns
Returns the state of the specified keyboard as one of
`KEYBOARD_STATE_UNDEFINED`, `KEYBOARD_STATE_NEEDS_DOWNLOAD`,
`KEYBOARD_STATE_NEEDS_UPDATE` or `KEYBOARD_STATE_UP_TO_DATE`.
## Description
Use this method to get the state of the specified keyboard. It returns
`KEYBOARD_STATE_UNDEFINED` if keyboardID or languageID is not specified
(`null` or empty string). It returns `KEYBOARD_STATE_NEEDS_DOWNLOAD` if
the specified keyboard does not exist in `assets/languages/` folder. In
all other cases it returns either `KEYBOARD_STATE_UP_TO_DATE` or
`KEYBOARD_STATE_NEEDS_UPDATE`. Note: Only keyboards provided by Keyman
may return `KEYBOARD_STATE_NEEDS_UPDATE`. If you have a custom keyboard,
you need to implement your own method to check whether or not it needs
update. `KEYBOARD_STATE_UP_TO_DATE` does not necessarily mean that the
keyboard is in fact up to date, you need to make sure language list has
recently been displayed (see
[`showLanguageList() (Deprecated)`](showLanguageList)) without failure
to access Keyman server to be certain.
## Examples
### Example: Using `getKeyboardState()`
The following script illustrate the use of `getKeyboardState()`:
``` javascript
KeyboardState keyboardState = KMManager.getKeyboardState(this, "tamil99m", "ta");
switch (keyboardState) {
case KEYBOARD_STATE_NEEDS_DOWNLOAD:
// We need to download this keyboard or manually add it into assets/languages/ folder.
break;
case KEYBOARD_STATE_UP_TO_DATE:
case KEYBOARD_STATE_NEEDS_UPDATE:
// We can safely use this keyboard since it exists in assets/languages/ folder.
break;
default:
// Undefined state
}
```

View file

@ -0,0 +1,41 @@
---
title: KMManager.getKeyboardTextFontFilename()
---
## Summary
The **`getKeyboardTextFontFilename()`** method returns the selected
keyboard's text font filename.
## Syntax
``` javascript
KMManager.getKeyboardTextFontFilename()
```
### Returns
Returns the selected keyboard's text font filename as `String` if it has
any, empty string otherwise.
## Description
Use this method to get the text font filename of the selected keyboard.
## Examples
### Example: Using `getKeyboardTextFontFilename()`
The following script illustrate the use of
`getKeyboardTextFontFilename()`:
``` javascript
String textFontFilename = KMManager.getKeyboardTextFontFilename();
```
## See also
- [`getKeyboardOskFontFilename()`](getKeyboardOskFontFilename)
- [`getKeyboardTextFontTypeface()`](getKeyboardTextFontTypeface)
- [`getKeyboardOskFontTypeface()`](getKeyboardOskFontTypeface)
- [`getFontTypeface()`](getFontTypeface)

View file

@ -0,0 +1,49 @@
---
title: KMManager.getKeyboardTextFontTypeface()
---
## Summary
The **`getKeyboardTextFontTypeface()`** method creates a new typeface
from the selected keyboard's text font.
## Syntax
``` javascript
KMManager.getKeyboardTextFontTypeface(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the new typeface created from the selected keyboard's text font
if it exists, `null` otherwise.
## Description
Use this method to create a new typeface from the selected keyboard's
text font if it has any.
## Examples
### Example: Using `getKeyboardTextFontTypeface()`
The following script illustrate the use of
`getKeyboardTextFontTypeface()`:
``` javascript
KMTextView textView = (KMTextView) findViewById(R.id.kmTextView);
Typeface textFontTypeface = KMManager.getKeyboardTextFontTypeface(this);
textView.setTypeface(textFontTypeface);
```
## See also
- [`getKeyboardOskFontTypeface()`](getKeyboardOskFontTypeface)
- [`getKeyboardTextFontFilename()`](getKeyboardTextFontFilename)
- [`getKeyboardOskFontFilename()`](getKeyboardOskFontFilename)
- [`getFontTypeface()`](getFontTypeface)

View file

@ -0,0 +1,87 @@
---
title: KMManager.getKeyboardsList()
---
## Summary
The **`getKeyboardsList()`** method returns the keyboards list.
## Syntax
``` javascript
KMManager.getKeyboardsList(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns keyboards list as `List<Keyboard>` if it exists, `null`
otherwise.
## Description
Use this method to get details of all keyboard's in keyboards menu.
------------------------------------------------------------------------
## Syntax (Deprecated)
``` javascript
KMManager.getKeyboardsList(Context context)
```
### Parameters
`context`
: The context.
### Returns
(Deprecated) Returns keyboards list as
`ArrayList<HashMap<String key, String value>>` if it exists, `null`
otherwise.
## Description
Use this method to get details of all keyboard's in keyboards menu.
------------------------------------------------------------------------
## Examples
### Example: Using `getKeyboardsList()`
The following script illustrate the use of `getKeyboardsList()`:
``` javascript
List<Keyboard> keyboardsList = KMManager.getKeyboardsList(this);
if ((keyboardsList != null) && keyboardsList.size() < 2) {
// Add another Keyboard
Keyboard kbd = new Keyboard(...);
KMManager.addKeyboard(kbd);
}
```
## History
Added syntax for returning list of Keyboard type in Keyman Engine for
Android 14.0.
Deprecated syntax for returning the list of HashMap&lt;String key,
String value&gt; in Keyman Engine for Android 14.0
## See also
- [`getCurrentKeyboardIndex()`](getCurrentKeyboardIndex)
- [`getCurrentKeyboardInfo()`](getCurrentKeyboardInfo)
- [`getKeyboardIndex()`](getKeyboardIndex)
- [`getKeyboardInfo()`](getKeyboardInfo)
- [`keyboardExists()`](keyboardExists)

View file

@ -0,0 +1,40 @@
---
title: KMManager.getLanguageCorrectionPreferenceKey()
---
## Summary
A constant to use as a shared preference key to store whether the LMLayer should enable corrections for a given language.
## Syntax
```java
KMManager.getLanguageCorrectionPreferenceKey(String langID)
```
### Parameters
`langId`
: The BCP 47 language ID
### Returns
Returns the language correction preference key as a String.
## Description
Use this method to get a String that can be used as a shared preference key.
The usage of this preference key is experimental and likely to be deprecated in a future release of Keyman Engine for Android.
## Examples
### Example: Using `getLanguageCorrectionPreferenceKey()`
The following script illustrates the use of `getLanguageCorrectionPreferenceKey()`:
```java
SharedPreferences prefs = ...; // Get the app's shared preferences
String langID = "ta";
boolean key = KMManager.getLanguageCorrectionPreferenceKey(langID);
boolean mayCorrect = prefs.getBoolean(key, true);
```
## See also
* [getLanguagePredictionPreferenceKey()](getLanguagePredictionPreferenceKey)

View file

@ -0,0 +1,40 @@
---
title: KMManager.getLanguagePredictionPreferenceKey()
---
## Summary
A constant to use as a shared preference key to store whether the LMLayer should enable suggestions for a given language.
## Syntax
```java
KMManager.getLanguagePredictionPreferenceKey(String langID)
```
### Parameters
`langId`
: The BCP 47 language ID
### Returns
Returns the language prediction preference key as a String.
## Description
Use this method to get a String that can be used as a shared preference key.
The usage of this preference key is experimental and likely to be deprecated in a future release of Keyman Engine for Android.
## Examples
### Example: Using `getLanguagePredictionPreferenceKey()`
The following script illustrates the use of `getLanguagePredictionPreferenceKey()`:
```java
SharedPreferences prefs = ...; // Get the app's shared preferences
String langID = "ta";
boolean key = KMManager.getLanguagePredictionPreferenceKey(langID);
boolean mayPredict = prefs.getBoolean(key, true);
```
## See also
* [getLanguageCorrectionPreferenceKey()](getLanguageCorrectionPreferenceKey)

View file

@ -0,0 +1,61 @@
---
title: KMManager.getLatestKeyboardFileVersion()
---
## Summary
The **`getLatestKeyboardFileVersion()`** method returns the specified
keyboard's latest file version number.
## Syntax
``` javascript
KMManager.getLatestKeyboardFileVersion(Context context, String packageID, String keyboardID)
```
### Parameters
`context`
: The context.
`packageID`
: ID of the package.
`keyboardID`
: ID of the keyboard.
### Returns
Returns the specified keyboard's latest file version number as `String`
if the keyboard exists, `null` otherwise.
## Description
Use this method to get the latest file version number of the specified
keyboard if it exists in the `assets/cloud/` or `assets/packages/`
folder.
If packageID is `cloud`, this method determines the latest file version
by the filename.
If packageID is something else, the metadata file
assets/packageID/kmp.json is parsed to determine the keyboard version.
## Examples
### Example: Using `getLatestKeyboardFileVersion()`
The following script illustrate the use of
`getLatestKeyboardFileVersion()`:
``` javascript
String latestVersion = getLatestKeyboardFileVersion(this, "cloud", "tamil99m");
if (latestVersion != null) {
// If we assume that there are 2 tamil99m keyboard files in assets/cloud/ folder
// with filenames; tamil99m-1.0.js and tamil99m-1.1.js
// then latestVersion = "1.1"
}
else {
// This keyboard does not exist in assets/cloud/ folder!
}
```

View file

@ -0,0 +1,47 @@
---
title: KMManager.getLexicalModelInfo()
---
## Summary
The `getLexicalModelInfo()` method returns returns dictionary information of the specified lexical model.
## Syntax
```java
HashMap<String,String> KMManager.getLexicalModelInfo(Context context, int index)
```
### Parameters
`context`
: The context.
`index`
: Zero-based index of the installed lexical model
### Returns
Returns a dictionary `Hashmap<String, String>` containing information on the specified lexical model.
The keys for the HashMap are:
| Keys |
|---------------------------------------------|
| `KMManager.KMKey_PackageID` |
| `KMManager.KMKey_LexicalModelID` |
| `KMManager.KMKey_LexicalModelName` |
| `KMManager.KMKey_LexicalModelVersion` |
| `KMManager.KMKey_LanguageID` |
| `KMManager.KMKey_LanguageName` |
| `KMManager.KMKey_CustomHelpLink` (optional) |
## Description
Use this method to get details about a specified lexical model. (language and keyboard information)
## Examples
### Example: Using `getLexicalModelInfo()`
The following code illustrates the use of `getLexicalModelInfo()`:
```java
// Gets information on the first installed lexical model
HashMap<String, String> lexicalModelInfo = KMManager.getLexicalModelInfo(context, 0);
```

View file

@ -0,0 +1,32 @@
---
title: KMManager.getLexicalModelsList()
---
## Summary
The **getLexicalModelsList()** method returns the array of lexical models list.
## Syntax
```java
ArrayList<HashMap<String, String>> KMManager.getLexicalModelsList(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns a list of all the installed lexical models.
## Description
Use this method to get details of all the installed lexical models.
## Examples
### Example: Using getLexicalModelsList()
The following script illustrate the use of `getLexicalModelsList()`:
```java
ArrayList<HashMap<String, String>> lexicalModelList = KMManager.getLexicalModelsList(context);
```
## See also
* [getLexicalModelInfo()](getLexicalModelInfo)

View file

@ -0,0 +1,38 @@
---
title: KMManager.getLongpressDelay()
---
## Summary
The `getLongpressDelay()` method returns from stored preference the number of milliseconds to trigger a longpress gesture.
Defaults to 500 milliseconds.
## Syntax
```java
int KMManager.getLongpressDelay()
```
### Returns
Returns the number of milliseconds to trigger a longpress gesture. This preference is stored at the app level and is applied to all Keyman keyboards.
## Description
Use this method to get details about how long to press a key for longpress keys to appear.
## Examples
### Example: Using `getLongpressDelay()`
The following code illustrates the use of `getLongpressDelay()`:
```java
int currentDelayTimeMS = KMManager.getLongpressDelay();
currentDelayTimeMS += 250; // ms
```
## History
Keyman Engine for Android 18.0: New function.
## See also
* [sendOptionsToKeyboard](sendOptionsToKeyboard)
* [setLongpressDelay](setLongpressDelay)

View file

@ -0,0 +1,23 @@
---
title: KMManager.getMaySendCrashReport()
---
## Summary
The **getMaySendCrashReport()** method returns whether Keyman Engine is allowed to send crash reports over the network to sentry.keyman.com.
## Syntax
```java
KMManager.getMaySendCrashReport()
```
### Returns
Returns `true` if crash reports can be sent over the network to sentry.keyman.com, `false` otherwise.
## Description
Use this method to check if Keyman Engine will be accessing the network to send crash reports.
## History
Added syntax in Keyman Engine for Android 14.0.
## See also
* [setMaySendCrashReport](setMaySendCrashReport)

View file

@ -0,0 +1,37 @@
---
title: KMManager.getOrientation()
---
## Summary
The `getOrientation()` method returns the current orientation of the device.
## Syntax
```java
KMManager.getOrientation(Context context)
```
### Parameters
`context`
: The context.
### Returns
Returns the device orientation as an int, one of:
* `Configuration.ORIENTATION_PORTRAIT` (`1`)
* `Configuration.ORIENTATION_LANDSCAPE` (`2`)
* `Configuration.ORIENTATION_UNDEFINED` (`0`)
## Description
Use this method to get the current orientation of the device
## Examples
### Example: Using `getOrientation()`
The following code illustrates the use of `getOrientation()`:
```java
int orientation = KMManager.getOrientation(context);
```

View file

@ -0,0 +1,45 @@
---
title: KMManager.getSpacebarText()
---
## Summary
The `getSpacebarText()` method returns the current text display pattern for the
spacebar.
## Syntax
```java
KMManager.SpacebarText KMManager.getSpacebarText()
```
### Returns
The current text display pattern for the spacebar, one of:
* `LANGUAGE` - the language name for the keyboard
* `KEYBOARD` - the keyboard name
* `LANGUAGE_KEYBOARD` - both the language name and the keyboard name,
separated by hyphen
* `BLANK` - no text to be displayed
## Description
The default text display pattern is `LANGUAGE_KEYBOARD`. The text shown on the
keyboard may be overridden on a per-keyboard basis with the `displayName`
parameter of the `setKeyboard()` function.
---
## Example: Using `getSpacebarText()`
The following script illustrates the use of `getSpacebarText()`:
```java
// get the current spacebar text mode
KMManager.SpacebarText mode = KMManager.getSpacebarText();
```
## See also
* [`setSpacebarText()`](setSpacebarText)

View file

@ -0,0 +1,32 @@
---
title: KMManager.getVersion()
---
## Summary
The **`getVersion()`** method returns the version number of Keyman
Engine.
## Syntax
``` javascript
KMManager.getVersion()
```
### Returns
Returns Keyman Engine version number as `String`.
## Description
Use this method to get the version number of Keyman Engine.
## Examples
### Example: Using `getVersion()`
The following script illustrate the use of `getVersion()`:
``` javascript
String version = KMManager.getVersion();
```

View file

@ -0,0 +1,34 @@
---
title: KMManager.getWindowDensity()
---
## Summary
The `getWindowDensity()` method returns the density of the window.
## Syntax
```java
KMManager.getWindowDensity(Context context)
```
`context`
: The context.
### Returns
Returns the density
## Description
Use this method to get the [density](https://developer.android.com/reference/android/util/DisplayMetrics#density) of the window. This is a scaling factor for the Density Independent Pixel (DIP) unit.
## Examples
### Example: Using `getWindowDensity()`
The following code illustrates the use of `getWindowDensity()`:
```java
float density = KMManager.getWindowDensity(context);
```
## See Also
* [getWindowSize](getWindowSize)

View file

@ -0,0 +1,39 @@
---
title: KMManager.getWindowSize()
---
## Summary
The `getWindowSize()` method returns the size of the area the window would occupy.
## Syntax
```java
KMManager.getWindowSize(Context context)
```
`context`
: The context.
### Returns
Returns the window size (native resolution) of the display as (int x, int y).
## Description
Use this method to get the size of the entire display.
For API level 29 and below, the size of the [entire display minus system decoration areas](https://developer.android.com/reference/android/view/Display#getSize(android.graphics.Point) is returned.
For API level 30 and above, it may or may not include [system decoration areas](https://developer.android.com/reference/android/view/Display)
## Examples
### Example: Using `getWindowSize()`
The following code illustrates the use of `getWindowSize()`:
```java
Point size = KMManager.getWindowSize(context);
int screenHeight = size.y;
```
## See also
* [getWindowDensity](getWindowDensity)

View file

@ -0,0 +1,38 @@
---
title: KMManager.hasConnection()
---
## Summary
The **hasConnection()** method returns whether the device has active network connection.
## Syntax
```java
KMManager.hasConnection(Context context)
```
## Parameters
`context`
: The context
## Returns
Returns `true` if application's AndroidManifest.xml file has granted
[Manifest.permission.ACCESS_NETWORK_STATE](https://developer.android.com/reference/android/Manifest.permission#ACCESS_NETWORK_STATE)
permission and the device has an active network connection, `false` otherwise.
## Description
Use this method to check if the device has an active network connection. It is important to make sure there is an active network connection before initiating a download or update.
## Examples
### Example: Using `hasConnection()`
The following script illustrate the use of `hasConnection()`:
```java
if (KMManager.hasConnection(this)) {
// has network connection
}
else {
// no network connection
}
```

View file

@ -0,0 +1,36 @@
---
title: KMManager.hideSystemKeyboard()
---
## Summary
The **`hideSystemKeyboard()`** method hides the system OSK.
## Syntax
``` javascript
KMManager.hideSystemKeyboard()
```
## Description
Use this method to hide the system OSK. A common usage is to prevent
your app from displaying both in-app OSK and the system OSK.
## Examples
### Example: Using `hideSystemKeyboard()`
The following script illustrate the use of `hideSystemKeyboard()`:
``` javascript
protected void onResume() {
super.onResume();
KMManager.onResume();
KMManager.hideSystemKeyboard();
// ...
```
## See also
- [`onResume()`](onResume)

View file

@ -0,0 +1,285 @@
---
title: KMManager class
---
## Summary
The **`KMManager`** class provides methods for controlling Keyman Engine
## Syntax
```java
KMManager.methodName()
```
```java
KMManager.CONSTANT
```
## Description
The KMManager is the core class which provides most of the methods and constants you will need to develop your apps with Keyman Engine
<!-- Fill in examples of how to use, etc. -->
## Methods
[`addKeyboard()`](addKeyboard)
: adds a keyboard into the keyboards list
[`addKeyboardDownloadEventListener()`](addKeyboardDownloadEventListener)
: adds the specified listener into the list of keyboard download event listeners
[`addKeyboardEventListener()`](addKeyboardEventListener)
: adds the specified listener into the list of keyboard event listeners
[`addLexicalModel()`](addLexicalModel)
: adds a lexical model into the lexical models list
[`advanceToNextInputMode()`](advanceToNextInputMode)
: switch to the next system keyboard input mode
[`advanceToPreviousInputMethod()`](advanceToPreviousInputMethod)
: switch to the previous system keyboard input mode
[`applyKeyboardHeight()`](applyKeyboardHeight)
: sets the height of keyboard frame
[`canAddNewKeyboard()`](canAddNewKeyboard)
: returns whether adding a new keyboard is enabled, like in the keyboard picker menu
[`canRemoveKeyboard()`](canRemoveKeyboard)
: returns whether removing a keyboard is enabled, like in the keyboard picker menu
[`copyHTMLBannerAssets()`](copyHTMLBannerAssets)
: copies a folder of HTML banner assets so it's available for your keyboard app's resources
[`createInputView()`](createInputView)
: creates the input view to be used in InputMethodService
[`deregisterLexicalModel()`](deregisterLexicalModel)
: deregisters the specified lexical model from the LMLayer so it isn't used
[`executeHardwareKeystroke()`](executeHardwareKeystroke)
: process the keystroke generated from a physical keyboard
[`getAssociatedLexicalModel()`](getAssociatedLexicalModel)
: search the installed lexical models list and see if there's an associated model for a given language
[`getBannerHeight()`](getBannerHeight)
: returns the height of the suggestion banner
[`getCurrentKeyboardIndex()`](getCurrentKeyboardIndex)
: returns index number of the current keyboard in keyboards list
[`getCurrentKeyboardInfo()`](getCurrentKeyboardInfo)
: returns information dictionary of the current keyboard
[`getDefaultKeyboard()`](getDefaultKeyboard)
: returns the keyboard information for the fallback keyboard
[`getFontTypeface()`](getFontTypeface)
: creates a new typeface from the specified font filename
[`getGlobeKeyAction()`](getGlobeKeyAction)
: returns the action type of the 'Globe' key
[`getHapticFeedback()`](getHapticFeedback)
: returns whether the device vibrates as the user types
~~`getKeyboardFontFilename()`~~ `(Deprecated)`
: use getKeyboardTextFontFilename or getKeyboardOskFontFilename instead
~~`getKeyboardFontTypeface()`~~ `(Deprecated)`
: use getKeyboardTextFontTypeface or getKeyboardOskFontTypeface instead
[`getKeyboardHeight()`](getKeyboardHeight)
: returns the height of the keyboard frame
[`getKeyboardIndex()`](getKeyboardIndex)
: returns index number of the specified keyboard in keyboards list
[`getKeyboardInfo()`](getKeyboardInfo)
: returns information dictionary of the specified keyboard
[`getKeyboardsList()`](getKeyboardsList)
: returns the array of keyboards list
[`getKeyboardOskFontFilename()`](getKeyboardOskFontFilename)
: returns the selected keyboard's OSK font filename
[`getKeyboardOskFontTypeface()`](getKeyboardOskFontTypeface)
: creates a new typeface from the selected keyboard's OSK font
[`getKeyboardState()`](getKeyboardState)
: returns the specified keyboard's state
[`getKeyboardTextFontFilename()`](getKeyboardTextFontFilename)
: returns the selected keyboard's text font filename
[`getKeyboardTextFontTypeface()`](getKeyboardTextFontTypeface)
: creates a new typeface from the selected keyboard's text font
[`getKMKeyboard()`](getKMKeyboard)
: returns the KMKeyboard depending whether it's an in-app or system keyboard
[`getLatestKeyboardFileVersion()`](getLatestKeyboardFileVersion)
: returns the specified keyboard's latest file version number
[`getLexicalModelInfo()`](getLexicalModelInfo)
: returns dictionary information of the specified lexical model
[`getLexicalModelsList()`](getLexicalModelsList)
: returns the array of lexical models list
[`getLanguageCorrectionPreferenceKey()`](getLanguageCorrectionPreferenceKey)
: returns a String to use as a shared preference key to store whether the LMLayer should enable corrections for a given language
[`getLanguagePredictionPreferenceKey()`](getLanguagePredictionPreferenceKey)
: returns a String to use as a shared preference key to store whether the LMLayer should enable suggestions for a given language.
[`getLongpressDelay()`](getLongpressDelay)
: returns from stored preference the number of milliseconds to trigger a longpress gesture
[`getMaySendCrashReport()`](getMaySendCrashReport)
: returns whether Keyman Engine is allowed to send crash reports over the network to sentry.keyman.com
[`getOrientation()`](getOrientation)
: returns the device's current orientation (Portrait vs Landscape)
[`getSpacebarText()`](getSpacebarText)
: returns the current text display pattern for the spacebar
[`getVersion()`](getVersion)
: returns the version number of Keyman Engine
[`getWindowDensity()`](getWindowDensity)
: returns the density of the window
[`getWindowSize()`](getWindowSize)
: returns the size of an area the window would occupy
[`hasConnection()`](hasConnection)
: returns whether the device has active network connection
[`hideSystemKeyboard()`](hideSystemKeyboard)
: hides the system OSK
[`initialize()`](initialize)
: initializes the Keyman manager
[`isDebugMode()`](isDebugMode)
: returns whether debugging of Keyman Engine is enabled
~~`isHelpBubbleEnabled()`~~ `(Deprecated)`
: returns whether the help bubble is enabled
[`isKeyboardLoaded()`](isKeyboardLoaded)
: returns whether the specified in-app or system keyboard is loaded
[`keyboardExists()`](keyboardExists)
: returns whether the specified keyboard exists in keyboards list
[`lexicalModelExists()`](lexicalModelExists)
: returns whether the specified lexical model exists in lexical models list
[`onConfigurationChanged()`](onConfigurationChanged)
: performs necessary actions in an InputMethodService's <code>onConfigurationChanged()</code>
[`onDestroy()`](onDestroy)
: performs necessary actions in an InputMethodService's <code>onDestroy()</code>
[`onPause()`](onPause)
: performs necessary actions in an Activity's <code>onPause()</code>
[`onResume()`](onResume)
: performs necessary actions in an Activity's <code>onResume()</code>
[`onStartInput()`](onStartInput)
: performs necessary actions in an InputMethodService's <code>onStartInput()</code>
[`registerAssociatedLexicalModel()`](registerAssociatedLexicalModel)
: registers a lexical model with the associated language ID
[`registerLexicalModel()`](registerLexicalModel)
: registers a lexical model to use with the LMLayer
[`removeKeyboard()`](removeKeyboard)
: removes the keyboard at specified position from the keyboards list
[`removeKeyboardDownloadEventListener()`](removeKeyboardDownloadEventListener)
: removes the specified listener from the list of keyboard download event listeners
[`removeKeyboardEventListener()`](removeKeyboardEventListener)
: removes the specified listener from the list of keyboard event listeners
[`sendOptionsToKeyboard()`](sendOptionsToKeyboard)
: sends options like longpress delay to the KeymanWeb keyboard
[`setCanAddNewKeyboard()`](setCanAddNewKeyboard)
: sets whether adding a new keyboard is allowed
[`setCanRemoveKeyboard()`](setCanRemoveKeyboard)
: sets whether removing a keyboard is allowed, like in the keyboard picker menu
[`setDebugMode()`](setDebugMode)
: enables or disables debugging of Keyman Engine
[`setDefaultKeyboard()`](setDefaultKeyboard)
: sets the keyboard information for the fallback keyboard
[`setGlobeKeyAction()`](setGlobeKeyAction)
: sets an action type for the 'Globe' key
[`setHapticFeedback()`](setHapticFeedback)
: sets whether the device vibrates as the user types
~~`setHelpBubbleEnabled()`~~ `(deprecated)`
: enables or disables the help bubble
[`setHTMLBanner()`](setHTMLBanner)
: sets the contents of an HTML banner for Keyman Engine to display when suggestions aren't available
[`setKeyboard()`](setKeyboard)
: sets the keyboard to be used
[`setKeyboardPickerFont()`](setKeyboardPickerFont)
: sets the font for the keyboard picker menu
~~`setKeymanLicense()`~~ `(Deprecated)`
: sets the developer license/key pair to unlock Keyman Engine
[`setLongpressDelay()`](setLongpressDelay)
: stores the longpress delay in milliseconds as a preference.
[`setMaySendCrashReport()`](setMaySendCrashReport)
: sets whether Keyman Engine can send crash reports over the network to sentry.keyman.com
[`setShouldAllowSetKeyboard()`](setShouldAllowSetKeyboard)
: sets whether Keyman Engine allows setting a keyboard other than the default keyboard
[`setShouldCheckKeyboardUpdates()`](setShouldCheckKeyboardUpdates)
: sets whether Keyman Engine should check for keyboard updates
[`setSpacebarText()`](setSpacebarText)
: sets the current text display pattern for the spacebar
[`shouldAllowSetKeyboard()`](shouldAllowSetKeyboard)
: returns whether Keyman Engine allows setting a keyboard other than the default keyboard
[`shouldCheckKeyboardUpdates()`](shouldCheckKeyboardUpdates)
: returns whether Keyman Engine should check for keyboard updates
[`showKeyboardPicker()`](showKeyboardPicker)
: displays the keyboard picker menu
~~`showLanguageList()`~~ `(Deprecated)`
: displays the language list
[`switchToNextKeyboard()`](switchToNextKeyboard)
: loads the next available keyboard in keyboards list
[`updateSelectionRange()`](updateSelectionRange)
: updates the selection range of the current context
[`updateText()`](updateText)
: updates the current context with the specified text

View file

@ -0,0 +1,47 @@
---
title: KMManager.initialize()
---
## Summary
The **`initialize()`** method initializes the Keyman manager.
## Syntax
``` javascript
KMManager.initialize(Context context, KeyboardType keyboardType)
```
### Parameters
`context`
: The context that starts the initialization. This is normally an
Activity or the application context of an InputMethodService.
`keyboardType`
: KeyboardType to be used. `KEYBOARD_TYPE_INAPP` or
`KEYBOARD_TYPE_SYSTEM`.
## Description
This method is normally called from `onCreate()` method of an Activity
or InputMethodService.
## Examples
### Example: Using `initialize()`
The following script illustrate the use of `initialize()`:
``` javascript
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// ...
KMManager.initialize(this, KeyboardType.KEYBOARD_TYPE_INAPP);
// ...
// do not call setContentView before initializing the Keyman manager.
setContentView(R.layout.activity_main);
// ...
}
```

View file

@ -0,0 +1,36 @@
---
title: KMManager.isDebugMode()
---
## Summary
The **`isDebugMode()`** method returns whether debugging of Keyman
Engine is enabled.
## Syntax
``` javascript
KMManager.isDebugMode()
```
### Returns
Returns `true` if debugging is enabled, `false` otherwise.
## Description
Use this method to check if debugging of Keyman Engine is enabled.
## Examples
### Example: Using `isDebugMode()`
The following script illustrate the use of `isDebugMode()`:
``` javascript
boolean isDebugEnabled = KMManager.isDebugMode();
```
## See also
- [`setDebugMode()`](setDebugMode)

View file

@ -0,0 +1,42 @@
---
title: KMManager.isHelpBubbleEnabled() (Deprecated)
---
## Summary
The **`isHelpBubbleEnabled()`** method returns whether the help bubble
is enabled.
## Syntax
``` javascript
KMManager.isHelpBubbleEnabled()
```
### Returns
Returns `true` if the help bubble is enabled, `false` otherwise.
## Description
Use this method to check if the help bubble is enabled. This method only
works for the in-app keyboard since the system-wide keyboard never
displays a help bubble.
## Examples
### Example: Using `isHelpBubbleEnabled()`
The following script illustrate the use of `isHelpBubbleEnabled()`:
``` javascript
boolean isHelpBubbleEnabled = KMManager.isHelpBubbleEnabled();
```
## History
Deprecated syntax in Keyman Engine for Android 16.0
## See also
- [`setHelpBubbleEnabled()`](setHelpBubbleEnabled) (Deprecated)

View file

@ -0,0 +1,44 @@
---
title: KMManager.isKeyboardLoaded()
---
## Summary
The **isKeyboardLoaded()** method returns whether the specified in-app or system keyboard is loaded.
## Syntax
```java
KMManager.isKeyboardLoaded(KeyboardType type)
```
### Parameters
type
: `KeyboardType.KEYBOARD_TYPE_INAPP` or `KeyboardType.KEYBOARD_TYPE_SYSTEM`
If type is `KeyboardType.KEYBOARD_TYPE_UNDEFINED`, the function will return `false`.
### Returns
Returns `true` if the specified keyboard is loaded, `false` otherwise.
## Description
Use this method to check if a keyboard is loaded and ready to use.
---
## Examples
### Example: Using isKeyboardLoaded
The following script illustrate the use of `isKeyboardLoaded`
```java
if (KMManager.isKeyboardLoaded(KeyboardType.KEYBOARD_TYPE_SYSTEM) {
// Get the keyboard info at index 0
Keyboard keyboardInfo = KMManager.getKeyboardInfo(this, 0)
}
```
## History
Added syntax in Keyman Engine for Android 14.0.
## See also
* [setKeyboard](setKeyboard)

View file

@ -0,0 +1,53 @@
---
title: KMManager.keyboardExists()
---
## Summary
The **`keyboardExists()`** method returns whether the specified keyboard
exists in keyboards list.
## Syntax
``` javascript
KMManager.keyboardExists(Context context, String keyboardID, String languageID)
```
### Parameters
`context`
: The context.
`keyboardID`
: ID of the keyboard.
`languageID`
: ID of the associated language.
### Returns
Returns `true` if the keyboard exists in keyboards list, `false`
otherwise.
## Description
Use this method to check if the keyboard with given keyboard ID and
language ID exists in keyboards list.
## Examples
### Example: Using `keyboardExists()`
The following script illustrate the use of `keyboardExists()`:
``` javascript
boolean keyboardExists = KMManager.keyboardExists(this, "tamil99m", "ta");
```
## See also
- [`getCurrentKeyboardIndex()`](getCurrentKeyboardIndex)
- [`getCurrentKeyboardInfo()`](getCurrentKeyboardInfo)
- [`getKeyboardIndex()`](getKeyboardIndex)
- [`getKeyboardInfo()`](getKeyboardInfo)
- [`getKeyboardsList()`](getKeyboardsList)

View file

@ -0,0 +1,42 @@
---
title: KMManager.lexicalModelExists()
---
## Summary
The **lexicalModelExists()** method returns whether the specified lexical model exists in lexical models list.
## Syntax
```java
bool KMManager.lexicalModelExists(Context context, String packageID, String languageID, String modelID)
```
### Parameters
`context`
: The context.
`packageID`
: ID of the package
`languageID`
: ID of the associated language
`modelID`
: ID of the lexical model
### Returns
Returns `true` if the lexical model exists in the lexical models list, otherwise `false`.
## Description
Use this method to determine if a lexical model with given package ID, language ID, and model ID exists in the lexical models list.
## Examples
### Example: Using lexicalModelExists()
The following script illustrate the use of `lexicalModelExists()`:
```java
// Determine if the specified lexical model exists for English (en)
boolean exists = KMManager.lexicalModelExists(context, "nrc.en.mtnt", "en", "nrc.en.mtnt");
```
## See also
* [`getLexicalModelInfo()`](getLexicalModelInfo)

View file

@ -0,0 +1,45 @@
---
title: KMManager.onConfigurationChanged()
---
## Summary
The **`onConfigurationChanged()`** method performs necessary actions in
an InputMethodService's `onConfigurationChanged()`.
## Syntax
``` javascript
KMManager.onConfigurationChanged(Configuration newConfig)
```
### Parameters
`newConfig`
: The new device configuration.
## Description
To be called from an InputMethodService's `onConfigurationChanged()`
method.
## Examples
### Example: Using `onConfigurationChanged()`
The following script illustrate the use of `onConfigurationChanged()`:
``` javascript
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
KMManager.onConfigurationChanged(newConfig);
// ...
}
```
## See also
- [`createInputView()`](createInputView)
- [`onStartInput()`](onStartInput)
- [`onDestroy()`](onDestroy)

View file

@ -0,0 +1,39 @@
---
title: KMManager.onDestroy()
---
## Summary
The **`onDestroy()`** method performs necessary actions in an
InputMethodService's `onDestroy()`.
## Syntax
``` javascript
KMManager.onDestroy()
```
## Description
To be called from an InputMethodService's `onDestroy()` method.
## Examples
### Example: Using `onDestroy()`
The following script illustrate the use of `onDestroy()`:
``` javascript
@Override
public void onDestroy() {
// ...
KMManager.onDestroy();
super.onDestroy();
}
```
## See also
- [`createInputView()`](createInputView)
- [`onStartInput()`](onStartInput)
- [`onConfigurationChanged()`](onConfigurationChanged)

View file

@ -0,0 +1,37 @@
---
title: KMManager.onPause()
---
## Summary
The **`onPause()`** method performs necessary actions in an Activity's
`onPause()`.
## Syntax
``` javascript
KMManager.onPause()
```
## Description
To be called from an Activity's `onPause()` method.
## Examples
### Example: Using `onPause()`
The following script illustrate the use of `onPause()`:
``` javascript
@Override
protected void onPause() {
super.onPause();
KMManager.onPause();
// ...
}
```
## See also
- [`onResume()`](onResume)

View file

@ -0,0 +1,37 @@
---
title: KMManager.onResume()
---
## Summary
The **`onResume()`** method performs necessary actions in an Activity's
`onResume()`.
## Syntax
``` javascript
KMManager.onResume()
```
## Description
To be called from an Activity's `onResume()` method.
## Examples
### Example: Using `onResume()`
The following script illustrate the use of `onResume()`:
``` javascript
@Override
protected void onResume() {
super.onResume();
KMManager.onResume();
// ...
}
```
## See also
- [`onPause()`](onPause)

View file

@ -0,0 +1,49 @@
---
title: KMManager.onStartInput()
---
## Summary
The **`onStartInput()`** method performs necessary actions in an
InputMethodService's `onStartInput()`.
## Syntax
``` javascript
KMManager.onStartInput(EditorInfo attribute, boolean restarting)
```
### Parameters
`attribute`
: Description of the type of text being edited.
`restarting`
: Set to true if we are restarting input on the same text field as
before.
## Description
To be called from an InputMethodService's `onStartInput()` method.
## Examples
### Example: Using `onStartInput()`
The following script illustrate the use of `onStartInput()`:
``` javascript
@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
// ...
super.onStartInput(attribute, restarting);
KMManager.onStartInput(attribute, restarting);
// ...
}
```
## See also
- [`createInputView()`](createInputView)
- [`onConfigurationChanged()`](onConfigurationChanged)
- [`onDestroy()`](onDestroy)

View file

@ -0,0 +1,36 @@
---
title: KMManager.registerAssociatedLexicalModel()
---
## Summary
The **registerAssociatedLexicalModel()** method registers a lexical model with the associated language ID.
## Syntax
```java
KMManager.registerAssociatedLexicalModel(String langId)
```
### Parameters
`langId`
: The BCP 47 language ID
### Returns
Returns `true` if a new lexical model is loaded (different from the currently loaded lexical model), `false` otherwise.
## Description
Use this method after switching keyboard languages so the LMLayer will load and use the correct lexical model for generating suggestions.
## Examples
### Example: Using `registerAssociatedLexicalModel()`
The following script illustrates the use of `registerAssociatedLexicalModel()`:
```java
String langId = "ta";
KMManager.registerAssociatedLexicalModel(langId);
```
## See also
* [getAssociatedLexicalModel()](getAssociatedLexicalModel)
* [registerLexicalModel()](registerLexicalModel)

View file

@ -0,0 +1,45 @@
---
title: KMManager.registerLexicalModel()
---
## Summary
The **registerLexicalModel()** method registers a lexical model to use with the LMLayer.
## Syntax
```java
KMManager.registerLexicalModel(HashMap<String, String> lexicalModelInfo)
```
### Parameters
`lexicalModelInfo`
: A dictionary of lexical model information with keys and values defined as `HashMap<String key, String value)`.
### Returns
Returns `true` if the lexical model was registered successfully, `false` otherwise.
## Description
Use this method to registers a lexical model so it will generate suggestions with an
associated keyboard of a matching language.
**Note:** When typing in a password field, the word suggestions are temporarily disabled.
## Examples
### Example: Using `registerLexicalModel()`
The following script illustrates the use of `registerLexicalModel()`:
```java
HashMap<String, String>lexicalModelInfo = new HashMap<String, String>();
lexicalModelInfo.put(KMManager.KMKey_PackageID, "example.ta.wordlist");
lexicalModelInfo.put(KMManager.KMKey_LanguageID, "ta");
lexicalModelInfo.put(KMManager.KMKey_LexicalModelID, "example.ta.wordlist");
lexicalModelInfo.put(KMManager.KMKey_LexicalModelVersion, "1.0");
KMManager.addLexicalModel(this, lexicalModelInfo);
KMManager.registerLexicalModel(lexicalModelInfo);
```
## See also
* [addLexicalModel()](addLexicalModel)
* [deregisterLexicalModel()](deregisterLexicalModel)

View file

@ -0,0 +1,48 @@
---
title: KMManager.removeKeyboard()
---
## Summary
The **`removeKeyboard()`** method removes the keyboard at specified
position from the keyboards list.
## Syntax
``` javascript
KMManager.removeKeyboard(Context context, int position)
```
### Parameters
`context`
: The context.
`position`
: 0-based position of the keyboard in the keyboards list.
### Returns
Returns `true` if the keyboard was removed successfully, `false`
otherwise.
## Description
Use this method to remove a keyboard from the keyboards list. If the
position is invalid, it will be ignored and the method will return
`false` without altering the keyboards list.
## Examples
### Example: Using `removeKeyboard()`
The following script illustrate the use of `removeKeyboard()`:
``` javascript
// Remove the second keyboard in the list
KMManager.removeKeyboard(this, 1);
```
## See also
- [`addKeyboard()`](addKeyboard)

View file

@ -0,0 +1,46 @@
---
title: KMManager.removeKeyboardDownloadEventListener()
---
## Summary
The **`removeKeyboardDownloadEventListener()`** method removes the
specified listener from the list of keyboard download event listeners.
## Syntax
``` javascript
KMManager.removeKeyboardDownloadEventListener(OnKeyboardDownloadEventListener listener)
```
### Parameters
`listener`
: The listener to be removed.
## Description
Use this method to remove the listener to stop receiving keyboard
download event notifications. The listener must be removed once you
finished with it.
## Examples
### Example: Using `removeKeyboardDownloadEventListener()`
The following script illustrate the use of
`removeKeyboardDownloadEventListener()`:
``` javascript
@Override
protected void onPause() {
super.onPause();
// ...
KMManager.removeKeyboardDownloadEventListener(this);
// ...
}
```
## See also
- [`addKeyboardDownloadEventListener()`](addKeyboardDownloadEventListener)

View file

@ -0,0 +1,45 @@
---
title: KMManager.removeKeyboardEventListener()
---
## Summary
The **`removeKeyboardEventListener()`** method removes the specified
listener from the list of keyboard event listeners.
## Syntax
``` javascript
KMManager.removeKeyboardEventListener(OnKeyboardEventListener listener)
```
### Parameters
`listener`
: The listener to be removed.
## Description
Use this method to remove the listener to stop receiving keyboard event
notifications. The listener must be removed once you finished with it.
## Examples
### Example: Using `removeKeyboardEventListener()`
The following script illustrate the use of
`removeKeyboardEventListener()`:
``` javascript
@Override
protected void onPause() {
super.onPause();
// ...
KMManager.removeKeyboardEventListener(this);
// ...
}
```
## See also
- [`addKeyboardEventListener()`](addKeyboardEventListener)

View file

@ -0,0 +1,41 @@
---
title: Summary
---
The **`method()`** method does . . .
## Syntax
``` javascript
KMManager.method(Param param1, Param param2)
```
### Parameters
`param1`
: Param details.
`param2`
: Param details.
### Returns
Details of return value if any
## Description
Description.
## Examples
### Example: Using `method()`
The following script illustrate the use of `method()`:
``` javascript
//Code here
```
## See also
- [`...`](sample_template)

View file

@ -0,0 +1,41 @@
---
title: KMManager.sendOptionsToKeyboard()
---
## Summary
The `sendOptionsToKeyboard()` method sends options like longpress delay to the KeymanWeb keyboard.
## Syntax
```java
KMManager.sendOptionsToKeyboard()
```
## Description
Use this method to update options in the KeymanWeb keyboard.
* Number of milliseconds to trigger a longpress gesture
This method requires a keyboard to be loaded for the values to take effect.
## Examples
### Example: Using `sendOptionsToKeyboard()`
The following code illustrates the use of `sendOptionsToKeyboard()`:
```java
int currentDelayTimeMS = 250;
// Store currentDelayTimeMS
KMManager.setLongpressDelay(currentDelayTimeMS);
// Apply the keyboard options
KMManager.sendOptionsToKeyboard();
```
## History
Keyman Engine for Android 18.0: New function.
## See also
* [getLongpressDelay](getLongpressDelay)
* [setLongpressDelay](setLongpressDelay)

View file

@ -0,0 +1,39 @@
---
title: KMManager.setCanAddNewKeyboard()
---
## Summary
The **`setCanAddNewKeyboard()`** method sets whether adding a new
keyboard is allowed.
## Syntax
``` javascript
KMManager.setCanAddNewKeyboard(boolean newValue)
```
### Parameters
`newValue`
: If `false`, adding a new keyboard is disabled.
## Description
Use this method to enable or disable '+' (add new keyboard) button in
the keyboard picker menu.
## Examples
### Example: Using `setCanAddNewKeyboard()`
The following script illustrate the use of `setCanAddNewKeyboard()`:
``` javascript
// Disable add new keyboard button.
KMManager.setCanAddNewKeyboard(false);
```
## See also
- [`canAddNewKeyboard`](canAddNewKeyboard)

View file

@ -0,0 +1,33 @@
---
title: KMManager.setCanRemoveKeyboard()
---
## Summary
The **setCanRemoveKeyboard()** method sets whether removing a keyboard is allowed, like in the keyboard picker menu.
## Syntax
```java
void KMManager.setCanRemoveKeyboard(boolean newValue)
```
## Parameters
`newValue`
: `true` if removing a keyboard is allowed, `false` otherwise.
## Description
Use this method to grant the end user permission to remove keyboards from the keyboard list. If set to `false`, the installed keyboard list is permanent.
## Examples
### Example: Using `setCanRemoveKeyboard()`
The following script illustrates the use of `setCanRemoveKeyboard()`:
```java
// Disable removing keyboards
KMManager.setCanRemoveKeyboard(false);
```
## See also
* [`canRemoveKeyboard()`](canRemoveKeyboard)

View file

@ -0,0 +1,39 @@
---
title: KMManager.setDebugMode()
---
## Summary
The **`setDebugMode()`** enables or disables debugging of Keyman Engine.
## Syntax
``` javascript
KMManager.setDebugMode(boolean value)
```
### Parameters
`value`
: Set `true` to enable debugging, `false` to disable.
## Description
Use this method to enable or disable log output generated by Keyman
Engine. By default debugging is disabled.
## Examples
### Example: Using `setDebugMode()`
The following script illustrate the use of `setDebugMode()`:
``` javascript
KMManager.setDebugMode(true);
// Debugging is now on
// Initialize KMManager here
```
## See also
- [isDebugMode()](isDebugMode)

View file

@ -0,0 +1,55 @@
---
title: KMManager.setDefaultKeyboard()
---
## Summary
The **setDefaultKeyboard()** method sets the keyboard information for the fallback keyboard.
## Syntax
```java
KMManager.setDefaultKeyboard(Keyboard keyboardInfo)
```
### Parameters
keyboardInfo
The keyboard information for the default keyboard.
## Description
The **setDefaultKeyboard()** method sets the keyboard information for the fallback keyboard. If Keyman Engine
has issues with a current keyboard, KMManager will switch to this fallback keyboard.
A fallback keyboard should also be defined if an app doesn't automatically add a keyboard (requires user selection).
**setDefaultKeyboard** should be called after KMManager.initialize().
## Examples
### Example: Using setDefaultKeyboard()
The following script illustrates the use of `setDefaultKeyboard()`:
```java
KMManager.initialize(getApplicationContext(), KMManager.KeyboardType.KEYBOARD_TYPE_INAPP);
// Set the default (fallback) keyboard if this app doesn't automatically call addKeyboard().
KMManager.setDefaultKeyboard(
new Keyboard(
"basic_kbdtam99", // Package ID - filename of the .kmp file
"basic_kbdtam99", // Keyboard ID
"Tamil 99 Basic", // Keyboard Name
"ta", // Language ID
"Tamil", // Language Name
"1.0", // Keyboard Version
null, // URL to help documentation if available
"", // URL to latest .kmp file
true, // Boolean to show this is a new keyboard in the keyboard picker
KMManager.KMDefault_KeyboardFont, // Font for the keyboard
KMManager.KMDefault_KeyboardFont) // Font for OSK
);
```
## History
Added syntax in Keyman Engine for Android 14.0.
## See also
* [getDefaultKeyboard](getDefaultKeyboard)

View file

@ -0,0 +1,58 @@
---
title: KMManager.setGlobeKeyAction()
---
## Summary
The **setGlobeKeyAction()** method sets the short-press action type for the 'Globe' key.
## Syntax
```java
KMManager.setGlobeKeyAction(KeyboardType kbType, int action)
```
### Parameters
type
: `KeyboardType.KEYBOARD_TYPE_INAPP` or `KeyboardType.KEYBOARD_TYPE_SYSTEM`
action
: The action type. `GLOBE_KEY_ACTION_SHOW_MENU`, `GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD`,
`GLOBE_KEY_ACTION_ADVANCE_TO_PREVIOUS_SYSTEM_KEYBOARD`, `GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD`,
`GLOBE_KEY_ACTION_SHOW_SYSTEM_KEYBOARDS`, `GLOBE_KEY_ACTION_DO_NOTHING`.
## Description
Use this method to set the short-press action type for the 'Globe' key. Even when the default action type is
set, Keyman Engine will still use the following default action types when only one Keyman keyboard is installed:
| KeyboardType | # Keyman Keyboards Installed | Globe Key Action Type |
|----------------------|:----------------------------:|------------------------------------------------------|
| KEYBOARD_TYPE_INAPP | 1 | GLOBE_KEY_ACTION_SHOW_MENU |
| KEYBOARD_TYPE_SYSTEM | 1 | GLOBE_KEY_ACTION_ADVANCE_TO_PREVIOUS_SYSTEM_KEYBOARD |
The action `GLOBE_KEY_ACTION_SHOW_MENU` displays the Keyman keyboard picker menu.
Other enabled system keyboards are also listed at the end of the menu</p>
The action `GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD` switches to the next Keyman keyboard (if more than 1 are installed).
Otherwise, the Keyman keyboard picker menu is displayed.
The action `GLOBE_KEY_ACTION_ADVANCE_TO_PREVIOUS_SYSTEM_KEYBOARD` switches to the previous system keyboard.
The action `GLOBE_KEY_ACTION_ADVANCE_TO_NEXT_SYSTEM_KEYBOARD` switches to the next system keyboard.
The action `GLOBE_KEY_ACTION_SHOW_SYSTEM_KEYBOARDS` brings up the Android input method picker and
can only be set for `KEYBOARD_TYPE_SYSTEM`.
## Examples
### Example: Using setGlobeKeyAction
The following script illustrate the use of `setGlobeKeyAction`
```java
// Tapping 'Globe' key will switch to the next keyboard
KMManager.setGlobeKeyAction(KeyboardType.KEYBOARD_TYPE_SYSTEM,
GlobeKeyAction.GLOBE_KEY_ACTION_SWITCH_TO_NEXT_KEYBOARD);
```
## See also
* [getGlobeKeyAction](getGlobeKeyAction)

View file

@ -0,0 +1,45 @@
---
title: KMManager.setHTMLBanner
---
## Summary
The **setHTMLBanner()** method sets the HTML banner content for Keyman Engine to display when suggestions aren't available.
## Syntax
```javascript
KMManager.setHTMLBanner(KeyboardType keyboardType, String content)
```
### Parameters
`keyboardType`
: KeyboardType to be used. `KEYBOARD_TYPE_INAPP` or `KEYBOARD_TYPE_SYSTEM`.
`content`
: HTML content formatted as a string.
### Returns
Returns `true` if HTML banner is set, `false` otherwise.
## Description
When suggestions aren't available for a keyboard, an HTML banner is displayed instead.
Use this method to specify the HTML content to display in the banner to theme your keyboard app.
If the banner theme references assets (like .svg or .css files), ensure you've also called [copyHTMLBannerAssets()](copyHTMLBannerAssets).
Note: The HTML banner needs to be updated whenever the keyboard is reloaded, so call this in `SystemKeyboard.onInitializeInterface(()`.
## Examples
### Example: Using `setHTMLBanner()`
The following script illustrates the use of `setHTMLBanner()`:
```javascript
String KMGRAY_BANNER = "<div style=\"background: #b4b4b8; width: 100%; height: 100%; position: absolute; left: 0; top: 0\"></div>";
// Sets the HTML banner content
KMManager.setHTMLBanner(KeyboardType.KEYBOARD_TYPE_SYSTEM, KMGRAY_BANNER);
```
## See also
* [copyHTMLBannerAssets()](copyHTMLBannerAssets)

View file

@ -0,0 +1,35 @@
---
title: KMManager.setHapticFeedback()
---
## Summary
The **setHapticFeedback()** method sets whether the device vibrates as the user types.
## Syntax
```java
KMManager.setHapticFeedback(boolean value)
```
### Parameters
value
Set `true` to enable device vibrating as the user types, `false` to disable.
## Description
Use this method to enable or disable haptic feedback. This determines if the device vibrates as the user types.
By default, haptic feedback is disabled.
## Examples
### Example: Using setHapticFeedback()
The following script illustrates the use of `setHapticFeedback()`:
```java
// Enable haptic feeedback
KMManager.setHapticFeedback(true);
```
## History
Keyman Engine for Android 15.0: New function.
## See also
* [getHapticFeedback](getHapticFeedback)

View file

@ -0,0 +1,44 @@
---
title: KMManager.setHelpBubbleEnabled() (Deprecated)
---
## Summary
The **`setHelpBubbleEnabled()`** enables or disables the help bubble.
## Syntax
``` javascript
KMManager.setHelpBubbleEnabled(boolean newValue)
```
### Parameters
`newValue`
: Set `true` to enable the help bubble, `false` to disable.
## Description
Use this method to enable or disable the help bubble which displays "Tap
here to change keyboard" over the 'Globe' key if the user has never used
it yet. By default it is enabled. This method only works for the in-app
keyboard since the system-wide keyboard never displays a help bubble.
## Examples
### Example: Using `setHelpBubbleEnabled()`
The following script illustrate the use of `setHelpBubbleEnabled()`:
``` javascript
KMManager.setHelpBubbleEnabled(false);
// Help bubble is now disabled
```
## History
Deprecated syntax in Keyman Engine for Android 16.0
## See also
- [isHelpBubbleEnabled()](isHelpBubbleEnabled) (Deprecated)

View file

@ -0,0 +1,155 @@
---
title: KMManager.setKeyboard()
---
## Summary
The `setKeyboard()` method sets the active keyboard.
## Syntax
```java
KMManager.setKeyboard(Context context, Keyboard keyboardInfo)
```
### Parameters
`context`
: The context.
`keyboardInfo`
: `Keyboard` type of the keyboard information. <!-- TODO: add Keyboard type documentation -->
### Returns
Returns `true` if the keyboard was set successfully, `false` otherwise.
## Description
Selects the keyboard identified by the keyboard information, which is
normally returned by [`getKeyboardInfo()`](getKeyboardInfo).
---
## Syntax
```java
KMManager.setKeyboard(String packageID, String keyboardID, String languageID)
KMManager.setKeyboard(String packageID, String keyboardID, String languageID, String keyboardName, String languageName, String kFont, String kOskFont)
KMManager.setKeyboard(String packageID, String keyboardID, String languageID, String keyboardName, String languageName, String kFont, String kOskFont, String displayName)
```
### Parameters
`packageID`
: ID of the keyboard package.
`keyboardID`
: ID of the keyboard.
`languageID`
: ID of the associated language.
`keyboardName`
: Name of the keyboard.
`languageName`
: Name of the associated language.
`kFont`
: Filename or description of the font to type with the keyboard. Can be `null`
or empty string.
`kOskFont`
: Filename or description of the font displayed on the keyboard. Can be `null`
or empty string.
`displayName`
: A text string to display on the spacebar identifying this keyboard; if `null`,
uses engine default from [`setSpacebarText()`](setSpacebarText); if `""`,
shows no text on the spacebar.
### Returns
Returns `true` if the keyboard was set successfully, `false` otherwise.
## Description
Sets the currently active keyboard, along with font and display details.
---
## Syntax
```
KMManager.setKeyboard(Context context, int position)
```
### Parameters
`context`
: The context.
`position`
: 0-based position of the keyboard in the keyboards list.
### Returns
Returns `true` if the keyboard was set successfully, `false` otherwise.
## Description
Sets the currently active keyboard by position in the keyboards list, as
returned by [`getKeyboardsList()`](getKeyboardsList)
---
## Examples
### Example 1: Using `setKeyboard()`
The following script illustrates the use of `setKeyboard()` with keyboard information:
```java
// Setting a Keyman keyboard
Keyboard keyboardInfo = KMManager.getDefaultKeyboard();
KMManager.setKeyboard(getApplicationContext(), keyboardInfo);
```
### Example 2: Using `setKeyboard()`
The following script illustrates the use of `setKeyboard()` with package ID,
keyboard ID, and language ID:
```java
// Setting a Keyman keyboard
KMManager.setKeyboard("sil_euro_latin", "sil_euro_latin", "en");
```
### Example 3: Using `setKeyboard()`
The following script illustrates the use of `setKeyboard()`, providing
additional font detail:
```java
// Setting a custom keyboard from the tamil99m keyboard package
KMManager.setKeyboard("tamil99m", "tamil99m", "ta", "Tamil 99M", "Tamil", "aava1.ttf", "aava1.ttf");
```
### Example 4: Using `setKeyboard()`
The following script illustrates the use of `setKeyboard()` with keyboard index:
```java
// Setting a custom keyboard which exists in keyboards list
int kbIndex = KMManager.getKeyboardIndex(this, "tamil99m", "ta");
KMManager.setKeyboard(this, kbIndex);
```
## See also
* [`addKeyboard()`](addKeyboard)
* [`getDefaultKeyboard()`](getDefaultKeyboard)
* [`getKeyboardInfo()`](getKeyboardInfo)
* [`getKeyboardsList()`](getKeyboardsList)
* [`switchToNextKeyboard()`](switchToNextKeyboard)

View file

@ -0,0 +1,33 @@
---
title: KMManager.setKeyboardPickerFont()
---
## Summary
The **`setKeyboardPickerFont()`** sets the font for the keyboard picker
menu.
## Syntax
``` javascript
KMManager.setKeyboardPickerFont(Typeface typeface)
```
### Parameters
`typeface`
: The font
## Description
Use this method to set a font for the keyboard picker menu.
## Examples
### Example: Using `setKeyboardPickerFont()`
The following script illustrate the use of `setKeyboardPickerFont()`:
``` javascript
KMManager.setKeyboardPickerFont(Typeface.createFromAsset(getAssets(), "fonts/custom_font.ttf"));
```

View file

@ -0,0 +1,47 @@
---
title: KMManager.setKeymanLicense() (Deprecated)
---
## Summary
(Deprecated) The **`setKeymanLicense()`** method sets the developer
license/key pair to unlock Keyman Engine.
## Syntax
``` javascript
KMManager.setKeymanLicense(String license, String key)
```
### Parameters
`license`
: Your developer license for Keyman Engine for Android.
`key`
: Your developer key for Keyman Engine for Android.
## Description
You must use this method to set the developer license/key pair before
initializing the KMManager. You will receive the license/key pair when
you purchase Keyman Engine for Android.
## Examples
### Example: Using `setKeymanLicense()`
The following script illustrate the use of `setKeymanLicense()`:
``` javascript
KMManager.setLicense(“YourLicense”,”YourKey”);
// Initialize KMManager here after setting the license
```
## History
Deprecated in Keyman Engine for Android 12.0
## See also
- [`KMManager.initialize()`](initialize)

View file

@ -0,0 +1,42 @@
---
title: KMManager.setLongpressDelay()
---
## Summary
The `setLongpressDelay()` method sets the number of milliseconds to trigger a longpress gesture as a stored preference.
## Syntax
```java
KMManager.setLongpressDelay(int longpressDelay)
```
### Parameter
`longpressDelay`
: The number of milliseconds, ranging from 300 ms to 1500 ms.
## Description
Use this method to store how many milliseconds to trigger a longpress as a preference.
This preference is stored at the Keyman app level, and is applied to all Keyman keyboards.
## Examples
### Example: Using `setLongpressDelay()`
The following code illustrates the use of `setLongpressDelay()`:
```java
int currentDelayTimeMS = 300;
// Store currentDelayTimeMS
KMManager.setLongpressDelay(currentDelayTimeMS);
// Apply the keyboard options
KMManager.sendOptionsToKeyboard();
```
## History
Keyman Engine for Android 18.0: New function.
## See also
* [getLongpressDelay](getLongpressDelay)
* [sendOptionsToKeyboard](sendOptionsToKeyboard)

View file

@ -0,0 +1,40 @@
---
title: KMManager.setMaySendCrashReport()
---
## Summary
The **setMaySendCrashReport()** enables or disables whether Keyman Engine can send crash reports over the
network to sentry.keyman.com.
## Syntax
```java
KMManager.setMaySendCrashReport(boolean value)
```
### Parameters
value
Set `true` to enable crash reports to be sent, `false` to disable.
## Description
Use this method to enable or disable whether Keyman Engine can send crash reports over the network.
By default sending crash reports is enabled.
If you don't want crash reports to be sent, your app must disable this before `KMManager.initialize()`.
## Examples
### Example: Using setMaySendCrashReport()
The following script illustrates the use of `setMaySendCrashReport()`:
```java
// Disable crash reports from being sent
KMManager.setMaySendCrashReport(false);
// Initialize KMManager
KMManager.initialize(getApplicationContext(), KeyboardType.KEYBOARD_TYPE_INAPP);
```
## History
Added syntax in Keyman Engine for Android 14.0.
## See also
* [getMaySendCrashReport](getMaySendCrashReport)

View file

@ -0,0 +1,44 @@
---
title: KMManager.setShouldAllowSetKeyboard()
---
## Summary
The **`setShouldAllowSetKeyboard()`** method sets whether Keyman Engine
allows setting a keyboard other than the default keyboard.
## Syntax
``` javascript
KMManager.setShouldAllowSetKeyboard(boolean value)
```
### Parameters
`value`
: If `false`, Keyman Engine will not allow setting a keyboard.
## Description
Use this method to enable or disable setting a keyboard other than the
default keyboard. If set to `false` Keyman Engine will immediately load
the default keyboard, and ignore calls to setKeyboard method. It is
particularly useful if used with Google Play Licensing service in order
to put the Keyman on-screen keyboard in a locked state if the paid app
is unlicensed.
## Examples
### Example: Using `setShouldAllowSetKeyboard()`
The following script illustrate the use of
`setShouldAllowSetKeyboard()`:
``` javascript
// Put Keyman on-screen keyboard in locked state if the app is unlicensed.
KMManager.setShouldAllowSetKeyboard(false);
```
## See also
- [`shouldAllowSetKeyboard`](shouldAllowSetKeyboard)

View file

@ -0,0 +1,40 @@
---
title: KMManager.setShouldCheckKeyboardUpdates()
---
## Summary
The **`setShouldCheckKeyboardUpdates()`** method sets whether Keyman
Engine should check for keyboard updates.
## Syntax
``` javascript
KMManager.setShouldCheckKeyboardUpdates(boolean newValue)
```
### Parameters
`newValue`
: If `false`, Keyman Engine will not check for keyboard updates.
## Description
Use this method to enable or disable keyboard updates when the keyboard
picker menu is displayed.
## Examples
### Example: Using `setShouldCheckKeyboardUpdates()`
The following script illustrate the use of
`setShouldCheckKeyboardUpdates()`:
``` javascript
// Disable keyboard updates.
KMManager.setShouldCheckKeyboardUpdates(false);
```
## See also
- [`shouldCheckKeyboardUpdates`](shouldCheckKeyboardUpdates)

View file

@ -0,0 +1,50 @@
---
title: KMManager.setSpacebarText()
---
## Summary
The `setSpacebarText()` method sets the text display pattern for the
spacebar.
## Syntax
```java
KMManager.setSpacebarText(KMManager.SpacebarText mode)
```
### Parameters
`mode`
: The display pattern to use for the spacebar, one of:
* `LANGUAGE` - the language name for the keyboard
* `KEYBOARD` - the keyboard name
* `LANGUAGE_KEYBOARD` - both the language name and the keyboard name,
separated by hyphen
* `BLANK` - no text to be displayed
### Returns
No return value.
## Description
The default text display pattern is `LANGUAGE_KEYBOARD`. The text shown on the
keyboard may be overridden on a per-keyboard basis with the `displayName`
parameter of the `setKeyboard()` function.
---
## Example: Using `setSpacebarText()`
The following script illustrates the use of `setSpacebarText()`:
```java
// don't show anything on the spacebar
KMManager.setSpacebarText(KMManager.SpacebarText.BLANK);
```
## See also
* [`getSpacebarText()`](getSpacebarText)

View file

@ -0,0 +1,43 @@
---
title: KMManager.shouldAllowSetKeyboard()
---
## Summary
The **`shouldAllowSetKeyboard()`** method returns whether Keyman Engine
allows setting a keyboard other than the default keyboard.
## Syntax
``` javascript
KMManager.shouldAllowSetKeyboard()
```
### Returns
Returns `true` if Keyman Engine allows setting a keyboard, `false`
otherwise.
## Description
Use this method to check if Keyman Engine allows setting a keyboard
other than the default keyboard.
## Examples
### Example: Using `shouldAllowSetKeyboard()`
The following script illustrate the use of `shouldAllowSetKeyboard()`:
``` javascript
if (KMManager.shouldAllowSetKeyboard()) {
// setting a keyboard is allowed
}
else {
// setting a keyboard is not allowed
}
```
## See also
- [`setShouldAllowSetKeyboard`](setShouldAllowSetKeyboard)

View file

@ -0,0 +1,41 @@
---
title: KMManager.shouldCheckKeyboardUpdates()
---
## Summary
The **`shouldCheckKeyboardUpdates()`** method returns whether Keyman
Engine should check for keyboard updates.
## Syntax
``` javascript
KMManager.shouldCheckKeyboardUpdates()
```
### Returns
Returns `true` if Keyman Engine should check for keyboard updates,
`false` otherwise.
## Description
Use this method to check if Keyman Engine should check for keyboard
updates when the keyboard picker menu is displayed.
## Examples
### Example: Using `shouldCheckKeyboardUpdates()`
The following script illustrate the use of
`shouldCheckKeyboardUpdates()`:
``` javascript
if (KMManager.shouldCheckKeyboardUpdates()) {
// checking keyboard updates is enabled
}
```
## See also
- [`setShouldCheckKeyboardUpdates`](setShouldCheckKeyboardUpdates)

View file

@ -0,0 +1,51 @@
---
title: KMManager.showKeyboardPicker()
---
## Summary
The **`showKeyboardPicker()`** method displays the keyboard picker menu.
## Syntax
``` javascript
KMManager.showKeyboardPicker(Context context, KeyboardType kbType)
```
### Parameters
`context`
: The context.
`kbType`
: The keyboard type. `KEYBOARD_TYPE_INAPP` or `KEYBOARD_TYPE_SYSTEM`.
## Description
Use this method to display keyboard picker menu. Normally you do not
need to call this method explicitly since, by default, Keyman on-screen
keyboard calls this method to display the keyboard picker menu whenever
'globe' key is tapped. Multiple calls to this method is unsafe and may
result in multiple instances of keyboard picker menu being displayed at
the same time.
## Examples
### Example: Using `showKeyboardPicker()`
The following script illustrate the use of `showKeyboardPicker()`:
``` javascript
final Context context = this;
ImageButton globeButton = (ImageButton) findViewById(R.id.globeButton);
globeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
KMManager.showKeyboardPicker(context, KMManager.KeyboardType.KEYBOARD_TYPE_INAPP);
}
});
```
## See also
- [`showLanguageList() (Deprecated)`](showLanguageList)

View file

@ -0,0 +1,50 @@
---
title: KMManager.showLanguageList() (Deprecated)
---
## Summary
(Deprecated) The **`showLanguageList()`** method displays the language
list.
## Syntax
``` javascript
KMManager.showLanguageList(Context context)
```
### Parameters
`context`
: The context.
## Description
The Keyman keyboard picker menu used to call this method to display the
language list whenever the '+' button was tapped. As of 14.0, keyboards
are no longer added this way, and this call is removed.
## Examples
### Example: Using `showLanguageList()`
The following script illustrate the use of `showLanguageList()`:
``` javascript
final Context context = this;
ImageButton languageButton = (ImageButton) findViewById(R.id.languageButton);
languageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
KMManager.showLanguageList(context);
}
});
```
## History
Deprecated syntax in Keyman Engine for Android 14.0
## See also
- [`showKeyboardPicker()`](showKeyboardPicker)

View file

@ -0,0 +1,46 @@
---
title: KMManager.switchToNextKeyboard()
---
## Summary
The **`switchToNextKeyboard()`** method loads the next available
keyboard in keyboards list.
## Syntax
``` javascript
KMManager.switchToNextKeyboard(Context context)
```
### Parameters
`context`
: The context.
## Description
Use this method to switch to next keyboard in the keyboards list. If the
next keyboard does not exists, then it loads the first keyboard in the
keyboards list.
## Examples
### Example: Using `switchToNextKeyboard()`
The following script illustrate the use of `switchToNextKeyboard()`:
``` javascript
final Context context = this;
ImageButton nextButton = (ImageButton) findViewById(R.id.nextButton);
nextButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
KMManager.switchToNextKeyboard(context);
}
});
```
## See also
- [`setKeyboard()`](setKeyboard)

View file

@ -0,0 +1,77 @@
---
title: KMManager.updateSelectionRange()
---
## Summary
The `updateSelectionRange()` method updates the selection range of the current context.
## Syntax
```java
KMManager.updateSelectionRange(KeyboardType kbType)
```
### Parameters
`kbType`
: Keyboard type requesting the selection range update. `KEYBOARD_TYPE_INAPP` or `KEYBOARD_TYPE_SYSTEM`.
### Returns
Returns `true` if the selection range was updated successfully, `false` otherwise.
## Description
Use this method to update the selection range of the current context. It must be called in response to InputMethodService's onUpdateSelection method and whenever InputMethodService's onStartInput method has been called. Normally you do not need to call this method for in-app keyboards.
----
## Syntax (Deprecated)
```javascript
KMManager.updateSelectionRange(KeyboardType kbType, int selStart, int selEnd)
```
### Parameters
`kbType`
: Keyboard type requesting the selection range update. `KEYBOARD_TYPE_INAPP` or `KEYBOARD_TYPE_SYSTEM`.
`selStart`
: The new selection start location.
`selEnd`
: The new selection end location.
### Returns
(Deprecated) Returns `true` if the selection range was updated successfully, `false` otherwise.
## Description
Use this method to update the selection range of the current context. It must be called in response to InputMethodService's onUpdateSelection method and whenever InputMethodService's onStartInput method has been called. Normally you do not need to call this method for in-app keyboards.
Since this syntax is deprecated, use `KMManager.updateSelectionRange(KeyboardType kbType)` syntax instead.
## Example: Using `updateSelectionRange()`
The following script illustrates the use of `updateSelectionRange()`:
```javascript
@Override
public void onUpdateSelection(int oldSelStart, int oldSelEnd, int newSelStart, int newSelEnd, int candidatesStart, int candidatesEnd) {
super.onUpdateSelection(oldSelStart, oldSelEnd, newSelStart, newSelEnd, candidatesStart, candidatesEnd);
KMManager.updateSelectionRange(KMManager.KeyboardType.KEYBOARD_TYPE_SYSTEM);
}
```
## History
Deprecated `updateSelectionRange(KeyboardType kbType, int selStart, int selEnd)` syntax in Keyman Engine for Android 17.0
## See also
* [`updateText()`](updateText)

View file

@ -0,0 +1,62 @@
---
title: KMManager.updateText()
---
## Summary
The **`updateText()`** method updates the current context with the
specified text.
## Syntax
``` javascript
KMManager.updateText(KeyboardType kbType, String text)
```
### Parameters
`kbType`
: Keyboard type requesting the context update. `KEYBOARD_TYPE_INAPP`
or `KEYBOARD_TYPE_SYSTEM`.
`text`
: The text to replace the current context.
### Returns
Returns `true` if the current context was updated successfully, `false`
otherwise.
## Description
Use this method to update the current context. It must be called in
InputMethodService's onStartInput method to match the current context
with the text in the editor. Normally you do not need to call this
method for in-app keyboards.
## Examples
### Example: Using `updateText()`
The following script illustrate the use of `updateText()`:
``` javascript
@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {
super.onStartInput(attribute, restarting);
// ...
InputConnection ic = getCurrentInputConnection();
if (ic != null) {
ExtractedText icText = ic.getExtractedText(new ExtractedTextRequest(), 0);
if (icText != null) {
KMManager.updateText(KeyboardType.KEYBOARD_TYPE_SYSTEM, icText.text.toString());
// ...
}
}
// ...
}
```
## See also
- [updateSelectionRange()](updateSelectionRange)

View file

@ -0,0 +1,38 @@
---
title: KeyboardEventHandler class
---
## Description
The KeyboardEventHandler class provides keyboard events and methods to
notify registered listeners on keyboard and lexical-model events.
## Events
### OnKeyboardEventListener Interface
[`onKeyboardLoaded()`](onKeyboardLoaded)
: is called when the keyboard has been loaded for the first time
[`onKeyboardChanged()`](onKeyboardChanged)
: is called when another keyboard has been set
[`onKeyboardShown()`](onKeyboardShown)
: is called when the keyboard has been shown
[`onKeyboardDismissed()`](onKeyboardDismissed)
: is called when the keyboard has been dismissed
### OnKeyboardDownloadEventListener Interface
[`onKeyboardDownloadStarted()`](onKeyboardDownloadStarted)
: is called when a keyboard download has started
[`onKeyboardDownloadFinished()`](onKeyboardDownloadFinished)
: is called when a keyboard download has finished
[`onPackageInstalled()`](onPackageInstalled)
: is called when a keyboard package has been installed
[`onLexicalModelInstalled()`](onLexicalModelInstalled)
: is called when a lexical-model package has been installed

View file

@ -0,0 +1,42 @@
---
title: onKeyboardChanged()
---
## Summary
The **`onKeyboardChanged()`** event is called when another keyboard has
been set.
## Syntax
``` javascript
public void onKeyboardChanged(String newKeyboard)
```
### Parameters
`newKeyboard`
: New keyboard identifier as languageID_keyboardID (e.g. eng_us).
## Description
Implement this method to handle keyboard changed event.
## Examples
### Example: Using `onKeyboardChanged()`
The following script illustrate the use of `onKeyboardChanged()`:
``` javascript
@Override
public void onKeyboardChanged(String newKeyboard) {
// handle keyboard changed event here
}
```
## See also
- [`onKeyboardDismissed()`](onKeyboardDismissed)
- [`onKeyboardLoaded()`](onKeyboardLoaded)
- [`onKeyboardShown()`](onKeyboardShown)

View file

@ -0,0 +1,37 @@
---
title: onKeyboardDismissed()
---
## Summary
The **`onKeyboardDismissed()`** event is called when the keyboard has
been dismissed.
## Syntax
``` javascript
public void onKeyboardDismissed()
```
## Description
Implement this method to handle keyboard dismissed event.
## Examples
### Example: Using `onKeyboardDismissed()`
The following script illustrate the use of `onKeyboardDismissed()`:
``` javascript
@Override
public void onKeyboardDismissed() {
// handle keyboard dismissed event here
}
```
## See also
- [`onKeyboardChanged()`](onKeyboardChanged)
- [`onKeyboardLoaded()`](onKeyboardLoaded)
- [`onKeyboardShown()`](onKeyboardShown)

View file

@ -0,0 +1,46 @@
---
title: onKeyboardDownloadFinished()
---
## Summary
The **`onKeyboardDownloadFinished()`** event is called when a keyboard
download has finished.
## Syntax
``` javascript
public void onKeyboardDownloadFinished(HashMap<String key, String value> keyboardInfo, int result)
```
### Parameters
`keyboardInfo`
: The information dictionary of the keyboard with keys and values
defined as `HashMap<String key, String value>`.
`result`
: The result of the download (result &gt; 0 if successful, &lt; 0 if
failed).
## Description
Implement this method to handle keyboard download finished event.
## Examples
### Example: Using `onKeyboardDownloadFinished()`
The following script illustrate the use of
`onKeyboardDownloadFinished()`:
``` javascript
@Override
public void onKeyboardDownloadFinished(HashMap<String key, String value> keyboardInfo, int result) {
// handle keyboard download finished event here
}
```
## See also
- [`onKeyboardDownloadStarted()`](onKeyboardDownloadStarted)

View file

@ -0,0 +1,42 @@
---
title: onKeyboardDownloadStarted()
---
## Summary
The **`onKeyboardDownloadStarted()`** event is called when a keyboard
download has started.
## Syntax
``` javascript
public void onKeyboardDownloadStarted(HashMap<String key, String value> keyboardInfo)
```
### Parameters
`keyboardInfo`
: The information dictionary of the keyboard with keys and values
defined as `HashMap<String key, String value>`.
## Description
Implement this method to handle keyboard download started event.
## Examples
### Example: Using `onKeyboardDownloadStarted()`
The following script illustrate the use of
`onKeyboardDownloadStarted()`:
``` javascript
@Override
public void onKeyboardDownloadStarted(HashMap<String key, String value> keyboardInfo) {
// handle keyboard download started event here
}
```
## See also
- [`onKeyboardDownloadFinished()`](onKeyboardDownloadFinished)

Some files were not shown because too many files have changed in this diff Show more