From 52d220e71b2840b35d143afd248fe33e2cfebe91 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" <takaoka@google.com> Date: Tue, 6 Aug 2013 10:48:39 +0900 Subject: [PATCH] Remove unnecessary suggestion strip container Change-Id: I3710e1fe1574c0f69f7f448619e939fb45e9b8d3 --- java/res/layout/input_view.xml | 37 +++++-------------- java/res/values/attrs.xml | 1 - java/res/values/styles.xml | 10 +---- java/res/values/themes-basic-highcontrast.xml | 1 - java/res/values/themes-basic.xml | 1 - java/res/values/themes-gingerbread.xml | 1 - java/res/values/themes-ics.xml | 1 - java/res/values/themes-stone-bold.xml | 1 - java/res/values/themes-stone.xml | 1 - .../android/inputmethod/latin/InputView.java | 10 ++--- .../android/inputmethod/latin/LatinIME.java | 18 ++++----- 11 files changed, 25 insertions(+), 57 deletions(-) diff --git a/java/res/layout/input_view.xml b/java/res/layout/input_view.xml index 136e18cd59..1ffb8a32a7 100644 --- a/java/res/layout/input_view.xml +++ b/java/res/layout/input_view.xml @@ -30,34 +30,17 @@ android:layout_width="match_parent" android:layout_height="0dp" /> - <!-- 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. --> - <LinearLayout - android:id="@+id/suggestions_container" - android:orientation="horizontal" + <!-- To ensure that key preview popup is correctly placed when the current system locale is + one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> + <com.android.inputmethod.latin.suggestions.SuggestionStripView + android:id="@+id/suggestion_strip_view" + android:layoutDirection="ltr" android:layout_width="match_parent" - android:layout_height="wrap_content" - > - <View - android:layout_width="@dimen/suggestions_strip_padding" - android:layout_height="@dimen/suggestions_strip_height" - style="?attr/suggestionsStripBackgroundStyle" /> - <!-- To ensure that key preview popup is correctly placed when the current system locale is - one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> - <com.android.inputmethod.latin.suggestions.SuggestionStripView - android:id="@+id/suggestion_strip_view" - android:layoutDirection="ltr" - android:layout_weight="1.0" - android:layout_width="0dp" - android:layout_height="@dimen/suggestions_strip_height" - android:gravity="center_vertical" - style="?attr/suggestionStripViewStyle" /> - <View - android:layout_width="@dimen/suggestions_strip_padding" - android:layout_height="@dimen/suggestions_strip_height" - style="?attr/suggestionsStripBackgroundStyle" /> - </LinearLayout> + android:layout_height="@dimen/suggestions_strip_height" + android:gravity="center_vertical" + android:paddingRight="@dimen/suggestions_strip_padding" + android:paddingLeft="@dimen/suggestions_strip_padding" + style="?attr/suggestionStripViewStyle" /> <!-- To ensure that key preview popup is correctly placed when the current system locale is one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index c318317474..b054e03037 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -28,7 +28,6 @@ <attr name="moreKeysKeyboardViewStyle" format="reference" /> <attr name="moreKeysKeyboardPanelStyle" format="reference" /> <!-- Suggestions strip style --> - <attr name="suggestionsStripBackgroundStyle" format="reference" /> <attr name="suggestionStripViewStyle" format="reference" /> <attr name="moreSuggestionsViewStyle" format="reference" /> <attr name="suggestionBackgroundStyle" format="reference" /> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index 8b6c29e59f..37c6a95534 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -145,13 +145,10 @@ <style name="MoreKeysKeyboardPanelStyle"> <item name="android:background">@drawable/keyboard_popup_panel_background</item> </style> - <style name="SuggestionsStripBackgroundStyle"> - <item name="android:background">@drawable/keyboard_suggest_strip</item> - </style> <style name="SuggestionStripViewStyle" - parent="SuggestionsStripBackgroundStyle" > + <item name="android:background">@drawable/keyboard_suggest_strip</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="colorValidTypedWord">@color/highlight_color_default</item> <item name="colorTypedWord">@color/typed_word_color_default</item> @@ -380,13 +377,10 @@ <style name="MoreKeysKeyboardPanelStyle.IceCreamSandwich"> <item name="android:background">@drawable/keyboard_popup_panel_background_holo</item> </style> - <style name="SuggestionsStripBackgroundStyle.IceCreamSandwich"> - <item name="android:background">@drawable/keyboard_suggest_strip_holo</item> - </style> <style name="SuggestionStripViewStyle.IceCreamSandwich" - parent="SuggestionsStripBackgroundStyle.IceCreamSandwich" > + <item name="android:background">@drawable/keyboard_suggest_strip_holo</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="colorValidTypedWord">@color/highlight_color_ics</item> <item name="colorTypedWord">@color/highlight_color_ics</item> diff --git a/java/res/values/themes-basic-highcontrast.xml b/java/res/values/themes-basic-highcontrast.xml index 48df0a1b68..e81d473869 100644 --- a/java/res/values/themes-basic-highcontrast.xml +++ b/java/res/values/themes-basic-highcontrast.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-basic.xml b/java/res/values/themes-basic.xml index 88a0c5d8db..c44f0f614f 100644 --- a/java/res/values/themes-basic.xml +++ b/java/res/values/themes-basic.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-gingerbread.xml b/java/res/values/themes-gingerbread.xml index 51f680a7aa..129afdf5b5 100644 --- a/java/res/values/themes-gingerbread.xml +++ b/java/res/values/themes-gingerbread.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Gingerbread</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml index d9c59a1803..1264831f31 100644 --- a/java/res/values/themes-ics.xml +++ b/java/res/values/themes-ics.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.IceCreamSandwich</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle.IceCreamSandwich</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle.IceCreamSandwich</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle.IceCreamSandwich</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item> diff --git a/java/res/values/themes-stone-bold.xml b/java/res/values/themes-stone-bold.xml index 6ace9d673a..196f3ef9f8 100644 --- a/java/res/values/themes-stone-bold.xml +++ b/java/res/values/themes-stone-bold.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-stone.xml b/java/res/values/themes-stone.xml index 3c3826b1a1..d0d35c28dc 100644 --- a/java/res/values/themes-stone.xml +++ b/java/res/values/themes-stone.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/src/com/android/inputmethod/latin/InputView.java b/java/src/com/android/inputmethod/latin/InputView.java index 5359c81859..1cf17c8c0e 100644 --- a/java/src/com/android/inputmethod/latin/InputView.java +++ b/java/src/com/android/inputmethod/latin/InputView.java @@ -24,7 +24,7 @@ import android.view.View; import android.widget.LinearLayout; public final class InputView extends LinearLayout { - private View mSuggestionStripContainer; + private View mSuggestionStripView; private View mKeyboardView; private int mKeyboardTopPadding; @@ -43,13 +43,13 @@ public final class InputView extends LinearLayout { @Override protected void onFinishInflate() { - mSuggestionStripContainer = findViewById(R.id.suggestions_container); + mSuggestionStripView = findViewById(R.id.suggestion_strip_view); mKeyboardView = findViewById(R.id.keyboard_view); } @Override public boolean dispatchTouchEvent(MotionEvent me) { - if (mSuggestionStripContainer.getVisibility() == VISIBLE + if (mSuggestionStripView.getVisibility() == VISIBLE && mKeyboardView.getVisibility() == VISIBLE && forwardTouchEvent(me)) { return true; @@ -97,7 +97,7 @@ public final class InputView extends LinearLayout { } final Rect receivingRect = mEventReceivingRect; - mSuggestionStripContainer.getGlobalVisibleRect(receivingRect); + mSuggestionStripView.getGlobalVisibleRect(receivingRect); final int translatedX = x - receivingRect.left; final int translatedY; if (y < forwardingLimitY) { @@ -107,7 +107,7 @@ public final class InputView extends LinearLayout { translatedY = y - receivingRect.top; } me.setLocation(translatedX, translatedY); - mSuggestionStripContainer.dispatchTouchEvent(me); + mSuggestionStripView.dispatchTouchEvent(me); return true; } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 385e884abc..e1906c5fed 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -152,7 +152,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private View mExtractArea; private View mKeyPreviewBackingView; - private View mSuggestionsContainer; private SuggestionStripView mSuggestionStripView; // Never null private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; @@ -667,7 +666,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mExtractArea = getWindow().getWindow().getDecorView() .findViewById(android.R.id.extractArea); mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing); - mSuggestionsContainer = view.findViewById(R.id.suggestions_container); mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view); if (mSuggestionStripView != null) mSuggestionStripView.setListener(this, view); @@ -1111,17 +1109,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void setSuggestionStripShownInternal(final boolean shown, final boolean needsInputViewShown) { // TODO: Modify this if we support suggestions with hard keyboard - if (onEvaluateInputViewShown() && mSuggestionsContainer != null) { + if (onEvaluateInputViewShown() && mSuggestionStripView != null) { final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); final boolean inputViewShown = (mainKeyboardView != null) ? mainKeyboardView.isShown() : false; final boolean shouldShowSuggestions = shown && (needsInputViewShown ? inputViewShown : true); if (isFullscreenMode()) { - mSuggestionsContainer.setVisibility( + mSuggestionStripView.setVisibility( shouldShowSuggestions ? View.VISIBLE : View.GONE); } else { - mSuggestionsContainer.setVisibility( + mSuggestionStripView.setVisibility( shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE); } } @@ -1142,7 +1140,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return 0; } final int keyboardHeight = mainKeyboardView.getHeight(); - final int suggestionsHeight = mSuggestionsContainer.getHeight(); + final int suggestionsHeight = mSuggestionStripView.getHeight(); final int displayHeight = getResources().getDisplayMetrics().heightPixels; final Rect rect = new Rect(); mKeyPreviewBackingView.getWindowVisibleDisplayFrame(rect); @@ -1160,7 +1158,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onComputeInsets(final InputMethodService.Insets outInsets) { super.onComputeInsets(outInsets); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - if (mainKeyboardView == null || mSuggestionsContainer == null) { + if (mainKeyboardView == null || mSuggestionStripView == null) { return; } final int adjustedBackingHeight = getAdjustedBackingViewHeight(); @@ -1170,13 +1168,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // be considered. // See {@link android.inputmethodservice.InputMethodService#onComputeInsets}. final int extractHeight = isFullscreenMode() ? mExtractArea.getHeight() : 0; - final int suggestionsHeight = (mSuggestionsContainer.getVisibility() == View.GONE) ? 0 - : mSuggestionsContainer.getHeight(); + final int suggestionsHeight = (mSuggestionStripView.getVisibility() == View.GONE) ? 0 + : mSuggestionStripView.getHeight(); final int extraHeight = extractHeight + backingHeight + suggestionsHeight; int visibleTopY = extraHeight; // Need to set touchable region only if input view is being shown if (mainKeyboardView.isShown()) { - if (mSuggestionsContainer.getVisibility() == View.VISIBLE) { + if (mSuggestionStripView.getVisibility() == View.VISIBLE) { visibleTopY -= suggestionsHeight; } final int touchY = mainKeyboardView.isShowingMoreKeysPanel() ? 0 : visibleTopY; -- GitLab