I am using SuperNova-Emoji for showing emoji icon in my app and now I tried to implement by this official guide but even after following official code with the library i am using it doesn't support image insertion and also make library's edit text unaware of any text.
Image Insertion Code From My Fragment.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.main, container, false);
EditText_TypedMsg = v.findViewById(R.id.Chat_Screen_Text_Message);
sendButton = v.findViewById(R.id.Send);
emo_Button = v.findViewById(R.id.emo);
//EMOJI Edittext SETUP
ParentViewForEmoji = v.findViewById(R.id.Chat_Screen_Main_Layout_Fragment);
emojIcon = new EmojIconActions(getActivity(),ParentViewForEmoji,EditText_TypedMsg,emo_Button);
emojIcon.ShowEmojIcon();
// Keyboard Insertion Start
EditText_TypedMsg = new EmojiconEditText(getActivity()){
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
Log.d(TAG, "onCreateInputConnection: Editor Info = "+outAttrs.inputType);
final InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
EditorInfoCompat.setContentMimeTypes(outAttrs,
new String[]{"image/png",
"image/gif",
"image/jpeg",
"image/webp"});
final InputConnectionCompat.OnCommitContentListener callback = new InputConnectionCompat.OnCommitContentListener() {
@Override
public boolean onCommitContent(InputContentInfoCompat inputContentInfo, int flags, Bundle opts) {
// read and display inputContentInfo asynchronously
Log.d(TAG, "onCommitContent: Input Content Info == "+inputContentInfo.getContentUri());
if (BuildCompat.isAtLeastNMR1() && (flags &
InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
try {
inputContentInfo.requestPermission();
}
catch (Exception e) {
return false; // return false if failed
}
}
// read and display inputContentInfo asynchronously.
// call inputContentInfo.releasePermission() as needed.
return true; // return true if succeeded
}
};
return InputConnectionCompat.createWrapper(inputConnection, outAttrs, callback);
}
};
// Keyboard Insertion End
return v;
}
Above code also make EditText_TypedMsg.gettext() blank even i enter any text. Is there anything i am missing in my code.