am 75fb3ce1: More readable Key.toString() and MoreKeySpec.toString()

* commit '75fb3ce1be3c879bb614097a2534f791c833dd7c':
  More readable Key.toString() and MoreKeySpec.toString()
main
Tadashi G. Takaoka 2012-07-30 00:26:05 -07:00 committed by Android Git Automerger
commit fb1fe2da9e
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;
}
}
}