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());
}
}
}
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();
}
}
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;
}
}
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();
}
}
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();
}
}
}
}
Aggregations