Merge branch 'r3.3'

This commit is contained in:
Chumva 2019-04-08 18:18:35 +03:00
commit fce933fa32
18 changed files with 453 additions and 262 deletions

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:id="@+id/route_directions_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/directions_card_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/content_padding"
android:text="@string/step_by_step"
android:textColor="?attr/main_font_color_basic"
android:textSize="@dimen/text_button_text_size"
osmand:typeface="@string/font_roboto_medium" />
<LinearLayout
android:id="@+id/items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>

View file

@ -121,6 +121,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/altitude_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
@ -220,6 +221,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/slope_info_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
@ -264,6 +266,7 @@
</LinearLayout>
<LinearLayout
android:id="@+id/slope_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"

View file

@ -36,7 +36,7 @@
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/divider_color_basic"
android:visibility="gone"/>
android:visibility="visible"/>
<FrameLayout
android:id="@+id/start_button"

View file

@ -1606,6 +1606,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return trackDetailsMenu;
}
public void hideContextAndRouteInfoMenues() {
mapContextMenu.hideMenues();
mapRouteInfoMenu.hide();
}
public void openDrawer() {
mapActions.updateDrawerMenu();
boolean animate = !settings.DO_NOT_USE_ANIMATIONS.get();

View file

@ -889,7 +889,8 @@ public class MapActivityActions implements DialogProvider {
}
public void openIntermediatePointsDialog() {
WaypointsFragment.showInstance(mapActivity);
mapActivity.hideContextAndRouteInfoMenues();
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager());
}
public void openRoutePreferencesDialog() {

View file

@ -1263,7 +1263,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
super.onResume();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
if (!menu.isActive() || (mapActivity.getMapRouteInfoMenu().isVisible()) || MapRouteInfoMenu.chooseRoutesVisible) {
if (!menu.isActive() || (mapActivity.getMapRouteInfoMenu().isVisible()) || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
dismissMenu();
return;
}

View file

@ -157,6 +157,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
public void onPause() {
super.onPause();
setUpdateEnable(false);
if (actionMode != null) {
actionMode.finish();
}
if (optionsMenu != null) {
optionsMenu.close();
}
@ -1004,7 +1007,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
public void onClick(View v) {
List<GpxDisplayItem> items = itemGroups.get(group);
if (ch.isChecked()) {
if (groupPosition == 0) {
if (groupPosition == 0 && groups.size() > 1) {
setTrackPointsSelection(true);
} else {
setGroupSelection(items, groupPosition, true);
@ -1027,7 +1030,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
}
private void setTrackPointsSelection(boolean select) {
if (groups.size() > 1) {
if (!groups.isEmpty()) {
setGroupSelection(null, 0, select);
for (int i = 1; i < groups.size(); i++) {
GpxDisplayGroup g = groups.get(i);

View file

@ -109,6 +109,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
public static int directionInfo = -1;
public static boolean chooseRoutesVisible = false;
public static boolean waypointsVisible = false;
private boolean routeCalculationInProgress;
private boolean selectFromMapTouch;
@ -1350,7 +1352,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && mapActivity.getMyApplication().getTargetPointsHelper().checkPointToNavigateShort()) {
WaypointsFragment.showInstance(mapActivity);
hide();
WaypointsFragment.showInstance(mapActivity.getSupportFragmentManager(), getCurrentMenuState());
}
}
});

View file

@ -469,6 +469,8 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerButtons), nightMode,
R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.controls_divider), nightMode,
R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_options_container), nightMode,
R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
AndroidUtils.setBackground(ctx, view.findViewById(R.id.app_modes_fold_container), nightMode,

View file

@ -1,8 +1,6 @@
package net.osmand.plus.routepreparationmenu;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
@ -11,7 +9,6 @@ import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.view.ContextThemeWrapper;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@ -65,6 +62,7 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard.PublicTransportCardListener;
import net.osmand.plus.routepreparationmenu.cards.RouteDirectionsCard;
import net.osmand.plus.routepreparationmenu.cards.RouteInfoCard;
import net.osmand.plus.routepreparationmenu.cards.RouteStatisticCard;
import net.osmand.plus.routing.RouteCalculationResult;
@ -72,7 +70,6 @@ import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.TurnPathHelper;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.widgets.style.CustomTypefaceSpan;
import net.osmand.render.RenderingRuleSearchRequest;
@ -255,81 +252,40 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
transportCard = null;
makeGpx();
createRouteStatisticCards(cardsContainer);
createRouteDirections(cardsContainer);
createRouteDirectionsCard(cardsContainer);
}
}
}
}
private void createRouteDirections(LinearLayout cardsContainer) {
OsmandApplication app = requireMyApplication();
TextViewEx routeDirectionsTitle = new TextViewEx(app);
routeDirectionsTitle.setTextColor(getMainFontColor());
routeDirectionsTitle.setTextSize(15);
routeDirectionsTitle.setGravity(Gravity.CENTER_VERTICAL);
routeDirectionsTitle.setPadding(dpToPx(16), dpToPx(16), dpToPx(16), dpToPx(16));
routeDirectionsTitle.setText(R.string.step_by_step);
routeDirectionsTitle.setTypeface(FontCache.getRobotoMedium(app));
cardsContainer.addView(routeDirectionsTitle);
List<RouteDirectionInfo> routeDirections = app.getRoutingHelper().getRouteDirections();
for (int i = 0; i < routeDirections.size(); i++) {
RouteDirectionInfo routeDirectionInfo = routeDirections.get(i);
OnClickListener onClickListener = createRouteDirectionInfoViewClickListener(i, routeDirectionInfo);
View view = getRouteDirectionView(i, routeDirectionInfo, routeDirections, onClickListener);
cardsContainer.addView(view);
}
}
private OnClickListener createRouteDirectionInfoViewClickListener(final int directionInfoIndex, final RouteDirectionInfo routeDirectionInfo) {
return new OnClickListener() {
@Override
public void onClick(View view) {
OsmandApplication app = requireMyApplication();
Location loc = app.getRoutingHelper().getLocationFromRouteDirection(routeDirectionInfo);
if (loc != null) {
MapRouteInfoMenu.directionInfo = directionInfoIndex;
OsmandSettings settings = app.getSettings();
settings.setMapLocationToShow(loc.getLatitude(), loc.getLongitude(),
Math.max(13, settings.getLastKnownMapZoom()),
new PointDescription(PointDescription.POINT_TYPE_MARKER,
routeDirectionInfo.getDescriptionRoutePart() + " " + getTimeDescription(app, routeDirectionInfo)),
false, null);
MapActivity.launchMapActivityMoveToTop(getActivity());
dismiss();
}
}
};
}
private void createRouteStatisticCards(LinearLayout cardsContainer) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
OsmandApplication app = mapActivity.getMyApplication();
RouteStatisticCard statisticCard = new RouteStatisticCard(mapActivity, gpx, new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
InterceptorLinearLayout mainView = getMainView();
if (mainView != null) {
mainView.requestDisallowInterceptTouchEvent(true);
}
return false;
}
}, new OnClickListener() {
@Override
public void onClick(View v) {
openDetails();
}
});
statisticCard.setTransparentBackground(true);
menuCards.add(statisticCard);
cardsContainer.addView(statisticCard.build(mapActivity));
buildRowDivider(cardsContainer, false);
slopeDataSet = statisticCard.getSlopeDataSet();
elevationDataSet = statisticCard.getElevationDataSet();
if (gpx.hasAltitude) {
RouteStatisticCard statisticCard = new RouteStatisticCard(mapActivity, gpx, new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
InterceptorLinearLayout mainView = getMainView();
if (mainView != null) {
mainView.requestDisallowInterceptTouchEvent(true);
}
return false;
}
}, new OnClickListener() {
@Override
public void onClick(View v) {
openDetails();
}
});
statisticCard.setTransparentBackground(true);
menuCards.add(statisticCard);
cardsContainer.addView(statisticCard.build(mapActivity));
buildRowDivider(cardsContainer, false);
slopeDataSet = statisticCard.getSlopeDataSet();
elevationDataSet = statisticCard.getElevationDataSet();
List<RouteSegmentResult> route = app.getRoutingHelper().getRoute().getOriginalRoute();
if (route != null) {
RenderingRulesStorage currentRenderer = app.getRendererRegistry().getCurrentSelectedRenderer();
@ -360,6 +316,19 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
private void createRouteDirectionsCard(LinearLayout cardsContainer) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
RouteDirectionsCard directionsCard = new RouteDirectionsCard(mapActivity);
directionsCard.setTransparentBackground(true);
directionsCard.setListener(this);
menuCards.add(directionsCard);
cardsContainer.addView(directionsCard.build(mapActivity));
buildRowDivider(cardsContainer, false);
}
private void createRouteCard(LinearLayout cardsContainer, RouteInfoCard routeInfoCard) {
OsmandApplication app = requireMyApplication();
menuCards.add(routeInfoCard);
@ -374,7 +343,7 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
private void buildSegmentItem(View view, final TransportRouteResultSegment segment,
final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double boardingTime) {
final TransportRouteResultSegment nextSegment, int[] startTime, double walkSpeed, double boardingTime) {
OsmandApplication app = requireMyApplication();
TransportRoute transportRoute = segment.route;
List<TransportStop> stops = segment.getTravelStops();
@ -1483,6 +1452,30 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
private void showDirectionsInfo(int directionInfoIndex) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
RoutingHelper helper = mapActivity.getRoutingHelper();
List<RouteDirectionInfo> routeDirections = helper.getRouteDirections();
if (routeDirections.size() > directionInfoIndex) {
RouteDirectionInfo routeDirectionInfo = routeDirections.get(directionInfoIndex);
Location loc = helper.getLocationFromRouteDirection(routeDirectionInfo);
if (loc != null) {
MapRouteInfoMenu.directionInfo = directionInfoIndex;
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
settings.setMapLocationToShow(loc.getLatitude(), loc.getLongitude(),
Math.max(13, settings.getLastKnownMapZoom()),
new PointDescription(PointDescription.POINT_TYPE_MARKER,
routeDirectionInfo.getDescriptionRoutePart() + " " + getTimeDescription(mapActivity.getMyApplication(), routeDirectionInfo)),
false, null);
MapActivity.launchMapActivityMoveToTop(mapActivity);
dismiss();
}
}
}
@Override
public void onPublicTransportCardBadgePressed(@NonNull PublicTransportCard card, @NonNull TransportRouteResultSegment segment) {
showRouteSegmentOnMap(segment);
@ -1512,6 +1505,8 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) {
if (card instanceof PublicTransportCard && buttonIndex == 0) {
openMenuFullScreen();
} else if (card instanceof RouteDirectionsCard && buttonIndex >= 0) {
showDirectionsInfo(buttonIndex);
}
}
@ -1525,48 +1520,6 @@ public class RouteDetailsFragment extends ContextMenuFragment implements PublicT
}
}
public View getRouteDirectionView(int position, RouteDirectionInfo model, List<RouteDirectionInfo> directionsInfo, OnClickListener onClickListener) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return null;
}
OsmandApplication app = mapActivity.getMyApplication();
ContextThemeWrapper context = new ContextThemeWrapper(mapActivity, isNightMode() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme);
View row = LayoutInflater.from(context).inflate(R.layout.route_info_list_item, null);
TextView label = (TextView) row.findViewById(R.id.description);
TextView distanceLabel = (TextView) row.findViewById(R.id.distance);
TextView timeLabel = (TextView) row.findViewById(R.id.time);
TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
ImageView icon = (ImageView) row.findViewById(R.id.direction);
row.findViewById(R.id.divider).setVisibility(position == directionsInfo.size() - 1 ? View.INVISIBLE : View.VISIBLE);
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources(), true);
drawable.setColorFilter(new PorterDuffColorFilter(getActiveColor(), PorterDuff.Mode.SRC_ATOP));
drawable.setRouteType(model.getTurnType());
icon.setImageDrawable(drawable);
label.setText(model.getDescriptionRoutePart());
if (model.distance > 0) {
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(model.distance, app));
timeLabel.setText(getTimeDescription(app, model));
row.setContentDescription(label.getText() + " " + timeLabel.getText());
} else {
if (Algorithms.isEmpty(label.getText().toString())) {
label.setText(getString((position != directionsInfo.size() - 1) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
}
distanceLabel.setText("");
timeLabel.setText("");
row.setContentDescription("");
}
CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position, directionsInfo);
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance, app));
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, app.accessibilityEnabled()));
row.setOnClickListener(onClickListener);
return row;
}
public static CumulativeInfo getRouteDirectionCumulativeInfo(int position, List<RouteDirectionInfo> routeDirections) {
CumulativeInfo cumulativeInfo = new CumulativeInfo();
if (position >= routeDirections.size()) {

View file

@ -1,6 +1,5 @@
package net.osmand.plus.routepreparationmenu;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
@ -59,17 +58,13 @@ import java.util.ArrayList;
import java.util.List;
import static net.osmand.plus.helpers.WaypointDialogHelper.showOnMap;
import static net.osmand.plus.routepreparationmenu.ChooseRouteFragment.ROUTE_INFO_STATE_KEY;
public class WaypointsFragment extends BaseOsmAndFragment implements ObservableScrollViewCallbacks,
DynamicListViewCallbacks, WaypointDialogHelper.WaypointDialogHelperCallback {
public static final String TAG = "WaypointsFragment";
private OsmandApplication app;
private MapActivity mapActivity;
private WaypointDialogHelper waypointDialogHelper;
private View view;
private View mainView;
private DynamicListView listView;
@ -88,26 +83,24 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
private boolean nightMode;
private boolean wasDrawerDisabled;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
mapActivity = (MapActivity) getActivity();
}
private int routeInfoMenuState = -1;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
MapActivity mapActivity = (MapActivity) requireActivity();
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
waypointDialogHelper = mapActivity.getDashboard().getWaypointDialogHelper();
view = inflater.inflate(R.layout.route_waypoints_fragment, parent, false);
if (view == null) {
return null;
}
AndroidUtils.addStatusBarPadding21v(app, view);
AndroidUtils.addStatusBarPadding21v(mapActivity, view);
Bundle args = getArguments();
if (args != null) {
routeInfoMenuState = args.getInt(ROUTE_INFO_STATE_KEY, -1);
}
mainView = view.findViewById(R.id.main_view);
listView = (DynamicListView) view.findViewById(R.id.dash_list_view);
@ -147,9 +140,12 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
if (hasActivePoints) {
TargetOptionsBottomSheetDialogFragment fragment = new TargetOptionsBottomSheetDialogFragment();
fragment.setUsedOnMap(true);
fragment.show(mapActivity.getSupportFragmentManager(), TargetOptionsBottomSheetDialogFragment.TAG);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
TargetOptionsBottomSheetDialogFragment fragment = new TargetOptionsBottomSheetDialogFragment();
fragment.setUsedOnMap(true);
fragment.show(mapActivity.getSupportFragmentManager(), TargetOptionsBottomSheetDialogFragment.TAG);
}
}
}
});
@ -225,29 +221,34 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
@Override
public String getTitle() {
List<Object> activeObjects;
if ((mapActivity.getRoutingHelper().isRoutePlanningMode() || mapActivity.getRoutingHelper().isFollowingMode())
&& item != null
&& ((activeObjects = stableAdapter.getActiveObjects()).isEmpty() || isContainsOnlyStart(activeObjects))) {
return mapActivity.getResources().getString(R.string.cancel_navigation);
} else {
return null;
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
List<Object> activeObjects;
if ((mapActivity.getRoutingHelper().isRoutePlanningMode() || mapActivity.getRoutingHelper().isFollowingMode())
&& item != null
&& ((activeObjects = stableAdapter.getActiveObjects()).isEmpty() || isContainsOnlyStart(activeObjects))) {
return mapActivity.getResources().getString(R.string.cancel_navigation);
}
}
return null;
}
};
}
@Override
public void onHidePopup() {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
stableAdapter.refreshData();
applyPointsChanges();
updateTitle();
List<Object> activeObjects = stableAdapter.getActiveObjects();
if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) {
mapActivity.getMapActions().stopNavigationWithoutConfirm();
mapActivity.getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
mapActivity.getMapRouteInfoMenu().hide();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
stableAdapter.refreshData();
applyPointsChanges();
updateTitle();
List<Object> activeObjects = stableAdapter.getActiveObjects();
if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) {
mapActivity.getMapActions().stopNavigationWithoutConfirm();
mapActivity.getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
mapActivity.getMapRouteInfoMenu().hide();
}
}
}
@ -269,12 +270,15 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bundle args = new Bundle();
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, MapRouteInfoMenu.PointType.INTERMEDIATE.name());
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
fragment.setArguments(args);
fragment.setUsedOnMap(true);
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
Bundle args = new Bundle();
args.putString(AddPointBottomSheetDialog.POINT_TYPE_KEY, MapRouteInfoMenu.PointType.INTERMEDIATE.name());
AddPointBottomSheetDialog fragment = new AddPointBottomSheetDialog();
fragment.setArguments(args);
fragment.setUsedOnMap(true);
fragment.show(mapActivity.getSupportFragmentManager(), AddPointBottomSheetDialog.TAG);
}
}
});
@ -284,9 +288,12 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getTargetPointsHelper().clearAllPoints(true);
updateTitle();
reloadAdapter();
OsmandApplication app = getMyApplication();
if (app != null) {
app.getTargetPointsHelper().clearAllPoints(true);
updateTitle();
reloadAdapter();
}
}
});
@ -331,23 +338,33 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
@Override
public void onResume() {
super.onResume();
wasDrawerDisabled = mapActivity.isDrawerDisabled();
waypointDialogHelper.addHelperCallback(this);
app.getTargetPointsHelper().addListener(onStateChangedListener);
if (!wasDrawerDisabled) {
mapActivity.disableDrawer();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
MapRouteInfoMenu.waypointsVisible = true;
wasDrawerDisabled = mapActivity.isDrawerDisabled();
mapActivity.getDashboard().getWaypointDialogHelper().addHelperCallback(this);
mapActivity.getMyApplication().getTargetPointsHelper().addListener(onStateChangedListener);
if (!wasDrawerDisabled) {
mapActivity.disableDrawer();
}
updateRouteCalculationProgress(0);
updateControlsVisibility(false, false);
}
updateRouteCalculationProgress(0);
}
@Override
public void onPause() {
super.onPause();
cancelTimer();
waypointDialogHelper.removeHelperCallback(this);
app.getTargetPointsHelper().removeListener(onStateChangedListener);
if (!wasDrawerDisabled) {
mapActivity.enableDrawer();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
MapRouteInfoMenu.waypointsVisible = false;
mapActivity.getDashboard().getWaypointDialogHelper().removeHelperCallback(this);
mapActivity.getMyApplication().getTargetPointsHelper().removeListener(onStateChangedListener);
if (!wasDrawerDisabled) {
mapActivity.enableDrawer();
}
updateControlsVisibility(true, routeInfoMenuState != -1);
}
}
@ -395,20 +412,29 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
startTimer();
}
@Nullable
private MapActivity getMapActivity() {
return (MapActivity) getActivity();
}
public void applyDayNightMode() {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
boolean landscapeLayout = !portrait;
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
int colorActive = ContextCompat.getColor(mapActivity, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
if (!landscapeLayout) {
AndroidUtils.setBackground(app, mainView, nightMode, R.drawable.route_info_menu_bg_light, R.drawable.route_info_menu_bg_dark);
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.route_info_menu_bg_light, R.drawable.route_info_menu_bg_dark);
} else {
AndroidUtils.setBackground(app, mainView, nightMode, R.drawable.route_info_menu_bg_left_light, R.drawable.route_info_menu_bg_left_dark);
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.route_info_menu_bg_left_light, R.drawable.route_info_menu_bg_left_dark);
}
((TextView) view.findViewById(R.id.sort_button)).setTextColor(colorActive);
((TextView) view.findViewById(R.id.add_button_descr)).setTextColor(colorActive);
((TextView) view.findViewById(R.id.clear_all_button_descr)).setTextColor(colorActive);
((TextView) view.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(app, nightMode ? R.color.main_font_dark : R.color.main_font_light));
((TextView) view.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.main_font_dark : R.color.main_font_light));
FrameLayout addButton = view.findViewById(R.id.add_button);
TextView addButtonDescr = (TextView) view.findViewById(R.id.add_button_descr);
@ -416,10 +442,10 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
addButtonDescr.setText(R.string.shared_string_add);
addButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getPaintedContentIcon(R.drawable.ic_action_plus, colorActive), null, null, null);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, addButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, addButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(mapActivity, addButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(mapActivity, addButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, addButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
AndroidUtils.setBackground(mapActivity, addButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
FrameLayout clearButton = view.findViewById(R.id.clear_all_button);
@ -428,12 +454,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
clearButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getPaintedContentIcon(R.drawable.ic_action_clear_all, colorActive), null, null, null);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
AndroidUtils.setBackground(app, clearButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
AndroidUtils.setBackground(mapActivity, clearButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
AndroidUtils.setBackground(mapActivity, clearButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
} else {
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
AndroidUtils.setBackground(mapActivity, clearButtonDescr, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
}
AndroidUtils.setBackground(app, view.findViewById(R.id.cancel_button), nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
AndroidUtils.setBackground(mapActivity, view.findViewById(R.id.cancel_button), nightMode, R.color.card_and_list_background_light, R.color.card_and_list_background_dark);
AndroidUtils.setBackground(mapActivity, view.findViewById(R.id.controls_divider), nightMode, R.color.divider_light, R.color.divider_dark);
((TextView) view.findViewById(R.id.cancel_button_descr)).setTextColor(colorActive);
((TextView) view.findViewById(R.id.start_button_descr)).setText(getText(R.string.shared_string_apply));
@ -442,6 +469,11 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
public void reloadListAdapter(ArrayAdapter<Object> listAdapter) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
WaypointDialogHelper waypointDialogHelper = mapActivity.getDashboard().getWaypointDialogHelper();
mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(new ArrayList<LocationPointWrapper>());
listAdapter.setNotifyOnChange(false);
@ -461,7 +493,8 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
return new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
OsmandApplication app = getMyApplication();
if (app != null && listAdapter.getItem(item) instanceof LocationPointWrapper) {
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
if (ps != null) {
showOnMap(app, ctx, ps.getPoint(), false);
@ -476,6 +509,8 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
final WaypointDialogHelper waypointDialogHelper = ctx.getDashboard().getWaypointDialogHelper();
List<Object> points = waypointDialogHelper.getTargetPoints();
List<Object> activePoints = waypointDialogHelper.getActivePoints(points);
@ -489,7 +524,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
Object obj = getItem(position);
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper point = (LocationPointWrapper) obj;
v = updateWaypointItemView(edit, deletedPoints, app, ctx, waypointDialogHelper, v, point, this, nightMode, flat, position);
v = updateWaypointItemView(edit, deletedPoints, ctx, v, point, this, nightMode, flat, position);
}
return v;
}
@ -501,7 +536,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
if (w.type == WaypointHelper.TARGETS) {
final TargetPoint t = (TargetPoint) w.point;
if (t.getOriginalPointDescription() != null
&& t.getOriginalPointDescription().isSearchingAddress(mapActivity)) {
&& t.getOriginalPointDescription().isSearchingAddress(ctx)) {
GeocodingLookupService.AddressLookupRequest lookupRequest
= new GeocodingLookupService.AddressLookupRequest(t.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
@ -510,9 +545,8 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
//updateRouteInfoMenu(ctx);
}
}, null);
app.getGeocodingLookupService().lookupAddress(lookupRequest);
ctx.getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest);
}
}
}
}
@ -520,12 +554,32 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
return listAdapter;
}
public void updateControlsVisibility(boolean visible, boolean openingRouteInfo) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
int visibility = visible ? View.VISIBLE : View.GONE;
mapActivity.findViewById(R.id.map_center_info).setVisibility(visibility);
mapActivity.findViewById(R.id.map_left_widgets_panel).setVisibility(visibility);
if (!openingRouteInfo) {
mapActivity.findViewById(R.id.map_right_widgets_panel).setVisibility(visibility);
if (!portrait) {
mapActivity.getMapView().setMapPositionX(visible ? 0 : 1);
}
}
mapActivity.refreshMap();
}
}
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
reloadAdapter();
showToast.value = false;
}
public void updateRouteCalculationProgress(int progress) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
ProgressBar progressBarButton = (ProgressBar) view.findViewById(R.id.progress_bar_button);
if (progressBarButton != null) {
if (progressBarButton.getVisibility() != View.VISIBLE) {
@ -542,10 +596,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
public void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb) {
int bgColor = ContextCompat.getColor(app, nightMode ? R.color.activity_background_dark : R.color.activity_background_light);
int progressColor = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
OsmandApplication app = getMyApplication();
if (app != null) {
int bgColor = ContextCompat.getColor(app, nightMode ? R.color.activity_background_dark : R.color.activity_background_light);
int progressColor = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
}
}
private void setDynamicListItems(DynamicListView listView, StableArrayAdapter listAdapter) {
@ -554,6 +611,10 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private void updateListAdapter() {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
List<LocationPointWrapper> deletedPoints = new ArrayList<>();
listView.setEmptyView(null);
StableArrayAdapter listAdapter = getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, false, nightMode);
@ -588,7 +649,8 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private void updateTitle() {
if (isAdded()) {
OsmandApplication app = getMyApplication();
if (app != null && isAdded()) {
final TextViewEx title = (TextViewEx) view.findViewById(R.id.title);
int pointsSize = app.getTargetPointsHelper().getAllPoints().size();
String text = getString(R.string.shared_string_target_points) + " (" + (pointsSize != 0 ? pointsSize : 1) + ")";
@ -597,6 +659,10 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private void applyPointsChanges() {
OsmandApplication app = getMyApplication();
if (app == null) {
return;
}
app.runInUIThread(new Runnable() {
@Override
public void run() {
@ -672,16 +738,17 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
final OsmandApplication app, final Activity ctx,
final WaypointDialogHelper helper, View v,
final MapActivity mapActivity, View v,
final LocationPointWrapper point,
final ArrayAdapter adapter, final boolean nightMode,
final boolean flat, final int position) {
final OsmandApplication app = mapActivity.getMyApplication();
final WaypointDialogHelper helper = mapActivity.getDashboard().getWaypointDialogHelper();
if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.route_waypoint_item, null);
v = mapActivity.getLayoutInflater().inflate(R.layout.route_waypoint_item, null);
}
v.setBackgroundColor(ContextCompat.getColor(app, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light));
updatePointInfoView(app, ctx, v, point, true, nightMode, edit, false);
v.setBackgroundColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.card_and_list_background_dark : R.color.card_and_list_background_light));
updatePointInfoView(mapActivity, v, point, true, nightMode, edit, false);
final ImageView move = (ImageView) v.findViewById(R.id.info_move);
final ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
@ -708,11 +775,11 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
public void onClick(View v) {
if (targetPointsHelper.getPointToStart() == null) {
if (!targetPointsHelper.getIntermediatePoints().isEmpty()) {
WaypointDialogHelper.replaceStartWithFirstIntermediate(targetPointsHelper, ctx, helper);
WaypointDialogHelper.replaceStartWithFirstIntermediate(targetPointsHelper, mapActivity, helper);
}
} else {
targetPointsHelper.setStartPoint(null, true, null);
WaypointDialogHelper.updateControls(ctx, helper);
WaypointDialogHelper.updateControls(mapActivity, helper);
}
}
});
@ -720,13 +787,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WaypointDialogHelper.deletePoint(app, ctx, adapter, helper, point, deletedPoints, true);
WaypointDialogHelper.deletePoint(app, mapActivity, adapter, helper, point, deletedPoints, true);
}
});
}
}
AndroidUtils.setBackground(ctx, topDivider, nightMode, R.color.divider_light, R.color.divider_dark);
AndroidUtils.setBackground(mapActivity, topDivider, nightMode, R.color.divider_light, R.color.divider_dark);
topDivider.setVisibility(position != 0 ? View.VISIBLE : View.GONE);
move.setVisibility(notFlatTargets ? View.VISIBLE : View.GONE);
@ -744,36 +811,35 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
return v;
}
private static void updatePointInfoView(final OsmandApplication app, final Activity activity,
private static void updatePointInfoView(final MapActivity mapActivity,
View localView, final LocationPointWrapper ps,
final boolean mapCenter, final boolean nightMode,
final boolean edit, final boolean topBar) {
WaypointHelper wh = app.getWaypointHelper();
final OsmandApplication app = mapActivity.getMyApplication();
WaypointHelper wh = mapActivity.getMyApplication().getWaypointHelper();
final LocationPoint point = ps.getPoint();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
if (!topBar) {
text.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.main_font_dark : R.color.main_font_light));
text.setTextColor(ContextCompat.getColor(mapActivity, nightMode ? R.color.main_font_dark : R.color.main_font_light));
}
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
if (!edit) {
localView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showOnMap(app, activity, point, mapCenter);
showOnMap(app, mapActivity, point, mapCenter);
}
});
}
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
textDist.setTextColor(ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(activity, app, nightMode));
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(mapActivity, app, nightMode));
int dist = -1;
boolean startPoint = ps.type == WaypointHelper.TARGETS && ((TargetPoint) ps.point).start;
if (!startPoint) {
if (!wh.isRouteCalculated()) {
if (activity instanceof MapActivity) {
dist = (int) MapUtils.getDistance(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity)
.getMapView().getLongitude(), point.getLatitude(), point.getLongitude());
}
dist = (int) MapUtils.getDistance(mapActivity.getMapView().getLatitude(), mapActivity.getMapView().getLongitude(),
point.getLatitude(), point.getLongitude());
} else {
dist = wh.getRouteDistance(ps);
}
@ -831,15 +897,15 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
case WaypointHelper.TARGETS:
TargetPoint targetPoint = (TargetPoint) ps.point;
if (targetPoint.start) {
pointDescription = activity.getResources().getString(R.string.starting_point);
pointDescription = mapActivity.getResources().getString(R.string.starting_point);
} else {
pointDescription = getPointDescription(activity, targetPoint).getTypeName();
pointDescription = getPointDescription(mapActivity, targetPoint).getTypeName();
}
break;
case WaypointHelper.FAVORITES:
FavouritePoint favPoint = (FavouritePoint) ps.point;
pointDescription = Algorithms.isEmpty(favPoint.getCategory()) ? activity.getResources().getString(R.string.shared_string_favorites) : favPoint.getCategory();
pointDescription = Algorithms.isEmpty(favPoint.getCategory()) ? mapActivity.getResources().getString(R.string.shared_string_favorites) : favPoint.getCategory();
break;
}
}
@ -864,15 +930,20 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
}
public static boolean showInstance(final MapActivity mapActivity) {
try {
mapActivity.getContextMenu().hideMenues();
public static boolean showInstance(FragmentManager fragmentManager) {
return WaypointsFragment.showInstance(fragmentManager, -1);
}
public static boolean showInstance(FragmentManager fragmentManager, int routeInfoState) {
try {
WaypointsFragment fragment = new WaypointsFragment();
mapActivity.getSupportFragmentManager()
.beginTransaction()
Bundle args = new Bundle();
args.putInt(ROUTE_INFO_STATE_KEY, routeInfoState);
fragment.setArguments(args);
fragmentManager.beginTransaction()
.add(R.id.routeMenuContainer, fragment, TAG)
.addToBackStack(TAG)
.commitAllowingStateLoss();
return true;
@ -883,14 +954,16 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
}
private void dismiss() {
FragmentActivity activity = getActivity();
if (activity != null) {
try {
activity.getSupportFragmentManager().popBackStack(TAG,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
} catch (Exception e) {
//
try {
MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) {
mapActivity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
if (routeInfoMenuState != -1) {
mapActivity.getMapLayers().getMapControlsLayer().showRouteInfoControlDialog(routeInfoMenuState);
}
}
} catch (Exception e) {
//
}
}
}

View file

@ -0,0 +1,105 @@
package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.support.annotation.NonNull;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routepreparationmenu.RouteDetailsFragment;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.views.TurnPathHelper;
import net.osmand.util.Algorithms;
import java.util.List;
public class RouteDirectionsCard extends BaseCard {
public RouteDirectionsCard(@NonNull MapActivity mapActivity) {
super(mapActivity);
}
@Override
public int getCardLayoutId() {
return R.layout.route_directions_card;
}
@Override
protected void updateContent() {
LinearLayout root = (LinearLayout) view.findViewById(R.id.items);
root.removeAllViews();
createRouteDirections(root);
}
private void createRouteDirections(LinearLayout cardsContainer) {
List<RouteDirectionInfo> routeDirections = app.getRoutingHelper().getRouteDirections();
for (int i = 0; i < routeDirections.size(); i++) {
RouteDirectionInfo routeDirectionInfo = routeDirections.get(i);
View view = getRouteDirectionView(i, routeDirectionInfo, routeDirections);
cardsContainer.addView(view);
}
}
private static String getTimeDescription(OsmandApplication app, RouteDirectionInfo model) {
final int timeInSeconds = model.getExpectedTime();
return Algorithms.formatDuration(timeInSeconds, app.accessibilityEnabled());
}
private View getRouteDirectionView(final int directionInfoIndex, RouteDirectionInfo model, List<RouteDirectionInfo> directionsInfo) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return null;
}
OsmandApplication app = mapActivity.getMyApplication();
ContextThemeWrapper context = new ContextThemeWrapper(mapActivity, nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme);
View row = LayoutInflater.from(context).inflate(R.layout.route_info_list_item, null);
TextView label = (TextView) row.findViewById(R.id.description);
TextView distanceLabel = (TextView) row.findViewById(R.id.distance);
TextView timeLabel = (TextView) row.findViewById(R.id.time);
TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
ImageView icon = (ImageView) row.findViewById(R.id.direction);
row.findViewById(R.id.divider).setVisibility(directionInfoIndex == directionsInfo.size() - 1 ? View.INVISIBLE : View.VISIBLE);
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(mapActivity.getResources(), true);
drawable.setColorFilter(new PorterDuffColorFilter(getActiveColor(), PorterDuff.Mode.SRC_ATOP));
drawable.setRouteType(model.getTurnType());
icon.setImageDrawable(drawable);
label.setText(model.getDescriptionRoutePart());
if (model.distance > 0) {
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(model.distance, app));
timeLabel.setText(getTimeDescription(app, model));
row.setContentDescription(label.getText() + " " + timeLabel.getText());
} else {
if (Algorithms.isEmpty(label.getText().toString())) {
label.setText(mapActivity.getString((directionInfoIndex != directionsInfo.size() - 1) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
}
distanceLabel.setText("");
timeLabel.setText("");
row.setContentDescription("");
}
RouteDetailsFragment.CumulativeInfo cumulativeInfo = RouteDetailsFragment.getRouteDirectionCumulativeInfo(directionInfoIndex, directionsInfo);
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance, app));
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, app.accessibilityEnabled()));
row.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CardListener listener = getListener();
if (listener != null) {
listener.onCardButtonPressed(RouteDirectionsCard.this, directionInfoIndex);
}
}
});
return row;
}
}

