Add username

This commit is contained in:
vshcherb 2014-05-28 12:56:16 +02:00
parent 950b7cef2f
commit 067a265adc
3 changed files with 21 additions and 4 deletions

View file

@ -171,8 +171,8 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
storage.save();
}
processed = true;
} else if(command.equalsIgnoreCase("AGROUP_CREATE") || command.equalsIgnoreCase("GROUP_JOIN") ) {
if(command.equalsIgnoreCase("AGROUP_CREATE")) {
} else if(command.equalsIgnoreCase("GROUP_CREATE") || command.equalsIgnoreCase("GROUP_JOIN") ) {
if(command.equalsIgnoreCase("GROUP_CREATE")) {
operation = command;
try {
gid = obj.getString(GROUP_ID);
@ -289,8 +289,8 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
obj.put("expireTime", expireTime);
obj.put("description", description);
obj.put("policy", policy);
service.pushCommand("AGROUP_CREATE|" + obj.toString());
return "AGROUP_CREATE";
service.pushCommand("GROUP_CREATE|" + obj.toString());
return "GROUP_CREATE";
} catch (JSONException e) {
throw new RuntimeException(e);
}

View file

@ -12,6 +12,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
import net.osmand.plus.osmo.OsMoService.SessionInfo;
import net.osmand.plus.osmodroid.OsMoDroidLayer;
import net.osmand.plus.parkingpoint.ParkingPositionLayer;
import net.osmand.plus.views.MapInfoLayer;
@ -126,6 +127,21 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
boolean visible = true;
String txt = "OsMo";
String subtxt = "";
SessionInfo si = getService().getCurrentSessionInfo();
if (si != null) {
String uname = si.username;
if (uname != null && uname.length() > 0) {
if (uname.length() > 7 && uname.indexOf(' ') != -1) {
uname = uname.substring(0, uname.indexOf(' '));
}
if (uname.length() > 4 && uname.indexOf(' ') != -1) {
txt = "";
subtxt = uname;
} else {
txt = uname;
}
}
}
Drawable small = srcinactive;
Drawable big = srcinactive;
long last = service.getLastCommandTime();

View file

@ -41,6 +41,7 @@ public class TextInfoWidget extends BaseMapWidget {
+ (int) (3 * scaleCoefficient));
}
}
public void setText(String text, String subtext) {
this.text = text;