Merge branch 'r3.3'
This commit is contained in:
commit
0cadac6309
6 changed files with 261 additions and 161 deletions
|
@ -165,6 +165,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
private MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||
private static MapContextMenu mapContextMenu = new MapContextMenu();
|
||||
private static MapRouteInfoMenu mapRouteInfoMenu = new MapRouteInfoMenu();
|
||||
private static TrackDetailsMenu trackDetailsMenu = new TrackDetailsMenu();
|
||||
private static Intent prevActivityIntent = null;
|
||||
|
||||
private List<ActivityResultListener> activityResultListeners = new ArrayList<>();
|
||||
|
@ -228,6 +229,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
mapViewTrackingUtilities = app.getMapViewTrackingUtilities();
|
||||
mapContextMenu.setMapActivity(this);
|
||||
mapRouteInfoMenu.setMapActivity(this);
|
||||
trackDetailsMenu.setMapActivity(this);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
// Full screen is not used here
|
||||
|
@ -345,8 +347,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
if (removeFragment(PlanRouteFragment.TAG)) {
|
||||
app.getMapMarkersHelper().getPlanRouteContext().setFragmentVisible(true);
|
||||
}
|
||||
if (TrackDetailsMenu.isVisible()) {
|
||||
mapLayers.getMapControlsLayer().getTrackDetailsMenu().hide();
|
||||
if (trackDetailsMenu.isVisible()) {
|
||||
trackDetailsMenu.dismiss();
|
||||
}
|
||||
removeFragment(ImportGpxBottomSheetDialogFragment.TAG);
|
||||
removeFragment(AdditionalActionsBottomSheetDialogFragment.TAG);
|
||||
|
@ -587,8 +589,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
showQuickSearch(ShowQuickSearchMode.CURRENT, false);
|
||||
return;
|
||||
}
|
||||
if (TrackDetailsMenu.isVisible()) {
|
||||
getMapLayers().getMapControlsLayer().getTrackDetailsMenu().hide();
|
||||
if (trackDetailsMenu.isVisible()) {
|
||||
trackDetailsMenu.hide();
|
||||
if (prevActivityIntent == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1094,6 +1096,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
dashboardOnMap.hideDashboard();
|
||||
}
|
||||
}
|
||||
if (trackDetailsMenu.isVisible()) {
|
||||
trackDetailsMenu.show();
|
||||
}
|
||||
if (searchRequestToShow != null) {
|
||||
showQuickSearch(searchRequestToShow);
|
||||
}
|
||||
|
@ -1124,7 +1129,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
//mapContextMenu.setMapZoom(settings.getMapZoomToShow());
|
||||
mapContextMenu.setMapZoom(tb.getZoom());
|
||||
if (toShow instanceof GpxDisplayItem) {
|
||||
TrackDetailsMenu trackDetailsMenu = mapLayers.getMapControlsLayer().getTrackDetailsMenu();
|
||||
trackDetailsMenu.setGpxItem((GpxDisplayItem) toShow);
|
||||
trackDetailsMenu.show();
|
||||
} else if (mapRouteInfoMenu.isVisible()) {
|
||||
|
@ -1269,6 +1273,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
super.onDestroy();
|
||||
mapContextMenu.setMapActivity(null);
|
||||
mapRouteInfoMenu.setMapActivity(null);
|
||||
trackDetailsMenu.setMapActivity(null);
|
||||
unregisterReceiver(screenOffReceiver);
|
||||
app.getAidlApi().onDestroyMapActivity(this);
|
||||
FailSafeFuntions.quitRouteRestoreDialog();
|
||||
|
@ -1596,6 +1601,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
return mapRouteInfoMenu;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public TrackDetailsMenu getTrackDetailsMenu() {
|
||||
return trackDetailsMenu;
|
||||
}
|
||||
|
||||
public void openDrawer() {
|
||||
mapActions.updateDrawerMenu();
|
||||
boolean animate = !settings.DO_NOT_USE_ANIMATIONS.get();
|
||||
|
|
|
@ -3,7 +3,7 @@ package net.osmand.plus.mapcontextmenu.other;
|
|||
import android.content.Context;
|
||||
import android.graphics.Matrix;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -21,14 +21,14 @@ import com.github.mikephil.charting.listener.OnChartGestureListener;
|
|||
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -43,7 +43,6 @@ import net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet;
|
|||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -51,42 +50,114 @@ import java.util.List;
|
|||
|
||||
public class TrackDetailsMenu {
|
||||
|
||||
@Nullable
|
||||
private MapActivity mapActivity;
|
||||
@Nullable
|
||||
private GpxDisplayItem gpxItem;
|
||||
@Nullable
|
||||
private TrackDetailsBarController toolbarController;
|
||||
@Nullable
|
||||
private TrkSegment segment;
|
||||
@Nullable
|
||||
private TrackChartPoints trackChartPoints;
|
||||
@Nullable
|
||||
private List<WptPt> xAxisPoints;
|
||||
private int topMarginPx;
|
||||
private boolean visible;
|
||||
private boolean hidding;
|
||||
|
||||
private static boolean VISIBLE;
|
||||
|
||||
public TrackDetailsMenu(@NonNull MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
topMarginPx = AndroidUtils.dpToPx(mapActivity, 48f);
|
||||
public TrackDetailsMenu() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MapActivity getMapActivity() {
|
||||
return mapActivity;
|
||||
}
|
||||
|
||||
public void setMapActivity(@Nullable MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
if (mapActivity != null) {
|
||||
if (topMarginPx == 0) {
|
||||
topMarginPx = AndroidUtils.dpToPx(mapActivity, 48f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GpxDisplayItem getGpxItem() {
|
||||
return gpxItem;
|
||||
}
|
||||
|
||||
public void setGpxItem(GpxDisplayItem gpxItem) {
|
||||
public void setGpxItem(@NonNull GpxDisplayItem gpxItem) {
|
||||
this.gpxItem = gpxItem;
|
||||
}
|
||||
|
||||
public static boolean isVisible() {
|
||||
return VISIBLE;
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
public void show() {
|
||||
if (!VISIBLE) {
|
||||
VISIBLE = true;
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null && getGpxItem() != null) {
|
||||
visible = true;
|
||||
TrackDetailsMenuFragment.showInstance(mapActivity);
|
||||
}
|
||||
}
|
||||
|
||||
public void dismiss() {
|
||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||
if (fragment != null) {
|
||||
fragment.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||
if (fragment != null) {
|
||||
hidding = true;
|
||||
fragment.dismiss();
|
||||
} else {
|
||||
segment = null;
|
||||
trackChartPoints = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||
if (fragment != null) {
|
||||
fragment.updateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private TrackDetailsMenuFragment getMenuFragment() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
TrackDetailsMenuFragment fragment = (TrackDetailsMenuFragment) mapActivity.getSupportFragmentManager()
|
||||
.findFragmentByTag(TrackDetailsMenuFragment.TAG);
|
||||
if (fragment != null && !fragment.isDetached()) {
|
||||
return fragment;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void onShow() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (mapActivity != null && gpxItem != null) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
GPXFile groupGpx = gpxItem.group.getGpx();
|
||||
if (groupGpx != null) {
|
||||
gpxItem.wasHidden = app.getSelectedGpxHelper().getSelectedFileByPath(groupGpx.path) == null;
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(groupGpx);
|
||||
}
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
if (!portrait) {
|
||||
mapActivity.getMapView().setMapPositionX(1);
|
||||
} else {
|
||||
toolbarController = new TrackDetailsBarController();
|
||||
if (gpxItem != null && gpxItem.group != null) {
|
||||
TrackDetailsBarController toolbarController = new TrackDetailsBarController();
|
||||
this.toolbarController = toolbarController;
|
||||
if (gpxItem.group != null) {
|
||||
toolbarController.setTitle(gpxItem.group.getGpxName());
|
||||
} else {
|
||||
toolbarController.setTitle(mapActivity.getString(R.string.rendering_category_details));
|
||||
|
@ -94,7 +165,10 @@ public class TrackDetailsMenu {
|
|||
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.onBackPressed();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
toolbarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||
|
@ -105,55 +179,34 @@ public class TrackDetailsMenu {
|
|||
});
|
||||
mapActivity.showTopToolbar(toolbarController);
|
||||
}
|
||||
|
||||
mapActivity.refreshMap();
|
||||
|
||||
TrackDetailsMenuFragment.showInstance(mapActivity);
|
||||
mapActivity.getMapLayers().getContextMenuLayer().enterGpxDetailsMode();
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
WeakReference<TrackDetailsMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().dismiss();
|
||||
} else {
|
||||
segment = null;
|
||||
VISIBLE = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
WeakReference<TrackDetailsMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().updateInfo();
|
||||
}
|
||||
}
|
||||
|
||||
private WeakReference<TrackDetailsMenuFragment> findMenuFragment() {
|
||||
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackDetailsMenuFragment.TAG);
|
||||
if (fragment != null && !fragment.isDetached()) {
|
||||
return new WeakReference<>((TrackDetailsMenuFragment) fragment);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDismiss() {
|
||||
VISIBLE = false;
|
||||
if (gpxItem != null && !gpxItem.route && gpxItem.wasHidden && gpxItem.group != null && gpxItem.group.getGpx() != null) {
|
||||
mapActivity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpxItem.group.getGpx(), false, false);
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
if (gpxItem != null && !gpxItem.route && gpxItem.wasHidden && gpxItem.group != null && gpxItem.group.getGpx() != null) {
|
||||
mapActivity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpxItem.group.getGpx(), false, false);
|
||||
}
|
||||
TrackDetailsBarController toolbarController = this.toolbarController;
|
||||
if (toolbarController != null) {
|
||||
mapActivity.hideTopToolbar(toolbarController);
|
||||
}
|
||||
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(null);
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(null);
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
if (toolbarController != null) {
|
||||
mapActivity.hideTopToolbar(toolbarController);
|
||||
if (hidding) {
|
||||
hidding = false;
|
||||
visible = false;
|
||||
segment = null;
|
||||
trackChartPoints = null;
|
||||
}
|
||||
mapActivity.getMapLayers().getContextMenuLayer().exitGpxDetailsMode();
|
||||
mapActivity.getMapLayers().getGpxLayer().setTrackChartPoints(null);
|
||||
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(null);
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
segment = null;
|
||||
trackChartPoints = null;
|
||||
}
|
||||
|
||||
public void updateInfo(final View main) {
|
||||
|
@ -161,9 +214,11 @@ public class TrackDetailsMenu {
|
|||
}
|
||||
|
||||
private TrkSegment getTrackSegment(LineChart chart) {
|
||||
TrkSegment segment = this.segment;
|
||||
if (segment == null) {
|
||||
List<ILineDataSet> ds = chart.getLineData().getDataSets();
|
||||
if (ds != null && ds.size() > 0) {
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (ds != null && ds.size() > 0 && gpxItem != null) {
|
||||
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
|
||||
for (TrkSegment s : t.segments) {
|
||||
if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) {
|
||||
|
@ -175,6 +230,7 @@ public class TrackDetailsMenu {
|
|||
break;
|
||||
}
|
||||
}
|
||||
this.segment = segment;
|
||||
}
|
||||
}
|
||||
return segment;
|
||||
|
@ -183,11 +239,12 @@ public class TrackDetailsMenu {
|
|||
private WptPt getPoint(LineChart chart, float pos) {
|
||||
WptPt wpt = null;
|
||||
List<ILineDataSet> ds = chart.getLineData().getDataSets();
|
||||
if (ds != null && ds.size() > 0) {
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (ds != null && ds.size() > 0 && gpxItem != null) {
|
||||
TrkSegment segment = getTrackSegment(chart);
|
||||
OrderedLineDataSet dataSet = (OrderedLineDataSet) ds.get(0);
|
||||
if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME ||
|
||||
gpxItem.chartAxisType == GPXDataSetAxisType.TIMEOFDAY) {
|
||||
gpxItem.chartAxisType == GPXDataSetAxisType.TIMEOFDAY) {
|
||||
float time = pos * 1000;
|
||||
for (WptPt p : segment.points) {
|
||||
if (p.time - gpxItem.analysis.startTime >= time) {
|
||||
|
@ -220,7 +277,8 @@ public class TrackDetailsMenu {
|
|||
double left = 0, right = 0;
|
||||
double top = 0, bottom = 0;
|
||||
List<ILineDataSet> ds = chart.getLineData().getDataSets();
|
||||
if (ds != null && ds.size() > 0) {
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (ds != null && ds.size() > 0 && gpxItem != null) {
|
||||
TrkSegment segment = getTrackSegment(chart);
|
||||
OrderedLineDataSet dataSet = (OrderedLineDataSet) ds.get(0);
|
||||
if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME || gpxItem.chartAxisType == GPXDataSetAxisType.TIMEOFDAY) {
|
||||
|
@ -274,45 +332,55 @@ public class TrackDetailsMenu {
|
|||
|
||||
private void fitTrackOnMap(LineChart chart, LatLon location, boolean forceFit) {
|
||||
QuadRect rect = getRect(chart, chart.getLowestVisibleX(), chart.getHighestVisibleX());
|
||||
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
|
||||
int tileBoxWidthPx = 0;
|
||||
int tileBoxHeightPx = 0;
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
|
||||
int tileBoxWidthPx = 0;
|
||||
int tileBoxHeightPx = 0;
|
||||
|
||||
WeakReference<TrackDetailsMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
TrackDetailsMenuFragment f = fragmentRef.get();
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
if (!portrait) {
|
||||
tileBoxWidthPx = tb.getPixWidth() - f.getWidth();
|
||||
} else {
|
||||
tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
|
||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||
if (fragment != null) {
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
if (!portrait) {
|
||||
tileBoxWidthPx = tb.getPixWidth() - fragment.getWidth();
|
||||
} else {
|
||||
tileBoxHeightPx = tb.getPixHeight() - fragment.getHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tileBoxHeightPx > 0 || tileBoxWidthPx > 0) {
|
||||
if (forceFit) {
|
||||
mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom,
|
||||
tileBoxWidthPx, tileBoxHeightPx, topMarginPx);
|
||||
} else if (location != null &&
|
||||
!mapActivity.getMapView().getTileBox(tileBoxWidthPx, tileBoxHeightPx, topMarginPx).containsLatLon(location)) {
|
||||
boolean animating = mapActivity.getMapView().getAnimatedDraggingThread().isAnimating();
|
||||
mapActivity.getMapView().fitLocationToMap(location.getLatitude(), location.getLongitude(),
|
||||
mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, topMarginPx, !animating);
|
||||
} else {
|
||||
mapActivity.refreshMap();
|
||||
if (tileBoxHeightPx > 0 || tileBoxWidthPx > 0) {
|
||||
if (forceFit) {
|
||||
mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom,
|
||||
tileBoxWidthPx, tileBoxHeightPx, topMarginPx);
|
||||
} else if (location != null &&
|
||||
!mapActivity.getMapView().getTileBox(tileBoxWidthPx, tileBoxHeightPx, topMarginPx).containsLatLon(location)) {
|
||||
boolean animating = mapActivity.getMapView().getAnimatedDraggingThread().isAnimating();
|
||||
mapActivity.getMapView().fitLocationToMap(location.getLatitude(), location.getLongitude(),
|
||||
mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, topMarginPx, !animating);
|
||||
} else {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshChart(LineChart chart, boolean forceFit) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (mapActivity == null || gpxItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Highlight[] highlights = chart.getHighlighted();
|
||||
LatLon location = null;
|
||||
|
||||
TrackChartPoints trackChartPoints = this.trackChartPoints;
|
||||
if (trackChartPoints == null) {
|
||||
trackChartPoints = new TrackChartPoints();
|
||||
TrkSegment segment = getTrackSegment(chart);
|
||||
int segmentColor = segment != null ? segment.getColor(0) : 0;
|
||||
trackChartPoints.setSegmentColor(segmentColor);
|
||||
trackChartPoints.setGpx(getGpxItem().group.getGpx());
|
||||
trackChartPoints.setGpx(gpxItem.group.getGpx());
|
||||
this.trackChartPoints = trackChartPoints;
|
||||
}
|
||||
|
||||
float minimumVisibleXValue = chart.getLowestVisibleX();
|
||||
|
@ -370,6 +438,11 @@ public class TrackDetailsMenu {
|
|||
}
|
||||
|
||||
private void updateView(final View parentView) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (mapActivity == null || gpxItem == null) {
|
||||
return;
|
||||
}
|
||||
GPXTrackAnalysis analysis = gpxItem.analysis;
|
||||
if (analysis == null || gpxItem.chartTypes == null) {
|
||||
parentView.setVisibility(View.GONE);
|
||||
|
@ -408,15 +481,18 @@ public class TrackDetailsMenu {
|
|||
|
||||
@Override
|
||||
public void onChartGestureEnd(MotionEvent me, ChartGesture lastPerformedGesture) {
|
||||
if ((lastPerformedGesture == ChartGesture.DRAG && hasTranslated) ||
|
||||
lastPerformedGesture == ChartGesture.X_ZOOM ||
|
||||
lastPerformedGesture == ChartGesture.Y_ZOOM ||
|
||||
lastPerformedGesture == ChartGesture.PINCH_ZOOM ||
|
||||
lastPerformedGesture == ChartGesture.DOUBLE_TAP ||
|
||||
lastPerformedGesture == ChartGesture.ROTATE) {
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (gpxItem != null) {
|
||||
if ((lastPerformedGesture == ChartGesture.DRAG && hasTranslated) ||
|
||||
lastPerformedGesture == ChartGesture.X_ZOOM ||
|
||||
lastPerformedGesture == ChartGesture.Y_ZOOM ||
|
||||
lastPerformedGesture == ChartGesture.PINCH_ZOOM ||
|
||||
lastPerformedGesture == ChartGesture.DOUBLE_TAP ||
|
||||
lastPerformedGesture == ChartGesture.ROTATE) {
|
||||
|
||||
gpxItem.chartMatrix = new Matrix(chart.getViewPortHandler().getMatrixTouch());
|
||||
refreshChart(chart, true);
|
||||
gpxItem.chartMatrix = new Matrix(chart.getViewPortHandler().getMatrixTouch());
|
||||
refreshChart(chart, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,21 +576,21 @@ public class TrackDetailsMenu {
|
|||
final List<GPXDataSetType[]> availableTypes = new ArrayList<>();
|
||||
boolean hasSlopeChart = false;
|
||||
if (analysis.hasElevationData) {
|
||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE });
|
||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE});
|
||||
if (gpxItem.chartAxisType != GPXDataSetAxisType.TIME
|
||||
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
||||
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SLOPE});
|
||||
}
|
||||
}
|
||||
if (analysis.hasSpeedData) {
|
||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.SPEED });
|
||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.SPEED});
|
||||
}
|
||||
if (analysis.hasElevationData && gpxItem.chartAxisType != GPXDataSetAxisType.TIME
|
||||
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE });
|
||||
&& gpxItem.chartAxisType != GPXDataSetAxisType.TIMEOFDAY) {
|
||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE});
|
||||
}
|
||||
if (analysis.hasElevationData && analysis.hasSpeedData) {
|
||||
availableTypes.add(new GPXDataSetType[] { GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED });
|
||||
availableTypes.add(new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED});
|
||||
}
|
||||
|
||||
for (GPXDataSetType t : gpxItem.chartTypes) {
|
||||
|
@ -529,7 +605,7 @@ public class TrackDetailsMenu {
|
|||
yAxis.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final PopupMenu optionsMenu = new PopupMenu(mapActivity, v);
|
||||
PopupMenu optionsMenu = new PopupMenu(v.getContext(), v);
|
||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
for (final GPXDataSetType[] types : availableTypes) {
|
||||
MenuItem menuItem = optionsMenu.getMenu()
|
||||
|
@ -538,6 +614,7 @@ public class TrackDetailsMenu {
|
|||
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem mItem) {
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
gpxItem.chartTypes = types;
|
||||
update();
|
||||
return true;
|
||||
|
@ -572,20 +649,24 @@ public class TrackDetailsMenu {
|
|||
xAxis.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final PopupMenu optionsMenu = new PopupMenu(mapActivity, v);
|
||||
final PopupMenu optionsMenu = new PopupMenu(v.getContext(), v);
|
||||
DirectionsDialogs.setupPopUpMenuIcon(optionsMenu);
|
||||
for (final GPXDataSetAxisType type : GPXDataSetAxisType.values()) {
|
||||
MenuItem menuItem = optionsMenu.getMenu()
|
||||
.add(type.getStringId()).setIcon(type.getImageDrawable(app));
|
||||
.add(type.getStringId()).setIcon(type.getImageDrawable(app));
|
||||
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem mItem) {
|
||||
|
||||
gpxItem.chartAxisType = type;
|
||||
gpxItem.chartHighlightPos = -1;
|
||||
gpxItem.chartMatrix = null;
|
||||
update();
|
||||
return true;
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
if (gpxItem != null) {
|
||||
gpxItem.chartAxisType = type;
|
||||
gpxItem.chartHighlightPos = -1;
|
||||
gpxItem.chartMatrix = null;
|
||||
update();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -603,15 +684,18 @@ public class TrackDetailsMenu {
|
|||
}
|
||||
|
||||
private void updateChart(LineChart chart) {
|
||||
GpxDisplayItem gpxItem = getGpxItem();
|
||||
chart.notifyDataSetChanged();
|
||||
chart.invalidate();
|
||||
if (gpxItem.chartMatrix != null) {
|
||||
chart.getViewPortHandler().refresh(new Matrix(gpxItem.chartMatrix), chart, true);
|
||||
}
|
||||
if (gpxItem.chartHighlightPos != -1) {
|
||||
chart.highlightValue(gpxItem.chartHighlightPos, 0);
|
||||
} else {
|
||||
chart.highlightValue(null);
|
||||
if (gpxItem != null) {
|
||||
if (gpxItem.chartMatrix != null) {
|
||||
chart.getViewPortHandler().refresh(new Matrix(gpxItem.chartMatrix), chart, true);
|
||||
}
|
||||
if (gpxItem.chartHighlightPos != -1) {
|
||||
chart.highlightValue(gpxItem.chartHighlightPos, 0);
|
||||
} else {
|
||||
chart.highlightValue(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu.other;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
|
@ -25,16 +26,23 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
|
||||
private TrackDetailsMenu menu;
|
||||
private View mainView;
|
||||
private boolean paused = true;
|
||||
|
||||
@Nullable
|
||||
private MapActivity getMapActivity() {
|
||||
return (MapActivity) getActivity();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private MapActivity requireMapActivity() {
|
||||
return (MapActivity) requireMyActivity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
menu = mapActivity.getMapLayers().getMapControlsLayer().getTrackDetailsMenu();
|
||||
MapActivity mapActivity = requireMapActivity();
|
||||
menu = mapActivity.getTrackDetailsMenu();
|
||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
ContextThemeWrapper context =
|
||||
new ContextThemeWrapper(mapActivity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
|
||||
|
@ -74,7 +82,7 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
closeButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
menu.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -107,7 +115,16 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
super.onResume();
|
||||
if (menu == null || menu.getGpxItem() == null) {
|
||||
dismiss();
|
||||
} else {
|
||||
menu.onShow();
|
||||
}
|
||||
paused = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
paused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,6 +140,10 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
return R.color.status_bar_transparent_gradient;
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return paused;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
if (mainView != null) {
|
||||
return mainView.getHeight();
|
||||
|
@ -164,26 +185,28 @@ public class TrackDetailsMenuFragment extends BaseOsmAndFragment {
|
|||
|
||||
public void applyDayNightMode() {
|
||||
MapActivity ctx = getMapActivity();
|
||||
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(ctx);
|
||||
boolean landscapeLayout = !portraitMode;
|
||||
boolean nightMode = ctx.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
if (!landscapeLayout) {
|
||||
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
|
||||
}
|
||||
if (ctx != null) {
|
||||
boolean portraitMode = AndroidUiHelper.isOrientationPortrait(ctx);
|
||||
boolean landscapeLayout = !portraitMode;
|
||||
boolean nightMode = ctx.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
if (!landscapeLayout) {
|
||||
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(ctx, mainView, nightMode, R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
|
||||
}
|
||||
|
||||
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.y_axis_title), nightMode);
|
||||
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.x_axis_title), nightMode);
|
||||
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.y_axis_title), nightMode);
|
||||
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.x_axis_title), nightMode);
|
||||
|
||||
ImageView yAxisArrow = (ImageView) mainView.findViewById(R.id.y_axis_arrow);
|
||||
ImageView xAxisArrow = (ImageView) mainView.findViewById(R.id.x_axis_arrow);
|
||||
yAxisArrow.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_drop_down));
|
||||
xAxisArrow.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_drop_down));
|
||||
ImageView yAxisArrow = (ImageView) mainView.findViewById(R.id.y_axis_arrow);
|
||||
ImageView xAxisArrow = (ImageView) mainView.findViewById(R.id.x_axis_arrow);
|
||||
yAxisArrow.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_drop_down));
|
||||
xAxisArrow.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_drop_down));
|
||||
|
||||
ImageButton backButton = (ImageButton) mainView.findViewById(R.id.top_bar_back_button);
|
||||
if (backButton != null) {
|
||||
backButton.setImageDrawable(getIcon(R.drawable.ic_arrow_back, R.color.color_white));
|
||||
ImageButton backButton = (ImageButton) mainView.findViewById(R.id.top_bar_back_button);
|
||||
if (backButton != null) {
|
||||
backButton.setImageDrawable(getIcon(R.drawable.ic_arrow_back, R.color.color_white));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1367,10 +1367,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
if (list.size() > 0) {
|
||||
gpxItem.chartTypes = list.toArray(new GPXDataSetType[list.size()]);
|
||||
}
|
||||
if (gpxItem.group.getGpx() != null) {
|
||||
gpxItem.wasHidden = app.getSelectedGpxHelper().getSelectedFileByPath(gpxInfo.file.getAbsolutePath()) == null;
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpxItem.group.getGpx());
|
||||
}
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
settings.setMapLocationToShow(gpxItem.locationStart.lat, gpxItem.locationStart.lon,
|
||||
settings.getLastKnownMapZoom(),
|
||||
|
|
|
@ -1168,12 +1168,6 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
gpxItem.locationOnMap = gpxItem.locationStart;
|
||||
}
|
||||
|
||||
GPXFile gpx = getGpx();
|
||||
GPXFile groupGpx = gpxItem.group.getGpx();
|
||||
if (gpx != null && groupGpx != null) {
|
||||
gpxItem.wasHidden = app.getSelectedGpxHelper().getSelectedFileByPath(gpx.path) == null;
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(groupGpx);
|
||||
}
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(),
|
||||
settings.getLastKnownMapZoom(),
|
||||
|
|
|
@ -46,14 +46,13 @@ import net.osmand.plus.TargetPointsHelper;
|
|||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
|
||||
import net.osmand.plus.base.ContextMenuFragment.MenuState;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
|
||||
import net.osmand.plus.base.ContextMenuFragment.MenuState;
|
||||
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu.PointType;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.search.QuickSearchDialogFragment.QuickSearchType;
|
||||
|
@ -101,7 +100,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
private OsmandSettings settings;
|
||||
|
||||
private MapRouteInfoMenu mapRouteInfoMenu;
|
||||
private TrackDetailsMenu trackDetailsMenu;
|
||||
private MapHudButton backToLocationControl;
|
||||
private MapHudButton menuControl;
|
||||
private MapHudButton compassHud;
|
||||
|
@ -132,10 +130,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
|
||||
}
|
||||
|
||||
public TrackDetailsMenu getTrackDetailsMenu() {
|
||||
return trackDetailsMenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean drawInScreenPixels() {
|
||||
return true;
|
||||
|
@ -299,7 +293,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
private void initRouteControls() {
|
||||
mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu();
|
||||
trackDetailsMenu = new TrackDetailsMenu(mapActivity);
|
||||
}
|
||||
|
||||
public void setControlsClickable(boolean clickable) {
|
||||
|
@ -753,7 +746,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
routePlanningMode = true;
|
||||
}
|
||||
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
|
||||
boolean trackDialogOpened = TrackDetailsMenu.isVisible();
|
||||
boolean trackDialogOpened = mapActivity.getTrackDetailsMenu().isVisible();
|
||||
boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls();
|
||||
boolean showRouteCalculationControls = routePlanningMode ||
|
||||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
|
|
Loading…
Reference in a new issue