Search in sources :

Example 1 with DrawSettings

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

the class OsmandMonitoringPlugin method createMonitoringControl.

/**
 * creates (if it wasn't created previously) the control to be added on a MapInfoLayer that shows a monitoring state (recorded/stopped)
 */
private TextInfoWidget createMonitoringControl(final MapActivity map) {
    monitoringControl = new TextInfoWidget(map) {

        long lastUpdateTime;

        @Override
        public boolean updateInfo(DrawSettings drawSettings) {
            if (isSaving) {
                setText(map.getString(R.string.shared_string_save), "");
                setIcons(R.drawable.widget_monitoring_rec_big_day, R.drawable.widget_monitoring_rec_big_night);
                return true;
            }
            String txt = map.getString(R.string.monitoring_control_start);
            String subtxt = null;
            int dn;
            int d;
            long last = lastUpdateTime;
            final boolean globalRecord = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
            final boolean isRecording = app.getSavingTrackHelper().getIsRecording();
            float dist = app.getSavingTrackHelper().getDistance();
            // make sure widget always shows recorded track distance if unsaved track exists
            if (dist > 0) {
                last = app.getSavingTrackHelper().getLastTimeUpdated();
                String ds = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication());
                int ls = ds.lastIndexOf(' ');
                if (ls == -1) {
                    txt = ds;
                } else {
                    txt = ds.substring(0, ls);
                    subtxt = ds.substring(ls + 1);
                }
            }
            final boolean liveMonitoringEnabled = liveMonitoringHelper.isLiveMonitoringEnabled();
            if (globalRecord) {
                // indicates global recording (+background recording)
                if (liveMonitoringEnabled) {
                    dn = R.drawable.widget_live_monitoring_rec_big_night;
                    d = R.drawable.widget_live_monitoring_rec_big_day;
                } else {
                    dn = R.drawable.widget_monitoring_rec_big_night;
                    d = R.drawable.widget_monitoring_rec_big_day;
                }
            } else if (isRecording) {
                // indicates (profile-based, configured in settings) recording (looks like is only active during nav in follow mode)
                if (liveMonitoringEnabled) {
                    dn = R.drawable.widget_live_monitoring_rec_small_night;
                    d = R.drawable.widget_live_monitoring_rec_small_day;
                } else {
                    dn = R.drawable.widget_monitoring_rec_small_night;
                    d = R.drawable.widget_monitoring_rec_small_day;
                }
            } else {
                dn = R.drawable.widget_monitoring_rec_inactive_night;
                d = R.drawable.widget_monitoring_rec_inactive_day;
            }
            setText(txt, subtxt);
            setIcons(d, dn);
            if ((last != lastUpdateTime) && (globalRecord || isRecording)) {
                lastUpdateTime = last;
                // blink implementation with 2 indicator states (global logging + profile/navigation logging)
                if (liveMonitoringEnabled) {
                    dn = R.drawable.widget_live_monitoring_rec_small_night;
                    d = R.drawable.widget_live_monitoring_rec_small_day;
                } else {
                    dn = R.drawable.widget_monitoring_rec_small_night;
                    d = R.drawable.widget_monitoring_rec_small_day;
                }
                setIcons(d, dn);
                map.getMyApplication().runInUIThread(() -> {
                    int dn1;
                    int d1;
                    if (globalRecord) {
                        if (liveMonitoringEnabled) {
                            dn1 = R.drawable.widget_live_monitoring_rec_big_night;
                            d1 = R.drawable.widget_live_monitoring_rec_big_day;
                        } else {
                            dn1 = R.drawable.widget_monitoring_rec_big_night;
                            d1 = R.drawable.widget_monitoring_rec_big_day;
                        }
                    } else {
                        if (liveMonitoringEnabled) {
                            dn1 = R.drawable.widget_live_monitoring_rec_small_night;
                            d1 = R.drawable.widget_live_monitoring_rec_small_day;
                        } else {
                            dn1 = R.drawable.widget_monitoring_rec_small_night;
                            d1 = R.drawable.widget_monitoring_rec_small_day;
                        }
                    }
                    setIcons(d1, dn1);
                }, 500);
            }
            return true;
        }
    };
    monitoringControl.updateInfo(null);
    // monitoringControl.addView(child);
    monitoringControl.setOnClickListener(v -> controlDialog(map));
    return monitoringControl;
}
Also used : TextInfoWidget(net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget) DrawSettings(net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)

