This commit is contained in:
max-klaus 2019-11-09 17:44:29 +03:00
parent 2f81184d4f
commit 67d6bba73e

View file

@ -239,9 +239,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private boolean stopped = true; private boolean stopped = true;
private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(); private ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
private LockHelper lockHelper; private LockHelper lockHelper;
private StateChangedListener<Integer> mapScreenOrientationSettingListener = new StateChangedListener<Integer>() {
@Override
public void stateChanged(Integer change) {
applyScreenOrientation();
}
};
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this)); setRequestedOrientation(AndroidUiHelper.getScreenOrientation(this));
@ -951,10 +957,15 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
if (SecondSplashScreenFragment.VISIBLE) { if (SecondSplashScreenFragment.VISIBLE) {
dismissSecondSplashScreen(); dismissSecondSplashScreen();
} }
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); applyScreenOrientation();
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { }
setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());
} 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) { if (fragment != null) {
getSupportFragmentManager().beginTransaction().remove(fragment).commitAllowingStateLoss(); getSupportFragmentManager().beginTransaction().remove(fragment).commitAllowingStateLoss();
} }
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); applyScreenOrientation();
if (app.getSettings().MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
setRequestedOrientation(app.getSettings().MAP_SCREEN_ORIENTATION.get());
}
} }
} }
@ -1439,6 +1447,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
private void onPauseActivity() { private void onPauseActivity() {
settings.MAP_SCREEN_ORIENTATION.removeListener(mapScreenOrientationSettingListener);
if (!app.getRoutingHelper().isRouteWasFinished()) { if (!app.getRoutingHelper().isRouteWasFinished()) {
DestinationReachedMenu.resetShownState(); DestinationReachedMenu.resetShownState();
} }
@ -1499,6 +1508,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
}); });
getMapView().refreshMap(true); getMapView().refreshMap(true);
applyScreenOrientation();
getMyApplication().getNotificationHelper().refreshNotifications(); getMyApplication().getNotificationHelper().refreshNotifications();
} }