mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 07:01:05 +00:00
Simplify text direction
This commit is contained in:
parent
c16da8ca17
commit
4a216a719a
2 changed files with 2 additions and 26 deletions
|
@ -957,31 +957,6 @@ public class Helper {
|
||||||
}
|
}
|
||||||
// https://issuetracker.google.com/issues/37054851
|
// https://issuetracker.google.com/issues/37054851
|
||||||
|
|
||||||
static boolean isRtl(String text) {
|
|
||||||
if (TextUtils.isEmpty(text))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int rtl = 0;
|
|
||||||
int ltr = 0;
|
|
||||||
for (int i = 0; i < text.length(); i++)
|
|
||||||
switch (Character.getDirectionality(text.charAt(i))) {
|
|
||||||
case java.lang.Character.DIRECTIONALITY_RIGHT_TO_LEFT:
|
|
||||||
case java.lang.Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
|
|
||||||
case java.lang.Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
|
|
||||||
case java.lang.Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
|
|
||||||
rtl++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case java.lang.Character.DIRECTIONALITY_LEFT_TO_RIGHT:
|
|
||||||
case java.lang.Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
|
|
||||||
case java.lang.Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
|
|
||||||
ltr++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (rtl > ltr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DateFormat getTimeInstance(Context context) {
|
static DateFormat getTimeInstance(Context context) {
|
||||||
return getTimeInstance(context, SimpleDateFormat.MEDIUM);
|
return getTimeInstance(context, SimpleDateFormat.MEDIUM);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import android.text.Layout;
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.text.TextDirectionHeuristics;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.AlignmentSpan;
|
import android.text.style.AlignmentSpan;
|
||||||
|
@ -2260,7 +2261,7 @@ public class HtmlHelper {
|
||||||
case "text-align":
|
case "text-align":
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
|
||||||
Layout.Alignment alignment = null;
|
Layout.Alignment alignment = null;
|
||||||
boolean rtl = Helper.isRtl(ssb.subSequence(start, ssb.length()).toString());
|
boolean rtl = TextDirectionHeuristics.FIRSTSTRONG_LTR.isRtl(ssb, start, ssb.length() - start);
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "left":
|
case "left":
|
||||||
case "start":
|
case "start":
|
||||||
|
|
Loading…
Reference in a new issue