Merge pull request #9852 from osmandapp/master

update test branch
This commit is contained in:
Hardy 2020-09-18 22:20:15 +02:00 committed by GitHub
commit 882dc57eed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 249 additions and 109 deletions

View file

@ -549,10 +549,12 @@ public class RoutePlannerFrontEnd {
if (start != null && start.pnt == null) { if (start != null && start.pnt == null) {
gctx.routePointsSearched++; gctx.routePointsSearched++;
RouteSegmentPoint rsp = findRouteSegment(start.loc.getLatitude(), start.loc.getLongitude(), gctx.ctx, null, false); RouteSegmentPoint rsp = findRouteSegment(start.loc.getLatitude(), start.loc.getLongitude(), gctx.ctx, null, false);
if (rsp != null) {
if (MapUtils.getDistance(rsp.getPreciseLatLon(), start.loc) < distThreshold) { if (MapUtils.getDistance(rsp.getPreciseLatLon(), start.loc) < distThreshold) {
start.pnt = rsp; start.pnt = rsp;
} }
} }
}
if (start != null && start.pnt != null) { if (start != null && start.pnt != null) {
return true; return true;
} }

View file

@ -328,7 +328,7 @@ public class RouteSegmentResult implements StringExternalizable<RouteDataBundle>
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Location location = resources.getLocation(index); Location location = resources.getLocation(index);
if (location == null) { if (location == null) {
break; continue;
} }
double dist = 0; double dist = 0;
if (prevLocation != null) { if (prevLocation != null) {

View file

@ -18,7 +18,7 @@
android:id="@+id/route_menu_top_shadow_all" android:id="@+id/route_menu_top_shadow_all"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic" android:background="?attr/bg_color"
android:minHeight="@dimen/bottom_sheet_title_height" android:minHeight="@dimen/bottom_sheet_title_height"
android:orientation="vertical"> android:orientation="vertical">

View file

@ -4,7 +4,7 @@
android:id="@+id/import_track_card" android:id="@+id/import_track_card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic" android:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx

View file

@ -3,6 +3,7 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical" android:orientation="vertical"
android:background="?attr/bg_color"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">

View file

@ -18,7 +18,7 @@
android:id="@+id/route_menu_top_shadow_all" android:id="@+id/route_menu_top_shadow_all"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/card_and_list_background_basic" android:background="?attr/bg_color"
android:minHeight="@dimen/bottom_sheet_title_height" android:minHeight="@dimen/bottom_sheet_title_height"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"

View file

@ -551,11 +551,11 @@
<item name="android:windowAnimationStyle">@null</item> <item name="android:windowAnimationStyle">@null</item>
</style> </style>
<style name="DialogButtonStyleLight" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog"> <style name="DialogButtonStyleLight" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/active_color_primary_light</item> <item name="android:textColor">@color/active_color_primary_light</item>
</style> </style>
<style name="DialogButtonStyleDark" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog"> <style name="DialogButtonStyleDark" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/active_color_primary_dark</item> <item name="android:textColor">@color/active_color_primary_dark</item>
</style> </style>

View file

@ -47,10 +47,12 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.InterceptorLinearLayout; import net.osmand.plus.mapcontextmenu.InterceptorLinearLayout;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm; import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm; import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.plus.views.layers.MapControlsLayer;
import static net.osmand.plus.mapcontextmenu.MapContextMenuFragment.CURRENT_Y_UNDEFINED; import static net.osmand.plus.mapcontextmenu.MapContextMenuFragment.CURRENT_Y_UNDEFINED;
public abstract class ContextMenuFragment extends BaseOsmAndFragment { public abstract class ContextMenuFragment extends BaseOsmAndFragment
implements MapControlsLayer.MapControlsThemeInfoProvider {
public static class MenuState { public static class MenuState {
public static final int HEADER_ONLY = 1; public static final int HEADER_ONLY = 1;
@ -174,10 +176,19 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
return topView; return topView;
} }
@Override
public boolean isNightModeForMapControls() {
return nightMode;
}
public boolean isNightMode() { public boolean isNightMode() {
return nightMode; return nightMode;
} }
protected String getThemeInfoProviderTag() {
return null;
}
public void updateNightMode() { public void updateNightMode() {
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
@ -597,6 +608,10 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
if (!wasDrawerDisabled) { if (!wasDrawerDisabled) {
mapActivity.disableDrawer(); mapActivity.disableDrawer();
} }
String tag = getThemeInfoProviderTag();
if (tag != null) {
mapActivity.getMapLayers().getMapControlsLayer().addThemeInfoProviderTag(tag);
}
} }
} }
@ -611,9 +626,15 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
} }
} }
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (!wasDrawerDisabled && mapActivity != null) { if (mapActivity != null) {
if (!wasDrawerDisabled) {
mapActivity.enableDrawer(); mapActivity.enableDrawer();
} }
String tag = getThemeInfoProviderTag();
if (tag != null) {
mapActivity.getMapLayers().getMapControlsLayer().removeThemeInfoProviderTag(tag);
}
}
} }
public int getViewY() { public int getViewY() {

View file

@ -3,7 +3,9 @@ package net.osmand.plus.base;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
@ -207,12 +209,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
// 8dp is the shadow height // 8dp is the shadow height
boolean showTopShadow = screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8); boolean showTopShadow = screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(activity, 8);
if (AndroidUiHelper.isOrientationPortrait(activity)) { if (AndroidUiHelper.isOrientationPortrait(activity)) {
mainView.setBackgroundResource(showTopShadow ? getPortraitBgResId() : getBgColorId()); AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity));
if (!showTopShadow) { if (!showTopShadow) {
mainView.setPadding(0, 0, 0, 0); mainView.setPadding(0, 0, 0, 0);
} }
} else { } else {
mainView.setBackgroundResource(showTopShadow ? getLandscapeTopsidesBgResId() : getLandscapeSidesBgResId()); AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity));
} }
} }
}); });
@ -304,19 +306,27 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light; return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light;
} }
@DrawableRes protected Drawable getColoredBg(@NonNull Context ctx) {
protected int getPortraitBgResId() { int bgColor = ContextCompat.getColor(ctx, getBgColorId());
return nightMode ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_menu_light; return new ColorDrawable(bgColor);
} }
@DrawableRes protected Drawable getPortraitBg(@NonNull Context ctx) {
protected int getLandscapeTopsidesBgResId() { return createBackgroundDrawable(ctx, R.drawable.bg_contextmenu_shadow_top_light);
return nightMode ? R.drawable.bg_bottom_sheet_topsides_landscape_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
} }
@DrawableRes protected Drawable getLandscapeTopsidesBg(@NonNull Context ctx) {
protected int getLandscapeSidesBgResId() { return createBackgroundDrawable(ctx, R.drawable.bg_shadow_bottomsheet_topsides);
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light; }
protected Drawable getLandscapeSidesBg(@NonNull Context ctx) {
return createBackgroundDrawable(ctx, R.drawable.bg_shadow_bottomsheet_sides);
}
private LayerDrawable createBackgroundDrawable(@NonNull Context ctx, @DrawableRes int shadowDrawableResId) {
Drawable shadowDrawable = ContextCompat.getDrawable(ctx, shadowDrawableResId);
Drawable[] layers = new Drawable[]{shadowDrawable, getColoredBg(ctx)};
return new LayerDrawable(layers);
} }
protected boolean isNightMode(@NonNull OsmandApplication app) { protected boolean isNightMode(@NonNull OsmandApplication app) {

View file

@ -140,26 +140,6 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
return getIcon(id, nightMode ? R.color.ctx_menu_direction_color_dark : R.color.map_widget_blue); return getIcon(id, nightMode ? R.color.ctx_menu_direction_color_dark : R.color.map_widget_blue);
} }
@Override
protected int getBgColorId() {
return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light;
}
@Override
protected int getPortraitBgResId() {
return nightMode ? R.drawable.bg_additional_menu_dark : R.drawable.bg_bottom_menu_light;
}
@Override
protected int getLandscapeTopsidesBgResId() {
return nightMode ? R.drawable.bg_additional_menu_topsides_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
}
@Override
protected int getLandscapeSidesBgResId() {
return nightMode ? R.drawable.bg_additional_menu_sides_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
}
private Drawable getBackgroundIcon(@DrawableRes int resId) { private Drawable getBackgroundIcon(@DrawableRes int resId) {
return getIcon(resId, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light); return getIcon(resId, nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light);
} }

View file

@ -34,14 +34,17 @@ public class GpxTrackAdapter extends RecyclerView.Adapter<GpxTrackAdapter.TrackV
private LayoutInflater themedInflater; private LayoutInflater themedInflater;
private UiUtilities iconsCache; private UiUtilities iconsCache;
private List<GPXInfo> gpxInfoList; private List<GPXInfo> gpxInfoList;
private boolean showCurrentGpx;
private OnItemClickListener onItemClickListener; private OnItemClickListener onItemClickListener;
public GpxTrackAdapter(Context ctx, List<GPXInfo> gpxInfoList, boolean showCurrentGpx) { private boolean showFolderName;
private boolean showCurrentGpx;
public GpxTrackAdapter(Context ctx, List<GPXInfo> gpxInfoList, boolean showCurrentGpx, boolean showFolderName) {
app = (OsmandApplication) ctx.getApplicationContext(); app = (OsmandApplication) ctx.getApplicationContext();
themedInflater = UiUtilities.getInflater(ctx, app.getDaynightHelper().isNightModeForMapControls()); themedInflater = UiUtilities.getInflater(ctx, app.getDaynightHelper().isNightModeForMapControls());
iconsCache = app.getUIUtilities(); iconsCache = app.getUIUtilities();
this.gpxInfoList = gpxInfoList; this.gpxInfoList = gpxInfoList;
this.showFolderName = showFolderName;
this.showCurrentGpx = showCurrentGpx; this.showCurrentGpx = showCurrentGpx;
} }
@ -57,6 +60,10 @@ public class GpxTrackAdapter extends RecyclerView.Adapter<GpxTrackAdapter.TrackV
this.showCurrentGpx = showCurrentGpx; this.showCurrentGpx = showCurrentGpx;
} }
public void setShowFolderName(boolean showFolderName) {
this.showFolderName = showFolderName;
}
@NonNull @NonNull
@Override @Override
public GpxTrackAdapter.TrackViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public GpxTrackAdapter.TrackViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@ -82,6 +89,9 @@ public class GpxTrackAdapter extends RecyclerView.Adapter<GpxTrackAdapter.TrackV
GPXInfo info = gpxInfoList.get(adapterPosition); GPXInfo info = gpxInfoList.get(adapterPosition);
GpxDataItem dataItem = getDataItem(info); GpxDataItem dataItem = getDataItem(info);
String itemTitle = GpxUiHelper.getGpxTitle(info.getFileName()); String itemTitle = GpxUiHelper.getGpxTitle(info.getFileName());
if (!showFolderName) {
itemTitle = Algorithms.getFileWithoutDirs(itemTitle);
}
updateGpxInfoView(holder, itemTitle, info, dataItem, currentlyRecordingTrack, app); updateGpxInfoView(holder, itemTitle, info, dataItem, currentlyRecordingTrack, app);
holder.itemView.setOnClickListener(new View.OnClickListener() { holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -52,7 +52,7 @@ public class SelectGpxTrackBottomSheet extends MenuBottomSheetDialogFragment {
final RecyclerView recyclerView = mainView.findViewById(R.id.gpx_track_list); final RecyclerView recyclerView = mainView.findViewById(R.id.gpx_track_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
adapter = new GpxTrackAdapter(requireContext(), gpxInfoList, showCurrentGpx); adapter = new GpxTrackAdapter(requireContext(), gpxInfoList, showCurrentGpx, true);
adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() { adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() {
@Override @Override
public void onItemClick(int position) { public void onItemClick(int position) {

View file

@ -231,9 +231,11 @@ public class TransportStopController extends MenuController {
stopAggregated = new TransportStopAggregated(); stopAggregated = new TransportStopAggregated();
stopAggregated.setAmenity(amenity); stopAggregated.setAmenity(amenity);
TransportStop nearestStop = null; TransportStop nearestStop = null;
String amenityName = amenity.getName().toLowerCase();
for (TransportStop stop : transportStops) { for (TransportStop stop : transportStops) {
stop.setTransportStopAggregated(stopAggregated); stop.setTransportStopAggregated(stopAggregated);
if ((stop.getName().startsWith(amenity.getName()) String stopName = stop.getName().toLowerCase();
if (((stopName.contains(amenityName) || amenityName.contains(stopName))
&& (nearestStop == null && (nearestStop == null
|| nearestStop.getLocation().equals(stop.getLocation()))) || nearestStop.getLocation().equals(stop.getLocation())))
|| stop.getLocation().equals(loc)) { || stop.getLocation().equals(loc)) {

View file

@ -233,16 +233,16 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
} else { } else {
topShadow.setVisibility(View.VISIBLE); topShadow.setVisibility(View.VISIBLE);
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(),
R.color.card_and_list_background_light, R.color.card_and_list_background_dark); R.color.list_background_color_light, R.color.list_background_color_dark);
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(),
R.color.card_and_list_background_light, R.color.card_and_list_background_dark); R.color.list_background_color_light, R.color.list_background_color_dark);
} }
} }
} }
private void updateButtons(View view) { private void updateButtons(View view) {
View buttonsContainer = view.findViewById(R.id.buttons_container); View buttonsContainer = view.findViewById(R.id.buttons_container);
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg)); buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.bg_color));
applyButton.setOnClickListener(new View.OnClickListener() { applyButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -415,6 +415,11 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
} }
} }
@Override
protected String getThemeInfoProviderTag() {
return TAG;
}
public interface GpxApproximationFragmentListener { public interface GpxApproximationFragmentListener {
void onGpxApproximationDone(GpxRouteApproximation gpxApproximation, ApplicationMode mode); void onGpxApproximationDone(GpxRouteApproximation gpxApproximation, ApplicationMode mode);

View file

@ -537,22 +537,20 @@ public class MeasurementEditingContext {
List<RouteSegmentResult> segments = new ArrayList<>(); List<RouteSegmentResult> segments = new ArrayList<>();
for (RouteSegmentResult seg : rp1.routeToTarget) { for (RouteSegmentResult seg : rp1.routeToTarget) {
segments.add(seg); segments.add(seg);
if (seg.isForwardDirection()) { int ind = seg.getStartPointIndex();
for (int ik = seg.getStartPointIndex(); ik <= seg.getEndPointIndex(); ik++) { boolean plus = seg.isForwardDirection();
LatLon l = seg.getPoint(ik); float[] pf = seg.getObject().calculateHeightArray();
while (ind != seg.getEndPointIndex()) {
LatLon l = seg.getPoint(ind);
WptPt pt = new WptPt(); WptPt pt = new WptPt();
if (pf != null && pf.length > ind * 2 + 1) {
pt.ele = pf[ind * 2 + 1];
}
pt.lat = l.getLatitude(); pt.lat = l.getLatitude();
pt.lon = l.getLongitude(); pt.lon = l.getLongitude();
points.add(pt); points.add(pt);
} ind = plus ? ind + 1 : ind - 1;
} else {
for (int ik = seg.getEndPointIndex(); ik >= seg.getStartPointIndex(); ik--) {
LatLon l = seg.getPoint(ik);
WptPt pt = new WptPt();
pt.lat = l.getLatitude();
pt.lon = l.getLongitude();
points.add(pt);
}
} }
} }
roadSegmentData.put(pair, new RoadSegmentData(appMode, pair.first, pair.second, points, segments)); roadSegmentData.put(pair, new RoadSegmentData(appMode, pair.first, pair.second, points, segments));

View file

@ -78,6 +78,7 @@ import net.osmand.plus.measurementtool.command.ReversePointsCommand;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback; import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
import net.osmand.plus.views.layers.MapControlsLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
@ -107,7 +108,7 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo
public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener,
OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener,
SaveAsNewTrackFragmentListener { SaveAsNewTrackFragmentListener, MapControlsLayer.MapControlsThemeInfoProvider {
public static final String TAG = MeasurementToolFragment.class.getSimpleName(); public static final String TAG = MeasurementToolFragment.class.getSimpleName();
public static final String TAPS_DISABLED_KEY = "taps_disabled_key"; public static final String TAPS_DISABLED_KEY = "taps_disabled_key";
@ -137,6 +138,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private boolean pointsListOpened; private boolean pointsListOpened;
private boolean planRouteMode = false; private boolean planRouteMode = false;
private boolean directionMode = false; private boolean directionMode = false;
private boolean approximationApplied = false;
private boolean portrait; private boolean portrait;
private boolean nightMode; private boolean nightMode;
private int cachedMapPosition; private int cachedMapPosition;
@ -317,9 +319,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
mainView.findViewById(R.id.options_button).setOnClickListener(new OnClickListener() { mainView.findViewById(R.id.options_button).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
boolean trackSnappedToRoad = editingCtx.isTrackSnappedToRoad() || editingCtx.isNewData() || approximationApplied;
OptionsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(), OptionsBottomSheetDialogFragment.showInstance(mapActivity.getSupportFragmentManager(),
MeasurementToolFragment.this, MeasurementToolFragment.this,
editingCtx.isTrackSnappedToRoad() || editingCtx.isNewData(), trackSnappedToRoad,
editingCtx.getAppMode().getStringKey() editingCtx.getAppMode().getStringKey()
); );
} }
@ -529,6 +532,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
super.onResume(); super.onResume();
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMapLayers().getMapControlsLayer().addThemeInfoProviderTag(TAG);
mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden(); mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
cachedMapPosition = mapActivity.getMapView().getMapPosition(); cachedMapPosition = mapActivity.getMapView().getMapPosition();
setDefaultMapPosition(); setDefaultMapPosition();
@ -539,6 +543,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.getMapLayers().getMapControlsLayer().removeThemeInfoProviderTag(TAG);
}
setMapPosition(cachedMapPosition); setMapPosition(cachedMapPosition);
} }
@ -1119,7 +1127,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
final ApplicationMode appMode = editingCtx.getAppMode(); final ApplicationMode appMode = editingCtx.getAppMode();
if (mapActivity != null) { if (mapActivity != null) {
Drawable icon; Drawable icon;
if (editingCtx.isTrackSnappedToRoad() || editingCtx.isNewData()) { if (editingCtx.isTrackSnappedToRoad() || editingCtx.isNewData() || approximationApplied) {
if (appMode == MeasurementEditingContext.DEFAULT_APP_MODE) { if (appMode == MeasurementEditingContext.DEFAULT_APP_MODE) {
icon = getActiveIcon(R.drawable.ic_action_split_interval); icon = getActiveIcon(R.drawable.ic_action_split_interval);
} else { } else {
@ -1954,12 +1962,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
setupDoneButton(view); setupDoneButton(view);
View shadow = view.getShadowView(); View shadow = view.getShadowView();
if (shadow != null) { if (shadow != null) {
shadow.setVisibility(View.GONE); AndroidUiHelper.updateVisibility(shadow, false);
} }
} }
private void setupDoneButton(TopToolbarView view) { private void setupDoneButton(TopToolbarView view) {
TextView done = view.getSaveView(); TextView done = view.getSaveView();
AndroidUiHelper.updateVisibility(done, isVisible());
Context ctx = done.getContext(); Context ctx = done.getContext();
done.setAllCaps(false); done.setAllCaps(false);
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) done.getLayoutParams(); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) done.getLayoutParams();
@ -1996,8 +2006,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onApplyGpxApproximation() { public void onApplyGpxApproximation() {
approximationApplied = true;
exitApproximationMode(); exitApproximationMode();
doAddOrMovePointCommonStuff(); doAddOrMovePointCommonStuff();
updateSnapToRoadControls();
if (directionMode) { if (directionMode) {
directionMode = false; directionMode = false;
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
@ -2052,4 +2064,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
AndroidUiHelper.setVisibility(mapActivity, View.VISIBLE, R.id.map_ruler_container); AndroidUiHelper.setVisibility(mapActivity, View.VISIBLE, R.id.map_ruler_container);
} }
} }
public boolean isNightModeForMapControls() {
return nightMode;
}
} }

View file

@ -182,13 +182,6 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
if (inMeasurementMode) { if (inMeasurementMode) {
lineAttrs.updatePaints(view.getApplication(), settings, tb); lineAttrs.updatePaints(view.getApplication(), settings, tb);
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
new Renderable.StandardTrack(new ArrayList<>(before.points), 17.2).
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
new Renderable.StandardTrack(new ArrayList<>(after.points), 17.2).
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
if (editingCtx.isInApproximationMode()) { if (editingCtx.isInApproximationMode()) {
List<WptPt> originalTrackPointList = editingCtx.getOriginalTrackPointList(); List<WptPt> originalTrackPointList = editingCtx.getOriginalTrackPointList();
if (originalTrackPointList != null) { if (originalTrackPointList != null) {
@ -198,6 +191,15 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
drawSegment(view.getZoom(), lineAttrs.customColorPaint, canvas, tb); drawSegment(view.getZoom(), lineAttrs.customColorPaint, canvas, tb);
} }
} }
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
new Renderable.StandardTrack(new ArrayList<>(before.points), 17.2).
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
new Renderable.StandardTrack(new ArrayList<>(after.points), 17.2).
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
drawPoints(canvas, tb); drawPoints(canvas, tb);
} }
} }
@ -206,7 +208,9 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
if (inMeasurementMode) { if (inMeasurementMode) {
lineAttrs.updatePaints(view.getApplication(), settings, tb); lineAttrs.updatePaints(view.getApplication(), settings, tb);
if (!editingCtx.isInApproximationMode()) {
drawBeforeAfterPath(canvas, tb); drawBeforeAfterPath(canvas, tb);
}
if (editingCtx.getSelectedPointPosition() == -1) { if (editingCtx.getSelectedPointPosition() == -1) {
drawCenterIcon(canvas, tb, settings.isNightMode()); drawCenterIcon(canvas, tb, settings.isNightMode());

View file

@ -68,6 +68,8 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
if (app == null) { if (app == null) {
return; return;
} }
int highlightColorId = nightMode ? R.color.list_background_color_dark : R.color.activity_background_color_light;
if (savedInstanceState != null) { if (savedInstanceState != null) {
showOnMap = savedInstanceState.getBoolean(SHOW_ON_MAP_KEY); showOnMap = savedInstanceState.getBoolean(SHOW_ON_MAP_KEY);
simplifiedTrack = savedInstanceState.getBoolean(SIMPLIFIED_TRACK_KEY); simplifiedTrack = savedInstanceState.getBoolean(SIMPLIFIED_TRACK_KEY);
@ -85,7 +87,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
View editNameView = View.inflate(UiUtilities.getThemedContext(app, nightMode), View editNameView = View.inflate(UiUtilities.getThemedContext(app, nightMode),
R.layout.track_name_edit_text, null); R.layout.track_name_edit_text, null);
nameTextBox = editNameView.findViewById(R.id.name_text_box); nameTextBox = editNameView.findViewById(R.id.name_text_box);
nameTextBox.setBoxBackgroundColorResource(R.color.material_text_input_layout_bg); nameTextBox.setBoxBackgroundColorResource(highlightColorId);
nameTextBox.setHint(app.getString(R.string.ltr_or_rtl_combine_via_colon, nameTextBox.setHint(app.getString(R.string.ltr_or_rtl_combine_via_colon,
app.getString(R.string.shared_string_file_name), "").trim()); app.getString(R.string.shared_string_file_name), "").trim());
ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat ColorStateList colorStateList = ColorStateList.valueOf(ContextCompat
@ -190,14 +192,16 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
GradientDrawable background = (GradientDrawable) AppCompatResources.getDrawable(app, GradientDrawable background = (GradientDrawable) AppCompatResources.getDrawable(app,
R.drawable.bg_select_group_button_outline); R.drawable.bg_select_group_button_outline);
if (background != null) { if (background != null) {
int backgroundColor = AndroidUtils.getColorFromAttr(UiUtilities.getThemedContext(app, nightMode), int highlightColor = ContextCompat.getColor(app,nightMode ?
R.attr.activity_background_color); R.color.list_background_color_dark : R.color.activity_background_color_light);
int strokedColor = AndroidUtils.getColorFromAttr(UiUtilities.getThemedContext(app, nightMode),
R.attr.stroked_buttons_and_links_outline);
background = (GradientDrawable) background.mutate(); background = (GradientDrawable) background.mutate();
if (checked) { if (checked) {
background.setStroke(0, Color.TRANSPARENT); background.setStroke(0, Color.TRANSPARENT);
background.setColor(backgroundColor); background.setColor(highlightColor);
} else { } else {
background.setStroke(app.getResources().getDimensionPixelSize(R.dimen.map_button_stroke), backgroundColor); background.setStroke(app.getResources().getDimensionPixelSize(R.dimen.map_button_stroke), strokedColor);
} }
} }
return background; return background;
@ -328,6 +332,11 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
return false; return false;
} }
@Override
protected int getBgColorId() {
return nightMode ? R.color.activity_background_color_dark : R.color.list_background_color_light;
}
public interface SaveAsNewTrackFragmentListener { public interface SaveAsNewTrackFragmentListener {
void onSaveAsNewTrack(String folderName, String fileName, boolean showOnMap, boolean simplifiedTrack); void onSaveAsNewTrack(String folderName, String fileName, boolean showOnMap, boolean simplifiedTrack);

View file

@ -64,6 +64,7 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
private Map<String, List<GPXInfo>> gpxInfoMap; private Map<String, List<GPXInfo>> gpxInfoMap;
private Mode fragmentMode; private Mode fragmentMode;
private String selectedFolder; private String selectedFolder;
private String allFilesFolder;
public void setFragmentMode(Mode fragmentMode) { public void setFragmentMode(Mode fragmentMode) {
this.fragmentMode = fragmentMode; this.fragmentMode = fragmentMode;
@ -91,7 +92,7 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
final File gpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final File gpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
collectDirs(gpxDir, dirs); collectDirs(gpxDir, dirs);
List<String> dirItems = new ArrayList<>(); List<String> dirItems = new ArrayList<>();
String allFilesFolder = context.getString(R.string.shared_string_all); allFilesFolder = context.getString(R.string.shared_string_all);
if (savedInstanceState == null) { if (savedInstanceState == null) {
selectedFolder = allFilesFolder; selectedFolder = allFilesFolder;
} }
@ -116,7 +117,7 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
gpxList.add(gpxInfo); gpxList.add(gpxInfo);
} }
adapter = new GpxTrackAdapter(requireContext(), allGpxList, isShowCurrentGpx()); adapter = new GpxTrackAdapter(requireContext(), allGpxList, isShowCurrentGpx(), showFoldersName());
adapter.setAdapterListener(new OnItemClickListener() { adapter.setAdapterListener(new OnItemClickListener() {
@Override @Override
public void onItemClick(int position) { public void onItemClick(int position) {
@ -157,11 +158,16 @@ public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
private void updateFileList(String folderName, HorizontalSelectionAdapter folderAdapter) { private void updateFileList(String folderName, HorizontalSelectionAdapter folderAdapter) {
List<GPXInfo> gpxInfoList = gpxInfoMap.get(folderName); List<GPXInfo> gpxInfoList = gpxInfoMap.get(folderName);
adapter.setShowFolderName(showFoldersName());
adapter.setGpxInfoList(gpxInfoList != null ? gpxInfoList : new ArrayList<GPXInfo>()); adapter.setGpxInfoList(gpxInfoList != null ? gpxInfoList : new ArrayList<GPXInfo>());
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
folderAdapter.notifyDataSetChanged(); folderAdapter.notifyDataSetChanged();
} }
private boolean showFoldersName() {
return allFilesFolder.equals(selectedFolder);
}
private boolean isShowCurrentGpx() { private boolean isShowCurrentGpx() {
return fragmentMode == Mode.ADD_TO_TRACK; return fragmentMode == Mode.ADD_TO_TRACK;
} }

View file

@ -148,7 +148,7 @@ public class SnapTrackWarningFragment extends BaseOsmAndFragment {
} }
}); });
UiUtilities.setupDialogButton(nightMode, cancelButton, SECONDARY, R.string.shared_string_cancel); UiUtilities.setupDialogButton(nightMode, cancelButton, SECONDARY, R.string.shared_string_cancel);
UiUtilities.setupDialogButton(nightMode, applyButton, PRIMARY, R.string.shared_string_apply); UiUtilities.setupDialogButton(nightMode, applyButton, PRIMARY, R.string.shared_string_continue);
AndroidUiHelper.updateVisibility(applyButton, true); AndroidUiHelper.updateVisibility(applyButton, true);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true); AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true);
} }

View file

@ -128,7 +128,7 @@ public class StartPlanRouteBottomSheet extends BottomSheetBehaviourDialogFragmen
} }
}); });
final List<GPXInfo> gpxTopList = gpxList.subList(0, Math.min(5, gpxList.size())); final List<GPXInfo> gpxTopList = gpxList.subList(0, Math.min(5, gpxList.size()));
adapter = new GpxTrackAdapter(requireContext(), gpxTopList, false); adapter = new GpxTrackAdapter(requireContext(), gpxTopList, false, true);
adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() { adapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() {
@Override @Override
public void onItemClick(int position) { public void onItemClick(int position) {

View file

@ -62,6 +62,7 @@ import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.views.layers.MapControlsLayer;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -69,7 +70,8 @@ import java.io.File;
import java.util.List; import java.util.List;
public class FollowTrackFragment extends ContextMenuScrollFragment implements CardListener, IRouteInformationListener { public class FollowTrackFragment extends ContextMenuScrollFragment implements CardListener,
IRouteInformationListener, MapControlsLayer.MapControlsThemeInfoProvider {
public static final String TAG = FollowTrackFragment.class.getName(); public static final String TAG = FollowTrackFragment.class.getName();
@ -556,15 +558,15 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.drawable.travel_card_bg_light, R.drawable.travel_card_bg_dark); AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.drawable.travel_card_bg_light, R.drawable.travel_card_bg_dark);
} else { } else {
topShadow.setVisibility(View.VISIBLE); topShadow.setVisibility(View.VISIBLE);
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark); AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark); AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
} }
} }
} }
private void setupButtons(View view) { private void setupButtons(View view) {
View buttonsContainer = view.findViewById(R.id.buttons_container); View buttonsContainer = view.findViewById(R.id.buttons_container);
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg)); buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.bg_color));
View cancelButton = view.findViewById(R.id.dismiss_button); View cancelButton = view.findViewById(R.id.dismiss_button);
cancelButton.setOnClickListener(new View.OnClickListener() { cancelButton.setOnClickListener(new View.OnClickListener() {
@ -639,4 +641,9 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
public void routeWasFinished() { public void routeWasFinished() {
} }
@Override
protected String getThemeInfoProviderTag() {
return TAG;
}
} }

View file

@ -1633,7 +1633,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener, CardListener
String via = generateViaDescription(); String via = generateViaDescription();
GPXRouteParamsBuilder routeParamsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); GPXRouteParamsBuilder routeParamsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (routeParamsBuilder != null) { if (routeParamsBuilder != null) {
String fileName = new File(routeParamsBuilder.getFile().path).getName(); GPXFile gpxFile = routeParamsBuilder.getFile();
String fileName = null;
if (!Algorithms.isEmpty(gpxFile.path)) {
fileName = new File(gpxFile.path).getName();
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
fileName = gpxFile.tracks.get(0).name;
}
if (Algorithms.isEmpty(fileName)) {
fileName = app.getString(R.string.shared_string_gpx_track);
}
title.setText(GpxUiHelper.getGpxTitle(fileName)); title.setText(GpxUiHelper.getGpxTitle(fileName));
description.setText(R.string.follow_track); description.setText(R.string.follow_track);
buttonDescription.setText(R.string.shared_string_add); buttonDescription.setText(R.string.shared_string_add);

View file

@ -29,7 +29,8 @@ public class ImportTrackCard extends BaseCard {
@Override @Override
protected void updateContent() { protected void updateContent() {
int color = ContextCompat.getColor(app, R.color.preference_category_title); int color = ContextCompat.getColor(app, nightMode ?
R.color.active_color_primary_dark : R.color.active_color_primary_light);
Typeface typeface = FontCache.getRobotoMedium(app); Typeface typeface = FontCache.getRobotoMedium(app);
String importTrack = app.getString(R.string.plan_route_import_track); String importTrack = app.getString(R.string.plan_route_import_track);
SpannableString spannable = UiUtilities.createCustomFontSpannable(typeface, importTrack, importTrack, importTrack); SpannableString spannable = UiUtilities.createCustomFontSpannable(typeface, importTrack, importTrack, importTrack);

View file

@ -23,6 +23,8 @@ public class TracksToFollowCard extends BaseCard {
private List<GPXInfo> gpxInfoList; private List<GPXInfo> gpxInfoList;
private String selectedCategory; private String selectedCategory;
private String defaultCategory;
private String visibleCategory;
private GpxTrackAdapter tracksAdapter; private GpxTrackAdapter tracksAdapter;
@ -30,6 +32,8 @@ public class TracksToFollowCard extends BaseCard {
super(mapActivity); super(mapActivity);
this.gpxInfoList = gpxInfoList; this.gpxInfoList = gpxInfoList;
this.selectedCategory = selectedCategory; this.selectedCategory = selectedCategory;
defaultCategory = app.getString(R.string.shared_string_all);
visibleCategory = app.getString(R.string.shared_string_visible);
gpxInfoCategories = getGpxInfoCategories(); gpxInfoCategories = getGpxInfoCategories();
} }
@ -62,7 +66,7 @@ public class TracksToFollowCard extends BaseCard {
filesRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext())); filesRecyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
filesRecyclerView.setNestedScrollingEnabled(false); filesRecyclerView.setNestedScrollingEnabled(false);
tracksAdapter = new GpxTrackAdapter(view.getContext(), gpxInfoList, false); tracksAdapter = new GpxTrackAdapter(view.getContext(), gpxInfoList, false, showFoldersName());
tracksAdapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() { tracksAdapter.setAdapterListener(new GpxTrackAdapter.OnItemClickListener() {
@Override @Override
public void onItemClick(int position) { public void onItemClick(int position) {
@ -88,6 +92,7 @@ public class TracksToFollowCard extends BaseCard {
public void onItemSelected(String item) { public void onItemSelected(String item) {
selectedCategory = item; selectedCategory = item;
List<GPXInfo> items = gpxInfoCategories.get(item); List<GPXInfo> items = gpxInfoCategories.get(item);
tracksAdapter.setShowFolderName(showFoldersName());
tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList<GPXInfo>()); tracksAdapter.setGpxInfoList(items != null ? items : new ArrayList<GPXInfo>());
tracksAdapter.notifyDataSetChanged(); tracksAdapter.notifyDataSetChanged();
@ -101,17 +106,19 @@ public class TracksToFollowCard extends BaseCard {
selectionAdapter.notifyDataSetChanged(); selectionAdapter.notifyDataSetChanged();
} }
private boolean showFoldersName() {
return defaultCategory.equals(selectedCategory) || visibleCategory.equals(selectedCategory);
}
private Map<String, List<GPXInfo>> getGpxInfoCategories() { private Map<String, List<GPXInfo>> getGpxInfoCategories() {
String all = app.getString(R.string.shared_string_all);
String visible = app.getString(R.string.shared_string_visible);
Map<String, List<GPXInfo>> gpxInfoCategories = new LinkedHashMap<>(); Map<String, List<GPXInfo>> gpxInfoCategories = new LinkedHashMap<>();
gpxInfoCategories.put(visible, new ArrayList<GPXInfo>()); gpxInfoCategories.put(visibleCategory, new ArrayList<GPXInfo>());
gpxInfoCategories.put(all, new ArrayList<GPXInfo>()); gpxInfoCategories.put(defaultCategory, new ArrayList<GPXInfo>());
for (GPXInfo info : gpxInfoList) { for (GPXInfo info : gpxInfoList) {
if (info.isSelected()) { if (info.isSelected()) {
addGpxInfoCategory(gpxInfoCategories, info, visible); addGpxInfoCategory(gpxInfoCategories, info, visibleCategory);
} }
if (!Algorithms.isEmpty(info.getFileName())) { if (!Algorithms.isEmpty(info.getFileName())) {
File file = new File(info.getFileName()); File file = new File(info.getFileName());
@ -120,7 +127,7 @@ public class TracksToFollowCard extends BaseCard {
addGpxInfoCategory(gpxInfoCategories, info, dirName); addGpxInfoCategory(gpxInfoCategories, info, dirName);
} }
} }
addGpxInfoCategory(gpxInfoCategories, info, all); addGpxInfoCategory(gpxInfoCategories, info, defaultCategory);
} }
return gpxInfoCategories; return gpxInfoCategories;

View file

@ -337,13 +337,13 @@ public class RouteCalculationResult {
tunnelAlarm = null; tunnelAlarm = null;
} }
while (true) { while (true) {
if (i == s.getEndPointIndex() && routeInd != list.size() - 1) {
break;
}
Location n = new Location(""); //$NON-NLS-1$ Location n = new Location(""); //$NON-NLS-1$
LatLon point = s.getPoint(i); LatLon point = s.getPoint(i);
n.setLatitude(point.getLatitude()); n.setLatitude(point.getLatitude());
n.setLongitude(point.getLongitude()); n.setLongitude(point.getLongitude());
if (i == s.getEndPointIndex() && routeInd != list.size() - 1) {
break;
}
if (vls != null && i * 2 + 1 < vls.length) { if (vls != null && i * 2 + 1 < vls.length) {
float h = vls[2 * i + 1]; float h = vls[2 * i + 1];
n.setAltitude(h); n.setAltitude(h);
@ -356,6 +356,17 @@ public class RouteCalculationResult {
} }
lastHeight = h; lastHeight = h;
} }
// FIXME: investigate gpx file
if (s.getObject().getPoint31XTile(i) == 0 && s.getObject().getPoint31YTile(i) == 0) {
if (locations.size() > 0) {
Location prev = locations.get(locations.size() - 1);
n.setLatitude(prev.getLatitude());
n.setLongitude(prev.getLongitude());
if (prev.hasAltitude()) {
n.setAltitude(prev.getAltitude());
}
}
}
locations.add(n); locations.add(n);
attachAlarmInfo(alarms, s, i, locations.size()); attachAlarmInfo(alarms, s, i, locations.size());
segmentsToPopulate.add(s); segmentsToPopulate.add(s);

View file

@ -23,6 +23,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -196,13 +197,12 @@ public class VehicleParametersBottomSheet extends BasePreferenceBottomSheet {
return; return;
} }
if (AndroidUiHelper.isOrientationPortrait(activity)) { if (AndroidUiHelper.isOrientationPortrait(activity)) {
mainView.setBackgroundResource(showTopShadow ? getPortraitBgResId() : getBgColorId()); AndroidUtils.setBackground(mainView, showTopShadow ? getPortraitBg(activity) : getColoredBg(activity));
if (!showTopShadow) { if (!showTopShadow) {
mainView.setPadding(0, 0, 0, 0); mainView.setPadding(0, 0, 0, 0);
} }
} else { } else {
mainView.setBackgroundResource(showTopShadow AndroidUtils.setBackground(mainView, showTopShadow ? getLandscapeTopsidesBg(activity) : getLandscapeSidesBg(activity));
? getLandscapeTopsidesBgResId() : getLandscapeSidesBgResId());
} }
} }
}; };

View file

@ -432,15 +432,15 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.drawable.travel_card_bg_light, R.drawable.travel_card_bg_dark); AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.drawable.travel_card_bg_light, R.drawable.travel_card_bg_dark);
} else { } else {
topShadow.setVisibility(View.VISIBLE); topShadow.setVisibility(View.VISIBLE);
AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark); AndroidUtils.setBackground(mainView.getContext(), bottomContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.color.card_and_list_background_light, R.color.card_and_list_background_dark); AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.color.list_background_color_light, R.color.list_background_color_dark);
} }
} }
} }
private void setupButtons(View view) { private void setupButtons(View view) {
View buttonsContainer = view.findViewById(R.id.buttons_container); View buttonsContainer = view.findViewById(R.id.buttons_container);
buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.route_info_bg)); buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.bg_color));
View saveButton = view.findViewById(R.id.right_bottom_button); View saveButton = view.findViewById(R.id.right_bottom_button);
saveButton.setOnClickListener(new View.OnClickListener() { saveButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -720,6 +720,11 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
} }
} }
@Override
protected String getThemeInfoProviderTag() {
return TAG;
}
public interface OnNeedScrollListener { public interface OnNeedScrollListener {
void onVerticalScrollNeeded(int y); void onVerticalScrollNeeded(int y);
} }

