Search in sources :

Example 1 with BaseOsmAndFragment

use of net.osmand.plus.base.BaseOsmAndFragment in project Osmand by osmandapp.

the class MapActivity method updateStatusBarColor.

public void updateStatusBarColor() {
    if (Build.VERSION.SDK_INT >= 21) {
        int colorId = -1;
        BaseOsmAndFragment fragmentAboveDashboard = getVisibleBaseOsmAndFragment(R.id.fragmentContainer);
        BaseOsmAndFragment fragmentBelowDashboard = getVisibleBaseOsmAndFragment(R.id.routeMenuContainer, R.id.topFragmentContainer, R.id.bottomFragmentContainer);
        if (fragmentAboveDashboard != null) {
            colorId = fragmentAboveDashboard.getStatusBarColorId();
        } else if (dashboardOnMap.isVisible()) {
            colorId = dashboardOnMap.getStatusBarColor();
        } else if (fragmentBelowDashboard != null) {
            colorId = fragmentBelowDashboard.getStatusBarColorId();
        } else if (mapLayers.getMapQuickActionLayer() != null && mapLayers.getMapQuickActionLayer().isWidgetVisible()) {
            colorId = R.color.status_bar_transparent_gradient;
        }
        if (colorId != -1) {
            getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
            return;
        }
        boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
        boolean night = app.getDaynightHelper().isNightModeForMapControls();
        boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
        boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
        boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
        boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
        if (((quickSearchTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
            colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
        } else if (markerTopBar && mapControlsVisible) {
            colorId = R.color.status_bar_dark;
        } else {
            colorId = night ? R.color.status_bar_transparent_dark : R.color.status_bar_transparent_light;
        }
        getWindow().setStatusBarColor(ContextCompat.getColor(this, colorId));
    }
}
Also used : BaseOsmAndFragment(net.osmand.plus.base.BaseOsmAndFragment) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) QuadPoint(net.osmand.data.QuadPoint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)

Aggregations

QuadPoint (net.osmand.data.QuadPoint)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 BaseOsmAndFragment (net.osmand.plus.base.BaseOsmAndFragment)1 NewGpxPoint (net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)1