From 9c8007e09772f0dcb16fbf68e4e90975acda923f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 23 Nov 2014 16:31:25 +0100 Subject: [PATCH 1/2] Small refactoring --- OsmAnd/src/net/osmand/plus/osmo/OsMoControlDevice.java | 1 - OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoControlDevice.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoControlDevice.java index 882a55cd21..3d2b6215db 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoControlDevice.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoControlDevice.java @@ -33,7 +33,6 @@ public class OsMoControlDevice implements OsMoReactor { this.plugin = plugin; this.service = service; this.tracker = tracker; - service.registerReactor(this); } public JSONObject getBatteryLevel() throws JSONException { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 904e3de1fd..7d86e32d1d 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -62,6 +62,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer private OsMoPositionLayer olayer; protected MapActivity mapActivity; protected OsMoGroupsActivity groupsActivity; + protected OsMoControlDevice deviceControl; private final static Log log = PlatformUtil.getLog(OsMoPlugin.class); @@ -71,7 +72,7 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer service = new OsMoService(app, this); tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL, app.getSettings().OSMO_AUTO_SEND_LOCATIONS); - new OsMoControlDevice(app, this, service, tracker); + deviceControl = new OsMoControlDevice(app, this, service, tracker); groups = new OsMoGroups(this, service, tracker, app); ApplicationMode.regWidget("osmo_control", (ApplicationMode[])null); } From 171bde44c8658bd730ea992ceb2ba80cb76cefb6 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 23 Nov 2014 17:05:58 +0100 Subject: [PATCH 2/2] Fix issue not remember state of group (small issue on server left) --- OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java | 10 ++++++---- OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsStorage.java | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java index 505988115d..986807c434 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroups.java @@ -26,6 +26,7 @@ import android.text.TextUtils; public class OsMoGroups implements OsMoReactor, OsmoTrackerListener { private static final String GROUP_NAME = "name"; + private static final String ACTIVE = "active"; private static final String GROUP_ID = "group_id"; private static final String EXPIRE_TIME = "expireTime"; private static final String DESCRIPTION = "description"; @@ -250,14 +251,14 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener { JSONArray arr = new JSONArray(data); int arrLength = arr.length(); if (arrLength > 0) { - Map resivedGroups = new HashMap(); + Map receivedGroups = new HashMap(); for (int i = 0; i < arrLength; i++) { JSONObject o = arr.getJSONObject(i); OsMoGroup parsedGroup = parseGroup(o); - resivedGroups.put(parsedGroup.getGroupId(), parsedGroup); + receivedGroups.put(parsedGroup.getGroupId(), parsedGroup); } - storage.mergeGroups(resivedGroups); + storage.mergeGroups(receivedGroups); storage.save(); } processed = true; @@ -360,7 +361,8 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener { private OsMoGroup parseGroup(JSONObject obj) throws JSONException { OsMoGroup groupe = new OsMoGroup(); - groupe.enabled = true; + groupe.enabled = !(obj.has(ACTIVE) && ("0".equals(obj.getString(ACTIVE)) || + "false".equals(obj.getString(ACTIVE)))); groupe.name = obj.optString(GROUP_NAME); groupe.groupId = obj.getString(GROUP_ID); groupe.description = obj.optString(DESCRIPTION); diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsStorage.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsStorage.java index b7fc60c071..1262bd3f6f 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsStorage.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsStorage.java @@ -73,7 +73,6 @@ public class OsMoGroupsStorage { public void load() { String grp = pref.get(); try { - System.out.println("DEBUG : OsMo groups load info " + grp); JSONObject obj = new JSONObject(grp); parseGroupUsers(mainGroup, obj); if(!obj.has(GROUPS)) {