Merge "Use additional proximity chars even when no key is detected."
commit
03c3018492
|
@ -180,32 +180,34 @@ public class KeyDetector {
|
||||||
if (maxCodesSize <= numCodes) {
|
if (maxCodesSize <= numCodes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (primaryCode != NOT_A_CODE) {
|
|
||||||
final List<Integer> additionalChars =
|
final int code = (primaryCode == NOT_A_CODE) ? allCodes[0] : primaryCode;
|
||||||
mKeyboard.getAdditionalProximityChars().get(primaryCode);
|
if (code == NOT_A_CODE) {
|
||||||
if (additionalChars == null || additionalChars.size() == 0) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
final List<Integer> additionalChars = mKeyboard.getAdditionalProximityChars().get(code);
|
||||||
int currentCodesSize = numCodes;
|
if (additionalChars == null || additionalChars.size() == 0) {
|
||||||
allCodes[numCodes++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
|
return;
|
||||||
if (maxCodesSize <= numCodes) {
|
}
|
||||||
return;
|
int currentCodesSize = numCodes;
|
||||||
}
|
allCodes[numCodes++] = ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE;
|
||||||
// TODO: This is O(N^2). Assuming additionalChars.size() is up to 4 or 5.
|
if (maxCodesSize <= numCodes) {
|
||||||
for (int i = 0; i < additionalChars.size(); ++i) {
|
return;
|
||||||
final int additionalChar = additionalChars.get(i);
|
}
|
||||||
boolean contains = false;
|
// TODO: This is O(N^2). Assuming additionalChars.size() is up to 4 or 5.
|
||||||
for (int j = 0; j < currentCodesSize; ++j) {
|
for (int i = 0; i < additionalChars.size(); ++i) {
|
||||||
if (additionalChar == allCodes[j]) {
|
final int additionalChar = additionalChars.get(i);
|
||||||
contains = true;
|
boolean contains = false;
|
||||||
break;
|
for (int j = 0; j < currentCodesSize; ++j) {
|
||||||
}
|
if (additionalChar == allCodes[j]) {
|
||||||
|
contains = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!contains) {
|
}
|
||||||
allCodes[numCodes++] = additionalChar;
|
if (!contains) {
|
||||||
if (maxCodesSize <= numCodes) {
|
allCodes[numCodes++] = additionalChar;
|
||||||
return;
|
if (maxCodesSize <= numCodes) {
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,10 +259,17 @@ public class KeyDetector {
|
||||||
|
|
||||||
public static String printableCodes(int[] codes) {
|
public static String printableCodes(int[] codes) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
boolean addDelimiter = false;
|
||||||
for (final int code : codes) {
|
for (final int code : codes) {
|
||||||
if (code == NOT_A_CODE) break;
|
if (code == NOT_A_CODE) break;
|
||||||
if (sb.length() > 0) sb.append(", ");
|
if (code == ADDITIONAL_PROXIMITY_CHAR_DELIMITER_CODE) {
|
||||||
sb.append(code);
|
sb.append(" | ");
|
||||||
|
addDelimiter = false;
|
||||||
|
} else {
|
||||||
|
if (addDelimiter) sb.append(", ");
|
||||||
|
sb.append(code);
|
||||||
|
addDelimiter = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return "[" + sb + "]";
|
return "[" + sb + "]";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue