From b1913707ccde51cf133326300b5f04cb653a829b Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Sat, 11 Mar 2017 12:19:58 +0300 Subject: [PATCH] Fix bug with wpt colors --- .../editors/WptPtEditorFragment.java | 19 +++++++++++-------- .../plus/myplaces/TrackPointFragment.java | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index 085e7687d6..b368541105 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -33,6 +33,7 @@ public class WptPtEditorFragment extends PointEditorFragment { private boolean saved; private int color; + private int defaultColor; private boolean skipDialog; @Override @@ -41,6 +42,7 @@ public class WptPtEditorFragment extends PointEditorFragment { savingTrackHelper = getMapActivity().getMyApplication().getSavingTrackHelper(); selectedGpxHelper = getMapActivity().getMyApplication().getSelectedGpxHelper(); editor = getMapActivity().getContextMenu().getWptPtPointEditor(); + defaultColor = getResources().getColor(R.color.gpx_color_point); } @Override @@ -52,18 +54,19 @@ public class WptPtEditorFragment extends PointEditorFragment { FavoriteGroup group = getMyApplication().getFavorites().getGroup(wpt.category); if (group == null) { - - int defaultColor = getResources().getColor(R.color.gpx_color_point); - color = wpt.getColor(defaultColor); - - } else color = group.color; + color = wpt.getColor(0); + } else { + color = group.color; + } } @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - if (skipDialog) save(true); + if (skipDialog) { + save(true); + } } @Override @@ -247,12 +250,12 @@ public class WptPtEditorFragment extends PointEditorFragment { @Override public Drawable getNameIcon() { - return FavoriteImageDrawable.getOrCreate(getMapActivity(), color, false); + return FavoriteImageDrawable.getOrCreate(getMapActivity(), color == 0 ? defaultColor : color, false); } @Override public Drawable getCategoryIcon() { - return getPaintedIcon(R.drawable.ic_action_folder_stroke, color); + return getPaintedIcon(R.drawable.ic_action_folder_stroke, color == 0 ? defaultColor : color); } private static class SaveGpxAsyncTask extends AsyncTask { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index cf399acbaa..465c133e24 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -818,7 +818,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { groupColor = gpxItem.locationStart.getColor(groupColor); } if (groupColor == 0) { - groupColor = getMyActivity().getResources().getColor(R.color.gpx_track); + groupColor = getMyActivity().getResources().getColor(R.color.gpx_color_point); } icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), groupColor, false)); } else {