Merge "Use margin instead of padding in SuggestionStripView"

main
Tadashi G. Takaoka 2014-05-08 01:14:58 +00:00 committed by Android (Google) Code Review
commit e3e331aebb
10 changed files with 26 additions and 20 deletions

View File

@ -43,8 +43,6 @@
android:layout_width="match_parent"
android:layout_height="@dimen/config_suggestions_strip_height"
android:gravity="center_vertical"
android:paddingRight="@dimen/config_suggestions_strip_horizontal_padding"
android:paddingLeft="@dimen/config_suggestions_strip_horizontal_padding"
style="?attr/suggestionStripViewStyle" />
<!-- To ensure that key preview popup is correctly placed when the current system locale is

View File

@ -24,12 +24,16 @@
android:id="@+id/suggestions_strip"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/config_suggestions_strip_horizontal_margin"
android:layout_marginRight="@dimen/config_suggestions_strip_horizontal_margin" />
<LinearLayout
android:id="@+id/add_to_dictionary_strip"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/config_suggestions_strip_horizontal_margin"
android:layout_marginRight="@dimen/config_suggestions_strip_horizontal_margin"
android:visibility="invisible">
<TextView
android:id="@+id/word_to_save"
@ -49,7 +53,9 @@
android:id="@+id/important_notice_strip"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/config_suggestions_strip_horizontal_margin"
android:layout_marginRight="@dimen/config_suggestions_strip_horizontal_margin">
<TextView
android:id="@+id/important_notice_title"
android:layout_width="match_parent"

View File

@ -58,6 +58,7 @@
<fraction name="config_key_shifted_letter_hint_ratio_5row">48%</fraction>
<dimen name="config_suggestions_strip_height">36dp</dimen>
<dimen name="config_suggestions_strip_horizontal_margin">54dp</dimen>
<dimen name="config_more_suggestions_row_height">36dp</dimen>
<integer name="config_max_more_suggestions_row">2</integer>
<fraction name="config_min_more_suggestions_width">60%</fraction>

View File

@ -48,7 +48,8 @@
<fraction name="config_key_letter_ratio_5row">62%</fraction>
<fraction name="config_key_shifted_letter_hint_ratio_5row">36%</fraction>
<dimen name="config_suggestions_strip_horizontal_padding">252.0dp</dimen>
<dimen name="config_suggestions_strip_height">44dp</dimen>
<dimen name="config_suggestions_strip_horizontal_margin">180.0dp</dimen>
<integer name="config_max_more_suggestions_row">5</integer>
<fraction name="config_min_more_suggestions_width">50%</fraction>

View File

@ -63,12 +63,12 @@
<fraction name="config_key_shifted_letter_hint_ratio_5row">27%</fraction>
<dimen name="config_suggestions_strip_height">44dp</dimen>
<dimen name="config_suggestions_strip_horizontal_margin">0dp</dimen>
<dimen name="config_more_suggestions_row_height">44dp</dimen>
<integer name="config_max_more_suggestions_row">6</integer>
<fraction name="config_min_more_suggestions_width">90%</fraction>
<dimen name="config_suggestions_strip_horizontal_padding">94.5dp</dimen>
<dimen name="config_suggestion_min_width">48.0dp</dimen>
<dimen name="config_suggestion_text_horizontal_padding">12dp</dimen>
<dimen name="config_suggestion_text_horizontal_padding">10dp</dimen>
<dimen name="config_suggestion_text_size">22dp</dimen>
<dimen name="config_more_suggestions_hint_text_size">33dp</dimen>

View File

@ -49,7 +49,8 @@
<fraction name="config_key_letter_ratio_5row">53%</fraction>
<fraction name="config_key_shifted_letter_hint_ratio_5row">30%</fraction>
<dimen name="config_suggestions_strip_horizontal_padding">252.0dp</dimen>
<dimen name="config_suggestions_strip_height">44dp</dimen>
<dimen name="config_suggestions_strip_horizontal_margin">340dp</dimen>
<fraction name="config_min_more_suggestions_width">50%</fraction>
<!-- Gesture floating preview text parameters -->

View File

