From dcfb4f9089f13b7a01de7922c92e214a43b86214 Mon Sep 17 00:00:00 2001 From: Zahnstocher Date: Sat, 9 Aug 2014 12:56:26 +0200 Subject: [PATCH] Translation for possible values --- OsmAnd/res/values-de/strings.xml | 4 ++++ OsmAnd/res/values/strings.xml | 4 ++++ .../plus/activities/SettingsBaseActivity.java | 14 ++++++++++++++ .../views/mapwidgets/AppearanceWidgetsFactory.java | 14 +++++++++++--- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index c9cfb85d36..1f38c47e1d 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -1,5 +1,9 @@ + Karte ansehen + Auto + Fahrrad + Fußgänger Ansage von Favoriten in den Nähe Gefärbte Gebäude Navigation fortsetzen diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index c32a65f305..e0a25b83c6 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,10 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Browse map + Car + Bicycle + Pedestrian Colored buildings Invite... Do you want to leave group %1$s? diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 402b53ad4c..a8315c59c1 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -152,6 +152,20 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im } return defValue; } + + public static String getStringPropertyValue(Context ctx, String propertyValue) { + try { + propertyValue = propertyValue.replaceAll("\\s+","_"); + Field f = R.string.class.getField("rendering_value_" + propertyValue + "_name"); + if (f != null) { + Integer in = (Integer) f.get(null); + return ctx.getString(in); + } + } catch (Exception e) { + System.err.println(e.getMessage()); + } + return propertyValue; + } public SeekBarPreference createSeekBarPreference(OsmandPreference b, int title, int summary, int dialogTextId, int defValue, int maxValue) { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java index 2d6f8d9352..b0b39901ab 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/AppearanceWidgetsFactory.java @@ -207,9 +207,17 @@ public class AppearanceWidgetsFactory { public void run() { AlertDialog.Builder b = new AlertDialog.Builder(view.getContext()); //test old descr as title - b.setTitle(propertyDescr); - int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get()); - b.setSingleChoiceItems(p.getPossibleValues(), i, new DialogInterface.OnClickListener() { + b.setTitle(propertyDescr); + + int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get()); + + String[] possibleValuesString = new String[p.getPossibleValues().length]; + + for (int j = 0; j < p.getPossibleValues().length; j++) { + possibleValuesString[j] = SettingsActivity.getStringPropertyValue(view.getContext(), p.getPossibleValues()[j]); + } + + b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { pref.set(p.getPossibleValues()[which]);