Refactor, profilechange overide
This commit is contained in:
parent
1ce74b23ea
commit
a418f94cd1
6 changed files with 13 additions and 38 deletions
|
@ -39,14 +39,6 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
|||
|
||||
protected static final String KEY_DIALOG = "dialog";
|
||||
|
||||
private final static String MAP_STYLE_ACTION = "mapstyle.change";
|
||||
private final static String MAP_SOURCE_ACTION = "mapsource.change";
|
||||
private final static String MAP_OVERLAY_ACTION = "mapoverlay.change";
|
||||
private final static String MAP_UNDERLAY_ACTION = "mapunderlay.change";
|
||||
|
||||
private final static String KEY_NO_OVERLAY = "no_overlay";
|
||||
private final static String KEY_NO_UNDERLAY = "no_underlay";
|
||||
|
||||
private transient EditText title;
|
||||
|
||||
private transient Adapter adapter;
|
||||
|
@ -115,28 +107,10 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
|||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
String currentSource = "";
|
||||
switch (getActionType().getStringId()) {
|
||||
case MAP_STYLE_ACTION:
|
||||
currentSource = application.getSettings().RENDERER.get();
|
||||
break;
|
||||
case MAP_SOURCE_ACTION:
|
||||
currentSource = application.getSettings().MAP_ONLINE_DATA.get()
|
||||
? application.getSettings().MAP_TILE_SOURCES.get()
|
||||
: application.getString(R.string.vector_data);
|
||||
break;
|
||||
case MAP_OVERLAY_ACTION:
|
||||
currentSource = application.getSettings().MAP_OVERLAY.get() == null ? KEY_NO_OVERLAY
|
||||
: application.getSettings().MAP_OVERLAY.get();
|
||||
break;
|
||||
case MAP_UNDERLAY_ACTION:
|
||||
currentSource = application.getSettings().MAP_UNDERLAY.get() == null ? KEY_NO_UNDERLAY
|
||||
: application.getSettings().MAP_UNDERLAY.get();
|
||||
break;
|
||||
}
|
||||
String item = getSelectedItem(application);
|
||||
String arrowDirection = isLayoutRtl(application) ? "\u25c0" : "\u25b6";
|
||||
|
||||
return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, currentSource), arrowDirection + "\u2026");
|
||||
return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), arrowDirection + "\u2026");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,8 +30,6 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||
|
||||
public class MapStyleAction extends SwitchableAction<String> {
|
||||
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||
|
||||
public class SwitchProfileAction extends SwitchableAction<String> {
|
||||
|
||||
private final static String KEY_PROFILES = "profiles";
|
||||
|
@ -230,4 +232,11 @@ public class SwitchProfileAction extends SwitchableAction<String> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionText(OsmandApplication application) {
|
||||
String item = getSelectedItem(application);
|
||||
|
||||
return application.getString(R.string.ltr_or_rtl_combine_via_space, getTranslatedItemName(application, item), "\u2026");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||
|
||||
public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
||||
|
||||
private final static String KEY_OVERLAYS = "overlays";
|
||||
|
@ -61,7 +59,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
|
||||
@Override
|
||||
public String getSelectedItem(OsmandApplication app) {
|
||||
return app.getSettings().MAP_OVERLAY.get();
|
||||
return app.getSettings().MAP_OVERLAY.get() != null ? app.getSettings().MAP_OVERLAY.get() : KEY_NO_OVERLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -29,8 +29,6 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||
|
||||
public class MapSourceAction extends SwitchableAction<Pair<String, String>> {
|
||||
|
||||
public static final String LAYER_OSM_VECTOR = "LAYER_OSM_VECTOR";
|
||||
|
|
|
@ -28,8 +28,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.AndroidUtils.isLayoutRtl;
|
||||
|
||||
|
||||
public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
|
||||
|
||||
|
@ -61,7 +59,7 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
|
||||
@Override
|
||||
public String getSelectedItem(OsmandApplication app) {
|
||||
return app.getSettings().MAP_UNDERLAY.get();
|
||||
return app.getSettings().MAP_UNDERLAY.get() != null ? app.getSettings().MAP_UNDERLAY.get() : KEY_NO_UNDERLAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue