Search in sources :

Example 6 with TravelHelper

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;
}
Also used : Amenity(net.osmand.data.Amenity) TravelGpx(net.osmand.plus.wikivoyage.data.TravelGpx) OsmandApplication(net.osmand.plus.OsmandApplication) TravelArticle(net.osmand.plus.wikivoyage.data.TravelArticle) MapActivity(net.osmand.plus.activities.MapActivity) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper)

Example 7 with TravelHelper

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();
}
Also used : DayNightHelper(net.osmand.plus.helpers.DayNightHelper) OsmOAuthHelper(net.osmand.plus.plugins.osmedit.oauth.OsmOAuthHelper) FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) BackupHelper(net.osmand.plus.backup.BackupHelper) MapViewTrackingUtilities(net.osmand.plus.base.MapViewTrackingUtilities) WaypointHelper(net.osmand.plus.helpers.WaypointHelper) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) TravelObfHelper(net.osmand.plus.wikivoyage.data.TravelObfHelper) AvoidRoadsHelper(net.osmand.plus.routing.AvoidRoadsHelper) GpxDbHelper(net.osmand.plus.track.helpers.GpxDbHelper) OsmandRegions(net.osmand.map.OsmandRegions) LauncherShortcutsHelper(net.osmand.plus.helpers.LauncherShortcutsHelper) RendererRegistry(net.osmand.plus.render.RendererRegistry) DownloadTilesHelper(net.osmand.plus.plugins.rastermaps.DownloadTilesHelper) TargetPointsHelper(net.osmand.plus.helpers.TargetPointsHelper) QuickActionRegistry(net.osmand.plus.quickaction.QuickActionRegistry) AnalyticsHelper(net.osmand.plus.helpers.AnalyticsHelper) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper) OsmandMap(net.osmand.plus.views.OsmandMap) TravelDbHelper(net.osmand.plus.wikivoyage.data.TravelDbHelper) MapMarkersDbHelper(net.osmand.plus.mapmarkers.MapMarkersDbHelper) GpsFilterHelper(net.osmand.plus.track.helpers.GpsFilterHelper) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) RoutingHelper(net.osmand.plus.routing.RoutingHelper) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) ResourceManager(net.osmand.plus.resources.ResourceManager) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) TravelRendererHelper(net.osmand.plus.render.TravelRendererHelper) LiveMonitoringHelper(net.osmand.plus.plugins.monitoring.LiveMonitoringHelper) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) MapPoiTypes(net.osmand.osm.MapPoiTypes) QuickSearchHelper(net.osmand.plus.search.QuickSearchHelper) NetworkSettingsHelper(net.osmand.plus.backup.NetworkSettingsHelper) RoutingOptionsHelper(net.osmand.plus.routepreparationmenu.RoutingOptionsHelper) MapMarkersHelper(net.osmand.plus.mapmarkers.MapMarkersHelper) NotificationHelper(net.osmand.plus.notifications.NotificationHelper) InAppPurchaseHelperImpl(net.osmand.plus.inapp.InAppPurchaseHelperImpl) TransportRoutingHelper(net.osmand.plus.routing.TransportRoutingHelper) FileSettingsHelper(net.osmand.plus.settings.backend.backup.FileSettingsHelper) OprAuthHelper(net.osmand.plus.plugins.openplacereviews.OprAuthHelper) OsmandAidlApi(net.osmand.aidl.OsmandAidlApi) LockHelper(net.osmand.plus.helpers.LockHelper)

Example 8 with TravelHelper

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;
}
Also used : MapControlsLayer(net.osmand.plus.views.layers.MapControlsLayer) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) ContextMenuItemClickListener(net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment.ContextMenuItemClickListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) Intent(android.content.Intent) FavouritePoint(net.osmand.data.FavouritePoint) OsmandMonitoringPlugin(net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin) IndexItem(net.osmand.plus.download.IndexItem) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) WikivoyageExploreActivity(net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper)

Example 9 with TravelHelper

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;
}
Also used : TravelArticle(net.osmand.plus.wikivoyage.data.TravelArticle) ArrayList(java.util.ArrayList) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.GPXUtilities.GPXFile) File(java.io.File) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper) NonNull(androidx.annotation.NonNull)

Example 10 with TravelHelper

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();
            }
        });
    }
}
Also used : Drawable(android.graphics.drawable.Drawable) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) TravelHelper(net.osmand.plus.wikivoyage.data.TravelHelper)

Aggregations

TravelHelper (net.osmand.plus.wikivoyage.data.TravelHelper)12 View (android.view.View)4 TextView (android.widget.TextView)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 TravelArticle (net.osmand.plus.wikivoyage.data.TravelArticle)4 Drawable (android.graphics.drawable.Drawable)3 File (java.io.File)3 GPXFile (net.osmand.GPXUtilities.GPXFile)3 SelectedGpxFile (net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile)3 WebView (android.webkit.WebView)2 ImageView (android.widget.ImageView)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ArrayList (java.util.ArrayList)2 MapActivity (net.osmand.plus.activities.MapActivity)2 MapMarkersHelper (net.osmand.plus.mapmarkers.MapMarkersHelper)2 TravelGpx (net.osmand.plus.wikivoyage.data.TravelGpx)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 ColorStateList (android.content.res.ColorStateList)1 Bundle (android.os.Bundle)1