Example 2 with DrawSettings

use of net.osmand.plus.views.layers.base.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.layers.base.OsmandMapLayer.DrawSettings)

Example 3 with DrawSettings

use of net.osmand.plus.views.layers.base.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.layers.base.OsmandMapLayer.DrawSettings)

Example 4 with DrawSettings

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

the class SurfaceRenderer method renderFrame.

public void renderFrame() {
    if (mapView == null || mSurface == null || !mSurface.isValid()) {
        // Surface is not available, or has been destroyed, skip this frame.
        return;
    }
    DrawSettings drawSettings = new DrawSettings(mCarContext.isDarkMode(), false);
    RotatedTileBox tileBox = mapView.getCurrentRotatedTileBox().copy();
    renderFrame(tileBox, drawSettings);
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) DrawSettings(net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)

Example 5 with DrawSettings

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

the class AudioVideoNotesPlugin method registerWidget.

private void registerWidget(final MapActivity activity) {
    MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
    if (mapInfoLayer != null) {
        recordControl = new TextInfoWidget(activity) {

            private Integer cachedAction;

            private Boolean cachedRecording;

            @Override
            public boolean updateInfo(DrawSettings drawSettings) {
                boolean recording = isRecording();
                Integer action = AV_DEFAULT_ACTION.get();
                if (!Algorithms.objectEquals(recording, cachedRecording) || !Algorithms.objectEquals(action, cachedAction)) {
                    cachedAction = action;
                    cachedRecording = recording;
                    if (recording) {
                        setText(app.getString(R.string.shared_string_control_stop), null);
                        setIcons(R.drawable.widget_icon_av_active, R.drawable.widget_icon_av_active_night);
                    } else {
                        setText(app.getString(R.string.shared_string_control_start), null);
                        switch(action) {
                            case AV_DEFAULT_ACTION_VIDEO:
                                setIcons(R.drawable.widget_av_video_day, R.drawable.widget_av_video_night);
                                break;
                            case AV_DEFAULT_ACTION_TAKEPICTURE:
                                setIcons(R.drawable.widget_av_photo_day, R.drawable.widget_av_photo_night);
                                break;
                            case AV_DEFAULT_ACTION_AUDIO:
                                setIcons(R.drawable.widget_av_audio_day, R.drawable.widget_av_audio_night);
                                break;
                            default:
                                setIcons(R.drawable.widget_icon_av_inactive_day, R.drawable.widget_icon_av_inactive_night);
                                break;
                        }
                    }
                }
                return false;
            }
        };
        recordControl.setOnClickListener(v -> {
            if (isRecording()) {
                stopRecording(mapActivity, false);
            } else {
                defaultAction(mapActivity);
            }
        });
        mapInfoLayer.registerSideWidget(recordControl, new AudioVideoNotesWidgetState(app, AV_DEFAULT_ACTION), "audionotes", false, 32);
        mapInfoLayer.recreateControls();
    }
}
Also used : TextInfoWidget(net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) DrawSettings(net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)

Aggregations

DrawSettings (net.osmand.plus.views.layers.base.OsmandMapLayer.DrawSettings)22 TextInfoWidget (net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget)12 OsmandApplication (net.osmand.plus.OsmandApplication)6 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)6 View (android.view.View)5 Location (net.osmand.Location)4 RoutingHelper (net.osmand.plus.routing.RoutingHelper)4 Paint (android.graphics.Paint)3 TextView (android.widget.TextView)3 LatLon (net.osmand.data.LatLon)3 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)3 SuppressLint (android.annotation.SuppressLint)2 Message (android.os.Message)2 OnClickListener (android.view.View.OnClickListener)2 ImageView (android.widget.ImageView)2 LatLonPoint (com.jwetherell.openmap.common.LatLonPoint)2 MGRSPoint (com.jwetherell.openmap.common.MGRSPoint)2 UTMPoint (com.jwetherell.openmap.common.UTMPoint)2 OsmAndLocationProvider (net.osmand.plus.OsmAndLocationProvider)2 NextDirectionInfo (net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo)2