Update groups
This commit is contained in:
parent
3a28293fe1
commit
bcb97289d0
13 changed files with 141 additions and 74 deletions
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_big.png
Normal file
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_big.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.5 KiB |
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_signal_big.png
Normal file
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_signal_big.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4 KiB |
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_signal_small.png
Normal file
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_signal_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_small.png
Normal file
BIN
OsmAnd/res/drawable-large/mon_osmo_conn_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 558 B |
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical" >
|
||||
|
@ -9,7 +9,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone" />
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -1,15 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical" >
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/check_item"
|
||||
android:text="@string/osmo_connect_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical"
|
||||
android:visibility="gone" />
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
|
@ -44,6 +44,7 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="3dp" />
|
||||
</TableRow>
|
||||
<TableRow>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -58,6 +59,6 @@
|
|||
android:paddingLeft="3dp" />
|
||||
</TableRow>
|
||||
|
||||
</TableRow>
|
||||
|
||||
|
||||
</TableLayout>
|
|
@ -8,7 +8,6 @@
|
|||
android:paddingRight="4dp"
|
||||
android:paddingTop="5dp" >
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/explist_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -20,13 +19,29 @@
|
|||
<TextView
|
||||
android:id="@+id/category_name"
|
||||
style="@style/ListText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:textSize="18sp">
|
||||
android:layout_weight="1"
|
||||
android:textSize="18sp" >
|
||||
</TextView>
|
||||
|
||||
<include layout="@layout/check_item"/>
|
||||
|
||||
<!--
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical" >
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/check_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical" />
|
||||
</RelativeLayout>
|
||||
-->
|
||||
|
||||
</LinearLayout>
|
|
@ -24,6 +24,6 @@
|
|||
android:maxLines="7"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<include layout="@layout/check_item" />
|
||||
<!-- <include layout="@layout/check_item" /> -->
|
||||
|
||||
</LinearLayout>
|
|
@ -10,6 +10,7 @@
|
|||
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="int_days">days</string>
|
||||
<string name="osmo_connect_menu">Connect</string>
|
||||
<string name="osmo_expire_group">Expires in</string>
|
||||
<string name="osmo_group_description">Description</string>
|
||||
<string name="osmo_group_policy">Policy</string>
|
||||
|
@ -17,8 +18,8 @@
|
|||
<string name="osmo_connect_to_device_name">Device name</string>
|
||||
<string name="osmo_connect_to_group_id">Group id</string>
|
||||
<string name="osmo_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_to_device">Link with device</string>
|
||||
<string name="osmo_connect_to_group">Link with 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>
|
||||
|
@ -28,7 +29,6 @@
|
|||
<string name="hours_ago">hours ago</string>
|
||||
<string name="minutes_ago">min ago</string>
|
||||
<string name="seconds_ago">sec ago</string>
|
||||
<string name="osmo_connect_to_device">Link with device</string>
|
||||
<string name="osmo_connected_devices">Connected 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>
|
||||
|
|
|
@ -189,6 +189,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
if(group == null) {
|
||||
group = new OsMoGroup();
|
||||
group.groupId = gid;
|
||||
storage.addGroup(group);
|
||||
}
|
||||
parseGroup(obj, group);
|
||||
connectGroupImpl(group);
|
||||
|
@ -336,6 +337,7 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
|||
|
||||
public String leaveGroup(OsMoGroup group) {
|
||||
final String op = "GROUP_LEAVE:"+group.groupId;
|
||||
storage.deleteGroup(group);
|
||||
service.pushCommand(op);
|
||||
return op;
|
||||
}
|
||||
|
|
|
@ -56,8 +56,10 @@ import android.view.WindowManager;
|
|||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.OnGroupClickListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
|
@ -79,6 +81,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
public static final int CONNECT_TO = 1;
|
||||
protected static final int DELETE_ACTION_ID = 2;
|
||||
public static final int CREATE_GROUP = 3;
|
||||
protected static final int ON_OFF_ACTION_ID = 4;
|
||||
private static final int LIST_REFRESH_MSG_ID = OsmAndConstants.UI_HANDLER_SEARCH + 30;
|
||||
private static final long RECENT_THRESHOLD = 60000;
|
||||
|
||||
|
@ -139,6 +142,34 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -218,6 +249,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
app.getLocationProvider().addLocationListener(this);
|
||||
app.getLocationProvider().resumeAllUpdates();
|
||||
osMoPlugin.getTracker().setUITrackerListener(this);
|
||||
osMoPlugin.getGroups().setUiListener(this);
|
||||
adapter.synchronizeGroups();
|
||||
}
|
||||
|
||||
|
@ -228,15 +260,35 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
app.getLocationProvider().removeCompassListener(this);
|
||||
app.getLocationProvider().removeLocationListener(this);
|
||||
osMoPlugin.getTracker().setUITrackerListener(null);
|
||||
osMoPlugin.getGroups().setUiListener(null);
|
||||
}
|
||||
|
||||
private void enterSelectionMode(final Object o) {
|
||||
if(!checkOperationIsNotRunning()) {
|
||||
return;
|
||||
}
|
||||
actionMode = startActionMode(new Callback() {
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
selectedObject = o;
|
||||
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 mi = createMenuItem(menu, ON_OFF_ACTION_ID, R.string.default_buttons_ok, 0, 0,
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
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(o instanceof OsMoDevice ?
|
||||
((OsMoDevice) o).isEnabled() : ((OsMoGroup) o).isEnabled());
|
||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
onOffAction(check);
|
||||
}
|
||||
});
|
||||
mi.setActionView(view);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -268,9 +320,33 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
});
|
||||
bld.setNegativeButton(R.string.default_buttons_no, null);
|
||||
bld.show();
|
||||
} else if(item.getItemId() == ON_OFF_ACTION_ID) {
|
||||
CompoundButton bt = ((CompoundButton) item.getActionView().findViewById(R.id.check_item));
|
||||
onOffAction(bt);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void onOffAction(CompoundButton bt) {
|
||||
if((selectedObject instanceof OsMoDevice)) {
|
||||
OsMoDevice d = (OsMoDevice) selectedObject;
|
||||
if(bt.isChecked()) {
|
||||
osMoPlugin.getGroups().connectDevice(d);
|
||||
} else {
|
||||
osMoPlugin.getGroups().disconnectDevice(d);
|
||||
}
|
||||
} else {
|
||||
OsMoGroup g = (OsMoGroup) selectedObject;
|
||||
if(bt.isChecked()) {
|
||||
String operation = osMoPlugin.getGroups().connectGroup(g);
|
||||
startLongRunningOperation(operation);
|
||||
} else {
|
||||
String operation = osMoPlugin.getGroups().disconnectGroup(g);
|
||||
startLongRunningOperation(operation);
|
||||
}
|
||||
}
|
||||
quitSelectionMode();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -287,6 +363,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
}
|
||||
String operation = osMoPlugin.getGroups().leaveGroup((OsMoGroup) selectedObject);
|
||||
startLongRunningOperation(operation);
|
||||
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -294,9 +371,9 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||
OsMoDevice user = adapter.getChild(groupPosition, childPosition);
|
||||
if (user != selectedObject) {
|
||||
enterSelectionMode(user);
|
||||
OsMoDevice model = adapter.getChild(groupPosition, childPosition);
|
||||
if (model != selectedObject) {
|
||||
enterSelectionMode(model);
|
||||
} else {
|
||||
quitSelectionMode();
|
||||
}
|
||||
|
@ -509,10 +586,10 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
@Override
|
||||
public int compare(OsMoGroup lhs, OsMoGroup rhs) {
|
||||
if (lhs.isMainGroup()) {
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
if (rhs.isMainGroup()) {
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
return clt.compare(lhs.getVisibleName(OsMoGroupsActivity.this),
|
||||
rhs.getVisibleName(OsMoGroupsActivity.this));
|
||||
|
@ -562,7 +639,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
|
||||
public View getGroupView(final int groupPosition, final boolean isExpanded, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
|
@ -584,33 +661,6 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
} else {
|
||||
label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
||||
}
|
||||
final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
||||
ch.setVisibility(model.isMainGroup() ? View.INVISIBLE : View.VISIBLE);
|
||||
ch.setOnCheckedChangeListener(null);
|
||||
ch.setChecked(model.enabled);
|
||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
boolean revert = false;
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if(revert) {
|
||||
revert = false;
|
||||
return;
|
||||
}
|
||||
if(!checkOperationIsNotRunning()) {
|
||||
revert = true;
|
||||
ch.setChecked(!isChecked);
|
||||
return;
|
||||
}
|
||||
if(isChecked) {
|
||||
String operation = osMoPlugin.getGroups().connectGroup(model);
|
||||
startLongRunningOperation(operation);
|
||||
} else {
|
||||
String operation = osMoPlugin.getGroups().disconnectGroup(model);
|
||||
startLongRunningOperation(operation);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
|
@ -631,27 +681,25 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
}
|
||||
TextView label = (TextView) row.findViewById(R.id.osmo_label);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.osmo_user_icon);
|
||||
final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
||||
if(model.getGroup().isMainGroup()) {
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
ch.setOnCheckedChangeListener(null);
|
||||
ch.setChecked(model.enabled);
|
||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if(isChecked) {
|
||||
osMoPlugin.getGroups().connectDevice(model);
|
||||
} else {
|
||||
osMoPlugin.getGroups().disconnectDevice(model);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ch.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
// final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
||||
// if(model.getGroup().isMainGroup()) {
|
||||
// ch.setVisibility(View.VISIBLE);
|
||||
// ch.setOnCheckedChangeListener(null);
|
||||
// ch.setChecked(model.enabled);
|
||||
// ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
// if(isChecked) {
|
||||
// osMoPlugin.getGroups().connectDevice(model);
|
||||
// } else {
|
||||
// osMoPlugin.getGroups().disconnectDevice(model);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// ch.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
LatLon lnLocation = mapLocation;
|
||||
Location location = model.getLastLocation();
|
||||
|
@ -704,6 +752,8 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -135,7 +135,7 @@ public class OsMoTracker implements OsMoSender, OsMoReactor {
|
|||
float lat = 0;
|
||||
float lon = 0;
|
||||
float speed = 0;
|
||||
int k = 0;
|
||||
int k = 1;
|
||||
for (int i = 0; i <= data.length(); i++) {
|
||||
boolean separator = i == data.length() || Character.isDigit(data.charAt(i)) || data.charAt(i) == ':'
|
||||
|| data.charAt(i) == '.';
|
||||
|
|
Loading…
Reference in a new issue