Merge pull request #7207 from osmandapp/360_deg_setting

360 deg setting
This commit is contained in:
vshcherb 2019-07-09 15:01:26 +02:00 committed by GitHub
commit 021ad48e8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 5 deletions

View file

@ -40,6 +40,8 @@ public class OsmAndFormatter {
private static final SimpleDateFormat SIMPLE_TIME_OF_DAY_FORMAT = new SimpleDateFormat("HH:mm", Locale.getDefault());
private static final String[] localDaysStr = getLettersStringArray(DateFormatSymbols.getInstance().getShortWeekdays(), 3);
public static final float MILS_IN_DEGREE = 17.777778f;
public static final int FORMAT_DEGREES_SHORT = 6;
public static final int FORMAT_DEGREES = LocationConvert.FORMAT_DEGREES;
public static final int FORMAT_MINUTES = LocationConvert.FORMAT_MINUTES;
@ -195,12 +197,23 @@ public class OsmAndFormatter {
while(bearing > 360.0) {
bearing -= 360;
}
int azimuth = (int) bearing;
if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.MILLIRADS) {
return (int) (azimuth * 17.4533) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
if (bearing < 0) {
return Math.round((360 + bearing) * MILS_IN_DEGREE) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
} else {
return Math.round(bearing * MILS_IN_DEGREE) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
}
} else if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.DEGREES360) {
if (bearing < -0.5) {
return (360 + Math.round(bearing)) + AngularConstants.DEGREES360.getUnitSymbol();
} else if (bearing >= -0.5 && bearing < 0) {
return 0 + AngularConstants.DEGREES360.getUnitSymbol();
} else {
return Math.round(bearing) + AngularConstants.DEGREES360.getUnitSymbol();
}
} else {
return azimuth + AngularConstants.DEGREES.getUnitSymbol();
return Math.round(bearing) + AngularConstants.DEGREES.getUnitSymbol();
}
}

View file

@ -2967,6 +2967,7 @@ public class OsmandSettings {
public enum AngularConstants {
DEGREES(R.string.shared_string_degrees, "°"),
DEGREES360(R.string.shared_string_degrees, "°"),
MILLIRADS(R.string.shared_string_milliradians, "mil");
private final int key;

View file

@ -213,7 +213,13 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
AngularConstants[] ac = AngularConstants.values();
entries = new String[ac.length];
for (int i = 0; i < entries.length; i++) {
entries[i] = ac[i].toHumanString(getMyApplication());
if (ac[i] == AngularConstants.DEGREES) {
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 180";
} else if (ac [i] == AngularConstants.DEGREES360) {
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 360";
} else {
entries[i] = ac[i].toHumanString(getMyApplication());
}
}
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);