diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index a10517e7a8..3a18179ede 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -11,9 +11,10 @@
Thx - Hardy
-->
- Set the time for which the screen will turn on.
- Use proximity sensor
- Wave your hand over the top of the screen to turn on the screen while navigating.
+ Wake on turn
+ Set the time for which the screen will turn on.
+ Use proximity sensor
+ Wave your hand over the top of the screen to turn on the screen while navigating.
Please give us 30 seconds, share feedback and rate our work on Google Play.
Rate
diff --git a/OsmAnd/res/xml/navigation_settings.xml b/OsmAnd/res/xml/navigation_settings.xml
index 83805332c3..a7cc75484c 100644
--- a/OsmAnd/res/xml/navigation_settings.xml
+++ b/OsmAnd/res/xml/navigation_settings.xml
@@ -74,18 +74,20 @@
+ android:title="@string/wake_on_voice">
+ android:key="turn_screen_on_router"
+ android:summary="@string/wake_on_voice_descr"
+ android:title="@string/turn_screen_on_router"/>
+
WAKE_ON_VOICE_TIME_INT = new IntPreference("wake_on_voice_time_int", 0).makeProfile();
+ public final CommonPreference TURN_SCREEN_ON_TIME_INT = new IntPreference("turn_screen_on_time_int", 0).makeGlobal();
+
+ public final CommonPreference TURN_SCREEN_ON_ROUTER = new BooleanPreference("turn_screen_on_router", false).makeProfile();
{
- WAKE_ON_VOICE_TIME_INT.setModeDefaultValue(ApplicationMode.CAR, 0);
- WAKE_ON_VOICE_TIME_INT.setModeDefaultValue(ApplicationMode.BICYCLE, 0);
- WAKE_ON_VOICE_TIME_INT.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0);
+ TURN_SCREEN_ON_ROUTER.setModeDefaultValue(ApplicationMode.CAR, false);
+ TURN_SCREEN_ON_ROUTER.setModeDefaultValue(ApplicationMode.BICYCLE, false);
+ TURN_SCREEN_ON_ROUTER.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
}
- public final CommonPreference WAKE_ON_VOICE_SENSOR = new BooleanPreference("wake_on_voice_sensor", false).makeProfile();
-
- {
- WAKE_ON_VOICE_SENSOR.setModeDefaultValue(ApplicationMode.CAR, false);
- WAKE_ON_VOICE_SENSOR.setModeDefaultValue(ApplicationMode.BICYCLE, false);
- WAKE_ON_VOICE_SENSOR.setModeDefaultValue(ApplicationMode.PEDESTRIAN, false);
- }
+ public final CommonPreference TURN_SCREEN_ON_SENSOR = new BooleanPreference("turn_screen_on_sensor", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
// try without AUTO_FOLLOW_ROUTE_NAV (see forum discussion 'Simplify our navigation preference menu')
diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
index 79dc48d6da..f07da70c30 100644
--- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java
@@ -1415,6 +1415,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
getMapView().refreshMap(true);
}
});
+ lockHelper.refreshProfilesSettings();
getMapView().refreshMap(true);
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
index 6b419f05f5..fcb0d81720 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsNavigationActivity.java
@@ -3,7 +3,6 @@ package net.osmand.plus.activities;
import android.content.Context;
import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent;
import android.media.AudioManager;
@@ -17,19 +16,14 @@ import android.preference.PreferenceScreen;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.util.TypedValue;
-import android.view.ContextThemeWrapper;
-import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
-import android.widget.SeekBar;
-import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
-import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap;
@@ -44,7 +38,6 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.router.GeneralRouter;
-import net.osmand.router.GeneralRouter.GeneralRouterProfile;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.router.GeneralRouter.RoutingParameterType;
import net.osmand.util.Algorithms;
@@ -186,12 +179,12 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
selectAppModeDialog().show();
}
- addWakeOnVoice((PreferenceGroup) screen.findPreference("turn_screen_on"));
+ addTurnScreenOn((PreferenceGroup) screen.findPreference("turn_screen_on"));
addVoicePrefs((PreferenceGroup) screen.findPreference("voice"));
}
- private void addWakeOnVoice(PreferenceGroup screen) {
+ private void addTurnScreenOn(PreferenceGroup screen) {
Integer[] screenPowerSaveValues = new Integer[] { 0, 5, 10, 15, 20, 30, 45, 60 };
String[] screenPowerSaveNames = new String[screenPowerSaveValues.length];
screenPowerSaveNames[0] = getString(R.string.shared_string_never);
@@ -199,8 +192,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
screenPowerSaveNames[i] = screenPowerSaveValues[i] + " "
+ getString(R.string.int_seconds);
}
- registerListPreference(settings.WAKE_ON_VOICE_TIME_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
- registerBooleanPreference(settings.WAKE_ON_VOICE_SENSOR, screen);
+ registerListPreference(settings.TURN_SCREEN_ON_TIME_INT, screen, screenPowerSaveNames, screenPowerSaveValues);
+ registerBooleanPreference(settings.TURN_SCREEN_ON_ROUTER, screen);
+ registerBooleanPreference(settings.TURN_SCREEN_ON_SENSOR, screen);
}
private void reloadVoiceListPreference(PreferenceScreen screen) {
@@ -402,6 +396,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
return true;
}
super.onPreferenceChange(preference, newValue);
+ if (id.equals(settings.TURN_SCREEN_ON_ROUTER.getId())) {
+ boolean isRoutingListnerEnabled = Boolean.valueOf(newValue.toString());
+ getMyApplication().getLockHelper().setVoiceRouterListener(isRoutingListnerEnabled);
+ } else if (id.equals(settings.TURN_SCREEN_ON_SENSOR.getId())) {
+ boolean isSensorEnabled = Boolean.valueOf(newValue.toString());
+ getMyApplication().getLockHelper().setSensor(isSensorEnabled);
+ }
return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
index 1dfdea05dd..9600d011ef 100644
--- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java
@@ -204,7 +204,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
}
registerUnregisterSensor(location, smallSpeedForDirectionOfMovement);
if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation &&
- settings.WAKE_ON_VOICE_TIME_INT.get() == 0) {
+ settings.TURN_SCREEN_ON_TIME_INT.get() == 0) {
mapView.getAnimatedDraggingThread().startMoving(
location.getLatitude(), location.getLongitude(), zoom, rotation, false);
} else {
diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
index d2680625cf..feddc624de 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java
@@ -11,6 +11,7 @@ import android.os.PowerManager;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
+import net.osmand.plus.OsmandSettings;
import net.osmand.plus.routing.VoiceRouter;
public class LockHelper implements SensorEventListener {
@@ -25,6 +26,7 @@ public class LockHelper implements SensorEventListener {
private OsmandApplication app;
private LockRunnable lockRunnable;
private LockUIAdapter lockUIAdapter;
+ private OsmandSettings settings;
private VoiceRouter.VoiceMessageListener voiceMessageListener;
@@ -46,6 +48,7 @@ public class LockHelper implements SensorEventListener {
this.app = app;
uiHandler = new Handler();
lockRunnable = new LockRunnable();
+ settings = app.getSettings();
mSensorManager = (SensorManager) app.getSystemService(Context.SENSOR_SERVICE);
mProximity = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
@@ -56,9 +59,8 @@ public class LockHelper implements SensorEventListener {
unlockEvent();
}
};
-
- setVoiceRouterListener(true);
- setSensor(true);
+
+ refreshGlobalSettings();
}
private void releaseWakeLocks() {
@@ -99,7 +101,7 @@ public class LockHelper implements SensorEventListener {
boolean isScreenOn = AndroidUtils.isScreenOn(app);
boolean isScreenLocked = AndroidUtils.isScreenLocked(app);
- Integer screenPowerSave = app.getSettings().WAKE_ON_VOICE_TIME_INT.get();
+ Integer screenPowerSave = app.getSettings().TURN_SCREEN_ON_TIME_INT.get();
if ((isScreenOn || isScreenLocked) && screenPowerSave > 0) {
timedUnlock(screenPowerSave * 1000L);
@@ -113,11 +115,9 @@ public class LockHelper implements SensorEventListener {
@Override
public void onSensorChanged(SensorEvent event) {
- if (isSensorEnabled()) {
- if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) {
- if (event.values[0] >= -SENSOR_SENSITIVITY && event.values[0] <= SENSOR_SENSITIVITY) {
- unlockEvent();
- }
+ if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) {
+ if (event.values[0] >= -SENSOR_SENSITIVITY && event.values[0] <= SENSOR_SENSITIVITY) {
+ unlockEvent();
}
}
}
@@ -139,8 +139,14 @@ public class LockHelper implements SensorEventListener {
}
}
- private boolean isSensorEnabled() {
- return app.getSettings().WAKE_ON_VOICE_SENSOR.get();
+ public void refreshProfilesSettings() {
+ boolean isVRListenerEnabled = settings.TURN_SCREEN_ON_ROUTER.get();
+ setVoiceRouterListener(isVRListenerEnabled);
+ }
+
+ public void refreshGlobalSettings() {
+ boolean isSensorEnabled = settings.TURN_SCREEN_ON_SENSOR.get();
+ setSensor(isSensorEnabled);
}
public void setLockUIAdapter(LockUIAdapter adapter) {