use of net.osmand.plus.wikivoyage.data.TravelHelper in project Osmand by osmandapp.
the class POIMapLayer method showMenuAction.
@Override
public boolean showMenuAction(@Nullable Object object) {
OsmandApplication app = view.getApplication();
MapActivity mapActivity = view.getMapActivity();
TravelHelper travelHelper = app.getTravelHelper();
if (mapActivity != null && object instanceof Amenity) {
Amenity amenity = (Amenity) object;
if (amenity.getSubType().equals(ROUTE_TRACK)) {
TravelGpx travelGpx = travelHelper.searchGpx(amenity.getLocation(), amenity.getRouteId(), amenity.getRef());
if (travelGpx == null) {
return true;
}
travelHelper.openTrackMenu(travelGpx, mapActivity, amenity.getRouteId(), amenity.getLocation());
return true;
} else if (amenity.getSubType().equals(ROUTE_ARTICLE)) {
String lang = app.getLanguage();
lang = amenity.getContentLanguage(Amenity.DESCRIPTION, lang, "en");
String name = amenity.getName(lang);
TravelArticle article = travelHelper.getArticleByTitle(name, lang, true, null);
if (article == null) {
return true;
}
travelHelper.openTrackMenu(article, mapActivity, name, amenity.getLocation());
return true;
}
}
return false;
}
use of net.osmand.plus.wikivoyage.data.TravelHelper in project Osmand by osmandapp.
the class AppInitializer method onCreateApplication.
public void onCreateApplication() {
// always update application mode to default
OsmandSettings osmandSettings = app.getSettings();
if (osmandSettings.FOLLOW_THE_ROUTE.get()) {
ApplicationMode savedMode = osmandSettings.readApplicationMode();
if (!osmandSettings.APPLICATION_MODE.get().getStringKey().equals(savedMode.getStringKey())) {
osmandSettings.setApplicationMode(savedMode);
}
} else {
osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
}
startTime = System.currentTimeMillis();
getLazyRoutingConfig();
app.applyTheme(app);
startupInit(app.reconnectToBRouter(), IBRouterService.class);
app.backupHelper = startupInit(new BackupHelper(app), BackupHelper.class);
app.inAppPurchaseHelper = startupInit(new InAppPurchaseHelperImpl(app), InAppPurchaseHelperImpl.class);
app.poiTypes = startupInit(MapPoiTypes.getDefaultNoInit(), MapPoiTypes.class);
app.transportRoutingHelper = startupInit(new TransportRoutingHelper(app), TransportRoutingHelper.class);
app.routingHelper = startupInit(new RoutingHelper(app), RoutingHelper.class);
app.routingOptionsHelper = startupInit(new RoutingOptionsHelper(app), RoutingOptionsHelper.class);
app.resourceManager = startupInit(new ResourceManager(app), ResourceManager.class);
app.daynightHelper = startupInit(new DayNightHelper(app), DayNightHelper.class);
app.locationProvider = startupInit(new OsmAndLocationProvider(app), OsmAndLocationProvider.class);
app.avoidSpecificRoads = startupInit(new AvoidSpecificRoads(app), AvoidSpecificRoads.class);
app.avoidRoadsHelper = startupInit(new AvoidRoadsHelper(app), AvoidRoadsHelper.class);
app.savingTrackHelper = startupInit(new SavingTrackHelper(app), SavingTrackHelper.class);
app.analyticsHelper = startupInit(new AnalyticsHelper(app), AnalyticsHelper.class);
app.notificationHelper = startupInit(new NotificationHelper(app), NotificationHelper.class);
app.liveMonitoringHelper = startupInit(new LiveMonitoringHelper(app), LiveMonitoringHelper.class);
app.selectedGpxHelper = startupInit(new GpxSelectionHelper(app, app.savingTrackHelper), GpxSelectionHelper.class);
app.gpxDbHelper = startupInit(new GpxDbHelper(app), GpxDbHelper.class);
app.favoritesHelper = startupInit(new FavouritesHelper(app), FavouritesHelper.class);
app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
app.aidlApi = startupInit(new OsmandAidlApi(app), OsmandAidlApi.class);
app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
updateRegionVars();
app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class);
app.osmandMap = startupInit(new OsmandMap(app), OsmandMap.class);
// TODO TRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper
TravelHelper travelHelper = !TravelDbHelper.checkIfDbFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app);
app.travelHelper = startupInit(travelHelper, TravelHelper.class);
app.travelRendererHelper = startupInit(new TravelRendererHelper(app), TravelRendererHelper.class);
app.lockHelper = startupInit(new LockHelper(app), LockHelper.class);
app.fileSettingsHelper = startupInit(new FileSettingsHelper(app), FileSettingsHelper.class);
app.networkSettingsHelper = startupInit(new NetworkSettingsHelper(app), NetworkSettingsHelper.class);
app.quickActionRegistry = startupInit(new QuickActionRegistry(app.getSettings()), QuickActionRegistry.class);
app.osmOAuthHelper = startupInit(new OsmOAuthHelper(app), OsmOAuthHelper.class);
app.oprAuthHelper = startupInit(new OprAuthHelper(app), OprAuthHelper.class);
app.onlineRoutingHelper = startupInit(new OnlineRoutingHelper(app), OnlineRoutingHelper.class);
app.launcherShortcutsHelper = startupInit(new LauncherShortcutsHelper(app), LauncherShortcutsHelper.class);
app.gpsFilterHelper = startupInit(new GpsFilterHelper(app), GpsFilterHelper.class);
app.downloadTilesHelper = startupInit(new DownloadTilesHelper(app), DownloadTilesHelper.class);
initOpeningHoursParser();
}
use of net.osmand.plus.wikivoyage.data.TravelHelper 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;
}
use of net.osmand.plus.wikivoyage.data.TravelHelper in project Osmand by osmandapp.
the class MapMarkersHelper method getGroupsForSavedArticlesTravelBook.
@NonNull
public List<MapMarkersGroup> getGroupsForSavedArticlesTravelBook() {
List<MapMarkersGroup> res = new ArrayList<>();
TravelHelper travelHelper = ctx.getTravelHelper();
if (travelHelper.isAnyTravelBookPresent()) {
List<TravelArticle> savedArticles = travelHelper.getBookmarksHelper().getSavedArticles();
for (TravelArticle art : savedArticles) {
String gpxName = travelHelper.getGPXName(art);
File path = ctx.getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
MapMarkersGroup search = getMapMarkerGroupById(getMarkerGroupId(path), ItineraryType.TRACK);
if (search == null) {
MapMarkersGroup group = createGPXMarkerGroup(path);
group.setDisabled(true);
res.add(group);
}
}
}
return res;
}
use of net.osmand.plus.wikivoyage.data.TravelHelper in project Osmand by osmandapp.
the class WikivoyageArticleDialogFragment method updateSaveButton.
private void updateSaveButton() {
if (article != null) {
final TravelHelper helper = getMyApplication().getTravelHelper();
final boolean saved = helper.getBookmarksHelper().isArticleSaved(article);
Drawable icon = getActiveIcon(saved ? R.drawable.ic_action_read_later_fill : R.drawable.ic_action_read_later);
saveBtn.setText(getString(saved ? R.string.shared_string_remove : R.string.shared_string_bookmark));
saveBtn.setCompoundDrawablesWithIntrinsicBounds(null, null, icon, null);
saveBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
helper.saveOrRemoveArticle(article, !saved);
updateSaveButton();
}
});
}
}
Aggregations