fixed some issues with the Greek question mark and optimized the generation of the new line character in the suggestions
This commit is contained in:
parent
4fd1fb4378
commit
33fb98a996
4 changed files with 31 additions and 28 deletions
|
|
@ -13,9 +13,9 @@ import io.github.sspanak.tt9.util.Text;
|
|||
public class AutoSpace {
|
||||
private static final Set<Character> PRECEDING_SPACE_PUNCTUATION = Set.of('(', '«', '„');
|
||||
private static final Set<Character> PRECEDING_SPACE_FRENCH_PUNCTUATION = Set.of(';', ':', '!', '?', '»');
|
||||
private static final Set<Character> TRAILING_SPACE_PUNCTUATION = Set.of('.', ',', ';', '!', '?', ')', '%', '»', '؟', '“');
|
||||
private static final Set<Character> TRAILING_SPACE_PUNCTUATION = Set.of('.', ',', ';', '!', '?', ')', '%', '»', '؟', '“', Characters.GR_QUESTION_MARK.charAt(0));
|
||||
|
||||
private static final Set<Character> NO_PRECEDING_SPACE_PUNCTUATION = Set.of('.', ',', ')', '\'', '@', '“', '؟');
|
||||
private static final Set<Character> NO_PRECEDING_SPACE_PUNCTUATION = Set.of('.', ',', ')', '\'', '@', '“', '؟', Characters.GR_QUESTION_MARK.charAt(0));
|
||||
private static final Set<Character> NOT_FRENCH_NO_PRECEDING_SPACE_PUNCTUATION = Set.of(';', ':', '!', '?', '»');
|
||||
|
||||
private final SettingsStore settings;
|
||||
|
|
@ -103,10 +103,10 @@ public class AutoSpace {
|
|||
&& !nextChars.startsWithNumber()
|
||||
&& (
|
||||
TRAILING_SPACE_PUNCTUATION.contains(previousChar)
|
||||
|| (previousChar == ':' && !Character.isDigit(penultimateChar))
|
||||
|| (isLanguageFrench && previousChar == '«')
|
||||
|| (penultimateChar == ' ' && previousChar == '-')
|
||||
|| (penultimateChar == ' ' && previousChar == '/')
|
||||
|| (!Character.isDigit(penultimateChar) && previousChar == ':')
|
||||
|| (Character.isDigit(penultimateChar) && Characters.Currency.contains(String.valueOf(previousChar)))
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.util.AttributeSet;
|
|||
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||
import io.github.sspanak.tt9.util.Characters;
|
||||
|
||||
public class SoftKeyPunctuation extends SoftKey {
|
||||
public SoftKeyPunctuation(Context context) {
|
||||
|
|
@ -43,19 +44,29 @@ public class SoftKeyPunctuation extends SoftKey {
|
|||
}
|
||||
|
||||
int keyId = getId();
|
||||
if (tt9.isInputModePhone()) {
|
||||
if (keyId == R.id.soft_key_punctuation_1) return "*";
|
||||
if (keyId == R.id.soft_key_punctuation_2) return "#";
|
||||
} else if (tt9.isInputModeNumeric()) {
|
||||
if (keyId == R.id.soft_key_punctuation_1) return ",";
|
||||
if (keyId == R.id.soft_key_punctuation_2) return ".";
|
||||
} else {
|
||||
if (keyId == R.id.soft_key_punctuation_1) return "!";
|
||||
if (keyId == R.id.soft_key_punctuation_2) {
|
||||
return LanguageKind.isArabic(tt9.getLanguage()) ? "؟" : "?";
|
||||
}
|
||||
if (keyId == R.id.soft_key_punctuation_1) {
|
||||
return getKey1Char();
|
||||
} else if (keyId == R.id.soft_key_punctuation_2) {
|
||||
return getKey2Char();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
private String getKey1Char() {
|
||||
if (tt9.isInputModePhone()) return "*";
|
||||
if (tt9.isInputModeNumeric()) return ",";
|
||||
|
||||
return "!";
|
||||
}
|
||||
|
||||
private String getKey2Char() {
|
||||
if (tt9.isInputModePhone()) return "#";
|
||||
if (tt9.isInputModeNumeric()) return ".";
|
||||
|
||||
if (LanguageKind.isArabic(tt9.getLanguage())) return "؟";
|
||||
if (LanguageKind.isGreek(tt9.getLanguage())) return Characters.GR_QUESTION_MARK;
|
||||
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class SuggestionsBar {
|
|||
return stem + suggestions.get(id).substring(STEM_PUNCTUATION_VARIATION_PREFIX.length());
|
||||
}
|
||||
|
||||
return suggestions.get(id).equals(Characters.getNewLine()) ? "\n" : suggestions.get(id);
|
||||
return suggestions.get(id).equals(Characters.NEW_LINE) ? "\n" : suggestions.get(id);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ public class SuggestionsBar {
|
|||
}
|
||||
// make the new line better readable
|
||||
else if (suggestion.equals("\n")) {
|
||||
suggestions.add(Characters.getNewLine());
|
||||
suggestions.add(Characters.NEW_LINE);
|
||||
}
|
||||
// or add any other suggestion as is
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import io.github.sspanak.tt9.languages.Language;
|
|||
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||
|
||||
public class Characters {
|
||||
private static String NEW_LINE_CHARACTER = null;
|
||||
|
||||
public static final String GR_QUESTION_MARK = ";";
|
||||
public static final String NEW_LINE = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && new Paint().hasGlyph("⏎") ? "⏎" : "\\n";
|
||||
|
||||
final public static ArrayList<String> ArabicNumbers = new ArrayList<>(Arrays.asList(
|
||||
"٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"
|
||||
|
|
@ -23,7 +23,7 @@ public class Characters {
|
|||
|
||||
final public static ArrayList<Character> CombiningPunctuationHebrew = new ArrayList<>(Arrays.asList(
|
||||
',' , '-', '\'', ':', ';', '!', '?', '.', '"',
|
||||
'·', ';', // Greek
|
||||
'·', GR_QUESTION_MARK.charAt(0), // Greek
|
||||
'،', '؛', ':', '!', '؟' // Arabic
|
||||
));
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ public class Characters {
|
|||
));
|
||||
|
||||
final public static ArrayList<String> PunctuationGreek = new ArrayList<>(Arrays.asList(
|
||||
",", ".", "-", "«", "»", "(", ")", "&", "~", "`", "'", "\"", "·", ":", "!", ";"
|
||||
",", ".", "-", "«", "»", "(", ")", "&", "~", "`", "'", "\"", "·", ":", "!", GR_QUESTION_MARK
|
||||
));
|
||||
|
||||
final public static ArrayList<String> Currency = new ArrayList<>(Arrays.asList(
|
||||
|
|
@ -148,14 +148,6 @@ public class Characters {
|
|||
return Emoji.size();
|
||||
}
|
||||
|
||||
public static String getNewLine() {
|
||||
if (NEW_LINE_CHARACTER == null) {
|
||||
NEW_LINE_CHARACTER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && new Paint().hasGlyph("⏎") ? "⏎" : "\\n";
|
||||
}
|
||||
|
||||
return NEW_LINE_CHARACTER;
|
||||
}
|
||||
|
||||
public static boolean isCombiningPunctuation(Language language, char ch) {
|
||||
return
|
||||
CombiningPunctuation.contains(ch)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue