示例#1
0
  @Override
  public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
    boolean isNight = nightMode != null && nightMode.isNightMode();
    int shadw = isNight ? Color.TRANSPARENT : Color.WHITE;
    int textColor = isNight ? NIGHT_COLOR : Color.BLACK;
    if (shadowColor != shadw) {
      shadowColor = shadw;
      updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls);
    }
    // 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 showDefaultButtons =
        !routePlanningMode && (!routeFollowingMode || settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get());
    if (routePlanningMode) {
      forceHideView(zoomControls);
      forceHideView(mapMenuControls);
      forceHideView(mapRoutePlanControl);
    }
    checkVisibilityAndDraw(showDefaultButtons, zoomControls, canvas, tileBox, nightMode);
    checkVisibilityAndDraw(showDefaultButtons, mapMenuControls, canvas, tileBox, nightMode);
    // show only on touch
    checkVisibilityAndDraw(false, mapRoutePlanControl, canvas, tileBox, nightMode);

    // route calculation buttons
    boolean showRouteCalculationControls = routePlanningMode;
    checkVisibilityAndDraw(
        showRouteCalculationControls, mapSmallMenuControls, canvas, tileBox, nightMode);
    checkVisibilityAndDraw(
        showRouteCalculationControls, mapCancelNavigationControl, canvas, tileBox, nightMode);
    checkVisibilityAndDraw(
        showRouteCalculationControls, mapInfoNavigationControl, canvas, tileBox, nightMode);
    checkVisibilityAndDraw(
        showRouteCalculationControls, mapAppModeControl, canvas, tileBox, nightMode);
    checkVisibilityAndDraw(
        showRouteCalculationControls, mapNavigationControl, canvas, tileBox, nightMode);
    checkVisibilityAndDraw(
        showRouteCalculationControls, zoomSideControls, canvas, tileBox, nightMode);

    // the last one to check other controls visibility
    int vmargin =
        mapNavigationControl.isVisible() || zoomControls.isVisible() ? zoomControls.getHeight() : 0;
    rulerControl.setVerticalMargin(vmargin);
    checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
  }
示例#2
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);
  }
示例#3
0
 protected void notifyClicked(MapControls m) {
   if (mapNavigationControl != null) {
     mapNavigationControl.stopCounter();
   }
 }