Android Question Keyman Keyboard (open source)

Rusty

Well-Known Member
Licensed User
Longtime User
Has anyone implemented the Keyman Keyboards (supporting many, many languages) within their application?
If so, have you created a compatible Jar file?

Keyman.com
There is an .aar file at this location, but I don't know how to implement it...any suggestions greatly appreciated.

Thanks,
Rusty
 

DonManfred

Expert
Licensed User
Longtime User
Has anyone implemented the Keyman Keyboards (supporting many, many languages) within their application?
Not at the time you wrote the question.
But i like the Idea and also the - now free - library.

But:
To get it working with B4A one need to write a InputMethodService which can be set into the keyboard library. This is not available for B4A.

I tried to build a wrapper for it. I can´t get the IN APP Keyboard working at all.

If you install the Keyman app to your device you can install/setup it as systemwide keyboard.
This works.
But i guess it does not need a wrap at all as the keyboard is systemwide and you can access the new keyboard(s) from within your app too.

1577430769869.png

This is using the systemwide keyboard used with Keyman.
Clicking on the Globe does open a List of installed Keyboards in Keyman which can be used to switch the Keyboard.
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Hi Don (and anyone else :) )
I have tried to use the keyman with the systemwide keyboard and, of course the keyboard comes up, but their text editor covers the whole screen.
In your image in post #2, was that your EditText showing or their text editor overlay?
If it is your EditText, can you please tell me how you got the Keyman Text editor display to disappear?
Thanks
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
I am trying to use the .aar file for the Keyman keyboard.
This is in order to be able to change the language displayed, which i am able to do in Visual Studio and the Keyman API like this:
B4X:
''' <summary>
''' Keyman Properties
'''AutoApply  -   Determines whether settings changes are applied To Keyman Engine automatically As they are made.
'''Control    -   Returns an IKeymanControl Interface that provides methods For controlling the Keyman process And user Interface.
'''Errors     -   Returns an IKeymanErrors Interface that lists errors that the API incurred When undertaking various processes.
'''Hotkeys    -   Returns an IKeymanHotkeys Interface that lists all Of the configured Interface hotkeys.
'''Keyboards  -   Returns an IKeymanKeyboardsInstalled Interface that lists all Of the currently installed Keyman keyboards.
'''Languages  -   Returns an IKeymanLanguages Interface that lists all Of the currently avilable Windows languages And input methods.
'''hotkeys    -   Returns an IKeymanhotkeys Interface that lists all Of the configuration settings And values For Keyman Engine.
'''Packages   -   Returns an IKeymanPackagesInstalled Interface that lists all Of the currently installed Keyman packages.
'''SystemInfo -   Returns an IKeymanSystemInfo Interface that describes the current system configuration.
''' </summary>
Public Class clsKeyman
    Dim Keyman As New keymanapi.Keyman
    
    ''' <summary>
    ''' Show the on screen keyboard with current language
    ''' </summary>
    Public Sub Show()
        IsFocused = True
        Keyman.Control.StartVisualKeyboard()
    End Sub
    
    ''' <summary>
    ''' Set the ACTIVELANGUAGE for the on screen keyboard
    ''' </summary>
    ''' <param name="Language">Keyman LAYOUTNAME</param>
    Public Sub SelectLanguage(ByVal Language As String)
        Dim lang As keymanapi.IKeymanLanguage
        For Each lang In Keyman.Languages
            If Language.ToLower = lang.LocaleName.ToLower Then
                Keyman.Control.ActiveLanguage = lang
                Exit For
            End If
        Next
        Keyman.Refresh()
    End Sub
    
 ... other methods
 
 In the main application
      Public Keyman As New clsKeyman
     ...
         Keyman.Start()
    ...
         KeymanSetLanguage(cmbSourceLanguage.SelectedItem) 'this selects the language for display BEFORE it is displayed'

I know the API contains this method, but am at a loss as to how to use the downloaded .aar file within a simple application.
Any advice would be greatly appreciated.
Regards,
Rusty
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i was only able to use the keyboard if set globally in the device.
Based on the documentation it should be possible to show the Keyman Keyboard even if one set a different keyboard globally.

I was not able to do this. Showing a non global Keyboard.

Where does the code you posted comes from?

which i am able to do in Visual Studio
Visual studio can create android apps?
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Visual studio can create android apps?
No, unless you use Xamarin, in that case, it can create apps that run on PCs and the same source code can run on Android or Apple...

The code quoted was written by me. I have the keyboard(s) working well on my development PC, (Windows 10), with full functionality.
I'm using it in a translation application that allows my users to type in English; translate to something else; then edit the something else language using the proper language keyboard. (in order to purify and correct the original (Google or Bing) translation errors/localization)

I just can't seem to find a .Jar file to allow access to the methods etc. to allow me to do this on Android.
Keyman has 2 sample Java apps, but, unfortunately, I don't speak Java. I've read through them and can't make sense of them...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can JS be used in a B4a Webbrowser?
yes
If so, how does one implement this?
The forumsearch IS working. Did you tried it? There are plenty of similar questions and answers available.

I don´t know if it helps as i don´t see the customkeyboard added. I must missing something needed in my wrapper which i wrote.
 
Last edited:
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
I've searched through WebViewExtras and I think this may be a method to accomplish this, but when I try to "inject" the JS into the HTML, it fails...
The WebViewExtras example is modified below to try this.
The file in red is an Arabic keyboard I'm trying to use. It works on the PC version, but I'm sure the implementation below is incorrect, but can't figure out why.
I've never used Java Script before.
Suggestions are appreciated.



B4X:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>WebViewExtras demo</title>

[COLOR=rgb(184, 49, 47)]<script src='file:///android_asset/basic_kbda1.js'></script>[/COLOR]

</head>
<body>
<table style="border-collapse:collapse">
    <tr>
        <th>addJavascriptInterface()</th>
    </tr>
    <tr>
        <td>Adds a <a href="http://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface%28java.lang.Object,%20java.lang.String%29">JavascriptInterface</a> to a WebView.</td>
    </tr>
    <tr>
        <td>
            The JavascriptInterface is a Java object with methods that can be executed using javascript in your WebView.<br />
            The Java object can execute Subs in your B4A application.
        </td>
    </tr>
        <tr>
        <td>
            <!--    passing true or false to callUIThread seems to make no difference with this test
            presumably displaying a Toast message does not modify the activity UI?    -->
            Click <a href="javascript:void(0)" onclick="B4A.CallSub('ShowKeyboard', true)">HERE</a> to Show a Keyboard in B4A demo code.
        </td>
    </tr>
    <tr>
        <td>
            <!--    passing true or false to callUIThread seems to make no difference with this test
            presumably displaying a Toast message does not modify the activity UI?    -->
            Click <a href="javascript:void(0)" onclick="B4A.CallSub('ShowToast', true, 'Hello from javascript')">HERE</a> to call a Sub in the B4A demo code.
        </td>
    </tr>
    <tr>
        <td>
            <!--    CallSub(final String subName, final boolean callUIThread, final String parameter1)
            callUIThread is passed boolean true as the acitivity UI will be modified    -->
            Click <a href="javascript:void(0)" onclick="B4A.CallSub('ToggleWebViewHeight', true)">HERE</a> to call a Sub in the B4A demo code that will change the height of the WebViews in this demo.
        </td>
    </tr>
    <tr>
        <td>
            Click <a href="javascript:void(0)" onclick="alert(B4A.CallSub('GetString', false))">HERE</a> to call a Sub in the B4A demo code which will return a string to this page.<br />
            A B4A Sub can only return a (string) value to the javascript if the CallSub() method is passed boolean false as <b>callUIThread</b>.<br />
            <i>If the B4A Sub modifies the activity UI it cannot return a value to the calling javascript.</i>
        </td>
    </tr>
    <tr>
        <td><a href="file:///android_asset/web_view_extras_demo.htm">Back to index page</a></td>
    </tr>
</table>
</body>
</html>
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
i don´t think you can use a b4a webview for this.

As written the Keymanlibrary is using an Webview INTERNALLY. I don´t see any methods to access it or to load a website with a keyboard...
It is maybe possible with one of the objects in the lib. I did not found it as yet though.
 
Last edited:
Upvote 0
Top