Merge "Tweak ICS theme a bit"

main
Tadashi G. Takaoka 2011-07-01 05:12:43 -07:00 committed by Android (Google) Code Review
commit f008ae9ece
20 changed files with 58 additions and 64 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 341 B

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

View File

@ -18,13 +18,10 @@
*/
-->
<TextView
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/label_candidate_divider"
android:textSize="@dimen/candidate_text_size"
android:gravity="center"
android:src="@drawable/keyboard_suggest_strip_divider"
android:padding="0dp"
android:focusable="false"
android:clickable="false" />
android:gravity="center" />

View File

@ -24,5 +24,4 @@
android:layout_height="wrap_content"
android:textSize="6sp"
android:textColor="@android:color/white"
android:visibility="gone"
style="?attr/suggestionBackgroundStyle" />

View File

@ -27,9 +27,7 @@
android:orientation="horizontal"
android:layout_weight="1.0"
android:layout_width="0dp"
android:layout_height="match_parent"
>
</LinearLayout>
android:layout_height="match_parent" />
<LinearLayout
android:id="@+id/candidates_pane_control"
android:orientation="horizontal"
@ -42,22 +40,22 @@
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="30dp"
android:textSize="@dimen/candidate_text_size"
android:padding="0dp"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:visibility="visible"
style="?attr/suggestionBackgroundStyle" />
android:background="@drawable/btn_keyboard_key_ics" />
<TextView
android:id="@+id/close_candidates_pane"
android:text="@string/label_close_candidates_pane"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="30dp"
android:textSize="@dimen/candidate_text_size"
android:padding="0dp"
android:paddingRight="8dp"
android:paddingLeft="8dp"
android:visibility="gone"
style="?attr/suggestionBackgroundStyle" />
android:background="@drawable/btn_keyboard_key_ics" />
</LinearLayout>
<LinearLayout
android:id="@+id/touch_to_save"

View File

@ -57,7 +57,7 @@
<dimen name="key_preview_offset_ics">0.01in</dimen>
<dimen name="candidate_strip_height">38dip</dimen>
<dimen name="candidate_strip_height">36dip</dimen>
<dimen name="candidate_strip_fading_edge_length">63dip</dimen>
<!-- Amount of allowance for selecting keys in a mini popup keyboard by sliding finger. -->
<!-- popup_key_height x 1.2 -->

View File

@ -68,7 +68,7 @@
<dimen name="key_preview_height_ics">15.0mm</dimen>
<dimen name="key_preview_offset_ics">0.05in</dimen>
<dimen name="candidate_strip_height">46dip</dimen>
<dimen name="candidate_strip_height">44dip</dimen>
<dimen name="candidate_strip_padding">15.0mm</dimen>
<dimen name="candidate_min_width">0.3in</dimen>
<dimen name="candidate_padding">12dip</dimen>

View File

@ -69,7 +69,7 @@
<dimen name="key_preview_height_ics">15.0mm</dimen>
<dimen name="key_preview_offset_ics">0.05in</dimen>
<dimen name="candidate_strip_height">46dip</dimen>
<dimen name="candidate_strip_height">44dip</dimen>
<!-- candidate_strip_minimum_height =
key_preview_height_holo - key_preview_offset_holo + alpha -->
<dimen name="candidate_strip_minimum_height">18mm</dimen>

View File

@ -120,7 +120,6 @@
<attr name="colorTypedWord" format="color" />
<attr name="colorAutoCorrect" format="color" />
<attr name="colorSuggested" format="color" />
<attr name="colorDivider" format="color" />
<attr name="candidateCountInStrip" format="integer" />
</declare-styleable>

View File

@ -73,7 +73,7 @@
<dimen name="key_preview_height_ics">80sp</dimen>
<dimen name="key_preview_offset_ics">0.05in</dimen>
<dimen name="candidate_strip_height">42dip</dimen>
<dimen name="candidate_strip_height">40dip</dimen>
<!-- candidate_strip_minimum_height =
key_preview_height_holo - key_preview_offset_holo + alpha -->
<dimen name="candidate_strip_minimum_height">100sp</dimen>

View File

@ -50,7 +50,7 @@
<item name="iconPreviewSettingsKey">@drawable/sym_keyboard_settings_holo</item>
<item name="iconPreviewShortcutKey">@drawable/sym_keyboard_feedback_mic</item>
<!-- LatinKeyboard icons -->
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led</item>
<item name="autoCorrectionSpacebarLedIcon">@drawable/sym_keyboard_space_led_holo</item>
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
</style>
</resources>

View File

