Align relative to text direction

This commit is contained in:
M66B
2021-01-30 15:28:43 +01:00
parent 6b4b0e280e
commit 97084bfc35
2 changed files with 28 additions and 4 deletions

View File

@@ -55,7 +55,6 @@ import android.text.style.URLSpan;
import android.text.style.UnderlineSpan;
import android.util.Base64;
import android.util.Patterns;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -1951,7 +1950,6 @@ public class HtmlHelper {
final int dp3 = Helper.dp2pixels(context, 3);
final int dp6 = Helper.dp2pixels(context, 6);
final int dp24 = Helper.dp2pixels(context, 24);
final boolean ltr = (TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_LTR);
int message_zoom = prefs.getInt("message_zoom", 100);
float textSize = Helper.getTextSize(context, 0) * message_zoom / 100f;
@@ -2185,17 +2183,18 @@ public class HtmlHelper {
case "text-align":
// https://developer.mozilla.org/en-US/docs/Web/CSS/text-align
Layout.Alignment alignment = null;
boolean rtl = Helper.isRtl(ssb.subSequence(start, ssb.length()).toString());
switch (value) {
case "left":
case "start":
alignment = (ltr ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_OPPOSITE);
alignment = (rtl ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL);
break;
case "center":
alignment = Layout.Alignment.ALIGN_CENTER;
break;
case "right":
case "end":
alignment = (ltr ? Layout.Alignment.ALIGN_OPPOSITE : Layout.Alignment.ALIGN_NORMAL);
alignment = (rtl ? Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_OPPOSITE);
break;
}
if (alignment != null)