1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-03 11:33:19 +02:00

Add some docstring

This commit is contained in:
Roi 2018-08-26 02:09:50 +03:00
parent 6b57809646
commit 1ece83374b
2 changed files with 42 additions and 23 deletions

View File

@ -325,6 +325,12 @@ class RtlUtils {
}
}
/**
* This function return the contextual form of Arabic characters in a given state
* @param c - the character to convert
* @param state - the character state: beginning, middle, end or isolated
* @return the contextual character
*/
private static char getContextualSymbol(Character c, contextualState state) {
Character newChar;
switch (state){
@ -348,6 +354,41 @@ class RtlUtils {
}
}
/**
* This function return the contextual state of a given character, depend of the previous
* character state and the next charachter.
* @param prevState - previous character state or isolated if none
* @param curChar - the current character
* @param nextChar - the next character or null if none
* @return the current character contextual state
*/
private static contextualState getCharContextualState(contextualState prevState, Character curChar, Character nextChar) {
contextualState curState;
if ((prevState == contextualState.isolate || prevState == contextualState.end) &&
contextualArabicBeginning.containsKey(curChar) &&
contextualArabicEnd.containsKey(nextChar)){
curState = contextualState.begin;
} else if ((prevState == contextualState.begin || prevState == contextualState.middle) &&
contextualArabicEnd.containsKey(curChar)){
if (contextualArabicMiddle.containsKey(curChar) && contextualArabicEnd.containsKey(nextChar)){
curState = contextualState.middle;
}else{
curState = contextualState.end;
}
}else{
curState = contextualState.isolate;
}
return curState;
}
/**
* this function convert given string to it's contextual form
* @param s - the given string
* @return the contextual form of the string
*/
static String converToContextual(String s){
if (s == null || s.isEmpty() || s.length() == 1){
return s;
@ -389,28 +430,6 @@ class RtlUtils {
return newWord.toString();
}
private static contextualState getCharContextualState(contextualState prevState, Character curChar, Character nextChar) {
contextualState curState;
if ((prevState == contextualState.isolate || prevState == contextualState.end) &&
contextualArabicBeginning.containsKey(curChar) &&
contextualArabicEnd.containsKey(nextChar)){
curState = contextualState.begin;
} else if ((prevState == contextualState.begin || prevState == contextualState.middle) &&
contextualArabicEnd.containsKey(curChar)){
if (contextualArabicMiddle.containsKey(curChar) && contextualArabicEnd.containsKey(nextChar)){
curState = contextualState.middle;
}else{
curState = contextualState.end;
}
}else{
curState = contextualState.isolate;
}
return curState;
}
/**
* The function get a string and reverse it.

View File

@ -107,7 +107,7 @@
<string name="pref_title_rtl">Right-To-Left</string>
<string name="pref_summary_rtl">Enable this if your device has no support in right-to-left languages</string>
<string name="pref_rtl_max_line_length">Right-To-Left Max Line Length</string>
<string name="pref_rtl_max_line_length_summary">When Right-To-Left is enable, the text is separated to lines. Change tjis value if the lines are to long/short.</string>
<string name="pref_rtl_max_line_length_summary">When Right-To-Left is enable, the text is separated to lines. Change this value if the lines are to long/short.</string>
<string name="always">Always</string>
<string name="when_screen_off">When screen is off</string>