Search in sources :

Example 6 with SavingTrackHelper

use of net.osmand.plus.track.helpers.SavingTrackHelper 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 7 with SavingTrackHelper

use of net.osmand.plus.track.helpers.SavingTrackHelper in project Osmand by osmandapp.

the class MapActivityActions method createAddWaypointDialog.

private Dialog createAddWaypointDialog(final Bundle args) {
    boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
    AlertDialog.Builder builder = new AlertDialog.Builder(UiUtilities.getThemedContext(mapActivity, nightMode));
    builder.setTitle(R.string.add_waypoint_dialog_title);
    View view = UiUtilities.getInflater(mapActivity, nightMode).inflate(R.layout.add_gpx_point_dialog, null);
    final EditText editText = (EditText) view.findViewById(android.R.id.edit);
    builder.setView(view);
    builder.setNegativeButton(R.string.shared_string_cancel, null);
    builder.setPositiveButton(R.string.shared_string_add, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            double latitude = args.getDouble(KEY_LATITUDE);
            double longitude = args.getDouble(KEY_LONGITUDE);
            String name = editText.getText().toString();
            SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
            savingTrackHelper.insertPointData(latitude, longitude, System.currentTimeMillis(), null, name, null, 0);
            Toast.makeText(mapActivity, MessageFormat.format(getString(R.string.add_waypoint_dialog_added), name), Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });
    final AlertDialog alertDialog = builder.create();
    editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
            }
        }
    });
    return alertDialog;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) EditText(android.widget.EditText) DialogInterface(android.content.DialogInterface) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) GPXRouteParamsBuilder(net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) FavouritePoint(net.osmand.data.FavouritePoint)

Example 8 with SavingTrackHelper

use of net.osmand.plus.track.helpers.SavingTrackHelper in project Osmand by osmandapp.

the class WptPtEditorFragmentNew method doUpdateWpt.

private void doUpdateWpt(String name, String category, String description) {
    WptPt wpt = getWpt();
    WptPtEditor editor = getWptPtEditor();
    SavingTrackHelper savingTrackHelper = getSavingTrackHelper();
    GpxSelectionHelper selectedGpxHelper = getSelectedGpxHelper();
    if (wpt != null && editor != null && savingTrackHelper != null && selectedGpxHelper != null) {
        GPXFile gpx = editor.getGpxFile();
        if (gpx != null) {
            if (gpx.showCurrentTrack) {
                savingTrackHelper.updatePointData(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color, iconName, backgroundTypeName);
                if (!editor.isGpxSelected()) {
                    selectedGpxHelper.setGpxFileToDisplay(gpx);
                }
            } else {
                gpx.updateWptPt(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color, iconName, backgroundTypeName);
                saveGpx(getMyApplication(), gpx, editor.isGpxSelected());
            }
            syncGpx(gpx);
        }
    }
}
Also used : WptPt(net.osmand.GPXUtilities.WptPt) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) GPXFile(net.osmand.GPXUtilities.GPXFile)

Example 9 with SavingTrackHelper

use of net.osmand.plus.track.helpers.SavingTrackHelper in project Osmand by osmandapp.

the class WptPtEditorFragmentNew method delete.

@Override
protected void delete(final boolean needDismiss) {
    FragmentActivity activity = getActivity();
    if (activity != null) {
        final OsmandApplication app = (OsmandApplication) activity.getApplication();
        boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
        AlertDialog.Builder builder = new AlertDialog.Builder(UiUtilities.getThemedContext(activity, nightMode));
        builder.setMessage(getString(R.string.context_menu_item_delete_waypoint));
        builder.setNegativeButton(R.string.shared_string_no, null);
        builder.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                WptPt wpt = getWpt();
                WptPtEditor editor = getWptPtEditor();
                SavingTrackHelper savingTrackHelper = getSavingTrackHelper();
                if (wpt != null && editor != null && savingTrackHelper != null) {
                    GPXFile gpx = editor.getGpxFile();
                    if (gpx != null) {
                        if (gpx.showCurrentTrack) {
                            savingTrackHelper.deletePointData(wpt);
                        } else {
                            gpx.deleteWptPt(wpt);
                            saveGpx(getMyApplication(), gpx, editor.isGpxSelected());
                        }
                        syncGpx(gpx);
                    }
                    saved = true;
                }
                if (needDismiss) {
                    dismiss(true);
                } else {
                    MapActivity mapActivity = getMapActivity();
                    if (mapActivity != null) {
                        mapActivity.refreshMap();
                    }
                }
            }
        });
        builder.create().show();
    }
}
Also used : AlertDialog(android.app.AlertDialog) WptPt(net.osmand.GPXUtilities.WptPt) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) WptLocationPoint(net.osmand.data.WptLocationPoint) FragmentActivity(androidx.fragment.app.FragmentActivity) GPXFile(net.osmand.GPXUtilities.GPXFile) MapActivity(net.osmand.plus.activities.MapActivity)

Example 10 with SavingTrackHelper

use of net.osmand.plus.track.helpers.SavingTrackHelper in project Osmand by osmandapp.

the class WptPtEditorFragmentNew method doAddWpt.

private void doAddWpt(String name, String category, String description) {
    WptPt wpt = getWpt();
    WptPtEditor editor = getWptPtEditor();
    if (wpt != null && editor != null) {
        wpt.name = name;
        wpt.category = category;
        wpt.desc = description;
        if (color != 0) {
            wpt.setColor(color);
        } else {
            wpt.removeColor();
        }
        wpt.setBackgroundType(backgroundTypeName);
        wpt.setIconName(iconName);
        GPXFile gpx = editor.getGpxFile();
        SavingTrackHelper savingTrackHelper = getSavingTrackHelper();
        GpxSelectionHelper selectedGpxHelper = getSelectedGpxHelper();
        if (gpx != null && savingTrackHelper != null && selectedGpxHelper != null) {
            if (gpx.showCurrentTrack) {
                this.wpt = savingTrackHelper.insertPointData(wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), description, name, category, color, iconName, backgroundTypeName);
                if (!editor.isGpxSelected()) {
                    selectedGpxHelper.setGpxFileToDisplay(gpx);
                }
            } else {
                addWpt(gpx, description, name, category, color, iconName, backgroundTypeName);
                saveGpx(getMyApplication(), gpx, editor.isGpxSelected());
            }
            syncGpx(gpx);
        }
    }
}
Also used : WptPt(net.osmand.GPXUtilities.WptPt) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) GpxSelectionHelper(net.osmand.plus.track.helpers.GpxSelectionHelper) GPXFile(net.osmand.GPXUtilities.GPXFile)

Aggregations

SavingTrackHelper (net.osmand.plus.track.helpers.SavingTrackHelper)11 GPXFile (net.osmand.GPXUtilities.GPXFile)6 WptPt (net.osmand.GPXUtilities.WptPt)4 View (android.view.View)3 ImageView (android.widget.ImageView)3 GpxSelectionHelper (net.osmand.plus.track.helpers.GpxSelectionHelper)3 DialogInterface (android.content.DialogInterface)2 ImageButton (android.widget.ImageButton)2 TextView (android.widget.TextView)2 FragmentActivity (androidx.fragment.app.FragmentActivity)2 File (java.io.File)2 GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)2 AlertDialog (android.app.AlertDialog)1 ProgressDialog (android.app.ProgressDialog)1 Drawable (android.graphics.drawable.Drawable)1 AbsListView (android.widget.AbsListView)1 AdapterView (android.widget.AdapterView)1 Button (android.widget.Button)1 CheckBox (android.widget.CheckBox)1 CompoundButton (android.widget.CompoundButton)1