From 46380d4d8a44839bacbb420ea20c141d91b8f639 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Thu, 29 May 2014 12:27:01 +0200 Subject: [PATCH] Add follow action to groups activity --- OsmAnd/res/values/strings.xml | 1 + .../net/osmand/plus/osmo/OsMoGroupsActivity.java | 15 +++++++++++++-- OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java | 10 ---------- .../net/osmand/plus/osmo/OsMoPositionLayer.java | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0db0d13be2..e64efc4b02 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,7 @@ 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 --> + Follow Sign in In order to create groups you need to be a registered user of OsMo. Your osmo credentials are not valid. diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java index fd56e5d7ba..cc8a07e99c 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java @@ -102,6 +102,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements public static final int GROUP_INFO = 8; protected static final int SETTINGS_ID = 9; protected static final int SETTINGS_DEV_ID = 10; + protected static final int TRACK_DEV_ID = 11; private static final int LIST_REFRESH_MSG_ID = OsmAndConstants.UI_HANDLER_SEARCH + 30; private static final long RECENT_THRESHOLD = 60000; @@ -353,6 +354,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements createMenuItem(menu, SETTINGS_DEV_ID, R.string.settings, R.drawable.ic_action_settings_light, R.drawable.ic_action_settings_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM); } + if(device != null && device.getLastLocation() != null) { + MenuItem menuItem = createMenuItem(menu, TRACK_DEV_ID, R.string.osmo_set_moving_target, R.drawable.ic_action_flage_light, R.drawable.ic_action_flage_dark, + MenuItem.SHOW_AS_ACTION_IF_ROOM ); + menuItem.setTitleCondensed(getString(R.string.osmo_follow)); + } if(group != null) { createMenuItem(menu, GROUP_INFO, R.string.osmo_group_info, R.drawable.ic_action_info_light, R.drawable.ic_action_info_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM); @@ -393,7 +399,12 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - if(item.getItemId() == SETTINGS_DEV_ID) { + if(item.getItemId() == TRACK_DEV_ID) { + if(device != null) { + OsMoPositionLayer.setFollowDestination(device); + MapActivity.launchMapActivityMoveToTop(OsMoGroupsActivity.this); + } + } else if(item.getItemId() == SETTINGS_DEV_ID) { showSettingsDialog(device); } else if(item.getItemId() == DELETE_ACTION_ID ) { Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this); @@ -424,7 +435,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements Location location = device.getLastLocation(); app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), app.getSettings().getLastKnownMapZoom(), null, device.getVisibleName(), device); - osMoPlugin.setMapFollowTrackerId(device); + OsMoPositionLayer.setFollowTrackerId(device); MapActivity.launchMapActivityMoveToTop(OsMoGroupsActivity.this); } } else if(item.getItemId() == ON_OFF_ACTION_ID) { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 94c3a12d0a..12c56a1e25 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -40,7 +40,6 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer private OsMoGroups groups; private BaseMapWidget osmoControl; private OsMoPositionLayer olayer; - private Object followTrackerId; // 2014-05-27 23:11:40 public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -288,15 +287,6 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer }).reg(); } - public Object getFollowTrackerId() { - return followTrackerId; - } - - public void setMapFollowTrackerId(OsMoDevice d) { - if(olayer != null) { - OsMoPositionLayer.setFollowTrackerId(d); - } - } @Override public String getId() { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java index b307a62013..3c4c649182 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPositionLayer.java @@ -238,7 +238,7 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye if(sameDestId && l != null) { TargetPointsHelper targets = map.getMyApplication().getTargetPointsHelper(); RoutingHelper rh = map.getMyApplication().getRoutingHelper(); - double dist = 0.1; + double dist = 1; if(rh.isRouteBeingCalculated()) { dist = 100; } else if(rh.isRouteCalculated()) {