Search in sources :

Example 1 with OsmandMap

use of net.osmand.plus.views.OsmandMap in project Osmand by osmandapp.

the class MapActivityKeyListener method onKeyUp.

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    OsmandMap osmandMap = app.getOsmandMap();
    if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        OsmandMapTileView mapView = mapActivity.getMapView();
        if (!app.accessibilityEnabled()) {
            mapActions.contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
        } else if (uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
            uiHandler.removeMessages(LONG_KEYPRESS_MSG_ID);
            mapActions.contextMenuPoint(mapView.getLatitude(), mapView.getLongitude());
        }
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MENU) /*&& event.getRepeatCount() == 0*/
    {
        // repeat count 0 doesn't work for samsung, 1 doesn't work for lg
        mapActivity.toggleDrawer();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_C) {
        mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
    } else if (keyCode == KeyEvent.KEYCODE_D) {
        mapActivity.getMapViewTrackingUtilities().switchRotateMapMode();
    } else if (keyCode == KeyEvent.KEYCODE_MINUS) {
        osmandMap.changeZoom(-1);
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_PLUS || keyCode == KeyEvent.KEYCODE_EQUALS) {
        osmandMap.changeZoom(1);
        return true;
    } else if (mapScrollHelper.isAvailableKeyCode(keyCode)) {
        return mapScrollHelper.onKeyUp(keyCode);
    } else if (settings.EXTERNAL_INPUT_DEVICE.get() == PARROT_EXTERNAL_DEVICE) {
        // Parrot device has only dpad left and right
        if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
            osmandMap.changeZoom(-1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
            osmandMap.changeZoom(1);
            return true;
        }
    } else if (settings.EXTERNAL_INPUT_DEVICE.get() == WUNDERLINQ_EXTERNAL_DEVICE) {
        // WunderLINQ device, motorcycle smart phone control
        if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
            osmandMap.changeZoom(-1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
            osmandMap.changeZoom(1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_ESCAPE) {
            String callingApp = "wunderlinq://datagrid";
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(callingApp));
            mapActivity.startActivity(intent);
            return true;
        }
    } else if (settings.EXTERNAL_INPUT_DEVICE.get() == GENERIC_EXTERNAL_DEVICE) {
    // currently doesn't process specific commands
    } else if (OsmandPlugin.onMapActivityKeyUp(mapActivity, keyCode)) {
        return true;
    }
    return app.getAidlApi().onKeyEvent(event);
}
Also used : OsmandMap(net.osmand.plus.views.OsmandMap) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) Intent(android.content.Intent)

Example 2 with OsmandMap

use of net.osmand.plus.views.OsmandMap in project Osmand by osmandapp.

the class MapActivityKeyListener method onKeyDown.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER && app.accessibilityEnabled()) {
        if (!uiHandler.hasMessages(LONG_KEYPRESS_MSG_ID)) {
            Message msg = Message.obtain(uiHandler, new Runnable() {

                @Override
                public void run() {
                    app.getLocationProvider().emitNavigationHint();
                }
            });
            msg.what = LONG_KEYPRESS_MSG_ID;
            uiHandler.sendMessageDelayed(msg, LONG_KEYPRESS_DELAY);
        }
        return true;
    } else if (mapScrollHelper.isAvailableKeyCode(keyCode)) {
        return mapScrollHelper.onKeyDown(keyCode);
    }
    if (settings.USE_VOLUME_BUTTONS_AS_ZOOM.get()) {
        OsmandMap osmandMap = app.getOsmandMap();
        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
            osmandMap.changeZoom(-1);
            return true;
        } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
            osmandMap.changeZoom(1);
            return true;
        }
    }
    return app.getAidlApi().onKeyEvent(event);
}
Also used : OsmandMap(net.osmand.plus.views.OsmandMap) Message(android.os.Message)

Example 3 with OsmandMap

use of net.osmand.plus.views.OsmandMap in project Osmand by osmandapp.

the class NavigationScreen method newRouteIsCalculated.

@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
    OsmandApplication app = getApp();
    OsmandMap map = app.getOsmandMap();
    RoutingHelper rh = app.getRoutingHelper();
    if (rh.isRoutePlanningMode()) {
        adjustMapPosition(true);
    }
    map.refreshMap();
    if (newRoute && rh.isRoutePlanningMode() && map.getMapView().isCarView()) {
        app.runInUIThread(() -> getApp().getOsmandMap().fitCurrentRouteToMap(false, 0), 300);
    }
}
Also used : OsmandMap(net.osmand.plus.views.OsmandMap) OsmandApplication(net.osmand.plus.OsmandApplication) RoutingHelper(net.osmand.plus.routing.RoutingHelper)

Example 4 with OsmandMap

use of net.osmand.plus.views.OsmandMap in project Osmand by osmandapp.

the class MapContextMenuFragment method doZoomIn.

public void doZoomIn() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        OsmandMap osmandMap = mapActivity.getMyApplication().getOsmandMap();
        RotatedTileBox tb = map.getCurrentRotatedTileBox().copy();
        boolean containsLatLon = tb.containsLatLon(menu.getLatLon());
        if (!containsLatLon) {
            restoreCustomMapRatio();
        }
        if (map.isZooming() && (map.hasCustomMapRatio() || !containsLatLon)) {
            osmandMap.changeZoom(2, System.currentTimeMillis());
        } else {
            if (containsLatLon) {
                setCustomMapRatio();
            }
            osmandMap.changeZoom(1, System.currentTimeMillis());
        }
    }
}
Also used : OsmandMap(net.osmand.plus.views.OsmandMap) RotatedTileBox(net.osmand.data.RotatedTileBox) MapActivity(net.osmand.plus.activities.MapActivity)

Example 5 with OsmandMap

use of net.osmand.plus.views.OsmandMap 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)

Aggregations

OsmandMap (net.osmand.plus.views.OsmandMap)6 RoutingHelper (net.osmand.plus.routing.RoutingHelper)2 Intent (android.content.Intent)1 Message (android.os.Message)1 OsmandAidlApi (net.osmand.aidl.OsmandAidlApi)1 RotatedTileBox (net.osmand.data.RotatedTileBox)1 OsmandRegions (net.osmand.map.OsmandRegions)1 MapPoiTypes (net.osmand.osm.MapPoiTypes)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 MapActivity (net.osmand.plus.activities.MapActivity)1 BackupHelper (net.osmand.plus.backup.BackupHelper)1 NetworkSettingsHelper (net.osmand.plus.backup.NetworkSettingsHelper)1 MapViewTrackingUtilities (net.osmand.plus.base.MapViewTrackingUtilities)1 AnalyticsHelper (net.osmand.plus.helpers.AnalyticsHelper)1 AvoidSpecificRoads (net.osmand.plus.helpers.AvoidSpecificRoads)1 DayNightHelper (net.osmand.plus.helpers.DayNightHelper)1 LauncherShortcutsHelper (net.osmand.plus.helpers.LauncherShortcutsHelper)1 LockHelper (net.osmand.plus.helpers.LockHelper)1 TargetPointsHelper (net.osmand.plus.helpers.TargetPointsHelper)1 WaypointHelper (net.osmand.plus.helpers.WaypointHelper)1