Loading java/res/layout/hint_add_to_dictionary.xmldeleted 100644 → 0 +0 −36 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <!-- This is derived from suggestion_word.xml without minWidth attribute and padding --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="@dimen/config_suggestion_text_size" android:gravity="center" android:paddingLeft="0dp" android:paddingTop="0dp" android:paddingRight="0dp" android:paddingBottom="0dp" android:focusable="false" android:clickable="false" android:singleLine="true" android:ellipsize="none" style="?attr/suggestionWordStyle" /> java/res/layout/suggestions_strip.xml +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ <include layout="@layout/suggestion_divider" /> <include layout="@layout/hint_add_to_dictionary" layout="@layout/suggestion_word" android:id="@+id/hint_add_to_dictionary" /> </LinearLayout> </merge> java/src/com/android/inputmethod/latin/LatinIME.java +3 −1 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.JniUtils; import com.android.inputmethod.latin.utils.LatinImeLoggerUtils; import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.research.ResearchLogger; import java.io.FileDescriptor; Loading Loading @@ -1326,7 +1327,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // TODO[IL]: Define a clear interface for this public void setSuggestedWords(final SuggestedWords words, final boolean shouldShow) { if (mSuggestionStripView != null) { mSuggestionStripView.setSuggestions(words); mSuggestionStripView.setSuggestions( words, SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype())); mKeyboardSwitcher.onAutoCorrectionStateChanged(words.mWillAutoCorrect); } mInputLogic.mSuggestedWords = words; Loading java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +8 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewCompat; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; Loading @@ -39,7 +41,6 @@ import android.text.style.UnderlineSpan; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; Loading Loading @@ -88,6 +89,7 @@ final class SuggestionStripLayoutHelper { private final Drawable mMoreSuggestionsHint; private static final String MORE_SUGGESTIONS_HINT = "\u2026"; private static final String LEFTWARDS_ARROW = "\u2190"; private static final String RIGHTWARDS_ARROW = "\u2192"; private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD); private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan(); Loading Loading @@ -471,10 +473,13 @@ final class SuggestionStripLayoutHelper { final TextView hintView = (TextView)addToDictionaryStrip.findViewById( R.id.hint_add_to_dictionary); hintView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); hintView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL | GravityCompat.START); hintView.setTextColor(mColorAutoCorrect); final boolean isRtlLanguage = (ViewCompat.getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL); final String hintWithArrow = (isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW) + hintText; final int hintWidth = width - wordWidth; final String hintWithArrow = LEFTWARDS_ARROW + hintText; final float hintScaleX = getTextScaleX(hintWithArrow, hintWidth, hintView.getPaint()); hintView.setText(hintWithArrow); hintView.setTextScaleX(hintScaleX); Loading java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +10 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.latin.suggestions; import android.content.Context; import android.content.res.Resources; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.LayoutInflater; Loading Loading @@ -84,6 +85,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick showSuggestionsStrip(); } public void setLayoutDirection(final boolean isRtlLanguage) { final int layoutDirection = isRtlLanguage ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR; ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection); ViewCompat.setLayoutDirection(mAddToDictionaryStrip, layoutDirection); } public void showSuggestionsStrip() { mSuggestionsStrip.setVisibility(VISIBLE); mAddToDictionaryStrip.setVisibility(INVISIBLE); Loading Loading @@ -154,8 +162,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view); } public void setSuggestions(final SuggestedWords suggestedWords) { public void setSuggestions(final SuggestedWords suggestedWords, final boolean isRtlLanguage) { clear(); mStripVisibilityGroup.setLayoutDirection(isRtlLanguage); mSuggestedWords = suggestedWords; mLayoutHelper.layout(mSuggestedWords, mSuggestionsStrip, this); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { Loading Loading
java/res/layout/hint_add_to_dictionary.xmldeleted 100644 → 0 +0 −36 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- /* ** ** Copyright 2012, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ --> <!-- This is derived from suggestion_word.xml without minWidth attribute and padding --> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:textSize="@dimen/config_suggestion_text_size" android:gravity="center" android:paddingLeft="0dp" android:paddingTop="0dp" android:paddingRight="0dp" android:paddingBottom="0dp" android:focusable="false" android:clickable="false" android:singleLine="true" android:ellipsize="none" style="?attr/suggestionWordStyle" />
java/res/layout/suggestions_strip.xml +1 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ <include layout="@layout/suggestion_divider" /> <include layout="@layout/hint_add_to_dictionary" layout="@layout/suggestion_word" android:id="@+id/hint_add_to_dictionary" /> </LinearLayout> </merge>
java/src/com/android/inputmethod/latin/LatinIME.java +3 −1 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ import com.android.inputmethod.latin.utils.IntentUtils; import com.android.inputmethod.latin.utils.JniUtils; import com.android.inputmethod.latin.utils.LatinImeLoggerUtils; import com.android.inputmethod.latin.utils.LeakGuardHandlerWrapper; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.research.ResearchLogger; import java.io.FileDescriptor; Loading Loading @@ -1326,7 +1327,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // TODO[IL]: Define a clear interface for this public void setSuggestedWords(final SuggestedWords words, final boolean shouldShow) { if (mSuggestionStripView != null) { mSuggestionStripView.setSuggestions(words); mSuggestionStripView.setSuggestions( words, SubtypeLocaleUtils.isRtlLanguage(mSubtypeSwitcher.getCurrentSubtype())); mKeyboardSwitcher.onAutoCorrectionStateChanged(words.mWillAutoCorrect); } mInputLogic.mSuggestedWords = words; Loading
java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +8 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.graphics.Rect; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.support.v4.view.GravityCompat; import android.support.v4.view.ViewCompat; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; Loading @@ -39,7 +41,6 @@ import android.text.style.UnderlineSpan; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; Loading Loading @@ -88,6 +89,7 @@ final class SuggestionStripLayoutHelper { private final Drawable mMoreSuggestionsHint; private static final String MORE_SUGGESTIONS_HINT = "\u2026"; private static final String LEFTWARDS_ARROW = "\u2190"; private static final String RIGHTWARDS_ARROW = "\u2192"; private static final CharacterStyle BOLD_SPAN = new StyleSpan(Typeface.BOLD); private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan(); Loading Loading @@ -471,10 +473,13 @@ final class SuggestionStripLayoutHelper { final TextView hintView = (TextView)addToDictionaryStrip.findViewById( R.id.hint_add_to_dictionary); hintView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); hintView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL | GravityCompat.START); hintView.setTextColor(mColorAutoCorrect); final boolean isRtlLanguage = (ViewCompat.getLayoutDirection(addToDictionaryStrip) == ViewCompat.LAYOUT_DIRECTION_RTL); final String hintWithArrow = (isRtlLanguage ? RIGHTWARDS_ARROW : LEFTWARDS_ARROW) + hintText; final int hintWidth = width - wordWidth; final String hintWithArrow = LEFTWARDS_ARROW + hintText; final float hintScaleX = getTextScaleX(hintWithArrow, hintWidth, hintView.getPaint()); hintView.setText(hintWithArrow); hintView.setTextScaleX(hintScaleX); Loading
java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java +10 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.inputmethod.latin.suggestions; import android.content.Context; import android.content.res.Resources; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.LayoutInflater; Loading Loading @@ -84,6 +85,13 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick showSuggestionsStrip(); } public void setLayoutDirection(final boolean isRtlLanguage) { final int layoutDirection = isRtlLanguage ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR; ViewCompat.setLayoutDirection(mSuggestionsStrip, layoutDirection); ViewCompat.setLayoutDirection(mAddToDictionaryStrip, layoutDirection); } public void showSuggestionsStrip() { mSuggestionsStrip.setVisibility(VISIBLE); mAddToDictionaryStrip.setVisibility(INVISIBLE); Loading Loading @@ -154,8 +162,9 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick mMainKeyboardView = (MainKeyboardView)inputView.findViewById(R.id.keyboard_view); } public void setSuggestions(final SuggestedWords suggestedWords) { public void setSuggestions(final SuggestedWords suggestedWords, final boolean isRtlLanguage) { clear(); mStripVisibilityGroup.setLayoutDirection(isRtlLanguage); mSuggestedWords = suggestedWords; mLayoutHelper.layout(mSuggestedWords, mSuggestionsStrip, this); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { Loading