am 26a97909: am 3977cc97: am c7f8d54d: Merge "Prepare for changing text color for functional keys"
* commit '26a97909f6d1cfad2cc417a2bef91d977b076158': Prepare for changing text color for functional keysmain
commit
efa3ef17e9
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2013 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.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<!-- Functional keys. -->
|
||||
<item android:state_single="true" android:state_pressed="true"
|
||||
android:color="@color/key_text_color_functional_ics" />
|
||||
<item android:state_single="true"
|
||||
android:color="@color/key_text_color_functional_ics" />
|
||||
|
||||
<!-- Action keys. -->
|
||||
<item android:state_active="true" android:state_pressed="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
<item android:state_active="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
|
||||
<!-- Toggle keys. Use checkable/checked state. -->
|
||||
<item android:state_checkable="true" android:state_checked="true" android:state_pressed="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
<item android:state_checkable="true" android:state_pressed="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
<item android:state_checkable="true" android:state_checked="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
<item android:state_checkable="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
|
||||
<!-- Empty background keys. -->
|
||||
<item android:state_empty="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
|
||||
<!-- Normal keys. -->
|
||||
<item android:state_pressed="true"
|
||||
android:color="@color/key_text_color_normal_ics" />
|
||||
<item android:color="@color/key_text_color_normal_ics" />
|
||||
</selector>
|
|
@ -39,7 +39,6 @@
|
|||
<color name="typed_word_color_ics">#D833B5E5</color>
|
||||
<color name="suggested_word_color_ics">#B233B5E5</color>
|
||||
<color name="highlight_translucent_color_ics">#9933B5E5</color>
|
||||
<color name="key_text_color_ics">@android:color/white</color>
|
||||
<color name="key_text_shadow_color_ics">@android:color/transparent</color>
|
||||
<color name="key_text_inactivated_color_ics">#66E0E4E5</color>
|
||||
<color name="key_hint_letter_color_ics">#80000000</color>
|
||||
|
@ -66,4 +65,7 @@
|
|||
<!-- TODO: Color which should be included in the theme -->
|
||||
<color name="emoji_key_background_color">#00000000</color>
|
||||
<color name="emoji_key_pressed_background_color">#30FFFFFF</color>
|
||||
|
||||
<color name="key_text_color_normal_ics">@android:color/white</color>
|
||||
<color name="key_text_color_functional_ics">@android:color/white</color>
|
||||
</resources>
|
||||
|
|
|
@ -139,6 +139,8 @@ public class Key implements Comparable<Key> {
|
|||
|
||||
private final OptionalAttributes mOptionalAttributes;
|
||||
|
||||
private static final int DEFAULT_TEXT_COLOR = 0xFFFFFFFF;
|
||||
|
||||
private static final class OptionalAttributes {
|
||||
/** Text to output when pressed. This can be multiple characters, like ".com" */
|
||||
public final String mOutputText;
|
||||
|
@ -602,7 +604,22 @@ public class Key implements Comparable<Key> {
|
|||
}
|
||||
|
||||
public final int selectTextColor(final KeyDrawParams params) {
|
||||
return isShiftedLetterActivated() ? params.mTextInactivatedColor : params.mTextColor;
|
||||
if (isShiftedLetterActivated()) {
|
||||
return params.mTextInactivatedColor;
|
||||
}
|
||||
if (params.mTextColorStateList == null) {
|
||||
return DEFAULT_TEXT_COLOR;
|
||||
}
|
||||
final int[] state;
|
||||
// TODO: Hack!!!!!!!! Consider having a new attribute for the functional text labels.
|
||||
// Currently, we distinguish "input key" from "functional key" by checking the
|
||||
// length of the label( > 1) and "functional" attributes (= true).
|
||||
if (mLabel != null && mLabel.length() > 1) {
|
||||
state = getCurrentDrawableState();
|
||||
} else {
|
||||
state = KEY_STATE_NORMAL;
|
||||
}
|
||||
return params.mTextColorStateList.getColorForState(state, DEFAULT_TEXT_COLOR);
|
||||
}
|
||||
|
||||
public final int selectHintTextSize(final KeyDrawParams params) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.android.inputmethod.keyboard.internal;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
import com.android.inputmethod.latin.utils.ResourceUtils;
|
||||
|
@ -32,7 +33,7 @@ public final class KeyDrawParams {
|
|||
public int mHintLabelSize;
|
||||
public int mPreviewTextSize;
|
||||
|
||||
public int mTextColor;
|
||||
public ColorStateList mTextColorStateList;
|
||||
public int mTextInactivatedColor;
|
||||
public int mTextShadowColor;
|
||||
public int mHintLetterColor;
|
||||
|
@ -57,7 +58,7 @@ public final class KeyDrawParams {
|
|||
mHintLabelSize = copyFrom.mHintLabelSize;
|
||||
mPreviewTextSize = copyFrom.mPreviewTextSize;
|
||||
|
||||
mTextColor = copyFrom.mTextColor;
|
||||
mTextColorStateList = copyFrom.mTextColorStateList;
|
||||
mTextInactivatedColor = copyFrom.mTextInactivatedColor;
|
||||
mTextShadowColor = copyFrom.mTextShadowColor;
|
||||
mHintLetterColor = copyFrom.mHintLetterColor;
|
||||
|
@ -89,8 +90,8 @@ public final class KeyDrawParams {
|
|||
attr.mShiftedLetterHintRatio, mShiftedLetterHintSize);
|
||||
mHintLabelSize = selectTextSize(keyHeight, attr.mHintLabelRatio, mHintLabelSize);
|
||||
mPreviewTextSize = selectTextSize(keyHeight, attr.mPreviewTextRatio, mPreviewTextSize);
|
||||
|
||||
mTextColor = selectColor(attr.mTextColor, mTextColor);
|
||||
mTextColorStateList =
|
||||
attr.mTextColorStateList != null ? attr.mTextColorStateList : mTextColorStateList;
|
||||
mTextInactivatedColor = selectColor(attr.mTextInactivatedColor, mTextInactivatedColor);
|
||||
mTextShadowColor = selectColor(attr.mTextShadowColor, mTextShadowColor);
|
||||
mHintLetterColor = selectColor(attr.mHintLetterColor, mHintLetterColor);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package com.android.inputmethod.keyboard.internal;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.SparseIntArray;
|
||||
|
@ -37,7 +38,7 @@ public final class KeyVisualAttributes {
|
|||
public final float mHintLabelRatio;
|
||||
public final float mPreviewTextRatio;
|
||||
|
||||
public final int mTextColor;
|
||||
public final ColorStateList mTextColorStateList;
|
||||
public final int mTextInactivatedColor;
|
||||
public final int mTextShadowColor;
|
||||
public final int mHintLetterColor;
|
||||
|
@ -115,7 +116,7 @@ public final class KeyVisualAttributes {
|
|||
mPreviewTextRatio = ResourceUtils.getFraction(keyAttr,
|
||||
R.styleable.Keyboard_Key_keyPreviewTextRatio);
|
||||
|
||||
mTextColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextColor, 0);
|
||||
mTextColorStateList = keyAttr.getColorStateList(R.styleable.Keyboard_Key_keyTextColor);
|
||||
mTextInactivatedColor = keyAttr.getColor(
|
||||
R.styleable.Keyboard_Key_keyTextInactivatedColor, 0);
|
||||
mTextShadowColor = keyAttr.getColor(R.styleable.Keyboard_Key_keyTextShadowColor, 0);
|
||||
|
|
Loading…
Reference in New Issue