Merge pull request #6471 from osmandapp/kolomiets_branch

Kolomiets branch
This commit is contained in:
Alexey 2019-01-24 12:36:17 +03:00 committed by GitHub
commit f94d3b66ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 148 additions and 17 deletions

View file

@ -2886,6 +2886,10 @@
<string name="quick_action_add_poi_descr">Tapping this action button adds a POI in the middle of the screen.</string> <string name="quick_action_add_poi_descr">Tapping this action button adds a POI in the middle of the screen.</string>
<string name="quick_action_navigation_voice_descr">Tapping this action button disables or enables voice guidance during navigation.</string> <string name="quick_action_navigation_voice_descr">Tapping this action button disables or enables voice guidance during navigation.</string>
<string name="quick_action_add_parking_descr">Tapping this action button adds a parking location in the middle of the screen.</string> <string name="quick_action_add_parking_descr">Tapping this action button adds a parking location in the middle of the screen.</string>
<string name="quick_action_switch_day_night_descr">Tapping this action button switch between Day and Night modes for OsmAnd</string>
<string name="quick_action_switch_day_mode">Day Mode</string>
<string name="quick_action_switch_night_mode">Night Mode</string>
<string name="quick_action_day_night_switch_mode">Switch Day/Night mode</string>
<string name="quick_action_interim_dialog">Show an interim dialog</string> <string name="quick_action_interim_dialog">Show an interim dialog</string>
<string name="favorite_autofill_toast_text">" is saved to "</string> <string name="favorite_autofill_toast_text">" is saved to "</string>
<string name="favorite_empty_place_name">Place</string> <string name="favorite_empty_place_name">Place</string>

View file

@ -1562,18 +1562,16 @@ public class GPXUtilities {
if (tok == XmlPullParser.START_TAG) { if (tok == XmlPullParser.START_TAG) {
Object parse = parserState.peek(); Object parse = parserState.peek();
String tag = parser.getName(); String tag = parser.getName();
if (extensionReadMode && parse instanceof GPXExtensions) { if (extensionReadMode && parse != null) {
String value = readText(parser, tag); String value = readText(parser, tag);
if (value != null) { if (value != null) {
((GPXExtensions) parse).getExtensionsToWrite().put(tag.toLowerCase(), value); ((GPXExtensions) parse).getExtensionsToWrite().put(tag.toLowerCase(), value);
if (tag.equals("speed") && parse instanceof WptPt) { if (tag.equals("speed") && parse instanceof WptPt) {
try { try {
((WptPt) parse).speed = Float.parseFloat(value); ((WptPt) parse).speed = Float.parseFloat(value);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {}
} }
} }
}
} else if (parse instanceof GPXExtensions && tag.equals("extensions")) { } else if (parse instanceof GPXExtensions && tag.equals("extensions")) {
extensionReadMode = true; extensionReadMode = true;
} else { } else {

View file

@ -270,15 +270,14 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
} }
public void sortByDefault(boolean isSortedByDistance) {
public void sortByDefault() {
Location loc = app.getLocationProvider().getLastStaleKnownLocation(); Location loc = app.getLocationProvider().getLastStaleKnownLocation();
LatLon map = app.getMapViewTrackingUtilities().getMapLocation(); LatLon map = app.getMapViewTrackingUtilities().getMapLocation();
if (loc != null) { if (loc != null && isSortedByDistance) {
sortByDistance(new LatLon(loc.getLatitude(), loc.getLongitude())); sortByDistance(new LatLon(loc.getLatitude(), loc.getLongitude()));
} else if(map != null){ } else if (map != null && isSortedByDistance){
sortByDistance(map); sortByDistance(map);
} else{ } else {
sortByName(); sortByName();
} }
} }

View file

@ -1399,7 +1399,10 @@ public class ConfigureMapMenu {
public static int parseTrackColor(RenderingRulesStorage renderer, String colorName) { public static int parseTrackColor(RenderingRulesStorage renderer, String colorName) {
int defaultColor = -1; int defaultColor = -1;
RenderingRule gpxRule = renderer.getRenderingAttributeRule("gpx"); RenderingRule gpxRule = null;
if(renderer!=null) {
gpxRule = renderer.getRenderingAttributeRule("gpx");
}
if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) { if (gpxRule != null && gpxRule.getIfElseChildren().size() > 0) {
List<RenderingRule> rules = renderer.getRenderingAttributeRule("gpx").getIfElseChildren().get(0).getIfElseChildren(); List<RenderingRule> rules = renderer.getRenderingAttributeRule("gpx").getIfElseChildren().get(0).getIfElseChildren();
for (RenderingRule r : rules) { for (RenderingRule r : rules) {

View file

@ -55,7 +55,7 @@ public class FavoriteDialogs {
} }
}; };
favouritesAdapter.sortByDefault(); favouritesAdapter.sortByDefault(true);
if(points.size() == 0){ if(points.size() == 0){
Toast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show();
@ -208,7 +208,7 @@ public class FavoriteDialogs {
final OnDismissListener dismissListener, final Dialog[] dialogHolder, final boolean sortByDist) { final OnDismissListener dismissListener, final Dialog[] dialogHolder, final boolean sortByDist) {
ListView listView = new ListView(uiContext); ListView listView = new ListView(uiContext);
AlertDialog.Builder bld = new AlertDialog.Builder(uiContext); AlertDialog.Builder bld = new AlertDialog.Builder(uiContext);
favouritesAdapter.sortByDefault(); favouritesAdapter.sortByDefault(sortByDist);
listView.setAdapter(favouritesAdapter); listView.setAdapter(favouritesAdapter);
listView.setOnItemClickListener(click); listView.setOnItemClickListener(click);
bld.setPositiveButton(sortByDist ? R.string.sort_by_name : bld.setPositiveButton(sortByDist ? R.string.sort_by_name :

View file

@ -66,6 +66,44 @@
</wpt> </wpt>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="//ge:Placemark">
<xsl:variable name="lonlat" select="ge:Point/ge:coordinates"/>
<xsl:variable name="lon" select="substring-before($lonlat,',')"/>
<xsl:variable name="latele" select="substring-after($lonlat,',')"/>
<xsl:variable name="lat">
<xsl:choose>
<xsl:when test="contains($latele,' ')">
<xsl:value-of select="substring-before($latele,',')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$latele"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="foldername" select="../ge:name"/>
<xsl:if test="$lon">
<wpt lon="{$lon}" lat="{$lat}">
<xsl:choose>
<xsl:when test="contains($latele,',')">
<ele><xsl:value-of select="substring-after($latele,',')"/></ele>
</xsl:when>
</xsl:choose>
<type>
<xsl:value-of select="$foldername"/>
</type>
<name>
<xsl:value-of select="ge:name"/>
</name>
<xsl:if test="ge:description">
<desc>
<xsl:value-of select="ge:description"/>
</desc>
</xsl:if>
</wpt>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="//kml:Placemark"> <xsl:for-each select="//kml:Placemark">
<xsl:if test="kml:Point"> <xsl:if test="kml:Point">
<xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/> <xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/>

View file

@ -889,7 +889,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
boolean needMapAdjust = currentMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN; boolean needMapAdjust = currentMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
if (newMenuState != currentMenuState) { if (newMenuState != currentMenuState) {
restoreCustomMapRatio();
menu.updateControlsVisibility(true); menu.updateControlsVisibility(true);
doBeforeMenuStateChange(currentMenuState, newMenuState); doBeforeMenuStateChange(currentMenuState, newMenuState);
toggleDetailsHideButton(); toggleDetailsHideButton();
@ -1245,7 +1244,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
@Override @Override
public void onPause() { public void onPause() {
restoreCustomMapRatio();
if (view != null) { if (view != null) {
ViewParent parent = view.getParent(); ViewParent parent = view.getParent();

View file

@ -35,6 +35,7 @@ import net.osmand.plus.quickaction.actions.NewAction;
import net.osmand.plus.quickaction.actions.ShowHideFavoritesAction; import net.osmand.plus.quickaction.actions.ShowHideFavoritesAction;
import net.osmand.plus.quickaction.actions.ShowHideOSMBugAction; import net.osmand.plus.quickaction.actions.ShowHideOSMBugAction;
import net.osmand.plus.quickaction.actions.ShowHidePoiAction; import net.osmand.plus.quickaction.actions.ShowHidePoiAction;
import net.osmand.plus.quickaction.actions.DayNightModeAction;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@ -116,6 +117,9 @@ public class QuickActionFactory {
quickActions.add(new MapUnderlayAction()); quickActions.add(new MapUnderlayAction());
} }
quickActions.add(new DayNightModeAction());
QuickAction voice = new NavVoiceAction(); QuickAction voice = new NavVoiceAction();
QuickAction addDestination = new NavAddDestinationAction(); QuickAction addDestination = new NavAddDestinationAction();
QuickAction addFirstIntermediate = new NavAddFirstIntermediateAction(); QuickAction addFirstIntermediate = new NavAddFirstIntermediateAction();
@ -232,6 +236,9 @@ public class QuickActionFactory {
case NavResumePauseAction.TYPE: case NavResumePauseAction.TYPE:
return new NavResumePauseAction(); return new NavResumePauseAction();
case DayNightModeAction.TYPE:
return new DayNightModeAction();
default: default:
return new QuickAction(); return new QuickAction();
} }
@ -313,6 +320,9 @@ public class QuickActionFactory {
case NavResumePauseAction.TYPE: case NavResumePauseAction.TYPE:
return new NavResumePauseAction(quickAction); return new NavResumePauseAction(quickAction);
case DayNightModeAction.TYPE:
return new DayNightModeAction(quickAction);
default: default:
return quickAction; return quickAction;
} }
@ -394,6 +404,9 @@ public class QuickActionFactory {
case NavResumePauseAction.TYPE: case NavResumePauseAction.TYPE:
return R.drawable.ic_play_dark; return R.drawable.ic_play_dark;
case DayNightModeAction.TYPE:
return R.drawable.ic_action_map_day;
default: default:
return R.drawable.ic_action_plus; return R.drawable.ic_action_plus;
} }
@ -457,6 +470,9 @@ public class QuickActionFactory {
case MapUnderlayAction.TYPE: case MapUnderlayAction.TYPE:
return R.string.quick_action_map_underlay; return R.string.quick_action_map_underlay;
case DayNightModeAction.TYPE:
return R.string.quick_action_day_night_switch_mode;
case NavAddDestinationAction.TYPE: case NavAddDestinationAction.TYPE:
return R.string.quick_action_add_destination; return R.string.quick_action_add_destination;
@ -500,6 +516,7 @@ public class QuickActionFactory {
case ShowHideOSMBugAction.TYPE: case ShowHideOSMBugAction.TYPE:
case NavStartStopAction.TYPE: case NavStartStopAction.TYPE:
case NavResumePauseAction.TYPE: case NavResumePauseAction.TYPE:
case DayNightModeAction.TYPE:
return false; return false;
default: default:

View file

@ -0,0 +1,76 @@
package net.osmand.plus.quickaction.actions;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.quickaction.QuickAction;
public class DayNightModeAction extends QuickAction {
public static final int TYPE = 27;
public DayNightModeAction() {super(TYPE);}
public DayNightModeAction(QuickAction quickAction) {super(quickAction);}
@Override
public void execute(MapActivity activity) {
switch (activity.getMyApplication().getSettings().DAYNIGHT_MODE.get()){
case DAY: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.NIGHT);
break;
}
case NIGHT: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
case AUTO: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
case SENSOR: {
activity.getMyApplication().getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.DAY);
break;
}
}
}
@Override
public void drawUI(ViewGroup parent, MapActivity activity) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_with_text, parent, false);
((TextView) view.findViewById(R.id.text))
.setText(R.string.quick_action_switch_day_night_descr);
parent.addView(view);
}
@Override
public int getIconRes(Context context) {
if(context instanceof MapActivity) {
switch (((MapActivity) context).getMyApplication().getSettings().DAYNIGHT_MODE.get()) {
case NIGHT: {
return R.drawable.ic_action_map_night;
}
case AUTO: {
return R.drawable.ic_action_map_sunst;
}
case SENSOR: {
return R.drawable.ic_action_map_light_sensor;
}
}
}
return R.drawable.ic_action_map_day;
}
@Override
public String getActionText(OsmandApplication application) {
return application.getSettings().DAYNIGHT_MODE.get().toHumanString(application) + " Mode";
}
}

View file

@ -420,8 +420,8 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
@Override @Override
public void onActionSelected(QuickAction action) { public void onActionSelected(QuickAction action) {
QuickActionFactory.produceAction(action).execute(mapActivity);
setLayerState(false); setLayerState(false);
QuickActionFactory.produceAction(action).execute(mapActivity);
} }
public PointF getMovableCenterPoint(RotatedTileBox tb) { public PointF getMovableCenterPoint(RotatedTileBox tb) {

View file

@ -1180,8 +1180,6 @@ public class RouteInfoWidgetsFactory {
// update cache // update cache
if (view.isZooming()) { if (view.isZooming()) {
visible = false; visible = false;
} else if (!orientationPortrait && ma.getRoutingHelper().isRoutePlanningMode()) {
visible = false;
} else if (!tb.isZoomAnimated() && (tb.getZoom() != cacheRulerZoom || Math.abs(tb.getCenterTileX() - cacheRulerTileX) > 1 || Math } else if (!tb.isZoomAnimated() && (tb.getZoom() != cacheRulerZoom || Math.abs(tb.getCenterTileX() - cacheRulerTileX) > 1 || Math
.abs(tb.getCenterTileY() - cacheRulerTileY) > 1 || mapDensity.get() != cacheMapDensity) && .abs(tb.getCenterTileY() - cacheRulerTileY) > 1 || mapDensity.get() != cacheMapDensity) &&
tb.getPixWidth() > 0 && maxWidth > 0) { tb.getPixWidth() > 0 && maxWidth > 0) {