Esempio n. 1
0
 protected void parseLaunchIntentLocation() {
   Intent intent = getIntent();
   if (intent != null && intent.getData() != null) {
     Uri data = intent.getData();
     if ("http".equalsIgnoreCase(data.getScheme())
         && "download.osmand.net".equals(data.getHost())
         && "/go".equals(data.getPath())) {
       String lat = data.getQueryParameter("lat");
       String lon = data.getQueryParameter("lon");
       if (lat != null && lon != null) {
         try {
           double lt = Double.parseDouble(lat);
           double ln = Double.parseDouble(lon);
           String zoom = data.getQueryParameter("z");
           int z = settings.getLastKnownMapZoom();
           if (zoom != null) {
             z = Integer.parseInt(zoom);
           }
           settings.setMapLocationToShow(lt, ln, z, getString(R.string.shared_location));
         } catch (NumberFormatException e) {
         }
       }
     }
   }
 }
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {

    if (!isSelectFavoriteMode()) {
      QuickAction qa = new QuickAction(v);
      FavouritePoint point = favouritesAdapter.getItem(position);
      String name = getString(R.string.favorite) + ": " + point.getName();
      LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
      View.OnClickListener onshow =
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              settings.SHOW_FAVORITES.set(true);
            }
          };
      MapActivityActions.createDirectionsActions(
          qa, location, point, name, settings.getLastKnownMapZoom(), this, true, onshow);
      qa.show();
    } else {
      Intent intent = getIntent();
      intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position));
      setResult(SELECT_FAVORITE_POINT_RESULT_OK, intent);
      finish();
    }
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    int pos = ((android.widget.AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    int itemId = item.getItemId();
    if (itemId == R.id.showmod) {
      OsmandSettings settings = getMyApplication().getSettings();
      OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
      settings.setMapLocationToShow(
          info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom());
      MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this);
      return true;
    } else if (itemId == R.id.deletemod) {
      OsmPoint info = (OsmPoint) listAdapter.getItem(pos);
      if (info.getGroup() == OsmPoint.Group.POI) {
        dbpoi.deletePOI((OpenstreetmapPoint) info);
      } else if (info.getGroup() == OsmPoint.Group.BUG) {
        dbbug.deleteAllBugModifications((OsmNotesPoint) info);
      }
      listAdapter.delete(info);
      return true;
    } else if (itemId == R.id.uploadmods) {
      toUpload = new OsmPoint[] {listAdapter.getItem(pos)};
      showDialog(DIALOG_PROGRESS_UPLOAD);
      return true;
    }

    return super.onContextItemSelected(item);
  }
 private void selectModel(HistoryEntry model) {
   helper.selectEntry(model, this);
   OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchHistoryActivity.this);
   settings.setMapLocationToShow(
       model.getLat(), model.getLon(), settings.getLastKnownMapZoom(), null, model.getName());
   MapActivity.launchMapActivityMoveToTop(this);
 }
Esempio n. 5
0
  @Override
  protected void onResume() {
    super.onResume();
    cancelNotification();
    if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
      setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());
      // can't return from this method we are not sure if activity will be recreated or not
    }

    app.getLocationProvider().checkIfLastKnownLocationIsValid();
    // for voice navigation
    if (settings.AUDIO_STREAM_GUIDANCE.get() != null) {
      setVolumeControlStream(settings.AUDIO_STREAM_GUIDANCE.get());
    } else {
      setVolumeControlStream(AudioManager.STREAM_MUSIC);
    }

    applicationModeListener =
        new StateChangedListener<ApplicationMode>() {
          @Override
          public void stateChanged(ApplicationMode change) {
            updateApplicationModeSettings();
          }
        };
    settings.APPLICATION_MODE.addListener(applicationModeListener);
    updateApplicationModeSettings();

    String filterId = settings.getPoiFilterForMap();
    PoiFilter poiFilter = app.getPoiFilters().getFilterById(filterId);
    if (poiFilter == null) {
      poiFilter = new PoiFilter(null, app);
    }

    mapLayers.getPoiMapLayer().setFilter(poiFilter);

    // if destination point was changed try to recalculate route
    TargetPointsHelper targets = app.getTargetPointsHelper();
    RoutingHelper routingHelper = app.getRoutingHelper();
    if (routingHelper.isFollowingMode()
        && (!Algorithms.objectEquals(targets.getPointToNavigate(), routingHelper.getFinalLocation())
            || !Algorithms.objectEquals(
                targets.getIntermediatePoints(), routingHelper.getIntermediatePoints()))) {
      routingHelper.setFinalAndCurrentLocation(
          targets.getPointToNavigate(),
          targets.getIntermediatePoints(),
          app.getLocationProvider().getLastKnownLocation(),
          routingHelper.getCurrentGPXRoute());
    }
    app.getLocationProvider().resumeAllUpdates();

    if (settings != null && settings.isLastKnownMapLocation()) {
      LatLon l = settings.getLastKnownMapLocation();
      mapView.setLatLon(l.getLatitude(), l.getLongitude());
      mapView.setZoom(settings.getLastKnownMapZoom());
    }

    settings.MAP_ACTIVITY_ENABLED.set(true);
    checkExternalStorage();
    showAndHideMapPosition();

    LatLon cur = new LatLon(mapView.getLatitude(), mapView.getLongitude());
    LatLon latLonToShow = settings.getAndClearMapLocationToShow();
    String mapLabelToShow = settings.getAndClearMapLabelToShow();
    Object toShow = settings.getAndClearObjectToShow();
    if (settings.isRouteToPointNavigateAndClear()) {
      // always enable and follow and let calculate it (GPS is not accessible in garage)
      mapActions.getDirections(null, null, false);
    }
    if (mapLabelToShow != null && latLonToShow != null) {
      mapLayers.getContextMenuLayer().setSelectedObject(toShow);
      mapLayers.getContextMenuLayer().setLocation(latLonToShow, mapLabelToShow);
    }
    if (latLonToShow != null && !latLonToShow.equals(cur)) {
      mapView
          .getAnimatedDraggingThread()
          .startMoving(
              latLonToShow.getLatitude(),
              latLonToShow.getLongitude(),
              settings.getMapZoomToShow(),
              true);
    }
    if (latLonToShow != null) {
      // remember if map should come back to isMapLinkedToLocation=true
      mapViewTrackingUtilities.setMapLinkedToLocation(false);
    }

    View progress = mapLayers.getMapInfoLayer().getProgressBar();
    if (progress != null) {
      app.getResourceManager().setBusyIndicator(new BusyIndicator(this, progress));
    }

    OsmandPlugin.onMapActivityResume(this);
    mapView.refreshMap(true);
  }