Merge "Remove unnecessary suggestion strip container"

main
Tadashi G. Takaoka 2013-08-06 02:55:37 +00:00 committed by Android (Google) Code Review
commit daab5cafd2
11 changed files with 25 additions and 57 deletions

View File

@ -30,34 +30,17 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" /> 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"
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 <!-- 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+. --> one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. -->
<com.android.inputmethod.latin.suggestions.SuggestionStripView <com.android.inputmethod.latin.suggestions.SuggestionStripView
android:id="@+id/suggestion_strip_view" android:id="@+id/suggestion_strip_view"
android:layoutDirection="ltr" android:layoutDirection="ltr"
android:layout_weight="1.0" android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="@dimen/suggestions_strip_height" android:layout_height="@dimen/suggestions_strip_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingRight="@dimen/suggestions_strip_padding"
android:paddingLeft="@dimen/suggestions_strip_padding"
style="?attr/suggestionStripViewStyle" /> style="?attr/suggestionStripViewStyle" />
<View
android:layout_width="@dimen/suggestions_strip_padding"
android:layout_height="@dimen/suggestions_strip_height"
style="?attr/suggestionsStripBackgroundStyle" />
</LinearLayout>
<!-- To ensure that key preview popup is correctly placed when the current system locale is <!-- 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+. --> one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. -->

View File

@ -28,7 +28,6 @@
<attr name="moreKeysKeyboardViewStyle" format="reference" /> <attr name="moreKeysKeyboardViewStyle" format="reference" />
<attr name="moreKeysKeyboardPanelStyle" format="reference" /> <attr name="moreKeysKeyboardPanelStyle" format="reference" />
<!-- Suggestions strip style --> <!-- Suggestions strip style -->
<attr name="suggestionsStripBackgroundStyle" format="reference" />
<attr name="suggestionStripViewStyle" format="reference" /> <attr name="suggestionStripViewStyle" format="reference" />
<attr name="moreSuggestionsViewStyle" format="reference" /> <attr name="moreSuggestionsViewStyle" format="reference" />
<attr name="suggestionBackgroundStyle" format="reference" /> <attr name="suggestionBackgroundStyle" format="reference" />

View File

@ -145,13 +145,10 @@
<style name="MoreKeysKeyboardPanelStyle"> <style name="MoreKeysKeyboardPanelStyle">
<item name="android:background">@drawable/keyboard_popup_panel_background</item> <item name="android:background">@drawable/keyboard_popup_panel_background</item>
</style> </style>
<style name="SuggestionsStripBackgroundStyle">
<item name="android:background">@drawable/keyboard_suggest_strip</item>
</style>
<style <style
name="SuggestionStripViewStyle" name="SuggestionStripViewStyle"
parent="SuggestionsStripBackgroundStyle"
> >
<item name="android:background">@drawable/keyboard_suggest_strip</item>
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
<item name="colorValidTypedWord">@color/highlight_color_default</item> <item name="colorValidTypedWord">@color/highlight_color_default</item>
<item name="colorTypedWord">@color/typed_word_color_default</item> <item name="colorTypedWord">@color/typed_word_color_default</item>
@ -380,13 +377,10 @@
<style name="MoreKeysKeyboardPanelStyle.IceCreamSandwich"> <style name="MoreKeysKeyboardPanelStyle.IceCreamSandwich">
<item name="android:background">@drawable/keyboard_popup_panel_background_holo</item> <item name="android:background">@drawable/keyboard_popup_panel_background_holo</item>
</style> </style>
<style name="SuggestionsStripBackgroundStyle.IceCreamSandwich">
<item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
</style>
<style <style
name="SuggestionStripViewStyle.IceCreamSandwich" name="SuggestionStripViewStyle.IceCreamSandwich"
parent="SuggestionsStripBackgroundStyle.IceCreamSandwich"
> >
<item name="android:background">@drawable/keyboard_suggest_strip_holo</item>
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
<item name="colorValidTypedWord">@color/highlight_color_ics</item> <item name="colorValidTypedWord">@color/highlight_color_ics</item>
<item name="colorTypedWord">@color/highlight_color_ics</item> <item name="colorTypedWord">@color/highlight_color_ics</item>

