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.text.format.DateUtils;
import androidx.core.text.TextUtilsCompat;
import androidx.core.view.ViewCompat;
import com.jwetherell.openmap.common.LatLonPoint;
import com.jwetherell.openmap.common.MGRSPoint;
import com.jwetherell.openmap.common.UTMPoint;
@ -225,10 +227,10 @@ public class OsmAndFormatter {
}
public static String getFormattedAzimuth(float bearing, AngularConstants angularConstant) {
while(bearing < -180.0) {
while (bearing < -180.0) {
bearing += 360;
}
while(bearing > 360.0) {
while (bearing > 360.0) {
bearing -= 360;
}
switch (angularConstant) {
@ -402,7 +404,7 @@ public class OsmAndFormatter {
String typeName = amenity.getSubType();
if (pt != null) {
typeName = pt.getTranslation();
} else if(typeName != null){
} else if (typeName != null) {
typeName = Algorithms.capitalizeFirstLetterAndLowercase(typeName.replace('_', ' '));
}
String localName = amenity.getName(locale, transliterate);
@ -506,11 +508,20 @@ public class OsmAndFormatter {
if (outputFormat == FORMAT_DEGREES_SHORT) {
result.append(formatCoordinate(lat, outputFormat)).append(" ").append(formatCoordinate(lon, outputFormat));
} else if (outputFormat == FORMAT_DEGREES || outputFormat == FORMAT_MINUTES || outputFormat == FORMAT_SECONDS) {
boolean isLeftToRight = TextUtilsCompat.getLayoutDirectionFromLocale(Locale.getDefault()) == ViewCompat.LAYOUT_DIRECTION_LTR;
if (isLeftToRight) {
result
.append(formatCoordinate(lat, outputFormat)).append(" ")
.append(lat > 0 ? NORTH : SOUTH).append(", ")
.append(formatCoordinate(lon, outputFormat)).append(" ")
.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) {
UTMPoint pnt = new UTMPoint(new LatLonPoint(lat, lon));
result