private void initTopControls() { View configureMap = mapActivity.findViewById(R.id.map_layers_button); layersHud = createHudButton((ImageView) configureMap, R.drawable.map_layer_dark) .setIconsId(R.drawable.map_layer_dark, R.drawable.map_layer_night) .setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night); controls.add(layersHud); configureMap.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { notifyClicked(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP); } }); View compass = mapActivity.findViewById(R.id.map_compass_button); compassHud = createHudButton((ImageView) compass, R.drawable.map_compass) .setIconColorId(0) .setBg(R.drawable.btn_inset_circle_trans, R.drawable.btn_inset_circle_night); compassHud.compass = true; controls.add(compassHud); compass.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { notifyClicked(); mapActivity.getMapViewTrackingUtilities().switchRotateMapMode(); } }); }
private void updateCompass(boolean isNight) { float mapRotate = mapActivity.getMapView().getRotate(); if (mapRotate != cachedRotate) { cachedRotate = mapRotate; // Aply animation to image view compassHud.iv.invalidate(); } if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_NONE) { compassHud.setIconResId( isNight ? R.drawable.map_compass_niu_white : R.drawable.map_compass_niu); } else if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING) { compassHud.setIconResId( isNight ? R.drawable.map_compass_bearing_white : R.drawable.map_compass_bearing); } else { compassHud.setIconResId(isNight ? R.drawable.map_compass_white : R.drawable.map_compass); } }
private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) { boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null; boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); if (!enabled) { backToLocationControl.setBg(R.drawable.btn_circle, R.drawable.btn_circle_night); backToLocationControl.setIconColorId(R.color.icon_color, 0); } else if (tracked) { backToLocationControl.setBg(R.drawable.btn_circle, R.drawable.btn_circle_night); backToLocationControl.setIconColorId(R.color.color_myloc_distance); } else { backToLocationControl.setIconColorId(0); backToLocationControl.setBg(R.drawable.btn_circle_blue); } boolean visible = !(tracked && rh.isFollowingMode()); backToLocationControl.updateVisibility(visible && !dialogOpened); }
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()); } }
public MapHudButton createHudButton(View iv, int resId) { MapHudButton mc = new MapHudButton(); mc.iv = iv; mc.resId = resId; return mc; }