View File

@ -22,7 +22,6 @@
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>

View File

@ -22,7 +22,6 @@
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>

View File

@ -22,7 +22,6 @@
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Gingerbread</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Gingerbread</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>

View File

@ -22,7 +22,6 @@
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.IceCreamSandwich</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.IceCreamSandwich</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle.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="suggestionStripViewStyle">@style/SuggestionStripViewStyle.IceCreamSandwich</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item>

View File

@ -22,7 +22,6 @@
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>

View File

@ -22,7 +22,6 @@
<item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item>
<item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item>
<item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item>
<item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item>
<item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item>
<item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item>
<item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item>

View File

@ -24,7 +24,7 @@ import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
public final class InputView extends LinearLayout { public final class InputView extends LinearLayout {
private View mSuggestionStripContainer; private View mSuggestionStripView;
private View mKeyboardView; private View mKeyboardView;
private int mKeyboardTopPadding; private int mKeyboardTopPadding;
@ -43,13 +43,13 @@ public final class InputView extends LinearLayout {
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
mSuggestionStripContainer = findViewById(R.id.suggestions_container); mSuggestionStripView = findViewById(R.id.suggestion_strip_view);
mKeyboardView = findViewById(R.id.keyboard_view); mKeyboardView = findViewById(R.id.keyboard_view);
} }
@Override @Override
public boolean dispatchTouchEvent(MotionEvent me) { public boolean dispatchTouchEvent(MotionEvent me) {
if (mSuggestionStripContainer.getVisibility() == VISIBLE if (mSuggestionStripView.getVisibility() == VISIBLE
&& mKeyboardView.getVisibility() == VISIBLE && mKeyboardView.getVisibility() == VISIBLE
&& forwardTouchEvent(me)) { && forwardTouchEvent(me)) {
return true; return true;
@ -97,7 +97,7 @@ public final class InputView extends LinearLayout {
} }
final Rect receivingRect = mEventReceivingRect; final Rect receivingRect = mEventReceivingRect;
mSuggestionStripContainer.getGlobalVisibleRect(receivingRect); mSuggestionStripView.getGlobalVisibleRect(receivingRect);
final int translatedX = x - receivingRect.left; final int translatedX = x - receivingRect.left;
final int translatedY; final int translatedY;
if (y < forwardingLimitY) { if (y < forwardingLimitY) {
@ -107,7 +107,7 @@ public final class InputView extends LinearLayout {
translatedY = y - receivingRect.top; translatedY = y - receivingRect.top;
} }
me.setLocation(translatedX, translatedY); me.setLocation(translatedX, translatedY);
mSuggestionStripContainer.dispatchTouchEvent(me); mSuggestionStripView.dispatchTouchEvent(me);
return true; return true;
} }
} }

View File

@ -152,7 +152,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private View mExtractArea; private View mExtractArea;
private View mKeyPreviewBackingView; private View mKeyPreviewBackingView;
private View mSuggestionsContainer;
private SuggestionStripView mSuggestionStripView; private SuggestionStripView mSuggestionStripView;
// Never null // Never null
private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY;
@ -667,7 +666,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mExtractArea = getWindow().getWindow().getDecorView() mExtractArea = getWindow().getWindow().getDecorView()
.findViewById(android.R.id.extractArea); .findViewById(android.R.id.extractArea);
mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing); mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing);
mSuggestionsContainer = view.findViewById(R.id.suggestions_container);
mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view); mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view);
if (mSuggestionStripView != null) if (mSuggestionStripView != null)
mSuggestionStripView.setListener(this, view); mSuggestionStripView.setListener(this, view);
@ -1111,17 +1109,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private void setSuggestionStripShownInternal(final boolean shown, private void setSuggestionStripShownInternal(final boolean shown,
final boolean needsInputViewShown) { final boolean needsInputViewShown) {
// TODO: Modify this if we support suggestions with hard keyboard // TODO: Modify this if we support suggestions with hard keyboard
if (onEvaluateInputViewShown() && mSuggestionsContainer != null) { if (onEvaluateInputViewShown() && mSuggestionStripView != null) {
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
final boolean inputViewShown = (mainKeyboardView != null) final boolean inputViewShown = (mainKeyboardView != null)
? mainKeyboardView.isShown() : false; ? mainKeyboardView.isShown() : false;
final boolean shouldShowSuggestions = shown final boolean shouldShowSuggestions = shown
&& (needsInputViewShown ? inputViewShown : true); && (needsInputViewShown ? inputViewShown : true);
if (isFullscreenMode()) { if (isFullscreenMode()) {
mSuggestionsContainer.setVisibility( mSuggestionStripView.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.GONE); shouldShowSuggestions ? View.VISIBLE : View.GONE);
} else { } else {
mSuggestionsContainer.setVisibility( mSuggestionStripView.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE); shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE);
} }
} }
@ -1142,7 +1140,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return 0; return 0;
} }
final int keyboardHeight = mainKeyboardView.getHeight(); final int keyboardHeight = mainKeyboardView.getHeight();
final int suggestionsHeight = mSuggestionsContainer.getHeight(); final int suggestionsHeight = mSuggestionStripView.getHeight();
final int displayHeight = getResources().getDisplayMetrics().heightPixels; final int displayHeight = getResources().getDisplayMetrics().heightPixels;
final Rect rect = new Rect(); final Rect rect = new Rect();
mKeyPreviewBackingView.getWindowVisibleDisplayFrame(rect); mKeyPreviewBackingView.getWindowVisibleDisplayFrame(rect);
@ -1160,7 +1158,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
public void onComputeInsets(final InputMethodService.Insets outInsets) { public void onComputeInsets(final InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets); super.onComputeInsets(outInsets);
final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView();
if (mainKeyboardView == null || mSuggestionsContainer == null) { if (mainKeyboardView == null || mSuggestionStripView == null) {
return; return;
} }
final int adjustedBackingHeight = getAdjustedBackingViewHeight(); final int adjustedBackingHeight = getAdjustedBackingViewHeight();
@ -1170,13 +1168,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// be considered. // be considered.
// See {@link android.inputmethodservice.InputMethodService#onComputeInsets}. // See {@link android.inputmethodservice.InputMethodService#onComputeInsets}.
final int extractHeight = isFullscreenMode() ? mExtractArea.getHeight() : 0; final int extractHeight = isFullscreenMode() ? mExtractArea.getHeight() : 0;
final int suggestionsHeight = (mSuggestionsContainer.getVisibility() == View.GONE) ? 0 final int suggestionsHeight = (mSuggestionStripView.getVisibility() == View.GONE) ? 0
: mSuggestionsContainer.getHeight(); : mSuggestionStripView.getHeight();
final int extraHeight = extractHeight + backingHeight + suggestionsHeight; final int extraHeight = extractHeight + backingHeight + suggestionsHeight;
int visibleTopY = extraHeight; int visibleTopY = extraHeight;
// Need to set touchable region only if input view is being shown // Need to set touchable region only if input view is being shown
if (mainKeyboardView.isShown()) { if (mainKeyboardView.isShown()) {
if (mSuggestionsContainer.getVisibility() == View.VISIBLE) { if (mSuggestionStripView.getVisibility() == View.VISIBLE) {
visibleTopY -= suggestionsHeight; visibleTopY -= suggestionsHeight;
} }
final int touchY = mainKeyboardView.isShowingMoreKeysPanel() ? 0 : visibleTopY; final int touchY = mainKeyboardView.isShowingMoreKeysPanel() ? 0 : visibleTopY;