Exemple #1
0
 @Override
 public void onDraw(Canvas canvas, RectF latlonBounds, RectF tilesRect, DrawSettings nightMode) {
   boolean bold = routeLayer.getHelper().isFollowingMode();
   int color = !nightMode.isNightMode() ? Color.BLACK : Color.BLACK;
   if (paintText.getColor() != color) {
     paintText.setColor(color);
     paintSubText.setColor(color);
     paintSmallText.setColor(color);
     paintSmallSubText.setColor(color);
   }
   if (paintText.isFakeBoldText() != bold) {
     paintText.setFakeBoldText(bold);
     paintSubText.setFakeBoldText(bold);
     paintSmallText.setFakeBoldText(bold);
     paintSmallSubText.setFakeBoldText(bold);
   }
   // update data on draw
   rightStack.updateInfo();
   leftStack.updateInfo();
   if (view.getRotate() != cachedRotate) {
     cachedRotate = view.getRotate();
     compassView.invalidate();
   }
   lanesControl.updateInfo();
   //		topText.setTextColor(color);
   //		String text = "Пр.Независимости";
   //		float ts = topText.getPaint().measureText(text);
   //		int wth = topText.getRight() /*- compassView.getRight()*/;
   //		while(ts > wth && topText.getTextSize() - 1 > 5) {
   //			topText.setTextSize(topText.getTextSize() - 1);
   //			ts = topText.getPaint().measureText(text);
   //		}
   //		topText.setText(text);
 }
  @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);
  }
Exemple #3
0
  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());
    }
  }
Exemple #4
0
  public void updateColorShadowsOfText(DrawSettings drawSettings) {
    boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
    boolean nightMode = drawSettings == null ? false : drawSettings.isNightMode();
    boolean following = routeLayer.getHelper().isFollowingMode();
    int calcThemeId = (transparent ? 4 : 0) | (nightMode ? 2 : 0) | (following ? 1 : 0);
    if (themeId != calcThemeId) {
      themeId = calcThemeId;
      boolean textBold = following;
      int textColor = nightMode ? 0xffC8C8C8 : Color.BLACK;
      int textShadowColor = transparent && !nightMode ? Color.WHITE : Color.TRANSPARENT;
      int boxTop;
      int boxTopStack;
      int boxTopR;
      int boxTopL;
      int expand;
      Drawable boxFree = view.getResources().getDrawable(R.drawable.box_free_simple);

      if (transparent) {
        boxTop = R.drawable.box_top_t;
        boxTopStack = R.drawable.box_top_t_stack;
        boxTopR = R.drawable.box_top_rt;
        boxTopL = R.drawable.box_top_lt;
        expand = R.drawable.box_expand_t;
        if (nightMode) {
          boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple);
        }
      } else if (nightMode) {
        boxTop = R.drawable.box_top_n;
        boxTopStack = R.drawable.box_top_n_stack;
        boxTopR = R.drawable.box_top_rn;
        boxTopL = R.drawable.box_top_ln;
        expand = R.drawable.box_expand_t;
        boxFree = view.getResources().getDrawable(R.drawable.box_night_free_simple);
      } else {
        boxTop = R.drawable.box_top;
        boxTopStack = R.drawable.box_top_stack;
        boxTopR = R.drawable.box_top_r;
        boxTopL = R.drawable.box_top_l;
        expand = R.drawable.box_expand;
      }
      lanesControl.setBackgroundDrawable(boxFree);
      rightStack.setTopDrawable(view.getResources().getDrawable(boxTopR));
      rightStack.setStackDrawable(boxTopStack);

      leftStack.setTopDrawable(view.getResources().getDrawable(boxTopL));
      leftStack.setStackDrawable(boxTopStack);

      leftStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
      rightStack.setExpandImageDrawable(view.getResources().getDrawable(expand));
      statusBar.setBackgroundDrawable(view.getResources().getDrawable(boxTop));

      paintText.setColor(textColor);
      paintSubText.setColor(textColor);
      paintSmallText.setColor(textColor);
      paintSmallSubText.setColor(textColor);

      topText.setShadowColor(textShadowColor);
      leftStack.setShadowColor(textShadowColor);
      rightStack.setShadowColor(textShadowColor);

      paintText.setFakeBoldText(textBold);
      paintSubText.setFakeBoldText(textBold);
      paintSmallText.setFakeBoldText(textBold);
      paintSmallSubText.setFakeBoldText(textBold);

      rightStack.invalidate();
      leftStack.invalidate();
      statusBar.invalidate();
    }
  }