0

I have created Virtual keyboard in which I have to get notified about that the particular app supports the commit content api or not ?

Since I am using custom images inside my keyboard, this checking is required.

I am using InputMethodService and its already done in a demo app to check such thing as below :

@Override
public void onStartInputView(EditorInfo info, boolean restarting) {
    mGifButton.setEnabled(mGifFile != null && isCommitContentSupported(info, MIME_TYPE_GIF));
    mPngButton.setEnabled(mPngFile != null && isCommitContentSupported(info, MIME_TYPE_PNG));
    mWebpButton.setEnabled(mWebpFile != null && isCommitContentSupported(info, MIME_TYPE_WEBP));
}

here, in above code variables with 'm' initials are buttons. and method onStartInputView is overridden in which its checking for the support api and if is Supported then Buttons will be Enabled.

Its ok, buttons will disabled and change its color to little dark if its not supported. Now, since I am using GridView, i have done as below :

@Override
public void onStartInputView(EditorInfo info, boolean restarting) {
    Log.e(">>>>>>Editor Info : >> ",""+info);
    grid.setEnabled(imageFile1 != null && isCommitContentSupported(info, MIME_TYPE_PNG));
}

Its done, But HOW User will get notified that this is not supported.. since GridView is not changing its color or UI so that User will be aware that This is not working.

the return type of setEnabled is void.

So, HOW this possible ?

ZaptechDev Kumar
  • 164
  • 1
  • 14

1 Answers1

1

The Google has a example of a Keyboard with Commit Content on Github:

https://github.com/googlesamples/android-CommitContentSampleIME/blob/master/app/src/main/java/com/example/android/commitcontent/ime/ImageKeyboard.java

On the line 64, you have a function that verify if Commit Content is supported:

private boolean isCommitContentSupported(@Nullable EditorInfo editorInfo, @NonNull String mimeType) 

You can use the Toast, to notify the user.

Regis
  • 147
  • 2
  • 15