Fix turn screen on/off
This commit is contained in:
parent
5b399f039b
commit
aee1ab9f87
2 changed files with 19 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public class LockHelper implements SensorEventListener {
|
|||
|
||||
private Handler uiHandler;
|
||||
private OsmandApplication app;
|
||||
private CommonPreference<Boolean> turnScreenOn;
|
||||
private CommonPreference<Integer> turnScreenOnTime;
|
||||
private CommonPreference<Boolean> 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) {
|
||||
|
|
Loading…
Reference in a new issue