emojicon icon indicating copy to clipboard operation
emojicon copied to clipboard

Status bar and navigation bar

Open mlucchini opened this issue 9 years ago • 3 comments

It seems that for Lollipop, in EmojiconsPopup::setSizeForSoftKeyboard, we have to substract the size of "navigation_bar_height" as well as "status_bar_height" in case there's a navigation bar being displayed otherwise the emoji popup will take more space than the soft keyboard.

mlucchini avatar May 17 '15 10:05 mlucchini

Ya the previous comment is right Here is the solution i have got

/**
 * Call this function to resize the emoji popup according to your soft keyboard size
 */
public void setSizeForSoftKeyboard(){
    rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            Rect r = new Rect();
            rootView.getWindowVisibleDisplayFrame(r);

            int screenHeight = rootView.getRootView()
                    .getHeight();
            int heightDifference = screenHeight
                    - (r.bottom - r.top);
            int resourceId = mContext.getResources()
                    .getIdentifier("status_bar_height",
                            "dimen", "android");

            int navigation = mContext.getResources()
                    .getIdentifier("navigation_bar_height",
                            "dimen", "android");

            if (resourceId > 0) {
                if(Build.VERSION.SDK_INT> Build.VERSION_CODES.KITKAT)
                {
                    heightDifference -= mContext.getResources()
                            .getDimensionPixelSize(resourceId);
                    heightDifference -=mContext.getResources().getDimension(navigation);
                }else
                heightDifference -= mContext.getResources()
                        .getDimensionPixelSize(resourceId);
            }

            if (heightDifference > 100) {
                keyBoardHeight = heightDifference;
                setSize(LayoutParams.MATCH_PARENT, keyBoardHeight);
                if(isOpened == false){
                    if(onSoftKeyboardOpenCloseListener!=null)
                        onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight);
                }
                isOpened = true;
                if(pendingOpen){
                    showAtBottom();
                    pendingOpen = false;
                }
            }
            else{
                isOpened = false;
                if(onSoftKeyboardOpenCloseListener!=null)
                    onSoftKeyboardOpenCloseListener.onKeyboardClose();
            }
        }
    });
}

shailesh242121 avatar Aug 17 '15 12:08 shailesh242121

I found that the above code makes the popup always shorter than the keyboard. I tried several devices in the emulator, and both Lollipop and L. How can I reproduce this with an emulator?

cridus avatar Sep 12 '15 17:09 cridus

Hi, I'm having the same problem now, shailesh242121's code is better than the original, but on some devices it doesn't quite cover the whole keyboard, did anyone figure out a solution ?

Thanks in advance.

Meeks91 avatar Sep 24 '15 13:09 Meeks91