diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index bfa7cfcbbc..b0cbeaf65b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -909,6 +909,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } } + public void setKeepScreenOn(boolean keepScreenOn) { + View mainView = findViewById(R.id.MapViewWithLayers); + if (mainView != null) { + mainView.setKeepScreenOn(keepScreenOn); + } + } + private void clearIntent(Intent intent) { intent.setAction(null); intent.setData(null); @@ -1397,6 +1404,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } public void updateApplicationModeSettings() { + changeKeyguardFlags(true); updateMapSettings(); mapViewTrackingUtilities.updateSettings(); //app.getRoutingHelper().setAppMode(settings.getApplicationMode()); @@ -1898,8 +1906,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (enable) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + setKeepScreenOn(true); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + setKeepScreenOn(false); } } @@ -1976,12 +1986,14 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven @Override public void routeWasCancelled() { + changeKeyguardFlags(true); } @Override public void routeWasFinished() { if (!mIsDestroyed) { DestinationReachedMenu.show(this); + changeKeyguardFlags(true); } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java index 7fb21e4724..5d7c2cf403 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/LockHelper.java @@ -28,6 +28,7 @@ public class LockHelper implements SensorEventListener { private Handler uiHandler; private OsmandApplication app; + private CommonPreference turnScreenOn; private CommonPreference turnScreenOnTime; private CommonPreference turnScreenOnSensor; @@ -91,11 +92,15 @@ public class LockHelper implements SensorEventListener { private void lock() { releaseWakeLocks(); - if (lockUIAdapter != null) { + if (lockUIAdapter != null && isFollowingMode()) { lockUIAdapter.lock(); } } + private boolean isFollowingMode() { + return app.getRoutingHelper().isFollowingMode(); + } + private void timedUnlock(final long millis) { uiHandler.removeCallbacks(lockRunnable); uiHandler.post(new Runnable() { @@ -149,7 +154,7 @@ public class LockHelper implements SensorEventListener { } private boolean isSensorEnabled() { - return turnScreenOnSensor.get() && app.getRoutingHelper().isFollowingMode(); + return turnScreenOnSensor.get() && isFollowingMode(); } public void onStart(@NonNull Activity activity) {