View file

@ -28,6 +28,8 @@ import androidx.core.content.ContextCompat;
import androidx.core.view.ViewCompat; import androidx.core.view.ViewCompat;
import androidx.core.view.ViewPropertyAnimatorCompat; import androidx.core.view.ViewPropertyAnimatorCompat;
import androidx.core.view.ViewPropertyAnimatorListener; import androidx.core.view.ViewPropertyAnimatorListener;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.Slider; import com.google.android.material.slider.Slider;
@ -69,8 +71,10 @@ import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.corenative.NativeCoreContext; import net.osmand.plus.views.corenative.NativeCoreContext;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
@ -133,6 +137,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private boolean forceShowCompass; private boolean forceShowCompass;
private LatLon requestedLatLon; private LatLon requestedLatLon;
private long compassPressed; private long compassPressed;
private Set<String> themeInfoProviderTags = new HashSet<>();
public MapControlsLayer(MapActivity activity) { public MapControlsLayer(MapActivity activity) {
this.mapActivity = activity; this.mapActivity = activity;
@ -836,7 +841,7 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
private void updateControls(@NonNull RotatedTileBox tileBox, DrawSettings drawSettings) { private void updateControls(@NonNull RotatedTileBox tileBox, DrawSettings drawSettings) {
boolean isNight = drawSettings != null && drawSettings.isNightMode(); boolean isNight = isNightModeForMapControls(drawSettings);
boolean portrait = isPotrait(); boolean portrait = isPotrait();
// int shadw = isNight ? mapActivity.getResources().getColor(R.color.widgettext_shadow_night) : // int shadw = isNight ? mapActivity.getResources().getColor(R.color.widgettext_shadow_night) :
// mapActivity.getResources().getColor(R.color.widgettext_shadow_day); // mapActivity.getResources().getColor(R.color.widgettext_shadow_day);
@ -916,6 +921,25 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
} }
private boolean isNightModeForMapControls(DrawSettings drawSettings) {
MapControlsThemeInfoProvider themeInfoProvider = getThemeInfoProvider();
if (themeInfoProvider != null) {
return themeInfoProvider.isNightModeForMapControls();
}
return drawSettings != null && drawSettings.isNightMode();
}
private MapControlsThemeInfoProvider getThemeInfoProvider() {
FragmentManager fm = mapActivity.getSupportFragmentManager();
for (String tag : themeInfoProviderTags) {
Fragment f = fm.findFragmentByTag(tag);
if (f instanceof MapControlsThemeInfoProvider) {
return (MapControlsThemeInfoProvider) f;
}
}
return null;
}
public void updateCompass(boolean isNight) { public void updateCompass(boolean isNight) {
float mapRotate = mapActivity.getMapView().getRotate(); float mapRotate = mapActivity.getMapView().getRotate();
boolean showCompass = shouldShowCompass(); boolean showCompass = shouldShowCompass();
@ -1419,4 +1443,16 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
} }
} }
public void addThemeInfoProviderTag(String tag) {
themeInfoProviderTags.add(tag);
}
public void removeThemeInfoProviderTag(String tag) {
themeInfoProviderTags.remove(tag);
}
public interface MapControlsThemeInfoProvider {
boolean isNightModeForMapControls();
}
} }