Support embedded more key
This is a followup change to Ie10b3e0b. Change-Id: I1f91d96e32357b83bd0546537d561d638b6ff0c6main
parent
04bc787ce7
commit
e491be6e86
|
@ -41,14 +41,9 @@
|
||||||
latin:styleName="numberKeyStyle"
|
latin:styleName="numberKeyStyle"
|
||||||
latin:keyLabelFlags="alignLeftOfCenter|hasHintLabel"
|
latin:keyLabelFlags="alignLeftOfCenter|hasHintLabel"
|
||||||
latin:parentStyle="numKeyStyle" />
|
latin:parentStyle="numKeyStyle" />
|
||||||
<!-- U+0030: "0" DIGIT ZERO
|
|
||||||
U+002B: "+" PLUS SIGN -->
|
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="num0KeyStyle"
|
latin:styleName="num0KeyStyle"
|
||||||
latin:code="0x0030"
|
latin:keyLabel="0"
|
||||||
latin:altCode="0x002B"
|
|
||||||
latin:keyLabel="0 +"
|
|
||||||
latin:keyActionFlags="enableLongPress"
|
|
||||||
latin:parentStyle="numberKeyStyle" />
|
latin:parentStyle="numberKeyStyle" />
|
||||||
<key-style
|
<key-style
|
||||||
latin:styleName="num1KeyStyle"
|
latin:styleName="num1KeyStyle"
|
||||||
|
|
|
@ -111,13 +111,11 @@
|
||||||
<case
|
<case
|
||||||
latin:mode="datetime"
|
latin:mode="datetime"
|
||||||
>
|
>
|
||||||
<!-- U+002F: "/" SOLIDUS
|
<!-- U+002F: "/" SOLIDUS -->
|
||||||
U+003A: ":" COLON -->
|
|
||||||
<Key
|
<Key
|
||||||
latin:code="0x002F"
|
latin:code="0x002F"
|
||||||
latin:altCode="0x003A"
|
|
||||||
latin:keyLabel="/ :"
|
latin:keyLabel="/ :"
|
||||||
latin:keyActionFlags="enableLongPress"
|
latin:moreKeys="!embeddedMoreKey!,:"
|
||||||
latin:keyStyle="numKeyStyle" />
|
latin:keyStyle="numKeyStyle" />
|
||||||
</case>
|
</case>
|
||||||
<default>
|
<default>
|
||||||
|
|
|
@ -63,8 +63,12 @@
|
||||||
<Row>
|
<Row>
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="numPhoneToSymbolKeyStyle" />
|
latin:keyStyle="numPhoneToSymbolKeyStyle" />
|
||||||
|
<!-- U+0030: "0" DIGIT ZERO -->
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="num0KeyStyle" />
|
latin:keyStyle="num0KeyStyle"
|
||||||
|
latin:code="0x0030"
|
||||||
|
latin:keyLabel="0 +"
|
||||||
|
latin:moreKeys="!embeddedMoreKey!,+" />
|
||||||
<Key
|
<Key
|
||||||
latin:keyStyle="numSpaceKeyStyle" />
|
latin:keyStyle="numSpaceKeyStyle" />
|
||||||
<Key
|
<Key
|
||||||
|
|
|
@ -109,10 +109,12 @@ public class Key {
|
||||||
private static final int MORE_KEYS_FLAGS_FIXED_COLUMN_ORDER = 0x80000000;
|
private static final int MORE_KEYS_FLAGS_FIXED_COLUMN_ORDER = 0x80000000;
|
||||||
private static final int MORE_KEYS_FLAGS_HAS_LABELS = 0x40000000;
|
private static final int MORE_KEYS_FLAGS_HAS_LABELS = 0x40000000;
|
||||||
private static final int MORE_KEYS_FLAGS_NEEDS_DIVIDERS = 0x40000000;
|
private static final int MORE_KEYS_FLAGS_NEEDS_DIVIDERS = 0x40000000;
|
||||||
|
private static final int MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY = 0x20000000;
|
||||||
private static final String MORE_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
|
private static final String MORE_KEYS_AUTO_COLUMN_ORDER = "!autoColumnOrder!";
|
||||||
private static final String MORE_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
|
private static final String MORE_KEYS_FIXED_COLUMN_ORDER = "!fixedColumnOrder!";
|
||||||
private static final String MORE_KEYS_HAS_LABELS = "!hasLabels!";
|
private static final String MORE_KEYS_HAS_LABELS = "!hasLabels!";
|
||||||
private static final String MORE_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
|
private static final String MORE_KEYS_NEEDS_DIVIDERS = "!needsDividers!";
|
||||||
|
private static final String MORE_KEYS_EMBEDDED_MORE_KEY = "!embeddedMoreKey!";
|
||||||
|
|
||||||
/** Background type that represents different key background visual than normal one. */
|
/** Background type that represents different key background visual than normal one. */
|
||||||
public final int mBackgroundType;
|
public final int mBackgroundType;
|
||||||
|
@ -258,6 +260,9 @@ public class Key {
|
||||||
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_NEEDS_DIVIDERS)) {
|
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_NEEDS_DIVIDERS)) {
|
||||||
moreKeysColumn |= MORE_KEYS_FLAGS_NEEDS_DIVIDERS;
|
moreKeysColumn |= MORE_KEYS_FLAGS_NEEDS_DIVIDERS;
|
||||||
}
|
}
|
||||||
|
if (KeySpecParser.getBooleanValue(moreKeys, MORE_KEYS_EMBEDDED_MORE_KEY)) {
|
||||||
|
moreKeysColumn |= MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY;
|
||||||
|
}
|
||||||
mMoreKeysColumnAndFlags = moreKeysColumn;
|
mMoreKeysColumnAndFlags = moreKeysColumn;
|
||||||
|
|
||||||
final String[] additionalMoreKeys = style.getStringArray(
|
final String[] additionalMoreKeys = style.getStringArray(
|
||||||
|
@ -548,6 +553,10 @@ public class Key {
|
||||||
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
|
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_NEEDS_DIVIDERS) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasEmbeddedMoreKey() {
|
||||||
|
return (mMoreKeysColumnAndFlags & MORE_KEYS_FLAGS_EMBEDDED_MORE_KEY) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Drawable getIcon(KeyboardIconsSet iconSet) {
|
public Drawable getIcon(KeyboardIconsSet iconSet) {
|
||||||
return iconSet.getIconDrawable(mIconId);
|
return iconSet.getIconDrawable(mIconId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ import com.android.inputmethod.accessibility.AccessibleKeyboardViewProxy;
|
||||||
import com.android.inputmethod.deprecated.VoiceProxy;
|
import com.android.inputmethod.deprecated.VoiceProxy;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
|
import com.android.inputmethod.keyboard.PointerTracker.DrawingProxy;
|
||||||
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
import com.android.inputmethod.keyboard.PointerTracker.TimerProxy;
|
||||||
|
import com.android.inputmethod.keyboard.internal.KeySpecParser;
|
||||||
import com.android.inputmethod.latin.LatinIME;
|
import com.android.inputmethod.latin.LatinIME;
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
|
@ -480,13 +481,10 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
*/
|
*/
|
||||||
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
|
protected boolean onLongPress(Key parentKey, PointerTracker tracker) {
|
||||||
final int primaryCode = parentKey.mCode;
|
final int primaryCode = parentKey.mCode;
|
||||||
if (parentKey.mMoreKeys == null && !parentKey.altCodeWhileTyping()
|
if (parentKey.hasEmbeddedMoreKey()) {
|
||||||
&& parentKey.mAltCode != Keyboard.CODE_UNSPECIFIED) {
|
final int embeddedCode = KeySpecParser.getCode(getResources(), parentKey.mMoreKeys[0]);
|
||||||
// Long press on a key that has no more keys and is not altCodeWhileTyping, but altCode
|
|
||||||
// is defined, such as the "0 +" key on the phone layout and the "/ :" key on the
|
|
||||||
// datetime layout.
|
|
||||||
tracker.onLongPressed();
|
tracker.onLongPressed();
|
||||||
invokeCodeInput(parentKey.mAltCode);
|
invokeCodeInput(embeddedCode);
|
||||||
invokeReleaseKey(primaryCode);
|
invokeReleaseKey(primaryCode);
|
||||||
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
|
KeyboardSwitcher.getInstance().hapticAndAudioFeedback(primaryCode);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue