public RulerWidget(final OsmandApplication app, MapActivity ma) {
   this.ma = ma;
   layout = ma.findViewById(R.id.map_ruler_layout);
   icon = (ImageView) ma.findViewById(R.id.map_ruler_image);
   text = (TextView) ma.findViewById(R.id.map_ruler_text);
   textShadow = (TextView) ma.findViewById(R.id.map_ruler_text_shadow);
   maxWidth = ma.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
   orientationPortrait = AndroidUiHelper.isOrientationPortrait(ma);
 }
Beispiel #2
0
  public void createDashboardView() {
    baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff;
    waypointDialogHelper = new WaypointDialogHelper(mapActivity);
    landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity);
    dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
    View.OnClickListener listener =
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            hideDashboard();
          }
        };
    toolbar = ((Toolbar) dashboardView.findViewById(R.id.toolbar));
    ObservableScrollView scrollView =
        ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll));
    listView = (ListView) dashboardView.findViewById(R.id.dash_list_view);
    gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
    if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
      this.portrait = true;
      scrollView.setScrollViewCallbacks(this);
      ((ObservableListView) listView).setScrollViewCallbacks(this);
      mFlexibleSpaceImageHeight =
          mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_top_padding);
      mFlexibleBlurSpaceHeight =
          mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
      // Set padding view for ListView. This is the flexible space.
      paddingView = new View(mapActivity);
      AbsListView.LayoutParams lp =
          new AbsListView.LayoutParams(
              AbsListView.LayoutParams.MATCH_PARENT, mFlexibleSpaceImageHeight);
      paddingView.setLayoutParams(lp);
      // This is required to disable header's list selector effect
      paddingView.setClickable(true);
      paddingView.setOnClickListener(listener);
      listView.addHeaderView(paddingView);
      listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
    }
    dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
    dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);

    initActionButton();
    dashboardView.addView(actionButton);
  }
Beispiel #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());
    }
  }
Beispiel #4
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();
          }
        });
  }