Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a83512bc51
12 changed files with 498 additions and 21 deletions
138
OsmAnd/res/layout/fragment_measurement_tool.xml
Normal file
138
OsmAnd/res/layout/fragment_measurement_tool.xml
Normal file
|
@ -0,0 +1,138 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_transparent"
|
||||
android:clickable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_bottom_menu_dark"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingTop="12dp">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ruler_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_ruler"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/up_down_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_arrow_down"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/measurement_distance_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/ruler_icon"
|
||||
android:layout_toRightOf="@id/ruler_icon"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="724 m,"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/measurement_points_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/measurement_distance_text_view"
|
||||
android:layout_toLeftOf="@id/up_down_icon"
|
||||
android:layout_toRightOf="@id/measurement_distance_text_view"
|
||||
android:layout_toStartOf="@id/up_down_icon"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="points: 3"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/previous_dot_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_undo_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/next_dot_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/previous_dot_icon"
|
||||
android:layout_toRightOf="@id/previous_dot_icon"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_redo_dark"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/btn_round_blue"
|
||||
android:drawableLeft="@drawable/ic_action_plus"
|
||||
android:minHeight="36dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
<dimen name="map_button_inset_shadow">3dp</dimen>
|
||||
<dimen name="map_button_inset">3dp</dimen>
|
||||
<dimen name="map_button_rect_rad">4dp</dimen>
|
||||
<dimen name="map_button_rect_rad">3dp</dimen>
|
||||
|
||||
|
||||
<dimen name="map_widget_icon_margin">3dp</dimen>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
|
||||
<dimen name="map_button_inset_shadow">2dp</dimen>
|
||||
<dimen name="map_button_inset">2dp</dimen>
|
||||
<dimen name="map_button_rect_rad">3dp</dimen>
|
||||
<dimen name="map_button_rect_rad">2dp</dimen>
|
||||
<dimen name="map_button_stroke">1dp</dimen>
|
||||
<dimen name="map_button_stroke_dark">1dp</dimen>
|
||||
<dimen name="map_route_planning_land_width">320dp</dimen>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="measurement_tool">Measurement tool</string>
|
||||
<string name="quick_action_resume_pause_navigation">Resume/Pause Navigation</string>
|
||||
<string name="quick_action_resume_pause_navigation_descr">Press this button to pause the navigation, or to resume it if it was already paused.</string>
|
||||
<string name="quick_action_show_navigation_finish_dialog">Show Finish navigation dialog</string>
|
||||
|
|
|
@ -48,6 +48,7 @@ import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
|||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.liveupdates.OsmLiveActivity;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -695,6 +696,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.bottomFragmentContainer, fragment, MeasurementToolFragment.TAG)
|
||||
.addToBackStack(MeasurementToolFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.SQLiteTileSource;
|
||||
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
|
@ -88,6 +89,7 @@ public class MapActivityLayers {
|
|||
private DownloadedRegionsLayer downloadedRegionsLayer;
|
||||
private MapWidgetRegistry mapWidgetRegistry;
|
||||
private QuickActionRegistry quickActionRegistry;
|
||||
private MeasurementToolLayer measurementToolLayer;
|
||||
|
||||
private StateChangedListener<Integer> transparencyListener;
|
||||
|
||||
|
@ -148,6 +150,9 @@ public class MapActivityLayers {
|
|||
// 4. favorites layer
|
||||
mFavouritesLayer = new FavouritesLayer();
|
||||
mapView.addLayer(mFavouritesLayer, 4);
|
||||
// 4.6 measurement tool layer
|
||||
measurementToolLayer = new MeasurementToolLayer();
|
||||
mapView.addLayer(measurementToolLayer, 4.6f);
|
||||
// 5. transport layer
|
||||
transportStopsLayer = new TransportStopsLayer(activity);
|
||||
mapView.addLayer(transportStopsLayer, 5);
|
||||
|
@ -583,6 +588,10 @@ public class MapActivityLayers {
|
|||
return mFavouritesLayer;
|
||||
}
|
||||
|
||||
public MeasurementToolLayer getMeasurementToolLayer() {
|
||||
return measurementToolLayer;
|
||||
}
|
||||
|
||||
public MapTextLayer getMapTextLayer() {
|
||||
return mapTextLayer;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
private float skipHalfScreenStateLimit;
|
||||
|
||||
private int screenOrientation;
|
||||
private boolean created;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
|
||||
@Override
|
||||
|
@ -463,6 +464,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
//getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
|
||||
|
||||
created = true;
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -853,16 +855,25 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
View titleButtonContainer = view.findViewById(R.id.title_button_container);
|
||||
if (titleButtonContainer.getVisibility() == View.VISIBLE) {
|
||||
titleButtonHeight = titleButtonContainer.getMeasuredHeight() - dp16;
|
||||
if (titleButtonHeight < 0) {
|
||||
titleButtonHeight = 0;
|
||||
}
|
||||
}
|
||||
int downloadButtonsHeight = 0;
|
||||
View downloadButtonsContainer = view.findViewById(R.id.download_buttons_container);
|
||||
if (downloadButtonsContainer.getVisibility() == View.VISIBLE) {
|
||||
downloadButtonsHeight = downloadButtonsContainer.getMeasuredHeight() - dp16;
|
||||
if (downloadButtonsHeight < 0) {
|
||||
downloadButtonsHeight = 0;
|
||||
}
|
||||
}
|
||||
int titleProgressHeight = 0;
|
||||
View titleProgressContainer = view.findViewById(R.id.title_progress_container);
|
||||
if (titleProgressContainer.getVisibility() == View.VISIBLE) {
|
||||
titleProgressHeight = titleProgressContainer.getMeasuredHeight() - dp16;
|
||||
if (titleProgressHeight < 0) {
|
||||
titleProgressHeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (menuTopViewHeight != 0) {
|
||||
|
@ -1285,10 +1296,12 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
|
||||
public void updateMenu() {
|
||||
if (created) {
|
||||
menu.updateData();
|
||||
updateButtonsAndProgress();
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class MeasurementToolFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "MeasurementToolFragment";
|
||||
|
||||
private TextView distanceTv;
|
||||
private TextView pointsTv;
|
||||
private String pointsSt;
|
||||
|
||||
private boolean wasCollapseButtonVisible;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
pointsSt = mapActivity.getString(R.string.points).toLowerCase();
|
||||
|
||||
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_measurement_tool, null);
|
||||
|
||||
final View mainView = view.findViewById(R.id.main_view);
|
||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
|
||||
distanceTv = (TextView) mainView.findViewById(R.id.measurement_distance_text_view);
|
||||
pointsTv = (TextView) mainView.findViewById(R.id.measurement_points_text_view);
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.ruler_icon))
|
||||
.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_ruler, R.color.color_myloc_distance));
|
||||
((ImageView) mainView.findViewById(R.id.up_down_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
((ImageView) mainView.findViewById(R.id.previous_dot_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
|
||||
((ImageView) mainView.findViewById(R.id.next_dot_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_redo_dark));
|
||||
|
||||
mainView.findViewById(R.id.add_point_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
measurementLayer.addPointOnClick();
|
||||
updateText();
|
||||
}
|
||||
});
|
||||
|
||||
enterMeasurementMode();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
exitMeasurementMode();
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
||||
private MeasurementToolLayer getMeasurementLayer() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
return mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updateText() {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
distanceTv.setText(measurementLayer.getDistanceSt() + ",");
|
||||
pointsTv.setText(pointsSt + ": " + measurementLayer.getPointsCount());
|
||||
}
|
||||
}
|
||||
|
||||
private void enterMeasurementMode() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
measurementLayer.setInMeasurementMode(true);
|
||||
mapActivity.refreshMap();
|
||||
mapActivity.disableDrawer();
|
||||
mark(View.INVISIBLE, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);
|
||||
mark(View.GONE, R.id.map_route_info_button, R.id.map_menu_button, R.id.map_compass_button, R.id.map_layers_button,
|
||||
R.id.map_search_button, R.id.map_quick_actions_button);
|
||||
|
||||
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
|
||||
if (collapseButton != null && collapseButton.getVisibility() == View.VISIBLE) {
|
||||
wasCollapseButtonVisible = true;
|
||||
collapseButton.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
wasCollapseButtonVisible = false;
|
||||
}
|
||||
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
private void exitMeasurementMode() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
measurementLayer.setInMeasurementMode(false);
|
||||
mapActivity.refreshMap();
|
||||
mapActivity.enableDrawer();
|
||||
mark(View.VISIBLE, R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info,
|
||||
R.id.map_route_info_button, R.id.map_menu_button, R.id.map_compass_button, R.id.map_layers_button,
|
||||
R.id.map_search_button, R.id.map_quick_actions_button);
|
||||
|
||||
View collapseButton = mapActivity.findViewById(R.id.map_collapse_button);
|
||||
if (collapseButton != null && wasCollapseButtonVisible) {
|
||||
collapseButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
measurementLayer.clearPoints();
|
||||
}
|
||||
}
|
||||
|
||||
private void mark(int status, int... widgets) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
for (int widget : widgets) {
|
||||
View v = mapActivity.findViewById(widget);
|
||||
if (v != null) {
|
||||
v.setVisibility(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class MeasurementToolLayer extends OsmandMapLayer {
|
||||
|
||||
private OsmandMapTileView view;
|
||||
private boolean inMeasurementMode;
|
||||
private LinkedList<WptPt> measurementPoints = new LinkedList<>();
|
||||
private Bitmap centerIconDay;
|
||||
private Bitmap centerIconNight;
|
||||
private Bitmap pointIcon;
|
||||
private Paint bitmapPaint;
|
||||
private RenderingLineAttributes lineAttrs = new RenderingLineAttributes("rulerLine");
|
||||
private Path path = new Path();
|
||||
private int marginX;
|
||||
private int marginY;
|
||||
private TIntArrayList tx = new TIntArrayList();
|
||||
private TIntArrayList ty = new TIntArrayList();
|
||||
|
||||
@Override
|
||||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
|
||||
centerIconDay = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center_day);
|
||||
centerIconNight = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_ruler_center_night);
|
||||
pointIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_pedestrian_location);
|
||||
|
||||
bitmapPaint = new Paint();
|
||||
bitmapPaint.setAntiAlias(true);
|
||||
bitmapPaint.setDither(true);
|
||||
bitmapPaint.setFilterBitmap(true);
|
||||
|
||||
marginY = pointIcon.getHeight() / 2;
|
||||
marginX = pointIcon.getWidth() / 2;
|
||||
}
|
||||
|
||||
public boolean isInMeasurementMode() {
|
||||
return inMeasurementMode;
|
||||
}
|
||||
|
||||
void setInMeasurementMode(boolean inMeasurementMode) {
|
||||
this.inMeasurementMode = inMeasurementMode;
|
||||
}
|
||||
|
||||
int getPointsCount() {
|
||||
return measurementPoints.size();
|
||||
}
|
||||
|
||||
String getDistanceSt() {
|
||||
float dist = 0;
|
||||
if (measurementPoints.size() > 0) {
|
||||
for (int i = 1; i < measurementPoints.size(); i++) {
|
||||
dist += MapUtils.getDistance(measurementPoints.get(i - 1).lat, measurementPoints.get(i - 1).lon,
|
||||
measurementPoints.get(i).lat, measurementPoints.get(i).lon);
|
||||
}
|
||||
}
|
||||
return OsmAndFormatter.getFormattedDistance(dist, view.getApplication());
|
||||
}
|
||||
|
||||
void clearPoints() {
|
||||
measurementPoints.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
|
||||
if (inMeasurementMode) {
|
||||
lineAttrs.updatePaints(view, settings, tb);
|
||||
drawCenterIcon(canvas, tb, tb.getCenterPixelPoint(), settings.isNightMode());
|
||||
|
||||
if (measurementPoints.size() > 0) {
|
||||
path.reset();
|
||||
tx.reset();
|
||||
ty.reset();
|
||||
for (int i = 0; i < measurementPoints.size(); i++) {
|
||||
WptPt pt = measurementPoints.get(i);
|
||||
int locX = tb.getPixXFromLonNoRot(pt.lon);
|
||||
int locY = tb.getPixYFromLatNoRot(pt.lat);
|
||||
if (i == 0) {
|
||||
path.moveTo(locX, locY);
|
||||
} else {
|
||||
path.lineTo(locX, locY);
|
||||
}
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
|
||||
if (tb.containsLatLon(pt.lat, pt.lon)) {
|
||||
canvas.drawBitmap(pointIcon, locX - marginX, locY - marginY, bitmapPaint);
|
||||
}
|
||||
}
|
||||
path.lineTo(tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
tx.add(tb.getCenterPixelX());
|
||||
ty.add(tb.getCenterPixelY());
|
||||
calculatePath(tb, tx, ty, path);
|
||||
canvas.drawPath(path, lineAttrs.paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void drawCenterIcon(Canvas canvas, RotatedTileBox tb, QuadPoint center, boolean nightMode) {
|
||||
canvas.rotate(-tb.getRotate(), center.x, center.y);
|
||||
if (nightMode) {
|
||||
canvas.drawBitmap(centerIconNight, center.x - centerIconNight.getWidth() / 2,
|
||||
center.y - centerIconNight.getHeight() / 2, bitmapPaint);
|
||||
} else {
|
||||
canvas.drawBitmap(centerIconDay, center.x - centerIconDay.getWidth() / 2,
|
||||
center.y - centerIconDay.getHeight() / 2, bitmapPaint);
|
||||
}
|
||||
canvas.rotate(tb.getRotate(), center.x, center.y);
|
||||
}
|
||||
|
||||
void addPointOnClick() {
|
||||
RotatedTileBox tb = view.getCurrentRotatedTileBox();
|
||||
LatLon l = tb.getLatLonFromPixel(tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
WptPt pt = new WptPt();
|
||||
pt.lat = l.getLatitude();
|
||||
pt.lon = l.getLongitude();
|
||||
measurementPoints.add(pt);
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -484,16 +484,10 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
renderedObjects = nativeLib.searchRenderedObjectsFromContext(rc, (int) (point.x - x), (int) (point.y - y));
|
||||
}
|
||||
if (renderedObjects != null) {
|
||||
// double tx = c.first/ (rc->tileDivisor);
|
||||
// double ty = c.second / (rc->tileDivisor);
|
||||
// float dTileX = tx - rc->getLeft();
|
||||
// float dTileY = ty - rc->getTop();
|
||||
// rc->calcX = rc->cosRotateTileSize * dTileX - rc->sinRotateTileSize * dTileY;
|
||||
// rc->calcY = rc->sinRotateTileSize * dTileX + rc->cosRotateTileSize * dTileY;
|
||||
int TILE_SIZE = 256;
|
||||
double cosRotateTileSize = Math.cos(Math.toRadians(rc.rotate)) * TILE_SIZE;
|
||||
double sinRotateTileSize = Math.sin(Math.toRadians(rc.rotate)) * TILE_SIZE;
|
||||
for(RenderedObject r : renderedObjects) {
|
||||
for (RenderedObject r : renderedObjects) {
|
||||
double cx = r.getBbox().centerX();
|
||||
double cy = r.getBbox().centerY();
|
||||
double dTileX = (cx * cosRotateTileSize + cy * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
|
||||
|
@ -544,15 +538,14 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
}
|
||||
if (selectedObjects.size() == 1) {
|
||||
Object selectedObj = selectedObjects.keySet().iterator().next();
|
||||
LatLon latLon = null;
|
||||
LatLon latLon = objectLatLon;
|
||||
PointDescription pointDescription = null;
|
||||
final IContextMenuProvider provider = selectedObjects.get(selectedObj);
|
||||
if (provider != null) {
|
||||
latLon = provider.getObjectLocation(selectedObj);
|
||||
pointDescription = provider.getObjectName(selectedObj);
|
||||
}
|
||||
if (latLon == null) {
|
||||
latLon = objectLatLon;
|
||||
latLon = provider.getObjectLocation(selectedObj);
|
||||
}
|
||||
pointDescription = provider.getObjectName(selectedObj);
|
||||
}
|
||||
if (latLon == null) {
|
||||
latLon = getLatLon(point, tileBox);
|
||||
|
|
|
@ -712,7 +712,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
updateMyLocation(rh, routeDialogOpened || trackDialogOpened);
|
||||
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
|
||||
&& !isInChangeMarkerPositionMode() && !isInGpxDetailsMode();
|
||||
&& !isInChangeMarkerPositionMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode();
|
||||
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
|
||||
if (rh.isFollowingMode()) {
|
||||
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
|
||||
|
@ -729,13 +729,14 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
mapZoomIn.updateVisibility(!routeDialogOpened);
|
||||
mapZoomOut.updateVisibility(!routeDialogOpened);
|
||||
compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass());
|
||||
compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass() &&
|
||||
!isInMeasurementToolMode());
|
||||
|
||||
if (layersHud.setIconResId(settings.getApplicationMode().getMapIconId())) {
|
||||
layersHud.update(app, isNight);
|
||||
}
|
||||
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened);
|
||||
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened);
|
||||
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode());
|
||||
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode());
|
||||
|
||||
if (!routePlanningMode && !routeFollowingMode) {
|
||||
if (mapView.isZooming()) {
|
||||
|
@ -1127,6 +1128,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
return contextMenuLayer.isInGpxDetailsMode();
|
||||
}
|
||||
|
||||
private boolean isInMeasurementToolMode() {
|
||||
return mapActivity.getMapLayers().getMeasurementToolLayer().isInMeasurementMode();
|
||||
}
|
||||
|
||||
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
|
||||
return new View.OnLongClickListener() {
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.measurementtool.MeasurementToolLayer;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
|
@ -39,6 +40,7 @@ import static net.osmand.plus.views.ContextMenuLayer.VIBRATE_SHORT;
|
|||
public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRegistry.QuickActionUpdatesListener, QuickAction.QuickActionSelectionListener {
|
||||
|
||||
private final ContextMenuLayer contextMenuLayer;
|
||||
private final MeasurementToolLayer measurementToolLayer;
|
||||
private ImageView contextMarker;
|
||||
private final MapActivity mapActivity;
|
||||
private final OsmandApplication app;
|
||||
|
@ -63,6 +65,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
app = activity.getMyApplication();
|
||||
settings = activity.getMyApplication().getSettings();
|
||||
quickActionRegistry = activity.getMapLayers().getQuickActionRegistry();
|
||||
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
}
|
||||
|
||||
|
||||
|
@ -319,6 +322,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
boolean hideQuickButton = !isLayerOn ||
|
||||
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||
contextMenuLayer.isInGpxDetailsMode() ||
|
||||
measurementToolLayer.isInMeasurementMode() ||
|
||||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
|
||||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
|
||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
|
||||
|
|
Loading…
Reference in a new issue