add translations for styles
This commit is contained in:
parent
173a04ad3c
commit
186faca972
5 changed files with 59 additions and 13 deletions
|
@ -62,7 +62,7 @@ public abstract class SwitchableAction<T> 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<T> 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<T> extends QuickAction {
|
|||
|
||||
private List<T> 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<T> 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<T> extends QuickAction {
|
|||
|
||||
protected abstract void saveListToParams(List<T> list);
|
||||
|
||||
protected abstract String getItemName(T item);
|
||||
protected abstract String getItemName(T item, Context context);
|
||||
|
||||
protected abstract
|
||||
@StringRes
|
||||
|
|
|
@ -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<Pair<String, String>> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getItemName(Pair<String, String> item) {
|
||||
protected String getItemName(Pair<String, String> item, Context context) {
|
||||
return item.second;
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,16 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
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;
|
||||
|
|
|
@ -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<Pair<String, String>> {
|
|||
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<Pair<String, String>> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getItemName(Pair<String, String> item) {
|
||||
protected String getItemName(Pair<String, String> item, Context context) {
|
||||
return item.second;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String> {
|
|||
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<String> getFilteredStyles() {
|
||||
|
||||
List<String> filtered = new ArrayList<>();
|
||||
|
@ -192,8 +200,12 @@ public class MapStyleAction extends SwitchableAction<String> {
|
|||
}
|
||||
|
||||
@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
|
||||
|
|
|
@ -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<Pair<String, String>> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getItemName(Pair<String, String> item) {
|
||||
protected String getItemName(Pair<String, String> item, Context context) {
|
||||
return item.second;
|
||||
}
|
||||
|
||||
|
@ -123,6 +124,15 @@ public class MapUnderlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
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() {
|
||||
|
|
Loading…
Reference in a new issue