From 5ad44d3d2b7cbdf6780325e9997853aebf663f38 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Sat, 18 Nov 2023 14:32:44 +0700 Subject: [PATCH 1/4] chore: Add docs for Android HTML banner --- .../17.0/KMManager/copyHTMLBannerAssets.md | 42 ++++++++++++++++++ .../engine/android/17.0/KMManager/index.php | 6 +++ .../android/17.0/KMManager/setHTMLBanner.md | 43 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md create mode 100644 developer/engine/android/17.0/KMManager/setHTMLBanner.md diff --git a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md new file mode 100644 index 000000000..7ff9708fe --- /dev/null +++ b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md @@ -0,0 +1,42 @@ +--- +title: 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. + +This can be called towards the end of `SystemKeyboard.onCreate()`. + +## Examples + +### Example: Using `copyHTMLBannerAssets()` + +The following script illustrates the use of `copyHTMLBannerAssets()`: +```java + // Copies HTML banner assets located in /assets/banner/ + KMManager.copyHTMLBannerAssets(this, "banner"); +``` + +## See also +* [setHTMLBanner()](setHTMLBanner) diff --git a/developer/engine/android/17.0/KMManager/index.php b/developer/engine/android/17.0/KMManager/index.php index 449f7005f..4d1c94dd8 100644 --- a/developer/engine/android/17.0/KMManager/index.php +++ b/developer/engine/android/17.0/KMManager/index.php @@ -52,6 +52,9 @@
canRemoveKeyboard()
returns whether removing a keyboard is enabled, like in the keyboard picker menu
+
copyHTMLBannerAssets()
+
copies a folder of HTML banner assets so it's available for your keyboard app's resources
+
createInputView()
creates the input view to be used in InputMethodService
@@ -220,6 +223,9 @@
setHelpBubbleEnabled() (deprecated)
enables or disables the help bubble
+
setHTMLBanner()
+
sets the contents of an HTML banner for Keyman Engine to display when suggestions aren't available
+
setKeyboard()
sets the keyboard to be used
diff --git a/developer/engine/android/17.0/KMManager/setHTMLBanner.md b/developer/engine/android/17.0/KMManager/setHTMLBanner.md new file mode 100644 index 000000000..5f2fa5232 --- /dev/null +++ b/developer/engine/android/17.0/KMManager/setHTMLBanner.md @@ -0,0 +1,43 @@ +--- +title: 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. + +Note: This 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()`: +```java + String KMGRAY_BANNER = "
"; + // Sets the HTML banner content + KMManager.setHTMLBanner(KeyboardType.KEYBOARD_TYPE_SYSTEM, KMGRAY_BANNER); +``` + +## See also +* [copyHTMLBannerAssets()](copyHTMLBannerAssets) From 10759bc42ed54388038aa62464a5d4e0394f047f Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Nov 2023 07:55:18 +0700 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Eberhard Beilharz --- .../engine/android/17.0/KMManager/copyHTMLBannerAssets.md | 2 +- developer/engine/android/17.0/KMManager/setHTMLBanner.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md index 7ff9708fe..911711022 100644 --- a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md +++ b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md @@ -33,7 +33,7 @@ This can be called towards the end of `SystemKeyboard.onCreate()`. ### Example: Using `copyHTMLBannerAssets()` The following script illustrates the use of `copyHTMLBannerAssets()`: -```java +```javascript // Copies HTML banner assets located in /assets/banner/ KMManager.copyHTMLBannerAssets(this, "banner"); ``` diff --git a/developer/engine/android/17.0/KMManager/setHTMLBanner.md b/developer/engine/android/17.0/KMManager/setHTMLBanner.md index 5f2fa5232..daecc3aea 100644 --- a/developer/engine/android/17.0/KMManager/setHTMLBanner.md +++ b/developer/engine/android/17.0/KMManager/setHTMLBanner.md @@ -24,7 +24,7 @@ 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. +Use this method to specify the HTML content to display in the banner to theme your keyboard app. Note: This needs to be updated whenever the keyboard is reloaded, so call this in `SystemKeyboard.onInitializeInterface(()`. @@ -33,7 +33,7 @@ Note: This needs to be updated whenever the keyboard is reloaded, so call this i ### Example: Using `setHTMLBanner()` The following script illustrates the use of `setHTMLBanner()`: -```java +```javascript String KMGRAY_BANNER = "
"; // Sets the HTML banner content KMManager.setHTMLBanner(KeyboardType.KEYBOARD_TYPE_SYSTEM, KMGRAY_BANNER); From 9be59f6ba1686c479105a4c112424c3ffdb0a620 Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Nov 2023 07:57:09 +0700 Subject: [PATCH 3/4] Update developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md Co-authored-by: Eberhard Beilharz --- developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md index 911711022..e65007853 100644 --- a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md +++ b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md @@ -24,7 +24,7 @@ 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. +Use this method to specify any HTML assets the banner will use to theme your keyboard app. This can be called towards the end of `SystemKeyboard.onCreate()`. From 2c254ce481f053564e465683b67ad97a10d3620b Mon Sep 17 00:00:00 2001 From: Darcy Wong Date: Fri, 24 Nov 2023 08:05:36 +0700 Subject: [PATCH 4/4] chore: Clarify uses --- .../engine/android/17.0/KMManager/copyHTMLBannerAssets.md | 4 +++- developer/engine/android/17.0/KMManager/setHTMLBanner.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md index e65007853..733a368d5 100644 --- a/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md +++ b/developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md @@ -24,10 +24,12 @@ 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. +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()` diff --git a/developer/engine/android/17.0/KMManager/setHTMLBanner.md b/developer/engine/android/17.0/KMManager/setHTMLBanner.md index daecc3aea..5990945c5 100644 --- a/developer/engine/android/17.0/KMManager/setHTMLBanner.md +++ b/developer/engine/android/17.0/KMManager/setHTMLBanner.md @@ -26,7 +26,9 @@ Returns `true` if HTML banner is set, `false` otherwise. 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. -Note: This needs to be updated whenever the keyboard is reloaded, so call this in `SystemKeyboard.onInitializeInterface(()`. +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