Merge branch 'r3.3'
This commit is contained in:
commit
4b5240586b
6 changed files with 99 additions and 26 deletions
|
@ -878,7 +878,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
if (getActivity() == null) {
|
if (getActivity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
calculateLayout(view);
|
calculateLayout(view, initLayout);
|
||||||
|
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
doLayoutMenu();
|
doLayoutMenu();
|
||||||
|
@ -895,7 +895,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void calculateLayout(View view) {
|
protected void calculateLayout(View view, boolean initLayout) {
|
||||||
menuFullHeight = mainView.getHeight();
|
menuFullHeight = mainView.getHeight();
|
||||||
menuBottomViewHeight = menuFullHeight;
|
menuBottomViewHeight = menuFullHeight;
|
||||||
menuFullHeightMax = view.findViewById(R.id.route_menu_cards_container).getHeight() +
|
menuFullHeightMax = view.findViewById(R.id.route_menu_cards_container).getHeight() +
|
||||||
|
|
|
@ -338,14 +338,13 @@ public class TrackDetailsMenu {
|
||||||
int tileBoxWidthPx = 0;
|
int tileBoxWidthPx = 0;
|
||||||
int tileBoxHeightPx = 0;
|
int tileBoxHeightPx = 0;
|
||||||
|
|
||||||
TrackDetailsMenuFragment fragment = getMenuFragment();
|
|
||||||
if (fragment != null) {
|
|
||||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||||
if (!portrait) {
|
if (!portrait) {
|
||||||
tileBoxWidthPx = tb.getPixWidth() - fragment.getWidth();
|
int width = getFragmentWidth();
|
||||||
|
tileBoxWidthPx = width != -1 ? tb.getPixWidth() - width : 0;
|
||||||
} else {
|
} else {
|
||||||
tileBoxHeightPx = tb.getPixHeight() - fragment.getHeight();
|
int height = getFragmentHeight();
|
||||||
}
|
tileBoxHeightPx = height != -1 ? tb.getPixHeight() - height : 0;
|
||||||
}
|
}
|
||||||
if (tileBoxHeightPx > 0 || tileBoxWidthPx > 0) {
|
if (tileBoxHeightPx > 0 || tileBoxWidthPx > 0) {
|
||||||
if (forceFit) {
|
if (forceFit) {
|
||||||
|
@ -363,6 +362,22 @@ public class TrackDetailsMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getFragmentWidth() {
|
||||||
|
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||||
|
if (fragment != null) {
|
||||||
|
return fragment.getWidth();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getFragmentHeight() {
|
||||||
|
TrackDetailsMenuFragment fragment = getMenuFragment();
|
||||||
|
if (fragment != null) {
|
||||||
|
return fragment.getHeight();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshChart(LineChart chart, boolean forceFit) {
|
public void refreshChart(LineChart chart, boolean forceFit) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
GpxDisplayItem gpxItem = getGpxItem();
|
GpxDisplayItem gpxItem = getGpxItem();
|
||||||
|
|
|
@ -246,11 +246,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void calculateLayout(View view) {
|
protected void calculateLayout(View view, boolean initLayout) {
|
||||||
menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight()
|
menuTitleHeight = view.findViewById(R.id.route_menu_top_shadow_all).getHeight()
|
||||||
+ view.findViewById(R.id.control_buttons).getHeight()
|
+ view.findViewById(R.id.control_buttons).getHeight()
|
||||||
- view.findViewById(R.id.buttons_shadow).getHeight();
|
- view.findViewById(R.id.buttons_shadow).getHeight();
|
||||||
super.calculateLayout(view);
|
super.calculateLayout(view, initLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustMapPosition(int y) {
|
private void adjustMapPosition(int y) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ import com.github.mikephil.charting.charts.LineChart;
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.highlight.Highlight;
|
import com.github.mikephil.charting.highlight.Highlight;
|
||||||
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider;
|
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider;
|
||||||
|
import com.github.mikephil.charting.listener.ChartTouchListener;
|
||||||
|
import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
|
||||||
import com.github.mikephil.charting.renderer.HorizontalBarChartRenderer;
|
import com.github.mikephil.charting.renderer.HorizontalBarChartRenderer;
|
||||||
import com.github.mikephil.charting.utils.ViewPortHandler;
|
import com.github.mikephil.charting.utils.ViewPortHandler;
|
||||||
|
|
||||||
|
@ -120,12 +122,25 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
private RouteDetailsFragmentListener routeDetailsListener;
|
private RouteDetailsFragmentListener routeDetailsListener;
|
||||||
private RouteStatisticCard statisticCard;
|
private RouteStatisticCard statisticCard;
|
||||||
private List<RouteInfoCard> routeInfoCards = new ArrayList<>();
|
private List<RouteInfoCard> routeInfoCards = new ArrayList<>();
|
||||||
private TrackDetailsMenu trackDetailsMenu;
|
private RouteDetailsMenu routeDetailsMenu;
|
||||||
|
|
||||||
public interface RouteDetailsFragmentListener {
|
public interface RouteDetailsFragmentListener {
|
||||||
void onNavigationRequested();
|
void onNavigationRequested();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class RouteDetailsMenu extends TrackDetailsMenu {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getFragmentWidth() {
|
||||||
|
return getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getFragmentHeight() {
|
||||||
|
return getMenuFullHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMainLayoutId() {
|
public int getMainLayoutId() {
|
||||||
return R.layout.route_info_layout;
|
return R.layout.route_info_layout;
|
||||||
|
@ -186,8 +201,8 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && isPortrait()) {
|
if (mapActivity != null && isPortrait()) {
|
||||||
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.GONE);
|
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.GONE);
|
||||||
if (trackDetailsMenu != null) {
|
if (routeDetailsMenu != null) {
|
||||||
trackDetailsMenu.setMapActivity(mapActivity);
|
routeDetailsMenu.setMapActivity(mapActivity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,8 +212,8 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && isPortrait()) {
|
if (mapActivity != null && isPortrait()) {
|
||||||
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.VISIBLE);
|
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.VISIBLE);
|
||||||
if (trackDetailsMenu != null) {
|
if (routeDetailsMenu != null) {
|
||||||
trackDetailsMenu.setMapActivity(null);
|
routeDetailsMenu.setMapActivity(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
@ -376,17 +391,24 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
addRouteCard(cardsContainer, routeSmoothnessCard);
|
addRouteCard(cardsContainer, routeSmoothnessCard);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trackDetailsMenu = new TrackDetailsMenu();
|
routeDetailsMenu = new RouteDetailsMenu();
|
||||||
GpxDisplayItem gpxItem = statisticCard.getGpxItem();
|
GpxDisplayItem gpxItem = statisticCard.getGpxItem();
|
||||||
if (gpxItem != null) {
|
if (gpxItem != null) {
|
||||||
trackDetailsMenu.setGpxItem(gpxItem);
|
routeDetailsMenu.setGpxItem(gpxItem);
|
||||||
}
|
}
|
||||||
trackDetailsMenu.setMapActivity(mapActivity);
|
routeDetailsMenu.setMapActivity(mapActivity);
|
||||||
LineChart chart = statisticCard.getChart();
|
LineChart chart = statisticCard.getChart();
|
||||||
if (chart != null) {
|
if (chart != null) {
|
||||||
chart.setExtraRightOffset(16);
|
chart.setExtraRightOffset(16);
|
||||||
chart.setExtraLeftOffset(16);
|
chart.setExtraLeftOffset(16);
|
||||||
trackDetailsMenu.refreshChart(chart, true);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void calculateLayout(View view, boolean initLayout) {
|
||||||
|
super.calculateLayout(view, initLayout);
|
||||||
|
if (!initLayout && getCurrentMenuState() != MenuState.FULL_SCREEN) {
|
||||||
|
refreshChart(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1644,12 +1666,13 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshChart() {
|
private void refreshChart(boolean forceFit) {
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null && trackDetailsMenu != null && statisticCard != null) {
|
if (mapActivity != null && routeDetailsMenu != null && statisticCard != null &&
|
||||||
|
!mapActivity.getMyApplication().getRoutingHelper().isFollowingMode()) {
|
||||||
LineChart chart = statisticCard.getChart();
|
LineChart chart = statisticCard.getChart();
|
||||||
if (chart != null) {
|
if (chart != null) {
|
||||||
trackDetailsMenu.refreshChart(chart, false);
|
routeDetailsMenu.refreshChart(chart, forceFit);
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1670,7 +1693,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onValueSelected(BaseCard card, Entry e, Highlight h) {
|
public void onValueSelected(BaseCard card, Entry e, Highlight h) {
|
||||||
refreshChart();
|
refreshChart(false);
|
||||||
highlightRouteInfoCharts(h);
|
highlightRouteInfoCharts(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1679,6 +1702,23 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
|
||||||
highlightRouteInfoCharts(null);
|
highlightRouteInfoCharts(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChartGestureStart(BaseCard card, MotionEvent me, ChartGesture lastPerformedGesture) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChartGestureEnd(BaseCard card, MotionEvent me, ChartGesture lastPerformedGesture, boolean hasTranslated) {
|
||||||
|
if ((lastPerformedGesture == ChartGesture.DRAG && hasTranslated) ||
|
||||||
|
lastPerformedGesture == ChartGesture.X_ZOOM ||
|
||||||
|
lastPerformedGesture == ChartGesture.Y_ZOOM ||
|
||||||
|
lastPerformedGesture == ChartGesture.PINCH_ZOOM ||
|
||||||
|
lastPerformedGesture == ChartGesture.DOUBLE_TAP ||
|
||||||
|
lastPerformedGesture == ChartGesture.ROTATE) {
|
||||||
|
|
||||||
|
refreshChart(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class CumulativeInfo {
|
public static class CumulativeInfo {
|
||||||
public int distance;
|
public int distance;
|
||||||
public int time;
|
public int time;
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
package net.osmand.plus.routepreparationmenu.cards;
|
package net.osmand.plus.routepreparationmenu.cards;
|
||||||
|
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.highlight.Highlight;
|
import com.github.mikephil.charting.highlight.Highlight;
|
||||||
|
import com.github.mikephil.charting.listener.ChartTouchListener;
|
||||||
|
import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
|
||||||
|
|
||||||
public interface CardChartListener {
|
public interface CardChartListener {
|
||||||
/**
|
/**
|
||||||
|
@ -17,4 +21,8 @@ public interface CardChartListener {
|
||||||
* Called when nothing has been selected or an "un-select" has been made.
|
* Called when nothing has been selected or an "un-select" has been made.
|
||||||
*/
|
*/
|
||||||
void onNothingSelected(BaseCard card);
|
void onNothingSelected(BaseCard card);
|
||||||
|
|
||||||
|
void onChartGestureStart(BaseCard card, MotionEvent me, ChartGesture lastPerformedGesture);
|
||||||
|
|
||||||
|
void onChartGestureEnd(BaseCard card, MotionEvent me, ChartGesture lastPerformedGesture, boolean hasTranslated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,16 +278,21 @@ public class RouteStatisticCard extends BaseCard {
|
||||||
});
|
});
|
||||||
|
|
||||||
mChart.setOnChartGestureListener(new OnChartGestureListener() {
|
mChart.setOnChartGestureListener(new OnChartGestureListener() {
|
||||||
|
boolean hasTranslated = false;
|
||||||
float highlightDrawX = -1;
|
float highlightDrawX = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChartGestureStart(MotionEvent me, ChartGesture lastPerformedGesture) {
|
public void onChartGestureStart(MotionEvent me, ChartGesture lastPerformedGesture) {
|
||||||
|
hasTranslated = false;
|
||||||
if (mChart.getHighlighted() != null && mChart.getHighlighted().length > 0) {
|
if (mChart.getHighlighted() != null && mChart.getHighlighted().length > 0) {
|
||||||
highlightDrawX = mChart.getHighlighted()[0].getDrawX();
|
highlightDrawX = mChart.getHighlighted()[0].getDrawX();
|
||||||
} else {
|
} else {
|
||||||
highlightDrawX = -1;
|
highlightDrawX = -1;
|
||||||
}
|
}
|
||||||
|
CardChartListener chartListener = getChartListener();
|
||||||
|
if (chartListener != null) {
|
||||||
|
chartListener.onChartGestureStart(RouteStatisticCard.this, me, lastPerformedGesture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -299,6 +304,10 @@ public class RouteStatisticCard extends BaseCard {
|
||||||
} else {
|
} else {
|
||||||
gpxItem.chartHighlightPos = -1;
|
gpxItem.chartHighlightPos = -1;
|
||||||
}
|
}
|
||||||
|
CardChartListener chartListener = getChartListener();
|
||||||
|
if (chartListener != null) {
|
||||||
|
chartListener.onChartGestureEnd(RouteStatisticCard.this, me, lastPerformedGesture, hasTranslated);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -323,6 +332,7 @@ public class RouteStatisticCard extends BaseCard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChartTranslate(MotionEvent me, float dX, float dY) {
|
public void onChartTranslate(MotionEvent me, float dX, float dY) {
|
||||||
|
hasTranslated = true;
|
||||||
if (highlightDrawX != -1) {
|
if (highlightDrawX != -1) {
|
||||||
Highlight h = mChart.getHighlightByTouchPoint(highlightDrawX, 0f);
|
Highlight h = mChart.getHighlightByTouchPoint(highlightDrawX, 0f);
|
||||||
if (h != null) {
|
if (h != null) {
|
||||||
|
|
Loading…
Reference in a new issue