am 571320ad: am 5dee1fd6: Merge "Add dedicated background for custom action label key" into lmp-dev
* commit '571320ad90b2ac2bb9fa77cf6700feec3bc4030a': Add dedicated background for custom action label keymain
commit
c8b860e3e1
|
@ -15,6 +15,11 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- Custom label action keys. -->
|
||||||
|
<item android:state_active="true" android:state_checked="true" android:state_pressed="true"
|
||||||
|
android:drawable="@color/key_background_pressed_lxx_dark" />
|
||||||
|
<item android:state_active="true" android:state_checked="true"
|
||||||
|
android:drawable="@color/key_background_lxx_dark" />
|
||||||
<!-- Action keys. -->
|
<!-- Action keys. -->
|
||||||
<item android:state_active="true" android:state_pressed="true"
|
<item android:state_active="true" android:state_pressed="true"
|
||||||
android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_dark" />
|
android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_dark" />
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- Custom label action keys. -->
|
||||||
|
<item android:state_active="true" android:state_checked="true" android:state_pressed="true"
|
||||||
|
android:drawable="@color/key_background_pressed_lxx_light" />
|
||||||
|
<item android:state_active="true" android:state_checked="true"
|
||||||
|
android:drawable="@color/key_background_lxx_light" />
|
||||||
<!-- Action keys. -->
|
<!-- Action keys. -->
|
||||||
<item android:state_active="true" android:state_pressed="true"
|
<item android:state_active="true" android:state_pressed="true"
|
||||||
android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_light" />
|
android:drawable="@drawable/btn_keyboard_key_active_pressed_lxx_light" />
|
||||||
|
|
|
@ -270,9 +270,10 @@
|
||||||
<enum name="empty" value="0" />
|
<enum name="empty" value="0" />
|
||||||
<enum name="normal" value="1" />
|
<enum name="normal" value="1" />
|
||||||
<enum name="functional" value="2" />
|
<enum name="functional" value="2" />
|
||||||
<enum name="action" value="3" />
|
<enum name="stickyOff" value="3" />
|
||||||
<enum name="stickyOff" value="4" />
|
<enum name="stickyOn" value="4" />
|
||||||
<enum name="stickyOn" value="5" />
|
<enum name="action" value="5" />
|
||||||
|
<enum name="customAction" value="6" />
|
||||||
</attr>
|
</attr>
|
||||||
<!-- The key action flags. -->
|
<!-- The key action flags. -->
|
||||||
<attr name="keyActionFlags" format="integer">
|
<attr name="keyActionFlags" format="integer">
|
||||||
|
|
|
@ -230,6 +230,7 @@
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keySpec="dummy_label|!code/key_enter"
|
latin:keySpec="dummy_label|!code/key_enter"
|
||||||
latin:keyLabelFlags="fromCustomActionLabel"
|
latin:keyLabelFlags="fromCustomActionLabel"
|
||||||
|
latin:backgroundType="customAction"
|
||||||
latin:parentStyle="defaultEnterKeyStyle" />
|
latin:parentStyle="defaultEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<!-- imeAction is either actionNone or actionUnspecified. -->
|
<!-- imeAction is either actionNone or actionUnspecified. -->
|
||||||
|
|
|
@ -398,6 +398,7 @@
|
||||||
latin:styleName="enterKeyStyle"
|
latin:styleName="enterKeyStyle"
|
||||||
latin:keySpec="dummy_label|!code/key_enter"
|
latin:keySpec="dummy_label|!code/key_enter"
|
||||||
latin:keyLabelFlags="fromCustomActionLabel"
|
latin:keyLabelFlags="fromCustomActionLabel"
|
||||||
|
latin:backgroundType="customAction"
|
||||||
latin:parentStyle="defaultEnterKeyStyle" />
|
latin:parentStyle="defaultEnterKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<!-- imeAction is either actionNone or actionUnspecified. -->
|
<!-- imeAction is either actionNone or actionUnspecified. -->
|
||||||
|
|
|
@ -123,9 +123,10 @@ public class Key implements Comparable<Key> {
|
||||||
public static final int BACKGROUND_TYPE_EMPTY = 0;
|
public static final int BACKGROUND_TYPE_EMPTY = 0;
|
||||||
public static final int BACKGROUND_TYPE_NORMAL = 1;
|
public static final int BACKGROUND_TYPE_NORMAL = 1;
|
||||||
public static final int BACKGROUND_TYPE_FUNCTIONAL = 2;
|
public static final int BACKGROUND_TYPE_FUNCTIONAL = 2;
|
||||||
public static final int BACKGROUND_TYPE_ACTION = 3;
|
public static final int BACKGROUND_TYPE_STICKY_OFF = 3;
|
||||||
public static final int BACKGROUND_TYPE_STICKY_OFF = 4;
|
public static final int BACKGROUND_TYPE_STICKY_ON = 4;
|
||||||
public static final int BACKGROUND_TYPE_STICKY_ON = 5;
|
public static final int BACKGROUND_TYPE_ACTION = 5;
|
||||||
|
public static final int BACKGROUND_TYPE_CUSTOM_ACTION = 6;
|
||||||
|
|
||||||
private final int mActionFlags;
|
private final int mActionFlags;
|
||||||
private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01;
|
private static final int ACTION_FLAGS_IS_REPEATABLE = 0x01;
|
||||||
|
@ -483,9 +484,10 @@ public class Key implements Comparable<Key> {
|
||||||
case BACKGROUND_TYPE_EMPTY: return "empty";
|
case BACKGROUND_TYPE_EMPTY: return "empty";
|
||||||
case BACKGROUND_TYPE_NORMAL: return "normal";
|
case BACKGROUND_TYPE_NORMAL: return "normal";
|
||||||
case BACKGROUND_TYPE_FUNCTIONAL: return "functional";
|
case BACKGROUND_TYPE_FUNCTIONAL: return "functional";
|
||||||
case BACKGROUND_TYPE_ACTION: return "action";
|
|
||||||
case BACKGROUND_TYPE_STICKY_OFF: return "stickyOff";
|
case BACKGROUND_TYPE_STICKY_OFF: return "stickyOff";
|
||||||
case BACKGROUND_TYPE_STICKY_ON: return "stickyOn";
|
case BACKGROUND_TYPE_STICKY_ON: return "stickyOn";
|
||||||
|
case BACKGROUND_TYPE_ACTION: return "action";
|
||||||
|
case BACKGROUND_TYPE_CUSTOM_ACTION: return "customAction";
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -814,47 +816,37 @@ public class Key implements Comparable<Key> {
|
||||||
return dx * dx + dy * dy;
|
return dx * dx + dy * dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static int[] KEY_STATE_NORMAL_HIGHLIGHT_ON = {
|
static class KeyBackgroundState {
|
||||||
android.R.attr.state_checkable,
|
private final int[] mReleasedState;
|
||||||
android.R.attr.state_checked
|
private final int[] mPressedState;
|
||||||
};
|
|
||||||
|
|
||||||
private final static int[] KEY_STATE_PRESSED_HIGHLIGHT_ON = {
|
private KeyBackgroundState(final int ... attrs) {
|
||||||
android.R.attr.state_pressed,
|
mReleasedState = attrs;
|
||||||
android.R.attr.state_checkable,
|
mPressedState = Arrays.copyOf(attrs, attrs.length + 1);
|
||||||
android.R.attr.state_checked
|
mPressedState[attrs.length] = android.R.attr.state_pressed;
|
||||||
};
|
}
|
||||||
|
|
||||||
private final static int[] KEY_STATE_NORMAL_HIGHLIGHT_OFF = {
|
public int[] getState(final boolean pressed) {
|
||||||
android.R.attr.state_checkable
|
return pressed ? mPressedState : mReleasedState;
|
||||||
};
|
}
|
||||||
|
|
||||||
private final static int[] KEY_STATE_PRESSED_HIGHLIGHT_OFF = {
|
public static final KeyBackgroundState[] STATES = {
|
||||||
android.R.attr.state_pressed,
|
// 0: BACKGROUND_TYPE_EMPTY
|
||||||
android.R.attr.state_checkable
|
new KeyBackgroundState(android.R.attr.state_empty),
|
||||||
};
|
// 1: BACKGROUND_TYPE_NORMAL
|
||||||
|
new KeyBackgroundState(),
|
||||||
private final static int[] KEY_STATE_NORMAL = {
|
// 2: BACKGROUND_TYPE_FUNCTIONAL
|
||||||
};
|
new KeyBackgroundState(),
|
||||||
|
// 3: BACKGROUND_TYPE_STICKY_OFF
|
||||||
private final static int[] KEY_STATE_PRESSED = {
|
new KeyBackgroundState(android.R.attr.state_checkable),
|
||||||
android.R.attr.state_pressed
|
// 4: BACKGROUND_TYPE_STICKY_ON
|
||||||
};
|
new KeyBackgroundState(android.R.attr.state_checkable, android.R.attr.state_checked),
|
||||||
|
// 5: BACKGROUND_TYPE_ACTION
|
||||||
private final static int[] KEY_STATE_EMPTY = {
|
new KeyBackgroundState(android.R.attr.state_active),
|
||||||
android.R.attr.state_empty
|
// 6: BACKGROUND_TYPE_CUSTOM_ACTION
|
||||||
};
|
new KeyBackgroundState(android.R.attr.state_active, android.R.attr.state_checked)
|
||||||
|
|
||||||
// action normal state (with properties)
|
|
||||||
private static final int[] KEY_STATE_ACTIVE_NORMAL = {
|
|
||||||
android.R.attr.state_active
|
|
||||||
};
|
|
||||||
|
|
||||||
// action pressed state (with properties)
|
|
||||||
private static final int[] KEY_STATE_ACTIVE_PRESSED = {
|
|
||||||
android.R.attr.state_active,
|
|
||||||
android.R.attr.state_pressed
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the background drawable for the key, based on the current state and type of the key.
|
* Returns the background drawable for the key, based on the current state and type of the key.
|
||||||
|
@ -871,28 +863,8 @@ public class Key implements Comparable<Key> {
|
||||||
} else {
|
} else {
|
||||||
background = keyBackground;
|
background = keyBackground;
|
||||||
}
|
}
|
||||||
final int[] stateSet;
|
final int[] state = KeyBackgroundState.STATES[mBackgroundType].getState(mPressed);
|
||||||
switch (mBackgroundType) {
|
background.setState(state);
|
||||||
case BACKGROUND_TYPE_ACTION:
|
|
||||||
stateSet = mPressed ? KEY_STATE_ACTIVE_PRESSED : KEY_STATE_ACTIVE_NORMAL;
|
|
||||||
break;
|
|
||||||
case BACKGROUND_TYPE_STICKY_OFF:
|
|
||||||
stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_OFF : KEY_STATE_NORMAL_HIGHLIGHT_OFF;
|
|
||||||
break;
|
|
||||||
case BACKGROUND_TYPE_STICKY_ON:
|
|
||||||
stateSet = mPressed ? KEY_STATE_PRESSED_HIGHLIGHT_ON : KEY_STATE_NORMAL_HIGHLIGHT_ON;
|
|
||||||
break;
|
|
||||||
case BACKGROUND_TYPE_EMPTY:
|
|
||||||
stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_EMPTY;
|
|
||||||
break;
|
|
||||||
case BACKGROUND_TYPE_FUNCTIONAL:
|
|
||||||
stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
|
|
||||||
break;
|
|
||||||
default: /* BACKGROUND_TYPE_NORMAL */
|
|
||||||
stateSet = mPressed ? KEY_STATE_PRESSED : KEY_STATE_NORMAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
background.setState(stateSet);
|
|
||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue