From 898dbe3c29dc46707897f41dd37845ecaf310b92 Mon Sep 17 00:00:00 2001
From: Satoshi Kataoka <satok@google.com>
Date: Thu, 5 Sep 2013 12:19:43 +0900
Subject: [PATCH] Fix emoji keyboard insets

Bug: 10541453
Change-Id: I16dd72c8c55cb5d21ad61a3307c0f3c5f16f460c
---
 .../android/inputmethod/keyboard/KeyboardSwitcher.java    | 8 ++++++--
 java/src/com/android/inputmethod/latin/LatinIME.java      | 5 ++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index d128d3595e..cc1ffd183e 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -314,15 +314,19 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
         mState.onCodeInput(code, mLatinIME.getCurrentAutoCapsState());
     }
 
+    public boolean isShowingEmojiKeyboard() {
+        return mEmojiKeyboardView.getVisibility() == View.VISIBLE;
+    }
+
     public boolean isShowingMoreKeysPanel() {
-        if (mEmojiKeyboardView.getVisibility() == View.VISIBLE) {
+        if (isShowingEmojiKeyboard()) {
             return false;
         }
         return mKeyboardView.isShowingMoreKeysPanel();
     }
 
     public View getVisibleKeyboardView() {
-        if (mEmojiKeyboardView.getVisibility() == View.VISIBLE) {
+        if (isShowingEmojiKeyboard()) {
             return mEmojiKeyboardView;
         }
         return mKeyboardView;
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index cdd6c92e44..5657ed7790 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1234,7 +1234,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
         int visibleTopY = extraHeight;
         // Need to set touchable region only if input view is being shown
         if (visibleKeyboardView.isShown()) {
-            if (mSuggestionStripView.getVisibility() == View.VISIBLE) {
+            // Note that the height of Emoji layout is the same as the height of the main keyboard
+            // and the suggestion strip
+            if (mKeyboardSwitcher.isShowingEmojiKeyboard()
+                    || mSuggestionStripView.getVisibility() == View.VISIBLE) {
                 visibleTopY -= suggestionsHeight;
             }
             final int touchY = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
-- 
GitLab