View file

@ -100,40 +100,49 @@ public class RouteStatisticCard extends BaseCard {
String arriveStr = app.getString(R.string.arrive_at_time, OsmAndFormatter.getFormattedTime(time, true));
arriveTimeTv.setText(arriveStr);
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
buildHeader(analysis);
((TextView) view.findViewById(R.id.average_text)).setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
((TextView) view.findViewById(R.id.range_text)).setText(min + " - " + max);
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
((ImageView) view.findViewById(R.id.average_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.range_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.descent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_descent));
((ImageView) view.findViewById(R.id.ascent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_ascent));
buildSlopeInfo();
if (isTransparentBackground()) {
view.setBackgroundDrawable(null);
}
}
FrameLayout analyseButton = (FrameLayout) view.findViewById(R.id.analyse_button);
TextView analyseButtonDescr = (TextView) view.findViewById(R.id.analyse_button_descr);
private void buildSlopeInfo() {
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
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);
buildHeader(analysis);
if (analysis.hasElevationData) {
((TextView) view.findViewById(R.id.average_text)).setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
((TextView) view.findViewById(R.id.range_text)).setText(min + " - " + max);
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
((ImageView) view.findViewById(R.id.average_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.range_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_average));
((ImageView) view.findViewById(R.id.descent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_descent));
((ImageView) view.findViewById(R.id.ascent_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_altitude_ascent));
TextView analyseButtonDescr = (TextView) view.findViewById(R.id.analyse_button_descr);
FrameLayout analyseButton = (FrameLayout) view.findViewById(R.id.analyse_button);
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);
}
analyseButton.setOnClickListener(onAnalyseClickListener);
view.findViewById(R.id.altitude_container).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
view.findViewById(R.id.slope_info_divider).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
view.findViewById(R.id.slope_container).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
view.findViewById(R.id.buttons_container).setVisibility(analysis.hasElevationData ? View.VISIBLE : View.GONE);
}
@Nullable

