Fix groups
This commit is contained in:
parent
b15bdbca5f
commit
c61503a43a
4 changed files with 34 additions and 16 deletions
|
@ -333,6 +333,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
storage.save();
|
storage.save();
|
||||||
service.pushCommand(op);
|
service.pushCommand(op);
|
||||||
if(group.isEnabled()) {
|
if(group.isEnabled()) {
|
||||||
|
group.enabled = false;
|
||||||
disconnectAllGroupUsers(group);
|
disconnectAllGroupUsers(group);
|
||||||
}
|
}
|
||||||
return op;
|
return op;
|
||||||
|
|
|
@ -327,8 +327,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
selectedObject = o;
|
selectedObject = o;
|
||||||
device = (OsMoDevice) (o instanceof OsMoDevice ?o : null);
|
device = (OsMoDevice) (o instanceof OsMoDevice ?o : null);
|
||||||
group = (OsMoGroup) (o instanceof OsMoGroup ?o : null);
|
group = (OsMoGroup) (o instanceof OsMoGroup ?o : null);
|
||||||
MenuItem mi = createMenuItem(menu, ON_OFF_ACTION_ID, R.string.default_buttons_ok, 0, 0,
|
MenuItem mi = null;
|
||||||
MenuItem.SHOW_AS_ACTION_ALWAYS);
|
if(device == null || device.getGroup().isMainGroup()) {
|
||||||
|
mi = createMenuItem(menu, ON_OFF_ACTION_ID, R.string.default_buttons_ok, 0, 0,
|
||||||
|
MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
}
|
||||||
if(device != null && device.getLastLocation() != null) {
|
if(device != null && device.getLastLocation() != null) {
|
||||||
createMenuItem(menu, SHOW_ON_MAP_ID, R.string.show_poi_on_map, R.drawable.ic_action_marker_light, R.drawable.ic_action_marker_dark,
|
createMenuItem(menu, SHOW_ON_MAP_ID, R.string.show_poi_on_map, R.drawable.ic_action_marker_light, R.drawable.ic_action_marker_dark,
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
@ -351,19 +354,20 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||||
|
|
||||||
|
|
||||||
|
if (mi != null) {
|
||||||
|
final LayoutInflater inflater = LayoutInflater.from(OsMoGroupsActivity.this);
|
||||||
|
View view = inflater.inflate(R.layout.check_item_rel, null);
|
||||||
|
final CompoundButton check = (CompoundButton) view.findViewById(R.id.check_item);
|
||||||
|
check.setChecked((device != null && device.isEnabled()) || (group != null && group.isEnabled()));
|
||||||
|
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
final LayoutInflater inflater = LayoutInflater.from(OsMoGroupsActivity.this);
|
@Override
|
||||||
View view = inflater.inflate(R.layout.check_item_rel, null);
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
final CompoundButton check = (CompoundButton) view.findViewById(R.id.check_item);
|
onOffAction(check);
|
||||||
check.setChecked((device != null && device.isEnabled()) || (group != null && group.isEnabled()));
|
}
|
||||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
});
|
||||||
|
mi.setActionView(view);
|
||||||
@Override
|
}
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
onOffAction(check);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mi.setActionView(view);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,7 +747,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
sortedGroups.remove(group);
|
sortedGroups.remove(group);
|
||||||
users.remove(group);
|
users.remove(group);
|
||||||
} else {
|
} else {
|
||||||
List<OsMoDevice> us = !group.isEnabled() && !group.isMainGroup() ? new ArrayList<OsMoDevice>(0) : group.getGroupUsers();
|
List<OsMoDevice> us = !group.isEnabled() && !group.isMainGroup() ? new ArrayList<OsMoDevice>(0) : group.getVisibleGroupUsers();
|
||||||
final Collator ci = Collator.getInstance();
|
final Collator ci = Collator.getInstance();
|
||||||
Collections.sort(us, new Comparator<OsMoDevice>() {
|
Collections.sort(us, new Comparator<OsMoDevice>() {
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.osmo;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -218,6 +219,13 @@ public class OsMoGroupsStorage {
|
||||||
return dvs;
|
return dvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<OsMoDevice> getVisibleGroupUsers() {
|
||||||
|
if(!isActive()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return getGroupUsers();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isDeleted() {
|
public boolean isDeleted() {
|
||||||
return deleted;
|
return deleted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package net.osmand.plus.osmo;
|
package net.osmand.plus.osmo;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||||
|
@ -35,6 +37,9 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
|
||||||
private OsMoGroups groups;
|
private OsMoGroups groups;
|
||||||
private BaseMapWidget osmoControl;
|
private BaseMapWidget osmoControl;
|
||||||
|
|
||||||
|
// 2014-05-27 23:11:40
|
||||||
|
public static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
public OsMoPlugin(final OsmandApplication app) {
|
public OsMoPlugin(final OsmandApplication app) {
|
||||||
service = new OsMoService(app);
|
service = new OsMoService(app);
|
||||||
tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL);
|
tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL);
|
||||||
|
|
Loading…
Reference in a new issue