Fix "touch to save" colors
Bug: 5218662 Change-Id: I094b2ceb7438148eb5bdf620b188f598e8442a07main
parent
de4e8dedcc
commit
c04bbc1ae9
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
|
@ -25,35 +25,6 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/candidates_strip"
|
android:id="@+id/candidates_strip"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_weight="1.0"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/touch_to_save"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent" />
|
||||||
android:visibility="gone"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
android:id="@+id/word_to_save"
|
|
||||||
android:layout_weight="1.0"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:textSize="@dimen/candidate_text_size"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="middle"
|
|
||||||
style="?attr/suggestionBackgroundStyle" />
|
|
||||||
<include
|
|
||||||
layout="@layout/candidate_divider" />
|
|
||||||
<TextView
|
|
||||||
android:layout_weight="2.0"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="left|center_vertical"
|
|
||||||
android:text="@string/hint_add_to_dictionary"
|
|
||||||
android:textSize="@dimen/candidate_text_size"
|
|
||||||
android:background="@null" />
|
|
||||||
</LinearLayout>
|
|
||||||
</merge>
|
</merge>
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
<item name="maxPopupKeyboardColumn">@integer/config_max_popup_keyboard_column</item>
|
<item name="maxPopupKeyboardColumn">@integer/config_max_popup_keyboard_column</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="LatinKeyboard">
|
<style name="LatinKeyboard">
|
||||||
<item name="autoCorrectionSpacebarLedEnabled">@bool/config_auto_correction_spacebar_led_enabled</item>
|
<item name="autoCorrectionSpacebarLedEnabled">@bool/config_auto_correction_spacebar_led_enabled
|
||||||
|
</item>
|
||||||
<item name="spacebarTextColor">#FFC0C0C0</item>
|
<item name="spacebarTextColor">#FFC0C0C0</item>
|
||||||
<item name="spacebarTextShadowColor">#80000000</item>
|
<item name="spacebarTextShadowColor">#80000000</item>
|
||||||
</style>
|
</style>
|
||||||
|
@ -66,7 +67,10 @@
|
||||||
<item name="shadowRadius">2.75</item>
|
<item name="shadowRadius">2.75</item>
|
||||||
<item name="backgroundDimAmount">0.5</item>
|
<item name="backgroundDimAmount">0.5</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="PopupMiniKeyboardView" parent="KeyboardView">
|
<style
|
||||||
|
name="PopupMiniKeyboardView"
|
||||||
|
parent="KeyboardView"
|
||||||
|
>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_popup</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_popup</item>
|
||||||
<item name="verticalCorrection">@dimen/mini_keyboard_vertical_correction</item>
|
<item name="verticalCorrection">@dimen/mini_keyboard_vertical_correction</item>
|
||||||
</style>
|
</style>
|
||||||
|
@ -84,7 +88,10 @@
|
||||||
<style name="SuggestionPreviewBackgroundStyle">
|
<style name="SuggestionPreviewBackgroundStyle">
|
||||||
<item name="android:background">@drawable/candidate_feedback_background</item>
|
<item name="android:background">@drawable/candidate_feedback_background</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="CandidateViewStyle" parent="SuggestionsStripBackgroundStyle">
|
<style
|
||||||
|
name="CandidateViewStyle"
|
||||||
|
parent="SuggestionsStripBackgroundStyle"
|
||||||
|
>
|
||||||
<item name="suggestionStripOption">autoCorrectBold</item>
|
<item name="suggestionStripOption">autoCorrectBold</item>
|
||||||
<item name="colorTypedWord">#FFFFFFFF</item>
|
<item name="colorTypedWord">#FFFFFFFF</item>
|
||||||
<item name="colorAutoCorrect">#FFFCAE00</item>
|
<item name="colorAutoCorrect">#FFFCAE00</item>
|
||||||
|
@ -93,23 +100,35 @@
|
||||||
<item name="centerCandidatePercentile">@integer/center_candidate_percentile</item>
|
<item name="centerCandidatePercentile">@integer/center_candidate_percentile</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "Basic high contrast" -->
|
<!-- Theme "Basic high contrast" -->
|
||||||
<style name="KeyboardView.HighContrast" parent="KeyboardView">
|
<style
|
||||||
|
name="KeyboardView.HighContrast"
|
||||||
|
parent="KeyboardView"
|
||||||
|
>
|
||||||
<item name="android:background">@android:color/black</item>
|
<item name="android:background">@android:color/black</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key3</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key3</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "Stone" -->
|
<!-- Theme "Stone" -->
|
||||||
<style name="Keyboard.Stone" parent="Keyboard">
|
<style
|
||||||
|
name="Keyboard.Stone"
|
||||||
|
parent="Keyboard"
|
||||||
|
>
|
||||||
<item name="keyboardHeight">@dimen/keyboardHeight_stone</item>
|
<item name="keyboardHeight">@dimen/keyboardHeight_stone</item>
|
||||||
<item name="keyboardTopPadding">@fraction/keyboard_top_padding_stone</item>
|
<item name="keyboardTopPadding">@fraction/keyboard_top_padding_stone</item>
|
||||||
<item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_stone</item>
|
<item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_stone</item>
|
||||||
<item name="horizontalGap">@fraction/key_horizontal_gap_stone</item>
|
<item name="horizontalGap">@fraction/key_horizontal_gap_stone</item>
|
||||||
<item name="verticalGap">@fraction/key_bottom_gap_stone</item>
|
<item name="verticalGap">@fraction/key_bottom_gap_stone</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="LatinKeyboard.Stone" parent="LatinKeyboard">
|
<style
|
||||||
|
name="LatinKeyboard.Stone"
|
||||||
|
parent="LatinKeyboard"
|
||||||
|
>
|
||||||
<item name="spacebarTextColor">#FF000000</item>
|
<item name="spacebarTextColor">#FF000000</item>
|
||||||
<item name="spacebarTextShadowColor">#D0FFFFFF</item>
|
<item name="spacebarTextShadowColor">#D0FFFFFF</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardView.Stone" parent="KeyboardView">
|
<style
|
||||||
|
name="KeyboardView.Stone"
|
||||||
|
parent="KeyboardView"
|
||||||
|
>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
|
||||||
<item name="keyTextColor">#FF000000</item>
|
<item name="keyTextColor">#FF000000</item>
|
||||||
<item name="keyTextInactivatedColor">#FF808080</item>
|
<item name="keyTextInactivatedColor">#FF808080</item>
|
||||||
|
@ -119,39 +138,63 @@
|
||||||
<item name="keyUppercaseLetterActivatedColor">#CC000000</item>
|
<item name="keyUppercaseLetterActivatedColor">#CC000000</item>
|
||||||
<item name="shadowColor">#FFFFFFFF</item>
|
<item name="shadowColor">#FFFFFFFF</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="PopupMiniKeyboardView.Stone" parent="PopupMiniKeyboardView">
|
<style
|
||||||
|
name="PopupMiniKeyboardView.Stone"
|
||||||
|
parent="PopupMiniKeyboardView"
|
||||||
|
>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_stone</item>
|
||||||
<item name="keyTextColor">#FF000000</item>
|
<item name="keyTextColor">#FF000000</item>
|
||||||
<item name="shadowColor">#FFFFFFFF</item>
|
<item name="shadowColor">#FFFFFFFF</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "Stone bold" -->
|
<!-- Theme "Stone bold" -->
|
||||||
<style name="KeyboardView.Stone.Bold" parent="KeyboardView.Stone">
|
<style
|
||||||
|
name="KeyboardView.Stone.Bold"
|
||||||
|
parent="KeyboardView.Stone"
|
||||||
|
>
|
||||||
<item name="keyTextStyle">bold</item>
|
<item name="keyTextStyle">bold</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "Gingerbread" -->
|
<!-- Theme "Gingerbread" -->
|
||||||
<style name="Keyboard.Gingerbread" parent="Keyboard">
|
<style
|
||||||
|
name="Keyboard.Gingerbread"
|
||||||
|
parent="Keyboard"
|
||||||
|
>
|
||||||
<item name="horizontalGap">@fraction/key_horizontal_gap_gb</item>
|
<item name="horizontalGap">@fraction/key_horizontal_gap_gb</item>
|
||||||
<item name="verticalGap">@fraction/key_bottom_gap_gb</item>
|
<item name="verticalGap">@fraction/key_bottom_gap_gb</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardView.Gingerbread" parent="KeyboardView">
|
<style
|
||||||
|
name="KeyboardView.Gingerbread"
|
||||||
|
parent="KeyboardView"
|
||||||
|
>
|
||||||
<item name="android:background">@drawable/keyboard_dark_background</item>
|
<item name="android:background">@drawable/keyboard_dark_background</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_gingerbread</item>
|
||||||
<item name="keyTextStyle">bold</item>
|
<item name="keyTextStyle">bold</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="PopupMiniKeyboardView.Gingerbread" parent="PopupMiniKeyboardView">
|
<style
|
||||||
|
name="PopupMiniKeyboardView.Gingerbread"
|
||||||
|
parent="PopupMiniKeyboardView"
|
||||||
|
>
|
||||||
<item name="android:background">@null</item>
|
<item name="android:background">@null</item>
|
||||||
</style>
|
</style>
|
||||||
<!-- Theme "IceCreamSandwich" -->
|
<!-- Theme "IceCreamSandwich" -->
|
||||||
<style name="Keyboard.IceCreamSandwich" parent="Keyboard" >
|
<style
|
||||||
|
name="Keyboard.IceCreamSandwich"
|
||||||
|
parent="Keyboard"
|
||||||
|
>
|
||||||
<item name="keyboardTopPadding">@fraction/keyboard_top_padding_ics</item>
|
<item name="keyboardTopPadding">@fraction/keyboard_top_padding_ics</item>
|
||||||
<item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_ics</item>
|
<item name="keyboardBottomPadding">@fraction/keyboard_bottom_padding_ics</item>
|
||||||
<item name="horizontalGap">@fraction/key_horizontal_gap_ics</item>
|
<item name="horizontalGap">@fraction/key_horizontal_gap_ics</item>
|
||||||
<item name="verticalGap">@fraction/key_bottom_gap_ics</item>
|
<item name="verticalGap">@fraction/key_bottom_gap_ics</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="LatinKeyboard.IceCreamSandwich" parent="LatinKeyboard">
|
<style
|
||||||
|
name="LatinKeyboard.IceCreamSandwich"
|
||||||
|
parent="LatinKeyboard"
|
||||||
|
>
|
||||||
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
|
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="KeyboardView.IceCreamSandwich" parent="KeyboardView">
|
<style
|
||||||
|
name="KeyboardView.IceCreamSandwich"
|
||||||
|
parent="KeyboardView"
|
||||||
|
>
|
||||||
<item name="android:background">@drawable/keyboard_background_holo</item>
|
<item name="android:background">@drawable/keyboard_background_holo</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_ics</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_ics</item>
|
||||||
<item name="keyTextStyle">bold</item>
|
<item name="keyTextStyle">bold</item>
|
||||||
|
@ -169,7 +212,10 @@
|
||||||
<item name="shadowColor">#00000000</item>
|
<item name="shadowColor">#00000000</item>
|
||||||
<item name="shadowRadius">0.0</item>
|
<item name="shadowRadius">0.0</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="PopupMiniKeyboardView.IceCreamSandwich" parent="PopupMiniKeyboardView">
|
<style
|
||||||
|
name="PopupMiniKeyboardView.IceCreamSandwich"
|
||||||
|
parent="PopupMiniKeyboardView"
|
||||||
|
>
|
||||||
<item name="android:background">@null</item>
|
<item name="android:background">@null</item>
|
||||||
<item name="keyBackground">@drawable/btn_keyboard_key_popup_ics</item>
|
<item name="keyBackground">@drawable/btn_keyboard_key_popup_ics</item>
|
||||||
</style>
|
</style>
|
||||||
|
@ -184,10 +230,15 @@
|
||||||
<style name="SuggestionBackgroundStyle.IceCreamSandwich">
|
<style name="SuggestionBackgroundStyle.IceCreamSandwich">
|
||||||
<item name="android:background">@drawable/btn_candidate_ics</item>
|
<item name="android:background">@drawable/btn_candidate_ics</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="SuggestionPreviewBackgroundStyle.IceCreamSandwich">
|
<style
|
||||||
<item name="android:background">@drawable/keyboard_popup_panel_background_holo</item>
|
name="SuggestionPreviewBackgroundStyle.IceCreamSandwich"
|
||||||
|
parent="PopupMiniKeyboardPanelStyle.IceCreamSandwich"
|
||||||
|
>
|
||||||
</style>
|
</style>
|
||||||
<style name="CandidateViewStyle.IceCreamSandwich" parent="SuggestionsStripBackgroundStyle.IceCreamSandwich">
|
<style
|
||||||
|
name="CandidateViewStyle.IceCreamSandwich"
|
||||||
|
parent="SuggestionsStripBackgroundStyle.IceCreamSandwich"
|
||||||
|
>
|
||||||
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
|
<item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item>
|
||||||
<item name="colorTypedWord">#FFBCBEC0</item>
|
<item name="colorTypedWord">#FFBCBEC0</item>
|
||||||
<item name="colorAutoCorrect">#FF0099CC</item>
|
<item name="colorAutoCorrect">#FF0099CC</item>
|
||||||
|
|
|
@ -76,13 +76,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
private final PopupWindow mPreviewPopup;
|
private final PopupWindow mPreviewPopup;
|
||||||
private final TextView mPreviewText;
|
private final TextView mPreviewText;
|
||||||
|
|
||||||
private final View mTouchToSave;
|
|
||||||
private final TextView mWordToSave;
|
|
||||||
|
|
||||||
private Listener mListener;
|
private Listener mListener;
|
||||||
private SuggestedWords mSuggestions = SuggestedWords.EMPTY;
|
private SuggestedWords mSuggestions = SuggestedWords.EMPTY;
|
||||||
private boolean mShowingAutoCorrectionInverted;
|
private boolean mShowingAutoCorrectionInverted;
|
||||||
private boolean mShowingAddToDictionary;
|
|
||||||
|
|
||||||
private final SuggestionsStripParams mStripParams;
|
private final SuggestionsStripParams mStripParams;
|
||||||
private final SuggestionsPaneParams mPaneParams;
|
private final SuggestionsPaneParams mPaneParams;
|
||||||
|
@ -94,7 +90,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
private static final int MSG_HIDE_PREVIEW = 0;
|
private static final int MSG_HIDE_PREVIEW = 0;
|
||||||
private static final int MSG_UPDATE_SUGGESTION = 1;
|
private static final int MSG_UPDATE_SUGGESTION = 1;
|
||||||
|
|
||||||
private static final long DELAY_HIDE_PREVIEW = 1000;
|
private static final long DELAY_HIDE_PREVIEW = 1300;
|
||||||
private static final long DELAY_UPDATE_SUGGESTION = 300;
|
private static final long DELAY_UPDATE_SUGGESTION = 300;
|
||||||
|
|
||||||
public UiHandler(CandidateView outerInstance) {
|
public UiHandler(CandidateView outerInstance) {
|
||||||
|
@ -274,13 +270,16 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
private static final int AUTO_CORRECT_INVERT = 0x04;
|
private static final int AUTO_CORRECT_INVERT = 0x04;
|
||||||
private static final int VALID_TYPED_WORD_BOLD = 0x08;
|
private static final int VALID_TYPED_WORD_BOLD = 0x08;
|
||||||
|
|
||||||
private final TextPaint mPaint;
|
|
||||||
private final int mSuggestionStripOption;
|
private final int mSuggestionStripOption;
|
||||||
|
|
||||||
private final ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>();
|
private final ArrayList<CharSequence> mTexts = new ArrayList<CharSequence>();
|
||||||
|
|
||||||
public boolean mMoreSuggestionsAvailable;
|
public boolean mMoreSuggestionsAvailable;
|
||||||
|
|
||||||
|
public final TextView mWordToSaveView;
|
||||||
|
private final TextView mHintToSaveView;
|
||||||
|
private final CharSequence mHintToSaveText;
|
||||||
|
|
||||||
public SuggestionsStripParams(Context context, AttributeSet attrs, int defStyle,
|
public SuggestionsStripParams(Context context, AttributeSet attrs, int defStyle,
|
||||||
List<TextView> words, List<View> dividers, List<TextView> infos) {
|
List<TextView> words, List<View> dividers, List<TextView> infos) {
|
||||||
super(words, dividers, infos);
|
super(words, dividers, infos);
|
||||||
|
@ -305,9 +304,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
|
mInvertedForegroundColorSpan = new ForegroundColorSpan(mColorTypedWord ^ 0x00ffffff);
|
||||||
mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
|
mInvertedBackgroundColorSpan = new BackgroundColorSpan(mColorTypedWord);
|
||||||
|
|
||||||
mPaint = new TextPaint();
|
final LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
final float textSize = res.getDimension(R.dimen.candidate_text_size);
|
mWordToSaveView = (TextView)inflater.inflate(R.layout.candidate_word, null);
|
||||||
mPaint.setTextSize(textSize);
|
mHintToSaveView = (TextView)inflater.inflate(R.layout.candidate_word, null);
|
||||||
|
mHintToSaveText = context.getText(R.string.hint_add_to_dictionary);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTextColor() {
|
public int getTextColor() {
|
||||||
|
@ -498,6 +498,33 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
mMoreSuggestionsAvailable = false;
|
mMoreSuggestionsAvailable = false;
|
||||||
return countInStrip;
|
return countInStrip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void layoutAddToDictionaryHint(CharSequence word, ViewGroup stripView,
|
||||||
|
int stripWidth) {
|
||||||
|
final int width = stripWidth - mDividerWidth - mPadding * 2;
|
||||||
|
|
||||||
|
final TextView wordView = mWordToSaveView;
|
||||||
|
wordView.setTextColor(mColorTypedWord);
|
||||||
|
final int wordWidth = (int)(width * mCenterCandidateWeight);
|
||||||
|
final CharSequence text = getEllipsizedText(word, wordWidth, wordView.getPaint());
|
||||||
|
final float wordScaleX = wordView.getTextScaleX();
|
||||||
|
wordView.setTag(word);
|
||||||
|
wordView.setText(text);
|
||||||
|
wordView.setTextScaleX(wordScaleX);
|
||||||
|
stripView.addView(wordView);
|
||||||
|
setLayoutWeight(wordView, mCenterCandidateWeight, MATCH_PARENT);
|
||||||
|
|
||||||
|
stripView.addView(mDividers.get(0));
|
||||||
|
|
||||||
|
final TextView hintView = mHintToSaveView;
|
||||||
|
hintView.setTextColor(mColorAutoCorrect);
|
||||||
|
final int hintWidth = width - wordWidth;
|
||||||
|
final float hintScaleX = getTextScaleX(mHintToSaveText, hintWidth, hintView.getPaint());
|
||||||
|
hintView.setText(mHintToSaveText);
|
||||||
|
hintView.setTextScaleX(hintScaleX);
|
||||||
|
stripView.addView(hintView);
|
||||||
|
setLayoutWeight(hintView, 1.0f - mCenterCandidateWeight, MATCH_PARENT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -517,7 +544,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
if (defStyle != R.attr.candidateViewStyle) {
|
if (defStyle != R.attr.candidateViewStyle) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"can't accept defStyle other than R.attr.candidayeViewStyle: defStyle="
|
"can't accept defStyle other than R.attr.candidateViewStyle: defStyle="
|
||||||
+ defStyle);
|
+ defStyle);
|
||||||
}
|
}
|
||||||
setBackgroundDrawable(LinearLayoutCompatUtils.getBackgroundDrawable(
|
setBackgroundDrawable(LinearLayoutCompatUtils.getBackgroundDrawable(
|
||||||
|
@ -546,13 +573,10 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
mInfos.add((TextView)inflater.inflate(R.layout.candidate_info, null));
|
mInfos.add((TextView)inflater.inflate(R.layout.candidate_info, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
mTouchToSave = findViewById(R.id.touch_to_save);
|
|
||||||
mWordToSave = (TextView)findViewById(R.id.word_to_save);
|
|
||||||
mWordToSave.setOnClickListener(this);
|
|
||||||
|
|
||||||
mStripParams = new SuggestionsStripParams(context, attrs, defStyle, mWords, mDividers,
|
mStripParams = new SuggestionsStripParams(context, attrs, defStyle, mWords, mDividers,
|
||||||
mInfos);
|
mInfos);
|
||||||
mPaneParams = new SuggestionsPaneParams(mWords, mDividers, mInfos);
|
mPaneParams = new SuggestionsPaneParams(mWords, mDividers, mInfos);
|
||||||
|
mStripParams.mWordToSaveView.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -636,6 +660,15 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static float getTextScaleX(CharSequence text, int maxWidth, TextPaint paint) {
|
||||||
|
paint.setTextScaleX(1.0f);
|
||||||
|
final int width = getTextWidth(text, paint);
|
||||||
|
if (width <= maxWidth) {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
return maxWidth / (float)width;
|
||||||
|
}
|
||||||
|
|
||||||
private static CharSequence getEllipsizedText(CharSequence text, int maxWidth,
|
private static CharSequence getEllipsizedText(CharSequence text, int maxWidth,
|
||||||
TextPaint paint) {
|
TextPaint paint) {
|
||||||
if (text == null) return null;
|
if (text == null) return null;
|
||||||
|
@ -718,31 +751,29 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowingAddToDictionaryHint() {
|
public boolean isShowingAddToDictionaryHint() {
|
||||||
return mShowingAddToDictionary;
|
return mCandidatesStrip.getChildCount() > 0
|
||||||
|
&& mCandidatesStrip.getChildAt(0) == mStripParams.mWordToSaveView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAddToDictionaryHint(CharSequence word) {
|
public void showAddToDictionaryHint(CharSequence word) {
|
||||||
mWordToSave.setText(word);
|
clear();
|
||||||
mShowingAddToDictionary = true;
|
mStripParams.layoutAddToDictionaryHint(word, mCandidatesStrip, getWidth());
|
||||||
mCandidatesStrip.setVisibility(GONE);
|
|
||||||
mTouchToSave.setVisibility(VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dismissAddToDictionaryHint() {
|
public boolean dismissAddToDictionaryHint() {
|
||||||
if (!mShowingAddToDictionary) return false;
|
if (isShowingAddToDictionaryHint()) {
|
||||||
clear();
|
clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public SuggestedWords getSuggestions() {
|
public SuggestedWords getSuggestions() {
|
||||||
return mSuggestions;
|
return mSuggestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
mShowingAddToDictionary = false;
|
|
||||||
mShowingAutoCorrectionInverted = false;
|
mShowingAutoCorrectionInverted = false;
|
||||||
mTouchToSave.setVisibility(GONE);
|
|
||||||
mCandidatesStrip.setVisibility(VISIBLE);
|
|
||||||
mCandidatesStrip.removeAllViews();
|
mCandidatesStrip.removeAllViews();
|
||||||
mCandidatesPane.removeAllViews();
|
mCandidatesPane.removeAllViews();
|
||||||
closeCandidatesPane();
|
closeCandidatesPane();
|
||||||
|
@ -752,7 +783,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
mPreviewPopup.dismiss();
|
mPreviewPopup.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPreview(int index, CharSequence word) {
|
private void showPreview(View view, CharSequence word) {
|
||||||
if (TextUtils.isEmpty(word))
|
if (TextUtils.isEmpty(word))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -761,9 +792,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
previewText.setText(word);
|
previewText.setText(word);
|
||||||
previewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
previewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
|
||||||
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||||
View v = mWords.get(index);
|
|
||||||
final int[] offsetInWindow = new int[2];
|
final int[] offsetInWindow = new int[2];
|
||||||
v.getLocationInWindow(offsetInWindow);
|
view.getLocationInWindow(offsetInWindow);
|
||||||
final int posX = offsetInWindow[0];
|
final int posX = offsetInWindow[0];
|
||||||
final int posY = offsetInWindow[1] - previewText.getMeasuredHeight();
|
final int posY = offsetInWindow[1] - previewText.getMeasuredHeight();
|
||||||
final PopupWindow previewPopup = mPreviewPopup;
|
final PopupWindow previewPopup = mPreviewPopup;
|
||||||
|
@ -778,7 +808,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
|
|
||||||
private void addToDictionary(CharSequence word) {
|
private void addToDictionary(CharSequence word) {
|
||||||
if (mListener.addWordToDictionary(word.toString())) {
|
if (mListener.addWordToDictionary(word.toString())) {
|
||||||
showPreview(0, getContext().getString(R.string.added_word, word));
|
final CharSequence message = getContext().getString(R.string.added_word, word);
|
||||||
|
showPreview(mStripParams.mWordToSaveView, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,8 +824,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (view == mWordToSave) {
|
if (view == mStripParams.mWordToSaveView) {
|
||||||
addToDictionary(((TextView)view).getText());
|
addToDictionary((CharSequence)view.getTag());
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue