diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java index ea18f04b2f..26828f5cd5 100644 --- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java @@ -10,9 +10,6 @@ public class ToDoConstants { // TODO ANDROID // for 0.3 - // 68. Implement service to app work with screen offline - // (audio guidance & add new item to status bar & introduce error interval for gps building) - // for offline service save gpx (combine in one trkseg) // 71. Implement different mechanism for tiles (big sqlite planet see rmaps) // Improvement : Show stops in the transport route on the map @@ -31,9 +28,7 @@ public class ToDoConstants { // FIXME // 2. Bug with network location while routing (?) - fixed ? - // 3. TODO options : using trackball as an option - // 4. Add last turn as go straight (+) - // 5. After return if there was previous route (countinue follow) + // 5. After return if there was previous route (continue follow) // 6. Bug 13. @@ -63,6 +58,8 @@ public class ToDoConstants { // BUGS Swing // DONE ANDROID : + // 68. Implement service to app work with screen offline + // (audio guidance & add new item to status bar & introduce error interval for gps in buildings) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 4921ea7e9c..857d114515 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1,8 +1,14 @@ + Использовать трекбол, чтобы перемещать карту + Использовать трекбол + Выберите время поиска позиции сервиса + Время ожидания + Остановить фоновый сервис Где я? Сеть GPS + секунд мин. Выберите интервал позиционирования для сервиса Интервал позиционирования diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 0faccbeb64..db3da9c630 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1,9 +1,15 @@ + Use trackball to move map + Use trackball + Choose wait interval determining location + Wait interval + Switch off background navigation service Where am I? Osmand navigation service Network GPS + seconds min. Choose interval to determine location for background service Positioning interval diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index c72a60456d..16e730b63e 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -15,6 +15,7 @@ + @@ -29,6 +30,7 @@ + diff --git a/OsmAnd/src/com/osmand/NavigationService.java b/OsmAnd/src/com/osmand/NavigationService.java index ad510a2907..f5f7ad8310 100644 --- a/OsmAnd/src/com/osmand/NavigationService.java +++ b/OsmAnd/src/com/osmand/NavigationService.java @@ -1,8 +1,14 @@ package com.osmand; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; import android.app.Service; +import android.content.BroadcastReceiver; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; @@ -20,6 +26,8 @@ public class NavigationService extends Service implements LocationListener { public static class NavigationServiceBinder extends Binder { } + private final static int NOTIFICATION_SERVICE_ID = 1; + public final static String OSMAND_STOP_SERVICE_ACTION = "OSMAND_STOP_SERVICE_ACTION"; //$NON-NLS-1$ private NavigationServiceBinder binder = new NavigationServiceBinder(); private int serviceOffInterval; private String serviceOffProvider; @@ -27,6 +35,8 @@ public class NavigationService extends Service implements LocationListener { private Handler handler; private int serviceError; private RoutingHelper routingHelper; + private Notification notification; + @Override public IBinder onBind(Intent intent) { @@ -51,7 +61,7 @@ public class NavigationService extends Service implements LocationListener { } - }, serviceError); + }, delay); } @@ -63,11 +73,29 @@ public class NavigationService extends Service implements LocationListener { serviceOffInterval = OsmandSettings.getServiceOffInterval(this); serviceOffProvider = OsmandSettings.getServiceOffProvider(this); - serviceError = OsmandSettings.getServiceOffErrorInterval(this); + serviceError = OsmandSettings.getServiceOffWaitInterval(this); savingTrackHelper = new SavingTrackHelper(this); delayedAction(true, 500); routingHelper = RoutingHelper.getInstance(this); OsmandSettings.setServiceOffEnabled(this, true); + + registerReceiver(new BroadcastReceiver(){ + @Override + public void onReceive(Context context, Intent intent) { + NavigationService.this.stopSelf(); + } + + }, new IntentFilter(OSMAND_STOP_SERVICE_ACTION)); + + Intent notificationIntent = new Intent(OSMAND_STOP_SERVICE_ACTION); + notification = new Notification(R.drawable.icon, "", //$NON-NLS-1$ + System.currentTimeMillis()); + notification.flags = Notification.FLAG_NO_CLEAR; + notification.setLatestEventInfo(this, Version.APP_NAME, + getString(R.string.service_stop_background_service), PendingIntent.getBroadcast(this, 0, notificationIntent, + PendingIntent.FLAG_UPDATE_CURRENT)); + NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + mNotificationManager.notify(NOTIFICATION_SERVICE_ID, notification); } @@ -77,6 +105,9 @@ public class NavigationService extends Service implements LocationListener { LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); locationManager.removeUpdates(this); OsmandSettings.setServiceOffEnabled(this, false); + NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + mNotificationManager.cancel(NOTIFICATION_SERVICE_ID); + } diff --git a/OsmAnd/src/com/osmand/OsmandSettings.java b/OsmAnd/src/com/osmand/OsmandSettings.java index b9c7f6befd..a938916beb 100644 --- a/OsmAnd/src/com/osmand/OsmandSettings.java +++ b/OsmAnd/src/com/osmand/OsmandSettings.java @@ -52,6 +52,16 @@ public class OsmandSettings { SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); return prefs.getBoolean(USE_INTERNET_TO_DOWNLOAD_TILES, USE_INTERNET_TO_DOWNLOAD_TILES_DEF); } + + + // this value string is synchronized with settings_pref.xml preference name + public static final String USE_TRACKBALL_FOR_MOVEMENTS = "use_trackball_for_movements"; //$NON-NLS-1$ + public static final boolean USE_TRACKBALL_FOR_MOVEMENTS_DEF = true; + + public static boolean isUsingTrackBall(Context ctx) { + SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); + return prefs.getBoolean(USE_TRACKBALL_FOR_MOVEMENTS, USE_TRACKBALL_FOR_MOVEMENTS_DEF); + } // this value string is synchronized with settings_pref.xml preference name @@ -578,11 +588,11 @@ public class OsmandSettings { // this value string is synchronized with settings_pref.xml preference name - public static final String SERVICE_OFF_ERROR_INTERVAL = "service_off_error_interval"; //$NON-NLS-1$ - public static final int SERVICE_OFF_ERROR_INTERVAL_DEF = 60 * 1000; - public static int getServiceOffErrorInterval(Context ctx) { + public static final String SERVICE_OFF_WAIT_INTERVAL = "service_off_wait_interval"; //$NON-NLS-1$ + public static final int SERVICE_OFF_WAIT_INTERVAL_DEF = 90 * 1000; + public static int getServiceOffWaitInterval(Context ctx) { SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); - return prefs.getInt(SERVICE_OFF_ERROR_INTERVAL, SERVICE_OFF_ERROR_INTERVAL_DEF); + return prefs.getInt(SERVICE_OFF_WAIT_INTERVAL, SERVICE_OFF_WAIT_INTERVAL_DEF); } diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java index cd1ed3cf31..fa8af51367 100644 --- a/OsmAnd/src/com/osmand/activities/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -298,7 +298,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso } @Override public boolean onTrackballEvent(MotionEvent event) { - if(event.getAction() == MotionEvent.ACTION_MOVE){ + if(event.getAction() == MotionEvent.ACTION_MOVE && OsmandSettings.isUsingTrackBall(this)){ float x = event.getX(); float y = event.getY(); LatLon l = mapView.getLatLonFromScreenPoint(mapView.getCenterPointX() + x * 15, mapView.getCenterPointY() + y * 15); diff --git a/OsmAnd/src/com/osmand/activities/SettingsActivity.java b/OsmAnd/src/com/osmand/activities/SettingsActivity.java index 63a7500850..1bc87d7393 100644 --- a/OsmAnd/src/com/osmand/activities/SettingsActivity.java +++ b/OsmAnd/src/com/osmand/activities/SettingsActivity.java @@ -6,16 +6,18 @@ import java.util.List; import java.util.Set; import android.app.ProgressDialog; +import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.location.LocationManager; -import android.os.Environment; import android.os.Bundle; +import android.os.Environment; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; @@ -82,6 +84,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference private ListPreference mapScreenOrientation; private ListPreference voicePreference; private ListPreference routeServiceInterval; + private ListPreference routeServiceWaitInterval; private ListPreference routeServiceProvider; private CheckBoxPreference routeServiceEnabled; @@ -91,6 +94,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference new BooleanPreference(OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES, OsmandSettings.USE_INTERNET_TO_DOWNLOAD_TILES_DEF), new BooleanPreference(OsmandSettings.ROTATE_MAP_TO_BEARING, OsmandSettings.ROTATE_MAP_TO_BEARING_DEF), new BooleanPreference(OsmandSettings.SHOW_VIEW_ANGLE, OsmandSettings.SHOW_VIEW_ANGLE_DEF), + new BooleanPreference(OsmandSettings.USE_TRACKBALL_FOR_MOVEMENTS, OsmandSettings.USE_TRACKBALL_FOR_MOVEMENTS_DEF), new BooleanPreference(OsmandSettings.USE_ENGLISH_NAMES, OsmandSettings.USE_ENGLISH_NAMES_DEF), new BooleanPreference(OsmandSettings.SHOW_OSM_BUGS, OsmandSettings.SHOW_OSM_BUGS_DEF), new BooleanPreference(OsmandSettings.AUTO_ZOOM_MAP, OsmandSettings.AUTO_ZOOM_MAP_DEF), @@ -145,11 +149,21 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference routeServiceInterval =(ListPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_INTERVAL); routeServiceInterval.setOnPreferenceChangeListener(this); + routeServiceWaitInterval =(ListPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_WAIT_INTERVAL); + routeServiceWaitInterval.setOnPreferenceChangeListener(this); routeServiceProvider =(ListPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_PROVIDER); routeServiceProvider.setOnPreferenceChangeListener(this); routeServiceEnabled =(CheckBoxPreference) screen.findPreference(OsmandSettings.SERVICE_OFF_ENABLED); routeServiceEnabled.setOnPreferenceChangeListener(this); + + registerReceiver(new BroadcastReceiver(){ + @Override + public void onReceive(Context context, Intent intent) { + routeServiceEnabled.setChecked(false); + } + + }, new IntentFilter(NavigationService.OSMAND_STOP_SERVICE_ACTION)); } @Override @@ -194,6 +208,16 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference routeServiceInterval.setEntryValues(ints); routeServiceInterval.setValue(OsmandSettings.getServiceOffInterval(this)/60000+""); //$NON-NLS-1$ + ints = new String[]{"15", "30", "45", "60", "90", "120", "180", "300", "600"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ + intDescriptions = new String[ints.length]; + for(int i=0; i