1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-17 02:44:04 +02:00

Fix missing space

This commit is contained in:
Roi Greenberg 2018-08-26 02:06:45 +03:00
parent d9720e97a0
commit 6b57809646

View File

@ -135,6 +135,27 @@ class RtlUtils {
return false;
}
//list of sign that ends a word
private static ArrayList<Character> endLineSigns = new ArrayList<Character>() {
{
add('\0');
add('\n');
}
};
/**
* @return true if the char is in the end of word list, otherwise false
*/
static Boolean isEndLineSign(char c){
for (char sign: endLineSigns){
if (c == sign){
return true;
}
}
return false;
}
//map from Arabian characters to their contextual form in the beginning of the word
private static Map<Character, Character> contextualArabicIsolated = new HashMap<Character, Character>(){
{
@ -400,7 +421,7 @@ class RtlUtils {
*/
static String reverse(String s) {
int j = s.length();
int startWithSpace = 0;
int isEndLine = 0;
char[] newWord = new char[j];
if (j == 0) {
@ -408,18 +429,19 @@ class RtlUtils {
}
// remain end-of-word sign at the end
if (isWordEndSign(s.charAt(s.length() - 1))){
startWithSpace = 1;
if (isEndLineSign(s.charAt(s.length() - 1))){
isEndLine = 1;
newWord[--j] = s.charAt(s.length() - 1);
}
for (int i = 0; i < s.length() - startWithSpace; i++) {
for (int i = 0; i < s.length() - isEndLine; i++) {
if (directionSignsMap.containsKey(s.charAt(i))) {
newWord[--j] = directionSignsMap.get(s.charAt(i));
} else {
newWord[--j] = s.charAt(i);
}
}
return new String(newWord);
}
}