To start working with Fleksy Keyboard SDK with the Flutter framework, we will write custom platform-specific code and use the MethodChannel API. Check out the official documentation for more information.
The Android dependency for the Fleksy Keyboard SDK can be synced and set up via Gradle. For a smoother integration, consider opening the android directory in the Android Studio.
Add Fleksy SDK repository to the android/build.gradle file.
|
|
Add the dependency on the Flesky Keyboard SDK in the android/app/build.gradle file.
|
|
Disable compression for JSON and wav files in android/app/build.gradle file. The SDK uses these file types for theming and customization purposes.
|
|
Add a new tools namespace and tag in your app module’s AndroidManifest.xml file to replace the application label when manifests merge during compilation. It is required to resolve a manifest merge error during compilation.
|
|
Increase the minimum target SDK version of the app to 21. To do this, add a new property flutter.minSdkVersion in the android/local.properties file.
|
|
Then, load and set this property in the android/app/build.gradle file afterward.
|
|
|
|
Create a new input-method file (e.g., sample_input_method.xml) in your app module’s res/xml folder. The Android system will use this to obtain information about the input service we created above and display it to the users in the Settings.
<?xml version="1.0" encoding="utf-8"?>
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
android:icon="@mipmap/ic_launcher"
android:isDefault="true">
<subtype
android:imeSubtypeExtraValue="EmojiCapable,AsciiCapable,TrySuppressingImeSwitcher"
android:imeSubtypeMode="keyboard"
android:label="%s"
android:overridesImplicitlyEnabledSubtype="true" />
<subtype
android:imeSubtypeExtraValue="AsciiCapable"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard"
android:isAsciiCapable="true" />
</input-method>
Add the newly created service and input method in your app module’s AndroidManifest.xml file.
|
|
Finally, download & copy the English language pack resourceArchive-en-US.jet to the assets/encrypted folder of the main app module. This will be used by the Fleksy Keyboard SDK as the default starting language. We can download other languages later using the SDK as required.
assets/encrypted
directory is absent by default on new projects unless created manually.
For example:
With a terminal (bash) open at the root of the android project, and with the provided language pack stored in the ~/Downloads folder:
encrypted
folder inside the assets
folder:$ mkdir -p app/src/main/assets/encrypted
assets/encrypted
folder:$ cp ~/Downloads/resourceArchive-en-US.jet app/src/main/assets/encrypted
With the above steps, the Android part of our Flutter project is now ready to be built and run on a device of choice.
The iOS package for the Fleksy Keyboard SDK can be synced using Swift Package Manager. For the best experience, consider opening the ios directory in Xcode.
Xcode provides support to add a new Custom Keyboard Extension target to your project. It can be used to quickly generate required files and schemes in order to build your custom keyboard.
Xcode will ask you if you want to activate the scheme for the newly created extension. Choose Activate.
Add the FleksySDK package as a dependency using its repository URL, as follows:
https://github.com/FleksySDK/FleksySDK-iOS
Locate your Custom Keyboard Extension created in step 1 in the Project Navigatior.
import FleksyKeyboardSDK
class KeyboardViewController: FleksyKeyboardSDK.FKKeyboardViewController {
override func createConfiguration() -> KeyboardConfiguration {
let style = StyleConfiguration()
let appPopup = AppearancePopup()
let appLongpress = AppearanceLongPress()
let appearance = AppearanceConfiguration(
objPopup: appPopup,
objTouch: nil,
objLongpress: appLongpress
)
let typing = TypingConfiguration()
let panelConfig = PanelConfiguration()
let debugConfig = DebugConfiguration(debug: ())
let licenseConfig = LicenseConfiguration(
licenseKey: "<your-license-key>",
licenseSecret: "<your-license-secret>"
)
return KeyboardConfiguration(
panel: panelConfig,
capture: nil,
style: style,
appearance: appearance,
typing: typing,
specialKeys: nil,
license: licenseConfig,
debug: debugConfig
)
}
}
Fleksy Keyboard SDK doesn’t support building with bitcode so it must be disabled to avoid compilation failures.
Fleksy Keyboard SDK also needs access to the network to validate API keys, download language and theme packs, and much more. For that, add the required RequestsOpenAccess key.
That’s all. With the steps above, the iOS part of our Flutter project is also ready to be built.
For more information, consider checking out the API reference documentation for the respective platform, which documents all the available methods to customize the keyboard built with Fleksy Keyboard SDK.