use of net.osmand.plus.views.layers.MapControlsLayer in project Osmand by osmandapp.
the class ContextMenuScrollFragment method setupControlButtons.
protected void setupControlButtons(@NonNull View view) {
MapActivity mapActivity = requireMapActivity();
View zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
View zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
View myLocButtonView = view.findViewById(R.id.map_my_location_button);
MapLayers mapLayers = mapActivity.getMapLayers();
OsmandMapTileView mapTileView = mapActivity.getMapView();
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID);
mapControlsLayer.setupBackToLocationButton(myLocButtonView, false, BACK_TO_LOC_BUTTON_ID);
setupMapRulerWidget(view, mapLayers);
}
use of net.osmand.plus.views.layers.MapControlsLayer in project Osmand by osmandapp.
the class MapLayers method createLayers.
public void createLayers(@NonNull OsmandMapTileView mapView) {
// first create to make accessible
mapTextLayer = new MapTextLayer(app);
// 5.95 all labels
mapView.addLayer(mapTextLayer, 5.95f);
// 8. context menu layer
contextMenuLayer = new ContextMenuLayer(app);
mapView.addLayer(contextMenuLayer, 8);
// mapView.addLayer(underlayLayer, -0.5f);
mapTileLayer = new MapTileLayer(app, true);
mapView.addLayer(mapTileLayer, 0.05f);
mapView.setMainLayer(mapTileLayer);
// 0.5 layer
mapVectorLayer = new MapVectorLayer(app);
mapView.addLayer(mapVectorLayer, 0.0f);
downloadedRegionsLayer = new DownloadedRegionsLayer(app);
mapView.addLayer(downloadedRegionsLayer, 0.5f);
// 0.9 gpx layer
gpxLayer = new GPXLayer(app);
mapView.addLayer(gpxLayer, 0.9f);
// 1. route layer
routeLayer = new RouteLayer(app);
mapView.addLayer(routeLayer, 1);
// 1.5 preview route line layer
previewRouteLineLayer = new PreviewRouteLineLayer(app);
mapView.addLayer(previewRouteLineLayer, 1.5f);
// 2. osm bugs layer
// 3. poi layer
poiMapLayer = new POIMapLayer(app);
mapView.addLayer(poiMapLayer, 3);
// 4. favorites layer
mFavouritesLayer = new FavouritesLayer(app);
mapView.addLayer(mFavouritesLayer, 4);
// 4.6 measurement tool layer
measurementToolLayer = new MeasurementToolLayer(app);
mapView.addLayer(measurementToolLayer, 4.6f);
// 5. transport layer
transportStopsLayer = new TransportStopsLayer(app);
mapView.addLayer(transportStopsLayer, 5);
// 5.95 all text labels
// 6. point location layer
locationLayer = new PointLocationLayer(app);
mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer(app);
mapView.addLayer(navigationLayer, 7);
// 7.3 map markers layer
mapMarkersLayer = new MapMarkersLayer(app);
mapView.addLayer(mapMarkersLayer, 7.3f);
// 7.5 Impassible roads
impassableRoadsLayer = new ImpassableRoadsLayer(app);
mapView.addLayer(impassableRoadsLayer, 7.5f);
// 7.8 radius ruler control layer
radiusRulerControlLayer = new RadiusRulerControlLayer(app);
mapView.addLayer(radiusRulerControlLayer, 7.8f);
// 7.9 ruler by tap control layer
distanceRulerControlLayer = new DistanceRulerControlLayer(app);
mapView.addLayer(distanceRulerControlLayer, 7.9f);
// 8. context menu layer
// 9. map info layer
mapInfoLayer = new MapInfoLayer(app, routeLayer);
mapView.addLayer(mapInfoLayer, 9);
// 11. route info layer
mapControlsLayer = new MapControlsLayer(app);
mapView.addLayer(mapControlsLayer, 11);
// 12. quick actions layer
mapQuickActionLayer = new MapQuickActionLayer(app);
mapView.addLayer(mapQuickActionLayer, 12);
contextMenuLayer.setMapQuickActionLayer(mapQuickActionLayer);
transparencyListener = change -> app.runInUIThread(() -> {
mapTileLayer.setAlpha(change);
mapVectorLayer.setAlpha(change);
mapView.refreshMap();
});
app.getSettings().MAP_TRANSPARENCY.addListener(transparencyListener);
createAdditionalLayers();
}
use of net.osmand.plus.views.layers.MapControlsLayer in project Osmand by osmandapp.
the class MapActivity method updateApplicationModeSettings.
public void updateApplicationModeSettings() {
changeKeyguardFlags();
updateMapSettings();
app.getPoiFilters().loadSelectedPoiFilters();
getMapViewTrackingUtilities().appModeChanged();
OsmandMapTileView mapView = getMapView();
MapLayers mapLayers = getMapLayers();
if (mapLayers.getMapInfoLayer() != null) {
mapLayers.getMapInfoLayer().recreateControls();
}
if (mapLayers.getMapQuickActionLayer() != null) {
mapLayers.getMapQuickActionLayer().refreshLayer();
}
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
if (mapControlsLayer != null && (!mapControlsLayer.isMapControlsVisible() && !settings.MAP_EMPTY_STATE_ALLOWED.get())) {
showMapControls();
}
mapLayers.updateLayers(this);
mapActions.updateDrawerMenu();
updateNavigationBarColor();
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity());
app.getDaynightHelper().startSensorIfNeeded(change -> app.runInUIThread(() -> getMapView().refreshMap(true)));
getMapView().refreshMap(true);
applyScreenOrientation();
app.getAppCustomization().updateMapMargins(this);
dashboardOnMap.onApplicationModeSettingsUpdated();
}
use of net.osmand.plus.views.layers.MapControlsLayer in project Osmand by osmandapp.
the class MapActivity method onRequestPermissionsResult.
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull final int[] grantResults) {
if (grantResults.length > 0) {
OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
MapControlsLayer mcl = getMapView().getLayerByClass(MapControlsLayer.class);
if (mcl != null) {
mcl.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
if ((requestCode == DataStorageFragment.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE || requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE) && permissions.length > 0 && Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
permissionAsked = true;
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, R.string.missing_write_external_storage_permission, Toast.LENGTH_LONG).show();
}
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_LOCATION_PERMISSION) {
app.runInUIThread(() -> {
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
if (wizardFragment != null) {
wizardFragment.processLocationPermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
}
}, 1);
} else if (requestCode == MapActivityActions.REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION && permissions.length > 0 && Manifest.permission.ACCESS_FINE_LOCATION.equals(permissions[0])) {
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
LatLon latLon = getContextMenu().getLatLon();
if (latLon != null) {
mapActions.enterDirectionsFromPoint(latLon.getLatitude(), latLon.getLongitude());
}
} else {
app.showToastMessage(R.string.ask_for_location_permission);
}
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
use of net.osmand.plus.views.layers.MapControlsLayer in project Osmand by osmandapp.
the class MapActivityActions method createNormalOptionsMenu.
private ContextMenuAdapter createNormalOptionsMenu(final OsmandApplication app, ContextMenuAdapter optionsMenuHelper, boolean nightMode) {
createProfilesController(app, optionsMenuHelper, nightMode, false);
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity).setId(DRAWER_DASHBOARD_ID).setIcon(R.drawable.ic_dashboard).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_dashboard_open");
MapActivity.clearPrevActivityIntent();
mapActivity.closeDrawer();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity).setId(DRAWER_MAP_MARKERS_ID).setIcon(R.drawable.ic_action_flag).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_markers_open");
MapActivity.clearPrevActivityIntent();
MapMarkersDialogFragment.showInstance(mapActivity);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity).setId(DRAWER_MY_PLACES_ID).setIcon(R.drawable.ic_action_favorite).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_myplaces_open");
Intent newIntent = new Intent(mapActivity, app.getAppCustomization().getFavoritesActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
addMyPlacesTabToDrawer(optionsMenuHelper, R.string.shared_string_my_favorites, R.drawable.ic_action_folder_favorites, DRAWER_FAVORITES_ID);
addMyPlacesTabToDrawer(optionsMenuHelper, R.string.shared_string_tracks, R.drawable.ic_action_folder_tracks, DRAWER_TRACKS_ID);
if (OsmandPlugin.isActive(AudioVideoNotesPlugin.class)) {
addMyPlacesTabToDrawer(optionsMenuHelper, R.string.notes, R.drawable.ic_action_folder_av_notes, DRAWER_AV_NOTES_ID);
}
if (OsmandPlugin.isActive(OsmEditingPlugin.class)) {
addMyPlacesTabToDrawer(optionsMenuHelper, R.string.osm_edits, R.drawable.ic_action_folder_osm_notes, DRAWER_OSM_EDITS_ID);
}
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.backup_and_restore, mapActivity).setId(DRAWER_BACKUP_RESTORE_ID).setIcon(R.drawable.ic_action_cloud_upload).setListener((adapter, itemId, position, isChecked, viewCoordinates) -> {
app.logEvent("drawer_backup_restore_open");
if (app.getBackupHelper().isRegistered()) {
BackupAndRestoreFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
BackupAuthorizationFragment.showInstance(mapActivity.getSupportFragmentManager());
}
return true;
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity).setId(DRAWER_SEARCH_ID).setIcon(R.drawable.ic_action_search_dark).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_search_open");
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
return true;
}
}).createItem());
final OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
if (monitoringPlugin != null) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_widget_monitoring, mapActivity).setId(DRAWER_TRIP_RECORDING_ID).setIcon(R.drawable.ic_action_track_recordable).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("trip_recording_open");
MapActivity.clearPrevActivityIntent();
if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) {
TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
} else {
TripRecordingStartingBottomSheet.showTripRecordingDialog(mapActivity.getSupportFragmentManager(), app);
}
return true;
}
}).createItem());
}
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_navigation, mapActivity).setId(DRAWER_DIRECTIONS_ID).setIcon(R.drawable.ic_action_gdirections_dark).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_directions_open");
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
if (mapControlsLayer != null) {
mapControlsLayer.doRoute(false);
}
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.configure_map, mapActivity).setId(DRAWER_CONFIGURE_MAP_ID).setIcon(R.drawable.ic_action_layers).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_config_map_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
return false;
}
}).createItem());
String d = getString(R.string.welmode_download_maps);
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
List<IndexItem> updt = app.getDownloadThread().getIndexes().getItemsToUpdate();
if (updt != null && updt.size() > 0) {
d += " (" + updt.size() + ")";
}
}
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.welmode_download_maps, null).setId(DRAWER_DOWNLOAD_MAPS_ID).setTitle(d).setIcon(R.drawable.ic_type_archive).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_download_maps_open");
Intent newIntent = new Intent(mapActivity, app.getAppCustomization().getDownloadActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.live_updates, mapActivity).setId(DRAWER_LIVE_UPDATES_ID).setIcon(R.drawable.ic_action_map_update).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
LiveUpdatesFragment.showInstance(mapActivity.getSupportFragmentManager(), null);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_travel_guides) + " (Beta)").setId(DRAWER_TRAVEL_GUIDES_ID).setIcon(R.drawable.ic_action_travel).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
TravelHelper travelHelper = app.getTravelHelper();
travelHelper.initializeDataOnAppStartup();
if (!travelHelper.isAnyTravelBookPresent() && !travelHelper.getBookmarksHelper().hasSavedArticles()) {
WikivoyageWelcomeDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
} else {
Intent intent = new Intent(mapActivity, WikivoyageExploreActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
}
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.plan_route, mapActivity).setId(DRAWER_MEASURE_DISTANCE_ID).setIcon(R.drawable.ic_action_plan_route).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
StartPlanRouteBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
app.getAidlApi().registerNavDrawerItems(mapActivity, optionsMenuHelper);
optionsMenuHelper.addItem(new ItemBuilder().setLayout(R.layout.drawer_divider).setId(DRAWER_DIVIDER_ID).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity).setId(DRAWER_CONFIGURE_SCREEN_ID).setIcon(R.drawable.ic_configure_screen_dark).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_config_screen_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity).setId(DRAWER_PLUGINS_ID).setIcon(R.drawable.ic_extension_dark).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_plugins_open");
PluginsFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitle(getString(R.string.shared_string_settings)).setId(DRAWER_SETTINGS_ID).setIcon(R.drawable.ic_action_settings).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_settings_new_open");
mapActivity.showSettings();
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity).setId(DRAWER_HELP_ID).setIcon(R.drawable.ic_action_help).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent("drawer_help_open");
Intent intent = new Intent(mapActivity, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
return true;
}
}).createItem());
// ////////// Others
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
optionsMenuHelper.addItem(createOsmAndVersionDrawerItem());
return optionsMenuHelper;
}
Aggregations