From 6857b9852384898ffe6d0b9cdb549b3b3580f227 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 1 Jun 2014 18:17:22 +0200 Subject: [PATCH 1/5] Add 15 seconds tail for better move visualization --- OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java index 3c4acb4613..3aac6a2f35 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java @@ -162,15 +162,16 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener { group = storage.getGroup(gid); if(group != null) { List delta = mergeGroup(group, obj, false); + String mygid = service.getMyGroupTrackerId(); StringBuilder b = new StringBuilder(); for(OsMoDevice d : delta) { if(d.getDeletedTimestamp() != 0 && d.isEnabled()) { - if(group.name != null) { + if(group.name != null && !d.getTrackerId().equals(mygid)) { b.append(app.getString(R.string.osmo_user_left, d.getVisibleName(), group.getVisibleName(app))).append("\n"); } disconnectImpl(d); } else if(!d.isActive()) { - if(group.name != null) { + if(group.name != null && !d.getTrackerId().equals(mygid)) { b.append(app.getString(R.string.osmo_user_joined, d.getVisibleName(), group.getVisibleName(app))).append("\n"); } connectDeviceImpl(d); From 92f3624d295331845f0d41b5423955c4a54f3724 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 1 Jun 2014 23:45:17 +0200 Subject: [PATCH 2/5] Update ui to have selection and select individual users to track --- OsmAnd/res/layout-v14/check_item_rel.xml | 2 + OsmAnd/res/layout/check_item_rel.xml | 4 + OsmAnd/res/layout/osmo_group_item.xml | 28 +++--- .../osmand/plus/osmo/OsMoGroupsActivity.java | 93 ++++++++++++------- 4 files changed, 76 insertions(+), 51 deletions(-) diff --git a/OsmAnd/res/layout-v14/check_item_rel.xml b/OsmAnd/res/layout-v14/check_item_rel.xml index fafd584d05..26b81c2788 100644 --- a/OsmAnd/res/layout-v14/check_item_rel.xml +++ b/OsmAnd/res/layout-v14/check_item_rel.xml @@ -8,6 +8,8 @@ android:id="@+id/check_item" android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_marginTop="4dp" + android:layout_marginBottom="4dp" android:focusable="false" android:gravity="center_vertical"/> diff --git a/OsmAnd/res/layout/check_item_rel.xml b/OsmAnd/res/layout/check_item_rel.xml index f3b515724f..549ee64c09 100644 --- a/OsmAnd/res/layout/check_item_rel.xml +++ b/OsmAnd/res/layout/check_item_rel.xml @@ -9,6 +9,10 @@ android:text="@string/osmo_connect_menu" android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_marginLeft="3dp" + android:layout_marginRight="3dp" + android:layout_marginTop="3dp" + android:layout_marginBottom="3dp" android:focusable="false" android:gravity="center_vertical" /> diff --git a/OsmAnd/res/layout/osmo_group_item.xml b/OsmAnd/res/layout/osmo_group_item.xml index d78af32bc3..d725cd3b3e 100644 --- a/OsmAnd/res/layout/osmo_group_item.xml +++ b/OsmAnd/res/layout/osmo_group_item.xml @@ -4,7 +4,7 @@ android:layout_height="wrap_content" android:background="?attr/expandable_category_color" android:paddingBottom="5dp" - android:paddingLeft="4dp" + android:paddingLeft="3dp" android:paddingRight="4dp" android:paddingTop="5dp" > @@ -14,7 +14,8 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingLeft="6dp" - android:src="@drawable/expandable_category_unpushed" /> + android:src="@drawable/expandable_category_unpushed" /> + - - \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java index 7db76fb355..09b40a8512 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java @@ -36,6 +36,8 @@ import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice; import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup; import net.osmand.plus.osmo.OsMoService.SessionInfo; +import net.osmand.util.MapAlgorithms; +import net.osmand.util.MapUtils; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.Context; @@ -203,34 +205,6 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements white.setAntiAlias(true); updateStatus(); - getExpandableListView().setOnGroupClickListener(new OnGroupClickListener() { - @Override - public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { - OsMoGroup gr = adapter.getGroup(groupPosition); - if(gr.isMainGroup()) { - if(parent.isGroupExpanded(groupPosition)) { - parent.collapseGroup(groupPosition); - } else { - parent.expandGroup(groupPosition); - } - } else { - if(selectedObject == gr) { - quitSelectionMode(); - if(parent.isGroupExpanded(groupPosition)) { - parent.collapseGroup(groupPosition); - } else { - parent.expandGroup(groupPosition); - } - } else { - enterSelectionMode(gr); - } - } - if(groupPosition == 0) { - return true; - } - return false; - } - }); } long lastUpdateTime; @@ -339,7 +313,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements device = (OsMoDevice) (o instanceof OsMoDevice ?o : null); group = (OsMoGroup) (o instanceof OsMoGroup ?o : null); MenuItem mi = null; - if(device == null || device.getGroup().isMainGroup()) { + if(device != null) { mi = createMenuItem(menu, ON_OFF_ACTION_ID, R.string.default_buttons_ok, 0, 0, MenuItem.SHOW_AS_ACTION_ALWAYS); } @@ -929,6 +903,40 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements } else { label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC); } + View v = row.findViewById(R.id.settings); + if(model.isMainGroup()) { + v.setVisibility(View.GONE); + } else { + v.setVisibility(View.VISIBLE); + v.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View v) { + enterSelectionMode(model); + } + }); + } + CompoundButton ci = (CompoundButton) row.findViewById(R.id.check_item); + if(model.isMainGroup()) { + ci.setVisibility(View.GONE); + } else { + ci.setVisibility(View.VISIBLE); + ci.setOnCheckedChangeListener(null); + ci.setChecked(model.isEnabled() && model.isActive()); + ci.setOnCheckedChangeListener(new OnCheckedChangeListener() { + + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if(isChecked) { + String operation = osMoPlugin.getGroups().connectGroup(model); + startLongRunningOperation(operation); + } else { + String operation = osMoPlugin.getGroups().disconnectGroup(model); + startLongRunningOperation(operation); + } + } + }); + } return row; } @@ -961,17 +969,25 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements osMoPlugin.getGroups().setGenColor(model, activeColor); } //Location location = tracker.getLastLocation(model.trackerId); - if (location == null || mapLocation == null) { + if(model.isEnabled()) { + icon.setVisibility(View.INVISIBLE); + label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC); + label.setText(model.getVisibleName()); + } else if (location == null || mapLocation == null) { + label.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); + icon.setVisibility(View.VISIBLE); NonDirectionDrawable draw ; if(icon.getDrawable() instanceof NonDirectionDrawable) { draw = (NonDirectionDrawable) icon.getDrawable(); } else { draw = new NonDirectionDrawable(); } - draw.setColor(model.isEnabled()?activeColor : color); + draw.setColor(model.isEnabled() ? activeColor : color); icon.setImageDrawable(draw); label.setText(model.getVisibleName()); } else { + label.setTypeface(Typeface.DEFAULT, Typeface.NORMAL); + icon.setVisibility(View.VISIBLE); DirectionDrawable draw; if (icon.getDrawable() instanceof DirectionDrawable) { draw = (DirectionDrawable) icon.getDrawable(); @@ -1022,8 +1038,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements public void updateLocation(Location location) { MapViewTrackingUtilities mv = MapActivity.getMapViewTrackingUtilities(); if(mv != null && mv.isMapLinkedToLocation() && location != null) { + Location lt = mapLocation; mapLocation = location; - adapter.notifyDataSetInvalidated(); + if(lt == null || location.distanceTo(lt) > 8) { + refreshList(); + } } } @@ -1033,8 +1052,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements @Override public void updateCompassValue(float value) { + float vl = lastCompass; lastCompass = value; - refreshList(); + if(Math.abs(MapUtils.degreesDiff(vl, value)) > 15) { + refreshList(); + } } private void refreshList() { @@ -1042,7 +1064,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements Message msg = Message.obtain(uiHandler, new Runnable() { @Override public void run() { - adapter.notifyDataSetChanged(); + adapter.notifyDataSetInvalidated(); updateStatus(); } }); @@ -1051,10 +1073,13 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements } } + + @Override public void deviceLocationChanged(OsMoDevice device) { refreshList(); } + public static String colorToString(int color) { if ((0xFF000000 & color) == 0xFF000000) { return "#" + Integer.toHexString(color & 0x00FFFFFF); //$NON-NLS-1$ From ba1ca526ece1477d1bc8c15d91a6fec433a2cc0e Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 1 Jun 2014 23:54:20 +0200 Subject: [PATCH 3/5] Update ui to have selection and select individual users to track --- OsmAnd/res/layout/osmo_group_item.xml | 30 ++++++++++++------- OsmAnd/res/values/strings.xml | 2 +- .../osmand/plus/osmo/OsMoGroupsActivity.java | 10 +++++-- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/OsmAnd/res/layout/osmo_group_item.xml b/OsmAnd/res/layout/osmo_group_item.xml index d725cd3b3e..c191f2bbfd 100644 --- a/OsmAnd/res/layout/osmo_group_item.xml +++ b/OsmAnd/res/layout/osmo_group_item.xml @@ -14,28 +14,36 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingLeft="6dp" - android:src="@drawable/expandable_category_unpushed" /> - + android:src="@drawable/expandable_category_unpushed" /> - - + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 153633ae05..7e07c4f0fb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -62,7 +62,7 @@ Create group OsMo Server operation failed OpenStreetMap-Monitoring - Send my lcations + Send my locations OsMo quick access hours ago min ago diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java index 09b40a8512..3a4330c102 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java @@ -440,6 +440,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements quitSelectionMode(); } }); + refreshList(); } private StringBuilder setFields(StringBuilder bld, int field, String value) { @@ -509,6 +510,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements private void quitSelectionMode() { selectedObject = null; actionMode.finish(); + refreshList(); } @Override @@ -912,7 +914,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements @Override public void onClick(View v) { - enterSelectionMode(model); + if (model != selectedObject) { + enterSelectionMode(model); + } else { + quitSelectionMode(); + } } }); } @@ -969,7 +975,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements osMoPlugin.getGroups().setGenColor(model, activeColor); } //Location location = tracker.getLastLocation(model.trackerId); - if(model.isEnabled()) { + if(!model.isEnabled()) { icon.setVisibility(View.INVISIBLE); label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC); label.setText(model.getVisibleName()); From f4a5448e6bd6a1072e08002a414e19759826274f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 2 Jun 2014 00:07:12 +0200 Subject: [PATCH 4/5] Small fixes --- OsmAnd/res/layout-v14/check_item_rel.xml | 4 ++-- OsmAnd/res/layout/check_item_rel.xml | 4 ++-- OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OsmAnd/res/layout-v14/check_item_rel.xml b/OsmAnd/res/layout-v14/check_item_rel.xml index 26b81c2788..4bdff116d6 100644 --- a/OsmAnd/res/layout-v14/check_item_rel.xml +++ b/OsmAnd/res/layout-v14/check_item_rel.xml @@ -1,13 +1,13 @@ Date: Mon, 2 Jun 2014 01:50:02 +0200 Subject: [PATCH 5/5] Fix download button on map z9-12 --- OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 6 +++++- OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java | 1 + .../src/net/osmand/plus/views/DownloadedRegionsLayer.java | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index e4acc0a696..d1041657c7 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -75,7 +75,11 @@ public abstract class OsmandPlugin { installPlugin(SRTM_PLUGIN_COMPONENT, SRTMPlugin.FREE_ID, app, new SRTMPlugin(app, false)); } - installPlugin(PARKING_PLUGIN_COMPONENT, ParkingPositionPlugin.ID, app, new ParkingPositionPlugin(app)); + final ParkingPositionPlugin parking = new ParkingPositionPlugin(app); + boolean f = installPlugin(PARKING_PLUGIN_COMPONENT, ParkingPositionPlugin.ID, app, parking); + if(!f && Version.isParkingPluginInlined(app)) { + installedPlugins.add(parking); + } installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app)); installedPlugins.add(new OsmEditingPlugin(app)); installedPlugins.add(new OsmandDevelopmentPlugin(app)); diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java index 5b9f7f9039..0554727393 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java @@ -197,6 +197,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener { // connect to enabled devices in group for(OsMoDevice d : group.getGroupUsers(null)) { if(d.isEnabled()) { + d.active = false; connectDeviceImpl(d); } } diff --git a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java index 6f471e2a7d..ce8fab768f 100644 --- a/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/DownloadedRegionsLayer.java @@ -164,7 +164,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer { int right = MapUtils.get31TileNumberX(tileBox.getRightBottomLatLon().getLongitude()); int top = MapUtils.get31TileNumberY(tileBox.getLeftTopLatLon().getLatitude()); int bottom = MapUtils.get31TileNumberY(tileBox.getRightBottomLatLon().getLatitude()); - final boolean empty = rm.getRenderer().isLastMapRenderedEmpty(false); + final boolean empty = rm.getRenderer().isLastMapRenderedEmpty(tileBox.getZoom() < 12); noMapsPresent = empty; if (!empty && tileBox.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) { return Collections.emptyList();