diff --git a/OsmAnd/res/layout/route_info_header.xml b/OsmAnd/res/layout/route_info_header.xml index d2ba9e5148..9844a4ed9b 100644 --- a/OsmAnd/res/layout/route_info_header.xml +++ b/OsmAnd/res/layout/route_info_header.xml @@ -9,7 +9,7 @@ @@ -63,6 +65,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" + android:paddingStart="16dp" android:paddingLeft="16dp"> @@ -105,7 +109,7 @@ @@ -128,6 +132,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" + android:paddingStart="16dp" android:paddingLeft="16dp"> @@ -171,6 +177,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" + android:paddingStart="16dp" android:paddingLeft="16dp"> @@ -213,7 +221,7 @@ @@ -307,6 +321,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" + android:paddingStart="16dp" android:paddingLeft="16dp"> @@ -347,4 +363,40 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java index 7c6d36b463..809041feb6 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/TrackDetailsMenu.java @@ -288,7 +288,7 @@ public class TrackDetailsMenu { tileBoxHeightPx = tb.getPixHeight() - f.getHeight(); } } - if (tileBoxHeightPx > 0) { + if (tileBoxHeightPx > 0 || tileBoxWidthPx > 0) { if (forceFit) { mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom, tileBoxWidthPx, tileBoxHeightPx, topMarginPx); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 45f42750d4..f35a26fdb3 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -31,10 +31,14 @@ import android.widget.ImageButton; import net.osmand.AndroidUtils; import net.osmand.GPXUtilities; import net.osmand.Location; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.LockableViewPager; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityActions; @@ -90,6 +94,7 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe private boolean publicTransportMode; private int routeInfoMenuState = -1; + private boolean openingAnalyseOnMap = false; @Nullable @Override @@ -236,12 +241,26 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.icon_color); } + public void analyseOnMap(LatLon location, GpxDisplayItem gpxItem) { + openingAnalyseOnMap = true; + OsmandApplication app = requireMyApplication(); + final OsmandSettings settings = app.getSettings(); + settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), + settings.getLastKnownMapZoom(), + new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), + false, + gpxItem); + + dismiss(); + MapActivity.launchMapActivityMoveToTop(getMapActivity()); + } + public void dismiss() { try { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss(); - if (routeInfoMenuState != -1) { + if (routeInfoMenuState != -1 && !openingAnalyseOnMap) { mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(routeInfoMenuState); } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java index da6de5eea4..ae8570a471 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenuFragment.java @@ -255,10 +255,10 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment { @Override protected void calculateLayout(View view) { - super.calculateLayout(view); menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight() + view.findViewById(R.id.control_buttons).getHeight() - view.findViewById(R.id.buttons_shadow).getHeight(); + super.calculateLayout(view); } private void adjustMapPosition(int y) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java index 4d9f07adcd..c4c0c74695 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteDetailsFragment.java @@ -12,6 +12,7 @@ import android.os.Bundle; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v7.view.ContextThemeWrapper; import android.text.Spannable; @@ -320,6 +321,11 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT } return false; } + }, new OnClickListener() { + @Override + public void onClick(View v) { + openDetails(); + } }); statisticCard.setTransparentBackground(true); menuCards.add(statisticCard); @@ -1444,7 +1450,6 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT void openDetails() { if (gpxItem != null && elevationDataSet != null) { - OsmandApplication app = requireMyApplication(); LatLon location = null; WptPt wpt = null; gpxItem.chartTypes = new GPXDataSetType[]{GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE}; @@ -1473,33 +1478,9 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT gpxItem.locationOnMap = gpxItem.locationStart; } - final MapActivity activity = (MapActivity) getActivity(); - if (activity != null) { - dismiss(); - - final OsmandSettings settings = app.getSettings(); - settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), - settings.getLastKnownMapZoom(), - new PointDescription(PointDescription.POINT_TYPE_WPT, gpxItem.name), - false, - gpxItem); - - final MapRouteInfoMenu mapRouteInfoMenu = activity.getMapRouteInfoMenu(); - if (mapRouteInfoMenu.isVisible()) { - // We arrived here by the route info menu. - // First, we close it and then show the details. - mapRouteInfoMenu.setOnDismissListener(new OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - mapRouteInfoMenu.setOnDismissListener(null); - MapActivity.launchMapActivityMoveToTop(activity); - } - }); - mapRouteInfoMenu.hide(); - } else { - // We arrived here by the dashboard. - MapActivity.launchMapActivityMoveToTop(activity); - } + ChooseRouteFragment parent = (ChooseRouteFragment) getParentFragment(); + if (parent != null) { + parent.analyseOnMap(location, gpxItem); } } } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java index f2663aa870..4754894e9a 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/RouteStatisticCard.java @@ -1,11 +1,15 @@ package net.osmand.plus.routepreparationmenu.cards; import android.graphics.Matrix; +import android.os.Build; import android.support.annotation.Nullable; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import android.view.MotionEvent; import android.view.View; +import android.view.View.OnClickListener; +import android.view.View.OnTouchListener; +import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; @@ -16,6 +20,7 @@ import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture; import com.github.mikephil.charting.listener.OnChartGestureListener; +import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.plus.GpxSelectionHelper; @@ -40,12 +45,15 @@ public class RouteStatisticCard extends BaseCard { private OrderedLineDataSet slopeDataSet; @Nullable private OrderedLineDataSet elevationDataSet; - private View.OnTouchListener onTouchListener; + private OnTouchListener onTouchListener; + private OnClickListener onAnalyseClickListener; - public RouteStatisticCard(MapActivity mapActivity, GPXFile gpx, View.OnTouchListener onTouchListener) { + public RouteStatisticCard(MapActivity mapActivity, GPXFile gpx, OnTouchListener onTouchListener, + OnClickListener onAnalyseClickListener) { super(mapActivity); this.gpx = gpx; this.onTouchListener = onTouchListener; + this.onAnalyseClickListener = onAnalyseClickListener; makeGpxDisplayItem(); } @@ -115,6 +123,17 @@ public class RouteStatisticCard extends BaseCard { if (isTransparentBackground()) { view.setBackgroundDrawable(null); } + + FrameLayout analyseButton = (FrameLayout) view.findViewById(R.id.analyse_button); + TextView analyseButtonDescr = (TextView) view.findViewById(R.id.analyse_button_descr); + + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(app, analyseButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark); + AndroidUtils.setBackground(app, analyseButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark); + } else { + AndroidUtils.setBackground(app, analyseButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark); + } + analyseButton.setOnClickListener(onAnalyseClickListener); } @Nullable