Monday 15 March 2010

chat - ankushsachdeva emojicon display over softkeyboard (Android) -



chat - ankushsachdeva emojicon display over softkeyboard (Android) -

i implemented ankushsachdeva emojicon project display emojicons in chat app. when click on specific chat start chatactivity. if immediately click emoji-imagebutton made, without expanding keyboard first, looks left screenshot here

afterwords, emojicon-overlay always displayed correctly. (right screenshot)

i want overlay in right screenshot. ideas? (thanks in advance)

chatactivity:

private listview listview; //contains chatmessages , has customadapter private emojiconspopup popup; //emojicon-popup private edittext edittext; //edittext capture text , emojicons private inputmethodmanager inputmanager; @override protected void oncreate(bundle savedinstancestate){ listview = (listview) findviewbyid(r.id.listview); //...// inputmanager = (inputmethodmanager) getsystemservice(context.input_method_service); popup = new emojiconspopup(listview, getapplicationcontext()); popup.setsizeforsoftkeyboard(); popup.setonemojiconclickedlistener(new onemojiconclickedlistener(){ @override public void onemojiconclicked(emojicon emojicon){ edittext.append(emojicon.getemoji()); } }); popup.setonemojiconbackspaceclickedlistener(new onemojiconbackspaceclickedlistener(){ @override public void onemojiconbackspaceclicked(view v){ keyevent event = new keyevent(0, 0, 0, keyevent.keycode_del, 0, 0, 0, 0, keyevent.keycode_endcall); edittext.dispatchkeyevent(event); } }); popup.setonsoftkeyboardopencloselistener(new onsoftkeyboardopencloselistener(){ @override public void onkeyboardopen(int keyboardheight){ } @override public void onkeyboardclose(){ if (popup.isshowing()) popup.dismiss(); } }); } //called when emojicon button clicked public void onemojibuttonclicked(view view){ if (!popup.isshowing()){ inputmanager.showsoftinput(edittext, inputmethodmanager.show_implicit); popup.showatbottom(); //show popup emojicons }else if(popup.isshowing()){ popup.dismiss(); // hide popup emojicons } }

since, there no reliable way know soft keyboard height, library calculates opening keyboard , seeing how much top layout of view heirarchy shrinks.

i have added new function library showatbottompending() should solve problem. create next 2 changes code.

change onemojibuttonclicked function

public void onemojibuttonclicked(view view){ if (!popup.isshowing()){ popup.showatbottompending(); //show popup emojicons after keyboard visible inputmanager.showsoftinput(edittext, inputmethodmanager.show_implicit); }else if(popup.isshowing()){ popup.dismiss(); // hide popup emojicons } } instead of passing listview in emojiconspopup constructor, pass top layout of view hierarchy.

android chat overlay android-softkeyboard emoji

No comments:

Post a Comment