View file

@ -815,7 +815,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
public boolean disableSingleTap() {
if (activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.chooseRoutesVisible) {
if (activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
return true;
}
boolean res = false;
@ -832,7 +832,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
public boolean disableLongPressOnMap() {
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode ||
activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.chooseRoutesVisible) {
activity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
return true;
}
boolean res = false;

View file

@ -753,7 +753,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean routeDialogOpened = mapRouteInfoMenu.isVisible() || (showRouteCalculationControls && mapRouteInfoMenu.needShowMenu());
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode();
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode();
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
@ -768,10 +768,11 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningBtn.updateVisibility(showButtons);
menuControl.updateVisibility(showButtons);
mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened && (!isInChoosingRoutesMode() || !portrait));
mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened && (!isInChoosingRoutesMode() || !portrait));
mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
boolean forceHideCompass = routeDialogOpened || trackDialogOpened
|| isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode();
|| isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened || isInChoosingRoutesMode() || isInWaypointsChoosingMode();
compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
@ -779,9 +780,9 @@ public class MapControlsLayer extends OsmandMapLayer {
layersHud.update(app, isNight);
}
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
&& !contextMenuOpened && !isInChoosingRoutesMode());
&& !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode());
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
&& !contextMenuOpened && !isInChoosingRoutesMode());
&& !contextMenuOpened && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode());
if (!routePlanningMode && !routeFollowingMode) {
if (mapView.isZooming()) {
@ -862,7 +863,7 @@ public class MapControlsLayer extends OsmandMapLayer {
backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
}
boolean visible = !(tracked && rh.isFollowingMode());
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() && (!isInChoosingRoutesMode() || !portrait));
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() && (!isInChoosingRoutesMode() || !isInWaypointsChoosingMode() || !portrait));
if (app.accessibilityEnabled()) {
backToLocationControl.iv.setClickable(enabled && visible);
}
@ -1177,6 +1178,10 @@ public class MapControlsLayer extends OsmandMapLayer {
return MapRouteInfoMenu.chooseRoutesVisible;
}
private boolean isInWaypointsChoosingMode() {
return MapRouteInfoMenu.waypointsVisible;
}
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
return new View.OnLongClickListener() {

View file

@ -401,6 +401,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
mapMarkersLayer.isInPlanRouteMode() ||
mapRouteInfoMenu.isVisible() ||
MapRouteInfoMenu.chooseRoutesVisible ||
MapRouteInfoMenu.waypointsVisible ||
contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() ||
contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() ||
multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() ||

View file

@ -937,7 +937,7 @@ public class MapInfoWidgetsFactory {
}
}
}
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible) {
if (map.isTopToolbarActive() || !map.getContextMenu().shouldShowTopControls() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible) {
updateVisibility(false);
} else if (!showNextTurn && updateWaypoint()) {
updateVisibility(true);
@ -1003,7 +1003,8 @@ public class MapInfoWidgetsFactory {
all.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
WaypointsFragment.showInstance(map);
map.hideContextAndRouteInfoMenues();
WaypointsFragment.showInstance(map.getSupportFragmentManager());
}
});
remove.setOnClickListener(new OnClickListener() {

View file

@ -831,7 +831,7 @@ public class RouteInfoWidgetsFactory {
}
}
}
visible = loclanes != null && loclanes.length > 0 && !MapRouteInfoMenu.chooseRoutesVisible;
visible = loclanes != null && loclanes.length > 0 && !MapRouteInfoMenu.chooseRoutesVisible && !MapRouteInfoMenu.waypointsVisible;
if (visible) {
if (!Arrays.equals(lanesDrawable.lanes, loclanes) ||
(locimminent == 0) != lanesDrawable.imminent) {