Пример #1
0
    public void update(OsmandApplication ctx, boolean night) {
      if (nightMode == night && !f) {
        return;
      }
      f = false;
      nightMode = night;
      if (bgDark != 0 && bgLight != 0) {
        iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight));
      }
      Drawable d = null;
      if (resDarkId != 0 && nightMode) {
        d = ctx.getIconsCache().getIcon(resDarkId);
      } else if (resLightId != 0 && !nightMode) {
        d = ctx.getIconsCache().getIcon(resLightId);
      } else if (resId != 0) {
        d = ctx.getIconsCache().getIcon(resId, nightMode ? resClrDark : resClrLight);
      }

      if (iv instanceof ImageView) {
        if (compass) {
          ((ImageView) iv).setImageDrawable(new CompassDrawable(d));
        } else {
          ((ImageView) iv).setImageDrawable(d);
        }
      } else if (iv instanceof TextView) {
        ((TextView) iv).setCompoundDrawablesWithIntrinsicBounds(d, null, null, null);
      }
    }
Пример #2
0
 private void onApplicationModePress(View v) {
   final QuickAction mQuickAction = new QuickAction(v);
   mQuickAction.setOnAnchorOnTop(true);
   List<ApplicationMode> vls =
       ApplicationMode.values(mapActivity.getMyApplication().getSettings());
   final ApplicationMode[] modes = vls.toArray(new ApplicationMode[vls.size()]);
   Drawable[] icons = new Drawable[vls.size()];
   int[] values = new int[vls.size()];
   for (int k = 0; k < modes.length; k++) {
     icons[k] = app.getIconsCache().getIcon(modes[k].getSmallIconDark(), R.color.icon_color);
     values[k] = modes[k].getStringResource();
   }
   for (int i = 0; i < modes.length; i++) {
     final ActionItem action = new ActionItem();
     action.setTitle(mapActivity.getResources().getString(values[i]));
     action.setIcon(icons[i]);
     final int j = i;
     action.setOnClickListener(
         new OnClickListener() {
           @Override
           public void onClick(View v) {
             mapActivity.getMyApplication().getSettings().APPLICATION_MODE.set(modes[j]);
             mQuickAction.dismiss();
           }
         });
     mQuickAction.addActionItem(action);
   }
   mQuickAction.setAnimStyle(QuickAction.ANIM_AUTO);
   mQuickAction.show();
 }
Пример #3
0
 public void setImageDrawable(int res) {
   setImageDrawable(app.getIconsCache().getIcon(res, 0), false);
 }
Пример #4
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());
    }
  }
Пример #5
0
  public void updateRouteButtons(View main, boolean routeInfo) {
    ImageView dashButton = (ImageView) main.findViewById(R.id.map_dashboard_route_button);
    dashButton.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.map_dashboard));
    dashButton.setVisibility(
        AndroidUiHelper.isOrientationPortrait(mapActivity) ? View.GONE : View.VISIBLE);
    dashButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mapRouteInfoControlDialog.hideDialog();
            optionsRouteControlDialog.hideDialog();
            mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
          }
        });
    ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button);
    cancelRouteButton.setImageDrawable(
        app.getIconsCache().getContentIcon(R.drawable.map_action_cancel));
    cancelRouteButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            clickRouteCancel();
          }
        });

    ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button);
    waypointsButton.setImageDrawable(
        routeInfo
            ? app.getIconsCache().getIcon(R.drawable.map_action_waypoints, R.color.osmand_orange)
            : app.getIconsCache().getContentIcon(R.drawable.map_action_waypoints));
    waypointsButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            clickRouteWaypoints();
          }
        });

    ImageView options = (ImageView) main.findViewById(R.id.map_options_route_button);
    options.setImageDrawable(
        !routeInfo
            ? app.getIconsCache().getIcon(R.drawable.map_action_settings, R.color.osmand_orange)
            : app.getIconsCache().getContentIcon(R.drawable.map_action_settings));
    options.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            clickRouteParams();
          }
        });

    TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button);
    routeGoButton.setCompoundDrawables(
        app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance),
        null,
        null,
        null);
    routeGoButton.setText(
        AndroidUiHelper.isOrientationPortrait(mapActivity)
            ? mapActivity.getString(R.string.shared_string_go)
            : "");
    routeGoButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            clickRouteGo();
          }
        });
  }
Пример #6
0
 public Drawable getRowIcon(int iconId) {
   IconsCache iconsCache = app.getIconsCache();
   boolean light = app.getSettings().isLightContent();
   return iconsCache.getIcon(iconId, light ? R.color.icon_color : R.color.icon_color_light);
 }