@ -92,7 +92,6 @@
<item name="colorTypedWord">#FFFFFFFF</item>
<item name="colorAutoCorrect">#FFFCAE00</item>
<item name="colorSuggested">#FFFCAE00</item>
<item name="colorDivider">#20FFFFFF</item>
<item name="candidateCountInStrip">@integer/candidate_count_in_strip</item>
</style>
<!-- Theme "Basic high contrast" -->
@ -191,9 +190,8 @@
<style name="CandidateViewStyle.IceCreamSandwich" parent="SuggestionsStripBackgroundStyle.IceCreamSandwich">
<item name="autoCorrectHighlight">autoCorrectBold|autoCorrectInvert</item>
<item name="colorTypedWord">#FFFFFFFF</item>
<item name="colorAutoCorrect">#FFFFFFFF</item>
<item name="colorAutoCorrect">#FF3DC8FF</item>
<item name="colorSuggested">#FFFFFFFF</item>
<item name="colorDivider">#20FFFFFF</item>
<item name="candidateCountInStrip">@integer/candidate_count_in_strip</item>
</style>
<style name="PopupMiniKeyboardAnimation">

View File

@ -394,6 +394,8 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
public int mKeyLetterSize;
public final int[] mCoordinates = new int[2];
private static final int PREVIEW_ALPHA = 240;
public KeyPreviewDrawParams(TypedArray a, KeyDrawParams keyDrawParams) {
mPreviewBackground = a.getDrawable(R.styleable.KeyboardView_keyPreviewBackground);
mPreviewLeftBackground = a.getDrawable(
@ -402,6 +404,9 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
R.styleable.KeyboardView_keyPreviewRightBackground);
mPreviewSpacebarBackground = a.getDrawable(
R.styleable.KeyboardView_keyPreviewSpacebarBackground);
setAlpha(mPreviewBackground, PREVIEW_ALPHA);
setAlpha(mPreviewLeftBackground, PREVIEW_ALPHA);
setAlpha(mPreviewRightBackground, PREVIEW_ALPHA);
mPreviewOffset = a.getDimensionPixelOffset(
R.styleable.KeyboardView_keyPreviewOffset, 0);
mPreviewHeight = a.getDimensionPixelSize(
@ -417,6 +422,12 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
mPreviewTextSize = (int)(keyHeight * mPreviewTextRatio);
mKeyLetterSize = (int)(keyHeight * mKeyLetterRatio);
}
private static void setAlpha(Drawable drawable, int alpha) {
if (drawable == null)
return;
drawable.setAlpha(alpha);
}
}
public KeyboardView(Context context, AttributeSet attrs) {

View File

@ -61,8 +61,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private static final CharacterStyle UNDERLINE_SPAN = new UnderlineSpan();
// The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
private static final int MAX_SUGGESTIONS = 18;
private static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT;
private static final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT;
private static final int MATCH_PARENT = ViewGroup.LayoutParams.MATCH_PARENT;
private static final boolean DBG = LatinImeLogger.sDBG;
@ -90,7 +90,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
private final int mColorTypedWord;
private final int mColorAutoCorrect;
private final int mColorSuggestedCandidate;
private final int mColorDivider;
private final PopupWindow mPreviewPopup;
private final TextView mPreviewText;
@ -184,6 +183,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
final float textSize = res.getDimension(R.dimen.candidate_text_size);
mPaint.setTextSize(textSize);
mPadding = res.getDimensionPixelSize(R.dimen.candidate_padding);
divider.measure(WRAP_CONTENT, MATCH_PARENT);
mDividerWidth = divider.getMeasuredWidth();
mDividerHeight = divider.getMeasuredHeight();
mControlWidth = control.getMeasuredWidth();
@ -295,7 +295,6 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mColorTypedWord = a.getColor(R.styleable.CandidateView_colorTypedWord, 0);
mColorAutoCorrect = a.getColor(R.styleable.CandidateView_colorAutoCorrect, 0);
mColorSuggestedCandidate = a.getColor(R.styleable.CandidateView_colorSuggested, 0);
mColorDivider = a.getColor(R.styleable.CandidateView_colorDivider, 0);
mCandidateCountInStrip = a.getInt(
R.styleable.CandidateView_candidateCountInStrip, DEFAULT_CANDIDATE_COUNT_IN_STRIP);
a.recycle();
@ -321,7 +320,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
word.setOnLongClickListener(this);
mWords.add(word);
mInfos.add((TextView)inflater.inflate(R.layout.candidate_info, null));
mDividers.add(getDivider(inflater));
mDividers.add(inflater.inflate(R.layout.candidate_divider, null));
}
mTouchToSave = findViewById(R.id.touch_to_save);
@ -333,6 +332,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
mCandidatesPaneControl = (ViewGroup)findViewById(R.id.candidates_pane_control);
mExpandCandidatesPane = (TextView)findViewById(R.id.expand_candidates_pane);
mExpandCandidatesPane.getBackground().setAlpha(180);
mExpandCandidatesPane.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@ -340,6 +340,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
});
mCloseCandidatesPane = (TextView)findViewById(R.id.close_candidates_pane);
mCloseCandidatesPane.getBackground().setAlpha(180);
mCloseCandidatesPane.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
@ -348,15 +349,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
});
mCandidatesPaneControl.measure(WRAP_CONTENT, WRAP_CONTENT);
mParams = new CandidateViewLayoutParams(res, mDividers.get(0), mCandidatesPaneControl,
mAutoCorrectHighlight);
}
private View getDivider(LayoutInflater inflater) {
final TextView divider = (TextView)inflater.inflate(R.layout.candidate_divider, null);
divider.setTextColor(mColorDivider);
divider.measure(WRAP_CONTENT, WRAP_CONTENT);
return divider;
mParams = new CandidateViewLayoutParams(
res, mDividers.get(0), mCandidatesPaneControl, mAutoCorrectHighlight);
}
/**
@ -429,7 +423,7 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
? PUNCTUATIONS_IN_STRIP : mCandidateCountInStrip);
final int count = Math.min(mWords.size(), suggestions.size());
if (count <= params.mCountInStrip) {
if (count <= params.mCountInStrip && !DBG) {
mCandidatesPaneControl.setVisibility(GONE);
} else {
mCandidatesPaneControl.setVisibility(VISIBLE);
@ -437,8 +431,8 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
final int countInStrip = params.mCountInStrip;
int fromIndex = countInStrip;
int x = 0, y = 0;
View centeringFrom = null, lastView = null;
int x = 0, y = 0, infoX = 0;
for (int i = 0; i < count; i++) {
final int pos;
if (i <= 1) {
@ -497,18 +491,18 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
}
mCandidatesStrip.addView(word);
if (params.mCanUseFixedWidthColumns) {
setLayoutWeight(word, 1.0f);
setLayoutWeight(word, 1.0f, mCandidateStripHeight);
} else {
final int width = getTextWidth(text, paint) + params.mPadding * 2;
setLayoutWeight(word, width);
setLayoutWeight(word, width, mCandidateStripHeight);
}
if (info != null) {
word.measure(WRAP_CONTENT, MATCH_PARENT);
final int width = word.getMeasuredWidth();
mCandidatesPane.addView(info);
info.measure(WRAP_CONTENT, WRAP_CONTENT);
final int infoWidth = info.getMeasuredWidth();
FrameLayoutCompatUtils.placeViewAt(
info, width - infoWidth, 0, infoWidth, info.getMeasuredHeight());
final int width = info.getMeasuredWidth();
y = info.getMeasuredHeight();
FrameLayoutCompatUtils.placeViewAt(info, infoX, 0, width, y);
infoX += width * 2;
}
} else {
paint.setTextScaleX(1.0f);
@ -516,10 +510,9 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
int available = paneWidth - x - params.mPadding * 2;
if (textWidth >= available) {
// Needs new row, centering previous row.
centeringCandidates(fromIndex, i - 1, x, paneWidth);
centeringCandidates(centeringFrom, lastView, x, paneWidth);
x = 0;
y += mCandidateStripHeight;
fromIndex = i;
}
if (x != 0) {
// Add divider if this isn't the left most suggestion in current row.
@ -536,46 +529,45 @@ public class CandidateView extends LinearLayout implements OnClickListener, OnLo
word.setText(text);
word.setTextScaleX(scaleX);
mCandidatesPane.addView(word);
word.measure(WRAP_CONTENT, WRAP_CONTENT);
lastView = word;
if (x == 0) centeringFrom = word;
word.measure(WRAP_CONTENT,
MeasureSpec.makeMeasureSpec(mCandidateStripHeight, MeasureSpec.EXACTLY));
final int width = word.getMeasuredWidth();
final int height = word.getMeasuredHeight();
FrameLayoutCompatUtils.placeViewAt(
word, x, y + (mCandidateStripHeight - height) / 2, width, height);
x += width;
if (info != null) {
mCandidatesPane.addView(info);
lastView = info;
info.measure(WRAP_CONTENT, WRAP_CONTENT);
final int infoWidth = info.getMeasuredWidth();
FrameLayoutCompatUtils.placeViewAt(
info, x + width - infoWidth, y, infoWidth, info.getMeasuredHeight());
info, x - infoWidth, y, infoWidth, info.getMeasuredHeight());
}
x += width;
}
}
if (x != 0) {
// Centering last candidates row.
centeringCandidates(fromIndex, count - 1, x, paneWidth);
centeringCandidates(centeringFrom, lastView, x, paneWidth);
}
}
private static void setLayoutWeight(View v, float weight) {
private static void setLayoutWeight(View v, float weight, int height) {
final ViewGroup.LayoutParams lp = v.getLayoutParams();
if (lp instanceof LinearLayout.LayoutParams) {
final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
llp.weight = weight;
llp.width = 0;
llp.height = MATCH_PARENT;
llp.height = height;
}
}
private void centeringCandidates(int from, int to, int width, int paneWidth) {
private void centeringCandidates(View from, View to, int width, int paneWidth) {
final ViewGroup pane = mCandidatesPane;
final int fromIndex = pane.indexOfChild(mWords.get(from));
final int toIndex;
if (mInfos.get(to).getParent() != null) {
toIndex = pane.indexOfChild(mInfos.get(to));
} else {
toIndex = pane.indexOfChild(mWords.get(to));
}
final int fromIndex = pane.indexOfChild(from);
final int toIndex = pane.indexOfChild(to);
final int offset = (paneWidth - width) / 2;
for (int index = fromIndex; index <= toIndex; index++) {
offsetMargin(pane.getChildAt(index), offset, 0);