I made a little chat and I want to use my Google keyboard (GBoard) to send Gifs. When I clicked on a Gif I had this message: “App doesn't support image insertion here”.
I looked online and I saw that I need to override onCreateInputConnection() function for TextView like it says in this link : https://developer.android.com/guide/topics/text/image-keyboard#java
If I understand well, EditText is the native component of TextView. But I really don't know how I can override it.
I transposed the java code in typescript but I can't test and I don't know how to test it right now.
export class CustomTextView extends android.widget.TextView {
public onCreateInputConnection(editorInfo: android.view.inputmethod.EditorInfo): android.view.inputmethod.InputConnection {
var inputConnection = super.onCreateInputConnection(editorInfo);
androidx.core.view.inputmethod.EditorInfoCompat.setContentMimeTypes(editorInfo, Array("image/gif", "image/png"));
var callback = new androidx.core.view.inputmethod.InputConnectionCompat.OnCommitContentListener();
callback.onCommitContent = (inputContentInfo: androidx.core.view.inputmethod.InputContentInfoCompat, flags: number, opts: globalAndroid.os.Bundle): boolean => {
if (androidx.core.os.BuildCompat.isAtLeastNMR1() && (flags &
androidx.core.view.inputmethod.InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
try {
inputContentInfo.requestPermission();
}
catch (e) {
return false;
}
}
return true;
}
return androidx.core.view.inputmethod.InputConnectionCompat.createWrapper(inputConnection, editorInfo, callback);
}
}
I don't found any help online...
Thanks !
Thank you very much for your answer @manoj. So i tried to create a component like you said and override
onCreateInputConnection
.It quite works. I don't have this message: “App doesn't support image insertion here” anymore but nothing happen next and i don't know what i have to do...
Here is my code: