コード例 #1
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
   if (mapRouteInfoControlDialog.onSingleTap(point, tileBox)) {
     return true;
   }
   stopCounter();
   return false;
 }
コード例 #2
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (requestCode == REQUEST_ADDRESS_SELECT
       && resultCode == SearchAddressFragment.SELECT_ADDRESS_POINT_RESULT_OK) {
     String name = data.getStringExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_INTENT_KEY);
     boolean target = data.getBooleanExtra(MapRouteInfoControl.TARGET_SELECT, true);
     LatLon latLon =
         new LatLon(
             data.getDoubleExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_LAT, 0),
             data.getDoubleExtra(SearchAddressFragment.SELECT_ADDRESS_POINT_LON, 0));
     if (name != null) {
       mapRouteInfoControlDialog.selectAddress(name, latLon, target);
     } else {
       mapRouteInfoControlDialog.selectAddress("", latLon, target);
     }
   }
 }
コード例 #3
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 protected void clickRouteCancel() {
   notifyClicked();
   mapRouteInfoControlDialog.hideDialog();
   optionsRouteControlDialog.hideDialog();
   if (mapActivity.getRoutingHelper().isFollowingMode()) {
     mapActivity.getMapActions().stopNavigationActionConfirm();
   } else {
     mapActivity.getMapActions().stopNavigationWithoutConfirm();
   }
 }
コード例 #4
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 protected void clickRouteGo() {
   notifyClicked();
   mapRouteInfoControlDialog.hideDialog();
   optionsRouteControlDialog.hideDialog();
   RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
   if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
     mapActivity.getMapActions().enterRoutePlanningMode(null, null, false);
   } else {
     startNavigation();
   }
 }
コード例 #5
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 public void startNavigation() {
   stopCounter();
   OsmandApplication app = mapActivity.getMyApplication();
   RoutingHelper routingHelper = app.getRoutingHelper();
   if (routingHelper.isFollowingMode()) {
     switchToRouteFollowingLayout();
   } else {
     if (!app.getTargetPointsHelper().checkPointToNavigateShort()) {
       mapRouteInfoControlDialog.showDialog();
     } else {
       touchEvent = 0;
       mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
       app.getSettings().FOLLOW_THE_ROUTE.set(true);
       routingHelper.setFollowingMode(true);
       routingHelper.setRoutePlanningMode(false);
       mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
       app.getRoutingHelper().notifyIfRouteIsCalculated();
       routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
     }
   }
 }
コード例 #6
0
  @Override
  public void initLayer(final OsmandMapTileView view) {
    scaleCoefficient = view.getScaleCoefficient();
    FrameLayout parent = (FrameLayout) view.getParent();
    Handler showUIHandler = new Handler();
    int rightGravity = Gravity.RIGHT | Gravity.BOTTOM;
    int leftGravity = Gravity.LEFT | Gravity.BOTTOM;
    int rightCenterGravity = Gravity.RIGHT | Gravity.CENTER;

    // default buttons
    zoomControls =
        init(
            new MapZoomControls(mapActivity, showUIHandler, scaleCoefficient),
            parent,
            rightGravity);
    zoomSideControls =
        init(
            new MapZoomControls(mapActivity, showUIHandler, scaleCoefficient),
            parent,
            rightCenterGravity);
    mapMenuControls =
        init(
            new MapMenuControls(mapActivity, showUIHandler, scaleCoefficient), parent, leftGravity);
    mapRoutePlanControl =
        init(
            new MapRoutePlanControl(mapActivity, showUIHandler, scaleCoefficient),
            parent,
            leftGravity);
    // calculate route buttons
    mapSmallMenuControls =
        init(
            new SmallMapMenuControls(mapActivity, showUIHandler, scaleCoefficient),
            parent,
            leftGravity);
    mapCancelNavigationControl =
        init(
            new MapCancelControl(mapActivity, showUIHandler, scaleCoefficient),
            parent,
            leftGravity);
    mapInfoNavigationControl =
        init(
            new MapRouteInfoControl(
                mapActivity.getMapLayers().getContextMenuLayer(),
                mapActivity,
                showUIHandler,
                scaleCoefficient),
            parent,
            leftGravity);
    mapNavigationControl =
        init(
            new MapNavigateControl(
                mapInfoNavigationControl, mapActivity, showUIHandler, scaleCoefficient),
            parent,
            rightGravity);
    mapAppModeControl =
        init(
            new MapRoutePreferencesControl(mapActivity, showUIHandler, scaleCoefficient),
            parent,
            rightGravity);

    rulerControl =
        init(
            new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient),
            parent,
            rightGravity);
    mapRoutePlanControl.setMargin(mapMenuControls.getWidth());
    mapCancelNavigationControl.setMargin(mapSmallMenuControls.getWidth());
    mapInfoNavigationControl.setMargin(
        mapSmallMenuControls.getWidth() + mapCancelNavigationControl.getWidth());
    mapAppModeControl.setMargin(mapNavigationControl.getWidth());

    initTransparencyBar(view, parent);
  }
コード例 #7
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
  private void updateControls(RotatedTileBox tileBox, DrawSettings nightMode) {
    boolean isNight = nightMode != null && nightMode.isNightMode();
    int shadw = isNight ? Color.TRANSPARENT : Color.WHITE;
    int textColor =
        isNight ? mapActivity.getResources().getColor(R.color.widgettext_night) : Color.BLACK;
    if (shadowColor != shadw) {
      shadowColor = shadw;
      // TODO
      // updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls);
    }
    boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
    // default buttons
    boolean routePlanningMode = false;
    RoutingHelper rh = mapActivity.getRoutingHelper();
    if (rh.isRoutePlanningMode()) {
      routePlanningMode = true;
    } else if ((rh.isRouteCalculated() || rh.isRouteBeingCalculated()) && !rh.isFollowingMode()) {
      routePlanningMode = true;
    }
    boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
    boolean dialogOpened =
        optionsRouteControlDialog.isDialogVisible() || mapRouteInfoControlDialog.isDialogVisible();
    boolean showRouteCalculationControls =
        routePlanningMode
            || ((System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)
                && routeFollowingMode);
    boolean showMenuButton =
        (showRouteCalculationControls && portrait) || (!routeFollowingMode && !routePlanningMode);
    updateMyLocation(rh, dialogOpened);
    //		routePlanningBtn.setIconResId(routeFollowingMode ?	R.drawable.ic_action_gabout_dark :
    // R.drawable.map_directions	);
    //		routePlanningBtn.updateVisibility(showButtons && !routePlanningMode);
    routePlanningBtn.setIconResId(R.drawable.map_directions);
    routePlanningBtn.updateVisibility(!routeFollowingMode && !routePlanningMode);

    menuControl.updateVisibility(showMenuButton && !dialogOpened);
    mapZoomIn.updateVisibility(!dialogOpened);
    mapZoomOut.updateVisibility(!dialogOpened);
    compassHud.updateVisibility(!dialogOpened);
    layersHud.updateVisibility(!dialogOpened);

    if (routeFollowingMode || routePlanningMode) {
      mapAppModeShadow.setVisibility(View.GONE);
    } else {
      mapAppModeShadow.setVisibility(View.VISIBLE);
      if (!mapView.isZooming() || !OsmandPlugin.isDevelopment()) {
        zoomText.setVisibility(View.GONE);
        appModeIcon.setVisibility(View.VISIBLE);
        appModeIcon.setImageDrawable(
            app.getIconsCache()
                .getIcon(settings.getApplicationMode().getSmallIconDark(), !isNight));
      } else {
        zoomText.setVisibility(View.VISIBLE);
        appModeIcon.setVisibility(View.GONE);
        zoomText.setText(getZoomLevel(tileBox));
      }
    }
    int vis = showRouteCalculationControls ? View.VISIBLE : View.GONE;
    if (showRouteCalculationControls) {
      ((TextView) routeGoControl.iv).setTextColor(textColor);
      String text = portrait ? mapActivity.getString(R.string.shared_string_go) : "";
      if (startCounter > 0) {
        int get = (int) ((startCounter - System.currentTimeMillis()) / 1000l);
        text += " (" + get + ")";
      }
      ((TextView) routeGoControl.iv).setText(text);
    }

    if (routePreparationLayout.getVisibility() != vis) {
      routePreparationLayout.setVisibility(vis);
      mapDashControl.updateVisibility(showRouteCalculationControls && !portrait);
      mapRouteInfoControlDialog.setVisible(showRouteCalculationControls);
      if (showRouteCalculationControls) {
        if (!mapActivity.getRoutingHelper().isFollowingMode()
            && !mapActivity.getRoutingHelper().isPauseNavigation()) {
          startCounter();
        }
      } else {
        stopCounter();
      }
    }

    updateCompass(isNight);

    for (MapHudButton mc : controls) {
      mc.update(
          mapActivity.getMyApplication(), nightMode == null ? false : nightMode.isNightMode());
    }
  }
コード例 #8
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 public void showDialog() {
   mapRouteInfoControlDialog.setShowDialog();
 }
コード例 #9
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 protected void clickRouteWaypoints() {
   notifyClicked();
   optionsRouteControlDialog.hideDialog();
   mapRouteInfoControlDialog.showHideDialog();
 }
コード例 #10
0
ファイル: MapControlsLayer.java プロジェクト: nidina/Osmand
 protected void clickRouteParams() {
   notifyClicked();
   mapRouteInfoControlDialog.hideDialog();
   optionsRouteControlDialog.showAndHideDialog();
 }
コード例 #11
0
 public boolean updateInfo(DrawSettings drawSettings) {
   boolean visible = false;
   int locimminent = -1;
   int[] loclanes = null;
   int dist = 0;
   // TurnType primary = null;
   if ((rh == null || !rh.isFollowingMode())
       && trackingUtilities.isMapLinkedToLocation()
       && settings.SHOW_LANES.get()) {
     RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
     Location lp = locationProvider.getLastKnownLocation();
     if (ro != null) {
       float degree = lp == null || !lp.hasBearing() ? 0 : lp.getBearing();
       loclanes = RouteResultPreparation.parseTurnLanes(ro, degree / 180 * Math.PI);
       if (loclanes == null) {
         loclanes = RouteResultPreparation.parseLanes(ro, degree / 180 * Math.PI);
       }
     }
   } else if (rh != null && rh.isRouteCalculated()) {
     if (rh.isFollowingMode() && settings.SHOW_LANES.get()) {
       NextDirectionInfo r = rh.getNextRouteDirectionInfo(new NextDirectionInfo(), false);
       if (r != null && r.directionInfo != null && r.directionInfo.getTurnType() != null) {
         loclanes = r.directionInfo.getTurnType().getLanes();
         // primary = r.directionInfo.getTurnType();
         locimminent = r.imminent;
         // Do not show too far
         if ((r.distanceTo > 800 && r.directionInfo.getTurnType().isSkipToSpeak())
             || r.distanceTo > 1200) {
           loclanes = null;
         }
         dist = r.distanceTo;
       }
     } else {
       int di = MapRouteInfoControl.getDirectionInfo();
       if (di >= 0
           && MapRouteInfoControl.isControlVisible()
           && di < rh.getRouteDirections().size()) {
         RouteDirectionInfo next = rh.getRouteDirections().get(di);
         if (next != null) {
           loclanes = next.getTurnType().getLanes();
           // primary = next.getTurnType();
         }
       }
     }
   }
   visible = loclanes != null && loclanes.length > 0;
   if (visible) {
     if (!Arrays.equals(lanesDrawable.lanes, loclanes)
         || (locimminent == 0) != lanesDrawable.imminent) {
       lanesDrawable.imminent = locimminent == 0;
       lanesDrawable.lanes = loclanes;
       lanesDrawable.updateBounds();
       lanesView.setImageDrawable(null);
       lanesView.setImageDrawable(lanesDrawable);
       lanesView.requestLayout();
       lanesView.invalidate();
     }
     if (distChanged(dist, this.dist)) {
       this.dist = dist;
       if (dist == 0) {
         lanesShadowText.setText("");
         lanesText.setText("");
       } else {
         lanesShadowText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
         lanesText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
       }
       lanesShadowText.invalidate();
       lanesText.invalidate();
     }
   }
   updateVisibility(lanesShadowText, visible && shadowRadius > 0);
   updateVisibility(lanesText, visible);
   updateVisibility(lanesView, visible);
   updateVisibility(centerInfo, visible || progress.getVisibility() == View.VISIBLE);
   return true;
 }