Add ruler widgets

This commit is contained in:
Vitaliy 2020-07-27 23:02:29 +03:00
parent 2966d87dd5
commit 24f59ca8ab
10 changed files with 170 additions and 139 deletions

View file

@ -133,45 +133,7 @@
<!-- RULER -->
<FrameLayout
android:id="@+id/map_ruler_layout"
android:layout_width="@dimen/map_ruler_width"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="@dimen/map_ruler_bottom_margin">
<TextView
android:id="@+id/map_ruler_text_shadow"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:lineSpacingMultiplier="0.9"
android:textSize="@dimen/map_widget_text_size_small"
tools:text="100 m"/>
<TextView
android:id="@+id/map_ruler_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:lineSpacingMultiplier="0.9"
android:textSize="@dimen/map_widget_text_size_small"
tools:text="100 m"/>
</FrameLayout>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/map_ruler_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/ruler"/>
</FrameLayout>
<include layout="@layout/map_ruler" />
<!-- TRANSPARENCY -->

View file

@ -117,7 +117,12 @@
tools:src="@drawable/ic_action_remove_dark"
android:contentDescription="@string/snap_to_road" />
<include layout="@layout/map_ruler" />
<include
layout="@layout/map_ruler"
android:layout_width="@dimen/map_ruler_width"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/map_button_margin"
android:layout_marginLeft="@dimen/map_button_margin" />
</LinearLayout>

View file

@ -3,9 +3,7 @@
android:id="@+id/map_ruler_layout"
android:layout_width="@dimen/map_ruler_width"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginStart="@dimen/map_button_margin"
android:layout_marginLeft="@dimen/map_button_margin">
android:layout_gravity="bottom">
<FrameLayout
android:layout_width="match_parent"

View file

@ -90,6 +90,23 @@
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
<FrameLayout
android:id="@+id/map_controls_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<include
layout="@layout/map_ruler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|bottom"
android:layout_marginStart="@dimen/fab_margin_right"
android:layout_marginLeft="@dimen/fab_margin_right"
android:layout_marginEnd="@dimen/fab_margin_right"
android:layout_marginRight="@dimen/fab_margin_right"
tools:visibility="invisible" />
<include
layout="@layout/map_hud_controls"
android:layout_width="wrap_content"
@ -101,6 +118,8 @@
android:layout_marginRight="@dimen/fab_margin_right"
tools:visibility="invisible" />
</FrameLayout>
<LinearLayout
android:id="@+id/control_buttons"
android:layout_width="match_parent"

View file

@ -366,17 +366,17 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
View zoomButtonsView = view.findViewById(R.id.map_hud_controls);
this.zoomButtonsView = zoomButtonsView;
ImageButton zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
ImageButton zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
ImageButton myLocButtonView = view.findViewById(R.id.map_my_location_button);
ImageButton zoomInButton = view.findViewById(R.id.map_zoom_in_button);
ImageButton zoomOutButton = view.findViewById(R.id.map_zoom_out_button);
ImageButton backToLocation = view.findViewById(R.id.map_my_location_button);
OsmandMapTileView mapTileView = mapActivity.getMapView();
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID);
mapControlsLayer.setupMyLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID);
mapControlsLayer.setupZoomInButton(zoomInButton, longClickListener, ZOOM_IN_BUTTON_ID);
mapControlsLayer.setupZoomOutButton(zoomOutButton, longClickListener, ZOOM_OUT_BUTTON_ID);
mapControlsLayer.setupBackToLocationButton(backToLocation, BACK_TO_LOC_BUTTON_ID);
AndroidUiHelper.updateVisibility(zoomButtonsView, true);
}

View file

@ -10,7 +10,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -33,6 +32,7 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.base.ContextMenuFragment;
import net.osmand.plus.base.ContextMenuFragment.ContextMenuFragmentListener;
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
@ -42,7 +42,9 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.util.Algorithms;
@ -51,6 +53,7 @@ import org.apache.commons.logging.Log;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.BACK_TO_LOC_HUD_ID;
@ -85,7 +88,9 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
private SplitIntervalCard splitIntervalCard;
private ImageView appearanceIcon;
private View zoomButtonsView;
private View mapControlsView;
private RulerWidget rulerWidget;
@Override
public int getMainLayoutId() {
@ -173,7 +178,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
params.gravity = Gravity.BOTTOM | Gravity.START;
view.findViewById(R.id.control_buttons).setLayoutParams(params);
}
buildZoomButtons(view);
setupControlButtons(view);
enterTrackAppearanceMode();
runLayoutListener();
}
@ -202,12 +207,12 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
@Override
public void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated) {
updateZoomButtonsPos(fragment, y, animated);
updateMapControlsPos(fragment, y, animated);
}
@Override
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
updateZoomButtonsVisibility(menuState);
updateMapControlsVisibility(menuState);
}
@Override
@ -246,8 +251,13 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
MapActivityLayers mapLayers = mapActivity.getMapLayers();
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
mapControlsLayer.removeHudButtons(Arrays.asList(ZOOM_IN_BUTTON_ID, ZOOM_OUT_BUTTON_ID, BACK_TO_LOC_BUTTON_ID));
MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer();
mapInfoLayer.removeRulerWidgets(Collections.singletonList(rulerWidget));
}
}
@ -343,50 +353,56 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
return y;
}
private void buildZoomButtons(@NonNull View view) {
private void setupControlButtons(@NonNull View view) {
MapActivity mapActivity = requireMapActivity();
zoomButtonsView = view.findViewById(R.id.map_hud_controls);
mapControlsView = view.findViewById(R.id.map_controls_container);
ImageButton zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
ImageButton zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
ImageButton myLocButtonView = view.findViewById(R.id.map_my_location_button);
View zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
View zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
View myLocButtonView = view.findViewById(R.id.map_my_location_button);
View mapRulerView = view.findViewById(R.id.map_ruler_layout);
MapActivityLayers mapLayers = mapActivity.getMapLayers();
OsmandMapTileView mapTileView = mapActivity.getMapView();
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID);
mapControlsLayer.setupMyLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID);
mapControlsLayer.setupBackToLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID);
MapInfoLayer mapInfoLayer = mapLayers.getMapInfoLayer();
rulerWidget = mapInfoLayer.setupRulerWidget(mapRulerView);
}
public void updateZoomButtonsPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
View zoomButtonsView = this.zoomButtonsView;
if (zoomButtonsView != null) {
int zoomY = y - getZoomButtonsHeight();
public void updateMapControlsPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
View mapControlsView = this.mapControlsView;
if (mapControlsView != null) {
int zoomY = y - getMapControlsHeight();
if (animated) {
fragment.animateView(zoomButtonsView, zoomY);
fragment.animateView(mapControlsView, zoomY);
} else {
zoomButtonsView.setY(zoomY);
mapControlsView.setY(zoomY);
}
}
}
private int getZoomButtonsHeight() {
View zoomButtonsView = this.zoomButtonsView;
return zoomButtonsView != null ? zoomButtonsView.getHeight() : 0;
private int getMapControlsHeight() {
View mapControlsContainer = this.mapControlsView;
return mapControlsContainer != null ? mapControlsContainer.getHeight() : 0;
}
private void updateZoomButtonsVisibility(int menuState) {
View zoomButtonsView = this.zoomButtonsView;
if (zoomButtonsView != null) {
private void updateMapControlsVisibility(int menuState) {
View mapControlsView = this.mapControlsView;
if (mapControlsView != null) {
if (menuState == MenuState.HEADER_ONLY) {
if (zoomButtonsView.getVisibility() != View.VISIBLE) {
zoomButtonsView.setVisibility(View.VISIBLE);
if (mapControlsView.getVisibility() != View.VISIBLE) {
mapControlsView.setVisibility(View.VISIBLE);
}
} else {
if (zoomButtonsView.getVisibility() == View.VISIBLE) {
zoomButtonsView.setVisibility(View.INVISIBLE);
if (mapControlsView.getVisibility() == View.VISIBLE) {
mapControlsView.setVisibility(View.INVISIBLE);
}
}
}

View file

@ -355,7 +355,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initControls() {
View backToLocation = mapActivity.findViewById(R.id.map_my_location_button);
backToLocationControl = setupMyLocationButton(backToLocation, BACK_TO_LOC_HUD_ID);
backToLocationControl = setupBackToLocationButton(backToLocation, BACK_TO_LOC_HUD_ID);
View backToMenuButton = mapActivity.findViewById(R.id.map_menu_button);
@ -393,7 +393,7 @@ public class MapControlsLayer extends OsmandMapLayer {
});
}
public MapHudButton setupMyLocationButton(View backToLocation, String buttonId) {
public MapHudButton setupBackToLocationButton(View backToLocation, String buttonId) {
MapHudButton backToLocationButton = createHudButton(backToLocation, R.drawable.ic_my_location, buttonId)
.setIconColorId(R.color.map_button_icon_color_light, R.color.map_button_icon_color_dark)
.setBg(R.drawable.btn_circle_blue);
@ -650,12 +650,14 @@ public class MapControlsLayer extends OsmandMapLayer {
}
public void removeHudButtons(List<String> buttonIds) {
for (Iterator<MapHudButton> iterator = controls.iterator(); iterator.hasNext(); ) {
List<MapHudButton> hudButtons = new ArrayList<>(controls);
for (Iterator<MapHudButton> iterator = hudButtons.iterator(); iterator.hasNext(); ) {
MapHudButton mapHudButton = iterator.next();
if (buttonIds.contains(mapHudButton.id)) {
iterator.remove();
}
}
controls = hudButtons;
}
public void showMapControlsIfHidden() {

View file

@ -13,13 +13,13 @@ import androidx.core.content.ContextCompat;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.mapwidgets.LanesControl;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.widgetstates.CompassRulerWidgetState;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopCoordinatesView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
@ -28,15 +28,18 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
import net.osmand.plus.views.mapwidgets.widgetstates.WidgetState;
import net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget;
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.widgets.AlarmWidget;
import net.osmand.plus.views.mapwidgets.widgetstates.BearingWidgetState;
import net.osmand.plus.views.mapwidgets.LanesControl;
import net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget;
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
import net.osmand.plus.views.mapwidgets.widgetstates.TimeWidgetState;
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
import net.osmand.plus.views.mapwidgets.widgetstates.BearingWidgetState;
import net.osmand.plus.views.mapwidgets.widgetstates.CompassRulerWidgetState;
import net.osmand.plus.views.mapwidgets.widgetstates.TimeWidgetState;
import net.osmand.plus.views.mapwidgets.widgetstates.WidgetState;
import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_ALTITUDE;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_BATTERY;
@ -58,6 +61,7 @@ import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_SPEED;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_TIME;
public class MapInfoLayer extends OsmandMapLayer {
private final MapActivity map;
private final RouteLayer routeLayer;
private OsmandMapTileView view;
@ -66,10 +70,11 @@ public class MapInfoLayer extends OsmandMapLayer {
private LinearLayout rightStack;
private LinearLayout leftStack;
private ImageButton expand;
private View mapRulerLayout;
private static boolean expanded = false;
private LanesControl lanesControl;
private AlarmWidget alarmControl;
private RulerWidget rulerControl;
private List<RulerWidget> rulerWidgets;
private MapWidgetRegistry mapInfoControls;
private OsmandSettings settings;
@ -96,9 +101,11 @@ public class MapInfoLayer extends OsmandMapLayer {
public void initLayer(final OsmandMapTileView view) {
this.view = view;
mapInfoControls = map.getMapLayers().getMapWidgetRegistry() ;
leftStack = (LinearLayout) map.findViewById(R.id.map_left_widgets_panel);
rightStack = (LinearLayout) map.findViewById(R.id.map_right_widgets_panel);
expand = (ImageButton) map.findViewById(R.id.map_collapse_button);
leftStack = map.findViewById(R.id.map_left_widgets_panel);
rightStack = map.findViewById(R.id.map_right_widgets_panel);
expand = map.findViewById(R.id.map_collapse_button);
mapRulerLayout = map.findViewById(R.id.map_ruler_layout);
// update and create controls
registerAllControls();
map.getMyApplication().getAidlApi().registerWidgetControls(map);
@ -159,11 +166,12 @@ public class MapInfoLayer extends OsmandMapLayer {
}
public void registerAllControls(){
rulerWidgets = new ArrayList<>();
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
MapMarkersWidgetsFactory mwf = map.getMapLayers().getMapMarkersLayer().getWidgetsFactory();
OsmandApplication app = view.getApplication();
lanesControl = ric.createLanesControl(map, view);
lanesControl = RouteInfoWidgetsFactory.createLanesControl(map, view);
TextState ts = calculateTextState();
streetNameView = new TopTextView(map.getMyApplication(), map);
@ -175,11 +183,10 @@ public class MapInfoLayer extends OsmandMapLayer {
topToolbarView = new TopToolbarView(map);
updateTopToolbar(false);
alarmControl = ric.createAlarmInfoControl(app, map);
alarmControl = RouteInfoWidgetsFactory.createAlarmInfoControl(app, map);
alarmControl.setVisibility(false);
rulerControl = ric.createRulerControl(app, map);
rulerControl.setVisibility(false);
setupRulerWidget(mapRulerLayout);
// register left stack
registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, WIDGET_COMPASS, true, 4);
@ -252,15 +259,34 @@ public class MapInfoLayer extends OsmandMapLayer {
});
}
public RulerWidget setupRulerWidget(View mapRulerView) {
RulerWidget rulerWidget = RouteInfoWidgetsFactory.createRulerControl(map, mapRulerView);
rulerWidget.setVisibility(false);
TextState ts = calculateTextState();
boolean nightMode = drawSettings != null && drawSettings.isNightMode();
rulerWidget.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, (int) (2 * view.getDensity()));
rulerWidgets.add(rulerWidget);
return rulerWidget;
}
public void removeRulerWidgets(List<RulerWidget> rulers) {
List<RulerWidget> widgetList = new ArrayList<>(rulerWidgets);
widgetList.removeAll(rulers);
rulerWidgets = widgetList;
}
public void setTrackChartPoints(TrackChartPoints trackChartPoints) {
routeLayer.setTrackChartPoints(trackChartPoints);
}
private static class TextState {
boolean textBold ;
boolean textBold;
boolean night;
int textColor ;
int textShadowColor ;
int textColor;
int textShadowColor;
int boxTop;
int rightRes;
int leftRes;
@ -269,7 +295,6 @@ public class MapInfoLayer extends OsmandMapLayer {
int textShadowRadius;
}
private int themeId = -1;
public void updateColorShadowsOfText() {
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
@ -290,12 +315,15 @@ public class MapInfoLayer extends OsmandMapLayer {
updateTopCoordinates(nightMode, ts);
updateTopToolbar(nightMode);
lanesControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius / 2);
rulerControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, (int) (2 * view.getDensity()));
int padding = expand.getPaddingLeft();
expand.setBackgroundResource(ts.expand);
expand.setPadding(padding, padding, padding, padding);
rightStack.invalidate();
leftStack.invalidate();
for (RulerWidget rulerWidget : rulerWidgets) {
rulerWidget.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, (int) (2 * view.getDensity()));
}
}
}
@ -371,9 +399,11 @@ public class MapInfoLayer extends OsmandMapLayer {
topToolbarView.updateInfo();
topCoordinatesView.updateInfo();
alarmControl.updateInfo(drawSettings);
rulerControl.updateInfo(tileBox, drawSettings);
lanesControl.updateInfo(drawSettings);
for (RulerWidget rulerWidget : rulerWidgets) {
rulerWidget.updateInfo(tileBox, drawSettings);
}
}
@Override

View file

@ -551,10 +551,6 @@ public class RouteInfoWidgetsFactory {
return bearingControl;
}
public LanesControl createLanesControl(final MapActivity map, final OsmandMapTileView view) {
return new LanesControl(map, view);
}
public static boolean distChanged(int oldDist, int dist) {
return oldDist == 0 || Math.abs(oldDist - dist) >= 10;
}
@ -563,11 +559,15 @@ public class RouteInfoWidgetsFactory {
return Math.abs(oldDegrees - degrees) >= 1;
}
public AlarmWidget createAlarmInfoControl(OsmandApplication app, MapActivity map) {
public static LanesControl createLanesControl(final MapActivity map, final OsmandMapTileView view) {
return new LanesControl(map, view);
}
public static AlarmWidget createAlarmInfoControl(OsmandApplication app, MapActivity map) {
return new AlarmWidget(app, map);
}
public RulerWidget createRulerControl(OsmandApplication app, MapActivity map) {
return new RulerWidget(app, map);
public static RulerWidget createRulerControl(MapActivity map, View view) {
return new RulerWidget(map, view);
}
}

View file

@ -7,38 +7,37 @@ import android.widget.TextView;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import net.osmand.plus.views.OsmandMapTileView;
public class RulerWidget {
private MapActivity mapActivity;
private OsmandPreference<Float> mapDensity;
private View layout;
private ImageView icon;
private TextView text;
private TextView textShadow;
private MapActivity mapActivity;
private String cacheRulerText;
private int maxWidth;
private float cacheMapDensity;
private OsmandSettings.OsmandPreference<Float> mapDensity;
private int cacheRulerZoom;
private float cacheMapDensity;
private double cacheRulerTileX;
private double cacheRulerTileY;
private boolean orientationPortrait;
public RulerWidget(OsmandApplication app, MapActivity mapActivity) {
public RulerWidget(MapActivity mapActivity, View view) {
this.mapActivity = mapActivity;
layout = mapActivity.findViewById(R.id.map_ruler_layout);
icon = mapActivity.findViewById(R.id.map_ruler_image);
text = mapActivity.findViewById(R.id.map_ruler_text);
textShadow = mapActivity.findViewById(R.id.map_ruler_text_shadow);
maxWidth = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
orientationPortrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
layout = view.findViewById(R.id.map_ruler_layout);
icon = view.findViewById(R.id.map_ruler_image);
text = view.findViewById(R.id.map_ruler_text);
textShadow = view.findViewById(R.id.map_ruler_text_shadow);
maxWidth = view.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
mapDensity = mapActivity.getMyApplication().getSettings().MAP_DENSITY;
cacheMapDensity = mapDensity.get();
}