From c426a5f31dd31942126cb5f909d6dbe94f4d779c Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 17 Jun 2018 14:00:41 +0200 Subject: [PATCH] Inline synonyms into string --- .../src/net/osmand/plus/AppInitializer.java | 21 ++++++++++++++++--- .../android/sample1/SampleApplication.java | 20 +++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 82623ffcf4..1fe2c90e23 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -351,7 +351,14 @@ public class AppInitializer implements IProgress { Field f = R.string.class.getField("poi_" + keyName); if (f != null) { Integer in = (Integer) f.get(null); - return app.getString(in); + String val = app.getString(in); + if(val != null) { + int ind = val.indexOf(';'); + if (ind > 0) { + return val.substring(0, ind); + } + } + return val; } } catch (Throwable e) { LOG.info("No translation: " + keyName); @@ -372,10 +379,18 @@ public class AppInitializer implements IProgress { @Override public String getSynonyms(String keyName) { try { - Field f = R.string.class.getField("synonyms_poi_" + keyName); + Field f = R.string.class.getField("poi_" + keyName); if (f != null) { Integer in = (Integer) f.get(null); - return app.getString(in); + String val = app.getString(in); + if(val != null) { + int ind = val.indexOf(';'); + if(ind > 0) { + return val.substring(ind + 1); + } + return val; + } + return val; } } catch (Exception e) { } diff --git a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java index 726ae2c593..08c2e9246a 100644 --- a/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java +++ b/OsmAndCore-sample/src/net/osmand/core/samples/android/sample1/SampleApplication.java @@ -200,7 +200,14 @@ public class SampleApplication extends Application { Field f = R.string.class.getField("poi_" + type.getIconKeyName()); if (f != null) { Integer in = (Integer) f.get(null); - return getString(in); + String val = getString(in); + if(val != null) { + int ind = val.indexOf(';'); + if (ind > 0) { + return val.substring(0, ind); + } + } + return val; } } catch (Exception e) { System.err.println("No translation for "+ type.getIconKeyName() + " " + e.getMessage()); @@ -241,10 +248,17 @@ public class SampleApplication extends Application { @Override public String getSynonyms(String keyName) { try { - Field f = R.string.class.getField("synonyms_poi_" + keyName); + Field f = R.string.class.getField("poi_" + keyName); if (f != null) { Integer in = (Integer) f.get(null); - return getString(in); + String val = getString(in); + if(val != null) { + int ind = val.indexOf(';'); + if (ind > 0) { + return val.substring(ind + 1) ; + } + } + return val; } } catch (Exception e) { }