From a70ea6c83cbd214cc4f9e50d6cb7bcf9e3b9aec7 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 31 Jul 2014 00:17:38 +0200 Subject: [PATCH 1/2] Fix OsMo --- OsmAnd/res/values/strings.xml | 2 ++ .../net/osmand/plus/osmo/OsMoGroupsActivity.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index f874b30658..6af6ee2ad4 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 --> + Leave group %1$s? + Please specify tracker id Continue Navigation Pause Navigation Keep diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java index ab497f2639..eac8ff5e3e 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java @@ -431,7 +431,9 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this); String name = (selectedObject instanceof OsMoDevice)? ((OsMoDevice) selectedObject).getVisibleName() : ((OsMoGroup) selectedObject).getVisibleName(OsMoGroupsActivity.this); - bld.setTitle(getString(R.string.delete_confirmation_msg, name)); + bld.setTitle(getString( + selectedObject instanceof OsMoDevice? R.string.delete_confirmation_msg : + R.string.osmo_leave_confirmation_msg, name)); bld.setPositiveButton(R.string .default_buttons_yes, new DialogInterface.OnClickListener() { @Override @@ -814,11 +816,15 @@ 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); + name.setVisibility(View.VISIBLE); + labelName.setVisibility(View.VISIBLE); mgv.setVisibility(View.GONE); } else { labelTracker.setText(R.string.osmo_connect_to_group_id); labelName.setText(R.string.osmo_group_name); name.setHint(R.string.osmo_use_server_name); + name.setVisibility(View.GONE); + labelName.setVisibility(View.GONE); mgv.setVisibility(View.VISIBLE); } } @@ -833,6 +839,11 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements final String nameUser = name.getText().toString(); final String id = tracker.getText().toString(); final String nick = nickname.getText().toString(); + if(id.length() == 0) { + app.showToastMessage(R.string.osmo_specify_tracker_id); + connectToDevice(); + return; + } if(device.isChecked()) { OsMoDevice dev = osMoPlugin.getGroups().addConnectedDevice(id, nameUser, ColorDialogs.getRandomColor()); From 96112489b310eb604f647e3109d42c1ac656c57f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 31 Jul 2014 01:21:31 +0200 Subject: [PATCH 2/2] Fix osmo --- OsmAnd/res/values/strings.xml | 4 +-- .../osmand/plus/osmo/OsMoGroupsActivity.java | 2 ++ .../src/net/osmand/plus/osmo/OsMoPlugin.java | 10 ++++++ .../src/net/osmand/plus/osmo/OsMoService.java | 32 +++++++++++++++++-- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 6af6ee2ad4..2dd8d4501a 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,8 +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 --> - Leave group %1$s? - Please specify tracker id + Do you want to leave group %1$s? + Please specify id Continue Navigation Pause Navigation Keep diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java index eac8ff5e3e..6301a72559 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoGroupsActivity.java @@ -329,6 +329,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements if(osMoPlugin.getService().isConnected()) { adapter.synchronizeGroups(); } + osMoPlugin.setGroupsActivity(this); } @Override @@ -340,6 +341,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements } app.getLocationProvider().removeLocationListener(this); osMoPlugin.getGroups().setUiListener(null); + osMoPlugin.setGroupsActivity(null); } private void enterSelectionMode(final Object o) { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java index 17e3f1fdbb..16efac4ce6 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoPlugin.java @@ -61,8 +61,10 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer private BaseMapWidget osmoControl; private OsMoPositionLayer olayer; protected MapActivity mapActivity; + protected OsMoGroupsActivity groupsActivity; private final static Log log = PlatformUtil.getLog(OsMoPlugin.class); + public OsMoPlugin(final OsmandApplication app) { service = new OsMoService(app, this); @@ -82,6 +84,14 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer } return true; } + + public OsMoGroupsActivity getGroupsActivity() { + return groupsActivity; + } + + public void setGroupsActivity(OsMoGroupsActivity groupsActivity) { + this.groupsActivity = groupsActivity; + } @Override public void disable(OsmandApplication app) { diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java index fe9f985670..cc41b4bd45 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoService.java @@ -27,11 +27,15 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import android.app.AlertDialog; +import android.app.AlertDialog.Builder; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; +import android.content.DialogInterface; +import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.IntentFilter; import android.os.AsyncTask; @@ -300,8 +304,18 @@ public class OsMoService implements OsMoReactor { } } - private void runNotification(String error) { - if (notification == null) { + private void runNotification(final String error) { + final OsMoGroupsActivity ga = plugin.getGroupsActivity(); + if(ga != null) { + app.runInUIThread(new Runnable() { + + @Override + public void run() { + showRegisterAgain(ga, app.getString(R.string.osmo_auth_error, error)); + + } + }); + } else if (notification == null) { Intent notificationIntent = new Intent(OSMO_REGISTER_AGAIN); PendingIntent intent = PendingIntent.getBroadcast(app, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); @@ -319,6 +333,20 @@ public class OsMoService implements OsMoReactor { } + protected void showRegisterAgain(OsMoGroupsActivity ga, String msg) { + Builder bld = new AlertDialog.Builder(ga); + bld.setMessage(msg); + bld.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() { + + @Override + public void onClick(DialogInterface dialog, int which) { + registerAsync(); + } + }); + bld.setNegativeButton(R.string.default_buttons_cancel, null); + + } + private void showDialogAskToReregister(String error) { // Builder bld = new AlertDialog.Builder(this); // bld.setMessage(app.getString(R.string.osmo_io_error) + error);