From b8abc5fba713140809e66d75247e59238a750923 Mon Sep 17 00:00:00 2001 From: Denis Date: Wed, 13 Aug 2014 19:15:28 +0300 Subject: [PATCH 1/2] First implementation of dialog --- .../plus/helpers/WaypointDialogHelper.java | 102 +++++++++++++++++- .../osmand/plus/helpers/WaypointHelper.java | 32 +++++- .../plus/sherpafy/SherpafyCustomization.java | 2 +- 3 files changed, 129 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index 91aa3da87c..d453abcd97 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -39,6 +39,11 @@ public class WaypointDialogHelper { private long uiModified; private View closePointDialog; + private static final String GPX_WAYPOINTS = "GPX waypoints"; + private static final String FAVORITES = "Favorites"; + private static final String POI = "POI"; + private static final String TARGETS = "Targets"; + public WaypointDialogHelper(MapActivity mapActivity) { this.app = mapActivity.getMyApplication(); waypointHelper = this.app.getWaypointHelper(); @@ -47,7 +52,7 @@ public class WaypointDialogHelper { } public void updateDialog() { - List vlp = waypointHelper.getVisibleLocationPoints(); + List vlp = waypointHelper.getAllVisibleLocationPoints(); long locationPointsModified = waypointHelper.getLocationPointsModified(); if (locationPointsModified != uiModified) { uiModified = locationPointsModified; @@ -70,7 +75,7 @@ public class WaypointDialogHelper { all.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - showAllDialog(); + showAllDialog(waypointHelper.getAllVisibleLocationPoints()); } }); @@ -185,8 +190,95 @@ public class WaypointDialogHelper { }.execute(reachedView); } - public void showAllDialog(){ - final List visibleLocationPoints = waypointHelper.getVisibleLocationPoints(); + public void showWaypointsSettingsDialog(){ + final List points = getItemsList(waypointHelper.getAllVisibleLocationPoints()); + + final ArrayAdapter listAdapter = new ArrayAdapter(mapActivity, R.layout.waypoint_reached, R.id.title, + points) { + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + // User super class to create the View + View v = convertView; + if (v == null) { + if (points.get(position) instanceof LocationPoint){ + v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_reached, null); + int vl = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, mapActivity.getResources() + .getDisplayMetrics()); + final LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(vl, vl); + ll.setMargins(vl / 4, vl / 4, vl / 4, vl / 4); + v.findViewById(R.id.waypoint_icon).setLayoutParams(ll); + } else if (points.get(position) instanceof String){ + String header = (String)points.get(position); + v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_header, null); + TextView headerText = (TextView) v.findViewById(R.id.header_text); + headerText.setText(header); + ImageButton allpoints = (ImageButton) v.findViewById(R.id.all_points); + if (header.equals(FAVORITES)){ + allpoints.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showAllDialog(waypointHelper.getVisibleFavorites()); + } + }); + } else if (header.equals(TARGETS)){ + allpoints.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showAllDialog(waypointHelper.getVisibleTargets()); + } + }); + } else if (header.equals(GPX_WAYPOINTS)){ + allpoints.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showAllDialog(waypointHelper.getVisibleGpxPoints()); + } + }); + } else if (header.equals(POI)){ + allpoints.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showAllDialog(waypointHelper.getVisiblePOI()); + } + }); + } + } + + } + updatePointInfoView(v, (LocationPoint)getItem(position)); + TextView text = (TextView) v.findViewById(R.id.waypoint_text); + text.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showOnMap((LocationPoint)points.get(position)); + } + }); + + View remove = v.findViewById(R.id.info_close); + ((ImageButton) remove).setImageDrawable(mapActivity.getResources().getDrawable( + app.getSettings().isLightContent()? R.drawable.ic_action_gremove_light: + R.drawable.ic_action_gremove_dark)); + remove.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + LocationPoint point = waypointHelper.getAllVisibleLocationPoints().get(position); + remove(point); + waypointHelper.removeVisibleLocationPoint(point); + notifyDataSetChanged(); + } + }); + + return v; + } + + }; + } + + private List getItemsList(List visibleLocationPoints) { + return null; + } + + public void showAllDialog(final List visibleLocationPoints){ final ArrayAdapter listAdapter = new ArrayAdapter(mapActivity, R.layout.waypoint_reached, R.id.title, visibleLocationPoints) { @Override @@ -217,7 +309,7 @@ public class WaypointDialogHelper { remove.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - LocationPoint point = waypointHelper.getVisibleLocationPoints().get(position); + LocationPoint point = waypointHelper.getAllVisibleLocationPoints().get(position); remove(point); waypointHelper.removeVisibleLocationPoint(point); notifyDataSetChanged(); diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java index b96bbe9f50..4896779c4d 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointHelper.java @@ -1,7 +1,9 @@ package net.osmand.plus.helpers; import net.osmand.Location; +import net.osmand.data.FavouritePoint; import net.osmand.data.LocationPoint; +import net.osmand.plus.GPXUtilities; import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmandApplication; import net.osmand.util.MapUtils; @@ -41,10 +43,38 @@ public class WaypointHelper { } - public List getVisibleLocationPoints() { + public List getAllVisibleLocationPoints() { return visibleLocationPoints; } + public List getVisibleFavorites() { + List points = new ArrayList(); + for (LocationPoint point : visibleLocationPoints){ + if (point instanceof FavouritePoint){ + points.add(point); + } + } + return points; + } + + public List getVisibleGpxPoints() { + List points = new ArrayList(); + for (LocationPoint point : visibleLocationPoints){ + if (point instanceof GPXUtilities.WptPt){ + points.add(point); + } + } + return points; + } + + public List getVisiblePOI() { + return null; + } + + public List getVisibleTargets() { + return null; + } + public void locationChanged(Location location) { app.getAppCustomization(); lastKnownLocation = location; diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java index e08825b4b2..ff98f52479 100644 --- a/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java +++ b/OsmAnd/src/net/osmand/plus/sherpafy/SherpafyCustomization.java @@ -253,7 +253,7 @@ public class SherpafyCustomization extends OsmAndAppCustomization { @Override public void prepareLocationMenu(MapActivity mapActivity, ContextMenuAdapter adapter) { - filter(adapter, R.string.context_menu_item_directions_to, + filter(adapter, R.string.pause_navigation, R.string.continue_navigation, R.string.context_menu_item_directions_to, R.string.context_menu_item_destination_point, R.string.context_menu_item_search, R.string.context_menu_item_share_location, R.string.context_menu_item_add_favorite); MapActivityLayers layers = mapActivity.getMapLayers(); From d295c9361df701d432b3819e90936998ea935ac4 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 14 Aug 2014 11:27:59 +0300 Subject: [PATCH 2/2] Removed round items in tour selection --- OsmAnd/res/drawable/tour_bg.xml | 2 - OsmAnd/res/layout/sherpafy_list_tour_item.xml | 4 +- .../osmand/plus/views/CustomImageView.java | 38 ------------------- 3 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 OsmAnd/src/net/osmand/plus/views/CustomImageView.java diff --git a/OsmAnd/res/drawable/tour_bg.xml b/OsmAnd/res/drawable/tour_bg.xml index e60cc59b73..1a94704092 100644 --- a/OsmAnd/res/drawable/tour_bg.xml +++ b/OsmAnd/res/drawable/tour_bg.xml @@ -2,7 +2,5 @@ - \ No newline at end of file diff --git a/OsmAnd/res/layout/sherpafy_list_tour_item.xml b/OsmAnd/res/layout/sherpafy_list_tour_item.xml index 6decc6f550..91ef2786f3 100644 --- a/OsmAnd/res/layout/sherpafy_list_tour_item.xml +++ b/OsmAnd/res/layout/sherpafy_list_tour_item.xml @@ -19,7 +19,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - +