combining characters are now displayed with an empty-circle base for better readability
This commit is contained in:
parent
fb03f8ef61
commit
f4d031698f
3 changed files with 31 additions and 17 deletions
|
|
@ -15,6 +15,7 @@ import io.github.sspanak.tt9.languages.LanguageKind;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.util.Logger;
|
import io.github.sspanak.tt9.util.Logger;
|
||||||
import io.github.sspanak.tt9.util.TextTools;
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
|
import io.github.sspanak.tt9.util.chars.Characters;
|
||||||
|
|
||||||
public class SoftKeyNumber2to9 extends SoftKeyNumber {
|
public class SoftKeyNumber2to9 extends SoftKeyNumber {
|
||||||
public SoftKeyNumber2to9(Context context) { super(context); }
|
public SoftKeyNumber2to9(Context context) { super(context); }
|
||||||
|
|
@ -88,16 +89,17 @@ public class SoftKeyNumber2to9 extends SoftKeyNumber {
|
||||||
* In some languages there are many characters for a single key. Naturally, they can not all fit
|
* In some languages there are many characters for a single key. Naturally, they can not all fit
|
||||||
* on one key. As suggested by the community, we could display them as "A-Z".
|
* on one key. As suggested by the community, we could display them as "A-Z".
|
||||||
* @see <a href="https://github.com/sspanak/tt9/issues/628">Issue #628</a>
|
* @see <a href="https://github.com/sspanak/tt9/issues/628">Issue #628</a>
|
||||||
|
* Additionally, for combining characters, we want to add a dummy base, to ensure they look properly.
|
||||||
*/
|
*/
|
||||||
private String abbreviateCharList(String chars, Locale locale, boolean isUppercase) {
|
private String abbreviateCharList(String chars, Locale locale, boolean isUppercase) {
|
||||||
String firstLetter = chars.substring(0, 1);
|
String firstLetter = chars.substring(0, 1);
|
||||||
String lastLetter = chars.substring(chars.length() - 1);
|
firstLetter = TextTools.isCombining(firstLetter) ? Characters.COMBINING_ZERO_BASE + firstLetter : firstLetter;
|
||||||
boolean containsCombiningChars = TextTools.isCombining(firstLetter) || TextTools.isCombining(lastLetter);
|
|
||||||
|
|
||||||
return
|
String lastLetter = chars.substring(chars.length() - 1);
|
||||||
(isUppercase ? firstLetter.toUpperCase(locale) : firstLetter)
|
lastLetter = TextTools.isCombining(lastLetter) ? Characters.COMBINING_ZERO_BASE + lastLetter : lastLetter;
|
||||||
+ (containsCombiningChars ? "– " : "–")
|
|
||||||
+ (isUppercase ? lastLetter.toUpperCase(locale) : lastLetter);
|
String list = firstLetter + "–" + lastLetter;
|
||||||
|
return isUppercase ? list.toUpperCase(locale) : list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import io.github.sspanak.tt9.R;
|
||||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.ui.Vibration;
|
import io.github.sspanak.tt9.ui.Vibration;
|
||||||
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
import io.github.sspanak.tt9.ui.main.ResizableMainView;
|
||||||
|
import io.github.sspanak.tt9.util.TextTools;
|
||||||
import io.github.sspanak.tt9.util.chars.Characters;
|
import io.github.sspanak.tt9.util.chars.Characters;
|
||||||
|
|
||||||
public class SuggestionsBar {
|
public class SuggestionsBar {
|
||||||
|
|
@ -141,19 +142,24 @@ public class SuggestionsBar {
|
||||||
|
|
||||||
String suggestion = suggestions.get(id);
|
String suggestion = suggestions.get(id);
|
||||||
|
|
||||||
if (suggestion.endsWith(STEM_SUFFIX)) {
|
if (Characters.ZWJ_GRAPHIC.equals(suggestion)) return Characters.ZWJ;
|
||||||
return stem;
|
if (Characters.ZWNJ_GRAPHIC.equals(suggestion)) return Characters.ZWNJ;
|
||||||
} else if (suggestion.startsWith(STEM_VARIATION_PREFIX)) {
|
if (suggestion.equals(Characters.NEW_LINE)) return "\n";
|
||||||
return stem + suggestion.substring(STEM_VARIATION_PREFIX.length());
|
|
||||||
} else if (suggestion.startsWith(STEM_PUNCTUATION_VARIATION_PREFIX)) {
|
int endIndex = suggestion.indexOf(STEM_SUFFIX);
|
||||||
return stem + suggestion.substring(STEM_PUNCTUATION_VARIATION_PREFIX.length());
|
endIndex = endIndex == -1 ? suggestion.length() : endIndex;
|
||||||
|
|
||||||
|
int startIndex = 0;
|
||||||
|
String[] prefixes = {STEM_VARIATION_PREFIX, STEM_PUNCTUATION_VARIATION_PREFIX, Characters.COMBINING_ZERO_BASE};
|
||||||
|
for (String prefix : prefixes) {
|
||||||
|
startIndex = Math.max(startIndex, suggestion.indexOf(prefix) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIndex == 0 && endIndex == suggestion.length()) {
|
||||||
|
return suggestion;
|
||||||
}
|
}
|
||||||
|
|
||||||
return switch (suggestion) {
|
return stem + suggestion.substring(startIndex, endIndex);
|
||||||
case Characters.ZWJ_GRAPHIC -> Characters.ZWJ;
|
|
||||||
case Characters.ZWNJ_GRAPHIC -> Characters.ZWNJ;
|
|
||||||
default -> suggestion.equals(Characters.NEW_LINE) ? "\n" : suggestion;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -232,6 +238,10 @@ public class SuggestionsBar {
|
||||||
|
|
||||||
|
|
||||||
private String formatUnreadableSuggestion(String suggestion) {
|
private String formatUnreadableSuggestion(String suggestion) {
|
||||||
|
if (TextTools.isCombining(suggestion)) {
|
||||||
|
return Characters.COMBINING_ZERO_BASE + suggestion;
|
||||||
|
}
|
||||||
|
|
||||||
return switch (suggestion) {
|
return switch (suggestion) {
|
||||||
case "\n" -> Characters.NEW_LINE;
|
case "\n" -> Characters.NEW_LINE;
|
||||||
case Characters.ZWJ -> Characters.ZWJ_GRAPHIC;
|
case Characters.ZWJ -> Characters.ZWJ_GRAPHIC;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import java.util.Arrays;
|
||||||
import io.github.sspanak.tt9.languages.Language;
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
|
|
||||||
public class Characters extends Emoji {
|
public class Characters extends Emoji {
|
||||||
|
public static final String COMBINING_ZERO_BASE = "◌";
|
||||||
|
|
||||||
final public static ArrayList<String> Currency = new ArrayList<>(Arrays.asList(
|
final public static ArrayList<String> Currency = new ArrayList<>(Arrays.asList(
|
||||||
"$", "€", "₿", "¢", "¤", "₱", "¥", "£"
|
"$", "€", "₿", "¢", "¤", "₱", "¥", "£"
|
||||||
));
|
));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue