More readable Key.toString() and MoreKeySpec.toString()

Change-Id: Iee3c33dedd0c00ba259aa55e8b0c1c57b84eccdd
main
Tadashi G. Takaoka 2012-07-30 15:51:41 +09:00
parent efd8b838ee
commit 75fb3ce1be
2 changed files with 14 additions and 4 deletions

View File

@ -414,8 +414,14 @@ public class Key {
@Override
public String toString() {
return String.format("%s/%s %d,%d %dx%d %s/%s/%s",
Keyboard.printableCode(mCode), mLabel, mX, mY, mWidth, mHeight, mHintLabel,
final String label;
if (StringUtils.codePointCount(mLabel) == 1 && mLabel.codePointAt(0) == mCode) {
label = "";
} else {
label = "/" + mLabel;
}
return String.format("%s%s %d,%d %dx%d %s/%s/%s",
Keyboard.printableCode(mCode), label, mX, mY, mWidth, mHeight, mHintLabel,
KeyboardIconsSet.getIconName(mIconId), backgroundName(mBackgroundType));
}

View File

@ -90,8 +90,12 @@ public class KeySpecParser {
final String label = (mIconId == KeyboardIconsSet.ICON_UNDEFINED ? mLabel
: PREFIX_ICON + KeyboardIconsSet.getIconName(mIconId));
final String output = (mCode == Keyboard.CODE_OUTPUT_TEXT ? mOutputText
: String.format("0x%04x", mCode));
return label + "/" + output;
: Keyboard.printableCode(mCode));
if (StringUtils.codePointCount(label) == 1 && label.codePointAt(0) == mCode) {
return output;
} else {
return label + "|" + output;
}
}
}