Show status in activity
This commit is contained in:
parent
c8012c6431
commit
941dc8b522
10 changed files with 372 additions and 118 deletions
|
@ -7,7 +7,14 @@
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/osmo_status"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingLeft="6dp"
|
||||||
|
android:src="@drawable/mon_osmo_conn_small" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/motd"
|
android:id="@+id/motd"
|
||||||
android:layout_marginBottom="8dip"
|
android:layout_marginBottom="8dip"
|
||||||
|
|
|
@ -1,17 +1,63 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="3dp"
|
android:layout_width="fill_parent"
|
||||||
android:paddingRight="3dp" android:stretchColumns="1">
|
android:layout_height="wrap_content"
|
||||||
<TableRow >
|
android:paddingLeft="3dp"
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
|
android:paddingRight="3dp"
|
||||||
android:text="@string/osmo_connect_to_device_tracker_id"/>
|
android:stretchColumns="1" >
|
||||||
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="3dp"
|
|
||||||
android:id="@+id/TrackerId" android:inputType="textCapCharacters" android:selectAllOnFocus="true"/>
|
<TableRow>
|
||||||
</TableRow>
|
|
||||||
<TableRow>
|
<RadioGroup
|
||||||
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:text="@string/osmo_connect_to_device_name"/>
|
android:layout_height="wrap_content"
|
||||||
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="3dp"
|
android:layout_span="2" >
|
||||||
android:id="@+id/Name" android:inputType="textCapWords" />
|
|
||||||
</TableRow>
|
<RadioButton
|
||||||
</TableLayout>
|
android:id="@+id/ConnectToDevice"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_connect_to_device" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/ConnectToGroup"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_connect_to_group" />
|
||||||
|
</RadioGroup>
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/LabelTrackerId"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_connect_to_device_tracker_id" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/TrackerId"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textCapCharacters"
|
||||||
|
android:paddingLeft="3dp"
|
||||||
|
android:selectAllOnFocus="true" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/LabelName"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_connect_to_device_name" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/Name"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textCapWords"
|
||||||
|
android:paddingLeft="3dp" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
|
@ -6,7 +6,15 @@
|
||||||
android:layout_marginLeft="5dp"
|
android:layout_marginLeft="5dp"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/osmo_status"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:paddingLeft="6dp"
|
||||||
|
android:src="@drawable/mon_osmo_conn_small" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/motd"
|
android:id="@+id/motd"
|
||||||
android:layout_marginBottom="8dip"
|
android:layout_marginBottom="8dip"
|
||||||
|
|
|
@ -9,17 +9,22 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="osmo_connect_to_device_tracker_id">Tracker id</string>
|
||||||
|
<string name="osmo_connect_to_device_name">Device name</string>
|
||||||
|
<string name="osmo_connect_to_group_id">Group id</string>
|
||||||
|
<string name="osmo_connect_to_group_name">Group name</string>
|
||||||
|
<string name="osmo_connect_to_device">Device</string>
|
||||||
|
<string name="osmo_connect_to_group">Group</string>
|
||||||
|
<string name="osmo_connect">Connect to</string>
|
||||||
|
<string name="osmo_create_group">Create group</string>
|
||||||
|
<string name="osmo_server_operation_failed">OsMo Server operation failed</string>
|
||||||
<string name="osmo_activity">Osm Monitoring</string>
|
<string name="osmo_activity">Osm Monitoring</string>
|
||||||
<string name="osmo_enable_tracker">Send my locations</string>
|
<string name="osmo_enable_tracker">Send my locations</string>
|
||||||
<string name="osmo_control">OsMo quick access</string>
|
<string name="osmo_control">OsMo quick access</string>
|
||||||
<string name="hours_ago">hours ago</string>
|
<string name="hours_ago">hours ago</string>
|
||||||
<string name="minutes_ago">min ago</string>
|
<string name="minutes_ago">min ago</string>
|
||||||
<string name="seconds_ago">sec ago</string>
|
<string name="seconds_ago">sec ago</string>
|
||||||
<string name="osmo_connect_to_device_name">Name of device</string>
|
|
||||||
<string name="osmo_connect_to_device_tracker_id">Tracker id</string>
|
|
||||||
<string name="osmo_connect_to_device">Link with device</string>
|
<string name="osmo_connect_to_device">Link with device</string>
|
||||||
<string name="osmo_join_group">Join group</string>
|
|
||||||
<string name="osmo_new_device">Connect to device</string>
|
|
||||||
<string name="osmo_connected_devices">Connected devices</string>
|
<string name="osmo_connected_devices">Connected devices</string>
|
||||||
<string name="osmo_groups">OsMo Groups/Devices</string>
|
<string name="osmo_groups">OsMo Groups/Devices</string>
|
||||||
<string name="osmo_auto_send_locations_descr">Automatically start tracker session and send locations after application startup</string>
|
<string name="osmo_auto_send_locations_descr">Automatically start tracker session and send locations after application startup</string>
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
|
|
||||||
public interface OsMoGroupsUIListener {
|
public interface OsMoGroupsUIListener {
|
||||||
|
|
||||||
public void groupsListChange(String operation);
|
public void groupsListChange(String operation, OsMoGroup group);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsMoGroups(OsMoService service, OsMoTracker tracker, OsmandSettings settings) {
|
public OsMoGroups(OsMoService service, OsMoTracker tracker, OsmandSettings settings) {
|
||||||
|
@ -135,11 +135,12 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
public boolean acceptCommand(String command, String data, JSONObject obj, OsMoThread thread) {
|
public boolean acceptCommand(String command, String data, JSONObject obj, OsMoThread thread) {
|
||||||
boolean processed = false;
|
boolean processed = false;
|
||||||
String operation = command;
|
String operation = command;
|
||||||
|
OsMoGroup group = null;
|
||||||
if(command.startsWith("GROUP_CHANGE:")) {
|
if(command.startsWith("GROUP_CHANGE:")) {
|
||||||
String gid = command.substring(command.indexOf(':') + 1);
|
String gid = command.substring(command.indexOf(':') + 1);
|
||||||
OsMoGroup gr = storage.getGroup(gid);
|
group = storage.getGroup(gid);
|
||||||
if(gr != null) {
|
if(group != null) {
|
||||||
List<OsMoDevice> delta = mergeGroup(gr, obj, false);
|
List<OsMoDevice> delta = mergeGroup(group, obj, false);
|
||||||
for(OsMoDevice d :delta) {
|
for(OsMoDevice d :delta) {
|
||||||
if(d.getDeletedTimestamp() != 0 && d.isEnabled()) {
|
if(d.getDeletedTimestamp() != 0 && d.isEnabled()) {
|
||||||
disconnectImpl(d);
|
disconnectImpl(d);
|
||||||
|
@ -152,17 +153,17 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
processed = true;
|
processed = true;
|
||||||
} else if(command.startsWith("GROUP_DISCONNECT:")) {
|
} else if(command.startsWith("GROUP_DISCONNECT:")) {
|
||||||
String gid = command.substring(command.indexOf(':') + 1);
|
String gid = command.substring(command.indexOf(':') + 1);
|
||||||
OsMoGroup gr = storage.getGroup(gid);
|
group = storage.getGroup(gid);
|
||||||
if(gr != null) {
|
if(group != null) {
|
||||||
disconnectAllGroupUsers(gr);
|
disconnectAllGroupUsers(group);
|
||||||
}
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
} else if(command.startsWith("GROUP_CONNECT:")) {
|
} else if(command.startsWith("GROUP_CONNECT:")) {
|
||||||
String gid = command.substring(command.indexOf(':') + 1);
|
String gid = command.substring(command.indexOf(':') + 1);
|
||||||
OsMoGroup gr = storage.getGroup(gid);
|
group = storage.getGroup(gid);
|
||||||
if(gr != null) {
|
if(group != null) {
|
||||||
mergeGroup(gr, obj, true);
|
mergeGroup(group, obj, true);
|
||||||
gr.active = true;
|
group.active = true;
|
||||||
// connect to all devices in group
|
// connect to all devices in group
|
||||||
for(OsMoDevice d : storage.getMainGroup().getGroupUsers()) {
|
for(OsMoDevice d : storage.getMainGroup().getGroupUsers()) {
|
||||||
connectDeviceImpl(d);
|
connectDeviceImpl(d);
|
||||||
|
@ -170,32 +171,32 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
storage.save();
|
storage.save();
|
||||||
}
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
} else if(command.startsWith("GROUP_CREATE:") || command.startsWith("GROUP_JOIN:") ) {
|
} else if(command.startsWith("AGROUP_CREATE:") || command.startsWith("GROUP_JOIN:") ) {
|
||||||
if(command.startsWith("GROUP_CREATE:")) {
|
if(command.startsWith("AGROUP_CREATE:")) {
|
||||||
operation = "GROUP_CREATE";
|
operation = "AGROUP_CREATE";
|
||||||
}
|
}
|
||||||
String gid = command.substring(command.indexOf(':') + 1);
|
String gid = command.substring(command.indexOf(':') + 1);
|
||||||
OsMoGroup gr = storage.getGroup(gid);
|
group = storage.getGroup(gid);
|
||||||
if(gr == null) {
|
if(group == null) {
|
||||||
gr = new OsMoGroup();
|
group = new OsMoGroup();
|
||||||
gr.groupId = gid;
|
group.groupId = gid;
|
||||||
}
|
}
|
||||||
parseGroup(obj, gr);
|
parseGroup(obj, group);
|
||||||
connectGroupImpl(gr);
|
connectGroupImpl(group);
|
||||||
storage.save();
|
storage.save();
|
||||||
processed = true;
|
processed = true;
|
||||||
} else if(command.startsWith("LEAVE_GROUP:")) {
|
} else if(command.startsWith("LEAVE_GROUP:")) {
|
||||||
String gid = command.substring(command.indexOf(':') + 1);
|
String gid = command.substring(command.indexOf(':') + 1);
|
||||||
OsMoGroup gr = storage.getGroup(gid);
|
group = storage.getGroup(gid);
|
||||||
if(gr != null) {
|
if(group != null) {
|
||||||
disconnectAllGroupUsers(gr);
|
disconnectAllGroupUsers(group);
|
||||||
storage.deleteGroup(gr);
|
storage.deleteGroup(group);
|
||||||
storage.save();
|
storage.save();
|
||||||
}
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
if(processed && uiListener != null) {
|
if(processed && uiListener != null) {
|
||||||
uiListener.groupsListChange(operation);
|
uiListener.groupsListChange(operation, group);
|
||||||
}
|
}
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
@ -284,14 +285,21 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
obj.put("expireTime", expireTime);
|
obj.put("expireTime", expireTime);
|
||||||
obj.put("description", description);
|
obj.put("description", description);
|
||||||
obj.put("policy", policy);
|
obj.put("policy", policy);
|
||||||
service.pushCommand("GROUP_CREATE|" + obj.toString());
|
service.pushCommand("AGROUP_CREATE|" + obj.toString());
|
||||||
return "GROUP_CREATE";
|
return "AGROUP_CREATE";
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void deleteDevice(OsMoDevice device) {
|
||||||
|
storage.getMainGroup().users.remove(device.trackerId);
|
||||||
|
if(device.isEnabled()) {
|
||||||
|
disconnectImpl(device);
|
||||||
|
}
|
||||||
|
storage.save();
|
||||||
|
}
|
||||||
|
|
||||||
public OsMoDevice addConnectedDevice(String trackerId, String nameUser, int userColor) {
|
public OsMoDevice addConnectedDevice(String trackerId, String nameUser, int userColor) {
|
||||||
OsMoDevice us = new OsMoDevice();
|
OsMoDevice us = new OsMoDevice();
|
||||||
|
@ -322,7 +330,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
service.pushCommand(op);
|
service.pushCommand(op);
|
||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,9 @@ import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -25,10 +22,12 @@ import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
import net.osmand.plus.activities.OsmandExpandableListActivity;
|
import net.osmand.plus.activities.OsmandExpandableListActivity;
|
||||||
import net.osmand.plus.osmo.OsMoGroups.OsMoGroup;
|
import net.osmand.plus.osmo.OsMoGroups.OsMoGroupsUIListener;
|
||||||
import net.osmand.plus.osmo.OsMoGroups.OsMoUser;
|
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
|
||||||
|
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoGroup;
|
||||||
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
||||||
import net.osmand.plus.osmo.OsMoTracker.OsmoTrackerListener;
|
import net.osmand.plus.osmo.OsMoTracker.OsmoTrackerListener;
|
||||||
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -38,9 +37,9 @@ import android.graphics.Canvas;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Typeface;
|
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -52,30 +51,30 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ExpandableListView;
|
import android.widget.ExpandableListView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RadioButton;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.ActionMode;
|
import com.actionbarsherlock.view.ActionMode;
|
||||||
|
import com.actionbarsherlock.view.ActionMode.Callback;
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
import com.actionbarsherlock.view.Window;
|
import com.actionbarsherlock.view.Window;
|
||||||
import com.actionbarsherlock.view.ActionMode.Callback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OsMoGroupsActivity extends OsmandExpandableListActivity implements OsmAndCompassListener,
|
public class OsMoGroupsActivity extends OsmandExpandableListActivity implements OsmAndCompassListener,
|
||||||
OsmAndLocationListener, OsmoTrackerListener {
|
OsmAndLocationListener, OsmoTrackerListener, OsMoGroupsUIListener {
|
||||||
|
|
||||||
public static final int CONNECT_TO_DEVICE = 1;
|
public static final int CONNECT_TO = 1;
|
||||||
protected static final int DELETE_ACTION_ID = 2;
|
protected static final int DELETE_ACTION_ID = 2;
|
||||||
public static final int CREATE_GROUP = 3;
|
public static final int CREATE_GROUP = 3;
|
||||||
public static final int JOIN_GROUP = 4;
|
|
||||||
private static final int LIST_REFRESH_MSG_ID = OsmAndConstants.UI_HANDLER_SEARCH + 30;
|
private static final int LIST_REFRESH_MSG_ID = OsmAndConstants.UI_HANDLER_SEARCH + 30;
|
||||||
private static final long RECENT_THRESHOLD = 60000;
|
private static final long RECENT_THRESHOLD = 60000;
|
||||||
|
|
||||||
|
@ -91,8 +90,8 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
private float lastCompass;
|
private float lastCompass;
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private boolean selectionMode;
|
private Object selectedObject = null;
|
||||||
private Set<OsMoDevice> selectedObjects = new HashSet<OsMoGroups.OsMoDevice>();
|
private String operation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle icicle) {
|
public void onCreate(Bundle icicle) {
|
||||||
|
@ -124,6 +123,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
} else {
|
} else {
|
||||||
osMoPlugin.getTracker().disableTracker();
|
osMoPlugin.getTracker().disableTracker();
|
||||||
}
|
}
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TextView mtd = (TextView) findViewById(R.id.motd);
|
TextView mtd = (TextView) findViewById(R.id.motd);
|
||||||
|
@ -133,6 +133,49 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
if(visible) {
|
if(visible) {
|
||||||
mtd.setText(si.motd);
|
mtd.setText(si.motd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
long lastUpdateTime;
|
||||||
|
private Drawable blinkImg;
|
||||||
|
private void blink(final ImageView status, Drawable bigger, final Drawable smaller ) {
|
||||||
|
blinkImg = smaller;
|
||||||
|
status.setImageDrawable(bigger);
|
||||||
|
status.invalidate();
|
||||||
|
uiHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
blinkImg = null;
|
||||||
|
status.setImageDrawable(smaller);
|
||||||
|
status.invalidate();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatus() {
|
||||||
|
ImageView status = (ImageView) findViewById(R.id.osmo_status);
|
||||||
|
final Drawable srcSmall = getResources().getDrawable(R.drawable.mon_osmo_conn_small);
|
||||||
|
final Drawable srcSignalSmall = getResources().getDrawable(R.drawable.mon_osmo_conn_signal_small);
|
||||||
|
final Drawable srcBig = getResources().getDrawable(R.drawable.mon_osmo_conn_big);
|
||||||
|
final Drawable srcSignalBig = getResources().getDrawable(R.drawable.mon_osmo_conn_signal_big);
|
||||||
|
final Drawable srcinactive = getResources().getDrawable(R.drawable.monitoring_rec_inactive);
|
||||||
|
Drawable small = srcinactive;
|
||||||
|
Drawable big = srcinactive;
|
||||||
|
OsMoService service = osMoPlugin.getService();
|
||||||
|
OsMoTracker tracker = osMoPlugin.getTracker();
|
||||||
|
long last = service.getLastCommandTime();
|
||||||
|
if (service.isActive()) {
|
||||||
|
small = tracker.isEnabledTracker() ? srcSignalSmall : srcSmall;
|
||||||
|
big = tracker.isEnabledTracker() ? srcSignalBig : srcBig;
|
||||||
|
}
|
||||||
|
if (blinkImg != small) {
|
||||||
|
status.setImageDrawable(small);
|
||||||
|
}
|
||||||
|
if (last != lastUpdateTime) {
|
||||||
|
lastUpdateTime = last;
|
||||||
|
blink(status, big, small);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path createDirectionPath() {
|
private Path createDirectionPath() {
|
||||||
|
@ -183,11 +226,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
osMoPlugin.getTracker().setUITrackerListener(null);
|
osMoPlugin.getTracker().setUITrackerListener(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enterSelectionMode() {
|
private void enterSelectionMode(final Object o) {
|
||||||
actionMode = startActionMode(new Callback() {
|
actionMode = startActionMode(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
selectionMode = true;
|
selectedObject = o;
|
||||||
createMenuItem(menu, DELETE_ACTION_ID, R.string.default_buttons_delete, R.drawable.ic_action_delete_light, R.drawable.ic_action_delete_dark,
|
createMenuItem(menu, DELETE_ACTION_ID, R.string.default_buttons_delete, R.drawable.ic_action_delete_light, R.drawable.ic_action_delete_dark,
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
return true;
|
return true;
|
||||||
|
@ -200,12 +243,27 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyActionMode(ActionMode mode) {
|
public void onDestroyActionMode(ActionMode mode) {
|
||||||
selectionMode = false;
|
selectedObject = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||||
if(item.getItemId() == DELETE_ACTION_ID) {
|
if(item.getItemId() == DELETE_ACTION_ID ) {
|
||||||
|
Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this);
|
||||||
|
String name = (selectedObject instanceof OsMoDevice)? ((OsMoDevice) selectedObject).getVisibleName() :
|
||||||
|
((OsMoGroup) selectedObject).getVisibleName(OsMoGroupsActivity.this);
|
||||||
|
bld.setTitle(getString(R.string.delete_confirmation_msg, name));
|
||||||
|
bld.setPositiveButton(R.string .default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
Object obj = selectedObject;
|
||||||
|
quitSelectionMode();
|
||||||
|
deleteObject(obj);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.setNegativeButton(R.string.default_buttons_no, null);
|
||||||
|
bld.show();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -213,42 +271,99 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void deleteObject(Object selectedObject) {
|
||||||
|
if(selectedObject instanceof OsMoDevice) {
|
||||||
|
OsMoDevice d = (OsMoDevice)selectedObject;
|
||||||
|
osMoPlugin.getGroups().deleteDevice(d);
|
||||||
|
adapter.update(d.getGroup());
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
} else {
|
||||||
|
if (checkOperationIsNotRunning()) {
|
||||||
|
String operation = osMoPlugin.getGroups().leaveGroup((OsMoGroup) selectedObject);
|
||||||
|
startLongRunningOperation(operation);
|
||||||
|
}
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
if (!selectionMode) {
|
|
||||||
enterSelectionMode();
|
|
||||||
}
|
|
||||||
OsMoDevice user = adapter.getChild(groupPosition, childPosition);
|
OsMoDevice user = adapter.getChild(groupPosition, childPosition);
|
||||||
selectedObjects.add(user);
|
if (user != selectedObject) {
|
||||||
|
enterSelectionMode(user);
|
||||||
|
} else {
|
||||||
|
quitSelectionMode();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void quitSelectionMode() {
|
||||||
|
selectedObject = null;
|
||||||
|
actionMode.finish();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||||
if (item.getItemId() == CONNECT_TO_DEVICE) {
|
if (item.getItemId() == CONNECT_TO) {
|
||||||
connectToDevice();
|
connectToDevice();
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getItemId() == JOIN_GROUP) {
|
} else if (item.getItemId() == CREATE_GROUP) {
|
||||||
// shareFavourites();
|
createGroup();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createGroup() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void connectToDevice() {
|
private void connectToDevice() {
|
||||||
Builder builder = new AlertDialog.Builder(this);
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.osmo_connect_to_device);
|
builder.setTitle(R.string.osmo_connect_to_device);
|
||||||
final View v = getLayoutInflater().inflate(R.layout.osmo_connect_to_device, getExpandableListView(), false);
|
final View v = getLayoutInflater().inflate(R.layout.osmo_connect_to_device, getExpandableListView(), false);
|
||||||
|
final RadioButton device = (RadioButton) v.findViewById(R.id.ConnectToDevice);
|
||||||
|
//final RadioButton group = (RadioButton) v.findViewById(R.id.ConnectToGroup);
|
||||||
|
final TextView labelTracker = (TextView ) v.findViewById(R.id.LabelTrackerId);
|
||||||
|
final TextView labelName = (TextView ) v.findViewById(R.id.LabelName);
|
||||||
final EditText tracker = (EditText) v.findViewById(R.id.TrackerId);
|
final EditText tracker = (EditText) v.findViewById(R.id.TrackerId);
|
||||||
final EditText name = (EditText) v.findViewById(R.id.Name);
|
final EditText name = (EditText) v.findViewById(R.id.Name);
|
||||||
|
device.setChecked(true);
|
||||||
|
device.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if(isChecked) {
|
||||||
|
labelTracker.setText(R.string.osmo_connect_to_device_tracker_id);
|
||||||
|
labelName.setText(R.string.osmo_connect_to_device_name);
|
||||||
|
} else {
|
||||||
|
labelTracker.setText(R.string.osmo_connect_to_group_id);
|
||||||
|
labelName.setText(R.string.osmo_connect_to_group_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
builder.setView(v);
|
builder.setView(v);
|
||||||
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(R.string.default_buttons_apply, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String nameUser = name.getText().toString();
|
final String nameUser = name.getText().toString();
|
||||||
adapter.registerUser(tracker.getText().toString(), nameUser);
|
final String id = tracker.getText().toString();
|
||||||
|
if(device.isChecked()) {
|
||||||
|
OsMoDevice dev = osMoPlugin.getGroups().addConnectedDevice(id, nameUser, 0);
|
||||||
|
adapter.update(dev.group);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
} else {
|
||||||
|
if(!checkOperationIsNotRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String op = osMoPlugin.getGroups().joinGroup(id, nameUser);
|
||||||
|
startLongRunningOperation(op);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
|
@ -257,25 +372,62 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
|
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
|
||||||
createMenuItem(menu, CONNECT_TO_DEVICE, R.string.osmo_new_device, R.drawable.ic_action_marker_light,
|
createMenuItem(menu, CONNECT_TO, R.string.osmo_connect,
|
||||||
R.drawable.ic_action_marker_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
0, 0,/*R.drawable.ic_action_marker_light,*/
|
||||||
createMenuItem(menu, JOIN_GROUP, R.string.osmo_join_group, R.drawable.ic_action_markers_light,
|
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
R.drawable.ic_action_markers_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
createMenuItem(menu, CREATE_GROUP, R.string.osmo_create_group,
|
||||||
|
0, 0,/*R.drawable.ic_action_marker_light,*/
|
||||||
|
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showProgressBar() {
|
public void startLongRunningOperation(String operation) {
|
||||||
|
this.operation = operation;
|
||||||
setSupportProgressBarIndeterminateVisibility(true);
|
setSupportProgressBarIndeterminateVisibility(true);
|
||||||
|
uiHandler.postDelayed(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(OsMoGroupsActivity.this, R.string.osmo_server_operation_failed, Toast.LENGTH_LONG).show();
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
}, 15000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideProgressBar() {
|
public void hideProgressBar() {
|
||||||
|
OsMoGroupsActivity.this.operation = null;
|
||||||
setSupportProgressBarIndeterminateVisibility(false);
|
setSupportProgressBarIndeterminateVisibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void groupsListChange(final String operation, final OsMoGroup group) {
|
||||||
|
uiHandler.post(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String top = OsMoGroupsActivity.this.operation;
|
||||||
|
if(operation == top || (operation != null && operation.equals(top))) {
|
||||||
|
hideProgressBar();
|
||||||
|
}
|
||||||
|
adapter.update(group);
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
updateStatus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkOperationIsNotRunning() {
|
||||||
|
if(operation != null) {
|
||||||
|
Toast.makeText(this, R.string.wait_current_task_finished, Toast.LENGTH_SHORT).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
class OsMoGroupsAdapter extends OsmandBaseExpandableListAdapter {
|
class OsMoGroupsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
private List<OsMoGroup> sortedGroups = new ArrayList<OsMoGroups.OsMoGroup>();
|
private List<OsMoGroup> sortedGroups = new ArrayList<OsMoGroup>();
|
||||||
private Map<OsMoGroup, List<OsMoDevice>> users = new LinkedHashMap<OsMoGroups.OsMoGroup, List<OsMoDevice>>();
|
private Map<OsMoGroup, List<OsMoDevice>> users = new LinkedHashMap<OsMoGroup, List<OsMoDevice>>();
|
||||||
private OsMoGroups grs;
|
private OsMoGroups grs;
|
||||||
private OsMoTracker tracker;
|
private OsMoTracker tracker;
|
||||||
|
|
||||||
|
@ -285,43 +437,38 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
synchronizeGroups();
|
synchronizeGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerUser(String trackerId, String nameUser) {
|
public void update(OsMoGroup group) {
|
||||||
addUser(grs.registerUser(trackerId, nameUser));
|
if(group.isDeleted()) {
|
||||||
}
|
sortedGroups.remove(group);
|
||||||
|
users.remove(group);
|
||||||
|
} else {
|
||||||
|
List<OsMoDevice> us = !group.isEnabled() && !group.isMainGroup() ? new ArrayList<OsMoDevice>(0) : group.getGroupUsers();
|
||||||
|
final Collator ci = Collator.getInstance();
|
||||||
|
Collections.sort(us, new Comparator<OsMoDevice>() {
|
||||||
|
|
||||||
public void sort(Comparator<OsMoDevice> comparator) {
|
@Override
|
||||||
for (List<OsMoDevice> ps : users.values()) {
|
public int compare(OsMoDevice lhs, OsMoDevice rhs) {
|
||||||
Collections.sort(ps, comparator);
|
return ci.compare(lhs.getVisibleName(), rhs.getVisibleName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
users.put(group, us);
|
||||||
|
if(!sortedGroups.contains(group)) {
|
||||||
|
sortedGroups.add(group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addUser(OsMoDevice p) {
|
|
||||||
if (!users.containsKey(p.getGroup())) {
|
|
||||||
users.put(p.getGroup(), new ArrayList<OsMoDevice>());
|
|
||||||
sortedGroups.add(p.getGroup());
|
|
||||||
}
|
|
||||||
users.get(p.getGroup()).add(p);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void synchronizeGroups() {
|
public void synchronizeGroups() {
|
||||||
users.clear();
|
users.clear();
|
||||||
sortedGroups.clear();
|
sortedGroups.clear();
|
||||||
final Collator clt = Collator.getInstance();
|
final Collator clt = Collator.getInstance();
|
||||||
for (OsMoGroup key : grs.getGroups().values()) {
|
for (OsMoGroup key : grs.getGroups()) {
|
||||||
sortedGroups.add(key);
|
sortedGroups.add(key);
|
||||||
final ArrayList<OsMoDevice> list = new ArrayList<OsMoDevice>(key.users.values());
|
update(key);
|
||||||
Collections.sort(list, new Comparator<OsMoGroups.OsMoDevice>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(OsMoDevice lhs, OsMoDevice rhs) {
|
|
||||||
return clt.compare(lhs.getVisibleName(), rhs.getVisibleName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
users.put(key, list);
|
|
||||||
}
|
}
|
||||||
Collections.sort(sortedGroups, new Comparator<OsMoGroups.OsMoGroup>() {
|
Collections.sort(sortedGroups, new Comparator<OsMoGroup>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(OsMoGroup lhs, OsMoGroup rhs) {
|
public int compare(OsMoGroup lhs, OsMoGroup rhs) {
|
||||||
if (lhs.isMainGroup()) {
|
if (lhs.isMainGroup()) {
|
||||||
|
@ -398,13 +545,24 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
ch.setVisibility(model.isMainGroup() ? View.INVISIBLE : View.VISIBLE);
|
ch.setVisibility(model.isMainGroup() ? View.INVISIBLE : View.VISIBLE);
|
||||||
ch.setChecked(model.enabled);
|
ch.setChecked(model.enabled);
|
||||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
boolean revert = false;
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if(revert) {
|
||||||
|
revert = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(checkOperationIsNotRunning()) {
|
||||||
|
revert = true;
|
||||||
|
ch.setChecked(!isChecked);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(isChecked) {
|
if(isChecked) {
|
||||||
osMoPlugin.getGroups().connectGroup(model);
|
String operation = osMoPlugin.getGroups().connectGroup(model);
|
||||||
|
startLongRunningOperation(operation);
|
||||||
} else {
|
} else {
|
||||||
osMoPlugin.getGroups().disconnectGroup(model);
|
String operation = osMoPlugin.getGroups().disconnectGroup(model);
|
||||||
|
startLongRunningOperation(operation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -446,7 +604,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
|
|
||||||
|
|
||||||
LatLon lnLocation = mapLocation;
|
LatLon lnLocation = mapLocation;
|
||||||
Location location = tracker.getLastLocation(model.trackerId);
|
Location location = model.getLastLocation();
|
||||||
|
if(model.getTrackerId().equals(osMoPlugin.getService().getMyGroupTrackerId())) {
|
||||||
|
location = tracker.getLastSendLocation();
|
||||||
|
}
|
||||||
|
//Location location = tracker.getLastLocation(model.trackerId);
|
||||||
if (location == null || lnLocation == null) {
|
if (location == null || lnLocation == null) {
|
||||||
icon.setImageResource(R.drawable.list_favorite);
|
icon.setImageResource(R.drawable.list_favorite);
|
||||||
label.setText(model.getVisibleName());
|
label.setText(model.getVisibleName());
|
||||||
|
@ -505,6 +667,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
updateStatus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
msg.what = LIST_REFRESH_MSG_ID;
|
msg.what = LIST_REFRESH_MSG_ID;
|
||||||
|
@ -564,4 +727,5 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,6 +203,7 @@ public class OsMoGroupsStorage {
|
||||||
protected boolean enabled;
|
protected boolean enabled;
|
||||||
protected long expireTime;
|
protected long expireTime;
|
||||||
protected boolean active;
|
protected boolean active;
|
||||||
|
protected boolean deleted;
|
||||||
|
|
||||||
protected Map<String, OsMoDevice> users = new ConcurrentHashMap<String, OsMoDevice>();
|
protected Map<String, OsMoDevice> users = new ConcurrentHashMap<String, OsMoDevice>();
|
||||||
|
|
||||||
|
@ -217,6 +218,10 @@ public class OsMoGroupsStorage {
|
||||||
return dvs;
|
return dvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeleted() {
|
||||||
|
return deleted;
|
||||||
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
@ -370,10 +375,12 @@ public class OsMoGroupsStorage {
|
||||||
|
|
||||||
public void deleteGroup(OsMoGroup gr) {
|
public void deleteGroup(OsMoGroup gr) {
|
||||||
groups.remove(gr.groupId);
|
groups.remove(gr.groupId);
|
||||||
|
gr.deleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGroup(OsMoGroup g) {
|
public void addGroup(OsMoGroup g) {
|
||||||
groups.put(g.groupId, g);
|
groups.put(g.groupId, g);
|
||||||
|
g.deleted = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,10 +37,6 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
||||||
public OsMoPlugin(final OsmandApplication app) {
|
public OsMoPlugin(final OsmandApplication app) {
|
||||||
service = new OsMoService(app);
|
service = new OsMoService(app);
|
||||||
tracker = new OsMoTracker(service);
|
tracker = new OsMoTracker(service);
|
||||||
if(app.getSettings().OSMO_AUTO_SEND_LOCATIONS.get()) {
|
|
||||||
tracker.enableTracker();
|
|
||||||
}
|
|
||||||
groups = new OsMoGroups(service, tracker, app.getSettings());
|
|
||||||
this.app = app;
|
this.app = app;
|
||||||
ApplicationMode.regWidget("osmo_control", (ApplicationMode[])null);
|
ApplicationMode.regWidget("osmo_control", (ApplicationMode[])null);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +44,10 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
||||||
@Override
|
@Override
|
||||||
public boolean init(final OsmandApplication app) {
|
public boolean init(final OsmandApplication app) {
|
||||||
service.connect(true);
|
service.connect(true);
|
||||||
|
if(app.getSettings().OSMO_AUTO_SEND_LOCATIONS.get()) {
|
||||||
|
tracker.enableTracker();
|
||||||
|
}
|
||||||
|
groups = new OsMoGroups(service, tracker, app.getSettings());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.http.message.BasicNameValuePair;
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -243,6 +244,13 @@ public class OsMoService implements OsMoSender, OsMoReactor {
|
||||||
if(command.equals("MOTD")) {
|
if(command.equals("MOTD")) {
|
||||||
SessionInfo si = getCurrentSessionInfo();
|
SessionInfo si = getCurrentSessionInfo();
|
||||||
if(si != null) {
|
if(si != null) {
|
||||||
|
if(data.startsWith("[")){
|
||||||
|
try {
|
||||||
|
data = new JSONArray(data).getString(0);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
si.motd = data;
|
si.motd = data;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -256,7 +257,7 @@ public class OsMoThread {
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
if(obj != null && obj.has("error")) {
|
if(obj != null && obj.has("error")) {
|
||||||
error = true;
|
error = true;
|
||||||
|
|
Loading…
Reference in a new issue