From abb0c77af15a22b5d0953e477da8747cd5f2259d Mon Sep 17 00:00:00 2001
From: "Tadashi G. Takaoka" <takaoka@google.com>
Date: Fri, 2 Sep 2011 21:03:18 +0900
Subject: [PATCH] Use separate View for key preview backing

Bug: 5246982
Change-Id: Icec4281cb01771909fcece36647ee42ba179118c
---
 java/res/layout/input_view.xml                      |  7 +++++--
 java/res/values-land/dimens.xml                     |  2 +-
 java/res/values-sw600dp/dimens.xml                  |  1 +
 java/res/values-sw768dp/dimens.xml                  |  2 +-
 java/res/values/dimens.xml                          |  2 +-
 .../src/com/android/inputmethod/latin/LatinIME.java | 13 +++++++++----
 6 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/java/res/layout/input_view.xml b/java/res/layout/input_view.xml
index 88b48fccd1..13560e0cfa 100644
--- a/java/res/layout/input_view.xml
+++ b/java/res/layout/input_view.xml
@@ -25,6 +25,11 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
 >
+    <View
+        android:id="@+id/key_preview_backing"
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/key_preview_backing_height" />
+
     <!-- On tablets, the suggestions strip is centered with horizontal paddings on both sides
          because width of the landscape mode is too long for the suggestions strip. This
          LinearLayout is required to hold the paddings. -->
@@ -33,8 +38,6 @@
         android:orientation="horizontal"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:minHeight="@dimen/suggestions_view_minimum_height"
-        android:gravity="bottom"
     >
         <View
             android:layout_width="@dimen/suggestions_strip_padding"
diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml
index 9149b5d2a8..9de201ebe7 100644
--- a/java/res/values-land/dimens.xml
+++ b/java/res/values-land/dimens.xml
@@ -60,7 +60,7 @@
 
     <dimen name="suggestions_strip_height">36dip</dimen>
     <dimen name="more_suggestions_row_height">36dip</dimen>
-    <dimen name="suggestions_view_minimum_height">160sp</dimen>
+    <dimen name="key_preview_backing_height">36dip</dimen>
     <!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
     <!-- popup_key_height x 1.2 -->
     <dimen name="mini_keyboard_slide_allowance">0.336in</dimen>
diff --git a/java/res/values-sw600dp/dimens.xml b/java/res/values-sw600dp/dimens.xml
index 6955736b36..3b87fd66b5 100644
--- a/java/res/values-sw600dp/dimens.xml
+++ b/java/res/values-sw600dp/dimens.xml
@@ -68,6 +68,7 @@
 
     <dimen name="suggestions_strip_height">44dip</dimen>
     <dimen name="more_suggestions_row_height">44dip</dimen>
+    <dimen name="key_preview_backing_height">44dip</dimen>
     <dimen name="suggestions_strip_padding">15.0mm</dimen>
     <dimen name="suggestion_min_width">0.3in</dimen>
     <dimen name="suggestion_padding">12dip</dimen>
diff --git a/java/res/values-sw768dp/dimens.xml b/java/res/values-sw768dp/dimens.xml
index 7d2ac4860d..7f799092a4 100644
--- a/java/res/values-sw768dp/dimens.xml
+++ b/java/res/values-sw768dp/dimens.xml
@@ -71,7 +71,7 @@
 
     <dimen name="suggestions_strip_height">44dip</dimen>
     <dimen name="more_suggestions_row_height">44dip</dimen>
-    <dimen name="suggestions_view_minimum_height">200sp</dimen>
+    <dimen name="key_preview_backing_height">44dip</dimen>
     <dimen name="suggestions_strip_padding">15.0mm</dimen>
     <dimen name="suggestion_min_width">46dip</dimen>
     <dimen name="suggestion_padding">8dip</dimen>
diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml
index a506ed74db..c5c298df5f 100644
--- a/java/res/values/dimens.xml
+++ b/java/res/values/dimens.xml
@@ -81,7 +81,7 @@
     <dimen name="more_suggestions_row_height">40dip</dimen>
     <dimen name="more_suggestions_slide_allowance">0.2in</dimen>
     <fraction name="more_suggestions_info_ratio">12%</fraction>
-    <dimen name="suggestions_view_minimum_height">200sp</dimen>
+    <dimen name="key_preview_backing_height">40dip</dimen>
     <dimen name="suggestions_strip_padding">0dip</dimen>
     <dimen name="suggestion_min_width">44dip</dimen>
     <dimen name="suggestion_padding">6dip</dimen>
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index cea59fe0ad..191ae58112 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -157,6 +157,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
 
     private Settings.Values mSettingsValues;
 
+    private View mKeyPreviewBackingView;
     private View mSuggestionsContainer;
     private int mSuggestionsStripHeight;
     private SuggestionsView mSuggestionsView;
@@ -607,6 +608,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
     @Override
     public void setInputView(View view) {
         super.setInputView(view);
+        mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing);
         mSuggestionsContainer = view.findViewById(R.id.suggestions_container);
         mSuggestionsView = (SuggestionsView) view.findViewById(R.id.suggestions_view);
         if (mSuggestionsView != null)
@@ -945,12 +947,13 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
                     && (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
             if (isFullscreenMode()) {
                 // No need to have extra space to show the key preview.
-                mSuggestionsContainer.setMinimumHeight(0);
+                mKeyPreviewBackingView.setVisibility(View.GONE);
                 mSuggestionsContainer.setVisibility(
                         shouldShowSuggestions ? View.VISIBLE : View.GONE);
             } else {
                 // We must control the visibility of the suggestion strip in order to avoid clipped
                 // key previews, even when we don't show the suggestion strip.
+                mKeyPreviewBackingView.setVisibility(View.VISIBLE);
                 mSuggestionsContainer.setVisibility(
                         shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE);
             }
@@ -967,15 +970,17 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
         final KeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
         if (inputView == null || mSuggestionsContainer == null)
             return;
-        final int containerHeight = mSuggestionsContainer.getHeight();
-        int touchY = containerHeight;
+        final int backingHeight = (mKeyPreviewBackingView.getVisibility() == View.GONE) ? 0
+                : mKeyPreviewBackingView.getHeight();
+        final int extraHeight = mSuggestionsContainer.getHeight() + backingHeight;
+        int touchY = extraHeight;
         // Need to set touchable region only if input view is being shown
         if (mKeyboardSwitcher.isInputViewShown()) {
             if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
                 touchY -= mSuggestionsStripHeight;
             }
             final int touchWidth = inputView.getWidth();
-            final int touchHeight = inputView.getHeight() + containerHeight
+            final int touchHeight = inputView.getHeight() + extraHeight
                     // Extend touchable region below the keyboard.
                     + EXTENDED_TOUCHABLE_REGION_HEIGHT;
             if (DEBUG) {
-- 
GitLab