mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix incorrect hint label when redundant keys are removed
This commit is contained in:
parent
7e0234cb22
commit
02fd5e40d8
@ -440,8 +440,6 @@ public class Key implements Comparable<Key> {
|
|||||||
// Final attributes.
|
// Final attributes.
|
||||||
mCode = key.mCode;
|
mCode = key.mCode;
|
||||||
mLabel = key.mLabel;
|
mLabel = key.mLabel;
|
||||||
mHintLabel = key.mHintLabel;
|
|
||||||
mHintIconId = key.mHintIconId;
|
|
||||||
mLabelFlags = key.mLabelFlags;
|
mLabelFlags = key.mLabelFlags;
|
||||||
mIconId = key.mIconId;
|
mIconId = key.mIconId;
|
||||||
mWidth = key.mWidth;
|
mWidth = key.mWidth;
|
||||||
@ -461,6 +459,29 @@ public class Key implements Comparable<Key> {
|
|||||||
// Key state.
|
// Key state.
|
||||||
mPressed = key.mPressed;
|
mPressed = key.mPressed;
|
||||||
mEnabled = key.mEnabled;
|
mEnabled = key.mEnabled;
|
||||||
|
|
||||||
|
|
||||||
|
if (((mLabelFlags & LABEL_FLAGS_DISABLE_HINT_LABEL) != 0) || moreKeys == null || moreKeys.length == 0 || moreKeys[0].mLabel == null) {
|
||||||
|
mHintLabel = key.mHintLabel;
|
||||||
|
mHintIconId = key.mHintIconId;
|
||||||
|
} else {
|
||||||
|
String hintLabel = null;
|
||||||
|
String hintIcon = null;
|
||||||
|
|
||||||
|
String hintLabelCandidate = moreKeys[0].mLabel;
|
||||||
|
if(hintLabelCandidate.startsWith("\\")) hintLabelCandidate = hintLabelCandidate.substring(1);
|
||||||
|
|
||||||
|
if(hintLabelCandidate.length() == 1) {
|
||||||
|
hintLabel = moreKeys[0].mNeedsToUpperCase
|
||||||
|
? StringUtils.toTitleCaseOfKeyLabel(hintLabelCandidate, moreKeys[0].mLocale)
|
||||||
|
: hintLabelCandidate;
|
||||||
|
} else if(hintLabelCandidate.contains("!icon/")) {
|
||||||
|
hintIcon = KeySpecParser.getIconId(hintLabelCandidate);
|
||||||
|
}
|
||||||
|
|
||||||
|
mHintLabel = hintLabel;
|
||||||
|
mHintIconId = hintIcon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -52,11 +52,16 @@ public final class MoreKeySpec {
|
|||||||
public final String mOutputText;
|
public final String mOutputText;
|
||||||
public final String mIconId;
|
public final String mIconId;
|
||||||
|
|
||||||
|
public final boolean mNeedsToUpperCase;
|
||||||
|
public final Locale mLocale;
|
||||||
|
|
||||||
public MoreKeySpec(@Nonnull final String moreKeySpec, boolean needsToUpperCase,
|
public MoreKeySpec(@Nonnull final String moreKeySpec, boolean needsToUpperCase,
|
||||||
@Nonnull final Locale locale) {
|
@Nonnull final Locale locale) {
|
||||||
if (moreKeySpec.isEmpty()) {
|
if (moreKeySpec.isEmpty()) {
|
||||||
throw new KeySpecParser.KeySpecParserError("Empty more key spec");
|
throw new KeySpecParser.KeySpecParserError("Empty more key spec");
|
||||||
}
|
}
|
||||||
|
mLocale = locale;
|
||||||
|
mNeedsToUpperCase = needsToUpperCase;
|
||||||
final String label = KeySpecParser.getLabel(moreKeySpec);
|
final String label = KeySpecParser.getLabel(moreKeySpec);
|
||||||
mLabel = needsToUpperCase ? StringUtils.toTitleCaseOfKeyLabel(label, locale) : label;
|
mLabel = needsToUpperCase ? StringUtils.toTitleCaseOfKeyLabel(label, locale) : label;
|
||||||
final int codeInSpec = KeySpecParser.getCode(moreKeySpec);
|
final int codeInSpec = KeySpecParser.getCode(moreKeySpec);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user