Search in sources :

Example 6 with MapInfoLayer

use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.

the class ConnectedApp method registerWidgetControls.

void registerWidgetControls(@NonNull MapActivity mapActivity) {
    for (AidlMapWidgetWrapper widget : widgets.values()) {
        MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
        if (layer != null) {
            TextInfoWidget control = createWidgetControl(mapActivity, widget.getId());
            widgetControls.put(widget.getId(), control);
            int iconId = AndroidUtils.getDrawableId(mapActivity.getMyApplication(), widget.getMenuIconName());
            int menuIconId = iconId != 0 ? iconId : ContextMenuItem.INVALID_ID;
            String widgetKey = "aidl_widget_" + widget.getId();
            layer.registerSideWidget(control, menuIconId, widget.getMenuTitle(), widgetKey, false, widget.getOrder());
        }
    }
}
Also used : TextInfoWidget(net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer)

Example 7 with MapInfoLayer

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

Example 8 with MapInfoLayer

use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.

the class AudioVideoNotesPlugin method updateLayers.

@Override
public void updateLayers(@NonNull Context context, @Nullable MapActivity mapActivity) {
    OsmandApplication app = (OsmandApplication) context.getApplicationContext();
    OsmandMapTileView mapView = app.getOsmandMap().getMapView();
    if (isActive()) {
        if (SHOW_RECORDINGS.get()) {
            if (audioNotesLayer == null) {
                registerLayers(context, mapActivity);
            } else if (!mapView.getLayers().contains(audioNotesLayer)) {
                mapView.addLayer(audioNotesLayer, 3.5f);
            }
            mapView.refreshMap();
        } else if (audioNotesLayer != null) {
            mapView.removeLayer(audioNotesLayer);
            mapView.refreshMap();
        }
        if (recordControl == null && mapActivity != null) {
            registerWidget(mapActivity);
        }
    } else {
        if (audioNotesLayer != null) {
            mapView.removeLayer(audioNotesLayer);
            mapView.refreshMap();
            audioNotesLayer = null;
        }
        if (mapActivity != null) {
            MapInfoLayer mapInfoLayer = mapActivity.getMapLayers().getMapInfoLayer();
            if (recordControl != null && mapInfoLayer != null) {
                mapInfoLayer.removeSideWidget(recordControl);
                recordControl = null;
                mapInfoLayer.recreateControls();
            }
        }
        recordControl = null;
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView)

Example 9 with MapInfoLayer

use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.

the class OsmandDevelopmentPlugin method registerWidget.

private void registerWidget(@NonNull MapActivity activity) {
    MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
    final OsmandMapTileView mv = activity.getMapView();
    if (mapInfoLayer != null && mapInfoLayer.getSideWidget(FPSTextInfoWidget.class) == null) {
        FPSTextInfoWidget fps = new FPSTextInfoWidget(mv, activity);
        fps.setIcons(R.drawable.widget_fps_day, R.drawable.widget_fps_night);
        mapInfoLayer.registerSideWidget(fps, R.drawable.ic_action_fps, R.string.map_widget_fps_info, "fps", false, 50);
        mapInfoLayer.recreateControls();
    }
}
Also used : MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView)

Example 10 with MapInfoLayer

use of net.osmand.plus.views.layers.MapInfoLayer in project Osmand by osmandapp.

the class OsmandDevelopmentPlugin method updateLayers.

@Override
public void updateLayers(@NonNull Context context, @Nullable MapActivity mapActivity) {
    if (mapActivity != null) {
        if (isActive()) {
            registerWidget(mapActivity);
        } else {
            MapInfoLayer mapInfoLayer = mapActivity.getMapLayers().getMapInfoLayer();
            if (mapInfoLayer != null && mapInfoLayer.getSideWidget(FPSTextInfoWidget.class) != null) {
                mapInfoLayer.removeSideWidget(mapInfoLayer.getSideWidget(FPSTextInfoWidget.class));
                mapInfoLayer.recreateControls();
            }
        }
    }
}
Also used : MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer)

Aggregations

MapInfoLayer (net.osmand.plus.views.layers.MapInfoLayer)24 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)6 View (android.view.View)4 MapActivity (net.osmand.plus.activities.MapActivity)4 TextInfoWidget (net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget)4 ContextMenuItem (net.osmand.plus.ContextMenuItem)3 MapControlsLayer (net.osmand.plus.views.layers.MapControlsLayer)3 BroadcastReceiver (android.content.BroadcastReceiver)2 Context (android.content.Context)2 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 WeakReference (java.lang.ref.WeakReference)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)2 MapLayers (net.osmand.plus.views.MapLayers)2 SuppressLint (android.annotation.SuppressLint)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 MenuItem (android.view.MenuItem)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1