From 67d6bba73e4c345e25047c4f15df1b8286f07d7c Mon Sep 17 00:00:00 2001 From: max-klaus Date: Sat, 9 Nov 2019 17:44:29 +0300 Subject: [PATCH] Fix #7830 --- .../osmand/plus/activities/MapActivity.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 51e7071437..1dc9c484a7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -239,9 +239,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven private boolean stopped = true; private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); - private LockHelper lockHelper; + private StateChangedListener mapScreenOrientationSettingListener = new StateChangedListener() { + @Override + public void stateChanged(Integer change) { + applyScreenOrientation(); + } + }; + @Override public void onCreate(Bundle savedInstanceState) { setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this)); @@ -951,10 +957,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (SecondSplashScreenFragment.VISIBLE) { dismissSecondSplashScreen(); } - //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); - if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { - setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); - } + applyScreenOrientation(); + } + + settings.MAP_SCREEN_ORIENTATION.addListener(mapScreenOrientationSettingListener); + } + + public void applyScreenOrientation() { + if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { + setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); } } @@ -1060,10 +1071,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven if (fragment != null) { getSupportFragmentManager().beginTransaction().remove(fragment).commitAllowingStateLoss(); } - //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); - if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { - setRequestedOrientation(app.getSettings().MAP_SCREEN_ORIENTATION.get()); - } + applyScreenOrientation(); } } @@ -1439,6 +1447,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } private void onPauseActivity() { + settings.MAP_SCREEN_ORIENTATION.removeListener(mapScreenOrientationSettingListener); if (!app.getRoutingHelper().isRouteWasFinished()) { DestinationReachedMenu.resetShownState(); } @@ -1499,6 +1508,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } }); getMapView().refreshMap(true); + applyScreenOrientation(); getMyApplication().getNotificationHelper().refreshNotifications(); }