@ -61,12 +61,12 @@
<fraction name="config_key_shifted_letter_hint_ratio_5row">33%</fraction>
<dimen name="config_suggestions_strip_height">44dp</dimen>
<dimen name="config_suggestions_strip_horizontal_margin">100dp</dimen>
<dimen name="config_more_suggestions_row_height">44dp</dimen>
<integer name="config_max_more_suggestions_row">6</integer>
<fraction name="config_min_more_suggestions_width">90%</fraction>
<dimen name="config_suggestions_strip_horizontal_padding">94.5dp</dimen>
<dimen name="config_suggestion_min_width">46dp</dimen>
<dimen name="config_suggestion_text_horizontal_padding">8dp</dimen>
<dimen name="config_suggestion_text_horizontal_padding">10dp</dimen>
<dimen name="config_suggestion_text_size">22dp</dimen>
<dimen name="config_more_suggestions_hint_text_size">33dp</dimen>

View File

@ -64,10 +64,10 @@
<fraction name="config_key_shifted_letter_hint_ratio_5row">41%</fraction>
<dimen name="config_suggestions_strip_height">40dp</dimen>
<dimen name="config_suggestions_strip_horizontal_margin">0dp</dimen>
<dimen name="config_more_suggestions_row_height">40dp</dimen>
<integer name="config_max_more_suggestions_row">6</integer>
<fraction name="config_min_more_suggestions_width">90%</fraction>
<dimen name="config_suggestions_strip_horizontal_padding">0dp</dimen>
<dimen name="config_suggestion_min_width">44dp</dimen>
<dimen name="config_suggestion_text_horizontal_padding">6dp</dimen>
<dimen name="config_suggestion_text_size">18dp</dimen>

View File

@ -309,9 +309,8 @@ final class SuggestionStripLayoutHelper {
setupWordViewsTextAndColor(suggestedWords, mSuggestionsCountInStrip);
final TextView centerWordView = mWordViews.get(mCenterPositionInStrip);
final int availableStripWidth = placerView.getWidth()
- placerView.getPaddingRight() - placerView.getPaddingLeft();
final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, availableStripWidth);
final int stripWidth = stripView.getWidth();
final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth);
final int countInStrip;
if (suggestedWords.size() == 1 || getTextScaleX(centerWordView.getText(), centerWidth,
centerWordView.getPaint()) < MIN_TEXT_XSCALE) {
@ -319,11 +318,11 @@ final class SuggestionStripLayoutHelper {
// by consolidating all slots in the strip.
countInStrip = 1;
mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip);
layoutWord(mCenterPositionInStrip, availableStripWidth - mPadding);
layoutWord(mCenterPositionInStrip, stripWidth - mPadding);
stripView.addView(centerWordView);
setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT);
if (SuggestionStripView.DBG) {
layoutDebugInfo(mCenterPositionInStrip, placerView, availableStripWidth);
layoutDebugInfo(mCenterPositionInStrip, placerView, stripWidth);
}
} else {
countInStrip = mSuggestionsCountInStrip;
@ -337,7 +336,7 @@ final class SuggestionStripLayoutHelper {
x += divider.getMeasuredWidth();
}
final int width = getSuggestionWidth(positionInStrip, availableStripWidth);
final int width = getSuggestionWidth(positionInStrip, stripWidth);
final TextView wordView = layoutWord(positionInStrip, width);
stripView.addView(wordView);
setLayoutWeight(wordView, getSuggestionWeight(positionInStrip),
@ -474,8 +473,8 @@ final class SuggestionStripLayoutHelper {
return countInStrip;
}
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip,
final int stripWidth) {
public void layoutAddToDictionaryHint(final String word, final ViewGroup addToDictionaryStrip) {
final int stripWidth = addToDictionaryStrip.getWidth();
final int width = stripWidth - mDividerWidth - mPadding * 2;
final TextView wordView = (TextView)addToDictionaryStrip.findViewById(R.id.word_to_save);

View File

@ -209,7 +209,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
}
public void showAddToDictionaryHint(final String word) {
mLayoutHelper.layoutAddToDictionaryHint(word, mAddToDictionaryStrip, getWidth());
mLayoutHelper.layoutAddToDictionaryHint(word, mAddToDictionaryStrip);
// {@link TextView#setTag()} is used to hold the word to be added to dictionary. The word
// will be extracted at {@link #onClick(View)}.
mAddToDictionaryStrip.setTag(word);