diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 78cb98413d..ead453fe69 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +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
-->
+ Are you sure about regenerating personal ids? All devices, connected to you, won\'t be able to track you any more.
+ Regenerate user id
Cancel moving target
Center on the screen
Set as moving target
diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java
index b848c886a1..acdc4eeafd 100644
--- a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java
+++ b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java
@@ -29,6 +29,7 @@ public class ShareDialog {
private List share = new ArrayList();
private static final String ZXING_BARCODE_SCANNER_COMPONENT = "com.google.zxing.client.android"; //$NON-NLS-1$
private static final String ZXING_BARCODE_SCANNER_ACTIVITY = "com.google.zxing.client.android.ENCODE"; //$NON-NLS-1$
+ static final int ACTION = -1;
static final int VIEW = 0;
static final int EMAIL = 1;
static final int SMS = 2;
@@ -45,11 +46,17 @@ public class ShareDialog {
return this;
}
+
public ShareDialog viewContent(String content){
share.add(new ShareType(content, VIEW));
return this;
}
+ public ShareDialog setAction(String content, Runnable r){
+ share.add(new ShareType(content, ACTION, r));
+ return this;
+ }
+
public ShareDialog shareURLOrText(String url, String shortExplanation, String longExplanation){
if(shortExplanation == null) {
shortExplanation = url;
@@ -68,14 +75,23 @@ public class ShareDialog {
private static class ShareType {
public String content;
public int type;
+ private Runnable runnable;
public ShareType(String content, int type) {
this.content = content;
this.type = type;
}
+ public ShareType(String content, int action, Runnable r) {
+ this.content = content;
+ this.type = action;
+ this.runnable = r;
+ }
+
public String getShareName(Context ctx) {
- if(type == VIEW) {
+ if(type == ACTION) {
+ return content;
+ } else if(type == VIEW) {
return ctx.getString(R.string.show_details);
} else if(type == EMAIL) {
return "Email";
@@ -90,7 +106,9 @@ public class ShareDialog {
}
public void execute(Activity a, String title) {
- if(type == VIEW) {
+ if(type == ACTION) {
+ runnable.run();
+ } else if(type == VIEW) {
Builder bld = new AlertDialog.Builder(a);
bld.setTitle(title);
bld.setMessage(content);
diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java
index 4021452f91..59ea777ae9 100644
--- a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java
+++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java
@@ -31,6 +31,7 @@ import android.os.Build;
import android.provider.Settings.Secure;
public class OsMoService implements OsMoReactor {
+ public static final String REGENERATE_CMD = "REGENERATE_TRACKER_ID";
private OsMoThread thread;
private List listReactors = new java.util.concurrent.CopyOnWriteArrayList();
private ConcurrentLinkedQueue commands = new ConcurrentLinkedQueue();
diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java
index d63b554a1b..89e9831983 100644
--- a/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java
+++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java
@@ -32,6 +32,7 @@ public class OsMoThread {
// private static String TRACKER_SERVER = "srv.osmo.mobi";
// private static int TRACKER_PORT = 3245;
+
private static final String PING_CMD = "P";
protected final static Log log = PlatformUtil.getLog(OsMoThread.class);
private static final long HEARTBEAT_DELAY = 100;
@@ -290,6 +291,9 @@ public class OsMoThread {
}
}
continue;
+ } else if(header.equalsIgnoreCase(OsMoService.REGENERATE_CMD)) {
+ reconnect = true;
+ continue;
} else if(header.equalsIgnoreCase(PING_CMD)) {
pingSent = 0;
continue;
diff --git a/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java b/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java
index 89ae09fe9e..06400f276c 100644
--- a/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java
+++ b/OsmAnd/src/net/osmand/plus/osmo/SettingsOsMoActivity.java
@@ -11,6 +11,8 @@ import net.osmand.plus.osmo.OsMoService.SessionInfo;
import net.osmand.util.Algorithms;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
@@ -121,6 +123,7 @@ public class SettingsOsMoActivity extends SettingsBaseActivity {
} else {
ShareDialog dlg = new ShareDialog(this);
dlg.setTitle(getString(R.string.osmo_tracker_id));
+ dlg.setAction(getString(R.string.osmo_regenerate_login_ids), getRegenerateAction());
dlg.viewContent(ci.trackerId);
dlg.shareURLOrText(ci.trackerId, getString(R.string.osmo_tracker_id_share, ci.trackerId, ""), null);
dlg.showDialog();
@@ -129,6 +132,27 @@ public class SettingsOsMoActivity extends SettingsBaseActivity {
return super.onPreferenceClick(preference);
}
+ private Runnable getRegenerateAction() {
+ return new Runnable() {
+
+ @Override
+ public void run() {
+ Builder bld = new AlertDialog.Builder(SettingsOsMoActivity.this);
+ bld.setMessage(R.string.osmo_regenerate_login_ids_confirm);
+ bld.setPositiveButton(R.string.default_buttons_yes, new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ final OsMoPlugin plugin = OsMoPlugin.getEnabledPlugin(OsMoPlugin.class);
+ plugin.getService().pushCommand(OsMoService.REGENERATE_CMD);
+ }
+ });
+ bld.setNegativeButton(R.string.default_buttons_no, null);
+ bld.show();
+ }
+ };
+ }
+
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean p = super.onPreferenceChange(preference, newValue);