Add nickname

This commit is contained in:
vshcherb 2014-05-28 18:10:20 +02:00
parent d17809e416
commit b49791add0
6 changed files with 45 additions and 10 deletions

View file

@ -60,4 +60,19 @@
android:paddingLeft="3dp" />
</TableRow>
<TableRow android:id="@+id/MyGroupName">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/osmo_connect_to_my_nickname" />
<EditText
android:id="@+id/NickName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:paddingLeft="3dp" />
</TableRow>
</TableLayout>

View file

@ -9,7 +9,8 @@
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
-->
<string name="osmo_device_map_description">User : %1$s</string>
<string name="osmo_connect_to_my_nickname">My nickname</string>
<string name="osmo_user_name">User</string>
<string name="color_red">red</string>
<string name="color_pink">pink</string>
<string name="color_orange">orange</string>

View file

@ -828,6 +828,10 @@ public class OsmandSettings {
public final OsmandPreference<String> OSMO_DEVICE_KEY = new StringPreference("osmo_device_token", "").makeGlobal();
public final OsmandPreference<String> OSMO_USER_NAME = new StringPreference("osmo_user_name", "").makeGlobal();
public final OsmandPreference<String> OSMO_USER_PWD = new StringPreference("osmo_user_pwd", null).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();

View file

@ -319,8 +319,8 @@ public class OsMoGroups implements OsMoReactor, OsmoTrackerListener {
storage.save();
return us;
}
public String joinGroup(String groupId, String userName) {
final String op = "GROUP_JOIN:"+groupId;
public String joinGroup(String groupId, String userName, String nick) {
final String op = "GROUP_JOIN:"+groupId+"|"+nick;
OsMoGroup g = storage.getGroup(groupId);
if(g == null){
g = new OsMoGroup();

View file

@ -638,6 +638,14 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
final TextView labelName = (TextView ) v.findViewById(R.id.LabelName);
final EditText tracker = (EditText) v.findViewById(R.id.TrackerId);
final EditText name = (EditText) v.findViewById(R.id.Name);
final View mgv = v.findViewById(R.id.MyGroupName);
final EditText nickname = (EditText) v.findViewById(R.id.NickName);
if(app.getSettings().OSMO_USER_NAME.get().isEmpty()) {
app.getSettings().OSMO_USER_NAME.set(getString(R.string.osmo_user_name) + " " + new Random(10));
}
nickname.setText(app.getSettings().OSMO_USER_NAME.get());
device.setChecked(true);
device.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@ -646,9 +654,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
if(isChecked) {
labelTracker.setText(R.string.osmo_connect_to_device_tracker_id);
labelName.setText(R.string.osmo_connect_to_device_name);
mgv.setVisibility(View.GONE);
} else {
labelTracker.setText(R.string.osmo_connect_to_group_id);
labelName.setText(R.string.osmo_group_name);
mgv.setVisibility(View.VISIBLE);
}
}
});
@ -660,6 +670,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
public void onClick(DialogInterface dialog, int which) {
final String nameUser = name.getText().toString();
final String id = tracker.getText().toString();
final String nick = nickname.getText().toString();
if(device.isChecked()) {
OsMoDevice dev = osMoPlugin.getGroups().addConnectedDevice(id, nameUser, getRandomColor());
adapter.update(dev.group);
@ -668,7 +679,10 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
if(!checkOperationIsNotRunning()) {
return;
}
String op = osMoPlugin.getGroups().joinGroup(id, nameUser);
String op = osMoPlugin.getGroups().joinGroup(id, nameUser, nick);
if(app.getSettings().OSMO_USER_PWD.get() == null) {
app.getSettings().OSMO_USER_NAME.set(nick);
}
startLongRunningOperation(op);
}
}
@ -888,8 +902,8 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
location = tracker.getLastSendLocation();
}
int color = getResources().getColor(R.color.color_unknown);
int activeColor= model.getColor();
if(activeColor== 0) {
int activeColor = model.getColor();
if (activeColor == 0) {
activeColor = getRandomColor();
osMoPlugin.getGroups().setDeviceProperties(model, model.getVisibleName(), activeColor);
}
@ -915,12 +929,12 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
net.osmand.Location.distanceBetween(location.getLatitude(), location.getLongitude(),
mapLocation.getLatitude(), mapLocation.getLongitude(), mes);
draw.setAngle(mes[1] - lastCompass + 180);
final boolean recent = Math.abs(location.getTime() - System.currentTimeMillis()) < RECENT_THRESHOLD;
long now = System.currentTimeMillis();
final boolean recent = Math.abs( now - location.getTime() ) < RECENT_THRESHOLD;
draw.setColor(recent ? activeColor : color);
draw.setColor(color);
icon.setImageDrawable(draw);
int dist = (int) mes[0];
long seconds = Math.max(0, (System.currentTimeMillis() - location.getTime()) / 1000);
long seconds = Math.max(0, (now - location.getTime()) / 1000);
String time = "";
if (seconds < 60) {
seconds = (seconds / 5) * 5;
@ -1152,3 +1166,4 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
}

View file

@ -139,7 +139,7 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
@Override
public String getObjectDescription(Object o) {
if (o instanceof OsMoDevice) {
return map.getString(R.string.osmo_device_map_description, ((OsMoDevice) o).getVisibleName());
return map.getString(R.string.osmo_user_name) + " " + ((OsMoDevice) o).getVisibleName();
}
return null;
}