Improve fullscreen mode entering

This commit is contained in:
Alexander Sytnyk 2017-11-01 17:08:46 +02:00
parent fe803ac326
commit 840dae932f
8 changed files with 61 additions and 22 deletions

View file

@ -930,6 +930,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public void readLocationToShow() {
mapLayers.getMapControlsLayer().showMapControls();
mapLayers.getMapControlsLayer().showSystemUI();
LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
LatLon latLonToShow = settings.getAndClearMapLocationToShow();

View file

@ -85,6 +85,7 @@ import net.osmand.plus.srtmplugin.ContourLinesMenu;
import net.osmand.plus.srtmplugin.HillshadeMenu;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.DynamicListView;
@ -875,7 +876,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
mapActivity.getMapView().refreshMap();
}
mapActivity.getMapLayers().getMapControlsLayer().showMapControls();
MapControlsLayer controlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
controlsLayer.showMapControls();
controlsLayer.showSystemUI();
hideActionButton();
for (WeakReference<DashBaseFragment> df : fragList) {
if (df.get() != null) {

View file

@ -46,6 +46,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm;
@ -904,7 +905,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
((View) parent).addOnLayoutChangeListener(containerLayoutListener);
}
menu.updateControlsVisibility(true);
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
MapControlsLayer controlsLayer = getMapActivity().getMapLayers().getMapControlsLayer();
controlsLayer.showMapControls();
controlsLayer.showSystemUI();
}
@Override

View file

@ -4,7 +4,6 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -14,6 +13,7 @@ import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.views.MapControlsLayer;
public class MapRouteInfoMenuFragment extends Fragment {
public static final String TAG = "MapRouteInfoMenuFragment";
@ -55,7 +55,9 @@ public class MapRouteInfoMenuFragment extends Fragment {
if (menu == null) {
dismiss();
}
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
MapControlsLayer controlsLayer = getMapActivity().getMapLayers().getMapControlsLayer();
controlsLayer.showMapControls();
controlsLayer.showSystemUI();
}
@Override

View file

@ -53,6 +53,7 @@ import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapMarkersLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
@ -362,10 +363,10 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
public void onResume() {
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMyApplication().getLocationProvider().addLocationListener(this);
}
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
mapActivity.getMyApplication().getLocationProvider().addLocationListener(this);
MapControlsLayer controlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
controlsLayer.showMapControls();
controlsLayer.showSystemUI();
}
@Override

View file

@ -61,6 +61,7 @@ import net.osmand.plus.measurementtool.command.ClearPointsCommand;
import net.osmand.plus.measurementtool.command.MovePointCommand;
import net.osmand.plus.measurementtool.command.RemovePointCommand;
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
@ -461,7 +462,9 @@ public class MeasurementToolFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
getMapActivity().getMapLayers().getMapControlsLayer().showMapControls();
MapControlsLayer controlsLayer = getMapActivity().getMapLayers().getMapControlsLayer();
controlsLayer.showMapControls();
controlsLayer.showSystemUI();
}
@Override

View file

@ -814,7 +814,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (!processed) {
MapControlsLayer controlsLayer = activity.getMapLayers().getMapControlsLayer();
controlsLayer.switchMapControlsVisibility();
controlsLayer.switchStatusbarAndNavbarVisibility();
controlsLayer.switchSystemUiVisibility();
}
return false;
}

View file

@ -656,9 +656,17 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomOutButton.setOnLongClickListener(listener);
}
private boolean switchMapControlsAndSystemUiVisibilityNotAllowed() {
return app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation()
|| mapActivity.getMeasurementToolFragment() != null
|| mapActivity.getPlanRouteFragment() != null
|| mapActivity.getMapLayers().getRulerControlLayer().rulerModeOn();
}
public void showMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
}
public void hideMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
}
@ -673,10 +681,7 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public void switchMapControlsVisibility() {
if (app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation()
|| mapActivity.getMeasurementToolFragment() != null
|| mapActivity.getPlanRouteFragment() != null
|| mapActivity.getMapLayers().getRulerControlLayer().rulerModeOn()) {
if (switchMapControlsAndSystemUiVisibilityNotAllowed()) {
return;
}
if (isMapControlsVisible()) {
@ -686,17 +691,38 @@ public class MapControlsLayer extends OsmandMapLayer {
}
}
public void switchStatusbarAndNavbarVisibility() {
if (Build.VERSION.SDK_INT >= 19) {
View decorView = mapActivity.getWindow().getDecorView();
int uiOptions = decorView.getSystemUiVisibility();
uiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
uiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
uiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
public void showSystemUI() {
if (Build.VERSION.SDK_INT >= 19 && !isSystemUiVisible()) {
switchSystemUiVisibility();
}
}
public void hideSystemUI() {
if (Build.VERSION.SDK_INT >= 19 && isSystemUiVisible()) {
switchSystemUiVisibility();
}
}
public boolean isSystemUiVisible() {
if (Build.VERSION.SDK_INT >= 19) {
int uiOptions = mapActivity.getWindow().getDecorView().getSystemUiVisibility();
return !((uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN) == uiOptions);
}
return true;
}
public void switchSystemUiVisibility() {
if (switchMapControlsAndSystemUiVisibilityNotAllowed() || Build.VERSION.SDK_INT < 19) {
return;
}
View decorView = mapActivity.getWindow().getDecorView();
int uiOptions = decorView.getSystemUiVisibility();
uiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
uiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
uiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
public void startNavigation() {
OsmandApplication app = mapActivity.getMyApplication();
RoutingHelper routingHelper = app.getRoutingHelper();