Change the languages, typing experience, and much more with this class.
The configuration applied to the keyboard SDK.
Constructor:
data class KeyboardConfiguration(
val language: LanguageConfiguration,
val typing: TypingConfiguration,
val privacy: PrivacyConfiguration,
val style: StyleConfiguration,
val features: FeaturesConfiguration,
val predictions: PredictionsConfiguration,
val legacy: LegacyConfiguration,
val capture: CaptureConfiguration,
val monitor: MonitorConfiguration,
val emoji: EmojiConfiguration,
val feedback: FeedbackConfiguration,
val customizationBundle: CustomizationBundleConfiguration
)
All constructor parameters are optional, falling back to a default configuration for that field. See each individual configuration class for details and defaults.
Class | Description |
---|---|
languageConfiguration | A data class holding the language configuration |
typingConfiguration | A data class holding the typing configuration |
privacyConfiguration | A data class holding the privacy configuration |
styleConfiguration | A data class holding the style configuration |
featuresConfiguration | A data class holding the features configuration |
predictionsConfiguration | A data class holding the predictions configuration |
legacyConfiguration | Legacy compatibility configuration options |
dataCaptureMode | A data class holding the capture configuration |
monitorConfiguration | A data class holding the monitor configuration |
emojiConfiguration | A data class holding the emoji configuration |
appsConfiguration | A data class holding the apps configuration |
licenseConfiguration | A data class holding the license configuration |
feedbackConfiguration | A data class holding the feedback configuration |
customizationBundleConfiguration | A data class holding the customization bundle configuration |
Example:
KeyboardConfiguration(
language = LanguageConfiguration(
current = KeyboardLanguage(“de-DE”, “QWERTZ”)
),
style = StyleConfiguration(
forceTheme = SystemThemes.lightTheme,
forceDarkTheme = SystemThemes.darkTheme
)
)
The language configuration applied to the keyboard engine.
Constructor:
data class LanguageConfiguration(
var current: KeyboardLanguage = DEFAULT_KEYBOARD_LANGUAGE,
val userLanguages: List<KeyboardLanguage> = listOf(current),
val automaticDownload: Boolean = false,
val repository: LanguageRepository = LanguageRepository.PRODUCTION
)
Name | Description | Type | Default |
---|---|---|---|
current | The current configured language | KeyboardLanguage | KeyboardLanguage(“en-US”, “QWERTY”) |
userLanguages | The list of languages that the user has configured | List |
listOf(current) |
automaticDownload | Whether the SDK can attempt to download the missing userLanguages. | Boolean | true |
repository | The language repository to obtain language packs. | LanguageRepository | LanguageRepository.PRODUCTION |
LanguageOrderMode | The order of the languages on the space bar | LanguageOrderMode | LanguageOrderMode.DYNAMIC |
Example:
LanguageConfiguration(
current = KeyboardLanguage(“de-DE”, “QWERTZ”),
userLanguages = listOf(
KeyboardLanguage(“de-DE”, “QWERTZ”),
KeyboardLanguage(“es-ES”)
),
automaticDownload = true,
repository = LanguageRepository.BETA
)
The typing configuration applied to the keyboard engine
Constructor:
data class TypingConfiguration(
val caseSensitive: Boolean = true,
val smartPunctuation: Boolean = false,
val autoCapsBox: Boolean = true,
val autoCorrect: Boolean = true,
val autoLearn: Boolean = true,
val allowBackspaceToUndoAC: Boolean = true,
val doubleSpaceTapAddsPunctuation: Boolean = true,
val tripleSpaceAddsSpaceKey: Boolean = true,
val holdMode: HoldMode = HoldMode.POP,
val maxPopColumns: Int = 4,
val longPressForAccents: Boolean = true,
val magicButtonIcon: Icon = Icon.EMOJI,
val magicButtonActions: List<Icon>? = null,
val magicButtonTypeface: Typeface? = null,
val isMinimal: Boolean = false,
val minimalGestures: Boolean = false,
val swipeTyping: Boolean = true,
val punctuationSymbols: List<String>? = null,
val swipeTriggerFactor: Float = 0.5f,
val swipeGesturesLength: Float = 1.0f,
val swipeRightToAddSpace: Boolean = true,
val spaceBarLanguageGesture: Boolean = true,
val spaceBarTypingGesture: Boolean = true,
val dragAndHoldToDelete: Boolean = false,
val invertSwipeGestures: Boolean = false,
val swipeLeftToDelete: Boolean = true,
val autoCorrectAfterPunctuation: Boolean = false
)
Name | Description |
---|---|
caseSensitive | When true, the keyboard keys are case sensitive. |
smartPunctuation | When true, spaces are added after punctuation symbols |
autoCapsBox | When true, automatically set the caps layout after a punctuation symbol or at the start of an input field. |
autoCorrect | When true, autocorrect words after pressing space. |
autoLearn | When true, manually corrected words are automatically learned for the keyboard session duration. |
allowBackspaceToUndoAC | When true, tapping the backspace key after an auto correction will undo the auto correction. |
doubleSpaceTapAddsPunctuation | When true, add a punctuation symbol after the user taps the spacebar twice. |
tripleSpaceAddsSpaceKey | When true, add a space after the user taps the spacebar three times or more. |
holdMode | The visual style when holding a key. Style can be any of the following: HoldMode.POP: Accents appear over the keyboard layout. HoldMode.LAYOUT: Accents appear on a new keyboardlayout. |
maxPopColumns | The number of columns used to show accents and symbols after holding a key with variations. |
longPressForAccents | When holdMode is HoldMode.LAYOUT, long pressing a key shows accents. |
magicButtonIcon | The default action for the special button on the left of the space bar. Action can be any of the following: Icon.EMOJI: Show the emoji panel Icon.COMMA: Type a comma character Icon.AC_TOGGLE: Toggle Autocorrection Icon.GLOBE: Switch to next language Icon.MIC_ON: Toggle voice-to-speech IME |
magicButtonActions | A list of available actions when holding the magic button, as described by their icon. Action can be any of the following: Icon.EMOJI: Show the emoji panel Icon.COMMA: Type a comma character Icon.AC_TOGGLE: Toggle Autocorrection Icon.GLOBE: Switch to next language Icon.MIC_ON: Toggle voice-to-speech IME When null shows the default actions for the magic button. |
isMinimal | NOT AVAILABLE When true, the bottom row of buttons is hidden |
minimalGestures | NOT AVAILABLE When true, enable swipe up/down gestures on the shift key to enable/disable the minimal mode |
swipeTyping | Whether swipe typing is enabled for dictionaries that support swipe typing. |
punctuationSymbols | A list of custom punctuation symbols when holding the punctuation button. The symbols will be ordered around the center of the key until they reach the edge of the keyboard. When null uses the punctuation symbols set for the current dictionary in use. |
swipeTriggerFactor | The distance factor the user needs to swipe in order to start a swipe typing gesture. The factor is in terms of the key’s width that the user pressed first, being 1.0 a full key’s width, 0.5 half key’s width, and so on. |
swipeGesturesLength | The distance factor for the gestures like swipe left, right, up or down. Usually between 0.1 and 1.9, where a factor of 1.0 is the baseline. |
A number smaller than 1.0 would reduce the distance required to trigger the gesture, and a number larger than 1.0 would increase the distance required to trigger the gesture. |
|
swipeRightToAddSpace | Whether a swipe right gesture, which adds a space, is enabled or not. Note: When minimal mode is enabled, this setting is always enabled. |
spaceBarLanguageGesture | Whether language gestures on the space bar are enabled when more than one user language is configured. |
spaceBarTypingGesture | Whether typing gestures (backspace / space) on the space bar are enabled when only one user language is set or spaceBarLanguageGesture is disabled. |
dragAndHoldToDelete | Whether the drag and hold to delete gesture is enabled or not. |
invertSwipeGestures | Whether the horizontal swipe gestures are inverted. |
swipeLeftToDelete | Whether a swipe left gesture, which performs a word delete, is enabled or not. Note: When minimal mode is enabled, this setting is always enabled. |
autoCorrectAfterPunctuation | Whether a word is autocorrected after a punctuation symbol is entered. |
customMagicAction | Set a custom magic button action. Note: when set, this overrides the magicButtonIcon setting. |
customMagicActions | Set a list of magic button actions when the magic button is long-pressed. Note: when set, this overrides the magicButtonActions setting. |
magicButtonTypeface | Set a specific typefont to be used by the magicButton only. If this is empty, the default one is the flicon.ttf, which has all the different icons in the keyboard. (by default this font is embeeded in the sdk) |
Example:
TypingConfiguration(
caseSensitive = true,
smartPunctuation = false,
autoCapsBox = true,
autoCorrect = true,
autoLearn = true,
doubleSpaceTapAddsPunctuation = true,
tripleSpaceAddsSpaceKey = true,
holdMode = HoldMode.POP,
maxPopColumns = 8,
longPressForAccents = true,
magicButtonIcon = Icon.COMMA,
magicButtonActions = listOf(Icon.EMOJI, Icon.COMMA, Icon.AC_TOGGLE)
isMinimal = false,
swipeTyping = true,
punctuationSymbols = listOf(“!”, “?”, “,”, “@”, “#”),
swipeTriggerFactor = 0.5f,
swipeGesturesLength = 1.0f,
swipeRightToAddSpace = true,
invertSwipeGestures = false
)
Fields:
Name | Type | Default Value |
---|---|---|
caseSensitive | Boolean | true |
smartPunctuation | Boolean | false |
autoCapsBox | Boolean | true |
autoCorrect | Boolean | true |
doubleSpaceTapAddsPunctuation | Boolean | true |
tripleSpaceAddsSpaceKey | Boolean | true |
holdMode | HoldMode | HoldMode.POP |
maxPopColumns | Int | 4 |
longPressForAccents | Boolean | true |
magicButtonIcon | Icon | Icon.EMOJI |
magicButtonActions | List |
null |
isMinimal | Boolean | false |
minimalGestures | Boolean | false |
swipeTriggerFactor | Float | 0.5 |
swipeGesturesLength | Float | 1.0 |
swipeRightToAddSpace | Boolean | true |
invertSwipeGestures | Boolean | false |
swipeLeftToDelete | Boolean | true |
autoCorrectAfterPunctuation | Boolean | false |
customMagicAction | MagicAction? | null |
customMagicActions | List |
null |
magicButtonTypeface | Typeface? | null |
MagicAction
A MagicAction sealed class that allows you to show and perform custom actions with custom icons.
sealed class MagicAction {
data class DefaultAction(
val icon: Icon,
val iconLabel: String = icon.text
) : MagicAction()
data class CustomAction(
val iconLabel: String,
val callback: () -> Unit
) : MagicAction()
}
DefaultAction | An action that mimics a normal magic button action, like showing the emoji panel. The icon field specifies the action and icon to use, see magicButtonIcon for the list of available actions. The iconLabel specifies a custom UTF8 character from the icons font (flicon.ttf) when set, otherwise it falls back to the default icon for the given action. |
CustomAction | An action that performs a custom operation when selected. The iconLabel specifies a custom UTF8 character from the icons font (flicon.ttf). The callback is an argument-less callback that will be invoked when the magic button is pressed or a magic action is selected after holding down the magic button. |
Example:
val magicAction = MagicAction.DefaultAction(Icon.EMOJI, “\u6832”)
val magicActions = listOf(
MagicAction.DefaultAction(Icon.MIC_ON),
MagicAction.CustomAction(“\u6833”) { PanelHelper.openApp(“giphy”) }
)
Example:
@Keep
data class TypingConfiguration(
...
val magicButtonTypeface: Typeface? = null,
customMagicAction = MagicAction.DefaultAction(
Icon.COMMA, //The button action will be typing a comma
Icon.IMOJI.text //The icon shown will be the "imoji" logo
),
customMagicActions = listOf(
//Action implicit in the icon enum. In this chase, change language.
MagicAction.DefaultAction(Icon.GLOBE),
//Action is read from the Icon.AC_OFF. The icon to be show is the code "\uE654"
MagicAction.DefaultAction(Icon.AC_OFF, "\uE654"),
//A custom action has an icon (in this case a custom icon code) and a function
MagicAction.CustomAction("\uE619"){
TODO("Do custom action")
}
),
...
}
The privacy configuration applied to the keyboard engine.
Constructor:
data class PrivacyConfiguration(
val trackingEnabled: Boolean = false,
val updateNoiseEstimation: Boolean = false,
val reportAnalytics: Boolean = false
)
trackingEnabled | When true, the keyboard will emit messages on EventBus with typing gesture events. Only for debugging purposes. |
updateNoiseEstimation | When true, store in shared preferences typing noise estimations. Only for debugging purposes. |
reportAnalytics | Whether it should send ReportAnalytics events. When enabled, it also enables updateNoiseEstimation in order to generate the report. |
Example:
PrivacyConfiguration(
trackingEnabled = true,
updateNoiseEstimation = true
)
Fields:
Name | Type | Default value |
---|---|---|
trackingEnabled | Booleanfalse | |
updateNoiseEstimation | Boolean | false |
reportAnalytics | Boolean | false |
The style configuration applied to the keyboard engine.
Notes:
Constructor:
data class StyleConfiguration(
val keyboardSize: KeyboardSize = KeyboardSize.MEDIUM,
val themeKey: String? = null,
val darkThemeKey: String? = null,
val userFont: KeyboardFont = KeyboardFont.ROBOT_REGULAR,
val useStandardLayoutSystem: Boolean = true,
val forceTheme: KeyboardTheme? = null,
val forceDarkTheme: KeyboardTheme? = null,
val themeImagesPath: String? = null,
val userImagesPath: String? = null,
val keyboardInsets: KeyboardInsets? = null,
val spacebarLogo: Drawable? = null,
val fitSpacebarLogo: Boolean = true,
val swipeDuration: Long = 800,
val hoverStyle: HoverStyle? = null,
val hoverTileSizeFactor: Float = 1.0,
val drawHomeRow: Boolean = false,
val spacebarStyle: SpacebarStyle = SpacebarStyle.Automatic,
val firstRowHints: Boolean = false,
val allRowsHints: Boolean = false,
val keyboardFontRation: Float = 1.0f
)
keyboardSize | The size (height) of the keyboard area, excluding the predictions bar, suggestions bar and navigation bar paddings. Can be any of: KeyboardSize.SMALL: up to 150dp height KeyboardSize.MEDIUM: up to 200dp height KeyboardSize.MEDIUM_BIG: up to 225 dp height KeyboardSize.BIG: up to 250dp height |
themeKey | The theme key from a themes.json file, when available either in assets or files folder. |
darkThemeKey | The dark theme key from a themes.json file when available either in assets or device files folder. |
keyboardTypeface | The typeface to use for the keyboard letters and symbols. |
useStandardLayoutSystem | When true, the letter keys width will maintain a fixed size, when possible, and keys on each row will be packed at the center. When false, the keys on each row will expand in width to fill the available space. |
forceTheme | Force the light theme with a prebuilt KeyboardTheme. |
forceDarkTheme | Force the dark theme with a prebuilt KeyboardTheme. |
themeImagesPath | The location within the device-credentials protected storage where the background images will be found. |
userImagesPath | The location within the device-credentials protected storage where the user background images will be found. |
keyboardInsets | The keyboard layout insets, in pixels, that add margins around the sides and bottom of the keyboard keys layout. This does not include the top bar, suggestions, or other panels like emojis or trackpad. |
animateTiles | Whether icon tiles used for hover should animate or not. |
spacebarLogo | A drawable to render over the spacebar when no multiple user languages are loaded. |
fitSpacebarLogo | Whether the drawable should be scaled to fit inside the spacebar area, maintaining its aspect ratio. When false, the drawable is centered on the spacebar key without scaling. |
spacebarStyle | The behavior for the spacebar in terms of style and labeling.Can be any of: SpacebarStyle.Automatic: Shows user languages when more than one configured. SpacebarStyle.LogoOnly: Shows logo always SpacebarStyle.LanguageOnly: Shows only the user languages when more than one configured, regardless of whether a logo has been set. SpacebarStyle.Custom: Custom class to optionally customize when to draw the spacebar key, the language labels, logo, and icons. |
swipeDuration | The lifetime of a point in the swipe trail line, in milliseconds. Shorter values produce shorter trail lines at the same swipe speed. |
hoverStyle | A style configuration of the hover bar that is displayed in key presses and hover panels to select additional symbols and accents. See HoverStyle for details. When null uses the hardcoded bar width set to 42dp and bar height set to 74dp. |
hoverTileSizeFactor | The factor applied to the enlarge letter effect when hovering over a key with a tile. Value usually between 0 and 2. Set to 0 to disable the letter scale factor. |
drawHomeRow | Whether a background should be drawn under the second row from the top. Uses the homeBackground color from the theme, when set, otherwise 85% transparency from the keyLetters color. |
firstRowHints | Whether hints should display on the top right corner of the key. Only for the first row, containing the numbers. |
allRowsHints | Whether hints should display on the top right corner of all keys. |
keyboardFontRatio | A ratio to show the keyboard letters bigger or smaller than the default size |
Example:
StyleConfiguration(
keyboardSize = KeyboardSize.MEDIUM,
userFont = KeyboardFont.GILROY_MEDIUM,
useStandardLayoutSystem = true,
forceTheme = SystemThemes.lightTheme,
forceDarkTheme = SystemThemes.darkTheme,
keyboardInsets = KeyboardInsets(left=SIDE_MARGIN_PX, right=SIDE_MARGIN_PX),
spacebarLogo = ContextCompat.getDrawable(context, R.drawable.logo),
fitSpacebarLogo = true,
swipeDuration = 300,
hoverStyle = HoverStyle.FactorSizeBar(
widthFactor = 1.1f,
heightFactor = 1.75f,
maxWidth = resources.getDimensionPixelOffset(R.dimen.max_hover_width),
maxHeight = resources.getDimensionPixelOffset(R.dimen.max_hover_height)
),
hoverTileSizeFactor = 1.0f,
drawHomeRow = false
)
Fields:
Name | Type | Default value |
---|---|---|
keyboardSize | KeyboardSize | KeyboardSize.MEDIUM |
themeKey | String? | null |
darkThemeKey | String? | null |
keyboardTypeface | Typeface | null |
useStandardLayoutSystem | Boolean | false |
forceTheme | KeyboardTheme? | null |
forceDarkTheme | KeyboardTheme? | null |
keyboardInsets | KeyboardInsets? | null |
animateTiles | Boolean | true |
spacebarLogo | Drawable? | null |
fitSpacebarLogo | Boolean | true |
swipeDuration | Long | 800 |
hoverStyle | HoverStyle? | null |
hoverTileSizeFactor | Float | 1.0 |
drawHomeRow | Boolean | false |
firstRowHints | Boolean | false |
allRowsHints | Boolean | false |
keyboardFontRatio | Float | 1.0 |
A sealed class to customize the hover bar for key presses and hover panels.
A fixed size hover bar style.
width | The width, in pixels, of the hover bar. |
height | The height, in pixels, of the hover bar. |
Example:
HoverStyle.FixedSizeBar(
width = resources.getDimensionPixelOffset(R.dimen.hover_bar_width),
height = resources.getDimensionPixelOffset(R.dimen.hover_bar_height)
)
A factor size hover bar style. The width or height of the hover bar is set to the given factor of the largest letter key’s width or height of the active keyboard layout.
widthFactor | The factor width of the hover bar in respect to the largest key’s width of the active keyboard layout. A factor of 1.0 will match the width of the widest letter key of the active layout, while, for example, a 0.5 factor will render a hover bar at half the width of the widest letter key of the active layout. |
heightFactor | The factor height of the hover bar in respect to the largest key’s height of the active keyboard layout. A factor of 1.0 will match the height of the tallest letter key of the active layout, while, for example, a 0.5 factor will render a hover bar at half the height of the tallest letter key of the active layout. |
maxWidth | An optional width limit, in pixels. |
maxHeight | An optional height limit, in pixels |
Example:
HoverStyle.FactorSizeBar(
widthFactor = 1.1f,
heightFactor = 1.75f,
width = resources.getDimensionPixelOffset(R.dimen.hover_max_width),
height = resources.getDimensionPixelOffset(R.dimen.hover_max_height)
)
A custom class to draw hover keys and hold panels.
Notes:
Inferface:
abstract class Custom : HoverStyle() {
val listener: Listener? = null
val context: Context? = null
val keyboardBounds: RectF? = null
val theme: KeyboardTheme? = null
val typeface: Typeface? = null
var hoverKey: Key? = null
var holdKey: Key? = null
val isReady : Boolean
val isHover : Boolean
val isHold : Boolean
abstract val willDrawCustomHover: Boolean
abstract val willDrawCustomHoldPanel: Boolean
open fun onDraw(canvas: Canvas) {}
open fun onHoverStart() {}
open fun onHoverEnd() {}
open fun onHoldStart() {}
open fun onHoldEnd() {}
open fun onHoldDrag(x: Float, y: Float) : Boolean = true
open fun onHoldRelease(): String? = null
open fun onThemeChanged(theme: KeyboardTheme) {}
}
listener | A listener instance that can be used to perform operations on the keyboard related to the custom hover. Available once the keyboard becomes visible. |
context | A context related to the keyboard view. Available once the keyboard becomes visible. |
keyboardBounds | The bounds of the keyboard that the keys are drawn into. Available once the keyboard becomes visible. |
typeface | The typeface used for key labels. Available once the keyboard becomes visible. |
hoverKey | The current key being pressed, or null when no key is being pressed. |
holdKey | The current key that is being held and has alternate labels, or null when not in hold mode. |
isReady | A helper function that determines if the custom HoverStyle has been initialized. |
isHover | A helper function to determine if a key is being pressed. |
isHold | A helper function to determine if a key is being held. |
willDrawCustomHover | A required getter that determines if the custom HoverStyle class will draw the key presses itself, otherwise let the SDK draw the hover. |
willDrawCustomHoldPanel | A required getter that determines if the custom HoverStyle class will draw the hold panel itself, otherwise let the SDK draw the panel. |
onDraw | A method invoked every time the keyboard is redrawing. Draw any required hovers or panels in this step. |
onHoverStart | A method invoked when a key is pressed. |
onHoverEnd | A method invoked when a key is released. |
onHoldStart | A method invoked when a key with alternate labels is held. |
onHoldEnd | A method invoked when a key is no longer held. |
onHoldDrag | A method invoked when a pointer is dragged while a key is being held. |
onHoldRelease | A method invoked when a pointer is released after a key was held, which optionally returns the selected alternate label to be sent to the input editor. |
onThemeChanged | A method invoked when the theme of the keyboard might have changed. |
Example:
class MyCustomHover : HoverStyle.Custom() {
private val tempRect = Rect();
override val willDrawCustomHover: Boolean get() = true
override val willDrawCustomHoldPanel: Boolean get() = false
private val drawable by lazy {
context?.let {
ContextCompat.getDrawable(it, R.drawable.circle)
}
}
override fun onDraw(canvas: Canvas) {
hoverKey?.also { key ->
if (!key.isButton) {
drawable?.apply {
tempRect.set(
key.x.toInt() - intrinsicWidth / 2,
key.y.toInt() - intrinsicHeight / 2,
key.x.toInt() + intrinsicWidth / 2,
key.y.toInt() + intrinsicHeight / 2
)
bounds = tempRect
draw(canvas)
}
listener?.drawText(canvas, key.x, key.y, key.label, Color.WHITE)
}
}
}
}
An interface accessible from a custom HoverStyle to request operations to the keyboard view.
interface Listener {
fun redraw()
fun drawText(
canvas: Canvas,
x: Float,
y: Float,
label: String,
@ColorInt letterColor: Int? = null
)
}
redraw | Schedule a redraw of the keyboard view. Usually used inside update callbacks of an animator. |
drawText | A convenience method to draw a key label in the same size and format as the keyboard view, with an optional color. When letterColor is null, the theme’s keyLetters color is used. |
drawIcon | |
A convenience method to draw a key label using the icon font in the same size and format as the keyboard view, with an optional color. When letterColor is null, the theme’s keyLetters color is used. Must be used for hold panels where the hold key’s isMagicButton is true. |
A representation of the key being pressed.
data class Key(
val x: Float,
val y: Float,
val width: Float,
val height: Float,
val label: String,
val labels: List<String>,
val isButton: Boolean
)
x | The horizontal center of the key. |
y | The vertical center of the key. |
width | The width of the key, without spacing or margins. |
height | The height of the key, without spacing or margins. |
label | The label on the key. |
labels | The alternate labels, like accents or symbols, for the key. |
isButton | Whether the key is considered a button. Key presses are usually only visible in non-button keys. |
isMagicButton | Whether the key is a magic button. Magic buttons behave like a button, but when long pressed and drawing the hold panel, the labels inside a magic button should be drawn using the drawIcon method. |
A sealed class to customize the space bar.
Automatically draws the logo or the user languages:
Draw the logo when available, otherwise show a clean space bar.
The current language or the user languages configured by the user will not be displayed on the spacebar. It will still recognize the swipe left and right gestures on the spacebar to change the language, but it won’t display the change.
Draw the languages on the space bar when the user has configured 2 or more languages.
When the user has only one configured language, it will display an empty space bar, regardless if a logo for the space bar has been configured or not.
A custom class to draw a spacebar keycap, languages and/or icons.
Notes:
Interface:
abstract class Custom : SpacebarStyle() {
var listener : Listener? = null
var context : Context? = null
var theme : KeyboardTheme? = null
val state : State = State()
abstract val willDrawKeycap: Boolean
abstract val willDrawLanguages: Boolean
abstract val willDrawIcons: Boolean
open fun onLanguageSet(currentLanguage: String, languages: Set<String>) {}
open fun onStateUpdated(state: State) {}
open fun onThemeSet(theme: KeyboardTheme) {}
open fun onDrawKeyCap(canvas: Canvas) {}
open fun onDrawLabels(canvas: Canvas) {}
open fun onDrawIcons(canvas: Canvas) {}
interface Listener {
fun redraw()
}
data class State(
var x: Float = 0f,
var y: Float = 0f,
var width: Float = 0f,
var height: Float = 0f,
var pressed: Boolean = false,
var autoCorrectEnabled: Boolean = false,
var currentLanguage: String = String.empty(),
var sortedUserLanguages: Set<String> = emptySet()
)
}
listener | A listener instance that can be used to perform operations on the keyboard related to the spacebar. Available once the keyboard becomes visible. |
context | A context related to the keyboard view. Available once the keyboard becomes visible. |
state | The current spacebar and languages state. |
willDrawKeycap | Whether the custom spacebar style will draw the spacebar keycap. When false, the SDK will draw the keycap. |
willDrawLanguages | Whether the custom spacebar style will draw the languages and/or logo on the spacebar. When false, the SDK will draw the keycap on the Automatic mode. |
willDrawIcons | Whether the custom spacebar style will draw the icons, such as when the auto-correction is disabled. |
onLanguageSet | Invoked when either the current language is set, has changed, or the user languages changed. |
onStateUpdated | Invoked when the spacebar pressed state has changed or when the auto-correction enabled status has changed. |
onThemeSet | Invoked when the theme has been set or when the theme has changed. |
onDrawKeyCap | Invoked when willDrawKeycap is true to draw the spacebar keycap. |
onDrawLabels | Invoked when willDrawLanguages is true to draw the spacebar languages and/or logo. |
onDrawIcons | Invoked when willDrawIcons is true to draw the spacebar icons. |
Example:
private val spaceBarExample: SpacebarStyle = object : SpacebarStyle.Custom() {
override val willDrawIcons: Boolean get() = true
override val willDrawKeycap: Boolean get() = true
override val willDrawLanguages: Boolean get() = true
private val keyPaint = Paint()
private val keyPaintPressed = Paint()
private val labelPaint = Paint().apply { textAlign = CENTER; textSize = 14f }
private val iconPaint = Paint().apply { textAlign = RIGHT; textSize = 10f }
private var keyRect: RectF = RectF()
override fun onThemeSet(theme: KeyboardTheme) {
keyPaint.color = Color.RED
keyPaintPressed.color = Color.BLUE
labelPaint.color = Color.BLACK
iconPaint.color = Color.BLACK
onStateUpdated(state)
}
override fun onStateUpdated(state: State) {
val hs = context?.dp2px((theme?.keycapSpacingHorizontal ?: 0f)) ?: 0f
val vs = context?.dp2px((theme?.keycapSpacingVertical ?: 0f)) ?: 0f
keyRect.set(
state.x - state.width / 2f + hs,
state.y - state.height / 2f + vs,
state.x + state.width / 2f - hs,
state.y + state.height / 2f - vs
)
labelPaint.textSize = keyRect.height() / 3f
iconPaint.textSize = keyRect.height() / 6f
}
override fun onDrawKeyCap(canvas: Canvas) {
canvas.drawRect(keyRect, if (state.pressed) keyPaintPressed else keyPaint)
}
override fun onDrawLabels(canvas: Canvas) {
canvas.drawText(state.currentLanguage, state.x, state.y, labelPaint)
}
override fun onDrawIcons(canvas: Canvas) {
if (!state.autoCorrectEnabled) {
canvas.drawText("AC OFF", keyRect.right, keyRect.bottom, iconPaint)
}
}
}
The features configuration applied to the keyboard engine.
Constructor:
data class FeaturesConfiguration(
val suggestions: Boolean = true,
val suggestionGestures: Boolean = suggestions,
val nsp: Boolean = false,
val emojiPrediction: Boolean = false,
val textToSpeech: Boolean = false,
val speechMode: SpeechMode = SpeechMode.SystemIME,
val maxTextToSpeechQueuedUtterances: Int = 2,
val numberRow: Boolean = false
)
suggestions | When true, show suggestions bar between keyboard area and the predictions bar, allowing the addition and removal of words to the user dictionary. |
suggestionGestures | When true, handle up and down gestures for dictionary events. |
nsp | When true, perform additional prediction types. |
emojiPrediction | When true and nsp set to true, perform emoji predictions |
textToSpeech | When true, words typed and some key actions are spoken for accessibility reasons. |
speechMode | The Speech To Text mode to use, can be any of: SpeechMode.SystemIME, SpeechMode.Recognizer |
maxTextToSpeechQueuedUtterances | The max number of queued utterances. When the queued utterances reaches this number, older queued utterances are dequeued. |
numberRow | Boolean to enable or disable the number row. By default, this is disabled. |
Example:
FeaturesConfiguration(
suggestions = false,
nsp = false,
emojiPrediction = false,
textToSpeech = false,
speechMode = SpeechMode.Recognizer
)
Fields
Name | Type | Default value |
---|---|---|
suggestions | Boolean | true |
suggestionGestures | Boolean | value set on field suggestions |
nsp | Boolean | false |
emojiPrediction | Boolean | false |
textToSpeech | Boolean | false |
speechMode | SpeechMode | SpeechMode.SystemIME |
SpeechMode
SystemIME | Use the configured device’s text to speech input method service. |
Recognizer | Use the SDK bundled text to speech method. |
The predictions configuration applied to the keyboard engine.
Constructor:
data class PredictionsConfiguration(
val predictionTypes: List<PredictionModelType> = listOf(PredictionModelType.WORD),
val predictionStrategy: PredictionStrategy = CoreContainerStrategy(),
val showEnteredText: Boolean = true,
val showEmojiSuggestions: Boolean = false
)
predictionTypes | |
predictionStrategy | A strategy to display predictions on the prediction bar. Defaults to generic strategy to show 3 predictions at a time. |
showEnteredText | Whether it shall receive predictions for currently entered word or not (ENTERED_TEXT and ENTERED_TEXT_AUTO_CORRECTION) |
showEmojiSuggestions | Whether the engine shall generate emoji suggestions. |
Example:
PredictionsConfiguration(
keyboardApps = emptyList(),
predictionTypes = listOf(PredictionModelType.WORD, PredictionModelType.EMOJI)
)
Fields:
Name | Type | Default value |
---|---|---|
keyboardApps | List |
emptyList() |
predictionTypes | List |
|
predictionStrategy | PredictionStrategy | CorePredictionStrategy() |
showEnteredText | Boolean | true |
showEmojiSuggestions | Boolean |
In order to create a custom prediction rendering, the PredictionStrategy interface can be used to create it.
PredictionStrategy:
interface PredictionStrategy {
fun setNextWordPredictionEnabled(enabled: Boolean)
fun init(parent: FrameLayout, listener: PredictionListener)
fun onPredictionsChanged(predictions: List<PredictionModel>)
fun addNextSearch(search: PredictionModel.Search)
fun reset()
fun onThemeChanged(theme: KeyboardTheme)
}
PredictionListener:
interface PredictionListener {
fun emojiClicked(emoji: String)
fun wordClicked(nextWord: PredictionModel.Word)
}
For convenience, a DefaultPredictionStrategy class is provided with each method of the interface implemented with an empty function. This avoids future changes to the interface that do not require implementation.
Example usage:
private val predictionStrategy: PredictionStrategy by lazy {
object : PredictionStrategy.DefaultPredictionStrategy() {
lateinit var listener: PredictionListener
lateinit var firstPrediction: TextView
override fun init(parent: FrameLayout, listener: PredictionListener) {
this.listener = listener
firstPrediction = TextView(parent.context)
parent.addView(firstPrediction)
}
override fun onPredictionsChanged(predictions: List<PredictionModel>) {
var wordPredictions = predictions.filterIsInstance<PredictionModel.Word>()
wordPredictions.firstorNull()?.also { prediction ->
firstPrediction.text = prediction.content
firstPrediction.setOnClickListener { listener.wordClicked(prediction) }
}
}
override fun reset() {
firstPrediction.text = ""
}
override fun onThemeChanged(theme: KeyboardTheme) {
firstPrediction.setTextColor(theme.keyLetters)
}
}
}
The PredictionModel items received in onPredictionsChanged can be any of:
PredictionModel.Word( text: String, type: PredictionWordType ) |
A word prediction with the word inside the text field, and a type of word prediction. |
PredictionModel.Emoji(text: String) |
The PRedictionWordType can be any of:
ENTERED_TEXT | The word currently being typed. When sent via wordClicked of the listener, it will be added to the user dictionary and a dictionary event sent with the word added. |
ENTERED_TEXT_AUTO_CORRECTION | The word currently being typed that is available in the dictionary. It will not be added to the user dictionary. |
AUTO_CORRECTION | A prediction of what will be auto-corrected if the user pressed space. |
SUGGESTION | A suggested prediction for the current word. |
EMOJI | An emoji prediction that will replace the text currently being typed. |
The legacy configuration applied to the keyboard engine.
Notes:
Constructor:
data class LegacyConfiguration(
val useLegacyLayout: Boolean = false,
val useAllAccents: Boolean = false,
val swapEnterDelete: Boolean = false
)
Name | Description | Type | Default |
---|---|---|---|
useLegacyLayout | [DEPRECATED] When true, use a legacy layout where shift and delete buttons are placed on the bottom row. |
Boolean | false |
useAllAccents | [DEPRECATED] When true, holding on a key will show all possible accents, and not only the common accents for the current language. |
Boolean | false |
swapEnterDelete | [DEPRECATED] When true and useLegacyLayout is also true, the delete and enter keys are swapped. |
Boolean | false |
The capture configuration applied to the keyboard engine.
Note:
There are two different modes of data capture:
Both modes are mutually exclusive.
Event-based data capture continuously collects data throughout a keyboard session, whereas Session-based data capture accumulates all the data for a keyboard session and provides a report at the session’s end.
EventBased | Configuration for the Event-based data capture using the EventDataConfiguration object. |
SessionBased | Configuration for the Session-based data capture. |
Enable the event-based data capture.
Constructor:
data class DataCaptureMode.EventBased(
EventDataConfiguration(
keyStroke = true,
delete = true,
keyPlane = true,
word = true,
swipe = true,
sessionUpdate = true,
stressUpdate = true
)
sessionUpdate | Enable the reception of any changes made during the session. |
keyStroke | Enable the reception of any keystroke from the user. |
word | Enable the reception of all different words. |
delete | Enable the reception of all the delete data. |
swipe | Enable the reception of swipe data. |
keyPlane | Enable the reception of keyplane data. |
stressUpdate | Enable the reception of stress data. |
Check all the data components here.
Notes:
Constructor:
data class CaptureConfiguration(
val enabled: Boolean = false,
val logEvents: Boolean = false,
val sendDataEvents: Boolean = false,
val storeData: Boolean = true,
val location: String = ”resources”,
val dataConfiguration: FLDataConfiguration = FLDataConfiguration()
)
enabled | When true, store captured data in the provided location. |
logEvents | When true, log data events and files are created in the console. |
sendDataEvents | When true, emit the event GenericDataEvent.Session with the data. |
storeData | When true, store the data session to disk. |
location | The path relative to the application files directory. |
dataConfiguration | The data capture configuration, see FLDataConfiguration |
Example:
CaptureConfiguration(
enabled = true,
logEvents = BuildConfig.DEBUG,
location = “captures”,
dataConfiguration = FLDataConfiguration(dataText = false)
)
Fields:
Name | Type | Default value |
---|---|---|
enabled | Boolean | false |
logEvents | Boolean | false |
location | String | “resources” |
dataConfiguration | FLDataConfiguration | FLDataConfiguration() |
The data capture configuration.
Constructor:
data class FLDataConfiguration(
val dataText: Boolean = true,
val dataSwipe: Boolean = true,
val dataEmoji: Boolean = true,
val dataLayout: Boolean = true,
val dataTextField: Boolean = true,
val dataLanguage: Boolean = true,
val dataType: Boolean = true,
val dataArea: Boolean = true,
val dataCode: Boolean = true,
val dataPosition: Boolean = true,
val dataPress: Boolean = true,
val dataKeyPress: Boolean = true,
val dataKeyCenter: Boolean = true,
val dataKeyBounds: Boolean = true,
val dataConfigCoordinate: Int = DataConfigCoordinate.SCREEN_PIXEL
)
dataText | Capture all the written text |
dataSwipe | Capture all swipes of the user |
dataEmoji | Capture all emojis with all hex values of them |
dataLayout | Layout parameter: QWERTY, AZERTY, … |
dataTextField | Field where the user is typing. Specified in detail in the specs |
dataLanguage | Capture the current language of the user |
dataType | Capture the type, which is a specific parameter |
dataArea | Capture the area, which is another specific parameter |
dataCode | Capture the code of the key pressed. |
dataPosition | Capture positions from the center of the key |
dataPress | Capture the time of press and time release |
dataKeyPress | Capture the press key in the coordinate system |
dataKeyCenter | Capture the center key in the coordinate system |
dataKeyBounds | Capture the bounds of the current key |
dataConfigCoordinate | The type of coordinate system to use. See DataConfigCoordinate for the available options. |
dataWord | Capture state and data of words |
dataDelete | Capture words deleted |
dataKeyPlane | Capture key planes |
dataKeyText | Capture the labels of each key pressed |
dataPositionEnd | Capture release positions from the center of the key |
dataKeyPressEnd | Capture release positions |
dataPredictionsTouch | Capture touch position of predictions |
dataPrediction | Capture predictions selected |
dataConfigFormat | Format of data files. Can be any of: DataConfigFormat.STANDARD DataConfigFormat.GROUP_BY_TAP |
stressMonitor | Monitor the stress level |
An object containing constants to different types of coordinate systems:
DataConfigCoordinate.SCREEN_PIXEL | Reference to all pixels on the entire screen. This includes all pixels regardless of density. |
DataConfigCoordinate.KEYBOARD_PIXEL | Reference to all pixels contained in the keyboard. This includes all pixels, regardless of density. |
DataConfigCoordinate.KEYBOARD | Reference to pixels contained in the keyboard, seen internally. This could mean different density or other features, depending on the device. |
DataConfigCoordinate.INTERNAL_KEYBOARD | Reference to the internal points for the Engine. 320 x 288 points |
Note:
Data Capture specifies all the different components.
The monitor configuration applied to the keyboard engine. See EventBus for details on any monitoring events sent when extraction or composing is enabled.
Notes:
Constructor:
data class MonitorConfiguration(
val extractionMode: ExtractionMode = ExtractionMode.DISABLED,
val composing: Boolean = false
val input: Boolean = false
)
extractionMode | Whether editor content changes should be sent via EventBus. Can be any of: DISABLED: do not emit extraction events EXTRACTED: receive events of extractions as sent by the InputMethodService either as partial or complete extractions. AGGREGATE: receive events of extractions with all partial events applied into complete extractions. |
composing | Whether composing events should be sent via EventBus |
input | Whether input taps should be sent via EventBus. |
Example:
MonitorConfiguration(
extractionMode = ExtractionMode.AGGREGATE,
composing = true
input = true
)
Fields:
Name | Type | Default value |
---|---|---|
extractionMode | ExtractionMode | ExtractionMode.DISABLED |
composing | Boolean | false |
input | Boolean | false |
The emoji configuration applied to the keyboard engine.
Notes:
Constructor:
data class EmojiConfiguration(
val animatePanel: Boolean = true,
val swipeDownToClose: Boolean = true,
val keepVariations: Boolean = true,
val recent: Set<String> = emptySet(),
val variations: Map<String, String> = emptyMap(),
val defaultSkinTone: EmojiSkinTone = EmojiSkinTone.NEUTRAL,
val defaultGender: EmojiGender = EmojiGender.NEUTRAL,
val androidOnly: Boolean = true,
val addsSpaceAfterEmojiKey: Boolean = true
)
animatePanel | Whether the emoji panel animates on appear and hide. |
swipeDownToClose | Whether the emoji panel can be hidden by a swipe down gesture. |
keepVariations | Whether after selecting a variation, it stays as the default variation for the duration of the keyboard session. |
recent | A list of emojis to show in the recent emojis category. |
variations | A map of emoji variations previously selected. The key of the map is the base emoji, and the value is the variation emoji. |
defaultSkinTone | On compatible emojis with multiple skin tones and no previous variation selected, the skin tone applied will be the default variation. |
defaultGender | On compatible emojis with multiple genders and no previous variation selected, the gender applied will be the default variation. |
androidOnly | Whether it should only show emojis that are compatible with the android operating system version that the user is running. |
addsSpaceAfterEmojiKey | Whether it should add a space after an emoji is tapped. |
Example:
EmojiConfiguration(
animatePanel = false,
swipeDownToCLose = false,
recent = listOf("😂", "😍", "😭", "☺️"),
variations = mapOf(“👩” to "👩🏿”),
defaultSkinTone = EmojiSkinTone.MEDIUM_DARK,
defaultGender = EmojiGender.WOMAN,
androidOnly = true,
addsSpaceAfterEmojiKey = true
)
Fields:
Name | Type | Default value |
---|---|---|
animatePanel | Boolean | true |
swipeDownToClose | Boolean | true |
keepVariations | Boolean | true |
recent | List |
emptyList() |
variations | Map<String,String> | emptyMap() |
defaultSkinTone | EmojiSkinTone | EmojiSkinTone.NEUTRAL |
defaultGender | EmojiGender | EmojiGender.NEUTRAL |
androidOnly | Boolean | true |
addsSpaceAfterEmojiKey | Boolean | true |
The apps configuration applied to the keyboard engine.
Notes:
Constructor:
data class AppConfiguration(
val keyboardApps: List<KeyboardApp> = emptyList(),
val shareAuthority: String? = null,
val shareDirectory: String = "SharedContent",
val shareContentExpiration: Long = TimeUnit.DAYS.toMillis(1),
val showAppsInCarousel: Boolean = true
)
keyboardApps | A list of apps to be registered in the carousel and available to be opened via the PanelHelper. |
shareAuthority | The shared authority identifier to use when sharing media from apps. Must match a provider defined in the Android Manifest file. |
shareDirectory | The directory where the shared media will be stored and made available through the content provider. Files in this folder will be regularly deleted. |
shareContentExpiration | Expiration, in milliseconds, of the stored media for sharing. Applications using the shared media may still need to access the content for a certain amount of time. Safe content expiration is between one hour and one day. |
showAppsInCarousel | Whether apps should be added to the apps carousel when the top-left icon is clicked. |
Example:
val apps by lazy { listOf(GiphyApp(“key”)) }
AppsConfiguration(
keyboardApps = apps,
shareAuthority = "$packageName.fileprovider",
shareDirectory = "SharedContent",
shareContentExpiration = TimeUnit.HOURS.toMillis(1),
showAppsInCarousel = false
)
Fields:
Name | Type | Default value |
---|---|---|
keyboardApps | List |
emptyList() |
shareAuthority | String? | null |
shareDirectory | String | “SharedContent” |
shareContentExpiration | Long | TimeUnit.DAYS.toMillis(1) |
showAppsInCarousel | Boolean | true |
The license key and secret provided by the Fleksy SDK team, associated with the application(s) using the keyboard SDK.
Constructor:
data class LicenseConfiguration(
val licenseKey: String? = null,
val licenseSecret: String? = null
)
licenseKey | The license key |
licenseSecret | The license secret |
The feedback configuration applied to the keyboard engine.
Notes:
Constructor:
data class FeedbackConfiguration(
val soundMode: SoundMode = SoundMode.Silent,
val vibrationMode: VibrationMode = VibrationMode.Haptic(true)
)
soundMode | The sound mode for keyboard feedback, can be any of: SoundMode.Silent: No sound is produced SoundMode.Resources: Sounds from a defined sound set are used for sound feedback. |
vibrationMode | The vibration mode for keyboard feedback, can be any of: VibrationMode.None: No vibration is produced VibrationMode.Haptic: Use the haptic feedback features of the device, when available. VibrationMode.Duration: Configurable vibration duration. |
Example:
FeedbackConfiguration(
soundMode = SoundMode.Resources(
ResourceSoundSet(
tap = R.raw.v2_tap,
spacebar = R.raw.v2_spacebar,
backspace = R.raw.v2_backspace,
hold = R.raw.v2_hold,
modifier = R.raw.v2_modifier,
swipeHorizontal = R.raw.v2_swipe_h
),
1f
),
vibrationMode = VibrationMode.Haptic(true)
)
Fields:
Name | Type | Default value |
---|---|---|
animatePanel | SoundMode | SoundMode.Silent |
vibrationMode | VibrationMode | VibrationMode.Haptic(true) |
An object instance of a SoundMode that does not play sounds.
Example:
FeedbackConfiguration(
soundMode = SoundMode.Silent
)
A sound mode that plays audio sounds from resources.
soundSet | A sound set of type ResourceSoundSet |
volume | The volume of the playback from 0.0 to 1.0 |
Example:
SoundMode.Resources(
soundSet = ResourceSoundSet(
tap = R.raw.v2_tap,
spacebar = R.raw.v2_spacebar,
backspace = R.raw.v2_backspace,
hold = R.raw.v2_hold,
modifier = R.raw.v2_modifier,
swipeHorizontal = R.raw.v2_swipe_h
),
volume = 0.5f
)
An object instance of VibrationMode that does not perform any vibration feedback.
A VibrationMode that performs Haptic vibration feedback, if available.
fallbackVibration | Whether it should fall back to predefined duration vibration when haptic feedback is not available. |
Example:
VibrationMode.Haptic(fallbackVibration = true)
A VibrationMode that vibrates for the defined duration on each key tap.
duration | Duration of the vibration event, in milliseconds. |
Example:
VibrationMode.Duration(duration = 8L)
Class to configure the custom layout for enabling a custom action.
data class CustomizationBundleConfiguration {
/**
* The name of the bundle file that needs to be used for the keyboard layout customization.
* Do not include the ".bundle" extension in the `bundleFileName` parameter.
* Defaults to "fleksy-custom".
*
* Passing an empty string or a name for a bundle file that does not exist has no layout
* customization effect.
*/
val bundleFileName: String = "fleksy-custom",
/**
* The array of custom `Button`s to define the look and behavior of the custom buttons
* declared in the bundle file.
*
* If two buttons in the array have the same label (case insensitive) then only the first
* one in the array will be considered.
*/
val buttons: List<Button> = listOf()
}
Parameters:
buttons<>:
bundleFileName:
// Custom Action Button
class Button {
/**
* The case-insensitive label of the custom button. This string must match (case insensitively)
* the `label` of the custom button defined in `keyboard-global.json` file.
*/
val label: String,
/**
* The image to be shown in the custom button. If the image is null, then the label
* will be shown and it will be shown in uppercase or lowercase depending of the state of
* the shift button.
*/
val image: Int?,
/**
* How the image fits in the button. @see ScaleMode
*/
val scaleMode: ScaleMode = ScaleMode.CENTER_INSIDE,
/**
* The action to perform when the user taps the custom button, containing the label of the
* tapped button.
*
* @return the case-insensitive label of the tapped button. When comparing this parameter,
* note that the case of the label will match the keyboard's state.
*/
val action: (String) -> Unit
) {
/**
* Defines how an image will fit in the custom action button.
*/
@Keep
enum class ScaleMode {
/**
* Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions
* (width and height) of the image will be equal to or larger than the corresponding
* dimension of the button.
*/
CENTER_CROP,
/**
* Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions
* (width and height) of the image will be equal to or less than the corresponding
* dimension of the button..
*/
CENTER_INSIDE
}
}
Parameters:
label
of the custom button defined in the bundleFileName. By default, the name of the label is custom-action.image
. By default it is defined as CENTER_INSIDE
.Example:
In order to implement a custom action on the layout, check the feature in detail: Custom Action