Merge branch 'master' into Voice-prompts
# Conflicts: # OsmAnd/res/values/strings.xml
This commit is contained in:
commit
68dd209120
22 changed files with 214 additions and 120 deletions
|
@ -1,6 +1,10 @@
|
||||||
package net.osmand.router;
|
package net.osmand.router;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||||
|
import net.osmand.GPXUtilities.Track;
|
||||||
|
import net.osmand.GPXUtilities.TrkSegment;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.osm.edit.Node;
|
import net.osmand.osm.edit.Node;
|
||||||
import net.osmand.osm.edit.OsmMapUtils;
|
import net.osmand.osm.edit.OsmMapUtils;
|
||||||
|
@ -30,6 +34,8 @@ public class RouteColorize {
|
||||||
public static final int RED = rgbaToDecimal(243, 55, 77, 255);
|
public static final int RED = rgbaToDecimal(243, 55, 77, 255);
|
||||||
public static final int[] colors = new int[] {GREEN, YELLOW, RED};
|
public static final int[] colors = new int[] {GREEN, YELLOW, RED};
|
||||||
|
|
||||||
|
private static final int MAX_SLOPE_VALUE = 25;
|
||||||
|
|
||||||
public enum ColorizationType {
|
public enum ColorizationType {
|
||||||
ELEVATION,
|
ELEVATION,
|
||||||
SPEED,
|
SPEED,
|
||||||
|
@ -75,7 +81,7 @@ public class RouteColorize {
|
||||||
/**
|
/**
|
||||||
* @param type ELEVATION, SPEED, SLOPE
|
* @param type ELEVATION, SPEED, SLOPE
|
||||||
*/
|
*/
|
||||||
public RouteColorize(int zoom, GPXUtilities.GPXFile gpxFile, ColorizationType type) {
|
public RouteColorize(int zoom, GPXFile gpxFile, GPXTrackAnalysis analysis, ColorizationType type, float maxProfileSpeed) {
|
||||||
|
|
||||||
if (!gpxFile.hasTrkPt()) {
|
if (!gpxFile.hasTrkPt()) {
|
||||||
LOG.warn("GPX file is not consist of track points");
|
LOG.warn("GPX file is not consist of track points");
|
||||||
|
@ -85,21 +91,25 @@ public class RouteColorize {
|
||||||
List<Double> latList = new ArrayList<>();
|
List<Double> latList = new ArrayList<>();
|
||||||
List<Double> lonList = new ArrayList<>();
|
List<Double> lonList = new ArrayList<>();
|
||||||
List<Double> valList = new ArrayList<>();
|
List<Double> valList = new ArrayList<>();
|
||||||
for (GPXUtilities.Track t : gpxFile.tracks) {
|
|
||||||
for (GPXUtilities.TrkSegment ts : t.segments) {
|
int wptIdx = 0;
|
||||||
for (GPXUtilities.WptPt p : ts.points) {
|
for (Track t : gpxFile.tracks) {
|
||||||
|
for (TrkSegment ts : t.segments) {
|
||||||
|
for (WptPt p : ts.points) {
|
||||||
latList.add(p.lat);
|
latList.add(p.lat);
|
||||||
lonList.add(p.lon);
|
lonList.add(p.lon);
|
||||||
if (type == ColorizationType.SPEED) {
|
if (type == ColorizationType.SPEED) {
|
||||||
valList.add(p.speed);
|
valList.add((double) analysis.speedData.get(wptIdx).speed);
|
||||||
} else {
|
} else {
|
||||||
valList.add(p.ele);
|
valList.add((double) analysis.elevationData.get(wptIdx).elevation);
|
||||||
}
|
}
|
||||||
|
wptIdx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.zoom = zoom;
|
this.zoom = zoom;
|
||||||
|
colorizationType = type;
|
||||||
latitudes = listToArray(latList);
|
latitudes = listToArray(latList);
|
||||||
longitudes = listToArray(lonList);
|
longitudes = listToArray(lonList);
|
||||||
|
|
||||||
|
@ -108,9 +118,8 @@ public class RouteColorize {
|
||||||
} else {
|
} else {
|
||||||
values = listToArray(valList);
|
values = listToArray(valList);
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateMinMaxValue();
|
calculateMinMaxValue();
|
||||||
colorizationType = type;
|
maxValue = getMaxValue(colorizationType, analysis, minValue, maxProfileSpeed);
|
||||||
checkPalette();
|
checkPalette();
|
||||||
sortPalette();
|
sortPalette();
|
||||||
}
|
}
|
||||||
|
@ -194,7 +203,7 @@ public class RouteColorize {
|
||||||
return rgbaToDecimal((int) resultRed, (int) resultGreen, (int) resultBlue, (int) resultAlpha);
|
return rgbaToDecimal((int) resultRed, (int) resultGreen, (int) resultBlue, (int) resultAlpha);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getDefaultColor();
|
return getTransparentColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPalette(double[][] palette) {
|
public void setPalette(double[][] palette) {
|
||||||
|
@ -209,12 +218,12 @@ public class RouteColorize {
|
||||||
}
|
}
|
||||||
setPalette(new double[][] {
|
setPalette(new double[][] {
|
||||||
{minValue, gradientPalette[0]},
|
{minValue, gradientPalette[0]},
|
||||||
{colorizationType == ColorizationType.SLOPE ? 0 : (minValue + maxValue) / 2, gradientPalette[1]},
|
{(minValue + maxValue) / 2, gradientPalette[1]},
|
||||||
{maxValue, gradientPalette[2]}
|
{maxValue, gradientPalette[2]}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDefaultColor() {
|
private int getTransparentColor() {
|
||||||
return rgbaToDecimal(0, 0, 0, 0);
|
return rgbaToDecimal(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +304,7 @@ public class RouteColorize {
|
||||||
|
|
||||||
double[][] defaultPalette = {
|
double[][] defaultPalette = {
|
||||||
{minValue, GREEN},
|
{minValue, GREEN},
|
||||||
{colorizationType == ColorizationType.SLOPE ? 0 : (minValue + maxValue) / 2, YELLOW},
|
{(minValue + maxValue) / 2, YELLOW},
|
||||||
{maxValue, RED}
|
{maxValue, RED}
|
||||||
};
|
};
|
||||||
palette = defaultPalette;
|
palette = defaultPalette;
|
||||||
|
@ -397,6 +406,20 @@ public class RouteColorize {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getMinValue(ColorizationType type, GPXTrackAnalysis analysis) {
|
||||||
|
return type == ColorizationType.ELEVATION ? analysis.minElevation : 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getMaxValue(ColorizationType type, GPXTrackAnalysis analysis, double minValue, double maxProfileSpeed) {
|
||||||
|
if (type == ColorizationType.SPEED) {
|
||||||
|
return Math.max(analysis.maxSpeed, maxProfileSpeed);
|
||||||
|
} else if (type == ColorizationType.ELEVATION) {
|
||||||
|
return Math.max(analysis.maxElevation, minValue + 50);
|
||||||
|
} else {
|
||||||
|
return MAX_SLOPE_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void calculateMinMaxValue() {
|
private void calculateMinMaxValue() {
|
||||||
if (values.length == 0)
|
if (values.length == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -457,5 +480,4 @@ public class RouteColorize {
|
||||||
this.val = val;
|
this.val = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -88,7 +88,6 @@
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/card_and_list_background_basic"
|
|
||||||
android:minHeight="@dimen/toolbar_height"
|
android:minHeight="@dimen/toolbar_height"
|
||||||
android:padding="0dp"
|
android:padding="0dp"
|
||||||
osmand:contentInsetEnd="0dp"
|
osmand:contentInsetEnd="0dp"
|
||||||
|
|
|
@ -144,6 +144,7 @@
|
||||||
<string name="poi_diplomatic_services_non_immigrant_visas_filter">Non-immigrant visas</string>
|
<string name="poi_diplomatic_services_non_immigrant_visas_filter">Non-immigrant visas</string>
|
||||||
<string name="poi_diplomatic_services_immigrant_visas_filter">Immigrant visas</string>
|
<string name="poi_diplomatic_services_immigrant_visas_filter">Immigrant visas</string>
|
||||||
<string name="poi_diplomatic_services_citizen_services_filter">Citizen services</string>
|
<string name="poi_diplomatic_services_citizen_services_filter">Citizen services</string>
|
||||||
|
<string name="poi_bay_filter">Bay type</string>
|
||||||
|
|
||||||
<!-- categories -->
|
<!-- categories -->
|
||||||
<string name="poi_shop">Store</string>
|
<string name="poi_shop">Store</string>
|
||||||
|
@ -284,7 +285,6 @@
|
||||||
<string name="poi_ship_chandler">Ship chandler</string>
|
<string name="poi_ship_chandler">Ship chandler</string>
|
||||||
<string name="poi_sports">Sporting goods</string>
|
<string name="poi_sports">Sporting goods</string>
|
||||||
<string name="poi_stationery">Stationery store</string>
|
<string name="poi_stationery">Stationery store</string>
|
||||||
<string name="poi_tableware">Tableware store</string>
|
|
||||||
<string name="poi_ticket">Ticket sales</string>
|
<string name="poi_ticket">Ticket sales</string>
|
||||||
<string name="poi_tobacco">Tobacco store</string>
|
<string name="poi_tobacco">Tobacco store</string>
|
||||||
<string name="poi_toys">Toyshop</string>
|
<string name="poi_toys">Toyshop</string>
|
||||||
|
@ -4379,4 +4379,6 @@
|
||||||
<string name="poi_horseshoes">Horseshoes</string>
|
<string name="poi_horseshoes">Horseshoes</string>
|
||||||
<string name="poi_kickboxing">Kickboxing</string>
|
<string name="poi_kickboxing">Kickboxing</string>
|
||||||
|
|
||||||
|
<string name="poi_office_diplomatic">Diplomatic office</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<string name="map_quick_action_pattern">%1$s → …</string>
|
||||||
<string name="output">Output</string>
|
<string name="output">Output</string>
|
||||||
<string name="user_points">User points</string>
|
<string name="user_points">User points</string>
|
||||||
<string name="announce_when_exceeded">Announce when exceeded</string>
|
<string name="announce_when_exceeded">Announce when exceeded</string>
|
||||||
|
@ -33,7 +34,7 @@
|
||||||
<string name="monthly_subscription">Monthly subscription</string>
|
<string name="monthly_subscription">Monthly subscription</string>
|
||||||
<string name="annual_subscription">Annual subscription</string>
|
<string name="annual_subscription">Annual subscription</string>
|
||||||
<string name="osmand_live">OsmAnd Live</string>
|
<string name="osmand_live">OsmAnd Live</string>
|
||||||
<string name="troubleshooting_description">Please follow this link if you any issues with purchases.</string>
|
<string name="troubleshooting_description">Please follow this link if you have any issues with purchases.</string>
|
||||||
<string name="troubleshooting">Troubleshooting</string>
|
<string name="troubleshooting">Troubleshooting</string>
|
||||||
<string name="contact_support">Contact support</string>
|
<string name="contact_support">Contact support</string>
|
||||||
<string name="empty_purchases_description">If your purchases don\'t show up here, tap on “%1$s”, or contact our support team.</string>
|
<string name="empty_purchases_description">If your purchases don\'t show up here, tap on “%1$s”, or contact our support team.</string>
|
||||||
|
|
|
@ -92,6 +92,8 @@ public class MapActivityKeyListener implements KeyEvent.Callback {
|
||||||
return true;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_C) {
|
} else if (keyCode == KeyEvent.KEYCODE_C) {
|
||||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||||
|
} else if (keyCode == KeyEvent.KEYCODE_D) {
|
||||||
|
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||||
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) {
|
} else if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) {
|
||||||
// Parrot device has only dpad left and right
|
// Parrot device has only dpad left and right
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
|
||||||
|
|
|
@ -39,6 +39,8 @@ import java.util.Map;
|
||||||
|
|
||||||
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
|
public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener,
|
||||||
OsmAndCompassListener, MapMarkerChangedListener {
|
OsmAndCompassListener, MapMarkerChangedListener {
|
||||||
|
|
||||||
|
private static final int COMPASS_REQUEST_TIME_INTERVAL_MS = 5000;
|
||||||
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4;
|
||||||
|
|
||||||
private long lastTimeAutoZooming = 0;
|
private long lastTimeAutoZooming = 0;
|
||||||
|
@ -59,6 +61,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
private Float heading;
|
private Float heading;
|
||||||
private boolean drivingRegionUpdated = false;
|
private boolean drivingRegionUpdated = false;
|
||||||
private boolean movingToMyLocation = false;
|
private boolean movingToMyLocation = false;
|
||||||
|
private long compassRequest;
|
||||||
|
|
||||||
public MapViewTrackingUtilities(OsmandApplication app){
|
public MapViewTrackingUtilities(OsmandApplication app){
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
@ -424,7 +427,22 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
setMapLinkedToLocation(false);
|
setMapLinkedToLocation(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void switchRotateMapMode(){
|
public void switchRotateMapMode() {
|
||||||
|
if (app.getRoutingHelper().isFollowingMode()) {
|
||||||
|
if (compassRequest + COMPASS_REQUEST_TIME_INTERVAL_MS > System.currentTimeMillis()) {
|
||||||
|
compassRequest = 0;
|
||||||
|
switchRotateMapModeImpl();
|
||||||
|
} else {
|
||||||
|
compassRequest = System.currentTimeMillis();
|
||||||
|
app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
compassRequest = 0;
|
||||||
|
switchRotateMapModeImpl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void switchRotateMapModeImpl(){
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
String rotMode = app.getString(R.string.rotate_map_none_opt);
|
String rotMode = app.getString(R.string.rotate_map_none_opt);
|
||||||
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE && mapView.getRotate() != 0) {
|
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE && mapView.getRotate() != 0) {
|
||||||
|
|
|
@ -611,7 +611,7 @@ public class GpxUiHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
updateSelectedTracksAppearance(app, fileNames);
|
updateSelectedTracksAppearance(app, fileNames, gpxAppearanceParams);
|
||||||
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
|
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX,
|
||||||
fileNames.toArray(new String[0]));
|
fileNames.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
@ -718,13 +718,7 @@ public class GpxUiHelper {
|
||||||
return dlg;
|
return dlg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateSelectedTracksAppearance(OsmandApplication app, List<String> fileNames) {
|
private static void updateSelectedTracksAppearance(final OsmandApplication app, List<String> fileNames, final Map<String, String> params) {
|
||||||
final GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
|
|
||||||
final boolean showStartFinish = app.getSettings().SHOW_START_FINISH_ICONS.get();
|
|
||||||
final String savedWidth = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).get();
|
|
||||||
String savedColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).get();
|
|
||||||
final int color = GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), savedColor);
|
|
||||||
|
|
||||||
GpxDataItemCallback callback = new GpxDataItemCallback() {
|
GpxDataItemCallback callback = new GpxDataItemCallback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
|
@ -733,21 +727,34 @@ public class GpxUiHelper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGpxDataItemReady(GpxDataItem item) {
|
public void onGpxDataItemReady(GpxDataItem item) {
|
||||||
updateTrackAppearance(gpxDbHelper, item, savedWidth, color, showStartFinish);
|
updateTrackAppearance(app, item, params);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
|
||||||
for (String name : fileNames) {
|
for (String name : fileNames) {
|
||||||
GpxDataItem item = gpxDbHelper.getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), name), callback);
|
GpxDataItem item = gpxDbHelper.getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), name), callback);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
updateTrackAppearance(gpxDbHelper, item, savedWidth, color, showStartFinish);
|
updateTrackAppearance(app, item, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateTrackAppearance(GpxDbHelper gpxDbHelper, GpxDataItem item, String width, int color, boolean showStartFinish) {
|
private static void updateTrackAppearance(OsmandApplication app, GpxDataItem item, Map<String, String> params) {
|
||||||
gpxDbHelper.updateColor(item, color);
|
OsmandSettings settings = app.getSettings();
|
||||||
gpxDbHelper.updateWidth(item, width);
|
GpxDbHelper gpxDbHelper = app.getGpxDbHelper();
|
||||||
gpxDbHelper.updateShowStartFinish(item, showStartFinish);
|
if (params.containsKey(CURRENT_TRACK_COLOR_ATTR)) {
|
||||||
|
String savedColor = settings.getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR).get();
|
||||||
|
int color = GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), savedColor);
|
||||||
|
gpxDbHelper.updateColor(item, color);
|
||||||
|
}
|
||||||
|
if (params.containsKey(CURRENT_TRACK_WIDTH_ATTR)) {
|
||||||
|
String width = settings.getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR).get();
|
||||||
|
gpxDbHelper.updateWidth(item, width);
|
||||||
|
}
|
||||||
|
if (params.containsKey(SHOW_START_FINISH_ATTR)) {
|
||||||
|
boolean showStartFinish = settings.SHOW_START_FINISH_ICONS.get();
|
||||||
|
gpxDbHelper.updateShowStartFinish(item, showStartFinish);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateGpxInfoView(final @NonNull OsmandApplication app,
|
public static void updateGpxInfoView(final @NonNull OsmandApplication app,
|
||||||
|
|
|
@ -245,4 +245,11 @@ public class MapStyleAction extends SwitchableAction<String> {
|
||||||
? filters.get(0) + " +" + (filters.size() - 1)
|
? filters.get(0) + " +" + (filters.size() - 1)
|
||||||
: filters.get(0);
|
: filters.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActionText(OsmandApplication application) {
|
||||||
|
String currentSource = application.getSettings().RENDERER.get();
|
||||||
|
|
||||||
|
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -104,8 +104,8 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
final String currentSource = settings.MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
|
String currentSource = settings.MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
|
||||||
: settings.MAP_OVERLAY.get();
|
: settings.MAP_OVERLAY.get();
|
||||||
|
|
||||||
for (int idx = 0; idx < sources.size(); idx++) {
|
for (int idx = 0; idx < sources.size(); idx++) {
|
||||||
if (sources.get(idx).first.equals(currentSource)) {
|
if (sources.get(idx).first.equals(currentSource)) {
|
||||||
|
@ -224,4 +224,12 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return super.fillParams(root, activity);
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActionText(OsmandApplication application) {
|
||||||
|
String currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
|
||||||
|
: application.getSettings().MAP_OVERLAY.get();
|
||||||
|
|
||||||
|
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
|
||||||
OsmandSettings settings = activity.getMyApplication().getSettings();
|
OsmandSettings settings = activity.getMyApplication().getSettings();
|
||||||
List<Pair<String, String>> sources = loadListFromParams();
|
List<Pair<String, String>> sources = loadListFromParams();
|
||||||
if (sources.size() > 0) {
|
if (sources.size() > 0) {
|
||||||
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
|
boolean showBottomSheetStyles = Boolean.parseBoolean(getParams().get(KEY_DIALOG));
|
||||||
if (showBottomSheetStyles) {
|
if (showBottomSheetStyles) {
|
||||||
showChooseDialog(activity.getSupportFragmentManager());
|
showChooseDialog(activity.getSupportFragmentManager());
|
||||||
return;
|
return;
|
||||||
|
@ -214,4 +214,13 @@ public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return super.fillParams(root, activity);
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActionText(OsmandApplication application) {
|
||||||
|
String currentSource = application.getSettings().MAP_ONLINE_DATA.get()
|
||||||
|
? application.getSettings().MAP_TILE_SOURCES.get()
|
||||||
|
: application.getString(R.string.vector_data);
|
||||||
|
|
||||||
|
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,4 +226,12 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
|
||||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||||
return super.fillParams(root, activity);
|
return super.fillParams(root, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getActionText(OsmandApplication application) {
|
||||||
|
String currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
|
||||||
|
: application.getSettings().MAP_UNDERLAY.get();
|
||||||
|
|
||||||
|
return application.getString(R.string.map_quick_action_pattern, getTranslatedItemName(application, currentSource));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
||||||
public class RouteLineWidthCard extends BaseCard {
|
public class RouteLineWidthCard extends BaseCard {
|
||||||
|
|
||||||
private final static int CUSTOM_WIDTH_MIN = 1;
|
private final static int CUSTOM_WIDTH_MIN = 1;
|
||||||
private final static int CUSTOM_WIDTH_MAX = 24;
|
private final static int CUSTOM_WIDTH_MAX = 36;
|
||||||
|
|
||||||
private RouteLineDrawInfo routeLineDrawInfo;
|
private RouteLineDrawInfo routeLineDrawInfo;
|
||||||
private OnNeedScrollListener onNeedScrollListener;
|
private OnNeedScrollListener onNeedScrollListener;
|
||||||
|
|
|
@ -43,7 +43,8 @@ public class OsmAndPreferencesDataStore extends PreferenceDataStore {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putBoolean(String key, boolean value) {
|
public void putBoolean(String key, boolean value) {
|
||||||
if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(key)) {
|
if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(key)
|
||||||
|
|| osmandSettings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(key)) {
|
||||||
osmandSettings.setPreference(key, !value, appMode);
|
osmandSettings.setPreference(key, !value, appMode);
|
||||||
} else {
|
} else {
|
||||||
osmandSettings.setPreference(key, value, appMode);
|
osmandSettings.setPreference(key, value, appMode);
|
||||||
|
@ -107,7 +108,8 @@ public class OsmAndPreferencesDataStore extends PreferenceDataStore {
|
||||||
OsmandPreference<?> preference = osmandSettings.getPreference(key);
|
OsmandPreference<?> preference = osmandSettings.getPreference(key);
|
||||||
if (preference instanceof BooleanPreference) {
|
if (preference instanceof BooleanPreference) {
|
||||||
BooleanPreference booleanPreference = (BooleanPreference) preference;
|
BooleanPreference booleanPreference = (BooleanPreference) preference;
|
||||||
if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(booleanPreference.getId())) {
|
if (osmandSettings.DISABLE_COMPLEX_ROUTING.getId().equals(booleanPreference.getId())
|
||||||
|
|| osmandSettings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(booleanPreference.getId())) {
|
||||||
return !booleanPreference.getModeValue(appMode);
|
return !booleanPreference.getModeValue(appMode);
|
||||||
}
|
}
|
||||||
return booleanPreference.getModeValue(appMode);
|
return booleanPreference.getModeValue(appMode);
|
||||||
|
|
|
@ -853,7 +853,7 @@ public class OsmandSettings {
|
||||||
public boolean setValue(Object prefs, DrivingRegion val) {
|
public boolean setValue(Object prefs, DrivingRegion val) {
|
||||||
boolean overrideMetricSystem = !DRIVING_REGION_AUTOMATIC.getValue(prefs, DRIVING_REGION_AUTOMATIC.getDefaultValue());
|
boolean overrideMetricSystem = !DRIVING_REGION_AUTOMATIC.getValue(prefs, DRIVING_REGION_AUTOMATIC.getDefaultValue());
|
||||||
if (overrideMetricSystem && val != null) {
|
if (overrideMetricSystem && val != null) {
|
||||||
METRIC_SYSTEM.set(val.defMetrics);
|
METRIC_SYSTEM.setValue(prefs, val.defMetrics);
|
||||||
}
|
}
|
||||||
return super.setValue(prefs, val);
|
return super.setValue(prefs, val);
|
||||||
}
|
}
|
||||||
|
@ -866,7 +866,7 @@ public class OsmandSettings {
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
// cache of metrics constants as they are used very often
|
// cache of metrics constants as they are used very often
|
||||||
public final OsmandPreference<MetricsConstants> METRIC_SYSTEM = new EnumStringPreference<MetricsConstants>(this,
|
public final EnumStringPreference<MetricsConstants> METRIC_SYSTEM = (EnumStringPreference<MetricsConstants>) new EnumStringPreference<MetricsConstants>(this,
|
||||||
"default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()) {
|
"default_metric_system", MetricsConstants.KILOMETERS_AND_METERS, MetricsConstants.values()) {
|
||||||
protected MetricsConstants getDefaultValue() {
|
protected MetricsConstants getDefaultValue() {
|
||||||
return DRIVING_REGION.get().defMetrics;
|
return DRIVING_REGION.get().defMetrics;
|
||||||
|
|
|
@ -234,7 +234,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
|
||||||
ivIcon.setImageDrawable(icon);
|
ivIcon.setImageDrawable(icon);
|
||||||
|
|
||||||
if (currentKey.equals(MANUALLY_SPECIFIED)) {
|
if (currentKey.equals(MANUALLY_SPECIFIED)) {
|
||||||
tvSummary.setText(item.getDirectory());
|
setFormattedPath(item, tvSummary);
|
||||||
secondPart.setVisibility(View.GONE);
|
secondPart.setVisibility(View.GONE);
|
||||||
tvAdditionalDescription.setVisibility(View.GONE);
|
tvAdditionalDescription.setVisibility(View.GONE);
|
||||||
divider.setVisibility(View.GONE);
|
divider.setVisibility(View.GONE);
|
||||||
|
@ -252,15 +252,8 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
|
||||||
}
|
}
|
||||||
if (currentKey.equals(INTERNAL_STORAGE)) {
|
if (currentKey.equals(INTERNAL_STORAGE)) {
|
||||||
tvAdditionalDescription.setText(item.getDescription());
|
tvAdditionalDescription.setText(item.getDescription());
|
||||||
} else if (currentKey.equals(SHARED_STORAGE)) {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
|
||||||
BidiFormatter rtlFormatter = BidiFormatter.getInstance();
|
|
||||||
tvAdditionalDescription.setText(rtlFormatter.unicodeWrap(item.getDirectory()));
|
|
||||||
} else {
|
|
||||||
tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory()));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
tvAdditionalDescription.setText(item.getDirectory());
|
setFormattedPath(item, tvAdditionalDescription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,6 +303,15 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setFormattedPath(StorageItem item, TextView tvAdditionalDescription) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
|
BidiFormatter pathRtlFormatter = BidiFormatter.getInstance();
|
||||||
|
tvAdditionalDescription.setText(pathRtlFormatter.unicodeWrap(item.getDirectory()));
|
||||||
|
} else {
|
||||||
|
tvAdditionalDescription.setText(String.format("\u200E%s", item.getDirectory()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
if (!activity.isChangingConfigurations()) {
|
if (!activity.isChangingConfigurations()) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.ScrollView;
|
||||||
import androidx.activity.OnBackPressedCallback;
|
import androidx.activity.OnBackPressedCallback;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
|
@ -32,7 +33,6 @@ import net.osmand.plus.routing.cards.RouteLineColorCard;
|
||||||
import net.osmand.plus.routing.cards.RouteLineColorCard.OnMapThemeUpdateListener;
|
import net.osmand.plus.routing.cards.RouteLineColorCard.OnMapThemeUpdateListener;
|
||||||
import net.osmand.plus.routing.cards.RouteLineColorCard.OnSelectedColorChangeListener;
|
import net.osmand.plus.routing.cards.RouteLineColorCard.OnSelectedColorChangeListener;
|
||||||
import net.osmand.plus.routing.cards.RouteLineWidthCard;
|
import net.osmand.plus.routing.cards.RouteLineWidthCard;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
|
||||||
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener;
|
||||||
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
|
import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener;
|
||||||
|
|
||||||
|
@ -203,6 +203,8 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
closeButton.setImageResource(AndroidUtils.getNavigationIconResId(toolbarContainer.getContext()));
|
closeButton.setImageResource(AndroidUtils.getNavigationIconResId(toolbarContainer.getContext()));
|
||||||
|
int bgColorId = isNightMode() ? R.color.app_bar_color_dark : R.color.list_background_color_light;
|
||||||
|
toolbarContainer.setBackgroundColor(ContextCompat.getColor(requireContext(), bgColorId));
|
||||||
updateToolbarVisibility(toolbarContainer);
|
updateToolbarVisibility(toolbarContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +214,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple
|
||||||
if (Build.VERSION.SDK_INT >= 23 && !isNightMode() && view != null) {
|
if (Build.VERSION.SDK_INT >= 23 && !isNightMode() && view != null) {
|
||||||
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||||
}
|
}
|
||||||
return isNightMode() ? R.color.divider_color_dark : R.color.divider_color_light;
|
return isNightMode() ? R.color.status_bar_color_dark : R.color.divider_color_light;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -31,9 +31,8 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.routing.RouteService;
|
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
import net.osmand.plus.routing.RouteProvider;
|
import net.osmand.plus.routing.RouteService;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.BooleanPreference;
|
import net.osmand.plus.settings.backend.BooleanPreference;
|
||||||
|
@ -357,15 +356,14 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupReverseDirectionRecalculation(PreferenceScreen screen) {
|
private void setupReverseDirectionRecalculation(PreferenceScreen screen) {
|
||||||
SwitchPreferenceEx recalcRouteReverseDirectionPreference =
|
OsmandPreference<Boolean> preference = settings.DISABLE_WRONG_DIRECTION_RECALC;
|
||||||
createSwitchPreferenceEx(settings.DISABLE_WRONG_DIRECTION_RECALC.getId(),
|
SwitchPreferenceEx switchPreference = createSwitchPreferenceEx(preference.getId(),
|
||||||
R.string.in_case_of_reverse_direction,
|
R.string.in_case_of_reverse_direction,
|
||||||
R.layout.preference_with_descr_dialog_and_switch);
|
R.layout.preference_with_descr_dialog_and_switch);
|
||||||
recalcRouteReverseDirectionPreference.setIcon(
|
switchPreference.setIcon(getRoutingPrefIcon(preference.getId()));
|
||||||
getRoutingPrefIcon(settings.DISABLE_WRONG_DIRECTION_RECALC.getId()));
|
switchPreference.setSummaryOn(R.string.shared_string_enabled);
|
||||||
recalcRouteReverseDirectionPreference.setSummaryOn(R.string.shared_string_enabled);
|
switchPreference.setSummaryOff(R.string.shared_string_disabled);
|
||||||
recalcRouteReverseDirectionPreference.setSummaryOff(R.string.shared_string_disabled);
|
screen.addPreference(switchPreference);
|
||||||
screen.addPreference(recalcRouteReverseDirectionPreference);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupRouteRecalcHeader(PreferenceScreen screen) {
|
private void setupRouteRecalcHeader(PreferenceScreen screen) {
|
||||||
|
@ -546,7 +544,9 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||||
if (settings.DISABLE_COMPLEX_ROUTING.getId().equals(preference.getKey()) && newValue instanceof Boolean) {
|
if ((settings.DISABLE_COMPLEX_ROUTING.getId().equals(preference.getKey()) ||
|
||||||
|
settings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(preference.getKey())) &&
|
||||||
|
newValue instanceof Boolean) {
|
||||||
return onConfirmPreferenceChange(preference.getKey(), !(Boolean) newValue, getApplyQueryType()); // pref ui was inverted
|
return onConfirmPreferenceChange(preference.getKey(), !(Boolean) newValue, getApplyQueryType()); // pref ui was inverted
|
||||||
}
|
}
|
||||||
return onConfirmPreferenceChange(preference.getKey(), newValue, getApplyQueryType());
|
return onConfirmPreferenceChange(preference.getKey(), newValue, getApplyQueryType());
|
||||||
|
@ -573,8 +573,6 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
||||||
applyPreference(ROUTING_RECALC_DISTANCE, applyToAllProfiles, valueToSave);
|
applyPreference(ROUTING_RECALC_DISTANCE, applyToAllProfiles, valueToSave);
|
||||||
applyPreference(settings.DISABLE_OFFROUTE_RECALC.getId(), applyToAllProfiles, !enabled);
|
applyPreference(settings.DISABLE_OFFROUTE_RECALC.getId(), applyToAllProfiles, !enabled);
|
||||||
updateRouteRecalcDistancePref();
|
updateRouteRecalcDistancePref();
|
||||||
} else if (settings.DISABLE_WRONG_DIRECTION_RECALC.getId().equals(prefId)) {
|
|
||||||
applyPreference(settings.DISABLE_WRONG_DIRECTION_RECALC.getId(), applyToAllProfiles, newValue);
|
|
||||||
} else {
|
} else {
|
||||||
super.onApplyPreferenceChange(prefId, applyToAllProfiles, newValue);
|
super.onApplyPreferenceChange(prefId, applyToAllProfiles, newValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import android.widget.TextView;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
|
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
|
||||||
import com.google.android.material.slider.RangeSlider;
|
import com.google.android.material.slider.RangeSlider;
|
||||||
|
@ -50,14 +49,16 @@ import org.apache.commons.logging.Log;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.*;
|
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.END;
|
||||||
|
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.START;
|
||||||
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.HILLSHADE_FILE;
|
||||||
import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE;
|
import static net.osmand.plus.download.DownloadActivityType.SLOPE_FILE;
|
||||||
import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE;
|
|
||||||
import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE;
|
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MAX_ZOOM;
|
||||||
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM;
|
import static net.osmand.plus.srtmplugin.SRTMPlugin.TERRAIN_MIN_ZOOM;
|
||||||
|
import static net.osmand.plus.srtmplugin.TerrainMode.HILLSHADE;
|
||||||
|
import static net.osmand.plus.srtmplugin.TerrainMode.SLOPE;
|
||||||
|
|
||||||
|
|
||||||
public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener,
|
public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickListener,
|
||||||
|
@ -102,7 +103,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
|
|
||||||
private ArrayAdapter<ContextMenuItem> listAdapter;
|
private ArrayAdapter<ContextMenuItem> listAdapter;
|
||||||
|
|
||||||
private Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() {
|
private final Slider.OnChangeListener transparencySliderChangeListener = new Slider.OnChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||||
if (fromUser) {
|
if (fromUser) {
|
||||||
|
@ -114,7 +115,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() {
|
private final RangeSlider.OnChangeListener zoomSliderChangeListener = new RangeSlider.OnChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) {
|
public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) {
|
||||||
List<Float> values = slider.getValues();
|
List<Float> values = slider.getValues();
|
||||||
|
@ -186,11 +187,7 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
getString(R.string.slope_read_more),
|
getString(R.string.slope_read_more),
|
||||||
wikiString
|
wikiString
|
||||||
);
|
);
|
||||||
String emptyStateText = String.format(
|
String emptyStateText = getString(R.string.terrain_empty_state_text) + "\n" + PLUGIN_URL;
|
||||||
getString(R.string.ltr_or_rtl_combine_via_space),
|
|
||||||
getString(R.string.terrain_empty_state_text),
|
|
||||||
PLUGIN_URL
|
|
||||||
);
|
|
||||||
setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL, false);
|
setupClickableText(slopeReadMoreTv, readMoreText, wikiString, SLOPES_WIKI_URL, false);
|
||||||
setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL, true);
|
setupClickableText(emptyStateDescriptionTv, emptyStateText, PLUGIN_URL, PLUGIN_URL, true);
|
||||||
|
|
||||||
|
@ -290,10 +287,10 @@ public class TerrainFragment extends BaseOsmAndFragment implements View.OnClickL
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupClickableText(TextView textView,
|
private void setupClickableText(TextView textView,
|
||||||
String text,
|
String text,
|
||||||
String clickableText,
|
String clickableText,
|
||||||
final String url,
|
final String url,
|
||||||
final boolean medium) {
|
final boolean medium) {
|
||||||
SpannableString spannableString = new SpannableString(text);
|
SpannableString spannableString = new SpannableString(text);
|
||||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
|
import net.osmand.router.RouteColorize;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -42,8 +43,9 @@ public class GradientCard extends BaseCard {
|
||||||
AndroidUiHelper.updateVisibility(view, true);
|
AndroidUiHelper.updateVisibility(view, true);
|
||||||
TextView minValue = view.findViewById(R.id.min_value);
|
TextView minValue = view.findViewById(R.id.min_value);
|
||||||
TextView maxValue = view.findViewById(R.id.max_value);
|
TextView maxValue = view.findViewById(R.id.max_value);
|
||||||
float min = getMinValue();
|
double min = RouteColorize.getMinValue(selectedScaleType.toColorizationType(), gpxTrackAnalysis);
|
||||||
float max = getMaxValue(min);
|
double max = RouteColorize.getMaxValue(selectedScaleType.toColorizationType(),
|
||||||
|
gpxTrackAnalysis, min, app.getSettings().getApplicationMode().getMaxSpeed());
|
||||||
minValue.setText(formatValue(min));
|
minValue.setText(formatValue(min));
|
||||||
maxValue.setText(formatValue(max));
|
maxValue.setText(formatValue(max));
|
||||||
}
|
}
|
||||||
|
@ -53,27 +55,13 @@ public class GradientCard extends BaseCard {
|
||||||
updateContent();
|
updateContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getMinValue() {
|
private CharSequence formatValue(double value) {
|
||||||
return (float) (selectedScaleType == GradientScaleType.ALTITUDE ? gpxTrackAnalysis.minElevation : 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getMaxValue(float minValue) {
|
|
||||||
if (selectedScaleType == GradientScaleType.SPEED) {
|
|
||||||
return (Math.max(gpxTrackAnalysis.maxSpeed, app.getSettings().getApplicationMode().getMaxSpeed()));
|
|
||||||
} else if (selectedScaleType == GradientScaleType.ALTITUDE) {
|
|
||||||
return (float) Math.max(gpxTrackAnalysis.maxElevation, minValue + 50);
|
|
||||||
} else {
|
|
||||||
return 25;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private CharSequence formatValue(float value) {
|
|
||||||
if (selectedScaleType == GradientScaleType.ALTITUDE) {
|
if (selectedScaleType == GradientScaleType.ALTITUDE) {
|
||||||
return OsmAndFormatter.getFormattedAlt(value, app);
|
return OsmAndFormatter.getFormattedAlt(value, app);
|
||||||
} else if (selectedScaleType == GradientScaleType.SLOPE) {
|
} else if (selectedScaleType == GradientScaleType.SLOPE) {
|
||||||
return (int) value + " %";
|
return (int) value + " %";
|
||||||
}
|
}
|
||||||
String speed = OsmAndFormatter.getFormattedSpeed(value, app);
|
String speed = OsmAndFormatter.getFormattedSpeed((float) value, app);
|
||||||
String speedUnit = app.getSettings().SPEED_SYSTEM.get().toShortString(app);
|
String speedUnit = app.getSettings().SPEED_SYSTEM.get().toShortString(app);
|
||||||
Spannable formattedSpeed = new SpannableString(speed);
|
Spannable formattedSpeed = new SpannableString(speed);
|
||||||
formattedSpeed.setSpan(
|
formattedSpeed.setSpan(
|
||||||
|
|
|
@ -61,6 +61,7 @@ public class Renderable {
|
||||||
|
|
||||||
public List<WptPt> points = null; // Original list of points
|
public List<WptPt> points = null; // Original list of points
|
||||||
protected List<WptPt> culled = new ArrayList<>(); // Reduced/resampled list of points
|
protected List<WptPt> culled = new ArrayList<>(); // Reduced/resampled list of points
|
||||||
|
protected List<WptPt> oldCulled = new ArrayList<>();
|
||||||
protected int pointSize;
|
protected int pointSize;
|
||||||
protected double segmentSize;
|
protected double segmentSize;
|
||||||
|
|
||||||
|
@ -116,7 +117,7 @@ public class Renderable {
|
||||||
updateLocalPaint(p);
|
updateLocalPaint(p);
|
||||||
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
|
||||||
if (scaleType != null) {
|
if (scaleType != null) {
|
||||||
drawGradient(getPointsForDrawing(), p, canvas, tileBox);
|
drawGradient(getPointsForDrawingWithBorder(), p, canvas, tileBox);
|
||||||
} else {
|
} else {
|
||||||
drawSolid(getPointsForDrawing(), p, canvas, tileBox);
|
drawSolid(getPointsForDrawing(), p, canvas, tileBox);
|
||||||
}
|
}
|
||||||
|
@ -126,6 +127,9 @@ public class Renderable {
|
||||||
|
|
||||||
public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
|
public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
|
||||||
if (QuadRect.trivialOverlap(tileBox.getLatLonBounds(), trackBounds)) { // is visible?
|
if (QuadRect.trivialOverlap(tileBox.getLatLonBounds(), trackBounds)) { // is visible?
|
||||||
|
if (tileBox.getZoomAnimation() > 0 && !Algorithms.isEmpty(culled) && scaleType != null) {
|
||||||
|
oldCulled = new ArrayList<>(culled);
|
||||||
|
}
|
||||||
startCuller(zoom);
|
startCuller(zoom);
|
||||||
drawSingleSegment(zoom, p, canvas, tileBox);
|
drawSingleSegment(zoom, p, canvas, tileBox);
|
||||||
}
|
}
|
||||||
|
@ -139,6 +143,16 @@ public class Renderable {
|
||||||
return culled.isEmpty() ? points : culled;
|
return culled.isEmpty() ? points : culled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<WptPt> getPointsForDrawingWithBorder() {
|
||||||
|
if (!culled.isEmpty()) {
|
||||||
|
return culled;
|
||||||
|
} else if (!oldCulled.isEmpty()) {
|
||||||
|
return oldCulled;
|
||||||
|
} else {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void drawGeometry(Canvas canvas, RotatedTileBox tileBox, QuadRect quadRect, int arrowColor, int trackColor, float trackWidth) {
|
public void drawGeometry(Canvas canvas, RotatedTileBox tileBox, QuadRect quadRect, int arrowColor, int trackColor, float trackWidth) {
|
||||||
if (geometryWay != null) {
|
if (geometryWay != null) {
|
||||||
List<WptPt> points = getPointsForDrawing();
|
List<WptPt> points = getPointsForDrawing();
|
||||||
|
@ -290,7 +304,8 @@ public class Renderable {
|
||||||
super(pt, 0);
|
super(pt, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
|
@Override
|
||||||
|
public void drawSegment(double zoom, Paint p, Canvas canvas, RotatedTileBox tileBox) {
|
||||||
if (points.size() != pointSize) {
|
if (points.size() != pointSize) {
|
||||||
int prevSize = pointSize;
|
int prevSize = pointSize;
|
||||||
pointSize = points.size();
|
pointSize = points.size();
|
||||||
|
|
|
@ -680,15 +680,19 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
|
|
||||||
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas,
|
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas,
|
||||||
RotatedTileBox tileBox, DrawSettings settings) {
|
RotatedTileBox tileBox, DrawSettings settings) {
|
||||||
|
OsmandApplication app = view.getApplication();
|
||||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||||
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
|
||||||
GradientScaleType scaleType = getGradientScaleType(gpxFile);
|
GradientScaleType scaleType = getGradientScaleType(gpxFile);
|
||||||
List<RouteColorize.RouteColorizationPoint> colorsOfPoints = null;
|
List<RouteColorize.RouteColorizationPoint> colorsOfPoints = null;
|
||||||
if (scaleType != null) {
|
|
||||||
RouteColorize colorize = new RouteColorize(view.getZoom(), gpxFile, scaleType.toColorizationType());
|
if (needCalculatePointsColors(segments, scaleType)) {
|
||||||
|
RouteColorize colorize = new RouteColorize(view.getZoom(), gpxFile, selectedGpxFile.getTrackAnalysis(app),
|
||||||
|
scaleType.toColorizationType(), app.getSettings().getApplicationMode().getMaxSpeed());
|
||||||
colorize.setPalette(getColorizationPalette(gpxFile, scaleType));
|
colorize.setPalette(getColorizationPalette(gpxFile, scaleType));
|
||||||
colorsOfPoints = colorize.getResult(false);
|
colorsOfPoints = colorize.getResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int startIdx = 0;
|
int startIdx = 0;
|
||||||
for (TrkSegment ts : segments) {
|
for (TrkSegment ts : segments) {
|
||||||
String width = getTrackWidthName(gpxFile, defaultTrackWidthPref.get());
|
String width = getTrackWidthName(gpxFile, defaultTrackWidthPref.get());
|
||||||
|
@ -716,6 +720,25 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean needCalculatePointsColors(List<TrkSegment> segments, GradientScaleType scaleType) {
|
||||||
|
if (scaleType == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
RouteColorize.ColorizationType colorizationType = scaleType.toColorizationType();
|
||||||
|
for (int segIdx = segments.size() - 1; segIdx >= 0; segIdx--) {
|
||||||
|
List<WptPt> pts = segments.get(segIdx).points;
|
||||||
|
if (!Algorithms.isEmpty(pts)) {
|
||||||
|
for (int wptIdx = pts.size() - 1; wptIdx >= 0; wptIdx--) {
|
||||||
|
WptPt pt = pts.get(wptIdx);
|
||||||
|
if (pt.getColor(colorizationType) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private int setColorsToPoints(TrkSegment segment, List<RouteColorize.RouteColorizationPoint> colors, GradientScaleType scaleType, int startIdx) {
|
private int setColorsToPoints(TrkSegment segment, List<RouteColorize.RouteColorizationPoint> colors, GradientScaleType scaleType, int startIdx) {
|
||||||
int pointsSize = segment.points.size();
|
int pointsSize = segment.points.size();
|
||||||
RouteColorize.RouteColorizationPoint startColor = colors.get(startIdx);
|
RouteColorize.RouteColorizationPoint startColor = colors.get(startIdx);
|
||||||
|
|
|
@ -97,8 +97,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201;
|
private static final int REQUEST_LOCATION_FOR_NAVIGATION_FAB_PERMISSION = 201;
|
||||||
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202;
|
private static final int REQUEST_LOCATION_FOR_ADD_DESTINATION_PERMISSION = 202;
|
||||||
|
|
||||||
private static final int COMPASS_PRESSED_TIME_INTERVAL_MS = 5000;
|
|
||||||
|
|
||||||
public MapHudButton createHudButton(View iv, int resId, String id) {
|
public MapHudButton createHudButton(View iv, int resId, String id) {
|
||||||
MapHudButton mc = new MapHudButton();
|
MapHudButton mc = new MapHudButton();
|
||||||
mc.iv = iv;
|
mc.iv = iv;
|
||||||
|
@ -139,7 +137,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private MapQuickActionLayer mapQuickActionLayer;
|
private MapQuickActionLayer mapQuickActionLayer;
|
||||||
private boolean forceShowCompass;
|
private boolean forceShowCompass;
|
||||||
private LatLon requestedLatLon;
|
private LatLon requestedLatLon;
|
||||||
private long compassPressed;
|
|
||||||
private Set<String> themeInfoProviderTags = new HashSet<>();
|
private Set<String> themeInfoProviderTags = new HashSet<>();
|
||||||
|
|
||||||
public MapControlsLayer(MapActivity activity) {
|
public MapControlsLayer(MapActivity activity) {
|
||||||
|
@ -292,20 +289,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
compass.setOnClickListener(new View.OnClickListener() {
|
compass.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean followingMode = app.getRoutingHelper().isFollowingMode();
|
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
||||||
|
|
||||||
if (followingMode) {
|
|
||||||
if (compassPressed + COMPASS_PRESSED_TIME_INTERVAL_MS > System.currentTimeMillis()) {
|
|
||||||
compassPressed = 0;
|
|
||||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
|
||||||
} else {
|
|
||||||
compassPressed = System.currentTimeMillis();
|
|
||||||
app.showShortToastMessage(app.getString(R.string.press_again_to_change_the_map_orientation));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
compassPressed = 0;
|
|
||||||
mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue