Update selection & colors
This commit is contained in:
parent
941dc8b522
commit
3a28293fe1
14 changed files with 232 additions and 61 deletions
|
@ -1,13 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_gravity="center_vertical" >
|
android:layout_gravity="center_vertical" >
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/check_item"
|
android:id="@+id/check_item"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
|
@ -7,23 +7,28 @@
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/motd"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/osmo_status"
|
android:id="@+id/osmo_status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingLeft="6dp"
|
android:paddingLeft="4dp"
|
||||||
|
android:paddingRight="4dp"
|
||||||
android:src="@drawable/mon_osmo_conn_small" />
|
android:src="@drawable/mon_osmo_conn_small" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/motd"
|
|
||||||
android:layout_marginBottom="8dip"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
|
|
||||||
<Switch
|
<Switch
|
||||||
android:id="@+id/enable_tracker"
|
android:id="@+id/enable_tracker"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -31,5 +36,6 @@
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:text="@string/osmo_enable_tracker" />
|
android:text="@string/osmo_enable_tracker" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -1,13 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:layout_gravity="center_vertical" >
|
android:layout_gravity="center_vertical" >
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/check_item"
|
android:id="@+id/check_item"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="fill_parent"
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
63
OsmAnd/res/layout/osmo_create_group.xml
Normal file
63
OsmAnd/res/layout/osmo_create_group.xml
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="3dp"
|
||||||
|
android:paddingRight="3dp"
|
||||||
|
android:stretchColumns="1" >
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_group_name" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/Name"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="3dp" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_group_description" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/Description"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="3"
|
||||||
|
android:paddingLeft="3dp" />
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_expire_group" />
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/ExpireGroup"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="3dp" />
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/osmo_group_policy" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/Policy"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:lines="2"
|
||||||
|
android:paddingLeft="3dp" />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
|
@ -7,22 +7,28 @@
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/motd"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dip"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="18sp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/osmo_status"
|
android:id="@+id/osmo_status"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingLeft="6dp"
|
android:paddingLeft="4dp"
|
||||||
|
android:paddingRight="4dp"
|
||||||
android:src="@drawable/mon_osmo_conn_small" />
|
android:src="@drawable/mon_osmo_conn_small" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/motd"
|
|
||||||
android:layout_marginBottom="8dip"
|
|
||||||
android:gravity="center"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18sp" />
|
|
||||||
|
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/enable_tracker"
|
android:id="@+id/enable_tracker"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -30,5 +36,6 @@
|
||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:text="@string/osmo_enable_tracker" />
|
android:text="@string/osmo_enable_tracker" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -13,6 +13,8 @@
|
||||||
<color name="color_white">#FFFFFF</color>
|
<color name="color_white">#FFFFFF</color>
|
||||||
<color name="color_black">#000000</color>
|
<color name="color_black">#000000</color>
|
||||||
|
|
||||||
|
<color name="row_selection_color">#CC33BBE0</color>
|
||||||
|
|
||||||
<!-- Themed color list items -->
|
<!-- Themed color list items -->
|
||||||
<!-- invalid -red, localindex not supported, -->
|
<!-- invalid -red, localindex not supported, -->
|
||||||
<color name="color_invalid">#EE3232</color>
|
<color name="color_invalid">#EE3232</color>
|
||||||
|
|
|
@ -9,10 +9,14 @@
|
||||||
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="int_days">days</string>
|
||||||
|
<string name="osmo_expire_group">Expires in</string>
|
||||||
|
<string name="osmo_group_description">Description</string>
|
||||||
|
<string name="osmo_group_policy">Policy</string>
|
||||||
<string name="osmo_connect_to_device_tracker_id">Tracker id</string>
|
<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_device_name">Device name</string>
|
||||||
<string name="osmo_connect_to_group_id">Group id</string>
|
<string name="osmo_connect_to_group_id">Group id</string>
|
||||||
<string name="osmo_connect_to_group_name">Group name</string>
|
<string name="osmo_group_name">Group name</string>
|
||||||
<string name="osmo_connect_to_device">Device</string>
|
<string name="osmo_connect_to_device">Device</string>
|
||||||
<string name="osmo_connect_to_group">Group</string>
|
<string name="osmo_connect_to_group">Group</string>
|
||||||
<string name="osmo_connect">Connect to</string>
|
<string name="osmo_connect">Connect to</string>
|
||||||
|
|
|
@ -830,6 +830,8 @@ public class OsmandSettings {
|
||||||
|
|
||||||
public final OsmandPreference<Boolean> OSMO_AUTO_SEND_LOCATIONS = new BooleanPreference("osmo_automatically_send_locations", false).makeGlobal();
|
public final OsmandPreference<Boolean> OSMO_AUTO_SEND_LOCATIONS = new BooleanPreference("osmo_automatically_send_locations", false).makeGlobal();
|
||||||
|
|
||||||
|
public final CommonPreference<Integer> OSMO_SAVE_TRACK_INTERVAL = new IntPreference("osmo_save_track_interval", 3000).makeGlobal().cache();
|
||||||
|
|
||||||
public final OsmandPreference<String> OSMO_GROUPS = new StringPreference("osmo_groups", "{}").makeGlobal();
|
public final OsmandPreference<String> OSMO_GROUPS = new StringPreference("osmo_groups", "{}").makeGlobal();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.json.JSONObject;
|
||||||
public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
|
|
||||||
private static final String GROUP_NAME = "name";
|
private static final String GROUP_NAME = "name";
|
||||||
|
private static final String GROUP_ID = "group_id";
|
||||||
private static final String EXPIRE_TIME = "expireTime";
|
private static final String EXPIRE_TIME = "expireTime";
|
||||||
private static final String DESCRIPTION = "description";
|
private static final String DESCRIPTION = "description";
|
||||||
private static final String POLICY = "policy";
|
private static final String POLICY = "policy";
|
||||||
|
@ -171,11 +172,19 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
|
||||||
storage.save();
|
storage.save();
|
||||||
}
|
}
|
||||||
processed = true;
|
processed = true;
|
||||||
} else if(command.startsWith("AGROUP_CREATE:") || command.startsWith("GROUP_JOIN:") ) {
|
} else if(command.startsWith("AGROUP_CREATE") || command.startsWith("GROUP_JOIN:") ) {
|
||||||
if(command.startsWith("AGROUP_CREATE:")) {
|
String gid ;
|
||||||
operation = "AGROUP_CREATE";
|
if(command.startsWith("AGROUP_CREATE")) {
|
||||||
|
try {
|
||||||
|
gid = obj.getString(GROUP_ID);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
service.showErrorMessage(e.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gid = command.substring(command.indexOf(':') + 1);
|
||||||
}
|
}
|
||||||
String gid = command.substring(command.indexOf(':') + 1);
|
|
||||||
group = storage.getGroup(gid);
|
group = storage.getGroup(gid);
|
||||||
if(group == null) {
|
if(group == null) {
|
||||||
group = new OsMoGroup();
|
group = new OsMoGroup();
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.plus.OsmAndConstants;
|
import net.osmand.plus.OsmAndConstants;
|
||||||
|
@ -34,6 +35,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
@ -53,10 +55,12 @@ import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
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.RadioButton;
|
||||||
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -278,10 +282,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
adapter.update(d.getGroup());
|
adapter.update(d.getGroup());
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
if (checkOperationIsNotRunning()) {
|
if (!checkOperationIsNotRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String operation = osMoPlugin.getGroups().leaveGroup((OsMoGroup) selectedObject);
|
String operation = osMoPlugin.getGroups().leaveGroup((OsMoGroup) selectedObject);
|
||||||
startLongRunningOperation(operation);
|
startLongRunningOperation(operation);
|
||||||
}
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +322,39 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGroup() {
|
private void createGroup() {
|
||||||
// TODO Auto-generated method stub
|
Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.osmo_create_group);
|
||||||
|
final View v = getLayoutInflater().inflate(R.layout.osmo_create_group, getExpandableListView(), false);
|
||||||
|
final EditText policy = (EditText) v.findViewById(R.id.Policy);
|
||||||
|
final EditText description = (EditText) v.findViewById(R.id.Description);
|
||||||
|
final EditText name = (EditText) v.findViewById(R.id.Name);
|
||||||
|
final Spinner expire = (Spinner) v.findViewById(R.id.ExpireGroup);
|
||||||
|
final int[] days = new int[]{1,2,3,7,14};
|
||||||
|
String[] ds = new String[days.length];
|
||||||
|
for(int k = 0; k < days.length; k++) {
|
||||||
|
ds[k] = days[k] + " " + getString(R.string.int_days);
|
||||||
|
}
|
||||||
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, ds);
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
expire.setAdapter(adapter);
|
||||||
|
expire.setSelection(3);
|
||||||
|
|
||||||
|
builder.setView(v);
|
||||||
|
builder.setNegativeButton(R.string.default_buttons_cancel, null);
|
||||||
|
builder.setPositiveButton(R.string.default_buttons_ok, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
if(!checkOperationIsNotRunning()) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
long eTime = days[expire.getSelectedItemPosition()] * 60 * 60 * 24 * 1000 + System.currentTimeMillis();
|
||||||
|
String op = osMoPlugin.getGroups().createGroup(name.getText().toString(), eTime,
|
||||||
|
description.getText().toString(), policy.getText().toString());
|
||||||
|
startLongRunningOperation(op);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.create().show();
|
||||||
|
AndroidUtils.softKeyboardDelayed(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,7 +378,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
labelName.setText(R.string.osmo_connect_to_device_name);
|
labelName.setText(R.string.osmo_connect_to_device_name);
|
||||||
} else {
|
} else {
|
||||||
labelTracker.setText(R.string.osmo_connect_to_group_id);
|
labelTracker.setText(R.string.osmo_connect_to_group_id);
|
||||||
labelName.setText(R.string.osmo_connect_to_group_name);
|
labelName.setText(R.string.osmo_group_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -367,7 +404,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.create().show();
|
builder.create().show();
|
||||||
tracker.requestFocus();
|
AndroidUtils.softKeyboardDelayed(tracker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -532,17 +569,24 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
row = inflater.inflate(R.layout.osmo_group_item, parent, false);
|
row = inflater.inflate(R.layout.osmo_group_item, parent, false);
|
||||||
//fixBackgroundRepeat(row);
|
//fixBackgroundRepeat(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustIndicator(groupPosition, isExpanded, row);
|
adjustIndicator(groupPosition, isExpanded, row);
|
||||||
TextView label = (TextView) row.findViewById(R.id.category_name);
|
TextView label = (TextView) row.findViewById(R.id.category_name);
|
||||||
final OsMoGroup model = getGroup(groupPosition);
|
final OsMoGroup model = getGroup(groupPosition);
|
||||||
|
if(selectedObject == model) {
|
||||||
|
row.setBackgroundColor(getResources().getColor(R.color.row_selection_color));
|
||||||
|
} else {
|
||||||
|
row.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
label.setText(model.getVisibleName(OsMoGroupsActivity.this));
|
label.setText(model.getVisibleName(OsMoGroupsActivity.this));
|
||||||
if(model.isMainGroup() || model.active) {
|
if(model.isMainGroup() || model.isActive()) {
|
||||||
label.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
label.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||||
} else {
|
} else {
|
||||||
label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
||||||
}
|
}
|
||||||
final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
||||||
ch.setVisibility(model.isMainGroup() ? View.INVISIBLE : View.VISIBLE);
|
ch.setVisibility(model.isMainGroup() ? View.INVISIBLE : View.VISIBLE);
|
||||||
|
ch.setOnCheckedChangeListener(null);
|
||||||
ch.setChecked(model.enabled);
|
ch.setChecked(model.enabled);
|
||||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
boolean revert = false;
|
boolean revert = false;
|
||||||
|
@ -552,7 +596,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
revert = false;
|
revert = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(checkOperationIsNotRunning()) {
|
if(!checkOperationIsNotRunning()) {
|
||||||
revert = true;
|
revert = true;
|
||||||
ch.setChecked(!isChecked);
|
ch.setChecked(!isChecked);
|
||||||
return;
|
return;
|
||||||
|
@ -580,11 +624,17 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
}
|
}
|
||||||
final OsMoDevice model = (OsMoDevice) getChild(groupPosition, childPosition);
|
final OsMoDevice model = (OsMoDevice) getChild(groupPosition, childPosition);
|
||||||
row.setTag(model);
|
row.setTag(model);
|
||||||
|
if(selectedObject == model) {
|
||||||
|
row.setBackgroundColor(getResources().getColor(R.color.row_selection_color));
|
||||||
|
} else {
|
||||||
|
row.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
}
|
||||||
TextView label = (TextView) row.findViewById(R.id.osmo_label);
|
TextView label = (TextView) row.findViewById(R.id.osmo_label);
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.osmo_user_icon);
|
ImageView icon = (ImageView) row.findViewById(R.id.osmo_user_icon);
|
||||||
final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
final CompoundButton ch = (CompoundButton) row.findViewById(R.id.check_item);
|
||||||
if(model.getGroup().isMainGroup()) {
|
if(model.getGroup().isMainGroup()) {
|
||||||
ch.setVisibility(View.VISIBLE);
|
ch.setVisibility(View.VISIBLE);
|
||||||
|
ch.setOnCheckedChangeListener(null);
|
||||||
ch.setChecked(model.enabled);
|
ch.setChecked(model.enabled);
|
||||||
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
|
|
||||||
|
@ -610,7 +660,14 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
}
|
}
|
||||||
//Location location = tracker.getLastLocation(model.trackerId);
|
//Location location = tracker.getLastLocation(model.trackerId);
|
||||||
if (location == null || lnLocation == null) {
|
if (location == null || lnLocation == null) {
|
||||||
icon.setImageResource(R.drawable.list_favorite);
|
if(model.isEnabled()) {
|
||||||
|
icon.setImageResource(
|
||||||
|
//model.isActive() ? R.drawable.mon_osmo_conn_signal_small :
|
||||||
|
R.drawable.mon_osmo_conn_small);
|
||||||
|
} else {
|
||||||
|
icon.setImageResource(R.drawable.monitoring_rec_inactive);
|
||||||
|
|
||||||
|
}
|
||||||
label.setText(model.getVisibleName());
|
label.setText(model.getVisibleName());
|
||||||
} else {
|
} else {
|
||||||
DirectionDrawable draw = new DirectionDrawable();
|
DirectionDrawable draw = new DirectionDrawable();
|
||||||
|
@ -623,7 +680,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
icon.setImageResource(R.drawable.list_favorite);
|
icon.setImageResource(R.drawable.list_favorite);
|
||||||
int dist = (int) mes[0];
|
int dist = (int) mes[0];
|
||||||
long seconds = Math.max(0, (System.currentTimeMillis() - location.getTime()) / 1000);
|
long seconds = Math.max(0, (System.currentTimeMillis() - location.getTime()) / 1000);
|
||||||
String time = " (";
|
String time = "\n (";
|
||||||
if (seconds < 100) {
|
if (seconds < 100) {
|
||||||
time = seconds + " " + getString(R.string.seconds_ago);
|
time = seconds + " " + getString(R.string.seconds_ago);
|
||||||
} else if (seconds / 60 < 100) {
|
} else if (seconds / 60 < 100) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ 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, app.getSettings().OSMO_SAVE_TRACK_INTERVAL);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
ApplicationMode.regWidget("osmo_control", (ApplicationMode[])null);
|
ApplicationMode.regWidget("osmo_control", (ApplicationMode[])null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class OsMoThread {
|
||||||
protected final static Log log = PlatformUtil.getLog(OsMoThread.class);
|
protected final static Log log = PlatformUtil.getLog(OsMoThread.class);
|
||||||
private static final long HEARTBEAT_DELAY = 100;
|
private static final long HEARTBEAT_DELAY = 100;
|
||||||
private static final long HEARTBEAT_FAILED_DELAY = 10000;
|
private static final long HEARTBEAT_FAILED_DELAY = 10000;
|
||||||
private static final long TIMEOUT_TO_RECONNECT = 10 * 60 * 1000;
|
private static final long TIMEOUT_TO_RECONNECT = 60 * 1000;
|
||||||
private static final long TIMEOUT_TO_PING = 2 * 60 * 1000;
|
private static final long TIMEOUT_TO_PING = 2 * 60 * 1000;
|
||||||
private static final long LIMIT_OF_FAILURES_RECONNECT = 10;
|
private static final long LIMIT_OF_FAILURES_RECONNECT = 10;
|
||||||
private static final long SELECT_TIMEOUT = 500;
|
private static final long SELECT_TIMEOUT = 500;
|
||||||
|
@ -84,6 +84,7 @@ public class OsMoThread {
|
||||||
if (sessionInfo == null) {
|
if (sessionInfo == null) {
|
||||||
sessionInfo = service.prepareSessionToken();
|
sessionInfo = service.prepareSessionToken();
|
||||||
}
|
}
|
||||||
|
this.activeChannel = null;
|
||||||
authorized = 0;
|
authorized = 0;
|
||||||
reconnect = false;
|
reconnect = false;
|
||||||
failures = 0;
|
failures = 0;
|
||||||
|
@ -150,10 +151,10 @@ public class OsMoThread {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("Exception selecting socket", e);
|
log.info("Exception selecting socket", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
delay = HEARTBEAT_FAILED_DELAY;
|
|
||||||
if (activeChannel != null && !activeChannel.isConnected()) {
|
if (activeChannel != null && !activeChannel.isConnected()) {
|
||||||
activeChannel = null;
|
activeChannel = null;
|
||||||
}
|
}
|
||||||
|
delay = HEARTBEAT_FAILED_DELAY;
|
||||||
if(lastSendCommand != 0 && System.currentTimeMillis() - lastSendCommand > TIMEOUT_TO_RECONNECT ) {
|
if(lastSendCommand != 0 && System.currentTimeMillis() - lastSendCommand > TIMEOUT_TO_RECONNECT ) {
|
||||||
reconnect = true;
|
reconnect = true;
|
||||||
} else if (failures++ > LIMIT_OF_FAILURES_RECONNECT) {
|
} else if (failures++ > LIMIT_OF_FAILURES_RECONNECT) {
|
||||||
|
@ -279,6 +280,7 @@ public class OsMoThread {
|
||||||
continue;
|
continue;
|
||||||
} else if(header.equalsIgnoreCase(PING_CMD)) {
|
} else if(header.equalsIgnoreCase(PING_CMD)) {
|
||||||
pingSent = 0;
|
pingSent = 0;
|
||||||
|
continue;
|
||||||
// lastSendCommand = System.currentTimeMillis(); // not needed handled by send
|
// lastSendCommand = System.currentTimeMillis(); // not needed handled by send
|
||||||
}
|
}
|
||||||
boolean processed = false;
|
boolean processed = false;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -17,14 +18,17 @@ public class OsMoTracker implements OsMoSender, OsMoReactor {
|
||||||
private OsmoTrackerListener uiTrackerListener = null;
|
private OsmoTrackerListener uiTrackerListener = null;
|
||||||
private OsmoTrackerListener trackerListener = null;
|
private OsmoTrackerListener trackerListener = null;
|
||||||
private Location lastSendLocation;
|
private Location lastSendLocation;
|
||||||
|
private Location lastBufferLocation;
|
||||||
|
private CommonPreference<Integer> pref;
|
||||||
|
|
||||||
public interface OsmoTrackerListener {
|
public interface OsmoTrackerListener {
|
||||||
|
|
||||||
public void locationChange(String trackerId, Location location);
|
public void locationChange(String trackerId, Location location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsMoTracker(OsMoService service) {
|
public OsMoTracker(OsMoService service, CommonPreference<Integer> pref) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
|
this.pref = pref;
|
||||||
service.registerSender(this);
|
service.registerSender(this);
|
||||||
service.registerReactor(this);
|
service.registerReactor(this);
|
||||||
}
|
}
|
||||||
|
@ -93,10 +97,20 @@ public class OsMoTracker implements OsMoSender, OsMoReactor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendCoordinate(Location location) {
|
public void sendCoordinate(Location location) {
|
||||||
if(startSendingLocations) {
|
if(startSendingLocations && location != null) {
|
||||||
|
long ltime = lastBufferLocation == null ? 0 : lastBufferLocation.getTime();
|
||||||
|
|
||||||
|
if (location.getTime() - ltime > pref.get()) {
|
||||||
|
if(lastBufferLocation != null && (!lastBufferLocation.hasSpeed() || lastBufferLocation.getSpeed() < 1) &&
|
||||||
|
lastBufferLocation.distanceTo(location) < 40){
|
||||||
|
// ignores
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastBufferLocation = location;
|
||||||
bufferOfLocations.add(location);
|
bufferOfLocations.add(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getLocationsSent() {
|
public int getLocationsSent() {
|
||||||
return locationsSent;
|
return locationsSent;
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.osmand.access.AccessibleToast;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||||
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
import net.osmand.plus.osmo.OsMoService.SessionInfo;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
@ -22,12 +23,13 @@ import android.widget.Toast;
|
||||||
|
|
||||||
public class SettingsOsMoActivity extends SettingsBaseActivity {
|
public class SettingsOsMoActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
public static final String MORE_VALUE = "MORE_VALUE";
|
|
||||||
public static final String DEFINE_EDIT = "DEFINE_EDIT";
|
|
||||||
private Preference debugPref;
|
private Preference debugPref;
|
||||||
private Preference trackerId;
|
private Preference trackerId;
|
||||||
private CheckBoxPreference sendLocationsref;
|
private CheckBoxPreference sendLocationsref;
|
||||||
|
|
||||||
|
public static final int[] SECONDS = new int[] {1, 2, 3, 5, 10, 15, 30, 60, 90};
|
||||||
|
public static final int[] MINUTES = new int[] {2, 3, 5};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -48,6 +50,9 @@ public class SettingsOsMoActivity extends SettingsBaseActivity {
|
||||||
sendLocationsref.setSummary(R.string.osmo_auto_send_locations_descr);
|
sendLocationsref.setSummary(R.string.osmo_auto_send_locations_descr);
|
||||||
grp.addPreference(sendLocationsref);
|
grp.addPreference(sendLocationsref);
|
||||||
|
|
||||||
|
grp.addPreference(createTimeListPreference(settings.OSMO_SAVE_TRACK_INTERVAL, SECONDS,
|
||||||
|
MINUTES, 1000, R.string.save_track_interval, R.string.save_track_interval_descr));
|
||||||
|
|
||||||
debugPref = new Preference(this);
|
debugPref = new Preference(this);
|
||||||
debugPref.setTitle(R.string.osmo_settings_debug);
|
debugPref.setTitle(R.string.osmo_settings_debug);
|
||||||
debugPref.setOnPreferenceClickListener(this);
|
debugPref.setOnPreferenceClickListener(this);
|
||||||
|
|
Loading…
Reference in a new issue