diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 21c5da833a..38987e5315 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,7 @@
1. 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
-->
+ Previous navigation was unfinished. Continue following it? (%1$s seconds)
Route will be recalculated when location will be found
Hours
Minutes
@@ -759,7 +760,6 @@ You can enable (online or cached) tile map sources, tracking settings, and many
POI…
Map source…
Define view
- Previous navigation was unfinished. Continue following it?
Search POI
Show route from here
Use trackball to move map
diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
index e32cf256b4..4f0c214803 100644
--- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java
+++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java
@@ -15,16 +15,12 @@ import net.osmand.FavouritePoint;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
-import net.osmand.plus.FavouritesDbHelper;
-import net.osmand.plus.NavigationService;
-import net.osmand.plus.OsmandSettings;
-import net.osmand.plus.PoiFiltersHelper;
-import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.LogUtil;
import net.osmand.access.AccessibilityMode;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.activities.DayNightHelper;
import net.osmand.plus.activities.LiveMonitoringHelper;
+import net.osmand.plus.activities.OsmandIntents;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.render.NativeOsmandLibrary;
@@ -35,9 +31,11 @@ import net.osmand.plus.voice.CommandPlayerException;
import net.osmand.plus.voice.CommandPlayerFactory;
import net.osmand.render.RenderingRulesStorage;
import android.app.Activity;
+import android.app.AlarmManager;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Application;
+import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
@@ -483,9 +481,12 @@ public class OsmandApplication extends Application {
private class DefaultExceptionHandler implements UncaughtExceptionHandler {
private UncaughtExceptionHandler defaultHandler;
+ private PendingIntent intent;
public DefaultExceptionHandler() {
defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
+ intent = PendingIntent.getActivity(OsmandApplication.this.getBaseContext(), 0,
+ new Intent(OsmandApplication.this.getBaseContext(), OsmandIntents.getMainMenuActivity()), 0);
}
@Override
@@ -506,6 +507,11 @@ public class OsmandApplication extends Application {
writer.write(msg.toString());
writer.close();
}
+ if(routingHelper.isFollowingMode()) {
+ AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000, intent);
+ System.exit(2);
+ }
defaultHandler.uncaughtException(thread, ex);
} catch (Exception e) {
// swallow all exceptions
diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java
index 282ffe5782..7d4e163f63 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java
@@ -235,7 +235,13 @@ public class MainMenuActivity extends Activity {
if(exit){
return;
}
-
+ OsmandApplication app = ((OsmandApplication) getApplication());
+ // restore follow route mode
+ if(app.getSettings().FOLLOW_THE_ROUTE.get() && !app.getRoutingHelper().isRouteCalculated()){
+ final Intent mapIndent = new Intent(this, OsmandIntents.getMapActivity());
+ startActivityForResult(mapIndent, 0);
+ return;
+ }
startProgressDialog = new ProgressDialog(this);
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 4b520bf5c4..f50d50964e 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -34,6 +34,7 @@ import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.PointLocationLayer;
import android.app.Activity;
+import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.Notification;
@@ -41,6 +42,8 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnCancelListener;
+import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
@@ -71,6 +74,9 @@ import android.view.Window;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;
+import android.widget.FrameLayout.LayoutParams;
+import android.widget.LinearLayout;
+import android.widget.TextView;
import android.widget.Toast;
public class MapActivity extends AccessibleActivity implements IMapLocationListener, SensorEventListener {
@@ -169,6 +175,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
+ getMyApplication().getResourceManager().getRenderer().clearCache();
mapView.refreshMap(true);
}
});
@@ -324,11 +331,65 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
if (pointToNavigate == null && gpxPath == null) {
notRestoreRoutingMode();
} else {
- Builder builder = new AccessibleAlertBuilder(MapActivity.this);
- builder.setMessage(R.string.continue_follow_previous_route);
- builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
+ Runnable encapsulate = new Runnable() {
+ int delay = 7;
+ boolean quit = false;
+ Runnable delayDisplay = null;
+
@Override
- public void onClick(DialogInterface dialog, int which) {
+ public void run() {
+ Builder builder = new AccessibleAlertBuilder(MapActivity.this);
+ final TextView tv = new TextView(MapActivity.this);
+ tv.setText(getString(R.string.continue_follow_previous_route_auto, delay + ""));
+ tv.setPadding(7, 5, 7, 5);
+ builder.setView(tv);
+ builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ restoreRoutingMode();
+
+ }
+ });
+ builder.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ notRestoreRoutingMode();
+ quit = true;
+ }
+ });
+ final AlertDialog dlg = builder.show();
+ dlg.setOnDismissListener(new OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ quit = true;
+ }
+ });
+ dlg.setOnCancelListener(new OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ quit = true;
+ }
+ });
+ delayDisplay = new Runnable() {
+ @Override
+ public void run() {
+ if(!quit) {
+ delay --;
+ tv.setText(getString(R.string.continue_follow_previous_route_auto, delay + ""));
+ if(delay <= 0) {
+ dlg.dismiss();
+ restoreRoutingMode();
+ } else {
+ uiHandler.postDelayed(delayDisplay, 1000);
+ }
+ }
+ }
+ };
+ delayDisplay.run();
+ }
+
+ private void restoreRoutingMode() {
+ quit = true;
AsyncTask task = new AsyncTask() {
@Override
protected GPXFile doInBackground(String... params) {
@@ -361,14 +422,8 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
task.execute(gpxPath);
}
- });
- builder.setNegativeButton(R.string.default_buttons_no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- notRestoreRoutingMode();
- }
- });
- builder.show();
+ };
+ encapsulate.run();
}
}
@@ -383,13 +438,13 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
@Override
protected Dialog onCreateDialog(int id) {
- Dialog dialog = null;
- for (DialogProvider dp : dialogProviders) {
- dialog = dp.onCreateDialog(id);
- if (dialog != null) {
- return dialog;
+ Dialog dialog = null;
+ for (DialogProvider dp : dialogProviders) {
+ dialog = dp.onCreateDialog(id);
+ if (dialog != null) {
+ return dialog;
+ }
}
- }
if (id == OsmandApplication.PROGRESS_DIALOG) {
return startProgressDialog;
}