Merge pull request #4681 from osmandapp/fullscreen_mode

Fullscreen mode
This commit is contained in:
Alexey 2017-11-01 18:54:45 +03:00 committed by GitHub
commit 2e4c51c7c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 8 deletions

View file

@ -243,6 +243,38 @@ public class AndroidUtils {
return new PointF(centroidX, centroidY);
}
public static void showSystemUI(Activity activity) {
if (Build.VERSION.SDK_INT >= 19 && !isSystemUiVisible(activity)) {
switchSystemUiVisibility(activity);
}
}
public static void hideSystemUI(Activity activity) {
if (Build.VERSION.SDK_INT >= 19 && isSystemUiVisible(activity)) {
switchSystemUiVisibility(activity);
}
}
public static boolean isSystemUiVisible(Activity activity) {
if (Build.VERSION.SDK_INT >= 19) {
int uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
return !((uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN) == uiOptions);
}
return true;
}
public static void switchSystemUiVisibility(Activity activity) {
if (Build.VERSION.SDK_INT < 19) {
return;
}
View decorView = activity.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 static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {

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;

View file

@ -362,10 +362,8 @@ 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);
mapActivity.getMapLayers().getMapControlsLayer().showMapControls();
}
@Override

View file

@ -812,7 +812,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
boolean processed = hideVisibleMenues();
processed |= menu.onSingleTapOnMap();
if (!processed) {
activity.getMapLayers().getMapControlsLayer().switchMapControlsVisibility();
activity.getMapLayers().getMapControlsLayer().switchMapControlsVisibility(true);
}
return false;
}

View file

@ -48,7 +48,6 @@ import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.corenative.NativeCoreContext;
@ -659,7 +658,9 @@ public class MapControlsLayer extends OsmandMapLayer {
public void showMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
AndroidUtils.showSystemUI(mapActivity);
}
public void hideMapControls() {
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
}
@ -673,7 +674,7 @@ public class MapControlsLayer extends OsmandMapLayer {
return mapActivity.findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
}
public void switchMapControlsVisibility() {
public void switchMapControlsVisibility(boolean switchSystemUiVisibility) {
if (app.getRoutingHelper().isFollowingMode() || app.getRoutingHelper().isPauseNavigation()
|| mapActivity.getMeasurementToolFragment() != null
|| mapActivity.getPlanRouteFragment() != null
@ -682,6 +683,9 @@ public class MapControlsLayer extends OsmandMapLayer {
}
if (isMapControlsVisible()) {
hideMapControls();
if (switchSystemUiVisibility) {
AndroidUtils.hideSystemUI(mapActivity);
}
} else {
showMapControls();
}