diff --git a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java index 8869df04c9..58581de3cd 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/SwitchableAction.java @@ -62,7 +62,7 @@ public abstract class SwitchableAction extends QuickAction { final QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback(); final ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback); - final Adapter adapter = new Adapter(new QuickActionListFragment.OnStartDragListener() { + final Adapter adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() { @Override public void onStartDrag(RecyclerView.ViewHolder viewHolder) { touchHelper.startDrag(viewHolder); @@ -107,6 +107,8 @@ public abstract class SwitchableAction extends QuickAction { public abstract void executeWithParams(MapActivity activity, String params); + public abstract String getTranslatedItemName(Context context, String item); + protected void showChooseDialog(FragmentManager fm) { SelectMapViewQuickActionsBottomSheet fragment = new SelectMapViewQuickActionsBottomSheet(); Bundle args = new Bundle(); @@ -119,8 +121,10 @@ public abstract class SwitchableAction extends QuickAction { private List itemsList = new ArrayList<>(); private final QuickActionListFragment.OnStartDragListener onStartDragListener; + private Context context; - public Adapter(QuickActionListFragment.OnStartDragListener onStartDragListener) { + public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) { + this.context = context; this.onStartDragListener = onStartDragListener; this.itemsList = new ArrayList<>(); } @@ -135,7 +139,7 @@ public abstract class SwitchableAction extends QuickAction { public void onBindViewHolder(final Adapter.ItemHolder holder, final int position) { final T item = itemsList.get(position); - holder.title.setText(getItemName(item)); + holder.title.setText(getItemName(item, context)); holder.handleView.setOnTouchListener(new View.OnTouchListener() { @Override @@ -274,7 +278,7 @@ public abstract class SwitchableAction extends QuickAction { protected abstract void saveListToParams(List list); - protected abstract String getItemName(T item); + protected abstract String getItemName(T item, Context context); protected abstract @StringRes diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java index 09a40aa407..94c0188aaf 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapOverlayAction.java @@ -1,5 +1,6 @@ package net.osmand.plus.quickaction.actions; +import android.content.Context; import android.content.DialogInterface; import android.support.v4.util.Pair; import android.support.v7.app.AlertDialog; @@ -69,7 +70,7 @@ public class MapOverlayAction extends SwitchableAction> { } @Override - protected String getItemName(Pair item) { + protected String getItemName(Pair item, Context context) { return item.second; } @@ -120,7 +121,16 @@ public class MapOverlayAction extends SwitchableAction> { Toast.makeText(activity, activity.getString(R.string.quick_action_map_overlay_switch, params), Toast.LENGTH_SHORT).show(); } } - + + @Override + public String getTranslatedItemName(Context context, String item) { + if (item.equals(KEY_NO_OVERLAY)) { + return context.getString(R.string.no_overlay); + } else { + return item; + } + } + @Override protected int getAddBtnText() { return R.string.quick_action_map_overlay_action; diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java index 84a830ebdb..839403144e 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapSourceAction.java @@ -1,5 +1,6 @@ package net.osmand.plus.quickaction.actions; +import android.content.Context; import android.content.DialogInterface; import android.support.v4.util.Pair; import android.support.v7.app.AlertDialog; @@ -108,7 +109,16 @@ public class MapSourceAction extends SwitchableAction> { settings.MAP_ONLINE_DATA.set(true); activity.getMapLayers().updateMapSource(activity.getMapView(), settings.MAP_TILE_SOURCES); } - Toast.makeText(activity, activity.getString(R.string.quick_action_map_source_switch, params), Toast.LENGTH_SHORT).show(); + Toast.makeText(activity, activity.getString(R.string.quick_action_map_source_switch, getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show(); + } + + @Override + public String getTranslatedItemName(Context context, String item) { + if (item.equals(LAYER_OSM_VECTOR)) { + return context.getString(R.string.vector_data); + } else { + return item; + } } @Override @@ -178,7 +188,7 @@ public class MapSourceAction extends SwitchableAction> { } @Override - protected String getItemName(Pair item) { + protected String getItemName(Pair item, Context context) { return item.second; } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index 2a923f2940..2e411cff73 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -1,5 +1,6 @@ package net.osmand.plus.quickaction.actions; +import android.content.Context; import android.content.DialogInterface; import android.support.v7.app.AlertDialog; import android.support.v7.widget.SwitchCompat; @@ -69,12 +70,19 @@ public class MapStyleAction extends SwitchableAction { app.getRendererRegistry().setCurrentSelectedRender(loaded); ConfigureMapMenu.refreshMapComplete(activity); - Toast.makeText(activity, activity.getString(R.string.quick_action_map_style_switch, params), Toast.LENGTH_SHORT).show(); + Toast.makeText(activity, activity.getString(R.string.quick_action_map_style_switch, getTranslatedItemName(activity,params)), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(activity, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show(); } } - + + @Override + public String getTranslatedItemName(Context context, String item) { + String translation = RendererRegistry.getTranslatedRendererName(context, item); + return translation != null ? translation + : item.replace('_', ' ').replace('-', ' '); + } + public List getFilteredStyles() { List filtered = new ArrayList<>(); @@ -192,8 +200,12 @@ public class MapStyleAction extends SwitchableAction { } @Override - protected String getItemName(String item) { - return item; + protected String getItemName(String item, Context context) { + if (context != null) { + return getTranslatedItemName(context, item); + } else { + return item; + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java index 590d06b388..de492ef91c 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapUnderlayAction.java @@ -1,5 +1,6 @@ package net.osmand.plus.quickaction.actions; +import android.content.Context; import android.content.DialogInterface; import android.support.v4.util.Pair; import android.support.v7.app.AlertDialog; @@ -69,7 +70,7 @@ public class MapUnderlayAction extends SwitchableAction> { } @Override - protected String getItemName(Pair item) { + protected String getItemName(Pair item, Context context) { return item.second; } @@ -123,6 +124,15 @@ public class MapUnderlayAction extends SwitchableAction> { Toast.makeText(activity, activity.getString(R.string.quick_action_map_underlay_switch, params), Toast.LENGTH_SHORT).show(); } } + + @Override + public String getTranslatedItemName(Context context, String item) { + if (item.equals(KEY_NO_UNDERLAY)) { + return context.getString(R.string.no_underlay); + } else { + return item; + } + } @Override protected int getAddBtnText() {