From 08d18358cc4253f2574f8242cf87549bcc10f538 Mon Sep 17 00:00:00 2001 From: madwasp79 Date: Fri, 15 Mar 2019 12:16:09 +0200 Subject: [PATCH] Quickaction mode fix --- OsmAnd/res/values/strings.xml | 2 +- .../quickaction/actions/DayNightModeAction.java | 4 ++-- .../osmand/plus/views/MapQuickActionLayer.java | 15 ++++++--------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index caa37d1d0a..88d3e14aca 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -10,7 +10,7 @@ - For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience Thx - Hardy ---> mode +--> %s mode Learn more about how OsmAnd calculates routes in our blog. Public transport routes are now in the beta testing phase, so errors and inaccuracies may occur. Add intermediate point diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java index a3e6e6b1b5..d1c69fd611 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/DayNightModeAction.java @@ -57,9 +57,9 @@ public class DayNightModeAction extends QuickAction { @Override public String getActionText(OsmandApplication application) { if (application.getSettings().DAYNIGHT_MODE.get() == DayNightMode.DAY) { - return DayNightMode.NIGHT.toHumanString(application) + " " + application.getString(R.string.shared_string_mode); + return String.format("%s mode", DayNightMode.NIGHT.toHumanString(application)); } else { - return DayNightMode.DAY.toHumanString(application) + " " + application.getString(R.string.shared_string_mode); + return String.format("%s mode", DayNightMode.DAY.toHumanString(application)); } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java index 6cabfe0d3f..cab4f600c3 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java @@ -74,6 +74,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe private boolean isLayerOn; private boolean nightMode; + private boolean prevWidgetState; public MapQuickActionLayer(MapActivity activity, ContextMenuLayer contextMenuLayer) { this.mapActivity = activity; @@ -205,6 +206,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe * @return true, if state was changed */ public boolean setLayerState(boolean showWidget) { + prevWidgetState = showWidget; if (isWidgetVisible() == showWidget) // check if state change is needed return false; @@ -373,14 +375,14 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe @Override public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings settings) { - boolean nightMode = settings != null && settings.isNightMode(); + boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); if (isInMovingMarkerMode()) { canvas.translate(box.getCenterPixelX() - contextMarker.getWidth() / 2, box.getCenterPixelY() - contextMarker.getHeight()); contextMarker.draw(canvas); } if (this.nightMode != nightMode) { this.nightMode = nightMode; - updateQuickActionButton(isWidgetVisible()); + updateQuickActionButton(prevWidgetState); } setupQuickActionBtnVisibility(); } @@ -421,13 +423,8 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe @Override public void onActionSelected(QuickAction action) { - if (action instanceof DayNightModeAction) { - setLayerState(false); - QuickActionFactory.produceAction(action).execute(mapActivity); - } else { - QuickActionFactory.produceAction(action).execute(mapActivity); - setLayerState(false); - } + QuickActionFactory.produceAction(action).execute(mapActivity); + setLayerState(false); } public PointF getMovableCenterPoint(RotatedTileBox tb) {