use of net.osmand.plus.views.mapwidgets.TextInfoWidget in project Osmand by osmandapp.
the class AudioVideoNotesPlugin method registerWidget.
private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null) {
recordControl = new TextInfoWidget(activity);
if (mediaRec != null && mediaRecFile != null) {
updateRecordControl(activity, mediaRecFile);
} else {
recordControl.setImageDrawable(activity.getResources().getDrawable(R.drawable.monitoring_rec_inactive));
setRecordListener(recordControl, activity);
}
mapInfoLayer.registerSideWidget(recordControl, R.drawable.ic_action_micro_dark, R.string.map_widget_av_notes, "audionotes", false, 32);
mapInfoLayer.recreateControls();
}
}
use of net.osmand.plus.views.mapwidgets.TextInfoWidget in project Osmand by osmandapp.
the class MapillaryPlugin method createMonitoringControl.
private TextInfoWidget createMonitoringControl(final MapActivity map) {
mapillaryControl = new TextInfoWidget(map);
mapillaryControl.setText(map.getString(R.string.mapillary), "");
mapillaryControl.setIcons(R.drawable.widget_mapillary_day, R.drawable.widget_mapillary_night);
mapillaryControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openMapillary(map, null);
}
});
return mapillaryControl;
}
use of net.osmand.plus.views.mapwidgets.TextInfoWidget in project Osmand by osmandapp.
the class OsmandAidlApi method registerRemoveMapWidgetReceiver.
private void registerRemoveMapWidgetReceiver(final MapActivity mapActivity) {
removeMapWidgetReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String widgetId = intent.getStringExtra(AIDL_OBJECT_ID);
if (widgetId != null) {
MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
TextInfoWidget widgetControl = widgetControls.get(widgetId);
if (layer != null && widgetControl != null) {
layer.removeSideWidget(widgetControl);
widgetControls.remove(widgetId);
layer.recreateControls();
}
}
}
};
mapActivity.registerReceiver(removeMapWidgetReceiver, new IntentFilter(AIDL_REMOVE_MAP_WIDGET));
}
use of net.osmand.plus.views.mapwidgets.TextInfoWidget in project Osmand by osmandapp.
the class OsmandAidlApi method createWidgetControl.
private TextInfoWidget createWidgetControl(final MapActivity mapActivity, final String widgetId) {
final TextInfoWidget control = new TextInfoWidget(mapActivity) {
@Override
public boolean updateInfo(DrawSettings drawSettings) {
AMapWidget widget = widgets.get(widgetId);
if (widget != null) {
String txt = widget.getText();
String subtxt = widget.getDescription();
boolean night = drawSettings != null && drawSettings.isNightMode();
int icon = night ? getDrawableId(widget.getDarkIconName()) : getDrawableId(widget.getLightIconName());
setText(txt, subtxt);
if (icon != 0) {
setImageDrawable(icon);
} else {
setImageDrawable(null);
}
return true;
} else {
return false;
}
}
};
control.updateInfo(null);
control.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AMapWidget widget = widgets.get(widgetId);
if (widget != null && widget.getIntentOnClick() != null) {
app.startActivity(widget.getIntentOnClick());
}
}
});
return control;
}
use of net.osmand.plus.views.mapwidgets.TextInfoWidget in project Osmand by osmandapp.
the class ParkingPositionPlugin method createParkingPlaceInfoControl.
/**
* @return the control to be added on a MapInfoLayer
* that shows a distance between
* the current position on the map
* and the location of the parked car
*/
private TextInfoWidget createParkingPlaceInfoControl(final MapActivity map) {
TextInfoWidget parkingPlaceControl = new TextInfoWidget(map) {
private float[] calculations = new float[1];
private int cachedMeters = 0;
@Override
public boolean updateInfo(DrawSettings drawSettings) {
LatLon parkingPoint = parkingLayer.getParkingPoint();
if (parkingPoint != null && !map.getRoutingHelper().isFollowingMode()) {
OsmandMapTileView view = map.getMapView();
int d = 0;
if (d == 0) {
net.osmand.Location.distanceBetween(view.getLatitude(), view.getLongitude(), parkingPoint.getLatitude(), parkingPoint.getLongitude(), calculations);
d = (int) calculations[0];
}
if (distChanged(cachedMeters, d)) {
cachedMeters = d;
if (cachedMeters <= 20) {
cachedMeters = 0;
setText(null, null);
} else {
String ds = OsmAndFormatter.getFormattedDistance(cachedMeters, map.getMyApplication());
int ls = ds.lastIndexOf(' ');
if (ls == -1) {
setText(ds, null);
} else {
setText(ds.substring(0, ls), ds.substring(ls + 1));
}
}
return true;
}
} else if (cachedMeters != 0) {
cachedMeters = 0;
setText(null, null);
return true;
}
return false;
}
/**
* Utility method.
* @param oldDist
* @param dist
* @return
*/
private boolean distChanged(int oldDist, int dist) {
if (oldDist != 0 && Math.abs(oldDist - dist) < 30) {
return false;
}
return true;
}
};
parkingPlaceControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
OsmandMapTileView view = map.getMapView();
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
LatLon parkingPoint = parkingPosition;
if (parkingPoint != null) {
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
thread.startMoving(parkingPoint.getLatitude(), parkingPoint.getLongitude(), fZoom, true);
}
}
});
parkingPlaceControl.setText(null, null);
parkingPlaceControl.setIcons(R.drawable.widget_parking_day, R.drawable.widget_parking_night);
return parkingPlaceControl;
}
Aggregations