From cfefe9a0bd156ee1c0afac3ea5eac94ba3ad239d Mon Sep 17 00:00:00 2001 From: lookshe Date: Sat, 15 Aug 2015 23:45:43 +0200 Subject: Merged https://github.com/ankushsachdeva/emojicon/pull/16 --- .../ankushsachdeva/emojicon/EmojiconsPopup.java | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java index 12bc16e0..b5d26047 100644 --- a/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java +++ b/libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java @@ -29,16 +29,21 @@ import java.util.List; import android.app.Activity; import android.content.Context; +import android.content.res.Resources; import android.graphics.Rect; +import android.os.Build; import android.os.Handler; import android.os.SystemClock; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.view.Gravity; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.WindowManager.LayoutParams; @@ -155,13 +160,28 @@ public class EmojiconsPopup extends PopupWindow implements ViewPager.OnPageChang .getHeight(); int heightDifference = screenHeight - (r.bottom - r.top); - int resourceId = mContext.getResources() + Resources resources = mContext.getResources(); + int statusBarId = resources .getIdentifier("status_bar_height", "dimen", "android"); - if (resourceId > 0) { - heightDifference -= mContext.getResources() - .getDimensionPixelSize(resourceId); + if (statusBarId > 0) { + heightDifference -= resources + .getDimensionPixelSize(statusBarId); } + + //Resolved using http://stackoverflow.com/a/16608481/2853322 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + int navBarId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); + boolean hasMenuKey; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { + hasMenuKey = ViewConfiguration.get(mContext).hasPermanentMenuKey(); + } else hasMenuKey = true; //Skip has menu key below ICS + boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); + if (navBarId > 0 && !hasMenuKey && !hasBackKey) { + heightDifference -= resources.getDimensionPixelSize(navBarId); + } + } + if (heightDifference > 100) { keyBoardHeight = heightDifference; setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); -- cgit v1.2.3