RTL issue - Applying correct text direction (ltr or rtl)

https://github.com/osmandapp/OsmAnd/issues/11212
This commit is contained in:
androiddevkotlin 2021-03-25 23:56:08 +02:00
parent ce475077fe
commit eeaf45ea98

View file

@ -3,6 +3,8 @@ package net.osmand.plus;
import android.content.Context; import android.content.Context;
import android.text.format.DateUtils; import android.text.format.DateUtils;
import androidx.core.text.TextUtilsCompat;
import androidx.core.view.ViewCompat;
import com.jwetherell.openmap.common.LatLonPoint; import com.jwetherell.openmap.common.LatLonPoint;
import com.jwetherell.openmap.common.MGRSPoint; import com.jwetherell.openmap.common.MGRSPoint;
import com.jwetherell.openmap.common.UTMPoint; import com.jwetherell.openmap.common.UTMPoint;
@ -506,11 +508,20 @@ public class OsmAndFormatter {
if (outputFormat == FORMAT_DEGREES_SHORT) { if (outputFormat == FORMAT_DEGREES_SHORT) {
result.append(formatCoordinate(lat, outputFormat)).append(" ").append(formatCoordinate(lon, outputFormat)); result.append(formatCoordinate(lat, outputFormat)).append(" ").append(formatCoordinate(lon, outputFormat));
} else if (outputFormat == FORMAT_DEGREES || outputFormat == FORMAT_MINUTES || outputFormat == FORMAT_SECONDS) { } else if (outputFormat == FORMAT_DEGREES || outputFormat == FORMAT_MINUTES || outputFormat == FORMAT_SECONDS) {
boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR;
if (isLeftToRight) {
result result
.append(formatCoordinate(lat, outputFormat)).append(" ") .append(formatCoordinate(lat, outputFormat)).append(" ")
.append(lat > 0 ? NORTH : SOUTH).append(", ") .append(lat > 0 ? NORTH : SOUTH).append(", ")
.append(formatCoordinate(lon, outputFormat)).append(" ") .append(formatCoordinate(lon, outputFormat)).append(" ")
.append(lon > 0 ? EAST : WEST); .append(lon > 0 ? EAST : WEST);
} else {
result
.append(formatCoordinate(lat, outputFormat)).append(" ")
.append(lon > 0 ? EAST : WEST).append(" ")
.append(formatCoordinate(lon, outputFormat)).append(", ")
.append(lat > 0 ? NORTH : SOUTH);
}
} else if (outputFormat == UTM_FORMAT) { } else if (outputFormat == UTM_FORMAT) {
UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon)); UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon));
result result