From 8966ec95da81b203630ee5283731ab86e44bc605 Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Mon, 26 Oct 2020 10:49:17 +0200 Subject: [PATCH 1/2] Add favorites: Add names for icon groups to strings --- OsmAnd/res/values/strings.xml | 8 ++++ .../plus/activities/SettingsBaseActivity.java | 13 +++++++ .../editors/PointEditorFragmentNew.java | 37 ++++++++++--------- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 3132eb5971..5a5af9ed53 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,14 @@ Thx - Hardy --> + Travel + Emergency + Sport + Symbols + Service + Transport + Special + Amenity Gap %1$s — %2$s Wait for the route recalculation.\nGraph will be available after recalculation. diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 316de777b0..7a7706d2f2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -113,6 +113,19 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity booleanPreferences.put(b.getId(), b); return p; } + + public static String getIconStringPropertyName(Context ctx, String propertyName, String defValue) { + try { + Field f = R.string.class.getField("category_group_" + propertyName + "_icon"); + if (f != null) { + Integer in = (Integer) f.get(null); + return ctx.getString(in); + } + } catch (Exception e) { + System.err.println(e.getMessage()); + } + return defValue; + } public static String getRoutingStringPropertyName(Context ctx, String propertyName, String defValue) { try { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java index c487b7acc6..474c0e7870 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/PointEditorFragmentNew.java @@ -47,6 +47,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.SettingsBaseActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.ColorDialogs; @@ -567,23 +568,6 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { : R.color.inactive_buttons_and_links_bg_light))); } - private void createIconSelector() { - iconCategories = new LinkedHashMap<>(); - try { - JSONObject obj = new JSONObject(loadJSONFromAsset()); - JSONObject categories = obj.getJSONObject("categories"); - for (int i = 0; i < categories.length(); i++) { - JSONArray names = categories.names(); - JSONObject icons = categories.getJSONObject(names.get(i).toString()); - iconCategories.put(names.get(i).toString(), icons.getJSONArray("icons")); - } - } catch (JSONException e) { - e.printStackTrace(); - } - selectedIconCategory = getInitCategory(); - createIconForCategory(); - } - private String getInitCategory() { for (int j = 0; j < iconCategories.values().size(); j++) { JSONArray iconJsonArray = (JSONArray) iconCategories.values().toArray()[j]; @@ -604,6 +588,25 @@ public abstract class PointEditorFragmentNew extends BaseOsmAndFragment { return app.getResources().getResourceEntryName(iconId).replaceFirst("mx_", ""); } + private void createIconSelector() { + iconCategories = new LinkedHashMap<>(); + try { + JSONObject obj = new JSONObject(loadJSONFromAsset()); + JSONObject categories = obj.getJSONObject("categories"); + for (int i = 0; i < categories.length(); i++) { + JSONArray names = categories.names(); + JSONObject icons = categories.getJSONObject(names.get(i).toString()); + String name = names.get(i).toString(); + String translatedName = SettingsBaseActivity.getIconStringPropertyName(app, name, name); + iconCategories.put(translatedName, icons.getJSONArray("icons")); + } + } catch (JSONException e) { + e.printStackTrace(); + } + selectedIconCategory = getInitCategory(); + createIconForCategory(); + } + private void createIconForCategory() { FlowLayout selectIcon = view.findViewById(R.id.select_icon); selectIcon.removeAllViews(); From c72077322ec2446e3dd7b4a0211f7b66a89ffa0c Mon Sep 17 00:00:00 2001 From: androiddevkkotlin Date: Mon, 26 Oct 2020 13:20:43 +0200 Subject: [PATCH 2/2] Victors icon name --- OsmAnd/res/values/strings.xml | 16 ++++++++-------- .../plus/activities/SettingsBaseActivity.java | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 5a5af9ed53..66bf576966 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,14 +11,14 @@ Thx - Hardy --> - Travel - Emergency - Sport - Symbols - Service - Transport - Special - Amenity + Travel + Emergency + Sport + Symbols + Service + Transport + Special + Amenity Gap %1$s — %2$s Wait for the route recalculation.\nGraph will be available after recalculation. diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index 7a7706d2f2..1821c88474 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -116,7 +116,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity public static String getIconStringPropertyName(Context ctx, String propertyName, String defValue) { try { - Field f = R.string.class.getField("category_group_" + propertyName + "_icon"); + Field f = R.string.class.getField("icon_group_" + propertyName); if (f != null) { Integer in = (Integer) f.get(null); return ctx.getString(in);