Search in sources :

Example 1 with DrawSettings

use of net.osmand.plus.views.OsmandMapLayer.DrawSettings in project Osmand by osmandapp.

the class MapInfoWidgetsFactory method createGPSInfoControl.

public TextInfoWidget createGPSInfoControl(final MapActivity map) {
    final OsmandApplication app = map.getMyApplication();
    final OsmAndLocationProvider loc = app.getLocationProvider();
    final TextInfoWidget gpsInfoControl = new TextInfoWidget(map) {

        private int u = -1;

        private int f = -1;

        @Override
        public boolean updateInfo(DrawSettings d) {
            GPSInfo gpsInfo = loc.getGPSInfo();
            if (gpsInfo.usedSatellites != u || gpsInfo.foundSatellites != f) {
                u = gpsInfo.usedSatellites;
                f = gpsInfo.foundSatellites;
                setText(gpsInfo.usedSatellites + "/" + gpsInfo.foundSatellites, "");
                return true;
            }
            return false;
        }
    };
    gpsInfoControl.setIcons(R.drawable.widget_gps_info_day, R.drawable.widget_gps_info_night);
    gpsInfoControl.setText(null, null);
    gpsInfoControl.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            new StartGPSStatus(map).run();
        }
    });
    return gpsInfoControl;
}
Also used : OsmAndLocationProvider(net.osmand.plus.OsmAndLocationProvider) OsmandApplication(net.osmand.plus.OsmandApplication) OnClickListener(android.view.View.OnClickListener) GPSInfo(net.osmand.plus.OsmAndLocationProvider.GPSInfo) StartGPSStatus(net.osmand.plus.activities.actions.StartGPSStatus) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 2 with DrawSettings

use of net.osmand.plus.views.OsmandMapLayer.DrawSettings in project Osmand by osmandapp.

the class OsmAndMapSurfaceView method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    if (mapView == null) {
        return;
    }
    boolean nightMode = mapView.getApplication().getDaynightHelper().isNightMode();
    DrawSettings drawSettings = new DrawSettings(nightMode, false);
    mapView.drawOverMap(canvas, mapView.getCurrentRotatedTileBox().copy(), drawSettings);
}
Also used : DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 3 with DrawSettings

use of net.osmand.plus.views.OsmandMapLayer.DrawSettings in project Osmand by osmandapp.

the class OsmandMapTileView method refreshMap.

// this method could be called in non UI thread
public void refreshMap(final boolean updateVectorRendering) {
    if (view != null && view.isShown()) {
        boolean nightMode = application.getDaynightHelper().isNightMode();
        Boolean currentNightMode = this.nightMode;
        boolean forceUpdateVectorDrawing = currentNightMode != null && currentNightMode != nightMode;
        if (forceUpdateVectorDrawing) {
            resetDefaultColor();
        }
        this.nightMode = nightMode;
        DrawSettings drawSettings = new DrawSettings(nightMode, updateVectorRendering || forceUpdateVectorDrawing);
        sendRefreshMapMsg(drawSettings, 20);
        refreshBufferImage(drawSettings);
    }
}
Also used : DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 4 with DrawSettings

use of net.osmand.plus.views.OsmandMapLayer.DrawSettings in project Osmand by osmandapp.

the class OsmAndMapLayersView method onDraw.

@Override
protected void onDraw(Canvas canvas) {
    if (mapView == null) {
        return;
    }
    boolean nightMode = mapView.getApplication().getDaynightHelper().isNightMode();
    DrawSettings drawSettings = new DrawSettings(nightMode, false);
    mapView.drawOverMap(canvas, mapView.getCurrentRotatedTileBox().copy(), drawSettings);
}
Also used : DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Example 5 with DrawSettings

use of net.osmand.plus.views.OsmandMapLayer.DrawSettings in project Osmand by osmandapp.

the class RouteInfoWidgetsFactory method createNextInfoControl.

public NextTurnInfoWidget createNextInfoControl(final Activity activity, final OsmandApplication app, boolean horisontalMini) {
    final OsmandSettings settings = app.getSettings();
    final RoutingHelper routingHelper = app.getRoutingHelper();
    final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini) {

        NextDirectionInfo calc1 = new NextDirectionInfo();

        @Override
        public boolean updateInfo(DrawSettings drawSettings) {
            boolean followingMode = routingHelper.isFollowingMode() || app.getLocationProvider().getLocationSimulation().isRouteAnimating();
            TurnType turnType = null;
            boolean deviatedFromRoute = false;
            int turnImminent = 0;
            int nextTurnDistance = 0;
            if (routingHelper != null && routingHelper.isRouteCalculated() && followingMode) {
                deviatedFromRoute = routingHelper.isDeviatedFromRoute();
                if (deviatedFromRoute) {
                    turnImminent = 0;
                    turnType = TurnType.valueOf(TurnType.OFFR, settings.DRIVING_REGION.get().leftHandDriving);
                    setDeviatePath((int) routingHelper.getRouteDeviation());
                } else {
                    NextDirectionInfo r = routingHelper.getNextRouteDirectionInfo(calc1, true);
                    if (r != null && r.distanceTo > 0 && r.directionInfo != null) {
                        turnType = r.directionInfo.getTurnType();
                        nextTurnDistance = r.distanceTo;
                        turnImminent = r.imminent;
                    }
                }
            }
            setTurnType(turnType);
            setTurnImminent(turnImminent, deviatedFromRoute);
            setTurnDistance(nextTurnDistance);
            return true;
        }
    };
    nextTurnInfo.setOnClickListener(new View.OnClickListener() {

        // int i = 0;
        // boolean leftSide = false;
        @Override
        public void onClick(View v) {
            // TurnPathHelper.calcTurnPath(nextTurnInfo.pathForTurn, nextTurnInfo.turnType,nextTurnInfo.pathTransform);
            if (routingHelper.isRouteCalculated() && !routingHelper.isDeviatedFromRoute()) {
                routingHelper.getVoiceRouter().announceCurrentDirection(null);
            }
        }
    });
    // initial state
    return nextTurnInfo;
}
Also used : NextDirectionInfo(net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TurnType(net.osmand.router.TurnType) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) OsmandSettings(net.osmand.plus.OsmandSettings) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) Paint(android.graphics.Paint) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Aggregations

DrawSettings (net.osmand.plus.views.OsmandMapLayer.DrawSettings)20 View (android.view.View)10 TextView (android.widget.TextView)9 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)9 Paint (android.graphics.Paint)7 ImageView (android.widget.ImageView)7 OsmandApplication (net.osmand.plus.OsmandApplication)6 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)6 Location (net.osmand.Location)4 LatLon (net.osmand.data.LatLon)4 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 TextInfoWidget (net.osmand.plus.views.mapwidgets.TextInfoWidget)3 Message (android.os.Message)2 OnClickListener (android.view.View.OnClickListener)2 OsmAndLocationProvider (net.osmand.plus.OsmAndLocationProvider)2 OsmandSettings (net.osmand.plus.OsmandSettings)2 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 GeomagneticField (android.hardware.GeomagneticField)1 ListPopupWindow (android.support.v7.widget.ListPopupWindow)1