Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add docs for Android HTML banner #882

Merged
merged 4 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions developer/engine/android/17.0/KMManager/copyHTMLBannerAssets.md
Original file line number Diff line number Diff line change
@@ -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.
darcywong00 marked this conversation as resolved.
Show resolved Hide resolved

This can be called towards the end of `SystemKeyboard.onCreate()`.

## Examples

### Example: Using `copyHTMLBannerAssets()`

The following script illustrates the use of `copyHTMLBannerAssets()`:
```java
darcywong00 marked this conversation as resolved.
Show resolved Hide resolved
// Copies HTML banner assets located in /assets/banner/
KMManager.copyHTMLBannerAssets(this, "banner");
```

## See also
* [setHTMLBanner()](setHTMLBanner)
6 changes: 6 additions & 0 deletions developer/engine/android/17.0/KMManager/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<dt><code><a href='canRemoveKeyboard'>canRemoveKeyboard()</a></code></dt>
<dd>returns whether removing a keyboard is enabled, like in the keyboard picker menu</dd>

<dt><code><a href='copyHTMLBannerAssets'>copyHTMLBannerAssets()</a></code></dt>
<dd>copies a folder of HTML banner assets so it's available for your keyboard app's resources</dd>

<dt><code><a href='createInputView'>createInputView()</a></code></dt>
<dd>creates the input view to be used in InputMethodService</dd>

Expand Down Expand Up @@ -220,6 +223,9 @@
<dt><code><strike>setHelpBubbleEnabled()</strike> (deprecated)</code></dt>
<dd>enables or disables the help bubble</dd>

<dt><code><a href='setHTMLBanner'>setHTMLBanner()</a></code></dt>
<dd>sets the contents of an HTML banner for Keyman Engine to display when suggestions aren't available</dd>

<dt><code><a href='setKeyboard'>setKeyboard()</a></code></dt>
<dd>sets the keyboard to be used</dd>

Expand Down
43 changes: 43 additions & 0 deletions developer/engine/android/17.0/KMManager/setHTMLBanner.md
Original file line number Diff line number Diff line change
@@ -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.
darcywong00 marked this conversation as resolved.
Show resolved Hide resolved

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
darcywong00 marked this conversation as resolved.
Show resolved Hide resolved
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)