Add altitude info
This commit is contained in:
parent
60bef86647
commit
2c64a2cafc
8 changed files with 65 additions and 6 deletions
|
@ -1,5 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<resources>
|
||||
<string name="tip_recent_changes_0_6_9_t">Changes in 0.6.9 :
|
||||
\n\t- Improved offline map rendering
|
||||
\n\t- Native speedy offline rendering - look in experimental features (may not work on some devices)
|
||||
\n\t- Massive look and feel changes
|
||||
\n\t- Altitude info
|
||||
\n\t- New translations (Vienamese, Polish)
|
||||
\n\t- Other small features
|
||||
</string>
|
||||
|
||||
<string name="show_altitude_info_descr">Show current altitude information on map</string>
|
||||
<string name="show_altitude_info">Show altitude</string>
|
||||
<string name="use_transparent_map_theme_descr">Use transparent map controls (requires application restart)</string>
|
||||
<string name="use_transparent_map_theme">Transparent theme</string>
|
||||
|
||||
|
|
|
@ -88,7 +88,8 @@
|
|||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen android:key="appearance_settings" android:title="@string/appearance_settings" android:summary="@string/appearance_settings_descr">
|
||||
<CheckBoxPreference android:key="transparent_map_theme" android:title="@string/use_transparent_map_theme" android:summary="@string/use_transparent_map_theme_descr"></CheckBoxPreference>
|
||||
<CheckBoxPreference android:key="transparent_map_theme" android:title="@string/use_transparent_map_theme" android:summary="@string/use_transparent_map_theme_descr"/>
|
||||
<CheckBoxPreference android:key="show_altitude_info" android:title="@string/show_altitude_info" android:summary="@string/show_altitude_info_descr"/>
|
||||
</PreferenceScreen>
|
||||
|
||||
<PreferenceScreen android:key = "osm_settings" android:title="@string/osm_settings" android:summary="@string/osm_settings_descr">
|
||||
|
|
|
@ -81,6 +81,16 @@ public class OsmAndFormatter {
|
|||
return ((int) meters) + " " + ctx.getString(R.string.m); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFormattedAlt(double alt, Context ctx) {
|
||||
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
|
||||
MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
||||
if (mc == MetricsConstants.KILOMETERS_AND_METERS) {
|
||||
return ((int) alt) + " " + ctx.getString(R.string.m);
|
||||
} else {
|
||||
return ((int) (alt * FOOTS_IN_ONE_METER)) + " " + ctx.getString(R.string.foot);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFormattedSpeed(float metersperseconds, Context ctx) {
|
||||
OsmandSettings settings = OsmandSettings.getOsmandSettings(ctx);
|
||||
|
|
|
@ -1050,15 +1050,19 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Boolean> SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME =
|
||||
new BooleanPreference("show_arrival_time", true, true);
|
||||
|
||||
|
||||
// UI boxes
|
||||
public final CommonPreference<Boolean> TRANSPARENT_MAP_THEME =
|
||||
new BooleanPreference("transparent_map_theme", true, true);
|
||||
new BooleanPreference("transparent_map_theme", true, false);
|
||||
{
|
||||
TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.CAR, false);
|
||||
TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.BICYCLE, false);
|
||||
TRANSPARENT_MAP_THEME.setModeDefaultValue(ApplicationMode.PEDESTRIAN, true);
|
||||
}
|
||||
|
||||
public final CommonPreference<Boolean> SHOW_ALTITUDE_INFO =
|
||||
new BooleanPreference("show_altitude_info", false, false);
|
||||
|
||||
public enum DayNightMode {
|
||||
AUTO(R.string.daynight_mode_auto),
|
||||
DAY(R.string.daynight_mode_day),
|
||||
|
|
|
@ -87,8 +87,6 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
|
|||
|
||||
private Map<String, Map<String, ?>> listPrefValues = new LinkedHashMap<String, Map<String, ?>>();
|
||||
|
||||
|
||||
|
||||
private void registerBooleanPreference(OsmandPreference<Boolean> b, PreferenceScreen screen){
|
||||
CheckBoxPreference p = (CheckBoxPreference) screen.findPreference(b.getId());
|
||||
p.setOnPreferenceChangeListener(this);
|
||||
|
|
|
@ -14,7 +14,7 @@ import android.widget.TextView;
|
|||
|
||||
public class TipsAndTricksActivity {
|
||||
private int[][] tipNamesAndDescriptions = new int[][] {
|
||||
{R.string.tip_recent_changes,R.string.tip_recent_changes_0_6_8_t},
|
||||
{R.string.tip_recent_changes,R.string.tip_recent_changes_0_6_9_t},
|
||||
{R.string.tip_rotation_switching,R.string.tip_rotation_switching_t},
|
||||
{R.string.tip_update_index,R.string.tip_update_index_t},
|
||||
{R.string.tip_day_night_mode,R.string.tip_day_night_mode_t},
|
||||
|
|
|
@ -50,7 +50,7 @@ public abstract class MapInfoControl extends View {
|
|||
protected void drawShadowText(Canvas cv, String text, float centerX, float centerY, Paint textPaint) {
|
||||
int c = textPaint.getColor();
|
||||
textPaint.setStyle(Style.STROKE);
|
||||
textPaint.setColor(Color.LTGRAY);
|
||||
textPaint.setColor(Color.WHITE);
|
||||
textPaint.setStrokeWidth(4);
|
||||
cv.drawText(text, centerX, centerY, textPaint);
|
||||
// reset
|
||||
|
|
|
@ -43,6 +43,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
private float cachedRotate = 0;
|
||||
private boolean showArrivalTime = true;
|
||||
private boolean showAltitude = false;
|
||||
private boolean showMiniMap = false;
|
||||
|
||||
// layout pseudo-constants
|
||||
|
@ -120,6 +121,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
leftStack.setExpandImageDrawable(view.getResources().getDrawable(expand).mutate());
|
||||
statusBar.setBackgroundDrawable(view.getResources().getDrawable(boxTop).mutate());
|
||||
showAltitude = view.getSettings().SHOW_ALTITUDE_INFO.get();
|
||||
}
|
||||
|
||||
public void createTopBarElements() {
|
||||
|
@ -129,6 +131,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
rightStack = new MapStackControl(view.getContext());
|
||||
rightStack.addStackView(createDistanceControl());
|
||||
rightStack.addStackView(createAltitudeControl());
|
||||
rightStack.addCollapsedView(createSpeedControl());
|
||||
rightStack.addCollapsedView(createTimeControl());
|
||||
|
||||
|
@ -244,6 +247,38 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
return speedControl;
|
||||
}
|
||||
|
||||
private TextInfoControl createAltitudeControl(){
|
||||
final TextInfoControl altitudeControl = new TextInfoControl(map, 0, paintText, paintSubText) {
|
||||
private int cachedAlt = 0;
|
||||
|
||||
@Override
|
||||
public boolean updateInfo() {
|
||||
// draw speed
|
||||
if (showAltitude &&
|
||||
map.getLastKnownLocation() != null && map.getLastKnownLocation().hasAltitude()) {
|
||||
if (cachedAlt != (int) map.getLastKnownLocation().getAltitude()) {
|
||||
cachedAlt = (int) map.getLastKnownLocation().getAltitude();
|
||||
String ds = OsmAndFormatter.getFormattedAlt(cachedAlt, map);
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setText(ds, null);
|
||||
} else {
|
||||
setText(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (cachedAlt != 0) {
|
||||
cachedAlt = 0;
|
||||
setText(null, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
altitudeControl.setText(null, null);
|
||||
return altitudeControl;
|
||||
}
|
||||
|
||||
private TextInfoControl createTimeControl(){
|
||||
final Drawable time = view.getResources().getDrawable(R.drawable.info_time);
|
||||
final Drawable timeToGo = view.getResources().getDrawable(R.drawable.info_time_to_go);
|
||||
|
|
Loading…
Reference in a new issue