fixed the newline character not being displayed correctly on older devices
This commit is contained in:
parent
4b66226302
commit
81698c72da
2 changed files with 14 additions and 3 deletions
|
|
@ -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.Characters;
|
||||||
|
|
||||||
public class SuggestionsBar {
|
public class SuggestionsBar {
|
||||||
private double lastClickTime = 0;
|
private double lastClickTime = 0;
|
||||||
|
|
@ -115,11 +116,10 @@ public class SuggestionsBar {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return suggestions.get(id).equals("⏎") ? "\n" : suggestions.get(id);
|
return suggestions.get(id).equals(Characters.getNewLine()) ? "\n" : suggestions.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged")
|
|
||||||
public void setSuggestions(List<String> newSuggestions, int initialSel) {
|
public void setSuggestions(List<String> newSuggestions, int initialSel) {
|
||||||
ecoSetBackground(newSuggestions);
|
ecoSetBackground(newSuggestions);
|
||||||
|
|
||||||
|
|
@ -129,7 +129,7 @@ public class SuggestionsBar {
|
||||||
if (newSuggestions != null) {
|
if (newSuggestions != null) {
|
||||||
for (String suggestion : newSuggestions) {
|
for (String suggestion : newSuggestions) {
|
||||||
// make the new line better readable
|
// make the new line better readable
|
||||||
suggestions.add(suggestion.equals("\n") ? "⏎" : suggestion);
|
suggestions.add(suggestion.equals("\n") ? Characters.getNewLine() : suggestion);
|
||||||
}
|
}
|
||||||
selectedIndex = Math.max(initialSel, 0);
|
selectedIndex = Math.max(initialSel, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -138,6 +138,7 @@ public class SuggestionsBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("NotifyDataSetChanged")
|
||||||
private void setSuggestionsOnScreen() {
|
private void setSuggestionsOnScreen() {
|
||||||
if (mView != null) {
|
if (mView != null) {
|
||||||
mSuggestionsAdapter.setSelection(selectedIndex);
|
mSuggestionsAdapter.setSelection(selectedIndex);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Characters {
|
public class Characters {
|
||||||
|
private static String NEW_LINE_CHARACTER = null;
|
||||||
|
|
||||||
final public static ArrayList<String> ArabicNumbers = new ArrayList<>(Arrays.asList(
|
final public static ArrayList<String> ArabicNumbers = new ArrayList<>(Arrays.asList(
|
||||||
"٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"
|
"٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"
|
||||||
));
|
));
|
||||||
|
|
@ -131,4 +133,12 @@ public class Characters {
|
||||||
public static int getMaxEmojiLevel() {
|
public static int getMaxEmojiLevel() {
|
||||||
return Emoji.size();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue