Add ruler widgets
This commit is contained in:
parent
2966d87dd5
commit
24f59ca8ab
10 changed files with 170 additions and 139 deletions
|
@ -133,45 +133,7 @@
|
||||||
|
|
||||||
<!-- RULER -->
|
<!-- RULER -->
|
||||||
|
|
||||||
<FrameLayout
|
<include layout="@layout/map_ruler" />
|
||||||
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>
|
|
||||||
|
|
||||||
<!-- TRANSPARENCY -->
|
<!-- TRANSPARENCY -->
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,12 @@
|
||||||
tools:src="@drawable/ic_action_remove_dark"
|
tools:src="@drawable/ic_action_remove_dark"
|
||||||
android:contentDescription="@string/snap_to_road" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
android:id="@+id/map_ruler_layout"
|
android:id="@+id/map_ruler_layout"
|
||||||
android:layout_width="@dimen/map_ruler_width"
|
android:layout_width="@dimen/map_ruler_width"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom">
|
||||||
android:layout_marginStart="@dimen/map_button_margin"
|
|
||||||
android:layout_marginLeft="@dimen/map_button_margin">
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -90,16 +90,35 @@
|
||||||
|
|
||||||
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
|
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
|
||||||
|
|
||||||
<include
|
<FrameLayout
|
||||||
layout="@layout/map_hud_controls"
|
android:id="@+id/map_controls_container"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end|bottom"
|
android:layout_gravity="bottom">
|
||||||
android:layout_marginStart="@dimen/fab_margin_right"
|
|
||||||
android:layout_marginLeft="@dimen/fab_margin_right"
|
<include
|
||||||
android:layout_marginEnd="@dimen/fab_margin_right"
|
layout="@layout/map_ruler"
|
||||||
android:layout_marginRight="@dimen/fab_margin_right"
|
android:layout_width="wrap_content"
|
||||||
tools:visibility="invisible" />
|
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"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end|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" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/control_buttons"
|
android:id="@+id/control_buttons"
|
||||||
|
|
|
@ -366,17 +366,17 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
|
||||||
View zoomButtonsView = view.findViewById(R.id.map_hud_controls);
|
View zoomButtonsView = view.findViewById(R.id.map_hud_controls);
|
||||||
this.zoomButtonsView = zoomButtonsView;
|
this.zoomButtonsView = zoomButtonsView;
|
||||||
|
|
||||||
ImageButton zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
|
ImageButton zoomInButton = view.findViewById(R.id.map_zoom_in_button);
|
||||||
ImageButton zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
|
ImageButton zoomOutButton = view.findViewById(R.id.map_zoom_out_button);
|
||||||
ImageButton myLocButtonView = view.findViewById(R.id.map_my_location_button);
|
ImageButton backToLocation = view.findViewById(R.id.map_my_location_button);
|
||||||
|
|
||||||
OsmandMapTileView mapTileView = mapActivity.getMapView();
|
OsmandMapTileView mapTileView = mapActivity.getMapView();
|
||||||
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
|
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
|
||||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||||
|
|
||||||
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
|
mapControlsLayer.setupZoomInButton(zoomInButton, longClickListener, ZOOM_IN_BUTTON_ID);
|
||||||
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_BUTTON_ID);
|
mapControlsLayer.setupZoomOutButton(zoomOutButton, longClickListener, ZOOM_OUT_BUTTON_ID);
|
||||||
mapControlsLayer.setupMyLocationButton(myLocButtonView, BACK_TO_LOC_BUTTON_ID);
|
mapControlsLayer.setupBackToLocationButton(backToLocation, BACK_TO_LOC_BUTTON_ID);
|
||||||
|
|
||||||
AndroidUiHelper.updateVisibility(zoomButtonsView, true);
|
AndroidUiHelper.updateVisibility(zoomButtonsView, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
@ -33,6 +32,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.MapActivityLayers;
|
||||||
import net.osmand.plus.base.ContextMenuFragment;
|
import net.osmand.plus.base.ContextMenuFragment;
|
||||||
import net.osmand.plus.base.ContextMenuFragment.ContextMenuFragmentListener;
|
import net.osmand.plus.base.ContextMenuFragment.ContextMenuFragmentListener;
|
||||||
import net.osmand.plus.dialogs.GpxAppearanceAdapter;
|
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.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
import net.osmand.plus.track.SplitTrackAsyncTask.SplitTrackListener;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
|
import net.osmand.plus.views.MapInfoLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -51,6 +53,7 @@ import org.apache.commons.logging.Log;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.BACK_TO_LOC_HUD_ID;
|
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 SplitIntervalCard splitIntervalCard;
|
||||||
|
|
||||||
private ImageView appearanceIcon;
|
private ImageView appearanceIcon;
|
||||||
private View zoomButtonsView;
|
private View mapControlsView;
|
||||||
|
|
||||||
|
private RulerWidget rulerWidget;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMainLayoutId() {
|
public int getMainLayoutId() {
|
||||||
|
@ -173,7 +178,7 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
params.gravity = Gravity.BOTTOM | Gravity.START;
|
params.gravity = Gravity.BOTTOM | Gravity.START;
|
||||||
view.findViewById(R.id.control_buttons).setLayoutParams(params);
|
view.findViewById(R.id.control_buttons).setLayoutParams(params);
|
||||||
}
|
}
|
||||||
buildZoomButtons(view);
|
setupControlButtons(view);
|
||||||
enterTrackAppearanceMode();
|
enterTrackAppearanceMode();
|
||||||
runLayoutListener();
|
runLayoutListener();
|
||||||
}
|
}
|
||||||
|
@ -202,12 +207,12 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated) {
|
public void onContextMenuYPosChanged(@NonNull ContextMenuFragment fragment, int y, boolean needMapAdjust, boolean animated) {
|
||||||
updateZoomButtonsPos(fragment, y, animated);
|
updateMapControlsPos(fragment, y, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
public void onContextMenuStateChanged(@NonNull ContextMenuFragment fragment, int menuState) {
|
||||||
updateZoomButtonsVisibility(menuState);
|
updateMapControlsVisibility(menuState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -246,8 +251,13 @@ public class TrackAppearanceFragment extends ContextMenuFragment implements Card
|
||||||
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
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));
|
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;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildZoomButtons(@NonNull View view) {
|
private void setupControlButtons(@NonNull View view) {
|
||||||
MapActivity mapActivity = requireMapActivity();
|
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);
|
View zoomInButtonView = view.findViewById(R.id.map_zoom_in_button);
|
||||||
ImageButton zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
|
View zoomOutButtonView = view.findViewById(R.id.map_zoom_out_button);
|
||||||
ImageButton myLocButtonView = view.findViewById(R.id.map_my_location_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();
|
OsmandMapTileView mapTileView = mapActivity.getMapView();
|
||||||
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
|
View.OnLongClickListener longClickListener = MapControlsLayer.getOnClickMagnifierListener(mapTileView);
|
||||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
|
||||||
|
|
||||||
|
MapControlsLayer mapControlsLayer = mapLayers.getMapControlsLayer();
|
||||||
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
|
mapControlsLayer.setupZoomInButton(zoomInButtonView, longClickListener, ZOOM_IN_BUTTON_ID);
|
||||||
mapControlsLayer.setupZoomOutButton(zoomOutButtonView, longClickListener, ZOOM_OUT_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) {
|
public void updateMapControlsPos(@NonNull ContextMenuFragment fragment, int y, boolean animated) {
|
||||||
View zoomButtonsView = this.zoomButtonsView;
|
View mapControlsView = this.mapControlsView;
|
||||||
if (zoomButtonsView != null) {
|
if (mapControlsView != null) {
|
||||||
int zoomY = y - getZoomButtonsHeight();
|
int zoomY = y - getMapControlsHeight();
|
||||||
if (animated) {
|
if (animated) {
|
||||||
fragment.animateView(zoomButtonsView, zoomY);
|
fragment.animateView(mapControlsView, zoomY);
|
||||||
} else {
|
} else {
|
||||||
zoomButtonsView.setY(zoomY);
|
mapControlsView.setY(zoomY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getZoomButtonsHeight() {
|
private int getMapControlsHeight() {
|
||||||
View zoomButtonsView = this.zoomButtonsView;
|
View mapControlsContainer = this.mapControlsView;
|
||||||
return zoomButtonsView != null ? zoomButtonsView.getHeight() : 0;
|
return mapControlsContainer != null ? mapControlsContainer.getHeight() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateZoomButtonsVisibility(int menuState) {
|
private void updateMapControlsVisibility(int menuState) {
|
||||||
View zoomButtonsView = this.zoomButtonsView;
|
View mapControlsView = this.mapControlsView;
|
||||||
if (zoomButtonsView != null) {
|
if (mapControlsView != null) {
|
||||||
if (menuState == MenuState.HEADER_ONLY) {
|
if (menuState == MenuState.HEADER_ONLY) {
|
||||||
if (zoomButtonsView.getVisibility() != View.VISIBLE) {
|
if (mapControlsView.getVisibility() != View.VISIBLE) {
|
||||||
zoomButtonsView.setVisibility(View.VISIBLE);
|
mapControlsView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (zoomButtonsView.getVisibility() == View.VISIBLE) {
|
if (mapControlsView.getVisibility() == View.VISIBLE) {
|
||||||
zoomButtonsView.setVisibility(View.INVISIBLE);
|
mapControlsView.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private void initControls() {
|
private void initControls() {
|
||||||
View backToLocation = mapActivity.findViewById(R.id.map_my_location_button);
|
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);
|
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)
|
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)
|
.setIconColorId(R.color.map_button_icon_color_light, R.color.map_button_icon_color_dark)
|
||||||
.setBg(R.drawable.btn_circle_blue);
|
.setBg(R.drawable.btn_circle_blue);
|
||||||
|
@ -650,12 +650,14 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeHudButtons(List<String> buttonIds) {
|
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();
|
MapHudButton mapHudButton = iterator.next();
|
||||||
if (buttonIds.contains(mapHudButton.id)) {
|
if (buttonIds.contains(mapHudButton.id)) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
controls = hudButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showMapControlsIfHidden() {
|
public void showMapControlsIfHidden() {
|
||||||
|
|
|
@ -13,13 +13,13 @@ import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
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.MapInfoWidgetsFactory;
|
||||||
import net.osmand.plus.views.mapwidgets.widgetstates.CompassRulerWidgetState;
|
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopCoordinatesView;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopCoordinatesView;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
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.MapMarkersWidgetsFactory;
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
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.RouteInfoWidgetsFactory;
|
||||||
import net.osmand.plus.views.mapwidgets.widgets.AlarmWidget;
|
import net.osmand.plus.views.mapwidgets.widgets.AlarmWidget;
|
||||||
import net.osmand.plus.views.mapwidgets.widgetstates.BearingWidgetState;
|
import net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget;
|
||||||
import net.osmand.plus.views.mapwidgets.LanesControl;
|
|
||||||
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
|
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.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_ALTITUDE;
|
||||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_BATTERY;
|
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_BATTERY;
|
||||||
|
@ -58,18 +61,20 @@ import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_SPEED;
|
||||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_TIME;
|
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_TIME;
|
||||||
|
|
||||||
public class MapInfoLayer extends OsmandMapLayer {
|
public class MapInfoLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private final MapActivity map;
|
private final MapActivity map;
|
||||||
private final RouteLayer routeLayer;
|
private final RouteLayer routeLayer;
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
|
||||||
// groups
|
// groups
|
||||||
private LinearLayout rightStack;
|
private LinearLayout rightStack;
|
||||||
private LinearLayout leftStack;
|
private LinearLayout leftStack;
|
||||||
private ImageButton expand;
|
private ImageButton expand;
|
||||||
|
private View mapRulerLayout;
|
||||||
private static boolean expanded = false;
|
private static boolean expanded = false;
|
||||||
private LanesControl lanesControl;
|
private LanesControl lanesControl;
|
||||||
private AlarmWidget alarmControl;
|
private AlarmWidget alarmControl;
|
||||||
private RulerWidget rulerControl;
|
private List<RulerWidget> rulerWidgets;
|
||||||
private MapWidgetRegistry mapInfoControls;
|
private MapWidgetRegistry mapInfoControls;
|
||||||
|
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
@ -96,9 +101,11 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
public void initLayer(final OsmandMapTileView view) {
|
public void initLayer(final OsmandMapTileView view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
mapInfoControls = map.getMapLayers().getMapWidgetRegistry() ;
|
mapInfoControls = map.getMapLayers().getMapWidgetRegistry() ;
|
||||||
leftStack = (LinearLayout) map.findViewById(R.id.map_left_widgets_panel);
|
leftStack = map.findViewById(R.id.map_left_widgets_panel);
|
||||||
rightStack = (LinearLayout) map.findViewById(R.id.map_right_widgets_panel);
|
rightStack = map.findViewById(R.id.map_right_widgets_panel);
|
||||||
expand = (ImageButton) map.findViewById(R.id.map_collapse_button);
|
expand = map.findViewById(R.id.map_collapse_button);
|
||||||
|
mapRulerLayout = map.findViewById(R.id.map_ruler_layout);
|
||||||
|
|
||||||
// update and create controls
|
// update and create controls
|
||||||
registerAllControls();
|
registerAllControls();
|
||||||
map.getMyApplication().getAidlApi().registerWidgetControls(map);
|
map.getMyApplication().getAidlApi().registerWidgetControls(map);
|
||||||
|
@ -159,11 +166,12 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerAllControls(){
|
public void registerAllControls(){
|
||||||
|
rulerWidgets = new ArrayList<>();
|
||||||
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
RouteInfoWidgetsFactory ric = new RouteInfoWidgetsFactory();
|
||||||
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
MapInfoWidgetsFactory mic = new MapInfoWidgetsFactory();
|
||||||
MapMarkersWidgetsFactory mwf = map.getMapLayers().getMapMarkersLayer().getWidgetsFactory();
|
MapMarkersWidgetsFactory mwf = map.getMapLayers().getMapMarkersLayer().getWidgetsFactory();
|
||||||
OsmandApplication app = view.getApplication();
|
OsmandApplication app = view.getApplication();
|
||||||
lanesControl = ric.createLanesControl(map, view);
|
lanesControl = RouteInfoWidgetsFactory.createLanesControl(map, view);
|
||||||
|
|
||||||
TextState ts = calculateTextState();
|
TextState ts = calculateTextState();
|
||||||
streetNameView = new TopTextView(map.getMyApplication(), map);
|
streetNameView = new TopTextView(map.getMyApplication(), map);
|
||||||
|
@ -175,12 +183,11 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
topToolbarView = new TopToolbarView(map);
|
topToolbarView = new TopToolbarView(map);
|
||||||
updateTopToolbar(false);
|
updateTopToolbar(false);
|
||||||
|
|
||||||
alarmControl = ric.createAlarmInfoControl(app, map);
|
alarmControl = RouteInfoWidgetsFactory.createAlarmInfoControl(app, map);
|
||||||
alarmControl.setVisibility(false);
|
alarmControl.setVisibility(false);
|
||||||
|
|
||||||
rulerControl = ric.createRulerControl(app, map);
|
setupRulerWidget(mapRulerLayout);
|
||||||
rulerControl.setVisibility(false);
|
|
||||||
|
|
||||||
// register left stack
|
// register left stack
|
||||||
registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, WIDGET_COMPASS, true, 4);
|
registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, WIDGET_COMPASS, true, 4);
|
||||||
|
|
||||||
|
@ -236,7 +243,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
mapInfoControls.populateStackControl(rightStack, settings.getApplicationMode(), false, expanded);
|
mapInfoControls.populateStackControl(rightStack, settings.getApplicationMode(), false, expanded);
|
||||||
rightStack.requestLayout();
|
rightStack.requestLayout();
|
||||||
|
|
||||||
expand.setVisibility(mapInfoControls.hasCollapsibles(settings.getApplicationMode())?
|
expand.setVisibility(mapInfoControls.hasCollapsibles(settings.getApplicationMode())?
|
||||||
View.VISIBLE : View.GONE);
|
View.VISIBLE : View.GONE);
|
||||||
Drawable expandIcon = map.getMyApplication().getUIUtilities().getMapIcon(expanded ? R.drawable.ic_action_arrow_up :
|
Drawable expandIcon = map.getMyApplication().getUIUtilities().getMapIcon(expanded ? R.drawable.ic_action_arrow_up :
|
||||||
R.drawable.ic_action_arrow_down, true);
|
R.drawable.ic_action_arrow_down, true);
|
||||||
|
@ -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) {
|
public void setTrackChartPoints(TrackChartPoints trackChartPoints) {
|
||||||
routeLayer.setTrackChartPoints(trackChartPoints);
|
routeLayer.setTrackChartPoints(trackChartPoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TextState {
|
private static class TextState {
|
||||||
boolean textBold ;
|
boolean textBold;
|
||||||
boolean night;
|
boolean night;
|
||||||
int textColor ;
|
int textColor;
|
||||||
int textShadowColor ;
|
int textShadowColor;
|
||||||
int boxTop;
|
int boxTop;
|
||||||
int rightRes;
|
int rightRes;
|
||||||
int leftRes;
|
int leftRes;
|
||||||
|
@ -269,7 +295,6 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
int textShadowRadius;
|
int textShadowRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int themeId = -1;
|
private int themeId = -1;
|
||||||
public void updateColorShadowsOfText() {
|
public void updateColorShadowsOfText() {
|
||||||
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
|
boolean transparent = view.getSettings().TRANSPARENT_MAP_THEME.get();
|
||||||
|
@ -290,12 +315,15 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
updateTopCoordinates(nightMode, ts);
|
updateTopCoordinates(nightMode, ts);
|
||||||
updateTopToolbar(nightMode);
|
updateTopToolbar(nightMode);
|
||||||
lanesControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius / 2);
|
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();
|
int padding = expand.getPaddingLeft();
|
||||||
expand.setBackgroundResource(ts.expand);
|
expand.setBackgroundResource(ts.expand);
|
||||||
expand.setPadding(padding, padding, padding, padding);
|
expand.setPadding(padding, padding, padding, padding);
|
||||||
rightStack.invalidate();
|
rightStack.invalidate();
|
||||||
leftStack.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();
|
topToolbarView.updateInfo();
|
||||||
topCoordinatesView.updateInfo();
|
topCoordinatesView.updateInfo();
|
||||||
alarmControl.updateInfo(drawSettings);
|
alarmControl.updateInfo(drawSettings);
|
||||||
rulerControl.updateInfo(tileBox, drawSettings);
|
|
||||||
lanesControl.updateInfo(drawSettings);
|
lanesControl.updateInfo(drawSettings);
|
||||||
|
|
||||||
|
for (RulerWidget rulerWidget : rulerWidgets) {
|
||||||
|
rulerWidget.updateInfo(tileBox, drawSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
if (DateFormat.is24HourFormat(ctx)) {
|
if (DateFormat.is24HourFormat(ctx)) {
|
||||||
setText(DateFormat.format("k:mm", toFindTime).toString(), null); //$NON-NLS-1$
|
setText(DateFormat.format("k:mm", toFindTime).toString(), null); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
setText(DateFormat.format("h:mm", toFindTime).toString(),
|
setText(DateFormat.format("h:mm", toFindTime).toString(),
|
||||||
DateFormat.format("aa", toFindTime).toString()); //$NON-NLS-1$
|
DateFormat.format("aa", toFindTime).toString()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -551,10 +551,6 @@ public class RouteInfoWidgetsFactory {
|
||||||
return bearingControl;
|
return bearingControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LanesControl createLanesControl(final MapActivity map, final OsmandMapTileView view) {
|
|
||||||
return new LanesControl(map, view);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean distChanged(int oldDist, int dist) {
|
public static boolean distChanged(int oldDist, int dist) {
|
||||||
return oldDist == 0 || Math.abs(oldDist - dist) >= 10;
|
return oldDist == 0 || Math.abs(oldDist - dist) >= 10;
|
||||||
}
|
}
|
||||||
|
@ -563,11 +559,15 @@ public class RouteInfoWidgetsFactory {
|
||||||
return Math.abs(oldDegrees - degrees) >= 1;
|
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);
|
return new AlarmWidget(app, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RulerWidget createRulerControl(OsmandApplication app, MapActivity map) {
|
public static RulerWidget createRulerControl(MapActivity map, View view) {
|
||||||
return new RulerWidget(app, map);
|
return new RulerWidget(map, view);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,38 +7,37 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
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.OsmandMapLayer.DrawSettings;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
|
||||||
public class RulerWidget {
|
public class RulerWidget {
|
||||||
|
|
||||||
|
private MapActivity mapActivity;
|
||||||
|
private OsmandPreference<Float> mapDensity;
|
||||||
|
|
||||||
private View layout;
|
private View layout;
|
||||||
private ImageView icon;
|
private ImageView icon;
|
||||||
private TextView text;
|
private TextView text;
|
||||||
private TextView textShadow;
|
private TextView textShadow;
|
||||||
private MapActivity mapActivity;
|
|
||||||
private String cacheRulerText;
|
private String cacheRulerText;
|
||||||
private int maxWidth;
|
private int maxWidth;
|
||||||
private float cacheMapDensity;
|
|
||||||
private OsmandSettings.OsmandPreference<Float> mapDensity;
|
|
||||||
private int cacheRulerZoom;
|
private int cacheRulerZoom;
|
||||||
|
private float cacheMapDensity;
|
||||||
private double cacheRulerTileX;
|
private double cacheRulerTileX;
|
||||||
private double cacheRulerTileY;
|
private double cacheRulerTileY;
|
||||||
private boolean orientationPortrait;
|
|
||||||
|
|
||||||
public RulerWidget(OsmandApplication app, MapActivity mapActivity) {
|
public RulerWidget(MapActivity mapActivity, View view) {
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
layout = mapActivity.findViewById(R.id.map_ruler_layout);
|
layout = view.findViewById(R.id.map_ruler_layout);
|
||||||
icon = mapActivity.findViewById(R.id.map_ruler_image);
|
icon = view.findViewById(R.id.map_ruler_image);
|
||||||
text = mapActivity.findViewById(R.id.map_ruler_text);
|
text = view.findViewById(R.id.map_ruler_text);
|
||||||
textShadow = mapActivity.findViewById(R.id.map_ruler_text_shadow);
|
textShadow = view.findViewById(R.id.map_ruler_text_shadow);
|
||||||
maxWidth = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
|
maxWidth = view.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
|
||||||
orientationPortrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
|
||||||
mapDensity = mapActivity.getMyApplication().getSettings().MAP_DENSITY;
|
mapDensity = mapActivity.getMyApplication().getSettings().MAP_DENSITY;
|
||||||
cacheMapDensity = mapDensity.get();
|
cacheMapDensity = mapDensity.get();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue