diff options
author | lookshe <github@lookshe.org> | 2015-08-15 23:45:43 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2015-08-15 23:45:43 +0200 |
commit | cfefe9a0bd156ee1c0afac3ea5eac94ba3ad239d (patch) | |
tree | 98fc8eb358e33fb3d30ec0df69c9e586036d26ad /libs | |
parent | 79c585144d0967a2e5d4b1cfb6c486332d0b0cfb (diff) |
Merged https://github.com/ankushsachdeva/emojicon/pull/16
Diffstat (limited to 'libs')
-rw-r--r-- | libs/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java | 28 |
1 files changed, 24 insertions, 4 deletions
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); |