Switch to http scheme

This commit is contained in:
vshcherb 2014-05-29 02:41:02 +02:00
parent 3e42fbbdf4
commit 11606f20f0
5 changed files with 13 additions and 9 deletions

View file

@ -132,9 +132,10 @@
<activity android:name="net.osmand.plus.osmo.SettingsOsMoActivity" android:configChanges="keyboardHidden|orientation"></activity>
<activity android:name="net.osmand.plus.osmo.OsMoGroupsActivity">
<intent-filter>
<data android:scheme="osmo" />
<data android:scheme="http" android:host="osmo.mobi" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"></category>
</intent-filter>
</activity>

View file

@ -584,7 +584,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
AccessibleToast.makeText(this, R.string.osmo_auth_pending, Toast.LENGTH_SHORT).show();
} else {
ShareDialog dlg = new ShareDialog(this);
String url = "osmo://connect?id="+Uri.encode(trackerId);
String url = OsMoService.SHARE_TRACKER_URL + Uri.encode(trackerId);
if(name != null && name.length() > 0){;
url += "&name="+Uri.encode(name);
}
@ -597,7 +597,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
private void shareOsMoGroup(String name, String groupId) {
ShareDialog dlg = new ShareDialog(this);
String url = "osmo://join?id="+Uri.encode(groupId)+"&name="+Uri.encode(name);
String url = OsMoService.SHARE_GROUP_URL +Uri.encode(groupId)+"&name="+Uri.encode(name);
dlg.setTitle(getString(R.string.osmo_group));
dlg.viewContent(groupId);
dlg.shareURLOrText(url, getString(R.string.osmo_group_share, groupId, name, url), null);

View file

@ -24,22 +24,23 @@ public class OsMoIntentHandler extends AsyncTask<Intent, Void, String> {
for (Intent intent : params) {
String scheme = intent.getScheme();
Uri data = intent.getData();
if ("osmo".equals(scheme)) {
final String schemeSpecific = data.getSchemeSpecificPart();
if(schemeSpecific.equals("login")) {
if ("http".equals(scheme) && data.getHost().equals("osmo.mobi")) {
String path = data.getPath();
String lastPath = path.substring(path.lastIndexOf('/') + 1);
if(lastPath.equals("login")) {
String user = data.getQueryParameter("u");
String pwd = data.getQueryParameter("p");
app.getSettings().OSMO_USER_NAME.set(user);
app.getSettings().OSMO_USER_PWD.set(pwd);
plugin.getService().reconnectToServer();
} else if(schemeSpecific.equals("join")) {
} else if(lastPath.equals("join")) {
String gid = data.getQueryParameter("id");
String name = data.getQueryParameter("name");
if(name == null) {
name = "";
}
plugin.getGroups().joinGroup(gid, name, app.getSettings().OSMO_USER_NAME.get());
} else if(schemeSpecific.equals("connect")) {
} else if(lastPath.equals("connect")) {
String gid = data.getQueryParameter("id");
String name = data.getQueryParameter("name");
if(name == null) {

View file

@ -38,6 +38,8 @@ public class OsMoService implements OsMoReactor {
private ConcurrentLinkedQueue<String> commands = new ConcurrentLinkedQueue<String>();
private OsmandApplication app;
private static final Log log = PlatformUtil.getLog(OsMoService.class);
public static final String SHARE_TRACKER_URL = "http://osmo.mobi/connect?id=";
public static final String SHARE_GROUP_URL = "http://osmo.mobi/join?id=";
private String lastRegistrationError = null;

View file

@ -126,7 +126,7 @@ public class SettingsOsMoActivity extends SettingsBaseActivity {
dlg.setTitle(getString(R.string.osmo_tracker_id));
dlg.setAction(getString(R.string.osmo_regenerate_login_ids), getRegenerateAction());
dlg.viewContent(ci.trackerId);
String url = "osmo://connect?id="+Uri.encode(ci.trackerId);
String url = OsMoService.SHARE_TRACKER_URL+Uri.encode(ci.trackerId);
dlg.shareURLOrText(ci.trackerId, getString(R.string.osmo_tracker_id_share, ci.trackerId, "", url), null);
dlg.showDialog();
}