From d6bd0e414567faa358d9d09d7d724a7acca1c935 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 15 Mar 2021 22:45:02 +0200 Subject: [PATCH 01/96] init --- .../GpxApproximationFragment.java | 10 +++++++++ .../MeasurementToolFragment.java | 6 ++++-- .../FollowTrackFragment.java | 21 +++++++++++-------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java index 132f48b6a5..cea8ff65a4 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java @@ -21,6 +21,7 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.LocationsHolder; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; +import net.osmand.plus.LockableScrollView; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -157,6 +158,15 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment updateCardsLayout(); } updateCards(); + final LockableScrollView profileContainer = mainView.findViewById(R.id.route_menu_bottom_scroll); + profileContainer.postDelayed(new Runnable() { + @Override + public void run() { + if (snapToRoadAppMode.getOrder() > 4) { + profileContainer.fullScroll(View.FOCUS_DOWN); + } + } + }, 100); updateButtons(mainView); progressBar = mainView.findViewById(R.id.progress_bar); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 74f636802a..fcc7f0ca03 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -554,7 +554,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route }); initMeasurementMode(gpxData, savedInstanceState == null); - if (savedInstanceState == null) { if (fileName != null) { addNewGpxData(getGpxFile(fileName)); @@ -1959,10 +1958,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route } public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx, - boolean followTrackMode) { + boolean followTrackMode, boolean isShowSnapWarning) { MeasurementToolFragment fragment = new MeasurementToolFragment(); fragment.setEditingCtx(editingCtx); fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode); + Bundle bundle = new Bundle(); + bundle.putBoolean("isShowSnapWarning", isShowSnapWarning); + fragment.setArguments(bundle); return showFragment(fragment, fragmentManager); } diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index b5abb80b65..a5209eac18 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -446,15 +446,18 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca if (mapActivity != null) { if (card instanceof ImportTrackCard) { importTrack(); - } else if (card instanceof TrackEditCard || card instanceof AttachTrackToRoadsCard) { - openPlanRoute(); + } else if (card instanceof AttachTrackToRoadsCard) { + openPlanRoute(true); + close(); + } else if (card instanceof TrackEditCard) { + openPlanRoute(false); close(); - } else if (card instanceof SelectTrackCard) { - updateSelectionMode(true); - } else if (card instanceof ReverseTrackCard - || card instanceof NavigateTrackOptionsCard) { - updateMenu(); } + } else if (card instanceof SelectTrackCard) { + updateSelectionMode(true); + } else if (card instanceof ReverseTrackCard + || card instanceof NavigateTrackOptionsCard) { + updateMenu(); } } @@ -574,7 +577,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } } - public void openPlanRoute() { + public void openPlanRoute(boolean showSnapWarning) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null && gpxFile != null) { editingTrack = true; @@ -583,7 +586,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca editingContext.setGpxData(gpxData); editingContext.setAppMode(app.getRoutingHelper().getAppMode()); editingContext.setSelectedSegment(app.getSettings().GPX_ROUTE_SEGMENT.get()); - MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true); + MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), editingContext, true, showSnapWarning); } } From a8719b542fef323dcc2af7923590653ed71273b4 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Mon, 15 Mar 2021 23:56:14 +0200 Subject: [PATCH 02/96] Navigation > Follow track > select simplified track > edit > open "Route between points" --- .../MeasurementToolFragment.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index fcc7f0ca03..34fde58555 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -132,6 +132,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route private ImageView mainIcon; private String fileName; private OnBackPressedCallback onBackPressedCallback; + private boolean isShowSnapWarning; + private static final String SHOW_SNAP_WARNING = "show_snap_warning"; private InfoType currentInfoType; @@ -235,6 +237,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route if (mapActivity == null) { return null; } + if (savedInstanceState != null) { + restoreState(savedInstanceState); + } else if (getArguments() != null) { + restoreState(getArguments()); + } final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer(); final OsmandApplication app = mapActivity.getMyApplication(); @@ -349,7 +356,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route } }); - View applyPointBeforeAfterButton = mainView.findViewById(R.id.apply_point_before_after_point_button); UiUtilities.setupDialogButton(nightMode, applyPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply); @@ -553,6 +559,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route } }); + isShowSnapWarning = getArguments().getBoolean(SHOW_SNAP_WARNING); initMeasurementMode(gpxData, savedInstanceState == null); if (savedInstanceState == null) { if (fileName != null) { @@ -1963,7 +1970,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route fragment.setEditingCtx(editingCtx); fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode); Bundle bundle = new Bundle(); - bundle.putBoolean("isShowSnapWarning", isShowSnapWarning); + bundle.putBoolean(SHOW_SNAP_WARNING, isShowSnapWarning); fragment.setArguments(bundle); return showFragment(fragment, fragmentManager); } @@ -2107,7 +2114,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route manager.beginTransaction() .hide(this).commit(); layer.setTapsDisabled(true); - SnapTrackWarningFragment.showInstance(mapActivity.getSupportFragmentManager(), this); + if (isShowSnapWarning) { + SnapTrackWarningFragment.showInstance(mapActivity.getSupportFragmentManager(), this); + } AndroidUiHelper.setVisibility(mapActivity, View.GONE, R.id.map_ruler_container); } } @@ -2132,4 +2141,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route public interface OnUpdateInfoListener { void onUpdateInfo(); } + + public void restoreState(Bundle bundle) { + isShowSnapWarning = bundle.getBoolean(SHOW_SNAP_WARNING); + } } \ No newline at end of file From 4064e1af985b9b51a974f3367e9e687c48a42e50 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 17 Mar 2021 13:24:08 +0200 Subject: [PATCH 03/96] Travel: Maps you need card, popular articles jumping For more smoothy update recycle view notifyItemRangeChanged(getNeededMapsCardPosition(), items.size()); --- .../net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index d39e228abb..3f2db48f0c 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -158,8 +158,6 @@ public class ExploreRvAdapter extends RecyclerView.Adapter Date: Wed, 17 Mar 2021 17:20:52 +0200 Subject: [PATCH 04/96] Update ExploreRvAdapter.java --- .../net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index 3f2db48f0c..becc599ced 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -158,6 +158,8 @@ public class ExploreRvAdapter extends RecyclerView.Adapter Date: Wed, 17 Mar 2021 20:16:44 +0200 Subject: [PATCH 05/96] redesign trip recording start dialog --- ...tn_background_active_transparent_light.xml | 6 + ...btn_background_active_transparent_dark.xml | 6 + ...h_switch_divider_and_additional_button.xml | 124 ++++--- .../layout/preference_button_with_icon.xml | 47 +++ .../preference_button_with_icon_quadruple.xml | 57 ++++ .../preference_button_with_icon_triple.xml | 46 +++ ...l => trip_recording_starting_fragment.xml} | 91 +++-- OsmAnd/res/values/sizes.xml | 1 + OsmAnd/res/values/strings.xml | 1 + .../osmand/plus/activities/MapActivity.java | 7 +- .../plus/activities/MapActivityActions.java | 4 +- .../monitoring/OsmandMonitoringPlugin.java | 4 +- .../TripRecordingActiveBottomSheet.java | 113 ++++--- .../monitoring/TripRecordingBottomSheet.java | 306 ----------------- .../TripRecordingStartingBottomSheet.java | 314 ++++++++++++++++++ .../fragments/BaseSettingsFragment.java | 29 +- .../plus/track/TrackAppearanceFragment.java | 6 +- 17 files changed, 712 insertions(+), 450 deletions(-) create mode 100644 OsmAnd/res/drawable-hdpi/btn_background_active_transparent_light.xml create mode 100644 OsmAnd/res/drawable/btn_background_active_transparent_dark.xml create mode 100644 OsmAnd/res/layout/preference_button_with_icon.xml create mode 100644 OsmAnd/res/layout/preference_button_with_icon_quadruple.xml create mode 100644 OsmAnd/res/layout/preference_button_with_icon_triple.xml rename OsmAnd/res/layout/{trip_recording_fragment.xml => trip_recording_starting_fragment.xml} (57%) delete mode 100644 OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java create mode 100644 OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java diff --git a/OsmAnd/res/drawable-hdpi/btn_background_active_transparent_light.xml b/OsmAnd/res/drawable-hdpi/btn_background_active_transparent_light.xml new file mode 100644 index 0000000000..add11f80f7 --- /dev/null +++ b/OsmAnd/res/drawable-hdpi/btn_background_active_transparent_light.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/btn_background_active_transparent_dark.xml b/OsmAnd/res/drawable/btn_background_active_transparent_dark.xml new file mode 100644 index 0000000000..14ae96d07a --- /dev/null +++ b/OsmAnd/res/drawable/btn_background_active_transparent_dark.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml index 6953783885..a10a9eef42 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml @@ -4,80 +4,96 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginStart="@dimen/content_padding" + android:layout_marginLeft="@dimen/content_padding" + android:layout_marginEnd="@dimen/content_padding" + android:layout_marginRight="@dimen/content_padding" android:baselineAligned="false" android:gravity="center_vertical" - android:minHeight="@dimen/bottom_sheet_selected_item_title_height"> + android:minHeight="@dimen/bottom_sheet_list_item_height"> - + android:gravity="center_vertical" + app:cardBackgroundColor="?attr/switch_button_active" + app:cardCornerRadius="4dp" + app:cardElevation="0dp"> + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?attr/selectableItemBackground" + android:orientation="horizontal"> - + + + android:layout_gravity="center_vertical" + android:layout_marginStart="@dimen/bottom_sheet_content_margin" + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:clickable="false" + android:focusable="false" + android:focusableInTouchMode="false" + tools:checked="true" /> - + - - - + app:cardBackgroundColor="?attr/switch_button_active" + app:cardCornerRadius="4dp" + app:cardElevation="0dp"> - + android:background="?android:attr/selectableItemBackground" + android:clickable="true" + android:focusable="true" + android:gravity="center"> - + - + + + diff --git a/OsmAnd/res/layout/preference_button_with_icon.xml b/OsmAnd/res/layout/preference_button_with_icon.xml new file mode 100644 index 0000000000..1c6b6770fd --- /dev/null +++ b/OsmAnd/res/layout/preference_button_with_icon.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/preference_button_with_icon_quadruple.xml b/OsmAnd/res/layout/preference_button_with_icon_quadruple.xml new file mode 100644 index 0000000000..4105dbb2bc --- /dev/null +++ b/OsmAnd/res/layout/preference_button_with_icon_quadruple.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/preference_button_with_icon_triple.xml b/OsmAnd/res/layout/preference_button_with_icon_triple.xml new file mode 100644 index 0000000000..22d68ff090 --- /dev/null +++ b/OsmAnd/res/layout/preference_button_with_icon_triple.xml @@ -0,0 +1,46 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/trip_recording_fragment.xml b/OsmAnd/res/layout/trip_recording_starting_fragment.xml similarity index 57% rename from OsmAnd/res/layout/trip_recording_fragment.xml rename to OsmAnd/res/layout/trip_recording_starting_fragment.xml index f69e4eb4c7..809cc015ac 100644 --- a/OsmAnd/res/layout/trip_recording_fragment.xml +++ b/OsmAnd/res/layout/trip_recording_starting_fragment.xml @@ -1,11 +1,11 @@ + android:orientation="vertical" + android:paddingBottom="@dimen/content_padding"> + app:typeface="@string/font_roboto_medium" /> + android:paddingRight="@dimen/content_padding" + android:paddingBottom="@dimen/bottom_sheet_content_margin"> + - + android:layout_height="wrap_content" + app:cardBackgroundColor="?attr/switch_button_active" + app:cardCornerRadius="4dp" + app:cardElevation="0dp"> + + + + + + + + + + + + + - + android:layout_height="@dimen/content_padding" /> + + - - - diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index dae06fed05..79fa32d1c3 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -418,4 +418,5 @@ 3sp 80dp + 160dp \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 899beda35c..93cfd93231 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,7 @@ Thx - Hardy --> + Logging interval set time period in which OsmAnd will ask for the current location position data. Please select another type of colorization. The track does not contain speed data. The track does not contain altitude data. diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7e0a07e40c..487f4d902f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -93,7 +93,6 @@ import net.osmand.plus.importfiles.ImportHelper; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment; -import net.osmand.plus.mapcontextmenu.editors.SelectFavoriteCategoryBottomSheet; import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; import net.osmand.plus.mapmarkers.MapMarker; @@ -105,7 +104,7 @@ import net.osmand.plus.measurementtool.LoginBottomSheetFragment; import net.osmand.plus.measurementtool.MeasurementEditingContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.SnapTrackWarningFragment; -import net.osmand.plus.monitoring.TripRecordingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; @@ -2242,8 +2241,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(MeasurementToolFragment.TAG); } - public TripRecordingBottomSheet getTripRecordingBottomSheet() { - return getFragment(TripRecordingBottomSheet.TAG); + public TripRecordingStartingBottomSheet getTripRecordingBottomSheet() { + return getFragment(TripRecordingStartingBottomSheet.TAG); } public ChooseRouteFragment getChooseRouteFragment() { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index c0fec48168..ff78335e74 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -63,7 +63,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet; -import net.osmand.plus.monitoring.TripRecordingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment; import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataUtils; @@ -856,7 +856,7 @@ public class MapActivityActions implements DialogProvider { if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) { TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack()); } else { - TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager()); + TripRecordingStartingBottomSheet.showInstance(mapActivity.getSupportFragmentManager()); } return true; } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 2799ac8ded..4fa978a8d6 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -331,7 +331,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { if (hasDataToSave() || wasTrackMonitored()) { TripRecordingActiveBottomSheet.showInstance(fragmentManager, getCurrentTrack()); } else { - TripRecordingBottomSheet.showInstance(fragmentManager); + TripRecordingStartingBottomSheet.showInstance(fragmentManager); } /*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); @@ -523,7 +523,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { runnable.run(); } else if (map instanceof FragmentActivity) { FragmentActivity activity = (FragmentActivity) map; - TripRecordingBottomSheet.showInstance(activity.getSupportFragmentManager()); + TripRecordingStartingBottomSheet.showInstance(activity.getSupportFragmentManager()); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java index 00a9c0e8c0..27295899da 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java @@ -4,17 +4,16 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.res.ColorStateList; -import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.util.TypedValue; import android.text.format.DateUtils; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; +import android.widget.CompoundButton; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; @@ -26,7 +25,7 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.widget.AppCompatImageView; -import androidx.appcompat.widget.SwitchCompat; +import androidx.cardview.widget.CardView; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; @@ -49,7 +48,6 @@ import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.FontCache; import net.osmand.plus.myplaces.SaveCurrentTrackTask; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.track.GpxBlockStatisticsBuilder; @@ -66,7 +64,7 @@ import java.util.Arrays; import java.util.List; import static net.osmand.AndroidUtils.getSecondaryTextColorId; -import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT; +import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment { @@ -84,6 +82,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen private View statusContainer; private LinearLayout buttonAppearance; + private AppCompatImageView trackAppearanceIcon; private View buttonSave; private GpxBlockStatisticsBuilder blockStatisticsBuilder; @@ -141,7 +140,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave()); createItem(buttonOnline, ItemType.STOP_ONLINE, hasDataToSave()); - createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored()); + createItem(buttonSegment, ItemType.START_NEW_SEGMENT, wasTrackMonitored()); createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true); createItem(buttonStop, ItemType.STOP, true); @@ -163,37 +162,24 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode); LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); - showTrackContainer.setMinimumHeight(app.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_list_item_height)); - final LinearLayout buttonShow = showTrackContainer.findViewById(R.id.basic_item_body); + final CardView buttonShow = showTrackContainer.findViewById(R.id.compound_container); TextView showTrackTitle = buttonShow.findViewById(R.id.title); Integer showTitle = ItemType.SHOW_TRACK.getTitleId(); if (showTitle != null) { showTrackTitle.setText(showTitle); } - AndroidUtils.setPadding(buttonShow, AndroidUtils.dpToPx(app, 12f), 0, buttonShow.getPaddingRight(), 0); - showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode))); - showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size)); - Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium)); - showTrackTitle.setTypeface(typeface); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - float letterSpacing = AndroidUtils.getFloatValueFromRes(app, R.dimen.text_button_letter_spacing); - showTrackTitle.setLetterSpacing(letterSpacing); - } - final SwitchCompat showTrackOnMapButton = buttonShow.findViewById(R.id.switch_button); - showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT); + final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button); + showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); + UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); - View divider = buttonAppearance.getChildAt(0); - AndroidUiHelper.setVisibility(View.GONE, divider); - int marginS = app.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_small); - UiUtilities.setMargins(buttonAppearance, marginS, 0, 0, 0); - updateTrackIcon(buttonAppearance); + trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); + updateTrackIcon(app, trackAppearanceIcon); buttonAppearance.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (showTrackOnMapButton.isChecked()) { + if (showTrackCompound.isChecked()) { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { hide(); @@ -203,19 +189,19 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } }); - createItem(buttonAppearance, ItemType.APPEARANCE, showTrackOnMapButton.isChecked()); - setShowOnMapBackground(buttonShow, app, showTrackOnMapButton.isChecked(), nightMode); + createItem(buttonAppearance, ItemType.APPEARANCE, showTrackCompound.isChecked()); + setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buttonShow.setBackgroundTintList(null); } buttonShow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - boolean checked = !showTrackOnMapButton.isChecked(); - showTrackOnMapButton.setChecked(checked); + boolean checked = !showTrackCompound.isChecked(); + showTrackCompound.setChecked(checked); app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); createItem(buttonAppearance, ItemType.APPEARANCE, checked); - setShowOnMapBackground(buttonShow, app, checked, nightMode); + setShowOnMapBackground(buttonShow, checked, nightMode); } }); @@ -277,7 +263,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored); updateStatus(); createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true); - createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored); + createItem(buttonSegment, ItemType.START_NEW_SEGMENT, wasTrackMonitored); } }); @@ -310,15 +296,17 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } - private void updateTrackIcon(View buttonAppearance) { - String width = settings.CURRENT_TRACK_WIDTH.get(); - boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get(); - int color = settings.CURRENT_TRACK_COLOR.get(); - Drawable appearanceDrawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color); - AppCompatImageView appearanceIcon = buttonAppearance.findViewById(R.id.icon_after_divider); - int marginTrackIconH = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small); - UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0); - appearanceIcon.setImageDrawable(appearanceDrawable); + public static void updateTrackIcon(OsmandApplication app, AppCompatImageView appearanceIcon) { + if (appearanceIcon != null) { + OsmandSettings settings = app.getSettings(); + String width = settings.CURRENT_TRACK_WIDTH.get(); + boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get(); + int color = settings.CURRENT_TRACK_COLOR.get(); + Drawable appearanceDrawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color); + int marginTrackIconH = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small); + UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0); + appearanceIcon.setImageDrawable(appearanceDrawable); + } } private void createItem(View view, ItemType type, boolean enabled) { @@ -370,7 +358,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen setTextColor(context, desc, false, nightMode, type); } - setItemBackground(context, nightMode, button != null ? button : (LinearLayout) view, enabled); + setItemBackground(context, nightMode, button != null ? button : view, enabled); } private String getTimeTrackSaved() { @@ -505,7 +493,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen show(); for (String key : keys) { if (key.equals(UPDATE_TRACK_ICON)) { - updateTrackIcon(buttonAppearance); + updateTrackIcon(app, trackAppearanceIcon); } } } @@ -524,7 +512,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen RECORDING(R.string.recording_default_name, R.drawable.ic_action_track_recordable), ON_PAUSE(R.string.on_pause, R.drawable.ic_pause), CLEAR_DATA(R.string.clear_recorded_data, R.drawable.ic_action_delete_dark), - START_SEGMENT(R.string.gpx_start_new_segment, R.drawable.ic_action_new_segment), + START_NEW_SEGMENT(R.string.gpx_start_new_segment, R.drawable.ic_action_new_segment), SAVE(R.string.shared_string_save, R.drawable.ic_action_save_to_file), PAUSE(R.string.shared_string_pause, R.drawable.ic_pause), RESUME(R.string.shared_string_resume, R.drawable.ic_play_dark), @@ -532,7 +520,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop), STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file), STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), - CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close); + CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close), + START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement), + SETTINGS(R.string.shared_string_settings, R.drawable.ic_action_settings); @StringRes private final Integer titleId; @@ -560,24 +550,28 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } - public static void setItemBackground(Context context, boolean nightMode, LinearLayout view, boolean enabled) { + public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) { Drawable background = AppCompatResources.getDrawable(context, R.drawable.btn_background_inactive_light); if (background != null && enabled) { + int normalColorId = view instanceof CardView + ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode); ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( - context, getInactiveButtonColorId(nightMode), getActiveButtonColorId(nightMode) + context, normalColorId, getActiveTextColorId(nightMode) ); DrawableCompat.setTintList(background, iconColorStateList); + if (view instanceof CardView) { + ((CardView) view).setCardBackgroundColor(iconColorStateList); + return; + } } else { UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); } view.setBackgroundDrawable(background); } - public static void setShowOnMapBackground(LinearLayout view, Context context, boolean checked, boolean nightMode) { - Drawable background = AppCompatResources.getDrawable(context, - nightMode ? checked ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_stroked_inactive_dark - : checked ? R.drawable.btn_background_inactive_light : R.drawable.btn_background_stroked_inactive_light); - view.setBackgroundDrawable(background); + public static void setShowOnMapBackground(View view, boolean checked, boolean nightMode) { + int background = checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode); + view.setBackgroundResource(background); } public static void setTextColor(Context context, TextView tv, boolean enabled, boolean nightMode, ItemType type) { @@ -638,11 +632,26 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light; } + @DrawableRes + public static int getActiveTransparentColorId(boolean nightMode) { + return nightMode ? R.color.switch_button_active_dark : R.color.switch_button_active_light; + } + @ColorRes public static int getPressedColorId(boolean nightMode) { return nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light; } + @DrawableRes + public static int getActiveTransparentBackgroundId(boolean nightMode) { + return nightMode ? R.drawable.btn_background_active_transparent_dark : R.drawable.btn_background_active_transparent_light; + } + + @DrawableRes + public static int getInactiveStrokedBackgroundId(boolean nightMode) { + return nightMode ? R.drawable.btn_background_stroked_inactive_dark : R.drawable.btn_background_stroked_inactive_light; + } + @Override protected int getDismissButtonHeight() { return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java deleted file mode 100644 index bbaf9295f7..0000000000 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java +++ /dev/null @@ -1,306 +0,0 @@ -package net.osmand.plus.monitoring; - -import android.app.Activity; -import android.app.Dialog; -import android.content.Context; -import android.graphics.Typeface; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.text.SpannableString; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.widget.SwitchCompat; -import androidx.core.content.ContextCompat; -import androidx.fragment.app.FragmentManager; - -import com.google.android.material.slider.RangeSlider; - -import net.osmand.AndroidUtils; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.NavigationService; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.UiUtilities; -import net.osmand.plus.UiUtilities.DialogButtonType; -import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.SavingTrackHelper; -import net.osmand.plus.base.MenuBottomSheetDialogFragment; -import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; -import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.FontCache; -import net.osmand.plus.settings.backend.OsmandSettings; -import net.osmand.plus.track.TrackAppearanceFragment; - -import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT; -import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; -import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; - -public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment { - - public static final String TAG = TripRecordingBottomSheet.class.getSimpleName(); - - private OsmandApplication app; - private OsmandSettings settings; - - private ImageView upDownBtn; - private SwitchCompat confirmEveryRun; - private TextView intervalValueView; - private LinearLayout container; - private View divider; - private boolean infoExpanded; - - @Override - public void createMenuItems(Bundle savedInstanceState) { - app = requiredMyApplication(); - settings = app.getSettings(); - Context context = requireContext(); - - LayoutInflater inflater = UiUtilities.getInflater(context, nightMode); - View itemView = inflater.inflate(R.layout.trip_recording_fragment, null, false); - items.add(new BottomSheetItemWithDescription.Builder() - .setCustomView(itemView) - .create()); - - final int paddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small); - - LinearLayout showTrackOnMapView = itemView.findViewById(R.id.show_track_on_map); - TextView showTrackOnMapTitle = showTrackOnMapView.findViewById(R.id.title); - showTrackOnMapTitle.setText(R.string.show_track_on_map); - - ImageView trackAppearanceIcon = showTrackOnMapView.findViewById(R.id.icon_after_divider); - - int color = settings.CURRENT_TRACK_COLOR.get(); - String width = settings.CURRENT_TRACK_WIDTH.get(); - boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get(); - Drawable drawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color); - - trackAppearanceIcon.setImageDrawable(drawable); - trackAppearanceIcon.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - hide(); - SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingBottomSheet.this); - } - } - }); - - divider = itemView.findViewById(R.id.second_divider); - LinearLayout expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container); - upDownBtn = itemView.findViewById(R.id.up_down_button); - expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - toggleInfoView(); - } - }); - - final int secondsLength = SECONDS.length; - final int minutesLength = MINUTES.length; - - intervalValueView = itemView.findViewById(R.id.interval_value); - updateIntervalLegend(); - - container = itemView.findViewById(R.id.always_ask_and_range_slider_container); - RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider); - intervalSlider.setValueTo(secondsLength + minutesLength - 1); - int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode); - UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true); - container.setVisibility(View.GONE); - intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() { - - @Override - public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) { - int progress = (int) value; - if (progress == 0) { - settings.SAVE_GLOBAL_TRACK_INTERVAL.set(0); - } else if (progress < secondsLength) { - settings.SAVE_GLOBAL_TRACK_INTERVAL.set(SECONDS[progress] * 1000); - } else { - settings.SAVE_GLOBAL_TRACK_INTERVAL.set(MINUTES[progress - secondsLength] * 60 * 1000); - } - updateIntervalLegend(); - } - }); - - for (int i = 0; i < secondsLength + minutesLength; i++) { - if (i < secondsLength) { - if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) { - intervalSlider.setValues((float) i); - break; - } - } else { - if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= MINUTES[i - secondsLength] * 1000 * 60) { - intervalSlider.setValues((float) i); - break; - } - } - } - boolean checked = !settings.SAVE_GLOBAL_TRACK_REMEMBER.get(); - confirmEveryRun = itemView.findViewById(R.id.confirm_every_run); - confirmEveryRun.setChecked(checked); - setBackgroundAndPadding(checked, paddingSmall); - confirmEveryRun.setOnCheckedChangeListener(new OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - setBackgroundAndPadding(isChecked, paddingSmall); - settings.SAVE_GLOBAL_TRACK_REMEMBER.set(!isChecked); - } - }); - - final SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button); - showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - View basicItem = itemView.findViewById(R.id.basic_item_body); - basicItem.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean checked = !showTrackOnMapButton.isChecked(); - showTrackOnMapButton.setChecked(checked); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); - } - }); - UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT); - - updateUpDownBtn(); - } - - private void updateIntervalLegend() { - String text = getString(R.string.save_track_interval_globally); - String textValue; - int interval = settings.SAVE_GLOBAL_TRACK_INTERVAL.get(); - if (interval == 0) { - textValue = getString(R.string.int_continuosly); - } else { - int seconds = interval / 1000; - if (seconds <= SECONDS[SECONDS.length - 1]) { - textValue = seconds + " " + getString(R.string.int_seconds); - } else { - textValue = (seconds / 60) + " " + getString(R.string.int_min); - } - } - String textAll = getString(R.string.ltr_or_rtl_combine_via_colon, text, textValue); - Typeface typeface = FontCache.getRobotoMedium(app); - SpannableString spannableString = UiUtilities.createCustomFontSpannable(typeface, textAll, textValue); - intervalValueView.setText(spannableString); - } - - public void show() { - Dialog dialog = getDialog(); - if (dialog != null) { - dialog.show(); - } - } - - public void hide() { - Dialog dialog = getDialog(); - if (dialog != null) { - dialog.hide(); - } - } - - private void setBackgroundAndPadding(boolean isChecked, int paddingSmall) { - if (nightMode) { - confirmEveryRun.setBackgroundResource( - isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark); - } else { - confirmEveryRun.setBackgroundResource( - isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg); - } - confirmEveryRun.setPadding(paddingSmall, 0, paddingSmall, 0); - } - - private void updateUpDownBtn() { - int iconId = infoExpanded ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up; - upDownBtn.setImageDrawable(getContentIcon(iconId)); - } - - private void toggleInfoView() { - infoExpanded = !infoExpanded; - ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) divider.getLayoutParams(); - final int dp8 = AndroidUtils.dpToPx(app, 8f); - final int dp16 = AndroidUtils.dpToPx(app, 16f); - if (infoExpanded) { - AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8); - } else { - AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8); - } - AndroidUiHelper.updateVisibility(container, infoExpanded); - updateUpDownBtn(); - } - - @Override - protected boolean useVerticalButtons() { - return true; - } - - @Override - protected int getRightButtonHeight() { - return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); - } - - @Override - protected int getDismissButtonHeight() { - return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); - } - - @Override - protected int getRightBottomButtonTextId() { - return R.string.start_recording; - } - - @Override - protected int getDismissButtonTextId() { - return R.string.shared_string_cancel; - } - - @Override - protected DialogButtonType getRightBottomButtonType() { - return DialogButtonType.PRIMARY; - } - - @Override - public int getSecondDividerHeight() { - return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin); - } - - @Override - protected void onRightBottomButtonClick() { - SavingTrackHelper helper = app.getSavingTrackHelper(); - helper.startNewSegment(); - settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true); - app.startNavigationService(NavigationService.USED_BY_GPX); - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack()); - } - dismiss(); - } - - @Nullable - public MapActivity getMapActivity() { - Activity activity = getActivity(); - if (activity instanceof MapActivity) { - return (MapActivity) activity; - } - return null; - } - - public static void showInstance(@NonNull FragmentManager fragmentManager) { - if (!fragmentManager.isStateSaved()) { - TripRecordingBottomSheet fragment = new TripRecordingBottomSheet(); - fragment.show(fragmentManager, TAG); - } - } -} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java new file mode 100644 index 0000000000..7f19ea13fb --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -0,0 +1,314 @@ +package net.osmand.plus.monitoring; + +import android.app.Activity; +import android.app.Dialog; +import android.content.Context; +import android.graphics.Typeface; +import android.os.Build; +import android.os.Bundle; +import android.text.SpannableString; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.CompoundButton; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageView; +import androidx.appcompat.widget.SwitchCompat; +import androidx.cardview.widget.CardView; +import androidx.fragment.app.FragmentManager; + +import com.google.android.material.slider.RangeSlider; + +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.NavigationService; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.SavingTrackHelper; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.FontCache; +import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.settings.fragments.BaseSettingsFragment; +import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; +import net.osmand.plus.track.TrackAppearanceFragment; + +import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; +import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; +import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.setShowOnMapBackground; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon; + +public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragment { + + public static final String TAG = TripRecordingStartingBottomSheet.class.getSimpleName(); + public static final String UPDATE_LOGGING_INTERVAL = "update_logging_interval"; + + private OsmandApplication app; + private OsmandSettings settings; + + private AppCompatImageView upDownBtn; + private AppCompatImageView trackAppearanceIcon; + private CardView confirmContainer; + private SwitchCompat confirmCompound; + private TextView intervalValueView; + private LinearLayout intervalContainer; + private RangeSlider intervalSlider; + + private boolean infoExpanded; + + public static void showInstance(@NonNull FragmentManager fragmentManager) { + if (!fragmentManager.isStateSaved()) { + TripRecordingStartingBottomSheet fragment = new TripRecordingStartingBottomSheet(); + fragment.show(fragmentManager, TAG); + } + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + app = requiredMyApplication(); + settings = app.getSettings(); + Context context = requireContext(); + + LayoutInflater inflater = UiUtilities.getInflater(context, nightMode); + View itemView = inflater.inflate(R.layout.trip_recording_starting_fragment, null, false); + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(itemView) + .create()); + + LinearLayout expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container); + upDownBtn = itemView.findViewById(R.id.up_down_button); + expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + updateIntervalContainer(); + } + }); + + intervalValueView = itemView.findViewById(R.id.interval_value); + intervalContainer = itemView.findViewById(R.id.always_ask_and_range_slider_container); + intervalSlider = itemView.findViewById(R.id.interval_slider); + updateIntervalValue(); + + confirmContainer = itemView.findViewById(R.id.confirm_container); + confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button); + updateGlobalRemember(); + confirmContainer.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !confirmCompound.isChecked(); + confirmCompound.setChecked(checked); + settings.SAVE_GLOBAL_TRACK_REMEMBER.set(checked); + setShowOnMapBackground(confirmContainer, checked, nightMode); + } + }); + + LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); + + final CardView buttonShow = itemView.findViewById(R.id.compound_container); + TextView showTrackTitle = buttonShow.findViewById(R.id.title); + showTrackTitle.setText(R.string.show_track_on_map); + final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button); + showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); + UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); + + LinearLayout buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); + trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); + updateTrackIcon(app, trackAppearanceIcon); + buttonAppearance.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + hide(); + SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingStartingBottomSheet.this); + } + } + }); + setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + buttonShow.setBackgroundTintList(null); + } + buttonShow.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !showTrackCompound.isChecked(); + showTrackCompound.setChecked(checked); + app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); + setShowOnMapBackground(buttonShow, checked, nightMode); + } + }); + + updateUpDownBtn(); + + CardView cardLeft = itemView.findViewById(R.id.button_left); + createItem(app, nightMode, cardLeft, ItemType.CANCEL, true, null); + cardLeft.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + } + }); + + CardView cardCenter = itemView.findViewById(R.id.button_center); + createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null); + cardCenter.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + startRecording(); + } + }); + + CardView cardRight = itemView.findViewById(R.id.button_right); + createItem(app, nightMode, cardRight, ItemType.SETTINGS, true, null); + cardRight.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + hide(); + BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.MONITORING_SETTINGS, TripRecordingStartingBottomSheet.this); + } + } + }); + } + + private void updateIntervalLegend() { + String text = getString(R.string.save_track_interval_globally); + String textValue; + int interval = settings.SAVE_GLOBAL_TRACK_INTERVAL.get(); + if (interval == 0) { + textValue = getString(R.string.int_continuosly); + } else { + int seconds = interval / 1000; + if (seconds <= SECONDS[SECONDS.length - 1]) { + textValue = seconds + " " + getString(R.string.int_seconds); + } else { + textValue = (seconds / 60) + " " + getString(R.string.int_min); + } + } + String textAll = getString(R.string.ltr_or_rtl_combine_via_colon, text, textValue); + Typeface typeface = FontCache.getRobotoMedium(app); + SpannableString spannableString = UiUtilities.createCustomFontSpannable(typeface, textAll, textValue); + intervalValueView.setText(spannableString); + } + + private void updateIntervalValue() { + if (intervalSlider != null && intervalContainer != null) { + updateIntervalLegend(); + final int secondsLength = SECONDS.length; + final int minutesLength = MINUTES.length; + intervalSlider.setValueTo(secondsLength + minutesLength - 1); + int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode); + UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true); + intervalContainer.setVisibility(View.GONE); + intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() { + + @Override + public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) { + int progress = (int) value; + if (progress == 0) { + settings.SAVE_GLOBAL_TRACK_INTERVAL.set(0); + } else if (progress < secondsLength) { + settings.SAVE_GLOBAL_TRACK_INTERVAL.set(SECONDS[progress] * 1000); + } else { + settings.SAVE_GLOBAL_TRACK_INTERVAL.set(MINUTES[progress - secondsLength] * 60 * 1000); + } + updateIntervalLegend(); + } + }); + + for (int i = 0; i < secondsLength + minutesLength; i++) { + if (i < secondsLength) { + if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) { + intervalSlider.setValues((float) i); + break; + } + } else { + if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= MINUTES[i - secondsLength] * 1000 * 60) { + intervalSlider.setValues((float) i); + break; + } + } + } + } + } + + private void updateIntervalContainer() { + infoExpanded = !infoExpanded; + AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded); + updateUpDownBtn(); + } + + private void updateGlobalRemember() { + if (confirmContainer != null && confirmCompound != null) { + confirmCompound.setChecked(settings.SAVE_GLOBAL_TRACK_REMEMBER.get()); + setShowOnMapBackground(confirmContainer, confirmCompound.isChecked(), nightMode); + } + } + + private void updateUpDownBtn() { + int iconId = infoExpanded ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up; + upDownBtn.setImageDrawable(getContentIcon(iconId)); + } + + private void startRecording() { + SavingTrackHelper helper = app.getSavingTrackHelper(); + helper.startNewSegment(); + settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true); + app.startNavigationService(NavigationService.USED_BY_GPX); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack()); + } + dismiss(); + } + + public void show(String... keys) { + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.show(); + for (String key : keys) { + if (key.equals(UPDATE_TRACK_ICON)) { + updateTrackIcon(app, trackAppearanceIcon); + } + if (key.equals(UPDATE_LOGGING_INTERVAL)) { + updateGlobalRemember(); + updateIntervalValue(); + AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded); + } + } + } + } + + public void hide() { + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.hide(); + } + } + + @Nullable + public MapActivity getMapActivity() { + Activity activity = getActivity(); + if (activity instanceof MapActivity) { + return (MapActivity) activity; + } + return null; + } + + @Override + protected boolean hideButtonsContainer() { + return true; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index e6d39cade8..d71387c0ce 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -61,6 +61,7 @@ import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.audionotes.MultimediaNotesFragment; import net.osmand.plus.development.DevelopmentSettingsFragment; import net.osmand.plus.monitoring.MonitoringSettingsFragment; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.openplacereviews.OprSettingsFragment; import net.osmand.plus.osmedit.OsmEditingFragment; import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment; @@ -85,6 +86,7 @@ import java.io.Serializable; import java.util.Set; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; +import static net.osmand.plus.monitoring.TripRecordingStartingBottomSheet.UPDATE_LOGGING_INTERVAL; public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener, OnPreferenceClickListener, AppModeChangedListener, OnConfirmPreferenceChange { @@ -291,6 +293,15 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } } + @Override + public void onDestroyView() { + super.onDestroyView(); + Fragment target = getTargetFragment(); + if (target instanceof TripRecordingStartingBottomSheet) { + ((TripRecordingStartingBottomSheet) target).show(UPDATE_LOGGING_INTERVAL); + } + } + @Override public void onDetach() { super.onDetach(); @@ -884,21 +895,37 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl } public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType) { - return showInstance(activity, screenType, null); + return showInstance(activity, screenType, (ApplicationMode) null); + } + + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, Fragment target) { + return showInstance(activity, screenType, null, target); } public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode) { return showInstance(activity, screenType, appMode, new Bundle()); } + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode, Fragment target) { + return showInstance(activity, screenType, appMode, new Bundle(), target); + } + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode, @NonNull Bundle args) { + return showInstance(activity, screenType, appMode, args, null); + } + + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, + @Nullable ApplicationMode appMode, @NonNull Bundle args, @Nullable Fragment target) { try { Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName); if (appMode != null) { args.putString(APP_MODE_KEY, appMode.getStringKey()); } fragment.setArguments(args); + if (target != null) { + fragment.setTargetFragment(target, 0); + } activity.getSupportFragmentManager().beginTransaction() .replace(R.id.fragmentContainer, fragment, screenType.fragmentName) .addToBackStack(DRAWER_SETTINGS_ID + ".new") diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index f33571bdd6..807becbb1c 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -37,7 +37,7 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet; -import net.osmand.plus.monitoring.TripRecordingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.settings.backend.CommonPreference; @@ -398,8 +398,8 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement @Override public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingBottomSheet) { - ((TripRecordingBottomSheet) target).show(); + if (target instanceof TripRecordingStartingBottomSheet) { + ((TripRecordingStartingBottomSheet) target).show(UPDATE_TRACK_ICON); } else if (target instanceof TripRecordingActiveBottomSheet) { ((TripRecordingActiveBottomSheet) target).show(UPDATE_TRACK_ICON); } From a8e1d60af1077e0ebbe8ef89957914d465538f93 Mon Sep 17 00:00:00 2001 From: Skalii Date: Thu, 18 Mar 2021 02:41:01 +0200 Subject: [PATCH 06/96] fix bottom buttons width; some fixes; --- ...h_switch_divider_and_additional_button.xml | 16 ++-- .../preference_button_with_icon_triple.xml | 8 +- .../TripRecordingActiveBottomSheet.java | 95 ++++++++++--------- .../TripRecordingStartingBottomSheet.java | 50 +++------- 4 files changed, 73 insertions(+), 96 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml index a10a9eef42..e7b84c5305 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml @@ -66,25 +66,23 @@ + app:cardElevation="0dp" + tools:cardBackgroundColor="?attr/switch_button_active"> - + android:background="?android:attr/selectableItemBackground"> - + diff --git a/OsmAnd/res/layout/preference_button_with_icon_triple.xml b/OsmAnd/res/layout/preference_button_with_icon_triple.xml index 22d68ff090..c8905bbd61 100644 --- a/OsmAnd/res/layout/preference_button_with_icon_triple.xml +++ b/OsmAnd/res/layout/preference_button_with_icon_triple.xml @@ -1,7 +1,5 @@ @@ -28,7 +26,7 @@ android:layout_height="match_parent" android:layout_marginStart="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half" - android:layout_weight="0.5" + android:layout_weight="0.8" android:minWidth="@dimen/button_triple_center_width" android:minHeight="@dimen/setting_list_item_large_height" /> @@ -39,7 +37,7 @@ android:layout_height="match_parent" android:layout_marginStart="@dimen/content_padding_half" android:layout_marginLeft="@dimen/content_padding_half" - android:layout_weight="0.25" + android:layout_weight="0.1" android:minWidth="@dimen/context_menu_top_right_button_min_width" android:minHeight="@dimen/setting_list_item_large_height" /> diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java index 27295899da..7aaa832dd1 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java @@ -6,7 +6,6 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.os.AsyncTask; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.text.format.DateUtils; @@ -29,6 +28,7 @@ import androidx.cardview.widget.CardView; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; @@ -81,7 +81,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen private SelectedGpxFile selectedGpxFile; private View statusContainer; - private LinearLayout buttonAppearance; + private LinearLayout showTrackContainer; private AppCompatImageView trackAppearanceIcon; private View buttonSave; private GpxBlockStatisticsBuilder blockStatisticsBuilder; @@ -161,49 +161,15 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen blockStatisticsBuilder.setBlocksClickable(false); blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode); - LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); - - final CardView buttonShow = showTrackContainer.findViewById(R.id.compound_container); - TextView showTrackTitle = buttonShow.findViewById(R.id.title); - Integer showTitle = ItemType.SHOW_TRACK.getTitleId(); - if (showTitle != null) { - showTrackTitle.setText(showTitle); - } - final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button); - showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); - - buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); + showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); - updateTrackIcon(app, trackAppearanceIcon); - buttonAppearance.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (showTrackCompound.isChecked()) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { + createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, + ItemType.SHOW_TRACK.getTitleId(), TripRecordingActiveBottomSheet.this, new Runnable() { + @Override + public void run() { hide(); - SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingActiveBottomSheet.this); } - } - } - }); - createItem(buttonAppearance, ItemType.APPEARANCE, showTrackCompound.isChecked()); - setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - buttonShow.setBackgroundTintList(null); - } - buttonShow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean checked = !showTrackCompound.isChecked(); - showTrackCompound.setChecked(checked); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); - createItem(buttonAppearance, ItemType.APPEARANCE, checked); - setShowOnMapBackground(buttonShow, checked, nightMode); - } - }); + }); buttonClear.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { @Override @@ -309,6 +275,49 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } + public static void createShowTrackItem(final OsmandApplication app, final MapActivity mapActivity, + final boolean nightMode, LinearLayout showTrackContainer, + AppCompatImageView trackAppearanceIcon, Integer showTrackId, + final Fragment target, final Runnable hideOnClickButtonAppearance) { + final CardView buttonShowTrack = showTrackContainer.findViewById(R.id.compound_container); + final CardView buttonAppearance = showTrackContainer.findViewById(R.id.additional_button_container); + + TextView showTrackTextView = buttonShowTrack.findViewById(R.id.title); + if (showTrackId != null) { + showTrackTextView.setText(showTrackId); + } + final CompoundButton showTrackCompound = buttonShowTrack.findViewById(R.id.compound_button); + showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); + UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); + + setShowOnMapBackground(buttonShowTrack, showTrackCompound.isChecked(), nightMode); + buttonShowTrack.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + boolean checked = !showTrackCompound.isChecked(); + showTrackCompound.setChecked(checked); + app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); + setShowOnMapBackground(buttonShowTrack, checked, nightMode); + createItem(app, nightMode, buttonAppearance, ItemType.APPEARANCE, checked, null); + } + }); + + updateTrackIcon(app, trackAppearanceIcon); + createItem(app, nightMode, buttonAppearance, ItemType.APPEARANCE, showTrackCompound.isChecked(), null); + buttonAppearance.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (showTrackCompound.isChecked()) { + if (mapActivity != null) { + hideOnClickButtonAppearance.run(); + SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, target); + } + } + } + }); + } + private void createItem(View view, ItemType type, boolean enabled) { createItem(app, nightMode, view, type, enabled, null); } @@ -558,11 +567,11 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( context, normalColorId, getActiveTextColorId(nightMode) ); - DrawableCompat.setTintList(background, iconColorStateList); if (view instanceof CardView) { ((CardView) view).setCardBackgroundColor(iconColorStateList); return; } + DrawableCompat.setTintList(background, iconColorStateList); } else { UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java index 7f19ea13fb..c03a568137 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -4,12 +4,10 @@ import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.graphics.Typeface; -import android.os.Build; import android.os.Bundle; import android.text.SpannableString; import android.view.LayoutInflater; import android.view.View; -import android.widget.CompoundButton; import android.widget.LinearLayout; import android.widget.TextView; @@ -22,7 +20,6 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.slider.RangeSlider; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -37,13 +34,13 @@ import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; -import net.osmand.plus.track.TrackAppearanceFragment; import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem; +import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createShowTrackItem; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.setShowOnMapBackground; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon; @@ -60,6 +57,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm private CardView confirmContainer; private SwitchCompat confirmCompound; private TextView intervalValueView; + private LinearLayout showTrackContainer; private LinearLayout intervalContainer; private RangeSlider intervalSlider; @@ -100,6 +98,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm confirmContainer = itemView.findViewById(R.id.confirm_container); confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button); + UiUtilities.setupCompoundButton(confirmCompound, nightMode, GLOBAL); updateGlobalRemember(); confirmContainer.setOnClickListener(new View.OnClickListener() { @Override @@ -111,42 +110,15 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm } }); - LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); - - final CardView buttonShow = itemView.findViewById(R.id.compound_container); - TextView showTrackTitle = buttonShow.findViewById(R.id.title); - showTrackTitle.setText(R.string.show_track_on_map); - final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button); - showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); - UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); - - LinearLayout buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); + showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); - updateTrackIcon(app, trackAppearanceIcon); - buttonAppearance.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - hide(); - SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingStartingBottomSheet.this); - } - } - }); - setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - buttonShow.setBackgroundTintList(null); - } - buttonShow.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean checked = !showTrackCompound.isChecked(); - showTrackCompound.setChecked(checked); - app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); - setShowOnMapBackground(buttonShow, checked, nightMode); - } - }); + createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, + R.string.show_track_on_map, TripRecordingStartingBottomSheet.this, new Runnable() { + @Override + public void run() { + hide(); + } + }); updateUpDownBtn(); From c7fa20cc69f6ce5aae10208e97fc524628304545 Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 19 Mar 2021 14:30:56 +0200 Subject: [PATCH 07/96] remove confirm toggle; fix dialog title; --- .../trip_recording_starting_fragment.xml | 49 +------------------ .../TripRecordingStartingBottomSheet.java | 29 +---------- 2 files changed, 3 insertions(+), 75 deletions(-) diff --git a/OsmAnd/res/layout/trip_recording_starting_fragment.xml b/OsmAnd/res/layout/trip_recording_starting_fragment.xml index 809cc015ac..3c76b1e050 100644 --- a/OsmAnd/res/layout/trip_recording_starting_fragment.xml +++ b/OsmAnd/res/layout/trip_recording_starting_fragment.xml @@ -92,55 +92,10 @@ app:trackHeight="@dimen/slider_track_height" tools:visibility="visible" /> - - - - - - - - - - - - @@ -149,7 +104,7 @@ + android:layout_height="@dimen/context_menu_first_line_top_margin" /> diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java index c03a568137..c8c96d1323 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -14,7 +14,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; -import androidx.appcompat.widget.SwitchCompat; import androidx.cardview.widget.CardView; import androidx.fragment.app.FragmentManager; @@ -35,13 +34,11 @@ import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; -import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createShowTrackItem; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.setShowOnMapBackground; import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon; public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragment { @@ -54,8 +51,6 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm private AppCompatImageView upDownBtn; private AppCompatImageView trackAppearanceIcon; - private CardView confirmContainer; - private SwitchCompat confirmCompound; private TextView intervalValueView; private LinearLayout showTrackContainer; private LinearLayout intervalContainer; @@ -96,24 +91,10 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm intervalSlider = itemView.findViewById(R.id.interval_slider); updateIntervalValue(); - confirmContainer = itemView.findViewById(R.id.confirm_container); - confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button); - UiUtilities.setupCompoundButton(confirmCompound, nightMode, GLOBAL); - updateGlobalRemember(); - confirmContainer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean checked = !confirmCompound.isChecked(); - confirmCompound.setChecked(checked); - settings.SAVE_GLOBAL_TRACK_REMEMBER.set(checked); - setShowOnMapBackground(confirmContainer, checked, nightMode); - } - }); - showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, - R.string.show_track_on_map, TripRecordingStartingBottomSheet.this, new Runnable() { + R.string.shared_string_show_on_map, TripRecordingStartingBottomSheet.this, new Runnable() { @Override public void run() { hide(); @@ -221,13 +202,6 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm updateUpDownBtn(); } - private void updateGlobalRemember() { - if (confirmContainer != null && confirmCompound != null) { - confirmCompound.setChecked(settings.SAVE_GLOBAL_TRACK_REMEMBER.get()); - setShowOnMapBackground(confirmContainer, confirmCompound.isChecked(), nightMode); - } - } - private void updateUpDownBtn() { int iconId = infoExpanded ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up; upDownBtn.setImageDrawable(getContentIcon(iconId)); @@ -254,7 +228,6 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm updateTrackIcon(app, trackAppearanceIcon); } if (key.equals(UPDATE_LOGGING_INTERVAL)) { - updateGlobalRemember(); updateIntervalValue(); AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded); } From 94c58edb7c0206b400a6773854cbde24a272670e Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 19 Mar 2021 14:57:55 +0200 Subject: [PATCH 08/96] redesign trip recording dialog; add options dialog; --- .../layout/bottom_sheet_button_with_icon.xml | 8 +- .../layout/trip_recording_active_fragment.xml | 172 ------- OsmAnd/res/layout/trip_recording_fragment.xml | 91 ++++ OsmAnd/res/values/strings.xml | 2 + .../osmand/plus/activities/MapActivity.java | 6 +- .../plus/activities/MapActivityActions.java | 8 +- .../liveupdates/LiveUpdatesFragmentNew.java | 6 +- .../monitoring/OsmandMonitoringPlugin.java | 54 ++- ....java => TripRecordingBottomFragment.java} | 442 +++++++----------- ...TripRecordingClearDataBottomFragment.java} | 33 +- ...> TripRecordingDiscardBottomFragment.java} | 81 +--- .../TripRecordingOptionsBottomFragment.java | 350 ++++++++++++++ ... TripRecordingStartingBottomFragment.java} | 28 +- .../BooleanPreferenceBottomSheet.java | 4 +- .../fragments/BaseSettingsFragment.java | 8 +- .../plus/track/TrackAppearanceFragment.java | 14 +- 16 files changed, 728 insertions(+), 579 deletions(-) delete mode 100644 OsmAnd/res/layout/trip_recording_active_fragment.xml create mode 100644 OsmAnd/res/layout/trip_recording_fragment.xml rename OsmAnd/src/net/osmand/plus/monitoring/{TripRecordingActiveBottomSheet.java => TripRecordingBottomFragment.java} (65%) rename OsmAnd/src/net/osmand/plus/monitoring/{ClearRecordedDataBottomSheetFragment.java => TripRecordingClearDataBottomFragment.java} (71%) rename OsmAnd/src/net/osmand/plus/monitoring/{StopTrackRecordingBottomFragment.java => TripRecordingDiscardBottomFragment.java} (50%) create mode 100644 OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomFragment.java rename OsmAnd/src/net/osmand/plus/monitoring/{TripRecordingStartingBottomSheet.java => TripRecordingStartingBottomFragment.java} (88%) diff --git a/OsmAnd/res/layout/bottom_sheet_button_with_icon.xml b/OsmAnd/res/layout/bottom_sheet_button_with_icon.xml index 7c56093fbc..8dd296f01b 100644 --- a/OsmAnd/res/layout/bottom_sheet_button_with_icon.xml +++ b/OsmAnd/res/layout/bottom_sheet_button_with_icon.xml @@ -3,14 +3,13 @@ xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + tools:background="@drawable/btn_background_inactive_dark"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OsmAnd/res/layout/trip_recording_fragment.xml b/OsmAnd/res/layout/trip_recording_fragment.xml new file mode 100644 index 0000000000..68e449cdf3 --- /dev/null +++ b/OsmAnd/res/layout/trip_recording_fragment.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 93cfd93231..21bb56470e 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,8 @@ Thx - Hardy --> + All unsaved data will be lost. + Save and continue Logging interval set time period in which OsmAnd will ask for the current location position data. Please select another type of colorization. The track does not contain speed data. diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 487f4d902f..58e46db8ac 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -104,7 +104,7 @@ import net.osmand.plus.measurementtool.LoginBottomSheetFragment; import net.osmand.plus.measurementtool.MeasurementEditingContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.SnapTrackWarningFragment; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomFragment; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; @@ -2241,8 +2241,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(MeasurementToolFragment.TAG); } - public TripRecordingStartingBottomSheet getTripRecordingBottomSheet() { - return getFragment(TripRecordingStartingBottomSheet.TAG); + public TripRecordingStartingBottomFragment getTripRecordingBottomSheet() { + return getFragment(TripRecordingStartingBottomFragment.TAG); } public ChooseRouteFragment getChooseRouteFragment() { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index ff78335e74..c51ed68f32 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -62,8 +62,8 @@ import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; -import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingBottomFragment; +import net.osmand.plus.monitoring.TripRecordingStartingBottomFragment; import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment; import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataUtils; @@ -854,9 +854,9 @@ public class MapActivityActions implements DialogProvider { app.logEvent("trip_recording_open"); MapActivity.clearPrevActivityIntent(); if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) { - TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack()); + TripRecordingBottomFragment.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack()); } else { - TripRecordingStartingBottomSheet.showInstance(mapActivity.getSupportFragmentManager()); + TripRecordingStartingBottomFragment.showInstance(mapActivity.getSupportFragmentManager()); } return true; } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java index 756f6a3551..4eb764da2d 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java @@ -85,9 +85,9 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFreq import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getTertiaryTextColorId; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getActiveTextColorId; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getOsmandIconColorId; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getSecondaryIconColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.getActiveTextColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.getOsmandIconColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.getSecondaryIconColorId; public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements OnLiveUpdatesForLocalChange { diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 4fa978a8d6..de95978f7d 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -41,13 +41,16 @@ import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.OsmandMapLayer.DrawSettings; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.MapInfoLayer; import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget; import net.osmand.util.Algorithms; +import java.io.File; import java.lang.ref.WeakReference; +import java.util.Collections; import java.util.List; import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT; @@ -329,9 +332,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { public void controlDialog(final Activity activity, final boolean showTrackSelection) { FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager(); if (hasDataToSave() || wasTrackMonitored()) { - TripRecordingActiveBottomSheet.showInstance(fragmentManager, getCurrentTrack()); + TripRecordingBottomFragment.showInstance(fragmentManager, getCurrentTrack()); } else { - TripRecordingStartingBottomSheet.showInstance(fragmentManager); + TripRecordingStartingBottomFragment.showInstance(fragmentManager); } /*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); @@ -436,16 +439,22 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { } public void saveCurrentTrack() { - saveCurrentTrack(null, null); + saveCurrentTrack(null, null, true, false); } public void saveCurrentTrack(@Nullable final Runnable onComplete) { - saveCurrentTrack(onComplete, null); + saveCurrentTrack(onComplete, null, true, false); } public void saveCurrentTrack(@Nullable final Runnable onComplete, @Nullable Activity activity) { - stopRecording(); + saveCurrentTrack(onComplete, activity, true, false); + } + public void saveCurrentTrack(@Nullable final Runnable onComplete, @Nullable Activity activity, + final boolean stopRecording, final boolean openTrack) { + if (stopRecording) { + stopRecording(); + } final WeakReference activityRef = activity != null ? new WeakReference<>(activity) : null; app.getTaskManager().runInBackground(new OsmAndTaskRunnable() { @@ -461,7 +470,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { try { SavingTrackHelper helper = app.getSavingTrackHelper(); SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir()); - helper.close(); + if (stopRecording) { + helper.close(); + } return result; } catch (Exception e) { e.printStackTrace(); @@ -474,10 +485,31 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { isSaving = false; app.getNotificationHelper().refreshNotifications(); updateControl(); - if (activityRef != null && !Algorithms.isEmpty(result.getFilenames())) { - final Activity a = activityRef.get(); - if (a instanceof FragmentActivity && !a.isFinishing()) { - SaveGPXBottomSheetFragment.showInstance(((FragmentActivity) a).getSupportFragmentManager(), result.getFilenames()); + + File file = null; + File dir = app.getAppCustomization().getTracksDir(); + File[] children = dir.listFiles(); + if (children != null && !Algorithms.isEmpty(result.getFilenames())) { + SavingTrackHelper helper = app.getSavingTrackHelper(); + for (File child : children) { + if (child.getName().startsWith(result.getFilenames().get(0)) + && child.lastModified() == helper.getLastTimeFileSaved()) { + file = child; + } + } + } + if (file != null && file.exists()) { + if (!openTrack) { + if (activityRef != null) { + final Activity a = activityRef.get(); + if (a instanceof FragmentActivity && !a.isFinishing()) { + List singleName = Collections.singletonList(Algorithms.getFileNameWithoutExtension(file)); + SaveGPXBottomSheetFragment.showInstance(((FragmentActivity) a) + .getSupportFragmentManager(), singleName); + } + } + } else { + TrackMenuFragment.openTrack(mapActivity, file, null); } } @@ -523,7 +555,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { runnable.run(); } else if (map instanceof FragmentActivity) { FragmentActivity activity = (FragmentActivity) map; - TripRecordingStartingBottomSheet.showInstance(activity.getSupportFragmentManager()); + TripRecordingStartingBottomFragment.showInstance(activity.getSupportFragmentManager()); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java similarity index 65% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java index 7aaa832dd1..471ec813a6 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java @@ -5,11 +5,8 @@ import android.app.Dialog; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; -import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; -import android.text.format.DateUtils; -import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.widget.CompoundButton; @@ -25,59 +22,55 @@ import androidx.annotation.StringRes; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.widget.AppCompatImageView; import androidx.cardview.widget.CardView; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.recyclerview.widget.RecyclerView; -import com.google.android.material.snackbar.Snackbar; - import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXFile; -import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.SavingTrackHelper; -import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.myplaces.SaveCurrentTrackTask; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.track.GpxBlockStatisticsBuilder; -import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.track.TrackAppearanceFragment; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; -import java.lang.ref.WeakReference; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static net.osmand.AndroidUtils.getSecondaryTextColorId; +import static net.osmand.AndroidUtils.setPadding; import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL; -public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment { +public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment { - public static final String TAG = TripRecordingActiveBottomSheet.class.getSimpleName(); - private static final Log log = PlatformUtil.getLog(TripRecordingActiveBottomSheet.class); - private static final String UPDATE_CURRENT_GPX_FILE = "update_current_gpx_file"; + public static final String TAG = TripRecordingBottomFragment.class.getSimpleName(); + private static final Log LOG = PlatformUtil.getLog(TripRecordingBottomFragment.class); + private static final String SAVE_CURRENT_GPX_FILE = "save_current_gpx_file"; public static final String UPDATE_TRACK_ICON = "update_track_icon"; - private static final int GENERAL_UPDATE_GPS_INTERVAL = 1000; - private static final int GENERAL_UPDATE_SAVE_INTERVAL = 1000; + private static final int GPS_UPDATE_INTERVAL = 1000; private OsmandApplication app; private OsmandSettings settings; - private SavingTrackHelper helper; + private OsmandMonitoringPlugin plugin; + + private View statusContainer; + private AppCompatImageView trackAppearanceIcon; + private GpxBlockStatisticsBuilder blockStatisticsBuilder; + private SelectedGpxFile selectedGpxFile; private View statusContainer; @@ -88,7 +81,6 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen private final Handler handler = new Handler(); private Runnable updatingGPS; - private Runnable updatingTimeTrackSaved; private GPXFile getGPXFile() { return selectedGpxFile.getGpxFile(); @@ -98,21 +90,21 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen this.selectedGpxFile = selectedGpxFile; } - public boolean hasDataToSave() { + private boolean hasDataToSave() { return app.getSavingTrackHelper().hasDataToSave(); } - public boolean searchingGPS() { + private boolean searchingGPS() { return app.getLocationProvider().getLastKnownLocation() == null; } - public boolean wasTrackMonitored() { + private boolean wasTrackMonitored() { return settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); } public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) { if (!fragmentManager.isStateSaved()) { - TripRecordingActiveBottomSheet fragment = new TripRecordingActiveBottomSheet(); + TripRecordingBottomFragment fragment = new TripRecordingBottomFragment(); fragment.setSelectedGpxFile(selectedGpxFile); fragment.show(fragmentManager, TAG); } @@ -122,37 +114,22 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen public void createMenuItems(Bundle savedInstanceState) { app = requiredMyApplication(); settings = app.getSettings(); - helper = app.getSavingTrackHelper(); + plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode); final FragmentManager fragmentManager = getFragmentManager(); - View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false); + View itemView = inflater.inflate(R.layout.trip_recording_fragment, null, false); items.add(new BaseBottomSheetItem.Builder() .setCustomView(itemView) .create()); - View buttonClear = itemView.findViewById(R.id.button_clear); - final View buttonOnline = itemView.findViewById(R.id.button_online); - final View buttonSegment = itemView.findViewById(R.id.button_segment); - buttonSave = itemView.findViewById(R.id.button_save); - final View buttonPause = itemView.findViewById(R.id.button_pause); - View buttonStop = itemView.findViewById(R.id.button_stop); - - createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave()); - createItem(buttonOnline, ItemType.STOP_ONLINE, hasDataToSave()); - createItem(buttonSegment, ItemType.START_NEW_SEGMENT, wasTrackMonitored()); - createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true); - createItem(buttonStop, ItemType.STOP, true); - - AndroidUiHelper.updateVisibility(buttonOnline, app.getLiveMonitoringHelper().isLiveMonitoringEnabled()); - statusContainer = itemView.findViewById(R.id.status_container); updateStatus(); RecyclerView statBlocks = itemView.findViewById(R.id.block_statistics); if (savedInstanceState != null) { - if (savedInstanceState.containsKey(UPDATE_CURRENT_GPX_FILE) - && savedInstanceState.getBoolean(UPDATE_CURRENT_GPX_FILE)) { + if (savedInstanceState.containsKey(SAVE_CURRENT_GPX_FILE) + && savedInstanceState.getBoolean(SAVE_CURRENT_GPX_FILE)) { selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); } } @@ -161,63 +138,28 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen blockStatisticsBuilder.setBlocksClickable(false); blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode); - showTrackContainer = itemView.findViewById(R.id.show_track_on_map); + LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, - ItemType.SHOW_TRACK.getTitleId(), TripRecordingActiveBottomSheet.this, new Runnable() { + ItemType.SHOW_TRACK.getTitleId(), TripRecordingBottomFragment.this, new Runnable() { @Override public void run() { hide(); } }); - buttonClear.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { + CardView cardLeft = itemView.findViewById(R.id.button_left); + createItem(cardLeft, ItemType.CANCEL); + cardLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (fragmentManager != null && hasDataToSave()) { - ClearRecordedDataBottomSheetFragment.showInstance(fragmentManager, TripRecordingActiveBottomSheet.this); - } + dismiss(); } }); - buttonOnline.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - settings.LIVE_MONITORING.set(false); - AndroidUiHelper.updateVisibility(buttonOnline, false); - } - }); - - buttonSegment.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (wasTrackMonitored()) { - blockStatisticsBuilder.stopUpdatingStatBlocks(); - helper.startNewSegment(); - blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); - } - } - }); - - buttonSave.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (hasDataToSave()) { - final GPXFile gpxFile = getGPXFile(); - new SaveCurrentTrackTask(app, gpxFile, createSaveListener(new Runnable() { - @Override - public void run() { - blockStatisticsBuilder.stopUpdatingStatBlocks(); - blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); - stopUpdatingTimeTrackSaved(); - runUpdatingTimeTrackSaved(); - } - })).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } - } - }); - - buttonPause.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { + final CardView cardCenterLeft = itemView.findViewById(R.id.button_center_left); + createItem(cardCenterLeft, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME); + cardCenterLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean wasTrackMonitored = !wasTrackMonitored(); @@ -228,19 +170,94 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored); updateStatus(); - createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true); - createItem(buttonSegment, ItemType.START_NEW_SEGMENT, wasTrackMonitored); + createItem(cardCenterLeft, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME); } }); - buttonStop.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() { + CardView cardCenterRight = itemView.findViewById(R.id.button_center_right); + createItem(cardCenterRight, ItemType.FINISH); + cardCenterRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (fragmentManager != null) { - StopTrackRecordingBottomFragment.showInstance(getMapActivity(), fragmentManager, TripRecordingActiveBottomSheet.this); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null && plugin != null && app.getSavingTrackHelper().hasDataToSave()) { + plugin.saveCurrentTrack(null, mapActivity); + app.getNotificationHelper().refreshNotifications(); + dismiss(); } } }); + + CardView cardRight = itemView.findViewById(R.id.button_right); + createItem(cardRight, ItemType.OPTIONS); + cardRight.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (fragmentManager != null) { + TripRecordingOptionsBottomFragment.showInstance(fragmentManager, TripRecordingBottomFragment.this, selectedGpxFile); + } + } + }); + + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(SAVE_CURRENT_GPX_FILE, true); + } + + @Override + public void onResume() { + super.onResume(); + blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); + runUpdatingGPS(); + } + + @Override + public void onPause() { + super.onPause(); + blockStatisticsBuilder.stopUpdatingStatBlocks(); + stopUpdatingGPS(); + } + + public void show() { + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.show(); + } + } + + public void show(String... keys) { + show(); + for (String key : keys) { + if (key.equals(UPDATE_TRACK_ICON)) { + updateTrackIcon(app, trackAppearanceIcon); + } + } + } + + public void hide() { + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.hide(); + } + } + + public void stopUpdatingGPS() { + handler.removeCallbacks(updatingGPS); + } + + public void runUpdatingGPS() { + updatingGPS = new Runnable() { + @Override + public void run() { + int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); + updateStatus(); + handler.postDelayed(this, Math.max(GPS_UPDATE_INTERVAL, interval)); + } + }; + handler.post(updatingGPS); } private void updateStatus() { @@ -290,14 +307,14 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL); - setShowOnMapBackground(buttonShowTrack, showTrackCompound.isChecked(), nightMode); + setShowTrackItemBackground(buttonShowTrack, showTrackCompound.isChecked(), nightMode); buttonShowTrack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { boolean checked = !showTrackCompound.isChecked(); showTrackCompound.setChecked(checked); app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); - setShowOnMapBackground(buttonShowTrack, checked, nightMode); + setShowTrackItemBackground(buttonShowTrack, checked, nightMode); createItem(app, nightMode, buttonAppearance, ItemType.APPEARANCE, checked, null); } }); @@ -318,30 +335,31 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen }); } - private void createItem(View view, ItemType type, boolean enabled) { - createItem(app, nightMode, view, type, enabled, null); + protected static void setShowTrackItemBackground(View view, boolean checked, boolean nightMode) { + int background = checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode); + view.setBackgroundResource(background); } - private void createItem(View view, ItemType type, boolean enabled, @Nullable String description) { - createItem(app, nightMode, view, type, enabled, description); + private void createItem(View view, ItemType type) { + createItem(app, nightMode, view, type, true, null); } public static View createItem(Context context, boolean nightMode, LayoutInflater inflater, ItemType type) { + return createItem(context, nightMode, inflater, type, true, null); + } + + public static View createItem(Context context, boolean nightMode, LayoutInflater inflater, ItemType type, boolean enabled, String description) { View button = inflater.inflate(R.layout.bottom_sheet_button_with_icon, null); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); int horizontal = context.getResources().getDimensionPixelSize(R.dimen.content_padding); params.setMargins(horizontal, 0, horizontal, 0); button.setLayoutParams(params); - LinearLayout container = button.findViewById(R.id.button_container); - container.setClickable(false); - container.setFocusable(false); - createItem(context, nightMode, button, type, true, null); + createItem(context, nightMode, button, type, enabled, description); return button; } public static void createItem(Context context, boolean nightMode, View view, ItemType type, boolean enabled, @Nullable String description) { view.setTag(type); - LinearLayout button = view.findViewById(R.id.button_container); AppCompatImageView icon = view.findViewById(R.id.icon); if (icon != null) { @@ -367,151 +385,26 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen setTextColor(context, desc, false, nightMode, type); } - setItemBackground(context, nightMode, button != null ? button : view, enabled); + setItemBackground(context, nightMode, view, enabled); } - private String getTimeTrackSaved() { - long timeTrackSaved = helper.getLastTimeFileSaved(); - if (timeTrackSaved != 0) { - long now = System.currentTimeMillis(); - CharSequence time = DateUtils.getRelativeTimeSpanString(timeTrackSaved, now, DateUtils.MINUTE_IN_MILLIS); - return String.valueOf(time); + public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) { + Drawable background = AppCompatResources.getDrawable(context, R.drawable.btn_background_inactive_light); + if (background != null && enabled) { + int normalColorId = view instanceof CardView + ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode); + ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( + context, normalColorId, getActiveTextColorId(nightMode) + ); + if (view instanceof CardView) { + ((CardView) view).setCardBackgroundColor(iconColorStateList); + return; + } + DrawableCompat.setTintList(background, iconColorStateList); } else { - return null; - } - } - - @Override - public void onSaveInstanceState(@NonNull Bundle outState) { - super.onSaveInstanceState(outState); - outState.putBoolean(UPDATE_CURRENT_GPX_FILE, true); - } - - @Override - public void onResume() { - super.onResume(); - blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); - runUpdatingGPS(); - runUpdatingTimeTrackSaved(); - } - - @Override - public void onPause() { - super.onPause(); - blockStatisticsBuilder.stopUpdatingStatBlocks(); - stopUpdatingGPS(); - stopUpdatingTimeTrackSaved(); - } - - public void stopUpdatingGPS() { - handler.removeCallbacks(updatingGPS); - } - - public void runUpdatingGPS() { - updatingGPS = new Runnable() { - @Override - public void run() { - int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); - updateStatus(); - handler.postDelayed(this, Math.max(GENERAL_UPDATE_GPS_INTERVAL, interval)); - } - }; - handler.post(updatingGPS); - } - - public void stopUpdatingTimeTrackSaved() { - handler.removeCallbacks(updatingTimeTrackSaved); - } - - public void runUpdatingTimeTrackSaved() { - updatingTimeTrackSaved = new Runnable() { - @Override - public void run() { - String time = getTimeTrackSaved(); - createItem(buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null); - handler.postDelayed(this, GENERAL_UPDATE_SAVE_INTERVAL); - } - }; - handler.post(updatingTimeTrackSaved); - } - - private SaveGpxListener createSaveListener(@Nullable final Runnable callback) { - return new SaveGpxListener() { - - @Override - public void gpxSavingStarted() { - } - - @Override - public void gpxSavingFinished(Exception errorMessage) { - final MapActivity mapActivity = getMapActivity(); - final Context context = getContext(); - final SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir()); - ArrayList filenames = new ArrayList<>(result.getFilenames()); - String fileName = ""; - if (filenames.size() > 0) { - fileName = filenames.get(filenames.size() - 1) + IndexConstants.GPX_FILE_EXT; - } - String message = fileName + " " + app.getResources().getString(R.string.shared_string_is_saved) + ". " - + app.getResources().getString(R.string.track_recording_will_be_continued); - if (mapActivity != null && context != null) { - final WeakReference mapActivityRef = new WeakReference<>(mapActivity); - final FragmentManager fragmentManager = mapActivityRef.get().getSupportFragmentManager(); - Snackbar snackbar = Snackbar.make(getView(), - message, - Snackbar.LENGTH_LONG) - .setAction(R.string.shared_string_rename, new View.OnClickListener() { - @Override - public void onClick(View view) { - fragmentManager.beginTransaction().remove(TripRecordingActiveBottomSheet.this).commitAllowingStateLoss(); - SaveGPXBottomSheetFragment.showInstance(fragmentManager, result.getFilenames()); - } - }); - View view = snackbar.getView(); - CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) view.getLayoutParams(); - params.gravity = Gravity.TOP; - AndroidUtils.setMargins(params, 0, AndroidUtils.getStatusBarHeight(context), 0, 0); - view.setLayoutParams(params); - UiUtilities.setupSnackbar(snackbar, nightMode); - snackbar.show(); - if (callback != null) { - callback.run(); - } - } - } - }; - } - - @Nullable - public MapActivity getMapActivity() { - Activity activity = getActivity(); - if (activity instanceof MapActivity) { - return (MapActivity) activity; - } - return null; - } - - public void show() { - Dialog dialog = getDialog(); - if (dialog != null) { - dialog.show(); - } - } - - public void show(String... keys) { - show(); - for (String key : keys) { - if (key.equals(UPDATE_TRACK_ICON)) { - updateTrackIcon(app, trackAppearanceIcon); - } - } - } - - public void hide() { - Dialog dialog = getDialog(); - if (dialog != null) { - dialog.hide(); + UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); } + view.setBackgroundDrawable(background); } public enum ItemType { @@ -522,7 +415,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen ON_PAUSE(R.string.on_pause, R.drawable.ic_pause), CLEAR_DATA(R.string.clear_recorded_data, R.drawable.ic_action_delete_dark), START_NEW_SEGMENT(R.string.gpx_start_new_segment, R.drawable.ic_action_new_segment), - SAVE(R.string.shared_string_save, R.drawable.ic_action_save_to_file), + SAVE(R.string.trip_recording_save_and_continue, R.drawable.ic_action_save_to_file), PAUSE(R.string.shared_string_pause, R.drawable.ic_pause), RESUME(R.string.shared_string_resume, R.drawable.ic_play_dark), STOP(R.string.shared_string_control_stop, R.drawable.ic_action_rec_stop), @@ -531,7 +424,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close), START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement), - SETTINGS(R.string.shared_string_settings, R.drawable.ic_action_settings); + SETTINGS(R.string.shared_string_settings, R.drawable.ic_action_settings), + FINISH(R.string.shared_string_finish, R.drawable.ic_action_point_destination), + OPTIONS(R.string.shared_string_options, R.drawable.ic_overflow_menu_with_background); @StringRes private final Integer titleId; @@ -559,31 +454,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } - public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) { - Drawable background = AppCompatResources.getDrawable(context, R.drawable.btn_background_inactive_light); - if (background != null && enabled) { - int normalColorId = view instanceof CardView - ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode); - ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( - context, normalColorId, getActiveTextColorId(nightMode) - ); - if (view instanceof CardView) { - ((CardView) view).setCardBackgroundColor(iconColorStateList); - return; - } - DrawableCompat.setTintList(background, iconColorStateList); - } else { - UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); - } - view.setBackgroundDrawable(background); - } - - public static void setShowOnMapBackground(View view, boolean checked, boolean nightMode) { - int background = checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode); - view.setBackgroundResource(background); - } - - public static void setTextColor(Context context, TextView tv, boolean enabled, boolean nightMode, ItemType type) { + protected static void setTextColor(Context context, TextView tv, boolean enabled, boolean nightMode, ItemType type) { if (tv != null) { int activeColorId = type.isNegative() ? R.color.color_osm_edit_delete : getActiveTextColorId(nightMode); int normalColorId = enabled ? activeColorId : getSecondaryTextColorId(nightMode); @@ -592,7 +463,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } } - public static void setTintedIcon(Context context, AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) { + protected static void setTintedIcon(Context context, AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) { Integer iconId = type.getIconId(); if (iv != null && iconId != null) { Drawable icon = AppCompatResources.getDrawable(context, iconId); @@ -607,6 +478,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen int stopSize = iv.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(stopSize, stopSize); iv.setLayoutParams(params); + View container = (View) iv.getParent(); + setPadding(container, container.getPaddingLeft(), container.getTop(), + context.getResources().getDimensionPixelSize(R.dimen.content_padding_half), container.getBottom()); } } } @@ -662,17 +536,17 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } @Override - protected int getDismissButtonHeight() { - return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); - } - - @Override - protected int getDismissButtonTextId() { - return R.string.shared_string_close; - } - - @Override - protected boolean useVerticalButtons() { + protected boolean hideButtonsContainer() { return true; } + + @Nullable + public MapActivity getMapActivity() { + Activity activity = getActivity(); + if (activity instanceof MapActivity) { + return (MapActivity) activity; + } + return null; + } + } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/ClearRecordedDataBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomFragment.java similarity index 71% rename from OsmAnd/src/net/osmand/plus/monitoring/ClearRecordedDataBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomFragment.java index 9a5e40ab95..e51911c867 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/ClearRecordedDataBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomFragment.java @@ -11,21 +11,24 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; -import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType; +import net.osmand.plus.monitoring.TripRecordingBottomFragment.ItemType; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; -public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogFragment { +import static net.osmand.AndroidUtils.getPrimaryTextColorId; +import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.*; - public static final String TAG = ClearRecordedDataBottomSheetFragment.class.getSimpleName(); +public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogFragment { + + public static final String TAG = TripRecordingClearDataBottomFragment.class.getSimpleName(); private OsmandApplication app; public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) { if (!fragmentManager.isStateSaved()) { - ClearRecordedDataBottomSheetFragment fragment = new ClearRecordedDataBottomSheetFragment(); + TripRecordingClearDataBottomFragment fragment = new TripRecordingClearDataBottomFragment(); fragment.setTargetFragment(target, 0); fragment.show(fragmentManager, TAG); } @@ -37,14 +40,14 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin); int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding); - + String description = getString(R.string.clear_recorded_data_warning) + .concat(getString(R.string.lost_data_warning)); final View buttonClear = createItem(inflater, ItemType.CLEAR_DATA); final View buttonCancel = createItem(inflater, ItemType.CANCEL); items.add(new BottomSheetItemWithDescription.Builder() - .setDescription(app.getString(R.string.clear_recorded_data_warning)) - .setDescriptionColorId(!nightMode ? R.color.text_color_primary_light : R.color.text_color_primary_dark) - .setDescriptionMaxLines(2) + .setDescription(description) + .setDescriptionColorId(getPrimaryTextColorId(nightMode)) .setTitle(app.getString(R.string.clear_recorded_data)) .setLayoutId(R.layout.bottom_sheet_item_title_with_description) .create()); @@ -58,6 +61,7 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF public void onClick(View v) { app.getSavingTrackHelper().clearRecordedData(true); dismiss(); + dismissTargetDialog(TripRecordingClearDataBottomFragment.this, TripRecordingOptionsBottomFragment.class); } }) .create()); @@ -78,15 +82,15 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF } private View createItem(LayoutInflater inflater, ItemType type) { - return TripRecordingActiveBottomSheet.createItem(app, nightMode, inflater, type); + return TripRecordingBottomFragment.createItem(app, nightMode, inflater, type); } @Override public void onResume() { super.onResume(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingActiveBottomSheet) { - ((TripRecordingActiveBottomSheet) target).hide(); + if (target instanceof TripRecordingOptionsBottomFragment) { + ((TripRecordingOptionsBottomFragment) target).hide(); } } @@ -94,8 +98,8 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF public void onPause() { super.onPause(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingActiveBottomSheet) { - ((TripRecordingActiveBottomSheet) target).show(); + if (target instanceof TripRecordingOptionsBottomFragment) { + ((TripRecordingOptionsBottomFragment) target).show(); } } @@ -103,4 +107,5 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF protected boolean hideButtonsContainer() { return true; } -} \ No newline at end of file + +} diff --git a/OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomFragment.java similarity index 50% rename from OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomFragment.java index f648c5bbdf..971d7399e1 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/StopTrackRecordingBottomFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomFragment.java @@ -8,36 +8,29 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; -import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; -import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType; -import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.monitoring.TripRecordingBottomFragment.ItemType; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; -public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragment { +import static net.osmand.AndroidUtils.getPrimaryTextColorId; +import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.ACTION_STOP_AND_DISCARD; +import static net.osmand.plus.monitoring.TripRecordingOptionsBottomFragment.dismissTargetDialog; - public static final String TAG = StopTrackRecordingBottomFragment.class.getSimpleName(); +public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFragment { + + public static final String TAG = TripRecordingDiscardBottomFragment.class.getSimpleName(); private OsmandApplication app; - private MapActivity mapActivity; - private OsmandSettings settings; - private OsmandMonitoringPlugin plugin; - private ItemType tag = ItemType.CANCEL; - public void setMapActivity(MapActivity mapActivity) { - this.mapActivity = mapActivity; - } - - public static void showInstance(MapActivity mapActivity, @NonNull FragmentManager fragmentManager, @NonNull Fragment target) { + public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) { if (!fragmentManager.isStateSaved()) { - StopTrackRecordingBottomFragment fragment = new StopTrackRecordingBottomFragment(); - fragment.setMapActivity(mapActivity); + TripRecordingDiscardBottomFragment fragment = new TripRecordingDiscardBottomFragment(); fragment.setTargetFragment(target, 0); fragment.show(fragmentManager, TAG); } @@ -46,67 +39,48 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm @Override public void createMenuItems(Bundle savedInstanceState) { app = requiredMyApplication(); - settings = app.getSettings(); - plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); + final OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin); int verticalNormal = getResources().getDimensionPixelSize(R.dimen.content_padding); - -// final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); - final View buttonSave = createItem(inflater, ItemType.STOP_AND_SAVE); + String description = getString(R.string.track_recording_description) + .concat(getString(R.string.lost_data_warning)); + final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); final View buttonCancel = createItem(inflater, ItemType.CANCEL); items.add(new BottomSheetItemWithDescription.Builder() - .setDescription(app.getString(R.string.track_recording_description)) - .setDescriptionColorId(!nightMode ? R.color.text_color_primary_light : R.color.text_color_primary_dark) - .setDescriptionMaxLines(4) + .setDescription(description) + .setDescriptionColorId(getPrimaryTextColorId(nightMode)) .setTitle(app.getString(R.string.track_recording_title)) .setLayoutId(R.layout.bottom_sheet_item_title_with_description) .create()); items.add(new DividerSpaceItem(app, verticalBig)); - /*items.add(new BaseBottomSheetItem.Builder() + items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonDiscard) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - tag = (ItemType) buttonDiscard.getTag(); - if (plugin != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) { + if (plugin != null && app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) { plugin.stopRecording(); app.getNotificationHelper().refreshNotifications(); } app.getSavingTrackHelper().clearRecordedData(true); dismiss(); + dismissTargetDialog(TripRecordingDiscardBottomFragment.this, + TripRecordingOptionsBottomFragment.class, ACTION_STOP_AND_DISCARD, true); } }) .create()); - items.add(new DividerSpaceItem(app, verticalBig));*/ - - items.add(new BaseBottomSheetItem.Builder() - .setCustomView(buttonSave) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - tag = (ItemType) buttonSave.getTag(); - if (plugin != null && app.getSavingTrackHelper().hasDataToSave()) { - plugin.saveCurrentTrack(null, mapActivity); - app.getNotificationHelper().refreshNotifications(); - dismiss(); - } - } - }) - .create()); - - items.add(new DividerSpaceItem(app, verticalNormal)); + items.add(new DividerSpaceItem(app, verticalBig)); items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonCancel) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - tag = (ItemType) buttonCancel.getTag(); dismiss(); } }) @@ -116,15 +90,15 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm } private View createItem(LayoutInflater inflater, ItemType type) { - return TripRecordingActiveBottomSheet.createItem(app, nightMode, inflater, type); + return TripRecordingBottomFragment.createItem(app, nightMode, inflater, type); } @Override public void onResume() { super.onResume(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingActiveBottomSheet) { - ((TripRecordingActiveBottomSheet) target).hide(); + if (target instanceof TripRecordingOptionsBottomFragment) { + ((TripRecordingOptionsBottomFragment) target).hide(); } } @@ -132,13 +106,8 @@ public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragm public void onPause() { super.onPause(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingActiveBottomSheet) { - TripRecordingActiveBottomSheet tripRec = (TripRecordingActiveBottomSheet) target; - if (tag == ItemType.CANCEL) { - tripRec.show(); - } else { - tripRec.dismiss(); - } + if (target instanceof TripRecordingOptionsBottomFragment) { + ((TripRecordingOptionsBottomFragment) target).show(); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomFragment.java new file mode 100644 index 0000000000..aa755a4276 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomFragment.java @@ -0,0 +1,350 @@ +package net.osmand.plus.monitoring; + +import android.app.Activity; +import android.app.Dialog; +import android.os.AsyncTask; +import android.os.Bundle; +import android.os.Handler; +import android.text.format.DateUtils; +import android.view.LayoutInflater; +import android.view.View; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; + +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.SavingTrackHelper; +import net.osmand.plus.base.MenuBottomSheetDialogFragment; +import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.monitoring.TripRecordingBottomFragment.ItemType; +import net.osmand.plus.myplaces.SaveCurrentTrackTask; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; +import net.osmand.util.Algorithms; + +import static net.osmand.AndroidUtils.getPrimaryTextColorId; + +public class TripRecordingOptionsBottomFragment extends MenuBottomSheetDialogFragment { + + public static final String TAG = TripRecordingOptionsBottomFragment.class.getSimpleName(); + public static final String ACTION_STOP_AND_DISCARD = "action_stop_and_discard"; + private static final String SAVE_CURRENT_GPX_FILE = "save_current_gpx_file"; + private static final int SAVE_UPDATE_INTERVAL = 1000; + + private OsmandApplication app; + private OsmandSettings settings; + private SavingTrackHelper helper; + + private View buttonClear; + private View buttonSave; + + private SelectedGpxFile selectedGpxFile; + private final Handler handler = new Handler(); + private Runnable updatingTimeTrackSaved; + private int indexButtonOnline = -1; + private int indexButtonOnlineDivider = -1; + + private GPXFile getGPXFile() { + return selectedGpxFile.getGpxFile(); + } + + public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) { + this.selectedGpxFile = selectedGpxFile; + } + + public boolean hasDataToSave() { + return app.getSavingTrackHelper().hasDataToSave(); + } + + public boolean wasTrackMonitored() { + return settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); + } + + public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target, SelectedGpxFile selectedGpxFile) { + if (!fragmentManager.isStateSaved()) { + TripRecordingOptionsBottomFragment fragment = new TripRecordingOptionsBottomFragment(); + fragment.setTargetFragment(target, 0); + fragment.setSelectedGpxFile(selectedGpxFile); + fragment.show(fragmentManager, TAG); + } + } + + @Override + public void createMenuItems(Bundle savedInstanceState) { + app = requiredMyApplication(); + settings = app.getSettings(); + helper = app.getSavingTrackHelper(); + LayoutInflater inflater = UiUtilities.getInflater(app, nightMode); + final FragmentManager fragmentManager = getFragmentManager(); + int dp16 = getResources().getDimensionPixelSize(R.dimen.content_padding); + int dp36 = getResources().getDimensionPixelSize(R.dimen.context_menu_controller_height); + + if (savedInstanceState != null) { + if (savedInstanceState.containsKey(SAVE_CURRENT_GPX_FILE) + && savedInstanceState.getBoolean(SAVE_CURRENT_GPX_FILE)) { + selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + } + } + + buttonClear = createItem(inflater, ItemType.CLEAR_DATA, hasDataToSave()); + final View buttonDiscard = createItem(inflater, ItemType.STOP_AND_DISCARD); + final View buttonOnline = createItem(inflater, ItemType.STOP_ONLINE, hasDataToSave()); + buttonSave = createItem(inflater, ItemType.SAVE, hasDataToSave()); + final View buttonSegment = createItem(inflater, ItemType.START_NEW_SEGMENT, wasTrackMonitored()); + + items.add(new SimpleBottomSheetItem.Builder() + .setTitle(getString(R.string.shared_string_options)) + .setTitleColorId(getPrimaryTextColorId(nightMode)) + .setLayoutId(R.layout.bottom_sheet_item_title) + .create()); + + items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small))); + + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonClear) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (fragmentManager != null && hasDataToSave()) { + TripRecordingClearDataBottomFragment.showInstance(fragmentManager, TripRecordingOptionsBottomFragment.this); + } + } + }) + .create()); + + items.add(new DividerSpaceItem(app, dp16)); + + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonDiscard) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (fragmentManager != null) { + TripRecordingDiscardBottomFragment.showInstance(fragmentManager, TripRecordingOptionsBottomFragment.this); + } + } + }) + .create()); + + items.add(new DividerSpaceItem(app, dp36)); + + if (app.getLiveMonitoringHelper().isLiveMonitoringEnabled()) { + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonOnline) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + settings.LIVE_MONITORING.set(false); + if (indexButtonOnline != -1) { + AndroidUiHelper.updateVisibility(items.get(indexButtonOnline).getView(), false); + } + if (indexButtonOnlineDivider != -1) { + AndroidUiHelper.updateVisibility(items.get(indexButtonOnlineDivider).getView(), false); + } + } + }) + .create()); + indexButtonOnline = items.size() - 1; + + items.add(new DividerSpaceItem(app, dp36)); + indexButtonOnlineDivider = items.size() - 1; + } + + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonSave) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (hasDataToSave()) { + final GPXFile gpxFile = getGPXFile(); + new SaveCurrentTrackTask(app, gpxFile, createSaveListener()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + } + }) + .create()); + + items.add(new DividerSpaceItem(app, dp16)); + + items.add(new BaseBottomSheetItem.Builder() + .setCustomView(buttonSegment) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (wasTrackMonitored()) { + helper.startNewSegment(); + } + } + }) + .create()); + + items.add(new DividerSpaceItem(app, getResources().getDimensionPixelSize(R.dimen.content_padding_small))); + + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putBoolean(SAVE_CURRENT_GPX_FILE, true); + } + + @Override + public void onResume() { + super.onResume(); + runUpdatingTimeTrackSaved(); + Fragment target = getTargetFragment(); + if (target instanceof TripRecordingBottomFragment) { + ((TripRecordingBottomFragment) target).hide(); + } + } + + @Override + public void onPause() { + super.onPause(); + stopUpdatingTimeTrackSaved(); + Fragment target = getTargetFragment(); + if (target instanceof TripRecordingBottomFragment) { + if (isDiscard()) { + ((TripRecordingBottomFragment) target).dismiss(); + } else { + ((TripRecordingBottomFragment) target).show(); + } + } + } + + public void show() { + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.show(); + } + } + + public void hide() { + Dialog dialog = getDialog(); + if (dialog != null) { + dialog.hide(); + } + } + + private boolean isDiscard() { + Bundle args = getArguments(); + if (args != null) { + return args.getBoolean(ACTION_STOP_AND_DISCARD); + } + return false; + } + + protected static void dismissTargetDialog(Fragment current, Class targetClass) { + dismissTargetDialog(current, targetClass, null, null); + } + + protected static void dismissTargetDialog(Fragment current, Class targetClass, String booleanKey, Boolean value) { + if (targetClass.isInstance(current.getTargetFragment())) { + Fragment target = current.getTargetFragment(); + if (booleanKey != null && value != null) { + Bundle args = new Bundle(); + args.putBoolean(booleanKey, value); + target.setArguments(args); + } + if (target instanceof DialogFragment) { + ((DialogFragment) target).dismiss(); + } + } + } + + public void stopUpdatingTimeTrackSaved() { + handler.removeCallbacks(updatingTimeTrackSaved); + } + + public void runUpdatingTimeTrackSaved() { + updatingTimeTrackSaved = new Runnable() { + @Override + public void run() { + String time = getTimeTrackSaved(); + TripRecordingBottomFragment.createItem(app, nightMode, buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null); + TripRecordingBottomFragment.createItem(app, nightMode, buttonClear, ItemType.CLEAR_DATA, hasDataToSave(), null); + handler.postDelayed(this, SAVE_UPDATE_INTERVAL); + } + }; + handler.post(updatingTimeTrackSaved); + } + + private String getTimeTrackSaved() { + long timeTrackSaved = helper.getLastTimeFileSaved(); + if (timeTrackSaved != 0) { + long now = System.currentTimeMillis(); + CharSequence time = DateUtils.getRelativeTimeSpanString(timeTrackSaved, now, DateUtils.MINUTE_IN_MILLIS); + return String.valueOf(time); + } else { + return null; + } + } + + private View createItem(LayoutInflater inflater, ItemType type, boolean enabled) { + return TripRecordingBottomFragment.createItem(app, nightMode, inflater, type, enabled, null); + } + + private View createItem(LayoutInflater inflater, ItemType type) { + return TripRecordingBottomFragment.createItem(app, nightMode, inflater, type); + } + + private SaveGpxListener createSaveListener() { + return new SaveGpxListener() { + + @Override + public void gpxSavingStarted() { + } + + @Override + public void gpxSavingFinished(Exception errorMessage) { + MapActivity mapActivity = getMapActivity(); + OsmandMonitoringPlugin plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class); + if (mapActivity != null && plugin != null) { + stopUpdatingTimeTrackSaved(); + settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); + plugin.saveCurrentTrack(null, mapActivity, false, true); + dismiss(); + dismissTargetDialog(TripRecordingOptionsBottomFragment.this, TripRecordingBottomFragment.class); + settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true); + runUpdatingTimeTrackSaved(); + } + } + }; + } + + @Nullable + public MapActivity getMapActivity() { + Activity activity = getActivity(); + if (activity instanceof MapActivity) { + return (MapActivity) activity; + } + return null; + } + + @Override + protected int getDismissButtonHeight() { + return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); + } + + @Override + protected int getDismissButtonTextId() { + return R.string.shared_string_back; + } + + @Override + protected boolean useVerticalButtons() { + return true; + } + +} diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomFragment.java similarity index 88% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomFragment.java index c8c96d1323..8d379237e2 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomFragment.java @@ -29,21 +29,21 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.FontCache; -import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType; +import net.osmand.plus.monitoring.TripRecordingBottomFragment.ItemType; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createShowTrackItem; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.UPDATE_TRACK_ICON; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.createItem; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.createShowTrackItem; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.updateTrackIcon; -public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragment { +public class TripRecordingStartingBottomFragment extends MenuBottomSheetDialogFragment { - public static final String TAG = TripRecordingStartingBottomSheet.class.getSimpleName(); + public static final String TAG = TripRecordingStartingBottomFragment.class.getSimpleName(); public static final String UPDATE_LOGGING_INTERVAL = "update_logging_interval"; private OsmandApplication app; @@ -52,7 +52,6 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm private AppCompatImageView upDownBtn; private AppCompatImageView trackAppearanceIcon; private TextView intervalValueView; - private LinearLayout showTrackContainer; private LinearLayout intervalContainer; private RangeSlider intervalSlider; @@ -60,7 +59,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm public static void showInstance(@NonNull FragmentManager fragmentManager) { if (!fragmentManager.isStateSaved()) { - TripRecordingStartingBottomSheet fragment = new TripRecordingStartingBottomSheet(); + TripRecordingStartingBottomFragment fragment = new TripRecordingStartingBottomFragment(); fragment.show(fragmentManager, TAG); } } @@ -91,10 +90,10 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm intervalSlider = itemView.findViewById(R.id.interval_slider); updateIntervalValue(); - showTrackContainer = itemView.findViewById(R.id.show_track_on_map); + LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); createShowTrackItem(app, getMapActivity(), nightMode, showTrackContainer, trackAppearanceIcon, - R.string.shared_string_show_on_map, TripRecordingStartingBottomSheet.this, new Runnable() { + R.string.shared_string_show_on_map, TripRecordingStartingBottomFragment.this, new Runnable() { @Override public void run() { hide(); @@ -104,6 +103,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm updateUpDownBtn(); CardView cardLeft = itemView.findViewById(R.id.button_left); + createItem(app, nightMode, cardLeft, ItemType.CANCEL, true, null); cardLeft.setOnClickListener(new View.OnClickListener() { @Override @@ -113,6 +113,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm }); CardView cardCenter = itemView.findViewById(R.id.button_center); + createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null); cardCenter.setOnClickListener(new View.OnClickListener() { @Override @@ -122,6 +123,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm }); CardView cardRight = itemView.findViewById(R.id.button_right); + createItem(app, nightMode, cardRight, ItemType.SETTINGS, true, null); cardRight.setOnClickListener(new View.OnClickListener() { @Override @@ -129,7 +131,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { hide(); - BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.MONITORING_SETTINGS, TripRecordingStartingBottomSheet.this); + BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.MONITORING_SETTINGS, TripRecordingStartingBottomFragment.this); } } }); @@ -214,7 +216,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm app.startNavigationService(NavigationService.USED_BY_GPX); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack()); + TripRecordingBottomFragment.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack()); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index 08a4e34b6b..e46e438f67 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -6,7 +6,6 @@ import android.graphics.drawable.LayerDrawable; import android.os.Build; import android.os.Bundle; import android.view.View; -import android.widget.CompoundButton; import android.widget.LinearLayout; import androidx.annotation.NonNull; @@ -34,9 +33,8 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import org.apache.commons.logging.Log; -import static net.osmand.plus.UiUtilities.CompoundButtonType.TOOLBAR; import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getActivePrimaryColorId; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.getSecondaryIconColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.getSecondaryIconColorId; public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index d71387c0ce..2faf24db46 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -61,7 +61,7 @@ import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.audionotes.MultimediaNotesFragment; import net.osmand.plus.development.DevelopmentSettingsFragment; import net.osmand.plus.monitoring.MonitoringSettingsFragment; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomFragment; import net.osmand.plus.openplacereviews.OprSettingsFragment; import net.osmand.plus.osmedit.OsmEditingFragment; import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment; @@ -86,7 +86,7 @@ import java.io.Serializable; import java.util.Set; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; -import static net.osmand.plus.monitoring.TripRecordingStartingBottomSheet.UPDATE_LOGGING_INTERVAL; +import static net.osmand.plus.monitoring.TripRecordingStartingBottomFragment.UPDATE_LOGGING_INTERVAL; public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener, OnPreferenceClickListener, AppModeChangedListener, OnConfirmPreferenceChange { @@ -297,8 +297,8 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl public void onDestroyView() { super.onDestroyView(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingStartingBottomSheet) { - ((TripRecordingStartingBottomSheet) target).show(UPDATE_LOGGING_INTERVAL); + if (target instanceof TripRecordingStartingBottomFragment) { + ((TripRecordingStartingBottomFragment) target).show(UPDATE_LOGGING_INTERVAL); } } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 807becbb1c..958f45193a 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -36,8 +36,8 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingBottomFragment; +import net.osmand.plus.monitoring.TripRecordingStartingBottomFragment; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.settings.backend.CommonPreference; @@ -64,7 +64,7 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems; -import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON; +import static net.osmand.plus.monitoring.TripRecordingBottomFragment.UPDATE_TRACK_ICON; public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener, ColorPickerListener { @@ -398,10 +398,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement @Override public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingStartingBottomSheet) { - ((TripRecordingStartingBottomSheet) target).show(UPDATE_TRACK_ICON); - } else if (target instanceof TripRecordingActiveBottomSheet) { - ((TripRecordingActiveBottomSheet) target).show(UPDATE_TRACK_ICON); + if (target instanceof TripRecordingStartingBottomFragment) { + ((TripRecordingStartingBottomFragment) target).show(UPDATE_TRACK_ICON); + } else if (target instanceof TripRecordingBottomFragment) { + ((TripRecordingBottomFragment) target).show(UPDATE_TRACK_ICON); } } From 3bcf8d4e3ba4d68ab77fdf2577a0cf90fa98e32f Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 19 Mar 2021 15:00:37 +0200 Subject: [PATCH 09/96] small fixes; --- .../plus/monitoring/TripRecordingBottomFragment.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java index 471ec813a6..36ecc4edfb 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomFragment.java @@ -72,13 +72,6 @@ public class TripRecordingBottomFragment extends MenuBottomSheetDialogFragment { private GpxBlockStatisticsBuilder blockStatisticsBuilder; private SelectedGpxFile selectedGpxFile; - - private View statusContainer; - private LinearLayout showTrackContainer; - private AppCompatImageView trackAppearanceIcon; - private View buttonSave; - private GpxBlockStatisticsBuilder blockStatisticsBuilder; - private final Handler handler = new Handler(); private Runnable updatingGPS; From 4f5f99550936c00d0e9ae30862f6a1d8db22707e Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 16:35:16 +0200 Subject: [PATCH 10/96] rename "TrackAppearanceViewHolder" -> "AppearanceViewHolder" --- ...anceViewHolder.java => AppearanceViewHolder.java} | 10 +++++----- .../src/net/osmand/plus/track/TrackColoringCard.java | 12 ++++++------ OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) rename OsmAnd/src/net/osmand/plus/track/{TrackAppearanceViewHolder.java => AppearanceViewHolder.java} (64%) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceViewHolder.java b/OsmAnd/src/net/osmand/plus/track/AppearanceViewHolder.java similarity index 64% rename from OsmAnd/src/net/osmand/plus/track/TrackAppearanceViewHolder.java rename to OsmAnd/src/net/osmand/plus/track/AppearanceViewHolder.java index 1305f88f3d..bddb862593 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/track/AppearanceViewHolder.java @@ -8,13 +8,13 @@ import androidx.recyclerview.widget.RecyclerView; import net.osmand.plus.R; -public class TrackAppearanceViewHolder extends RecyclerView.ViewHolder { +public class AppearanceViewHolder extends RecyclerView.ViewHolder { - final TextView title; - final ImageView icon; - final ImageView button; + public final TextView title; + public final ImageView icon; + public final ImageView button; - TrackAppearanceViewHolder(View itemView) { + public AppearanceViewHolder(View itemView) { super(itemView); title = itemView.findViewById(R.id.groupName); icon = itemView.findViewById(R.id.groupIcon); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java index 41e17ac37e..9e48ca0bbe 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackColoringCard.java @@ -135,7 +135,7 @@ public class TrackColoringCard extends BaseCard { updateHeader(); } - private class TrackColoringAdapter extends RecyclerView.Adapter { + private class TrackColoringAdapter extends RecyclerView.Adapter { private List items; @@ -145,16 +145,16 @@ public class TrackColoringCard extends BaseCard { @NonNull @Override - public TrackAppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + public AppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode); View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false); view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width); view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height); - return new TrackAppearanceViewHolder(view); + return new AppearanceViewHolder(view); } @Override - public void onBindViewHolder(@NonNull final TrackAppearanceViewHolder holder, int position) { + public void onBindViewHolder(@NonNull final AppearanceViewHolder holder, int position) { final TrackAppearanceItem item = items.get(position); if (item.isActive() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -186,7 +186,7 @@ public class TrackColoringCard extends BaseCard { }); } - private void updateButtonBg(TrackAppearanceViewHolder holder, TrackAppearanceItem item) { + private void updateButtonBg(AppearanceViewHolder holder, TrackAppearanceItem item) { GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline); if (rectContourDrawable != null) { Context ctx = holder.itemView.getContext(); @@ -217,7 +217,7 @@ public class TrackColoringCard extends BaseCard { } } - private void updateTextAndIconColor(TrackAppearanceViewHolder holder, TrackAppearanceItem item) { + private void updateTextAndIconColor(AppearanceViewHolder holder, TrackAppearanceItem item) { Context ctx = holder.itemView.getContext(); boolean isSelected = item.getAttrName().equals(getSelectedAppearanceItem().getAttrName()); int iconColorId; diff --git a/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java index 9e98414d34..8c1385b43b 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackWidthCard.java @@ -184,7 +184,7 @@ public class TrackWidthCard extends BaseCard { } } - private class GpxWidthAdapter extends RecyclerView.Adapter { + private class GpxWidthAdapter extends RecyclerView.Adapter { private List items; @@ -194,13 +194,13 @@ public class TrackWidthCard extends BaseCard { @NonNull @Override - public TrackAppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + public AppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode); View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false); view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width); view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height); - TrackAppearanceViewHolder holder = new TrackAppearanceViewHolder(view); + AppearanceViewHolder holder = new AppearanceViewHolder(view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp, R.drawable.ripple_solid_dark_6dp); @@ -209,7 +209,7 @@ public class TrackWidthCard extends BaseCard { } @Override - public void onBindViewHolder(@NonNull final TrackAppearanceViewHolder holder, int position) { + public void onBindViewHolder(@NonNull final AppearanceViewHolder holder, int position) { AppearanceListItem item = items.get(position); holder.title.setText(item.getLocalizedValue()); @@ -238,7 +238,7 @@ public class TrackWidthCard extends BaseCard { }); } - private void updateWidthIcon(TrackAppearanceViewHolder holder, AppearanceListItem item) { + private void updateWidthIcon(AppearanceViewHolder holder, AppearanceListItem item) { int color = trackDrawInfo.getColor(); int iconId; @@ -251,7 +251,7 @@ public class TrackWidthCard extends BaseCard { holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(iconId, color)); } - private void updateButtonBg(TrackAppearanceViewHolder holder, AppearanceListItem item) { + private void updateButtonBg(AppearanceViewHolder holder, AppearanceListItem item) { GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline); if (rectContourDrawable != null) { if (getSelectedItem() != null && getSelectedItem().equals(item)) { From cbdf5e5a91617752d7ba47d2cf912dd0c086a54a Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 16:42:47 +0200 Subject: [PATCH 11/96] add getActiveColorRes() to BaseSettingsFragment --- .../osmand/plus/settings/fragments/BaseSettingsFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index e6d39cade8..bf73a68be5 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -685,6 +685,11 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl ContextCompat.getColor(app, nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light); } + @ColorRes + protected int getActiveColorRes() { + return isNightMode() ? R.color.active_color_primary_dark : R.color.active_color_primary_light; + } + @ColorRes protected int getBackgroundColorRes() { return isNightMode() ? R.color.list_background_color_dark : R.color.list_background_color_light; From 7ac502cb58362faeacfaac5ced7b78237016b6fc Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 16:45:38 +0200 Subject: [PATCH 12/96] small refactoring --- OsmAnd/src/net/osmand/plus/track/ColorsCard.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java index e6da7e736f..7651775f6c 100644 --- a/OsmAnd/src/net/osmand/plus/track/ColorsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/ColorsCard.java @@ -6,7 +6,6 @@ import android.view.View; import android.widget.ImageView; import androidx.annotation.ColorInt; -import androidx.core.content.ContextCompat; import androidx.core.graphics.ColorUtils; import androidx.fragment.app.Fragment; @@ -28,12 +27,6 @@ import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.List; -import androidx.annotation.ColorInt; -import androidx.annotation.ColorRes; -import androidx.core.content.ContextCompat; -import androidx.core.graphics.ColorUtils; -import androidx.fragment.app.Fragment; - public class ColorsCard extends BaseCard implements ColorPickerListener { public static final int MAX_CUSTOM_COLORS = 6; @@ -58,7 +51,12 @@ public class ColorsCard extends BaseCard implements ColorPickerListener { return R.layout.colors_card; } - public ColorsCard(MapActivity mapActivity, int selectedColor, Fragment targetFragment, List colors, ListStringPreference colorsListPreference, ApplicationMode appMode) { + public ColorsCard(MapActivity mapActivity, + int selectedColor, + Fragment targetFragment, + List colors, + ListStringPreference colorsListPreference, + ApplicationMode appMode) { super(mapActivity); this.targetFragment = targetFragment; this.selectedColor = selectedColor; From ae249e1185cc6b2a7262b29484e71d5ed1bf8407 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 16:57:41 +0200 Subject: [PATCH 13/96] Add constant for "public_transport" --- .../java/net/osmand/router/TransportRoutingConfiguration.java | 2 -- .../osmand/plus/measurementtool/MeasurementToolFragment.java | 3 ++- OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java | 4 +++- .../RouteBetweenPointsBottomSheetDialogFragment.java | 3 ++- .../src/net/osmand/plus/routing/TransportRoutingHelper.java | 2 ++ .../src/net/osmand/plus/settings/backend/OsmandSettings.java | 3 ++- 6 files changed, 11 insertions(+), 6 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java index c350204b52..9b61aec963 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/TransportRoutingConfiguration.java @@ -10,8 +10,6 @@ import net.osmand.router.GeneralRouter.RouteDataObjectAttribute; public class TransportRoutingConfiguration { - public static final String KEY = "public_transport"; - public int ZOOM_TO_LOAD_TILES = 15; public int walkRadius = 1500; // ? 3000 diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 38a24b37a5..6165e0e4bc 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -106,6 +106,7 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, @@ -897,7 +898,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route case SnapTrackWarningFragment.CONTINUE_RESULT_CODE: if (mapActivity != null) { ApplicationMode mode = editingCtx.getAppMode(); - if (mode == ApplicationMode.DEFAULT || "public_transport".equals(mode.getRoutingProfile())) { + if (mode == ApplicationMode.DEFAULT || PUBLIC_TRANSPORT_KEY.equals(mode.getRoutingProfile())) { mode = null; } List> pointsSegments = editingCtx.getPointsSegments(true, false); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java index 179ad54645..8b6d615d9c 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/ProfileCard.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; + public class ProfileCard extends BaseCard { private ApplicationMode selectedMode; @@ -42,7 +44,7 @@ public class ProfileCard extends BaseCard { Iterator iterator = modes.iterator(); while (iterator.hasNext()) { ApplicationMode mode = iterator.next(); - if ("public_transport".equals(mode.getRoutingProfile())) { + if (PUBLIC_TRANSPORT_KEY.equals(mode.getRoutingProfile())) { iterator.remove(); } } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java index 12eff78327..fec2f6379d 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/RouteBetweenPointsBottomSheetDialogFragment.java @@ -35,6 +35,7 @@ import static net.osmand.plus.UiUtilities.CustomRadioButtonType.END; import static net.osmand.plus.UiUtilities.CustomRadioButtonType.START; import static net.osmand.plus.measurementtool.MeasurementEditingContext.DEFAULT_APP_MODE; import static net.osmand.plus.measurementtool.SelectFileBottomSheet.BOTTOM_SHEET_HEIGHT_DP; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBehaviourDialogFragment { @@ -116,7 +117,7 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBeha for (int i = 0; i < modes.size(); i++) { ApplicationMode mode = modes.get(i); - if (!"public_transport".equals(mode.getRoutingProfile())) { + if (!PUBLIC_TRANSPORT_KEY.equals(mode.getRoutingProfile())) { icon = app.getUIUtilities().getPaintedIcon(mode.getIconRes(), mode.getProfileColor(nightMode)); addProfileView(navigationType, onClickListener, i, icon, mode.toHumanString(), mode.equals(appMode)); } diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 637e3078e7..9f56f6d633 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -55,6 +55,8 @@ public class TransportRoutingHelper { private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(TransportRoutingHelper.class); + public static final String PUBLIC_TRANSPORT_KEY = "public_transport"; + private List> listeners = new LinkedList<>(); private final OsmandApplication app; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index ec7d2b067f..4b9d981c59 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -84,6 +84,7 @@ import java.util.StringTokenizer; import static net.osmand.aidlapi.OsmAndCustomizationConstants.CONFIGURE_MAP_ITEM_ID_SCHEME; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_ITEM_ID_SCHEME; import static net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_CONTEXT_MENU_ACTIONS; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class OsmandSettings { @@ -998,7 +999,7 @@ public class OsmandSettings { ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.CAR, "car"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BICYCLE, "bicycle"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, "pedestrian"); - ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, "public_transport"); + ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, PUBLIC_TRANSPORT_KEY); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.BOAT, "boat"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.AIRCRAFT, "STRAIGHT_LINE_MODE"); ROUTING_PROFILE.setModeDefaultValue(ApplicationMode.SKI, "ski"); From fbeb657f870c4a5d2609ea8c7d36e2a09eab291a Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 17:08:22 +0200 Subject: [PATCH 14/96] route line customization strings --- OsmAnd/res/values/strings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 2bc271e8dd..63472a89eb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,11 @@ Thx - Hardy --> + + Specify color for map mode: %1$s. + Route line would be use %1$s specified on selected map style: %2$s. + Route line + Customize route line Please select another type of colorization. The track does not contain speed data. The track does not contain altitude data. From 35064dba0158091eac04d69c278722b73a09cf0a Mon Sep 17 00:00:00 2001 From: Skalii Date: Fri, 19 Mar 2021 17:48:57 +0200 Subject: [PATCH 15/96] some fixes; --- ...tom_sheet_with_switch_divider_and_additional_button.xml | 4 ++-- OsmAnd/res/layout/preference_button_with_icon_triple.xml | 7 ++----- OsmAnd/res/values/sizes.xml | 1 - .../plus/monitoring/TripRecordingActiveBottomSheet.java | 5 +++-- .../plus/settings/fragments/BaseSettingsFragment.java | 4 +--- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml index e7b84c5305..1eb3dd1bd4 100644 --- a/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml +++ b/OsmAnd/res/layout/bottom_sheet_with_switch_divider_and_additional_button.xml @@ -20,9 +20,9 @@ android:layout_marginRight="@dimen/content_padding_half" android:layout_weight="1" android:gravity="center_vertical" - app:cardBackgroundColor="?attr/switch_button_active" app:cardCornerRadius="4dp" - app:cardElevation="0dp"> + app:cardElevation="0dp" + tools:cardBackgroundColor="?attr/switch_button_active"> diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 79fa32d1c3..dae06fed05 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -418,5 +418,4 @@ 3sp 80dp - 160dp \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java index 7aaa832dd1..dc965143d3 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java @@ -579,8 +579,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen } public static void setShowOnMapBackground(View view, boolean checked, boolean nightMode) { - int background = checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode); - view.setBackgroundResource(background); + Drawable background = AppCompatResources.getDrawable(view.getContext(), + checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode)); + view.setBackgroundDrawable(background); } public static void setTextColor(Context context, TextView tv, boolean enabled, boolean nightMode, ItemType type) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java index d71387c0ce..a426321eb9 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsFragment.java @@ -923,9 +923,7 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl args.putString(APP_MODE_KEY, appMode.getStringKey()); } fragment.setArguments(args); - if (target != null) { - fragment.setTargetFragment(target, 0); - } + fragment.setTargetFragment(target, 0); activity.getSupportFragmentManager().beginTransaction() .replace(R.id.fragmentContainer, fragment, screenType.fragmentName) .addToBackStack(DRAWER_SETTINGS_ID + ".new") From 5dd662eb9967617c8ecd08979c0ec053954900ae Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 17:55:04 +0200 Subject: [PATCH 16/96] RouteLineAppearanceFragment initial commit --- OsmAnd/res/layout/route_line_appearance.xml | 122 ++++++++ .../RouteLineAppearanceFragment.java | 293 ++++++++++++++++++ 2 files changed, 415 insertions(+) create mode 100644 OsmAnd/res/layout/route_line_appearance.xml create mode 100644 OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java diff --git a/OsmAnd/res/layout/route_line_appearance.xml b/OsmAnd/res/layout/route_line_appearance.xml new file mode 100644 index 0000000000..de3ba175b0 --- /dev/null +++ b/OsmAnd/res/layout/route_line_appearance.xml @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java new file mode 100644 index 0000000000..ee6ffec18e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -0,0 +1,293 @@ +package net.osmand.plus.settings.fragments; + +import android.os.Build; +import android.os.Bundle; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.LinearLayout; + +import androidx.activity.OnBackPressedCallback; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; + +import net.osmand.AndroidUtils; +import net.osmand.plus.LockableScrollView; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.UiUtilities.DialogButtonType; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.ContextMenuScrollFragment; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.settings.backend.ApplicationMode; + +public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { + + public final static String TAG = RouteLineAppearanceFragment.class.getName(); + + private ApplicationMode appMode; + + private int toolbarHeightPx; + + private View buttonsShadow; + private View controlButtons; + private View toolbarContainer; + + @Override + public int getMainLayoutId() { + return R.layout.route_line_appearance; + } + + @Override + public int getHeaderViewHeight() { + return 0; + } + + @Override + public boolean isHeaderViewDetached() { + return false; + } + + @Override + public int getToolbarHeight() { + return isPortrait() ? toolbarHeightPx : 0; + } + + @Override + public float getMiddleStateKoef() { + return 0.5f; + } + + @Override + public int getInitialMenuState() { + return MenuState.HALF_SCREEN; + } + + @Override + public int getSupportedMenuStatesPortrait() { + return MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; + } + + @Override + public boolean shouldShowMapControls(int menuState) { + return menuState == MenuState.HALF_SCREEN; + } + + @Override + public void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + toolbarHeightPx = getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); + requireMyActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { + public void handleOnBackPressed() { + dismiss(); + } + }); + } + + @Override + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = super.onCreateView(inflater, container, savedInstanceState); + if (view != null) { + toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container); + buttonsShadow = view.findViewById(R.id.buttons_shadow); + controlButtons = view.findViewById(R.id.control_buttons); + if (isPortrait()) { + updateCardsLayout(); + } else { + int widthNoShadow = getLandscapeNoShadowWidth(); + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(widthNoShadow, ViewGroup.LayoutParams.WRAP_CONTENT); + params.gravity = Gravity.BOTTOM | Gravity.START; + controlButtons.setLayoutParams(params); + } + View bottomScrollView = getBottomScrollView(); + if (bottomScrollView instanceof LockableScrollView) { + ((LockableScrollView) bottomScrollView).setScrollingEnabled(false); + } + initContent(view); + } + return view; + } + + private void initContent(@NonNull View view) { + setupCards(); + setupToolbar(); + setupButtons(view); + setupScrollShadow(); + enterAppearanceMode(); + openMenuHalfScreen(); + calculateLayout(); + } + + private void calculateLayout() { + runLayoutListener(new Runnable() { + @Override + public void run() { + updateMapControlsPos(RouteLineAppearanceFragment.this, getViewY(), true); + } + }); + } + + private void setupCards() { + MapActivity mapActivity = requireMapActivity(); + ViewGroup cardsContainer = getCardsContainer(); + } + + private void setupToolbar() { + ImageView closeButton = toolbarContainer.findViewById(R.id.close_button); + closeButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // discard changes + dismiss(); + } + }); + closeButton.setImageResource(AndroidUtils.getNavigationIconResId(toolbarContainer.getContext())); + updateToolbarVisibility(toolbarContainer); + } + + @Override + public int getStatusBarColorId() { + View view = getView(); + if (Build.VERSION.SDK_INT >= 23 && !isNightMode() && view != null) { + view.setSystemUiVisibility(view.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); + } + return isNightMode() ? R.color.divider_color_dark : R.color.divider_color_light; + } + + @Override + public float getToolbarAlpha(int y) { + return isPortrait() ? 1f : 0f; + } + + private void setupButtons(View view) { + View buttonsContainer = view.findViewById(R.id.buttons_container); + buttonsContainer.setBackgroundColor(AndroidUtils.getColorFromAttr(view.getContext(), R.attr.bg_color)); + View saveButton = view.findViewById(R.id.right_bottom_button); + saveButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // save changes + dismiss(); + } + }); + + View cancelButton = view.findViewById(R.id.dismiss_button); + cancelButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + // discard changes + FragmentActivity activity = getActivity(); + if (activity != null) { + activity.onBackPressed(); + } + } + }); + + UiUtilities.setupDialogButton(isNightMode(), cancelButton, DialogButtonType.SECONDARY, R.string.shared_string_cancel); + UiUtilities.setupDialogButton(isNightMode(), saveButton, DialogButtonType.PRIMARY, R.string.shared_string_apply); + + AndroidUiHelper.updateVisibility(saveButton, true); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.buttons_divider), true); + } + + private void setupScrollShadow() { + final View scrollView = getBottomScrollView(); + scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { + @Override + public void onScrollChanged() { + boolean scrollToBottomAvailable = scrollView.canScrollVertically(1); + if (scrollToBottomAvailable) { + showShadowButton(); + } else { + hideShadowButton(); + } + } + }); + } + + private void showShadowButton() { + buttonsShadow.setVisibility(View.VISIBLE); + buttonsShadow.animate() + .alpha(0.8f) + .setDuration(200) + .setListener(null); + } + + private void hideShadowButton() { + buttonsShadow.animate() + .alpha(0f) + .setDuration(200); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + exitAppearanceMode(); + } + + private void enterAppearanceMode() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); + AndroidUiHelper.setVisibility(mapActivity, portrait ? View.INVISIBLE : View.GONE, + R.id.map_left_widgets_panel, + R.id.map_right_widgets_panel, + R.id.map_center_info); + } + } + + private void exitAppearanceMode() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + AndroidUiHelper.setVisibility(mapActivity, View.VISIBLE, + R.id.map_left_widgets_panel, + R.id.map_right_widgets_panel, + R.id.map_center_info, + R.id.map_search_button); + } + } + + private void updateCardsLayout() { + View mainView = getMainView(); + if (mainView != null) { + LinearLayout cardsContainer = getCardsContainer(); + View topShadow = getTopShadow(); + FrameLayout bottomContainer = getBottomContainer(); + if (getCurrentMenuState() == MenuState.HEADER_ONLY) { + topShadow.setVisibility(View.INVISIBLE); + bottomContainer.setBackgroundDrawable(null); + AndroidUtils.setBackground(mainView.getContext(), cardsContainer, isNightMode(), R.drawable.travel_card_bg_light, R.drawable.travel_card_bg_dark); + } else { + topShadow.setVisibility(View.VISIBLE); + 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.list_background_color_light, R.color.list_background_color_dark); + } + } + } + + public static boolean showInstance(@NonNull MapActivity mapActivity, + @NonNull ApplicationMode appMode, + @NonNull Fragment target) { + try { + RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment(); + fragment.setRetainInstance(true); + fragment.setTargetFragment(target, 0); + fragment.appMode = appMode; + + mapActivity.getSupportFragmentManager() + .beginTransaction() + .replace(R.id.fragmentContainer, fragment, TAG) + .addToBackStack(TAG) + .commitAllowingStateLoss(); + return true; + } catch (RuntimeException e) { + return false; + } + } +} From 8ce078f189ffa092a4ac06b830baa23df3b12b87 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 17:58:43 +0200 Subject: [PATCH 17/96] add "Customize route line" button to ProfileAppearanceFragment --- OsmAnd/res/xml/profile_appearance.xml | 7 +++++ .../fragments/ProfileAppearanceFragment.java | 28 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/OsmAnd/res/xml/profile_appearance.xml b/OsmAnd/res/xml/profile_appearance.xml index 87ec511b69..b037591e16 100644 --- a/OsmAnd/res/xml/profile_appearance.xml +++ b/OsmAnd/res/xml/profile_appearance.xml @@ -76,4 +76,11 @@ android:title="@string/select_navigation_icon" android:selectable="false"/> + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index b649ccf8cd..939e8124c7 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -74,6 +74,7 @@ import java.util.List; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILES_LIST_UPDATED_ARG; import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILE_KEY_ARG; +import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; public class ProfileAppearanceFragment extends BaseSettingsFragment implements OnSelectProfileCallback, CardListener, ColorPickerListener { @@ -91,6 +92,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O private static final String LOCATION_ICON_ITEMS = "location_icon_items"; private static final String SELECT_NAV_ICON = "select_nav_icon"; private static final String NAV_ICON_ITEMS = "nav_icon_items"; + private static final String CUSTOMIZE_ROUTE_LINE = "customize_route_line"; private static final String PROFILE_NAME_KEY = "profile_name_key"; private static final String PROFILE_STRINGKEY_KEY = "profile_stringkey_key"; @@ -235,10 +237,13 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O findPreference(SELECT_ICON).setIconSpaceReserved(false); findPreference(SELECT_LOCATION_ICON).setIconSpaceReserved(false); findPreference(SELECT_NAV_ICON).setIconSpaceReserved(false); + findPreference(CUSTOMIZE_ROUTE_LINE).setIcon( + getIcon(R.drawable.ic_action_route_distance, getActiveColorRes())); if (getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile) { findPreference(SELECT_ICON).setVisible(false); findPreference(ICON_ITEMS).setVisible(false); } + updateRouteLinePreference(); } @SuppressLint("InlinedApi") @@ -709,6 +714,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O changedProfile.routingProfile = changedProfile.parent.getRoutingProfile(); changedProfile.routeService = changedProfile.parent.getRouteService(); this.isBaseProfileImported = isBaseProfileImported; + updateRouteLinePreference(); } private void setupBaseProfileView(String stringKey) { @@ -716,6 +722,15 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O baseProfileName.setText(Algorithms.capitalizeFirstLetter(mode.toHumanString())); } + private void updateRouteLinePreference() { + Preference preference = findPreference(CUSTOMIZE_ROUTE_LINE); + if (preference != null) { + boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT); + boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile); + preference.setVisible(!isDefaultProfile && !isPublicTransport); + } + } + private boolean checkProfileName() { if (Algorithms.isBlank(changedProfile.name)) { Activity activity = getActivity(); @@ -967,6 +982,19 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } } + @Override + public boolean onPreferenceClick(Preference preference) { + String prefId = preference.getKey(); + if (CUSTOMIZE_ROUTE_LINE.equals(prefId)) { + MapActivity mapActivity = getMapActivity(); + ApplicationMode appMode = getSelectedAppMode(); + if (mapActivity != null && appMode != null) { + RouteLineAppearanceFragment.showInstance(mapActivity, appMode, this); + } + } + return super.onPreferenceClick(preference); + } + @Override public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) { } From a9bd3c7a9da4f92d1d25530b60d7374c39148c84 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 19 Mar 2021 18:02:42 +0200 Subject: [PATCH 18/96] Hide map widgets and disable context menu when RouteLineAppearanceFragment is visible --- .../osmand/plus/activities/MapActivity.java | 5 ++++ .../plus/views/layers/MapControlsLayer.java | 19 +++++++++++---- .../views/layers/MapQuickActionLayer.java | 3 +++ .../osmand/plus/views/layers/RouteLayer.java | 24 +++++++++++++++---- .../mapwidgets/MapInfoWidgetsFactory.java | 1 + .../mapwidgets/MapMarkersWidgetsFactory.java | 3 ++- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7e0a07e40c..958ee2d242 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -126,6 +126,7 @@ import net.osmand.plus.settings.datastorage.DataStorageFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; import net.osmand.plus.settings.fragments.ConfigureProfileFragment; +import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment; import net.osmand.plus.track.TrackAppearanceFragment; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -2266,6 +2267,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(TrackMenuFragment.TAG); } + public RouteLineAppearanceFragment getRouteLineAppearanceFragment() { + return getFragment(RouteLineAppearanceFragment.TAG); + } + public void backToConfigureProfileFragment() { FragmentManager fragmentManager = getSupportFragmentManager(); int backStackEntryCount = fragmentManager.getBackStackEntryCount(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index ed425c0993..37f46e05d8 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -872,14 +872,16 @@ public class MapControlsLayer extends OsmandMapLayer { boolean showBottomMenuButtons = (showRouteCalculationControls || !routeFollowingMode) && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode() - && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode(); + && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode() + && !isInRouteLineCustomizationMode(); routePlanningBtn.updateVisibility(showBottomMenuButtons); menuControl.updateVisibility(showBottomMenuButtons); boolean additionalDialogsHide = !isInGpxApproximationMode() && !isInTrackAppearanceMode() && !isInChoosingRoutesMode() - && !isInWaypointsChoosingMode(); + && !isInWaypointsChoosingMode() + && !isInRouteLineCustomizationMode(); boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && !isInFollowTrackMode() && (additionalDialogsHide || !portrait); @@ -888,7 +890,8 @@ public class MapControlsLayer extends OsmandMapLayer { boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode() || isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode() - || isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode(); + || isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode() + || isInRouteLineCustomizationMode(); compassHud.forceHideCompass = forceHideCompass; compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); @@ -899,7 +902,8 @@ public class MapControlsLayer extends OsmandMapLayer { } boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls && !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode() - && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode(); + && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() + && !isInRouteLineCustomizationMode(); layersHud.updateVisibility(showTopButtons); quickSearchHud.updateVisibility(showTopButtons); @@ -1029,7 +1033,8 @@ public class MapControlsLayer extends OsmandMapLayer { && !isInGpxApproximationMode() && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode() - && !isInFollowTrackMode(); + && !isInFollowTrackMode() + && !isInRouteLineCustomizationMode(); backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() && (additionalDialogsHide || !isPotrait())); } @@ -1397,6 +1402,10 @@ public class MapControlsLayer extends OsmandMapLayer { return MapRouteInfoMenu.waypointsVisible; } + private boolean isInRouteLineCustomizationMode() { + return mapActivity.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode(); + } + private boolean isInFollowTrackMode() { return MapRouteInfoMenu.followTrackVisible; } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapQuickActionLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapQuickActionLayer.java index 4ba977235e..3591a2eca9 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapQuickActionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapQuickActionLayer.java @@ -61,6 +61,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe private final MapMarkersLayer mapMarkersLayer; private final MapControlsLayer mapControlsLayer; private final GPXLayer gpxLayer; + private final RouteLayer routeLayer; private ImageView contextMarker; private final MapActivity mapActivity; private final OsmandApplication app; @@ -90,6 +91,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer(); gpxLayer = mapActivity.getMapLayers().getGpxLayer(); mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer(); + routeLayer = mapActivity.getMapLayers().getRouteLayer(); } @Override @@ -426,6 +428,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe mapMarkersLayer.isInPlanRouteMode() || gpxLayer.isInTrackAppearanceMode() || mapControlsLayer.isInTrackMenuMode() || + routeLayer.isInRouteLineAppearanceMode() || mapRouteInfoMenu.isVisible() || MapRouteInfoMenu.chooseRoutesVisible || MapRouteInfoMenu.waypointsVisible || diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 083d94f4ff..1c934e9651 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -202,12 +202,12 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); } } - + } private boolean isPlanRouteGraphsAvailable() { - if (view.getContext() instanceof MapActivity) { - MapActivity mapActivity = (MapActivity) view.getContext(); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { MeasurementToolFragment fragment = mapActivity.getMeasurementToolFragment(); if (fragment != null) { return fragment.hasVisibleGraph(); @@ -216,6 +216,20 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont return false; } + public boolean isInRouteLineAppearanceMode() { + MapActivity mapActivity = getMapActivity(); + return mapActivity != null + && mapActivity.getRouteLineAppearanceFragment() != null + && mapActivity.getRouteLineAppearanceFragment().isVisible(); + } + + private MapActivity getMapActivity() { + if (view.getContext() instanceof MapActivity) { + return (MapActivity) view.getContext(); + } + return null; + } + private void updateAttrs(DrawSettings settings, RotatedTileBox tileBox) { boolean updatePaints = attrs.updatePaints(view.getApplication(), settings, tileBox); attrs.isPaint3 = false; @@ -636,12 +650,12 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont @Override public boolean disableSingleTap() { - return false; + return isInRouteLineAppearanceMode(); } @Override public boolean disableLongPressOnMap() { - return false; + return isInRouteLineAppearanceMode(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 6bc09a5987..993790bfea 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -1207,6 +1207,7 @@ public class MapInfoWidgetsFactory { boolean visible = settings.SHOW_COORDINATES_WIDGET.get() && !map.shouldHideTopControls() && map.getMapRouteInfoMenu().shouldShowTopControls() && !map.isTopToolbarActive() && !map.getMapLayers().getGpxLayer().isInTrackAppearanceMode() + && !map.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode() && !MapRouteInfoMenu.chooseRoutesVisible && !MapRouteInfoMenu.waypointsVisible && !MapRouteInfoMenu.followTrackVisible; diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java index 52801776cd..1490ab32b1 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapMarkersWidgetsFactory.java @@ -191,7 +191,8 @@ public class MapMarkersWidgetsFactory { || map.isTopToolbarActive() || map.shouldHideTopControls() || map.getMapLayers().getGpxLayer().isInTrackAppearanceMode() - || map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode()) { + || map.getMapLayers().getMapMarkersLayer().isInPlanRouteMode() + || map.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode()) { updateVisibility(false); return; } From f16b46295dd62551a05ef5f959f95e265e8d8664 Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 21 Mar 2021 14:44:37 +0500 Subject: [PATCH 19/96] Make track arrows more visible when track line is thin --- .../views/layers/geometry/GpxGeometryWay.java | 20 ++++++-- .../geometry/GpxGeometryWayContext.java | 11 +++++ .../layers/geometry/GpxGeometryWayDrawer.java | 46 ++++++++++++++++++- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java index 24d49df0b1..0e9b73dc82 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java @@ -2,13 +2,14 @@ package net.osmand.plus.views.layers.geometry; import android.graphics.Bitmap; -import androidx.annotation.NonNull; - +import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.WptPt; import net.osmand.data.RotatedTileBox; import java.util.List; +import androidx.annotation.NonNull; + public class GpxGeometryWay extends GeometryWay> { private List points; @@ -76,7 +77,9 @@ public class GpxGeometryWay extends GeometryWay { - private static final double DIRECTION_ARROW_DISTANCE_MULTIPLIER = 10.0; + private static final float TRACK_WIDTH_THRESHOLD = 8f; + private static final float ARROW_DISTANCE_MULTIPLIER = 1.5f; + private static final float SPECIAL_ARROW_DISTANCE_MULTIPLIER = 10f; private Bitmap arrowBitmap; @@ -114,6 +117,9 @@ public class GpxGeometryWay extends GeometryWay { @@ -22,31 +25,70 @@ public class GpxGeometryWayDrawer extends GeometryWayDrawer style) { super(x, y, angle, style); + createCircleBitmap((GeometryArrowsStyle) style); } @Override void draw(Canvas canvas, GeometryWayContext context) { if (style instanceof GeometryArrowsStyle) { + Context ctx = style.getCtx(); GeometryArrowsStyle arrowsWayStyle = (GeometryArrowsStyle) style; Bitmap bitmap = style.getPointBitmap(); + boolean useSpecialArrow = arrowsWayStyle.useSpecialArrow(); - float newWidth = arrowsWayStyle.getTrackWidth() / 2f; + float newWidth = useSpecialArrow ? AndroidUtils.dpToPx(ctx, 12) : arrowsWayStyle.getTrackWidth() / 2f; float paintH2 = bitmap.getHeight() / 2f; float paintW2 = newWidth / 2f; Matrix matrix = getMatrix(); matrix.reset(); - matrix.postScale(newWidth / bitmap.getWidth(), 1); + float sy = useSpecialArrow ? newWidth / bitmap.getHeight() : 1; + matrix.postScale(newWidth / bitmap.getWidth(), sy); matrix.postRotate((float) angle, paintW2, paintH2); matrix.postTranslate(x - paintW2, y - paintH2); + if (useSpecialArrow) { + drawCircle(canvas, arrowsWayStyle); + } + Paint paint = context.getPaintIconCustom(); Integer pointColor = style.getPointColor(); paint.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, matrix, paint); } } + + private void drawCircle(Canvas canvas, GeometryArrowsStyle style) { + float offset = circleBitmap.getWidth() / 2f; + float angleOffset = AndroidUtils.dpToPx(style.getCtx(), 1); + double rad = Math.toRadians(angle + 90); + float x = (float) (this.x - offset - angleOffset * Math.cos(rad)); + float y = (float) (this.y - offset - angleOffset * Math.sin(rad)); + canvas.drawBitmap(circleBitmap, x, y, null); + } + + private void createCircleBitmap(GeometryArrowsStyle style) { + Context ctx = style.getCtx(); + int size = AndroidUtils.dpToPx(ctx, 16); + circleBitmap = Bitmap.createBitmap(size, size, style.getPointBitmap().getConfig()); + Paint paint = new Paint(Paint.DITHER_FLAG | Paint.ANTI_ALIAS_FLAG); + paint.setStyle(Paint.Style.FILL); + + Canvas c = new Canvas(circleBitmap); + + paint.setColor(0x33000000); + Path path = new Path(); + path.addCircle(size / 2f, size / 2f, AndroidUtils.dpToPx(ctx, 8), Path.Direction.CW); + c.drawPath(path, paint); + + paint.setColor(style.getTrackColor()); + path.reset(); + path.addCircle(size / 2f, size / 2f, AndroidUtils.dpToPx(ctx, 7), Path.Direction.CW); + c.drawPath(path, paint); + } } } \ No newline at end of file From ec564d35a0af12401c17440c76741be1a339b33b Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 21 Mar 2021 14:28:51 +0200 Subject: [PATCH 20/96] remove duplicate code --- .../dialogs/SelectMapStyleBottomSheetDialogFragment.java | 5 +---- .../osmand/plus/quickaction/actions/MapStyleAction.java | 9 +++------ OsmAnd/src/net/osmand/plus/render/RendererRegistry.java | 6 ++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java index f5515f11bd..96c84bfd01 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/SelectMapStyleBottomSheetDialogFragment.java @@ -193,10 +193,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial List names = new ArrayList<>(renderers.keySet()); for (String name : names) { - String translation = RendererRegistry.getTranslatedRendererName(context, name); - if (translation == null) { - translation = name.replace('_', ' ').replace('-', ' '); - } + String translation = RendererRegistry.getRendererName(context, name); res.put(translation, name); } diff --git a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java index a526954365..1bcac88a36 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/actions/MapStyleAction.java @@ -102,9 +102,7 @@ public class MapStyleAction extends SwitchableAction { @Override public String getTranslatedItemName(Context context, String item) { - String translation = RendererRegistry.getTranslatedRendererName(context, item); - return translation != null ? translation - : item.replace('_', ' ').replace('-', ' '); + return RendererRegistry.getRendererName(context, item); } public List getFilteredStyles() { @@ -175,9 +173,8 @@ public class MapStyleAction extends SwitchableAction { List visibleNamesList = new ArrayList<>(); final List items = new ArrayList<>(renderers.keySet()); for (String item : items) { - String translation = RendererRegistry.getTranslatedRendererName(activity, item); - visibleNamesList.add(translation != null ? translation - : item.replace('_', ' ').replace('-', ' ')); + String name = RendererRegistry.getRendererName(activity, item); + visibleNamesList.add(name); } final ArrayAdapter arrayAdapter = new ArrayAdapter<>(themedContext, R.layout.dialog_text_item); diff --git a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java index 1b070e38a1..4d0773169d 100644 --- a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java +++ b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java @@ -289,6 +289,12 @@ public class RendererRegistry { return renderers; } + public static String getRendererName(@NonNull Context ctx, @NonNull String name) { + String translation = getTranslatedRendererName(ctx, name); + return translation != null ? translation : + name.replace('_', ' ').replace('-', ' '); + } + @Nullable public static String getTranslatedRendererName(@NonNull Context ctx, @NonNull String key) { switch (key) { From b651a18e8de88660960773249d5989a961c1499a Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 21 Mar 2021 14:29:42 +0200 Subject: [PATCH 21/96] add settings for custom route line colors --- OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 4b9d981c59..dac320c5db 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -2690,6 +2690,7 @@ public class OsmandSettings { public final CommonPreference ROUTE_RECALCULATION_DISTANCE = new FloatPreference(this, "routing_recalc_distance", 0.f).makeProfile(); public final CommonPreference ROUTE_STRAIGHT_ANGLE = new FloatPreference(this, "routing_straight_angle", 30.f).makeProfile(); + public final ListStringPreference CUSTOM_ROUTE_LINE_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_route_line_colors", null, ",").makeShared().makeGlobal(); public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference(this, "enable_osmc_routing", true).makeProfile(); From c2b47322a6e2df0957c0f3a821b093425bc90c7b Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 21 Mar 2021 14:32:18 +0200 Subject: [PATCH 22/96] Add RouteLineDrawInfo for drawing unsaved route line parameters --- .../plus/routing/RouteLineDrawInfo.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java new file mode 100644 index 0000000000..66fd7e28f8 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java @@ -0,0 +1,83 @@ +package net.osmand.plus.routing; + +import android.os.Bundle; + +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osmand.util.Algorithms; + +public class RouteLineDrawInfo { + + private static final String LINE_COLOR = "line_color"; + private static final String LINE_WIDTH = "line_width"; + + @ColorInt + private Integer color; + private Integer width; + + public RouteLineDrawInfo(@Nullable @ColorInt Integer color, + @Nullable Integer width) { + this.color = color; + this.width = width; + } + + public RouteLineDrawInfo(@NonNull Bundle bundle) { + readBundle(bundle); + } + + public RouteLineDrawInfo(@NonNull RouteLineDrawInfo existed) { + this(existed.getColor(), existed.getWidth()); + } + + @Nullable + public Integer getColor() { + return color; + } + + @Nullable + public Integer getWidth() { + return width; + } + + public void setColor(@Nullable Integer color) { + this.color = color; + } + + public void setWidth(@Nullable Integer width) { + this.width = width; + } + + private void readBundle(@NonNull Bundle bundle) { + color = bundle.getInt(LINE_COLOR); + width = bundle.getInt(LINE_WIDTH); + } + + public void saveToBundle(@NonNull Bundle bundle) { + if (color != null) { + bundle.putInt(LINE_COLOR, color); + } + if (width != null) { + bundle.putInt(LINE_WIDTH, width); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof RouteLineDrawInfo)) return false; + + RouteLineDrawInfo that = (RouteLineDrawInfo) o; + + if (!Algorithms.objectEquals(getColor(), that.getColor())) return false; + return Algorithms.objectEquals(getWidth(), that.getWidth()); + } + + @Override + public int hashCode() { + int result = color != null ? color.hashCode() : 0; + result = 31 * result + (width != null ? width.hashCode() : 0); + return result; + } +} From 32e0defac08c4d44504e2b1d3a203c06e0dff463 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 21 Mar 2021 14:32:57 +0200 Subject: [PATCH 23/96] add temporally helper class --- .../osmand/plus/routing/RouteLineHelper.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 OsmAnd/src/net/osmand/plus/routing/RouteLineHelper.java diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineHelper.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineHelper.java new file mode 100644 index 0000000000..f9091621d3 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineHelper.java @@ -0,0 +1,59 @@ +package net.osmand.plus.routing; + +import android.graphics.Color; + +import androidx.annotation.NonNull; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.settings.backend.ApplicationMode; + +// it's just a test class, maybe it's better to move methods to other places or change the architecture +public class RouteLineHelper { + + public static void saveRouteLineAppearance(@NonNull OsmandApplication app, + @NonNull ApplicationMode appMode, + @NonNull RouteLineDrawInfo drawInfo) { + // save to settings + } + + public static RouteLineDrawInfo createDrawInfoForAppMode(@NonNull OsmandApplication app, + @NonNull ApplicationMode appMode) { + Integer color = getColorFromSettings(app, appMode); + Integer width = getWidthFromSettings(app, appMode); + return new RouteLineDrawInfo(color, width); + } + + public static Integer getColorFromSettings(@NonNull OsmandApplication app, + @NonNull ApplicationMode appMode) { + return null; + } + + public static Integer getWidthFromSettings(@NonNull OsmandApplication app, + @NonNull ApplicationMode appMode) { + return null; + } + + public static int getColor(@NonNull RouteLineDrawInfo drawInfo) { + if (drawInfo.getColor() != null) { + return drawInfo.getColor(); + } + return getMapStyleColor(); + } + + public static int getWidth(@NonNull RouteLineDrawInfo drawInfo) { + if (drawInfo.getWidth() != null) { + return drawInfo.getWidth(); + } + return getMapStyleWidth(); + } + + public static int getMapStyleColor() { + // get color from selected map style + return Color.BLUE; + } + + public static int getMapStyleWidth() { + // get width from selected map style + return 10; + } +} From 14bd85a64c52627de2e6e595493e6f40a6db4c08 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 21 Mar 2021 14:44:53 +0200 Subject: [PATCH 24/96] add ability to edit RouteLineDrawInfo and finish dialog UI --- OsmAnd/res/layout/route_line_color_card.xml | 100 +++++ OsmAnd/res/layout/route_line_width_card.xml | 170 +++++++++ .../routing/cards/RouteLineColorCard.java | 347 ++++++++++++++++++ .../routing/cards/RouteLineWidthCard.java | 313 ++++++++++++++++ .../fragments/ProfileAppearanceFragment.java | 21 +- .../RouteLineAppearanceFragment.java | 135 ++++++- .../osmand/plus/views/layers/RouteLayer.java | 19 +- 7 files changed, 1091 insertions(+), 14 deletions(-) create mode 100644 OsmAnd/res/layout/route_line_color_card.xml create mode 100644 OsmAnd/res/layout/route_line_width_card.xml create mode 100644 OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java create mode 100644 OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java diff --git a/OsmAnd/res/layout/route_line_color_card.xml b/OsmAnd/res/layout/route_line_color_card.xml new file mode 100644 index 0000000000..d1c96345b5 --- /dev/null +++ b/OsmAnd/res/layout/route_line_color_card.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/route_line_width_card.xml b/OsmAnd/res/layout/route_line_width_card.xml new file mode 100644 index 0000000000..9d0702b1dd --- /dev/null +++ b/OsmAnd/res/layout/route_line_width_card.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java new file mode 100644 index 0000000000..88e91c3b2a --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java @@ -0,0 +1,347 @@ +package net.osmand.plus.routing.cards; + +import android.content.Context; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import net.osmand.AndroidUtils; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.ColorDialogs; +import net.osmand.plus.helpers.enums.DayNightMode; +import net.osmand.plus.render.RendererRegistry; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; +import net.osmand.plus.routing.RouteLineDrawInfo; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.ListStringPreference; +import net.osmand.plus.track.AppearanceViewHolder; +import net.osmand.plus.track.ColorsCard; +import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; +import net.osmand.plus.widgets.MultiStateToggleButton; +import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener; +import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; +import net.osmand.render.RenderingRulesStorage; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + +public class RouteLineColorCard extends BaseCard implements CardListener, ColorPickerListener { + + private static final int DAY_TITLE_ID = R.string.day; + private static final int NIGHT_TITLE_ID = R.string.night; + + private final Fragment targetFragment; + private ApplicationMode appMode; + + private ColorsCard colorsCard; + private ColorTypeAdapter colorAdapter; + private RecyclerView groupRecyclerView; + private TextView tvColorName; + private TextView tvDescription; + private View themeToggleContainer; + private ViewGroup cardsContainer; + + private ColorMode selectedMode; + private RouteLineDrawInfo routeLineDrawInfo; + private DayNightMode initMapTheme; + private DayNightMode selectedMapTheme; + + private enum ColorMode { + DEFAULT(R.string.map_widget_renderer, R.drawable.ic_action_map_style), + CUSTOM(R.string.shared_string_custom, R.drawable.ic_action_settings); + + ColorMode(int titleId, int iconId) { + this.titleId = titleId; + this.iconId = iconId; + } + + int titleId; + int iconId; + } + + public RouteLineColorCard(@NonNull MapActivity mapActivity, + @NonNull Fragment targetFragment, + @NonNull RouteLineDrawInfo routeLineDrawInfo, + @NonNull ApplicationMode appMode, + @NonNull DayNightMode initMapTheme, + @NonNull DayNightMode selectedMapTheme) { + super(mapActivity); + this.targetFragment = targetFragment; + this.routeLineDrawInfo = routeLineDrawInfo; + this.appMode = appMode; + this.initMapTheme = initMapTheme; + this.selectedMapTheme = selectedMapTheme; + } + + @Override + public int getCardLayoutId() { + return R.layout.route_line_color_card; + } + + @Override + protected void updateContent() { + tvColorName = view.findViewById(R.id.color_name); + tvDescription = view.findViewById(R.id.description); + + colorAdapter = new ColorTypeAdapter(); + groupRecyclerView = view.findViewById(R.id.recycler_view); + groupRecyclerView.setAdapter(colorAdapter); + groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); + + themeToggleContainer = view.findViewById(R.id.theme_toggle_container); + LinearLayout radioGroup = (LinearLayout) view.findViewById(R.id.custom_radio_buttons); + setupRadioGroup(radioGroup); + + cardsContainer = (ViewGroup) view.findViewById(R.id.colors_card_container); + createColorSelector(cardsContainer); + + initSelectedMode(); + } + + private void initSelectedMode() { + selectedMode = routeLineDrawInfo.getColor() == null ? ColorMode.DEFAULT : ColorMode.CUSTOM; + modeChanged(); + } + + private void modeChanged() { + if (selectedMode == ColorMode.DEFAULT) { + themeToggleContainer.setVisibility(View.GONE); + cardsContainer.setVisibility(View.GONE); + changeMapTheme(initMapTheme); + } else { + themeToggleContainer.setVisibility(View.VISIBLE); + cardsContainer.setVisibility(View.VISIBLE); + changeMapTheme(isNightMap() ? DayNightMode.NIGHT : DayNightMode.DAY); + } + updateSelectedColor(); + updateDescription(); + } + + private void setupRadioGroup(LinearLayout buttonsContainer) { + RadioItem day = createMapThemeButton(false); + RadioItem night = createMapThemeButton(true); + + MultiStateToggleButton radioGroup = new MultiStateToggleButton(app, buttonsContainer, nightMode); + radioGroup.setItems(day, night); + + radioGroup.setSelectedItem(!isNightMap() ? day : night); + } + + private RadioItem createMapThemeButton(final boolean isNight) { + RadioItem item = new RadioItem(app.getString(!isNight ? DAY_TITLE_ID : NIGHT_TITLE_ID)); + item.setOnClickListener(new OnRadioItemClickListener() { + @Override + public boolean onRadioItemClick(RadioItem radioItem, View view) { + selectedMapTheme = isNight ? DayNightMode.NIGHT : DayNightMode.DAY; + changeMapTheme(selectedMapTheme); + updateDescription(); + return true; + } + }); + return item; + } + + private void changeMapTheme(DayNightMode mapTheme) { + if (targetFragment instanceof OnMapThemeUpdateListener) { + ((OnMapThemeUpdateListener) targetFragment).onMapThemeUpdated(mapTheme); + } + } + + private void createColorSelector(ViewGroup container) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + List colors = new ArrayList<>(); + for (int color : ColorDialogs.pallette) { + colors.add(color); + } + Integer selectedColor = routeLineDrawInfo.getColor(); + if (selectedColor != null) { + if (!ColorDialogs.isPaletteColor(selectedColor)) { + colors.add(selectedColor); + } + } else { + selectedColor = colors.get(0); + } + ListStringPreference preference = app.getSettings().CUSTOM_ROUTE_LINE_COLORS; + colorsCard = new ColorsCard(mapActivity, selectedColor, targetFragment, colors, preference, appMode); + colorsCard.setListener(this); + container.addView(colorsCard.build(mapActivity)); + } + } + + @Override + public void onColorSelected(Integer prevColor, int newColor) { + colorsCard.onColorSelected(prevColor, newColor); + updateSelectedColor(); + } + + private void updateSelectedColor() { + Integer color = selectedMode == ColorMode.CUSTOM ? colorsCard.getSelectedColor() : null; + routeLineDrawInfo.setColor(color); + updateColorName(); + if (targetFragment instanceof OnSelectedColorChangeListener) { + ((OnSelectedColorChangeListener) targetFragment).onSelectedColorChanged(); + } + } + + private void updateColorName() { + if (selectedMode == ColorMode.DEFAULT) { + tvColorName.setText(app.getString(R.string.map_widget_renderer)); + } else { + int selectedColor = routeLineDrawInfo.getColor(); + int colorNameId = ColorDialogs.getColorName(selectedColor); + tvColorName.setText(app.getString(colorNameId)); + } + } + + private void updateDescription() { + String description; + if (selectedMode == ColorMode.DEFAULT) { + String pattern = app.getString(R.string.route_line_use_map_style_appearance); + String color = app.getString(R.string.shared_string_color).toLowerCase(); + description = String.format(pattern, color, getMapStyleName()); + } else { + String pattern = app.getString(R.string.specify_color_for_map_mode); + String mapModeTitle = app.getString(isNightMap() ? NIGHT_TITLE_ID : DAY_TITLE_ID); + description = String.format(pattern, mapModeTitle.toLowerCase()); + } + tvDescription.setText(description); + } + + private String getMapStyleName() { + RendererRegistry rr = app.getRendererRegistry(); + RenderingRulesStorage storage = rr.getCurrentSelectedRenderer(); + if (storage == null) { + return ""; + } + return RendererRegistry.getRendererName(app, storage.getName()); + } + + private boolean isNightMap() { + return selectedMapTheme.isNight(); + } + + @Override + public void onCardLayoutNeeded(@NonNull BaseCard card) { + + } + + @Override + public void onCardPressed(@NonNull BaseCard card) { + if (card instanceof ColorsCard) { + updateSelectedColor(); + } + } + + @Override + public void onCardButtonPressed(@NonNull BaseCard card, int buttonIndex) { + + } + + private class ColorTypeAdapter extends RecyclerView.Adapter { + + private List items = Arrays.asList(ColorMode.values()); + + @NonNull + @Override + public AppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode); + View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false); + view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width); + view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height); + + AppearanceViewHolder holder = new AppearanceViewHolder(view); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp, + R.drawable.ripple_solid_dark_6dp); + } + return holder; + } + + @Override + public void onBindViewHolder(@NonNull final AppearanceViewHolder holder, int position) { + ColorMode item = items.get(position); + holder.title.setText(app.getString(item.titleId)); + + updateButtonBg(holder, item); + updateTextAndIconColor(holder, item); + + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + selectedMode = items.get(holder.getAdapterPosition()); + notifyItemRangeChanged(0, getItemCount()); + + modeChanged(); + + CardListener listener = getListener(); + if (listener != null) { + listener.onCardPressed(RouteLineColorCard.this); + } + } + }); + } + + private void updateButtonBg(AppearanceViewHolder holder, ColorMode item) { + GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline); + if (rectContourDrawable != null) { + if (selectedMode == item) { + int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor); + } else { + int strokeColor = ContextCompat.getColor(app, nightMode ? + R.color.stroked_buttons_and_links_outline_dark : + R.color.stroked_buttons_and_links_outline_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor); + } + holder.button.setImageDrawable(rectContourDrawable); + } + } + + private void updateTextAndIconColor(AppearanceViewHolder holder, ColorMode item) { + Context ctx = holder.itemView.getContext(); + int iconColorId; + int textColorId; + + if (selectedMode == item) { + iconColorId = AndroidUtils.getColorFromAttr(ctx, R.attr.default_icon_color); + textColorId = AndroidUtils.getColorFromAttr(ctx, android.R.attr.textColor); + } else { + iconColorId = AndroidUtils.getColorFromAttr(ctx, R.attr.colorPrimary); + textColorId = iconColorId; + } + + holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(item.iconId, iconColorId)); + holder.title.setTextColor(textColorId); + } + + @Override + public int getItemCount() { + return items.size(); + } + } + + public interface OnSelectedColorChangeListener { + void onSelectedColorChanged(); + } + + public interface OnMapThemeUpdateListener { + void onMapThemeUpdated(@NonNull DayNightMode mapTheme); + } +} diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java new file mode 100644 index 0000000000..8925fcec37 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -0,0 +1,313 @@ +package net.osmand.plus.routing.cards; + +import android.content.Context; +import android.graphics.drawable.GradientDrawable; +import android.os.Build; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.github.ksoichiro.android.observablescrollview.ScrollUtils; +import com.google.android.material.slider.Slider; + +import net.osmand.AndroidUtils; +import net.osmand.plus.R; +import net.osmand.plus.UiUtilities; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.render.RendererRegistry; +import net.osmand.plus.routepreparationmenu.cards.BaseCard; +import net.osmand.plus.routing.RouteLineDrawInfo; +import net.osmand.plus.routing.RouteLineHelper; +import net.osmand.plus.track.AppearanceViewHolder; +import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; +import net.osmand.render.RenderingRulesStorage; + +import java.util.Arrays; +import java.util.List; + +public class RouteLineWidthCard extends BaseCard { + + private final static int CUSTOM_WIDTH_MIN = 1; + private final static int CUSTOM_WIDTH_MAX = 24; + + private RouteLineDrawInfo routeLineDrawInfo; + private OnNeedScrollListener onNeedScrollListener; + + private WidthMode selectedMode; + + private WidthAdapter widthAdapter; + private View sliderContainer; + private RecyclerView groupRecyclerView; + private TextView tvModeType; + private TextView tvDescription; + + private enum WidthMode { + DEFAULT(R.string.map_widget_renderer, R.drawable.ic_action_map_style, null), + THIN(R.string.rendering_value_thin_name, R.drawable.ic_action_track_line_thin_color, 5), + MEDIUM(R.string.rendering_value_medium_name, R.drawable.ic_action_track_line_medium_color, 13), + THICK(R.string.rendering_value_bold_name, R.drawable.ic_action_track_line_bold_color, 28), + CUSTOM(R.string.shared_string_custom, R.drawable.ic_action_settings, null); + + WidthMode(int titleId, int iconId, Integer width) { + this.titleId = titleId; + this.iconId = iconId; + this.width = width; + } + + int titleId; + int iconId; + Integer width; + } + + public RouteLineWidthCard(@NonNull MapActivity mapActivity, + @NonNull RouteLineDrawInfo routeLineDrawInfo, + @NonNull OnNeedScrollListener onNeedScrollListener) { + super(mapActivity); + this.routeLineDrawInfo = routeLineDrawInfo; + this.onNeedScrollListener = onNeedScrollListener; + } + + @Override + public int getCardLayoutId() { + return R.layout.route_line_width_card; + } + + @Override + protected void updateContent() { + widthAdapter = new WidthAdapter(); + groupRecyclerView = view.findViewById(R.id.recycler_view); + groupRecyclerView.setAdapter(widthAdapter); + groupRecyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false)); + + tvModeType = view.findViewById(R.id.width_type); + tvDescription = view.findViewById(R.id.description); + sliderContainer = view.findViewById(R.id.slider_container); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.top_divider), isShowDivider()); + + initSelectedMode(); + } + + private void initSelectedMode() { + selectedMode = findAppropriateMode(getRouteLineWidth()); + modeChanged(); + } + + private void modeChanged() { + updateHeader(); + updateDescription(); + updateCustomWidthSlider(); + scrollMenuToSelectedItem(); + } + + public void updateItems() { + if (widthAdapter != null) { + widthAdapter.notifyDataSetChanged(); + } + } + + private void setRouteLineWidth(Integer width) { + routeLineDrawInfo.setWidth(width); + mapActivity.refreshMap(); + } + + private Integer getRouteLineWidth() { + return routeLineDrawInfo.getWidth(); + } + + private void updateHeader() { + tvModeType.setText(app.getString(selectedMode.titleId)); + } + + private void updateDescription() { + if (selectedMode == WidthMode.DEFAULT) { + String pattern = app.getString(R.string.route_line_use_map_style_appearance); + String width = app.getString(R.string.shared_string_color).toLowerCase(); + String description = String.format(pattern, width, getMapStyleName()); + tvDescription.setText(description); + tvDescription.setVisibility(View.VISIBLE); + } else { + tvDescription.setVisibility(View.GONE); + } + } + + private String getMapStyleName() { + RendererRegistry rr = app.getRendererRegistry(); + RenderingRulesStorage storage = rr.getCurrentSelectedRenderer(); + if (storage == null) { + return ""; + } + return RendererRegistry.getRendererName(app, storage.getName()); + } + + private void updateCustomWidthSlider() { + if (selectedMode == WidthMode.CUSTOM) { + Slider widthSlider = view.findViewById(R.id.width_slider); + + widthSlider.setValueTo(CUSTOM_WIDTH_MAX); + widthSlider.setValueFrom(CUSTOM_WIDTH_MIN); + + ((TextView) view.findViewById(R.id.width_value_min)).setText(String.valueOf(CUSTOM_WIDTH_MIN)); + ((TextView) view.findViewById(R.id.width_value_max)).setText(String.valueOf(CUSTOM_WIDTH_MAX)); + + Integer width = getRouteLineWidth(); + if (width == null || width > CUSTOM_WIDTH_MAX || width < CUSTOM_WIDTH_MIN) { + width = CUSTOM_WIDTH_MIN; + } + widthSlider.setValue(width); + + final TextView tvCustomWidth = view.findViewById(R.id.width_value_tv); + widthSlider.addOnChangeListener(new Slider.OnChangeListener() { + @Override + public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { + if (fromUser) { + Integer newWidth = (int) value; + setRouteLineWidth(newWidth); + tvCustomWidth.setText(String.valueOf(newWidth)); + } + } + }); + UiUtilities.setupSlider(widthSlider, nightMode, null, true); + ScrollUtils.addOnGlobalLayoutListener(sliderContainer, new Runnable() { + @Override + public void run() { + if (sliderContainer.getVisibility() == View.VISIBLE) { + onNeedScrollListener.onVerticalScrollNeeded(sliderContainer.getBottom()); + } + } + }); + AndroidUiHelper.updateVisibility(sliderContainer, true); + } else { + AndroidUiHelper.updateVisibility(sliderContainer, false); + } + } + + private void scrollMenuToSelectedItem() { + int position = widthAdapter.getItemPosition(selectedMode); + if (position != -1) { + groupRecyclerView.scrollToPosition(position); + } + } + + private static WidthMode findAppropriateMode(Integer width) { + WidthMode result = null; + if (width != null) { + for (WidthMode mode : WidthMode.values()) { + if (mode.width != null && (int) width == mode.width) { + result = mode; + break; + } + } + if (result == null) { + result = WidthMode.CUSTOM; + } + } else { + result = WidthMode.DEFAULT; + } + return result; + } + + private class WidthAdapter extends RecyclerView.Adapter { + + private final List items = Arrays.asList(WidthMode.values()); + + @NonNull + @Override + public AppearanceViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + LayoutInflater themedInflater = UiUtilities.getInflater(parent.getContext(), nightMode); + View view = themedInflater.inflate(R.layout.point_editor_group_select_item, parent, false); + view.getLayoutParams().width = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_width); + view.getLayoutParams().height = app.getResources().getDimensionPixelSize(R.dimen.gpx_group_button_height); + + AppearanceViewHolder holder = new AppearanceViewHolder(view); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AndroidUtils.setBackground(app, holder.button, nightMode, R.drawable.ripple_solid_light_6dp, + R.drawable.ripple_solid_dark_6dp); + } + return holder; + } + + @Override + public void onBindViewHolder(@NonNull final AppearanceViewHolder holder, int position) { + WidthMode item = items.get(position); + holder.title.setText(app.getString(item.titleId)); + + updateButtonBg(holder, item); + updateTextAndIconColor(holder, item); + + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + int prevSelectedPosition = getItemPosition(selectedMode); + selectedMode = items.get(holder.getAdapterPosition()); + notifyItemChanged(holder.getAdapterPosition()); + notifyItemChanged(prevSelectedPosition); + + if (selectedMode != WidthMode.CUSTOM) { + setRouteLineWidth(selectedMode.width); + } + modeChanged(); + + CardListener listener = getListener(); + if (listener != null) { + listener.onCardPressed(RouteLineWidthCard.this); + } + } + }); + } + + private void updateTextAndIconColor(AppearanceViewHolder holder, WidthMode item) { + Context ctx = holder.itemView.getContext(); + int iconColor; + int textColorId; + + if (selectedMode == item) { + iconColor = getIconColor(item, AndroidUtils.getColorFromAttr(ctx, R.attr.default_icon_color)); + textColorId = AndroidUtils.getColorFromAttr(ctx, android.R.attr.textColor); + } else { + iconColor = getIconColor(item, AndroidUtils.getColorFromAttr(ctx, R.attr.colorPrimary)); + textColorId = AndroidUtils.getColorFromAttr(ctx, R.attr.colorPrimary); + } + + holder.icon.setImageDrawable(app.getUIUtilities().getPaintedIcon(item.iconId, iconColor)); + holder.title.setTextColor(textColorId); + } + + private int getIconColor(@NonNull WidthMode mode, @ColorInt int defaultColor) { + return mode.width != null ? RouteLineHelper.getColor(routeLineDrawInfo) : defaultColor; + } + + private void updateButtonBg(AppearanceViewHolder holder, WidthMode item) { + GradientDrawable rectContourDrawable = (GradientDrawable) AppCompatResources.getDrawable(app, R.drawable.bg_select_group_button_outline); + if (rectContourDrawable != null) { + if (selectedMode == item) { + int strokeColor = ContextCompat.getColor(app, nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 2), strokeColor); + } else { + int strokeColor = ContextCompat.getColor(app, nightMode ? + R.color.stroked_buttons_and_links_outline_dark + : R.color.stroked_buttons_and_links_outline_light); + rectContourDrawable.setStroke(AndroidUtils.dpToPx(app, 1), strokeColor); + } + holder.button.setImageDrawable(rectContourDrawable); + } + } + + @Override + public int getItemCount() { + return items.size(); + } + + int getItemPosition(WidthMode widthMode) { + return items.indexOf(widthMode); + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 939e8124c7..3416222b95 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -54,10 +54,13 @@ import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; +import net.osmand.plus.routing.RouteLineDrawInfo; +import net.osmand.plus.routing.RouteLineHelper; import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper; +import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.OnApplyRouteLineListener; import net.osmand.plus.track.ColorsCard; import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.widgets.FlowLayout; @@ -76,7 +79,7 @@ import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILES_LIST_UP import static net.osmand.plus.profiles.SelectProfileBottomSheet.PROFILE_KEY_ARG; import static net.osmand.plus.routing.TransportRoutingHelper.PUBLIC_TRANSPORT_KEY; -public class ProfileAppearanceFragment extends BaseSettingsFragment implements OnSelectProfileCallback, CardListener, ColorPickerListener { +public class ProfileAppearanceFragment extends BaseSettingsFragment implements OnSelectProfileCallback, CardListener, ColorPickerListener, OnApplyRouteLineListener { private static final Log LOG = PlatformUtil.getLog(ProfileAppearanceFragment.class); @@ -161,6 +164,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O changedProfile.routeService = profile.routeService; changedProfile.locationIcon = profile.locationIcon; changedProfile.navigationIcon = profile.navigationIcon; + changedProfile.routeLineDrawInfo = profile.routeLineDrawInfo; isNewProfile = ApplicationMode.valueOfStringKey(changedProfile.stringKey, null) == null; } requireMyActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { @@ -181,6 +185,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O profile.routeService = baseModeForNewProfile.getRouteService(); profile.locationIcon = baseModeForNewProfile.getLocationIcon(); profile.navigationIcon = baseModeForNewProfile.getNavigationIcon(); + profile.routeLineDrawInfo = RouteLineHelper.createDrawInfoForAppMode(app, profile.parent); } @Override @@ -323,6 +328,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O outState.putBoolean(IS_BASE_PROFILE_IMPORTED, isBaseProfileImported); outState.putSerializable(PROFILE_LOCATION_ICON_KEY, changedProfile.locationIcon); outState.putSerializable(PROFILE_NAVIGATION_ICON_KEY, changedProfile.navigationIcon); + changedProfile.routeLineDrawInfo.saveToBundle(outState); } private void restoreState(Bundle savedInstanceState) { @@ -336,6 +342,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O isBaseProfileImported = savedInstanceState.getBoolean(IS_BASE_PROFILE_IMPORTED); changedProfile.locationIcon = (LocationIcon) savedInstanceState.getSerializable(PROFILE_LOCATION_ICON_KEY); changedProfile.navigationIcon = (NavigationIcon) savedInstanceState.getSerializable(PROFILE_NAVIGATION_ICON_KEY); + changedProfile.routeLineDrawInfo = new RouteLineDrawInfo(savedInstanceState); isNewProfile = savedInstanceState.getBoolean(IS_NEW_PROFILE_KEY); } @@ -771,6 +778,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O mode.setCustomIconColor(changedProfile.customColor); mode.setLocationIcon(changedProfile.locationIcon); mode.setNavigationIcon(changedProfile.navigationIcon); + RouteLineHelper.saveRouteLineAppearance(app, mode, changedProfile.routeLineDrawInfo); FragmentActivity activity = getActivity(); if (activity != null) { @@ -798,6 +806,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O if (!ApplicationMode.values(app).contains(mode)) { ApplicationMode.changeProfileAvailability(mode, true, app); } + RouteLineHelper.saveRouteLineAppearance(app, mode, changedProfile.routeLineDrawInfo); return mode; } @@ -989,7 +998,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O MapActivity mapActivity = getMapActivity(); ApplicationMode appMode = getSelectedAppMode(); if (mapActivity != null && appMode != null) { - RouteLineAppearanceFragment.showInstance(mapActivity, appMode, this); + RouteLineAppearanceFragment.showInstance(mapActivity, changedProfile.routeLineDrawInfo, appMode, this); } } return super.onPreferenceClick(preference); @@ -1005,6 +1014,11 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O this.onCardPressed(colorsCard); } + @Override + public void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo) { + changedProfile.routeLineDrawInfo = routeLineDrawInfo; + } + public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable String appMode, boolean imported) { try { Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName); @@ -1036,6 +1050,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O RouteService routeService; NavigationIcon navigationIcon; LocationIcon locationIcon; + RouteLineDrawInfo routeLineDrawInfo; @ColorInt public int getActualColor() { @@ -1072,6 +1087,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O return false; if (routeService != that.routeService) return false; if (navigationIcon != that.navigationIcon) return false; + if (routeLineDrawInfo != that.routeLineDrawInfo) return false; return locationIcon == that.locationIcon; } @@ -1087,6 +1103,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O result = 31 * result + (routeService != null ? routeService.hashCode() : 0); result = 31 * result + (navigationIcon != null ? navigationIcon.hashCode() : 0); result = 31 * result + (locationIcon != null ? locationIcon.hashCode() : 0); + result = 31 * result + (routeLineDrawInfo != null ? routeLineDrawInfo.hashCode() : 0); return result; } } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java index ee6ffec18e..39d9c853ca 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -10,6 +10,7 @@ import android.view.ViewTreeObserver; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.ScrollView; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; @@ -19,26 +20,45 @@ import androidx.fragment.app.FragmentActivity; import net.osmand.AndroidUtils; import net.osmand.plus.LockableScrollView; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.DialogButtonType; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.enums.DayNightMode; +import net.osmand.plus.routing.RouteLineDrawInfo; +import net.osmand.plus.routing.cards.RouteLineColorCard; +import net.osmand.plus.routing.cards.RouteLineColorCard.OnMapThemeUpdateListener; +import net.osmand.plus.routing.cards.RouteLineColorCard.OnSelectedColorChangeListener; +import net.osmand.plus.routing.cards.RouteLineWidthCard; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; +import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; -public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { +public class RouteLineAppearanceFragment extends ContextMenuScrollFragment implements ColorPickerListener, OnSelectedColorChangeListener, OnMapThemeUpdateListener { - public final static String TAG = RouteLineAppearanceFragment.class.getName(); + public static final String TAG = RouteLineAppearanceFragment.class.getName(); + + private static final String INIT_MAP_THEME = "init_map_theme"; + private static final String SELECTED_MAP_THEME = "selected_map_theme"; private ApplicationMode appMode; + private RouteLineDrawInfo routeLineDrawInfo; + private int toolbarHeightPx; + private DayNightMode initMapTheme; + private DayNightMode selectedMapTheme; private View buttonsShadow; private View controlButtons; private View toolbarContainer; + private RouteLineColorCard colorCard; + private RouteLineWidthCard widthCard; + @Override public int getMainLayoutId() { return R.layout.route_line_appearance; @@ -82,8 +102,19 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + toolbarHeightPx = getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); - requireMyActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { + + if (savedInstanceState != null) { + routeLineDrawInfo = new RouteLineDrawInfo(savedInstanceState); + initMapTheme = DayNightMode.valueOf(savedInstanceState.getString(INIT_MAP_THEME)); + selectedMapTheme = DayNightMode.valueOf(savedInstanceState.getString(SELECTED_MAP_THEME)); + } else { + initMapTheme = getMyApplication().getSettings().DAYNIGHT_MODE.get(); + selectedMapTheme = initMapTheme; + } + + requireMapActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { public void handleOnBackPressed() { dismiss(); } @@ -136,6 +167,36 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { private void setupCards() { MapActivity mapActivity = requireMapActivity(); ViewGroup cardsContainer = getCardsContainer(); + + colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, appMode, initMapTheme, selectedMapTheme); + cardsContainer.addView(colorCard.build(mapActivity)); + + widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener()); + cardsContainer.addView(widthCard.build(mapActivity)); + } + + private OnNeedScrollListener createScrollListener() { + return new OnNeedScrollListener() { + + @Override + public void onVerticalScrollNeeded(int y) { + View view = widthCard.getView(); + if (view != null) { + int resultYPosition = view.getTop() + y; + int dialogHeight = getInnerScrollableHeight(); + ScrollView scrollView = (ScrollView) getBottomScrollView(); + if (resultYPosition > (scrollView.getScrollY() + dialogHeight)) { + scrollView.smoothScrollTo(0, resultYPosition - dialogHeight); + } + } + } + + private int getInnerScrollableHeight() { + int totalScreenHeight = getViewHeight() - getMenuStatePosY(getCurrentMenuState()); + int frameTotalHeight = controlButtons.getHeight() + buttonsShadow.getHeight(); + return totalScreenHeight - frameTotalHeight; + } + }; } private void setupToolbar() { @@ -143,7 +204,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // discard changes dismiss(); } }); @@ -172,7 +232,9 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // save changes + if (getTargetFragment() instanceof OnApplyRouteLineListener) { + ((OnApplyRouteLineListener) getTargetFragment()).applyRouteLineAppearance(routeLineDrawInfo); + } dismiss(); } }); @@ -181,7 +243,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - // discard changes FragmentActivity activity = getActivity(); if (activity != null) { activity.onBackPressed(); @@ -225,6 +286,33 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { .setDuration(200); } + @Override + public void onResume() { + super.onResume(); + setDrawInfoOnRouteLayer(routeLineDrawInfo); + } + + @Override + public void onPause() { + super.onPause(); + setDrawInfoOnRouteLayer(null); + } + + private void setDrawInfoOnRouteLayer(@Nullable RouteLineDrawInfo drawInfo) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getMapLayers().getRouteLayer().setRouteLineDrawInfo(drawInfo); + } + } + + @Override + public void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + outState.putString(INIT_MAP_THEME, initMapTheme.name()); + outState.putString(SELECTED_MAP_THEME, selectedMapTheme.name()); + routeLineDrawInfo.saveToBundle(outState); + } + @Override public void onDestroyView() { super.onDestroyView(); @@ -250,6 +338,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { R.id.map_right_widgets_panel, R.id.map_center_info, R.id.map_search_button); + changeMapTheme(initMapTheme); } } @@ -271,13 +360,30 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { } } + @Override + public void onColorSelected(Integer prevColor, int newColor) { + colorCard.onColorSelected(prevColor, newColor); + } + + @Override + public void onSelectedColorChanged() { + if (widthCard != null) { + widthCard.updateItems(); + } + if (getMapActivity() != null) { + getMapActivity().refreshMap(); + } + } + public static boolean showInstance(@NonNull MapActivity mapActivity, + @NonNull RouteLineDrawInfo drawInfo, @NonNull ApplicationMode appMode, @NonNull Fragment target) { try { RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment(); fragment.setRetainInstance(true); fragment.setTargetFragment(target, 0); + fragment.routeLineDrawInfo = new RouteLineDrawInfo(drawInfo); fragment.appMode = appMode; mapActivity.getSupportFragmentManager() @@ -290,4 +396,21 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment { return false; } } + + @Override + public void onMapThemeUpdated(@NonNull DayNightMode mapTheme) { + changeMapTheme(mapTheme); + } + + private void changeMapTheme(@NonNull DayNightMode mapTheme) { + OsmandApplication app = getMyApplication(); + if (app != null) { + app.getSettings().DAYNIGHT_MODE.set(mapTheme); + selectedMapTheme = mapTheme; + } + } + + public interface OnApplyRouteLineListener { + void applyRouteLineAppearance(@NonNull RouteLineDrawInfo routeLineDrawInfo); + } } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 1c934e9651..ce7a9e12bd 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -32,6 +32,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteDirectionInfo; +import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; @@ -67,6 +68,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private LayerDrawable selectedPoint; private TrackChartPoints trackChartPoints; + private RouteLineDrawInfo routeLineDrawInfo; private RenderingLineAttributes attrs; private RenderingLineAttributes attrsPT; @@ -217,10 +219,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } public boolean isInRouteLineAppearanceMode() { - MapActivity mapActivity = getMapActivity(); - return mapActivity != null - && mapActivity.getRouteLineAppearanceFragment() != null - && mapActivity.getRouteLineAppearanceFragment().isVisible(); + return routeLineDrawInfo != null; + } + + public void setRouteLineDrawInfo(RouteLineDrawInfo routeLineDrawInfo) { + this.routeLineDrawInfo = routeLineDrawInfo; } private MapActivity getMapActivity() { @@ -277,9 +280,13 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } } } - + @Override - public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {} + public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { + if (routeLineDrawInfo != null) { + // draw route line on map + } + } private void drawAction(RotatedTileBox tb, Canvas canvas, List actionPoints) { if (actionPoints.size() > 0) { From 53c817e8112dc49c9905995c982ba904836ac2a2 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Sun, 21 Mar 2021 15:39:13 +0200 Subject: [PATCH 25/96] Review --- .../GpxApproximationFragment.java | 19 ++++++----- .../MeasurementToolFragment.java | 34 ++++++++----------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java index cea8ff65a4..521034a430 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java @@ -158,15 +158,6 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment updateCardsLayout(); } updateCards(); - final LockableScrollView profileContainer = mainView.findViewById(R.id.route_menu_bottom_scroll); - profileContainer.postDelayed(new Runnable() { - @Override - public void run() { - if (snapToRoadAppMode.getOrder() > 4) { - profileContainer.fullScroll(View.FOCUS_DOWN); - } - } - }, 100); updateButtons(mainView); progressBar = mainView.findViewById(R.id.progress_bar); @@ -185,6 +176,16 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment calculateGpxApproximation(true); + final LockableScrollView profileView = mainView.findViewById(R.id.route_menu_bottom_scroll); + final LinearLayout profileContainer = mainView.findViewById(R.id.route_menu_cards_container); + profileView.postDelayed(new Runnable() { + @Override + public void run() { + int selectedProfilePosition = profileContainer.getHeight() / ApplicationMode.values(getMyApplication()).size() * snapToRoadAppMode.getOrder(); + profileView.scrollTo(0, selectedProfilePosition); + } + }, 100); + return mainView; } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 34fde58555..23a86009a0 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -132,8 +132,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route private ImageView mainIcon; private String fileName; private OnBackPressedCallback onBackPressedCallback; - private boolean isShowSnapWarning; - private static final String SHOW_SNAP_WARNING = "show_snap_warning"; + private boolean showSnapWarning; private InfoType currentInfoType; @@ -237,11 +236,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route if (mapActivity == null) { return null; } - if (savedInstanceState != null) { - restoreState(savedInstanceState); - } else if (getArguments() != null) { - restoreState(getArguments()); - } + final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer(); final OsmandApplication app = mapActivity.getMyApplication(); @@ -559,12 +554,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route } }); - isShowSnapWarning = getArguments().getBoolean(SHOW_SNAP_WARNING); initMeasurementMode(gpxData, savedInstanceState == null); if (savedInstanceState == null) { if (fileName != null) { addNewGpxData(getGpxFile(fileName)); - } else if (editingCtx.isApproximationNeeded() && isFollowTrackMode()) { + } else if (editingCtx.isApproximationNeeded() && isFollowTrackMode() && showSnapWarning) { enterApproximationMode(mapActivity); } } else { @@ -673,6 +667,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route this.fileName = fileName; } + + public boolean isShowSnapWarning() { + return this.showSnapWarning; + } + + public void setShowSnapWarning(boolean showSnapWarning) { + this.showSnapWarning = showSnapWarning; + } + public MeasurementEditingContext getEditingCtx() { return editingCtx; } @@ -1965,13 +1968,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route } public static boolean showInstance(FragmentManager fragmentManager, MeasurementEditingContext editingCtx, - boolean followTrackMode, boolean isShowSnapWarning) { + boolean followTrackMode, boolean showSnapWarning) { MeasurementToolFragment fragment = new MeasurementToolFragment(); fragment.setEditingCtx(editingCtx); fragment.setMode(FOLLOW_TRACK_MODE, followTrackMode); - Bundle bundle = new Bundle(); - bundle.putBoolean(SHOW_SNAP_WARNING, isShowSnapWarning); - fragment.setArguments(bundle); + fragment.setShowSnapWarning(showSnapWarning); return showFragment(fragment, fragmentManager); } @@ -2114,9 +2115,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route manager.beginTransaction() .hide(this).commit(); layer.setTapsDisabled(true); - if (isShowSnapWarning) { - SnapTrackWarningFragment.showInstance(mapActivity.getSupportFragmentManager(), this); - } + SnapTrackWarningFragment.showInstance(mapActivity.getSupportFragmentManager(), this); AndroidUiHelper.setVisibility(mapActivity, View.GONE, R.id.map_ruler_container); } } @@ -2142,7 +2141,4 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route void onUpdateInfo(); } - public void restoreState(Bundle bundle) { - isShowSnapWarning = bundle.getBoolean(SHOW_SNAP_WARNING); - } } \ No newline at end of file From 95ba9cc0329f028ca9b61d60da371f3d6b938a33 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Sun, 21 Mar 2021 15:56:54 +0200 Subject: [PATCH 26/96] show route line example --- .../net/osmand/plus/views/layers/RouteLayer.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index ce7a9e12bd..2ca620adab 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -281,10 +281,26 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } } + private Paint routeLinePaint = new Paint(); + @Override public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (routeLineDrawInfo != null) { // draw route line on map + updateAttrs(settings, tileBox); + Integer color = routeLineDrawInfo.getColor(); + if (color == null) { + color = attrs.paint.getColor(); + } + Integer width = routeLineDrawInfo.getWidth(); + if (width == null) { + width = (int) attrs.paint.getStrokeWidth(); + } + routeLinePaint.setColor(color); + routeLinePaint.setStrokeWidth(width); + int screenCenter = AndroidUtils.getScreenWidth(getMapActivity())/2; + int screenHeight = AndroidUtils.getScreenHeight(getMapActivity()); + canvas.drawLine(screenCenter, 0, screenCenter, screenHeight, routeLinePaint); } } From fcd2eed6525258e036152f969d2fa062b9c9d14b Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 21 Mar 2021 17:25:58 +0200 Subject: [PATCH 27/96] Small fixes --- .../measurementtool/MeasurementToolFragment.java | 2 +- .../routepreparationmenu/FollowTrackFragment.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index b59915ecdb..9e88c5689f 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -571,7 +571,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route if (savedInstanceState == null) { if (fileName != null) { addNewGpxData(getGpxFile(fileName)); - } else if (editingCtx.isApproximationNeeded() && isFollowTrackMode() && showSnapWarning) { + } else if (editingCtx.isApproximationNeeded() && isFollowTrackMode() && isShowSnapWarning()) { enterApproximationMode(mapActivity); } } else { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index a5209eac18..8228fa6192 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -57,8 +57,8 @@ import net.osmand.plus.routepreparationmenu.cards.ReverseTrackCard; import net.osmand.plus.routepreparationmenu.cards.SelectTrackCard; import net.osmand.plus.routepreparationmenu.cards.TrackEditCard; import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard; -import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; @@ -452,12 +452,12 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca } else if (card instanceof TrackEditCard) { openPlanRoute(false); close(); + } else if (card instanceof SelectTrackCard) { + updateSelectionMode(true); + } else if (card instanceof ReverseTrackCard + || card instanceof NavigateTrackOptionsCard) { + updateMenu(); } - } else if (card instanceof SelectTrackCard) { - updateSelectionMode(true); - } else if (card instanceof ReverseTrackCard - || card instanceof NavigateTrackOptionsCard) { - updateMenu(); } } From 170c70e42bc555daf3015c776123234db90086cf Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 21 Mar 2021 20:54:58 +0500 Subject: [PATCH 28/96] Refactor to optimize memory consumption and rendering speed --- .../views/layers/geometry/GpxGeometryWay.java | 26 ++++++++++++-- .../geometry/GpxGeometryWayContext.java | 15 ++++++++ .../layers/geometry/GpxGeometryWayDrawer.java | 34 ++++--------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java index 0e9b73dc82..c0fdf55930 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java @@ -77,18 +77,27 @@ public class GpxGeometryWay extends GeometryWay { - private static final float TRACK_WIDTH_THRESHOLD = 8f; + private static final float TRACK_WIDTH_THRESHOLD_DP = 8f; private static final float ARROW_DISTANCE_MULTIPLIER = 1.5f; private static final float SPECIAL_ARROW_DISTANCE_MULTIPLIER = 10f; + private final float TRACK_WIDTH_THRESHOLD_PIX; private Bitmap arrowBitmap; + public static final int OUTER_CIRCLE_COLOR = 0x33000000; protected int pointColor; protected int trackColor; protected float trackWidth; + private float circleAngleOffset; + private float outerCircleRadius; + private float innerCircleRadius; + GeometryArrowsStyle(GpxGeometryWayContext context, int arrowColor, int trackColor, float trackWidth) { this(context, null, arrowColor, trackColor, trackWidth); + circleAngleOffset = AndroidUtils.dpToPx(context.getCtx(), 1); + outerCircleRadius = AndroidUtils.dpToPx(context.getCtx(), 8); + innerCircleRadius = AndroidUtils.dpToPx(context.getCtx(), 7); } GeometryArrowsStyle(GpxGeometryWayContext context, Bitmap arrowBitmap, int arrowColor, int trackColor, float trackWidth) { @@ -97,6 +106,7 @@ public class GpxGeometryWay extends GeometryWay style) { super(x, y, angle, style); - createCircleBitmap((GeometryArrowsStyle) style); } @Override @@ -63,32 +59,14 @@ public class GpxGeometryWayDrawer extends GeometryWayDrawer Date: Sun, 21 Mar 2021 18:06:57 +0200 Subject: [PATCH 29/96] Fix scroll to profile item --- .../measurementtool/GpxApproximationFragment.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java index 521034a430..a8e19d7141 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/GpxApproximationFragment.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ProgressBar; +import android.widget.ScrollView; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; @@ -21,7 +22,6 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.LocationsHolder; import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; -import net.osmand.plus.LockableScrollView; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -176,13 +176,15 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment calculateGpxApproximation(true); - final LockableScrollView profileView = mainView.findViewById(R.id.route_menu_bottom_scroll); - final LinearLayout profileContainer = mainView.findViewById(R.id.route_menu_cards_container); + final ScrollView profileView = (ScrollView) getBottomScrollView(); profileView.postDelayed(new Runnable() { @Override public void run() { - int selectedProfilePosition = profileContainer.getHeight() / ApplicationMode.values(getMyApplication()).size() * snapToRoadAppMode.getOrder(); - profileView.scrollTo(0, selectedProfilePosition); + View view = profileView.findViewWithTag(snapToRoadAppMode.getStringKey()); + if (view != null) { + int headerHeight = getResources().getDimensionPixelSize(R.dimen.measurement_tool_button_height); + profileView.scrollTo(0, view.getTop() + headerHeight); + } } }, 100); From e058dad69257b6e90c6d16050b75b1745072d719 Mon Sep 17 00:00:00 2001 From: cepprice Date: Sun, 21 Mar 2021 21:57:59 +0500 Subject: [PATCH 30/96] Don't bias arrow's position --- .../osmand/plus/views/layers/geometry/GpxGeometryWay.java | 6 ------ .../plus/views/layers/geometry/GpxGeometryWayDrawer.java | 3 --- 2 files changed, 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java index c0fdf55930..5ba26346a3 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GpxGeometryWay.java @@ -89,13 +89,11 @@ public class GpxGeometryWay extends GeometryWay Date: Sun, 21 Mar 2021 20:52:57 +0200 Subject: [PATCH 31/96] Remove unnecessary changes and fix cards update --- .../wikivoyage/explore/ExploreRvAdapter.java | 4 ++-- .../wikivoyage/explore/ExploreTabFragment.java | 17 ++++++++++++++--- .../explore/WikivoyageExploreActivity.java | 8 +++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java index becc599ced..6883aa2abd 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/ExploreRvAdapter.java @@ -158,8 +158,8 @@ public class ExploreRvAdapter extends RecyclerView.Adapter, List> res) { ExploreTabFragment fragment = weakFragment.get(); - if (res != null && fragment != null && fragment.isResumed()) { + if (res != null && fragment != null && fragment.isAdded()) { fragment.addIndexItemCards(res.first, res.second); + fragment.removeRedundantCards(); + if (!fragment.isResumed()) { + fragment.invalidateAdapter(); + } } } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java index 3bfa4b7a14..55f81ad441 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/WikivoyageExploreActivity.java @@ -373,7 +373,13 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv @Override public void savedArticlesUpdated() { - updateFragments(); + ExploreTabFragment exploreTabFragment = getExploreTabFragment(); + SavedArticlesTabFragment savedArticlesTabFragment = getSavedArticlesTabFragment(); + if (exploreTabFragment != null && savedArticlesTabFragment != null + && exploreTabFragment.isAdded() && savedArticlesTabFragment.isAdded()) { + exploreTabFragment.savedArticlesUpdated(); + savedArticlesTabFragment.savedArticlesUpdated(); + } } public static class LoadWikivoyageData extends AsyncTask { From 490d42f3340a7e1cd9cfdffcdd1bcca4bb2ace0a Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sun, 21 Mar 2021 23:17:16 +0200 Subject: [PATCH 32/96] Fix last view visibility --- .../fragments/BaseSettingsListFragment.java | 21 +++++++++++++++++++ .../fragments/ExportSettingsAdapter.java | 7 ------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java index 70cc3e95e0..6e2129deab 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/BaseSettingsListFragment.java @@ -6,8 +6,10 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AbsListView; import android.widget.ExpandableListView; import android.widget.LinearLayout; +import android.widget.ListView; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; @@ -18,6 +20,8 @@ import androidx.core.view.ViewCompat; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; +import com.github.ksoichiro.android.observablescrollview.ScrollUtils; + import net.osmand.AndroidUtils; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -129,6 +133,7 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem adapter = new ExportSettingsAdapter(app, exportMode, this, nightMode); adapter.updateSettingsItems(dataList, selectedItemsMap); expandableList.setAdapter(adapter); + setupListView(expandableList); updateAvailableSpace(); return root; @@ -195,6 +200,22 @@ public abstract class BaseSettingsListFragment extends BaseOsmAndFragment implem }); } + private void setupListView(@NonNull final ListView listView) { + if (listView.getFooterViewsCount() == 0) { + int padding = getResources().getDimensionPixelSize(R.dimen.toolbar_height_expanded); + + View emptyView = new View(listView.getContext()); + emptyView.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, padding)); + listView.addFooterView(emptyView); + ScrollUtils.addOnGlobalLayoutListener(listView, new Runnable() { + @Override + public void run() { + listView.requestLayout(); + } + }); + } + } + protected void updateAvailableSpace() { long calculatedSize = ExportSettingsAdapter.calculateItemsSize(adapter.getData()); if (calculatedSize != 0) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java index 634d317b05..360f786b77 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportSettingsAdapter.java @@ -58,7 +58,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { private final int secondaryColorRes; private final int groupViewHeight; private final int childViewHeight; - private final int listBottomPadding; ExportSettingsAdapter(OsmandApplication app, boolean exportMode, OnItemSelectedListener listener, boolean nightMode) { this.app = app; @@ -71,7 +70,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { secondaryColorRes = nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light; groupViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_group_height); childViewHeight = app.getResources().getDimensionPixelSize(R.dimen.setting_list_item_large_height); - listBottomPadding = app.getResources().getDimensionPixelSize(R.dimen.fab_recycler_view_padding_bottom); } @Override @@ -118,9 +116,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { } }); - boolean addPadding = !isExpanded && groupPosition == getGroupCount() - 1; - group.setPadding(0, 0, 0, addPadding ? listBottomPadding : 0); - adjustIndicator(app, groupPosition, isExpanded, group, nightMode); AndroidUiHelper.updateVisibility(group.findViewById(R.id.divider), isExpanded); AndroidUiHelper.updateVisibility(group.findViewById(R.id.card_top_divider), true); @@ -188,8 +183,6 @@ public class ExportSettingsAdapter extends OsmandBaseExpandableListAdapter { notifyDataSetChanged(); } }); - boolean addPadding = isLastChild && groupPosition == getGroupCount() - 1; - child.setPadding(0, 0, 0, addPadding ? listBottomPadding : 0); AndroidUiHelper.updateVisibility(child.findViewById(R.id.card_bottom_divider), isLastChild); return child; From 83870f0f458092809450f713115564887ebb77e7 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 22 Mar 2021 00:21:35 +0200 Subject: [PATCH 33/96] Fix unselected item icon color --- .../SimpleBottomSheetItem.java | 2 +- .../fragments/ExportItemsBottomSheet.java | 153 ++++++++++-------- 2 files changed, 88 insertions(+), 67 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java index bb93494214..b1cdaa6963 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/SimpleBottomSheetItem.java @@ -49,7 +49,7 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem { } - public void setTitle(String title) { + public void setTitle(CharSequence title) { this.title = title; titleTv.setText(title); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java index 5bfed7996f..c3e318b35b 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ExportItemsBottomSheet.java @@ -6,6 +6,13 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; +import androidx.core.widget.CompoundButtonCompat; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; + import net.osmand.AndroidUtils; import net.osmand.GPXUtilities.GPXTrackAnalysis; import net.osmand.IndexConstants; @@ -61,13 +68,6 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.core.content.ContextCompat; -import androidx.core.widget.CompoundButtonCompat; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; - import static net.osmand.view.ThreeStateCheckbox.State.CHECKED; import static net.osmand.view.ThreeStateCheckbox.State.MISC; import static net.osmand.view.ThreeStateCheckbox.State.UNCHECKED; @@ -142,15 +142,21 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { selectedItems.remove(item[0].getTag()); } updateTitleView(); + setupBottomSheetItem(item[0], item[0].getTag()); } }) .setTag(object); - setupBottomSheetItem(builder, object); item[0] = builder.create(); items.add(item[0]); } } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + updateItems(); + } + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -177,7 +183,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { selectedItems.clear(); } updateTitleView(); - updateItems(checked); + updateItems(); } }); setupDescription(view); @@ -221,10 +227,12 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { return itemsSize; } - private void updateItems(boolean checked) { + private void updateItems() { for (BaseBottomSheetItem item : items) { - if (item instanceof BottomSheetItemWithCompoundButton) { - ((BottomSheetItemWithCompoundButton) item).setChecked(checked); + if (item instanceof BottomSheetItemWithCompoundButton && item.getTag() != null) { + BottomSheetItemWithCompoundButton bottomSheetItem = (BottomSheetItemWithCompoundButton) item; + setupBottomSheetItem(bottomSheetItem, item.getTag()); + bottomSheetItem.setChecked(selectedItems.contains(item.getTag())); } } } @@ -274,7 +282,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { return null; } - private void setupBottomSheetItem(Builder builder, Object object) { + private void setupBottomSheetItem(BottomSheetItemWithCompoundButton item, Object object) { if (object instanceof ApplicationModeBean) { ApplicationModeBean modeBean = (ApplicationModeBean) object; String profileName = modeBean.userProfileName; @@ -286,7 +294,7 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { profileName = StringUtils.capitalize(modeBean.stringKey); } } - builder.setTitle(profileName); + item.setTitle(profileName); String routingProfile = ""; String routingProfileValue = modeBean.routingProfile; @@ -300,122 +308,135 @@ public class ExportItemsBottomSheet extends MenuBottomSheetDialogFragment { } } if (!Algorithms.isEmpty(routingProfile)) { - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.nav_type_hint), routingProfile)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, getString(R.string.nav_type_hint), routingProfile)); } else { - builder.setDescription(getString(R.string.profile_type_osmand_string)); + item.setDescription(getString(R.string.profile_type_osmand_string)); } int profileIconRes = AndroidUtils.getDrawableId(app, modeBean.iconName); ProfileIconColors iconColor = modeBean.iconColor; Integer customIconColor = modeBean.customIconColor; - int actualIconColor = customIconColor != null ? - customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode)); - builder.setIcon(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor)); + int actualIconColor; + if (selectedItems.contains(object)) { + actualIconColor = customIconColor != null ? customIconColor : ContextCompat.getColor(app, iconColor.getColor(nightMode)); + } else { + actualIconColor = ContextCompat.getColor(app, secondaryColorRes); + } + item.setIcon(uiUtilities.getPaintedIcon(profileIconRes, actualIconColor)); } else if (object instanceof QuickAction) { QuickAction quickAction = (QuickAction) object; - builder.setTitle(quickAction.getName(app)); - builder.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), activeColorRes)); + item.setTitle(quickAction.getName(app)); + item.setIcon(uiUtilities.getIcon(quickAction.getIconRes(), getItemIconColor(object))); } else if (object instanceof PoiUIFilter) { PoiUIFilter poiUIFilter = (PoiUIFilter) object; - builder.setTitle(poiUIFilter.getName()); + item.setTitle(poiUIFilter.getName()); int iconRes = RenderingIcons.getBigIconResourceId(poiUIFilter.getIconId()); - builder.setIcon(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes)); + item.setIcon(uiUtilities.getIcon(iconRes != 0 ? iconRes : R.drawable.ic_action_user, activeColorRes)); } else if (object instanceof TileSourceTemplate || object instanceof SQLiteTileSource) { ITileSource tileSource = (ITileSource) object; - builder.setTitle(tileSource.getName()); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_map, activeColorRes)); + item.setTitle(tileSource.getName()); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_map, getItemIconColor(object))); } else if (object instanceof File) { - setupBottomSheetItemForFile(builder, (File) object); + setupBottomSheetItemForFile(item, (File) object); } else if (object instanceof GpxSettingsItem) { - GpxSettingsItem item = (GpxSettingsItem) object; - setupBottomSheetItemForGpx(builder, item.getFile(), item.getAppearanceInfo()); + GpxSettingsItem settingsItem = (GpxSettingsItem) object; + setupBottomSheetItemForGpx(item, settingsItem.getFile(), settingsItem.getAppearanceInfo()); } else if (object instanceof FileSettingsItem) { - FileSettingsItem item = (FileSettingsItem) object; - setupBottomSheetItemForFile(builder, item.getFile()); + FileSettingsItem settingsItem = (FileSettingsItem) object; + setupBottomSheetItemForFile(item, settingsItem.getFile()); } else if (object instanceof AvoidRoadInfo) { AvoidRoadInfo avoidRoadInfo = (AvoidRoadInfo) object; - builder.setTitle(avoidRoadInfo.name); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, activeColorRes)); + item.setTitle(avoidRoadInfo.name); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_alert, getItemIconColor(object))); } else if (object instanceof OsmNotesPoint) { OsmNotesPoint osmNotesPoint = (OsmNotesPoint) object; - builder.setTitle(osmNotesPoint.getText()); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, activeColorRes)); + item.setTitle(osmNotesPoint.getText()); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_osm_note_add, getItemIconColor(object))); } else if (object instanceof OpenstreetmapPoint) { OpenstreetmapPoint openstreetmapPoint = (OpenstreetmapPoint) object; - builder.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, activeColorRes)); + item.setTitle(OsmEditingPlugin.getTitle(openstreetmapPoint, app)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_info_dark, getItemIconColor(object))); } else if (object instanceof FavoriteGroup) { FavoriteGroup group = (FavoriteGroup) object; - builder.setTitle(group.getDisplayName(app)); - int color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor(); - builder.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color)); + item.setTitle(group.getDisplayName(app)); + int color; + if (selectedItems.contains(object)) { + color = group.getColor() == 0 ? ContextCompat.getColor(app, R.color.color_favorite) : group.getColor(); + } else { + color = ContextCompat.getColor(app, secondaryColorRes); + } + item.setIcon(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color)); int points = group.getPoints().size(); String itemsDescr = getString(R.string.shared_string_gpx_points); - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, points)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, points)); } else if (object instanceof GlobalSettingsItem) { GlobalSettingsItem globalSettingsItem = (GlobalSettingsItem) object; - builder.setTitle(globalSettingsItem.getPublicName(app)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, activeColorRes)); + item.setTitle(globalSettingsItem.getPublicName(app)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_settings, getItemIconColor(object))); } else if (object instanceof ItineraryGroup) { ItineraryGroup markersGroup = (ItineraryGroup) object; if (ExportSettingsType.ACTIVE_MARKERS.name().equals(markersGroup.getId())) { - builder.setTitle(getString(R.string.map_markers)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, activeColorRes)); + item.setTitle(getString(R.string.map_markers)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_flag, getItemIconColor(object))); } else if (ExportSettingsType.HISTORY_MARKERS.name().equals(markersGroup.getId())) { - builder.setTitle(getString(R.string.markers_history)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes)); + item.setTitle(getString(R.string.markers_history)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object))); } int selectedMarkers = markersGroup.getMarkers().size(); String itemsDescr = getString(R.string.shared_string_items); - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, selectedMarkers)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_colon, itemsDescr, selectedMarkers)); } else if (object instanceof HistoryEntry) { HistoryEntry historyEntry = (HistoryEntry) object; - builder.setTitle(historyEntry.getName().getName()); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, activeColorRes)); + item.setTitle(historyEntry.getName().getName()); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_history, getItemIconColor(object))); } else if (object instanceof OnlineRoutingEngine) { OnlineRoutingEngine onlineRoutingEngine = (OnlineRoutingEngine) object; - builder.setTitle(onlineRoutingEngine.getName(app)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, activeColorRes)); + item.setTitle(onlineRoutingEngine.getName(app)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_world_globe_dark, getItemIconColor(object))); } } - private void setupBottomSheetItemForFile(Builder builder, File file) { + private void setupBottomSheetItemForFile(BottomSheetItemWithCompoundButton item, File file) { FileSubtype fileSubtype = FileSubtype.getSubtypeByPath(app, file.getPath()); - builder.setTitle(file.getName()); + item.setTitle(file.getName()); if (file.getAbsolutePath().contains(IndexConstants.RENDERERS_DIR)) { - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_map_style, activeColorRes)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_map_style, getItemIconColor(item.getTag()))); } else if (file.getAbsolutePath().contains(IndexConstants.ROUTING_PROFILES_DIR)) { - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, getItemIconColor(item.getTag()))); } else if (file.getAbsolutePath().contains(IndexConstants.GPX_INDEX_DIR)) { - setupBottomSheetItemForGpx(builder, file, null); + setupBottomSheetItemForGpx(item, file, null); } else if (file.getAbsolutePath().contains(IndexConstants.AV_INDEX_DIR)) { int iconId = AudioVideoNotesPlugin.getIconIdForRecordingFile(file); if (iconId == -1) { iconId = R.drawable.ic_action_photo_dark; } - builder.setIcon(uiUtilities.getIcon(iconId, activeColorRes)); - builder.setDescription(AndroidUtils.formatSize(app, file.length())); + item.setIcon(uiUtilities.getIcon(iconId, getItemIconColor(item.getTag()))); + item.setDescription(AndroidUtils.formatSize(app, file.length())); } else if (fileSubtype.isMap() || fileSubtype == FileSettingsItem.FileSubtype.TTS_VOICE || fileSubtype == FileSettingsItem.FileSubtype.VOICE) { - builder.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName())); - builder.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), activeColorRes)); + item.setTitle(FileNameTranslationHelper.getFileNameWithRegion(app, file.getName())); + item.setIcon(uiUtilities.getIcon(fileSubtype.getIconId(), getItemIconColor(item.getTag()))); if (fileSubtype.isMap()) { String mapDescription = getMapDescription(file); String formattedSize = AndroidUtils.formatSize(app, file.length()); if (mapDescription != null) { - builder.setDescription(getString(R.string.ltr_or_rtl_combine_via_bold_point, mapDescription, formattedSize)); + item.setDescription(getString(R.string.ltr_or_rtl_combine_via_bold_point, mapDescription, formattedSize)); } else { - builder.setDescription(formattedSize); + item.setDescription(formattedSize); } } } } - private void setupBottomSheetItemForGpx(Builder builder, File file, @Nullable GpxAppearanceInfo appearanceInfo) { - builder.setTitle(GpxUiHelper.getGpxTitle(file.getName())); - builder.setDescription(getTrackDescr(file, file.lastModified(), file.length(), appearanceInfo)); - builder.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, activeColorRes)); + private void setupBottomSheetItemForGpx(BottomSheetItemWithCompoundButton item, File file, @Nullable GpxAppearanceInfo appearanceInfo) { + item.setTitle(GpxUiHelper.getGpxTitle(file.getName())); + item.setDescription(getTrackDescr(file, file.lastModified(), file.length(), appearanceInfo)); + item.setIcon(uiUtilities.getIcon(R.drawable.ic_action_route_distance, getItemIconColor(item.getTag()))); + } + + private int getItemIconColor(Object object) { + return selectedItems.contains(object) ? activeColorRes : secondaryColorRes; } private final GpxDataItemCallback gpxDataItemCallback = new GpxDataItemCallback() { From 913e125968cb1cd9195eb7f3a9b38849ed670eb5 Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 22 Mar 2021 04:40:26 +0200 Subject: [PATCH 34/96] add static graphs --- OsmAnd/res/layout/gpx_item_altitude.xml | 1 + OsmAnd/res/layout/gpx_item_general.xml | 1 + OsmAnd/res/layout/gpx_item_speed.xml | 1 + .../res/layout/gpx_list_item_tab_content.xml | 4 +- OsmAnd/res/layout/trip_recording_fragment.xml | 8 +- .../TripRecordingBottomFragment.java | 142 ++++++++- .../plus/myplaces/GPXItemPagerAdapter.java | 289 +++++++++++------- .../plus/track/GpxBlockStatisticsBuilder.java | 252 +++++++++++---- .../net/osmand/plus/track/OverviewCard.java | 4 +- .../views/controls/PagerSlidingTabStrip.java | 16 +- 10 files changed, 522 insertions(+), 196 deletions(-) diff --git a/OsmAnd/res/layout/gpx_item_altitude.xml b/OsmAnd/res/layout/gpx_item_altitude.xml index 9dd2037878..699e6812ea 100644 --- a/OsmAnd/res/layout/gpx_item_altitude.xml +++ b/OsmAnd/res/layout/gpx_item_altitude.xml @@ -273,6 +273,7 @@ diff --git a/OsmAnd/res/layout/gpx_item_general.xml b/OsmAnd/res/layout/gpx_item_general.xml index 962bbbe9f5..fe90a5c031 100644 --- a/OsmAnd/res/layout/gpx_item_general.xml +++ b/OsmAnd/res/layout/gpx_item_general.xml @@ -291,6 +291,7 @@ diff --git a/OsmAnd/res/layout/gpx_item_speed.xml b/OsmAnd/res/layout/gpx_item_speed.xml index d5bc1d3edb..785c8109ef 100644 --- a/OsmAnd/res/layout/gpx_item_speed.xml +++ b/OsmAnd/res/layout/gpx_item_speed.xml @@ -275,6 +275,7 @@ diff --git a/OsmAnd/res/layout/gpx_list_item_tab_content.xml b/OsmAnd/res/layout/gpx_list_item_tab_content.xml index ac7918d06a..5fa3d3ab29 100644 --- a/OsmAnd/res/layout/gpx_list_item_tab_content.xml +++ b/OsmAnd/res/layout/gpx_list_item_tab_content.xml @@ -4,7 +4,9 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + + android:layout_marginBottom="@dimen/context_menu_padding_margin_small" /> + + 0) { - DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT); - DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM); + }); + if (analysis.timeSpan > 0) { + DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT); + DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM); - Date start = new Date(analysis.startTime); - ((TextView) view.findViewById(R.id.start_time_text)).setText(tf.format(start)); - ((TextView) view.findViewById(R.id.start_date_text)).setText(df.format(start)); - Date end = new Date(analysis.endTime); - ((TextView) view.findViewById(R.id.end_time_text)).setText(tf.format(end)); - ((TextView) view.findViewById(R.id.end_date_text)).setText(df.format(end)); - } else { - view.findViewById(R.id.list_divider).setVisibility(View.GONE); - view.findViewById(R.id.start_end_time).setVisibility(View.GONE); + Date start = new Date(analysis.startTime); + ((TextView) view.findViewById(R.id.start_time_text)).setText(tf.format(start)); + ((TextView) view.findViewById(R.id.start_date_text)).setText(df.format(start)); + Date end = new Date(analysis.endTime); + ((TextView) view.findViewById(R.id.end_time_text)).setText(tf.format(end)); + ((TextView) view.findViewById(R.id.end_date_text)).setText(df.format(end)); + } else { + view.findViewById(R.id.list_divider).setVisibility(View.GONE); + view.findViewById(R.id.start_end_time).setVisibility(View.GONE); + } } } else { chart.setVisibility(View.GONE); @@ -412,17 +463,19 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid view.findViewById(R.id.start_end_time).setVisibility(View.GONE); } updateJoinGapsInfo(view, position); - view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_GENERAL); + if (!onlyGraphs) { + view.findViewById(R.id.analyze_on_map).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openAnalyzeOnMap(GPXTabItemType.GPX_TAB_ITEM_GENERAL); + } + }); + TextView overflowMenu = view.findViewById(R.id.overflow_menu); + if (!gpxItem.group.getTrack().generalTrack) { + setupOptionsPopupMenu(overflowMenu, true); + } else { + overflowMenu.setVisibility(View.GONE); } - }); - TextView overflowMenu = view.findViewById(R.id.overflow_menu); - if (!gpxItem.group.getTrack().generalTrack) { - setupOptionsPopupMenu(overflowMenu, true); - } else { - overflowMenu.setVisibility(View.GONE); } } @@ -598,7 +651,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid @Override public void tabStylesUpdated(View tabsContainer, int currentPosition) { ViewGroup.MarginLayoutParams params = (MarginLayoutParams) tabsContainer.getLayoutParams(); - params.height = app.getResources().getDimensionPixelSize(R.dimen.dialog_button_height); + params.height = app.getResources().getDimensionPixelSize(!onlyGraphs ? R.dimen.dialog_button_height : R.dimen.context_menu_buttons_bottom_height); tabsContainer.setLayoutParams(params); UiUtilities.updateCustomRadioButtons(app, tabsContainer, nightMode, getCustomRadioButtonType(currentPosition)); } diff --git a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java index 09adb88117..1670562eee 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxBlockStatisticsBuilder.java @@ -14,6 +14,7 @@ import androidx.annotation.DrawableRes; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.AppCompatImageView; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -35,30 +36,44 @@ import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; +import static net.osmand.plus.liveupdates.LiveUpdatesFragmentNew.getDefaultIconColorId; + public class GpxBlockStatisticsBuilder { - private static final Log log = PlatformUtil.getLog(GpxBlockStatisticsBuilder.class); - private static final int GENERAL_UPDATE_INTERVAL = 1000; + private static final Log LOG = PlatformUtil.getLog(GpxBlockStatisticsBuilder.class); + private static final int BLOCKS_UPDATE_INTERVAL = 1000; + public static final String INIT_BLOCKS_BASE = "init_blocks_base"; + public static final String INIT_BLOCKS_GENERAL = "init_blocks_general"; + public static final String INIT_BLOCKS_ALTITUDE = "init_blocks_altitude"; + public static final String INIT_BLOCKS_SPEED = "init_blocks_speed"; private final OsmandApplication app; + private final boolean nightMode; + private RecyclerView blocksView; private final SelectedGpxFile selectedGpxFile; + private GPXTrackAnalysis analysis; private BlockStatisticsAdapter adapter; private final List items = new ArrayList<>(); private boolean blocksClickable = true; + private String initBlocksKey = INIT_BLOCKS_BASE; private final Handler handler = new Handler(); private Runnable updatingItems; private boolean updateRunning = false; - public GpxBlockStatisticsBuilder(OsmandApplication app, SelectedGpxFile selectedGpxFile) { + public GpxBlockStatisticsBuilder(OsmandApplication app, SelectedGpxFile selectedGpxFile, boolean nightMode) { this.app = app; this.selectedGpxFile = selectedGpxFile; + this.nightMode = nightMode; } public boolean isUpdateRunning() { @@ -73,6 +88,10 @@ public class GpxBlockStatisticsBuilder { this.blocksView = blocksView; } + public void setInitBlocksKey(String initBlocksKey) { + this.initBlocksKey = initBlocksKey; + } + @Nullable public GpxDisplayItem getDisplayItem(GPXFile gpxFile) { return gpxFile.tracks.size() > 0 ? GpxUiHelper.makeGpxDisplayItem(app, gpxFile) : null; @@ -82,9 +101,9 @@ public class GpxBlockStatisticsBuilder { return selectedGpxFile.getGpxFile(); } - public void initStatBlocks(@Nullable SegmentActionsListener actionsListener, @ColorInt int activeColor, boolean nightMode) { + public void initStatBlocks(@Nullable SegmentActionsListener actionsListener, @ColorInt int activeColor) { initItems(); - adapter = new BlockStatisticsAdapter(getDisplayItem(getGPXFile()), actionsListener, activeColor, nightMode); + adapter = new BlockStatisticsAdapter(getDisplayItem(getGPXFile()), actionsListener, activeColor); adapter.setItems(items); blocksView.setLayoutManager(new LinearLayoutManager(app, LinearLayoutManager.HORIZONTAL, false)); blocksView.setAdapter(adapter); @@ -107,7 +126,7 @@ public class GpxBlockStatisticsBuilder { } AndroidUiHelper.updateVisibility(blocksView, !Algorithms.isEmpty(items)); int interval = app.getSettings().SAVE_GLOBAL_TRACK_INTERVAL.get(); - updateRunning = handler.postDelayed(this, Math.max(GENERAL_UPDATE_INTERVAL, interval)); + updateRunning = handler.postDelayed(this, Math.max(BLOCKS_UPDATE_INTERVAL, interval)); } }; updateRunning = handler.post(updatingItems); @@ -117,65 +136,187 @@ public class GpxBlockStatisticsBuilder { public void initItems() { GPXFile gpxFile = getGPXFile(); GpxDisplayItem gpxDisplayItem = getDisplayItem(gpxFile); - GPXTrackAnalysis analysis = null; boolean withoutGaps = true; if (gpxDisplayItem != null) { analysis = gpxDisplayItem.analysis; withoutGaps = !selectedGpxFile.isJoinSegments() && gpxDisplayItem.isGeneralTrack(); } if (analysis != null) { - float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; - String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); - String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); - String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); - items.clear(); - prepareData(analysis, app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), - R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED, ItemType.ITEM_DISTANCE); - prepareData(analysis, app.getString(R.string.altitude_ascent), asc, - R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null, ItemType.ITEM_ALTITUDE); - prepareData(analysis, app.getString(R.string.altitude_descent), desc, - R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE, ItemType.ITEM_ALTITUDE); - prepareData(analysis, app.getString(R.string.average_speed), avg, - R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED); - prepareData(analysis, app.getString(R.string.max_speed), max, - R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED); - prepareData(analysis, app.getString(R.string.shared_string_time_span), - Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), - R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME); + switch (initBlocksKey) { + case INIT_BLOCKS_GENERAL: { + float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + Date start = new Date(analysis.startTime); + Date end = new Date(analysis.endTime); + prepareDataDistance(totalDistance); + prepareDataTimeSpan(timeSpan); + prepareDataStartTime(start); + prepareDataEndTime(end); + break; + } + case INIT_BLOCKS_ALTITUDE: { + String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app); + String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app); + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + prepareDataAverageAltitude(); + prepareDataAltitudeRange(min, max); + prepareDataAscent(asc); + prepareDataDescent(desc); + break; + } + case INIT_BLOCKS_SPEED: { + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + long timeMoving = withoutGaps ? analysis.timeMovingWithoutGaps : analysis.timeMoving; + float totalDistanceMoving = withoutGaps ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving; + prepareDataAverageSpeed(avg); + prepareDataMaximumSpeed(max); + prepareDataTimeMoving(timeMoving); + prepareDataDistanceCorrected(totalDistanceMoving); + break; + } + default: + case INIT_BLOCKS_BASE: { + float totalDistance = withoutGaps ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + float timeSpan = withoutGaps ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + prepareDataDistance(totalDistance); + prepareDataAscent(asc); + prepareDataDescent(desc); + prepareDataAverageSpeed(avg); + prepareDataMaximumSpeed(max); + prepareDataTimeSpan(timeSpan); + break; + } + } } } - public void prepareData(GPXTrackAnalysis analysis, String title, String value, - @DrawableRes int imageResId, @ColorRes int imageColorId, + public void prepareDataDistance(float totalDistance) { + prepareData(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), + R.drawable.ic_action_track_16, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED, ItemType.ITEM_DISTANCE); + } + + public void prepareDataAverageAltitude() { + prepareData(app.getString(R.string.average_altitude), OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app), + R.drawable.ic_action_altitude_average_16, GPXDataSetType.ALTITUDE, null, ItemType.ITEM_ALTITUDE); + } + + public void prepareDataAltitudeRange(String min, String max) { + String pattern = app.getString(R.string.ltr_or_rtl_combine_via_dash); + prepareData(app.getString(R.string.altitude_range), String.format(pattern, min, max), + R.drawable.ic_action_altitude_range_16, GPXDataSetType.ALTITUDE, null, ItemType.ITEM_ALTITUDE); + } + + public void prepareDataAscent(String asc) { + prepareData(app.getString(R.string.altitude_ascent), asc, + R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, + GPXDataSetType.SLOPE, null, ItemType.ITEM_ALTITUDE); + } + + public void prepareDataDescent(String desc) { + prepareData(app.getString(R.string.altitude_descent), desc, + R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, + GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE, ItemType.ITEM_ALTITUDE); + } + + public void prepareDataAverageSpeed(String avg) { + prepareData(app.getString(R.string.average_speed), avg, + R.drawable.ic_action_speed_16, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED); + } + + public void prepareDataMaximumSpeed(String max) { + prepareData(app.getString(R.string.max_speed), max, + R.drawable.ic_action_max_speed_16, GPXDataSetType.SPEED, null, ItemType.ITEM_SPEED); + } + + public void prepareDataTimeMoving(long timeMoving) { + prepareData(app.getString(R.string.shared_string_time_moving), + Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled()), + R.drawable.ic_action_time_span_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_MOVING); + } + + public void prepareDataDistanceCorrected(float totalDistanceMoving) { + prepareData(app.getString(R.string.distance_moving), + OsmAndFormatter.getFormattedDistance(totalDistanceMoving, app), + R.drawable.ic_action_polygom_dark, GPXDataSetType.SPEED, null, ItemType.ITEM_DISTANCE_MOVING); + } + + public void prepareDataTimeSpan(float timeSpan) { + prepareData(app.getString(R.string.shared_string_time_span), + Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), + R.drawable.ic_action_time_span_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME_SPAN); + } + + public void prepareDataStartTime(Date start) { + DateFormat dtf = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); + prepareData(app.getString(R.string.shared_string_start_time), dtf.format(start), + R.drawable.ic_action_time_start_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME); + } + + public void prepareDataEndTime(Date end) { + DateFormat dtf = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); + prepareData(app.getString(R.string.shared_string_end_time), dtf.format(end), + R.drawable.ic_action_time_end_16, GPXDataSetType.SPEED, null, ItemType.ITEM_TIME); + } + + public void prepareData(String title, String value, @DrawableRes int imageResId, GPXDataSetType firstType, GPXDataSetType secondType, ItemType itemType) { - StatBlock statBlock = new StatBlock(title, value, imageResId, imageColorId, firstType, secondType, itemType); - switch (statBlock.itemType) { - case ITEM_DISTANCE: { - if (analysis.totalDistance != 0f) { - items.add(statBlock); + prepareData(title, value, imageResId, getDefaultIconColorId(nightMode), firstType, secondType, itemType); + } + + public void prepareData(String title, String value, @DrawableRes int imageResId, @ColorRes int imageColorId, + GPXDataSetType firstType, GPXDataSetType secondType, ItemType itemType) { + if (analysis != null) { + StatBlock statBlock = new StatBlock(title, value, imageResId, imageColorId, firstType, secondType, itemType); + switch (statBlock.itemType) { + case ITEM_DISTANCE: { + if (analysis.totalDistance != 0f) { + items.add(statBlock); + } + break; } - break; - } - case ITEM_ALTITUDE: { - if (analysis.hasElevationData) { - items.add(statBlock); + case ITEM_DISTANCE_MOVING: { + if (analysis.totalDistanceMoving != 0f) { + items.add(statBlock); + } + break; } - break; - } - case ITEM_SPEED: { - if (analysis.isSpeedSpecified()) { - items.add(statBlock); + case ITEM_ALTITUDE: { + if (analysis.hasElevationData) { + items.add(statBlock); + } + break; } - break; - } - case ITEM_TIME: { - if (analysis.hasSpeedData) { - items.add(statBlock); + case ITEM_SPEED: { + if (analysis.isSpeedSpecified()) { + items.add(statBlock); + } + break; + } + case ITEM_TIME: { + if (analysis.timeSpan > 0) { + items.add(statBlock); + } + break; + } + case ITEM_TIME_SPAN: { + if (analysis.hasSpeedData) { + items.add(statBlock); + } + break; + } + case ITEM_TIME_MOVING: { + if (analysis.isTimeMoving()) { + items.add(statBlock); + } + break; } - break; } } } @@ -203,9 +344,12 @@ public class GpxBlockStatisticsBuilder { public enum ItemType { ITEM_DISTANCE, + ITEM_DISTANCE_MOVING, ITEM_ALTITUDE, ITEM_SPEED, - ITEM_TIME; + ITEM_TIME, + ITEM_TIME_SPAN, + ITEM_TIME_MOVING; } private class BlockStatisticsAdapter extends RecyclerView.Adapter { @@ -215,17 +359,15 @@ public class GpxBlockStatisticsBuilder { private final SegmentActionsListener actionsListener; @ColorInt private final int activeColor; - private final boolean nightMode; private final int minWidthPx; private final int maxWidthPx; private final int textSize; public BlockStatisticsAdapter(GpxDisplayItem displayItem, SegmentActionsListener actionsListener, - @ColorInt int activeColor, boolean nightMode) { + @ColorInt int activeColor) { this.displayItem = displayItem; this.actionsListener = actionsListener; this.activeColor = activeColor; - this.nightMode = nightMode; minWidthPx = AndroidUtils.dpToPx(app, 60f); maxWidthPx = AndroidUtils.dpToPx(app, 120f); textSize = app.getResources().getDimensionPixelSize(R.dimen.default_desc_text_size); @@ -250,7 +392,7 @@ public class GpxBlockStatisticsBuilder { holder.valueText.setText(item.value); holder.valueText.setTextColor(activeColor); holder.titleText.setText(item.title); - holder.titleText.setTextColor(app.getResources().getColor(R.color.text_color_secondary_light)); + holder.titleText.setTextColor(ContextCompat.getColor(app, R.color.text_color_secondary_light)); float letterSpacing = 0.00f; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { letterSpacing = Math.max(holder.valueText.getLetterSpacing(), holder.titleText.getLetterSpacing()); diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index 25fa38e04e..2822297f2e 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -51,7 +51,7 @@ public class OverviewCard extends BaseCard { super(mapActivity); this.actionsListener = actionsListener; this.selectedGpxFile = selectedGpxFile; - blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile); + blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile, nightMode); } @Override @@ -80,7 +80,7 @@ public class OverviewCard extends BaseCard { initEditButton(iconColorDef, iconColorPres); initDirectionsButton(iconColorDef, iconColorPres); } - blockStatisticsBuilder.initStatBlocks(actionsListener, getActiveColor(), nightMode); + blockStatisticsBuilder.initStatBlocks(actionsListener, getActiveColor()); } private GPXFile getGPXFile() { diff --git a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java index f6d5bdd4fd..f79ac0c6b5 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/PagerSlidingTabStrip.java @@ -66,12 +66,17 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { public interface CustomTabProvider { public View getCustomTabView(@NonNull ViewGroup parent, int position); + public void select(View tab); + public void deselect(View tab); + public void tabStylesUpdated(View tabsContainer, int currentPosition); } public interface OnTabReselectedListener { + public void onTabSelected(int position); + public void onTabReselected(int position); } @@ -121,7 +126,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { private int underlineHeight = 0; @ColorInt private int underlineColor; - + private int dividerWidth = 0; private int dividerPadding = 0; @@ -197,7 +202,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { //In case we have the padding they must be equal so we take the biggest padding = Math.max(paddingLeft, paddingRight); - + // get custom attrs a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip); @@ -221,7 +226,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { tabTypefaceSelectedStyle = a.getInt(R.styleable.PagerSlidingTabStrip_pstsTextSelectedStyle, Typeface.NORMAL); tabTextAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextAlpha, HALF_TRANSP); tabTextSelectedAlpha = a.getFloat(R.styleable.PagerSlidingTabStrip_pstsTextSelectedAlpha, OPAQUE); - tabTypeface = FontCache.getRobotoMedium(context); + tabTypeface = FontCache.getRobotoMedium(context); a.recycle(); setMarginBottomTabContainer(); @@ -326,6 +331,9 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { View tab = tabsContainer.getChildAt(pager.getCurrentItem()); notSelected(tab); pager.setCurrentItem(position); + if (tabReselectedListener != null) { + tabReselectedListener.onTabSelected(position); + } } else if (tabReselectedListener != null) { tabReselectedListener.onTabReselected(position); } @@ -470,7 +478,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { // draw underline rectPaint.setColor(underlineColor); //underlineColor canvas.drawRect(padding, height - underlineHeight, tabsContainer.getWidth() + padding, height, rectPaint); - + // draw divider if (dividerWidth != 0) { dividerPaint.setStrokeWidth(dividerWidth); From a8c732df4ec4212dd823daa31b4bef713df9a479 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 22 Mar 2021 10:52:49 +0200 Subject: [PATCH 35/96] Fix multimedia files export UI --- .../audionotes/AudioVideoNotesPlugin.java | 2 +- .../backend/backup/SettingsHelper.java | 4 ++-- .../fragments/DuplicatesSettingsAdapter.java | 10 +++++---- .../fragments/ExportItemsBottomSheet.java | 22 +++++++++++++++++++ 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java index f6d5f5c287..0bf4bb55fb 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/AudioVideoNotesPlugin.java @@ -317,7 +317,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin { } } - private String formatDateTime(Context ctx, long dateTime) { + public static String formatDateTime(Context ctx, long dateTime) { DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(ctx); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(ctx); return dateFormat.format(dateTime) + " " + timeFormat.format(dateTime); diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java index 0e3b9612cc..61a429f05f 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/backup/SettingsHelper.java @@ -900,11 +900,11 @@ public class SettingsHelper { List tileSourceTemplates = new ArrayList<>(); List routingFilesList = new ArrayList<>(); List renderFilesList = new ArrayList<>(); - List multimediaFilesList = new ArrayList<>(); List ttsVoiceFilesList = new ArrayList<>(); List voiceFilesList = new ArrayList<>(); List mapFilesList = new ArrayList<>(); List tracksFilesList = new ArrayList<>(); + List multimediaFilesList = new ArrayList<>(); List avoidRoads = new ArrayList<>(); List globalSettingsItems = new ArrayList<>(); List notesPointList = new ArrayList<>(); @@ -927,7 +927,7 @@ public class SettingsHelper { } else if (fileItem.getSubtype() == FileSubtype.ROUTING_CONFIG) { routingFilesList.add(fileItem.getFile()); } else if (fileItem.getSubtype() == FileSubtype.MULTIMEDIA_NOTES) { - multimediaFilesList.add(fileItem.getFile()); + multimediaFilesList.add(fileItem); } else if (fileItem.getSubtype() == FileSubtype.GPX) { tracksFilesList.add(fileItem); } else if (fileItem.getSubtype().isMap()) { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java index 4b8e40f1a0..12a046339a 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/DuplicatesSettingsAdapter.java @@ -6,6 +6,10 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.RecyclerView; + import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -15,6 +19,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.audionotes.AudioVideoNotesPlugin; +import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording; import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.GpxUiHelper; @@ -36,10 +41,6 @@ import org.apache.commons.logging.Log; import java.io.File; import java.util.List; -import androidx.annotation.NonNull; -import androidx.core.content.ContextCompat; -import androidx.recyclerview.widget.RecyclerView; - import static net.osmand.plus.settings.backend.backup.FileSettingsItem.FileSubtype; public class DuplicatesSettingsAdapter extends RecyclerView.Adapter { @@ -154,6 +155,7 @@ public class DuplicatesSettingsAdapter extends RecyclerView.Adapter Date: Mon, 22 Mar 2021 10:54:44 +0200 Subject: [PATCH 36/96] Fix possible npe --- .../net/osmand/plus/settings/backend/EnumStringPreference.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java b/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java index a88a17fed3..662c773172 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/EnumStringPreference.java @@ -30,7 +30,7 @@ public class EnumStringPreference> extends CommonPreference @Override protected String toString(E o) { - return o.name(); + return o == null ? null : o.name(); } @Override From a04f7e3bec28df6ff135dcbcd592934ecee84312 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 22 Mar 2021 11:33:57 +0200 Subject: [PATCH 37/96] Fix: selected value doesn't show above custom width slider after select "Custom" mode --- .../plus/routing/cards/RouteLineWidthCard.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java index 8925fcec37..a5ad4ccec1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -150,10 +150,11 @@ public class RouteLineWidthCard extends BaseCard { private void updateCustomWidthSlider() { if (selectedMode == WidthMode.CUSTOM) { - Slider widthSlider = view.findViewById(R.id.width_slider); + Slider slider = view.findViewById(R.id.width_slider); + final TextView tvCustomWidth = view.findViewById(R.id.width_value_tv); - widthSlider.setValueTo(CUSTOM_WIDTH_MAX); - widthSlider.setValueFrom(CUSTOM_WIDTH_MIN); + slider.setValueTo(CUSTOM_WIDTH_MAX); + slider.setValueFrom(CUSTOM_WIDTH_MIN); ((TextView) view.findViewById(R.id.width_value_min)).setText(String.valueOf(CUSTOM_WIDTH_MIN)); ((TextView) view.findViewById(R.id.width_value_max)).setText(String.valueOf(CUSTOM_WIDTH_MAX)); @@ -161,11 +162,12 @@ public class RouteLineWidthCard extends BaseCard { Integer width = getRouteLineWidth(); if (width == null || width > CUSTOM_WIDTH_MAX || width < CUSTOM_WIDTH_MIN) { width = CUSTOM_WIDTH_MIN; + setRouteLineWidth(width); } - widthSlider.setValue(width); + tvCustomWidth.setText(String.valueOf(width)); + slider.setValue(width); - final TextView tvCustomWidth = view.findViewById(R.id.width_value_tv); - widthSlider.addOnChangeListener(new Slider.OnChangeListener() { + slider.addOnChangeListener(new Slider.OnChangeListener() { @Override public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { if (fromUser) { @@ -175,7 +177,7 @@ public class RouteLineWidthCard extends BaseCard { } } }); - UiUtilities.setupSlider(widthSlider, nightMode, null, true); + UiUtilities.setupSlider(slider, nightMode, null, true); ScrollUtils.addOnGlobalLayoutListener(sliderContainer, new Runnable() { @Override public void run() { From 84266e5719f026a66cf318fc91fd182d9367bf45 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 22 Mar 2021 11:48:59 +0200 Subject: [PATCH 38/96] Fix route line in landscape --- .../net/osmand/plus/views/layers/RouteLayer.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 2ca620adab..ed7fbe173f 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -27,6 +27,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportStop; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.profiles.LocationIcon; @@ -298,9 +299,16 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } routeLinePaint.setColor(color); routeLinePaint.setStrokeWidth(width); - int screenCenter = AndroidUtils.getScreenWidth(getMapActivity())/2; - int screenHeight = AndroidUtils.getScreenHeight(getMapActivity()); - canvas.drawLine(screenCenter, 0, screenCenter, screenHeight, routeLinePaint); + MapActivity mapActivity = getMapActivity(); + int screenWidth = AndroidUtils.getScreenWidth(mapActivity); + int screenHeight = AndroidUtils.getScreenHeight(mapActivity); + int x; + if (AndroidUiHelper.isOrientationPortrait(mapActivity)) { + x = screenWidth / 2; + } else { + x = (int) (AndroidUtils.isLayoutRtl(mapActivity) ? screenWidth/4 : screenWidth * 0.75); + } + canvas.drawLine(x, 0, x, screenHeight, routeLinePaint); } } From 4543e16b1448eedc0dc5967628df9dd609148919 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 22 Mar 2021 12:03:10 +0200 Subject: [PATCH 39/96] Added icon ic_action_dialog for track recording show dialog option --- OsmAnd/res/drawable/ic_action_dialog.xml | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 OsmAnd/res/drawable/ic_action_dialog.xml diff --git a/OsmAnd/res/drawable/ic_action_dialog.xml b/OsmAnd/res/drawable/ic_action_dialog.xml new file mode 100644 index 0000000000..0346a117dd --- /dev/null +++ b/OsmAnd/res/drawable/ic_action_dialog.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + From 5ae37a101c59828aab3cbdf1e3f0bd6d1b0e5e79 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 22 Mar 2021 12:37:13 +0200 Subject: [PATCH 40/96] After code review fixes 1 --- OsmAnd/res/layout/route_line_color_card.xml | 2 -- .../plus/settings/fragments/ProfileAppearanceFragment.java | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/OsmAnd/res/layout/route_line_color_card.xml b/OsmAnd/res/layout/route_line_color_card.xml index d1c96345b5..c25332de88 100644 --- a/OsmAnd/res/layout/route_line_color_card.xml +++ b/OsmAnd/res/layout/route_line_color_card.xml @@ -93,8 +93,6 @@ android:id="@+id/colors_card_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingRight="@dimen/content_padding" - android:paddingLeft="@dimen/content_padding" android:paddingBottom="@dimen/content_padding_small"/> \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 3416222b95..690953d445 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -242,8 +242,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O findPreference(SELECT_ICON).setIconSpaceReserved(false); findPreference(SELECT_LOCATION_ICON).setIconSpaceReserved(false); findPreference(SELECT_NAV_ICON).setIconSpaceReserved(false); - findPreference(CUSTOMIZE_ROUTE_LINE).setIcon( - getIcon(R.drawable.ic_action_route_distance, getActiveColorRes())); if (getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile) { findPreference(SELECT_ICON).setVisible(false); findPreference(ICON_ITEMS).setVisible(false); @@ -735,6 +733,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT); boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile); preference.setVisible(!isDefaultProfile && !isPublicTransport); + preference.setIcon(getIcon(R.drawable.ic_action_route_distance, getActiveColorRes())); } } @@ -1087,7 +1086,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O return false; if (routeService != that.routeService) return false; if (navigationIcon != that.navigationIcon) return false; - if (routeLineDrawInfo != that.routeLineDrawInfo) return false; + if (routeLineDrawInfo != null ? !routeLineDrawInfo.equals(that.routeLineDrawInfo) : that.routeLineDrawInfo != null) return false; return locationIcon == that.locationIcon; } From 5f67fbcac69b1ad024e9fae2c2bbd10017e6fca3 Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 22 Mar 2021 13:13:04 +0200 Subject: [PATCH 41/96] add new setting - show start dialog --- OsmAnd/res/values/strings.xml | 6 +++-- OsmAnd/res/xml/monitoring_settings.xml | 9 +++++++- .../plus/activities/MapActivityActions.java | 2 +- .../MonitoringSettingsFragment.java | 7 ++++++ .../monitoring/OsmandMonitoringPlugin.java | 5 +++-- .../TripRecordingStartingBottomFragment.java | 22 ++++++++++++++++++- .../plus/settings/backend/OsmandSettings.java | 1 + 7 files changed, 45 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 21bb56470e..2e8b12d4fa 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,7 +11,9 @@ Thx - Hardy --> - All unsaved data will be lost. + If disabled, recording will start right after tap on the widget or menu item, skipping the confirmation dialog. + Show start dialog + All unsaved data will be lost. Save and continue Logging interval set time period in which OsmAnd will ask for the current location position data. Please select another type of colorization. @@ -1177,7 +1179,7 @@ No search results?\nProvide feedback - If disabled, recording will start right after tap on the widget or menu item, skipping the confirmation dialog. - Show start dialog - All unsaved data will be lost. + If disabled, recording will start right after tap on the widget or menu item, skipping the confirmation dialog. + Show start dialog + All unsaved data will be lost. Save and continue Logging interval set time period in which OsmAnd will ask for the current location position data. Please select another type of colorization. diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 7f96fbf3ec..487f4d902f 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -104,7 +104,7 @@ import net.osmand.plus.measurementtool.LoginBottomSheetFragment; import net.osmand.plus.measurementtool.MeasurementEditingContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.SnapTrackWarningFragment; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheetFragment; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; @@ -2241,8 +2241,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven return getFragment(MeasurementToolFragment.TAG); } - public TripRecordingStartingBottomSheetFragment getTripRecordingBottomSheet() { - return getFragment(TripRecordingStartingBottomSheetFragment.TAG); + public TripRecordingStartingBottomSheet getTripRecordingBottomSheet() { + return getFragment(TripRecordingStartingBottomSheet.TAG); } public ChooseRouteFragment getChooseRouteFragment() { diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index c3f36f89f3..4ef54303ea 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -62,8 +62,8 @@ import net.osmand.plus.mapmarkers.MarkersPlanRouteContext; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; -import net.osmand.plus.monitoring.TripRecordingBottomSheetFragment; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheetFragment; +import net.osmand.plus.monitoring.TripRecordingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment; import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataUtils; @@ -854,9 +854,9 @@ public class MapActivityActions implements DialogProvider { app.logEvent("trip_recording_open"); MapActivity.clearPrevActivityIntent(); if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) { - TripRecordingBottomSheetFragment.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack()); + TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager()); } else { - TripRecordingStartingBottomSheetFragment.showInstance(mapActivity.getSupportFragmentManager(), app, monitoringPlugin.getCurrentTrack()); + TripRecordingStartingBottomSheet.showTripRecordingDialog(mapActivity.getSupportFragmentManager(), app); } return true; } diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java index b9219a3d75..243362ea98 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragmentNew.java @@ -85,9 +85,9 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFreq import static net.osmand.plus.liveupdates.LiveUpdatesHelper.runLiveUpdate; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.setAlarmForPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getTertiaryTextColorId; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.getActiveTextColorId; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.getOsmandIconColorId; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.getSecondaryIconColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getActiveTextColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getOsmandIconColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getSecondaryIconColorId; public class LiveUpdatesFragmentNew extends BaseOsmAndDialogFragment implements OnLiveUpdatesForLocalChange { diff --git a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java index 2d67428141..f4ef01b7f1 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/MonitoringSettingsFragment.java @@ -300,8 +300,8 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment FragmentActivity activity = getActivity(); if (activity != null && !activity.isChangingConfigurations()) { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingStartingBottomSheetFragment) { - ((TripRecordingStartingBottomSheetFragment) target).show(); + if (target instanceof TripRecordingStartingBottomSheet) { + ((TripRecordingStartingBottomSheet) target).show(); } } super.onDestroy(); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java index 35dbea97a8..a96fc06d94 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java @@ -337,9 +337,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { public void controlDialog(final Activity activity, final boolean showTrackSelection) { FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager(); if (hasDataToSave() || wasTrackMonitored()) { - TripRecordingBottomSheetFragment.showInstance(fragmentManager, getCurrentTrack()); + TripRecordingBottomSheet.showInstance(fragmentManager); } else { - TripRecordingStartingBottomSheetFragment.showInstance(fragmentManager, app, getCurrentTrack()); + TripRecordingStartingBottomSheet.showTripRecordingDialog(fragmentManager, app); } /*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); @@ -507,7 +507,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { final Activity a = activityRef.get(); if (a instanceof FragmentActivity && !a.isFinishing()) { List singleName = Collections.singletonList(Algorithms.getFileNameWithoutExtension(file)); - SaveGPXBottomSheetFragment.showInstance(((FragmentActivity) a) + SaveGPXBottomSheet.showInstance(((FragmentActivity) a) .getSupportFragmentManager(), singleName); } } @@ -558,7 +558,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin { runnable.run(); } else if (map instanceof FragmentActivity) { FragmentActivity activity = (FragmentActivity) map; - TripRecordingStartingBottomSheetFragment.showInstance(activity.getSupportFragmentManager(), app, getCurrentTrack()); + TripRecordingStartingBottomSheet.showTripRecordingDialog(activity.getSupportFragmentManager(), app); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheet.java similarity index 97% rename from OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheet.java index d37d113e6c..14fd6e1352 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheet.java @@ -42,10 +42,10 @@ import java.util.List; import static net.osmand.FileUtils.ILLEGAL_FILE_NAME_CHARACTERS; -public class SaveGPXBottomSheetFragment extends MenuBottomSheetDialogFragment { +public class SaveGPXBottomSheet extends MenuBottomSheetDialogFragment { public static final String TAG = "SaveGPXBottomSheetFragment"; public static final String SAVED_TRACKS_KEY = "saved_track_filename"; - private static final Log LOG = PlatformUtil.getLog(SaveGPXBottomSheetFragment.class); + private static final Log LOG = PlatformUtil.getLog(SaveGPXBottomSheet.class); private boolean openTrack = false; private File file; @@ -227,7 +227,7 @@ public class SaveGPXBottomSheetFragment extends MenuBottomSheetDialogFragment { if (fragmentManager.isStateSaved()) { return; } - SaveGPXBottomSheetFragment f = new SaveGPXBottomSheetFragment(); + SaveGPXBottomSheet f = new SaveGPXBottomSheet(); Bundle b = new Bundle(); b.putStringArrayList(SAVED_TRACKS_KEY, new ArrayList<>(filenames)); f.setArguments(b); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java similarity index 97% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java index 4772e53197..8db1508454 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingBottomSheet.java @@ -73,10 +73,10 @@ import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_ALTITU import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_GENERAL; import static net.osmand.plus.track.GpxBlockStatisticsBuilder.INIT_BLOCKS_SPEED; -public class TripRecordingBottomSheetFragment extends MenuBottomSheetDialogFragment implements SegmentActionsListener { +public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment implements SegmentActionsListener { - public static final String TAG = TripRecordingBottomSheetFragment.class.getSimpleName(); - private static final Log LOG = PlatformUtil.getLog(TripRecordingBottomSheetFragment.class); + public static final String TAG = TripRecordingBottomSheet.class.getSimpleName(); + private static final Log LOG = PlatformUtil.getLog(TripRecordingBottomSheet.class); public static final String UPDATE_TRACK_ICON = "update_track_icon"; private static final int GPS_UPDATE_INTERVAL = 1000; private static final String[] INIT_BLOCKS_KEYS = @@ -104,10 +104,6 @@ public class TripRecordingBottomSheetFragment extends MenuBottomSheetDialogFragm return selectedGpxFile.getGpxFile(); } - public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) { - this.selectedGpxFile = selectedGpxFile; - } - private boolean hasDataToSave() { return helper.hasDataToSave(); } @@ -120,10 +116,9 @@ public class TripRecordingBottomSheetFragment extends MenuBottomSheetDialogFragm return settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); } - public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile) { + public static void showInstance(@NonNull FragmentManager fragmentManager) { if (!fragmentManager.isStateSaved()) { - TripRecordingBottomSheetFragment fragment = new TripRecordingBottomSheetFragment(); - fragment.setSelectedGpxFile(selectedGpxFile); + TripRecordingBottomSheet fragment = new TripRecordingBottomSheet(); fragment.show(fragmentManager, TAG); } } @@ -149,7 +144,7 @@ public class TripRecordingBottomSheetFragment extends MenuBottomSheetDialogFragm LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); createShowTrackItem(showTrackContainer, trackAppearanceIcon, ItemType.SHOW_TRACK.getTitleId(), - TripRecordingBottomSheetFragment.this, nightMode, new Runnable() { + TripRecordingBottomSheet.this, nightMode, new Runnable() { @Override public void run() { hide(); @@ -213,7 +208,7 @@ public class TripRecordingBottomSheetFragment extends MenuBottomSheetDialogFragm @Override public void onClick(View v) { if (fragmentManager != null) { - TripRecordingOptionsBottomSheetFragment.showInstance(fragmentManager, TripRecordingBottomSheetFragment.this); + TripRecordingOptionsBottomSheet.showInstance(fragmentManager, TripRecordingBottomSheet.this); } } }); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java similarity index 78% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java index 2e1f171bce..88814e4819 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingClearDataBottomSheet.java @@ -11,7 +11,7 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; -import net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.ItemType; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; @@ -19,15 +19,15 @@ import androidx.fragment.app.FragmentManager; import static net.osmand.AndroidUtils.getPrimaryTextColorId; -public class TripRecordingClearDataBottomSheetFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheetFragment.DismissTargetFragment { +public class TripRecordingClearDataBottomSheet extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheet.DismissTargetFragment { - public static final String TAG = TripRecordingClearDataBottomSheetFragment.class.getSimpleName(); + public static final String TAG = TripRecordingClearDataBottomSheet.class.getSimpleName(); private OsmandApplication app; public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) { if (!fragmentManager.isStateSaved()) { - TripRecordingClearDataBottomSheetFragment fragment = new TripRecordingClearDataBottomSheetFragment(); + TripRecordingClearDataBottomSheet fragment = new TripRecordingClearDataBottomSheet(); fragment.setTargetFragment(target, 0); fragment.show(fragmentManager, TAG); } @@ -81,15 +81,15 @@ public class TripRecordingClearDataBottomSheetFragment extends MenuBottomSheetDi } private View createItem(LayoutInflater inflater, ItemType type) { - return TripRecordingBottomSheetFragment.createItem(app, nightMode, inflater, type); + return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type); } @Override public void onResume() { super.onResume(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingOptionsBottomSheetFragment) { - ((TripRecordingOptionsBottomSheetFragment) target).hide(); + if (target instanceof TripRecordingOptionsBottomSheet) { + ((TripRecordingOptionsBottomSheet) target).hide(); } } @@ -97,8 +97,8 @@ public class TripRecordingClearDataBottomSheetFragment extends MenuBottomSheetDi public void onPause() { super.onPause(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingOptionsBottomSheetFragment) { - ((TripRecordingOptionsBottomSheetFragment) target).show(); + if (target instanceof TripRecordingOptionsBottomSheet) { + ((TripRecordingOptionsBottomSheet) target).show(); } } @@ -110,8 +110,8 @@ public class TripRecordingClearDataBottomSheetFragment extends MenuBottomSheetDi @Override public void dismissTarget() { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingOptionsBottomSheetFragment) { - ((TripRecordingOptionsBottomSheetFragment) target).dismiss(); + if (target instanceof TripRecordingOptionsBottomSheet) { + ((TripRecordingOptionsBottomSheet) target).dismiss(); } } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java similarity index 80% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java index 949257bc73..70414eab5e 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingDiscardBottomSheet.java @@ -12,24 +12,24 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; -import net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.ItemType; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import static net.osmand.AndroidUtils.getPrimaryTextColorId; -import static net.osmand.plus.monitoring.TripRecordingOptionsBottomSheetFragment.ACTION_STOP_AND_DISMISS; +import static net.osmand.plus.monitoring.TripRecordingOptionsBottomSheet.ACTION_STOP_AND_DISMISS; -public class TripRecordingDiscardBottomSheetFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheetFragment.DismissTargetFragment { +public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheet.DismissTargetFragment { - public static final String TAG = TripRecordingDiscardBottomSheetFragment.class.getSimpleName(); + public static final String TAG = TripRecordingDiscardBottomSheet.class.getSimpleName(); private OsmandApplication app; public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) { if (!fragmentManager.isStateSaved()) { - TripRecordingDiscardBottomSheetFragment fragment = new TripRecordingDiscardBottomSheetFragment(); + TripRecordingDiscardBottomSheet fragment = new TripRecordingDiscardBottomSheet(); fragment.setTargetFragment(target, 0); fragment.show(fragmentManager, TAG); } @@ -93,15 +93,15 @@ public class TripRecordingDiscardBottomSheetFragment extends MenuBottomSheetDial } private View createItem(LayoutInflater inflater, ItemType type) { - return TripRecordingBottomSheetFragment.createItem(app, nightMode, inflater, type); + return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type); } @Override public void onResume() { super.onResume(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingOptionsBottomSheetFragment) { - ((TripRecordingOptionsBottomSheetFragment) target).hide(); + if (target instanceof TripRecordingOptionsBottomSheet) { + ((TripRecordingOptionsBottomSheet) target).hide(); } } @@ -109,16 +109,16 @@ public class TripRecordingDiscardBottomSheetFragment extends MenuBottomSheetDial public void onPause() { super.onPause(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingOptionsBottomSheetFragment) { - ((TripRecordingOptionsBottomSheetFragment) target).show(); + if (target instanceof TripRecordingOptionsBottomSheet) { + ((TripRecordingOptionsBottomSheet) target).show(); } } @Override public void dismissTarget() { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingOptionsBottomSheetFragment) { - ((TripRecordingOptionsBottomSheetFragment) target).dismiss(); + if (target instanceof TripRecordingOptionsBottomSheet) { + ((TripRecordingOptionsBottomSheet) target).dismiss(); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java similarity index 86% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java index c110343ba8..ac42775bd2 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingOptionsBottomSheet.java @@ -27,7 +27,7 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.ItemType; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import net.osmand.plus.myplaces.SaveCurrentTrackTask; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; @@ -35,9 +35,9 @@ import net.osmand.util.Algorithms; import static net.osmand.AndroidUtils.getPrimaryTextColorId; -public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheetFragment.DismissTargetFragment { +public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragment implements TripRecordingBottomSheet.DismissTargetFragment { - public static final String TAG = TripRecordingOptionsBottomSheetFragment.class.getSimpleName(); + public static final String TAG = TripRecordingOptionsBottomSheet.class.getSimpleName(); public static final String ACTION_STOP_AND_DISMISS = "action_stop_and_discard"; private static final int SAVE_UPDATE_INTERVAL = 1000; @@ -72,7 +72,7 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) { if (!fragmentManager.isStateSaved()) { - TripRecordingOptionsBottomSheetFragment fragment = new TripRecordingOptionsBottomSheetFragment(); + TripRecordingOptionsBottomSheet fragment = new TripRecordingOptionsBottomSheet(); fragment.setTargetFragment(target, 0); fragment.show(fragmentManager, TAG); } @@ -109,7 +109,7 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial @Override public void onClick(View v) { if (fragmentManager != null && hasDataToSave()) { - TripRecordingClearDataBottomSheetFragment.showInstance(fragmentManager, TripRecordingOptionsBottomSheetFragment.this); + TripRecordingClearDataBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this); } } }) @@ -123,7 +123,7 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial @Override public void onClick(View v) { if (fragmentManager != null) { - TripRecordingDiscardBottomSheetFragment.showInstance(fragmentManager, TripRecordingOptionsBottomSheetFragment.this); + TripRecordingDiscardBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this); } } }) @@ -189,8 +189,8 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial super.onResume(); runUpdatingTimeTrackSaved(); Fragment target = getTargetFragment(); - if (target instanceof TripRecordingBottomSheetFragment) { - ((TripRecordingBottomSheetFragment) target).hide(); + if (target instanceof TripRecordingBottomSheet) { + ((TripRecordingBottomSheet) target).hide(); } } @@ -224,8 +224,8 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial @Override public void run() { String time = getTimeTrackSaved(); - TripRecordingBottomSheetFragment.createItem(app, nightMode, buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null); - TripRecordingBottomSheetFragment.createItem(app, nightMode, buttonClear, ItemType.CLEAR_DATA, hasDataToSave(), null); + TripRecordingBottomSheet.createItem(app, nightMode, buttonSave, ItemType.SAVE, hasDataToSave(), !Algorithms.isEmpty(time) ? time : null); + TripRecordingBottomSheet.createItem(app, nightMode, buttonClear, ItemType.CLEAR_DATA, hasDataToSave(), null); handler.postDelayed(this, SAVE_UPDATE_INTERVAL); } }; @@ -244,11 +244,11 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial } private View createItem(LayoutInflater inflater, ItemType type, boolean enabled) { - return TripRecordingBottomSheetFragment.createItem(app, nightMode, inflater, type, enabled, null); + return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type, enabled, null); } private View createItem(LayoutInflater inflater, ItemType type) { - return TripRecordingBottomSheetFragment.createItem(app, nightMode, inflater, type); + return TripRecordingBottomSheet.createItem(app, nightMode, inflater, type); } private SaveGpxListener createSaveListener() { @@ -286,11 +286,11 @@ public class TripRecordingOptionsBottomSheetFragment extends MenuBottomSheetDial @Override public void dismissTarget() { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingBottomSheetFragment) { + if (target instanceof TripRecordingBottomSheet) { if (isDiscard()) { - ((TripRecordingBottomSheetFragment) target).dismiss(); + ((TripRecordingBottomSheet) target).dismiss(); } else { - ((TripRecordingBottomSheetFragment) target).show(); + ((TripRecordingBottomSheet) target).show(); } } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java similarity index 87% rename from OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheetFragment.java rename to OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java index 8b41dab876..e45f792514 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/TripRecordingStartingBottomSheet.java @@ -19,31 +19,29 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.slider.RangeSlider; -import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.FontCache; -import net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.ItemType; +import net.osmand.plus.monitoring.TripRecordingBottomSheet.ItemType; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES; import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.createItem; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.createShowTrackItem; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.updateTrackIcon; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createItem; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.createShowTrackItem; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.updateTrackIcon; -public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDialogFragment { +public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragment { - public static final String TAG = TripRecordingStartingBottomSheetFragment.class.getSimpleName(); + public static final String TAG = TripRecordingStartingBottomSheet.class.getSimpleName(); public static final String UPDATE_LOGGING_INTERVAL = "update_logging_interval"; private OsmandApplication app; @@ -59,12 +57,12 @@ public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDia public static void showInstance(@NonNull FragmentManager fragmentManager) { if (!fragmentManager.isStateSaved()) { - TripRecordingStartingBottomSheetFragment fragment = new TripRecordingStartingBottomSheetFragment(); + TripRecordingStartingBottomSheet fragment = new TripRecordingStartingBottomSheet(); fragment.show(fragmentManager, TAG); } } - public static void showInstance(@NonNull FragmentManager fragmentManager, OsmandApplication app, SelectedGpxFile selectedGpxFile) { + public static void showTripRecordingDialog(@NonNull FragmentManager fragmentManager, OsmandApplication app) { if (!fragmentManager.isStateSaved()) { OsmandSettings settings = app.getSettings(); boolean showStartDialog = settings.SHOW_TRIP_REC_START_DIALOG.get(); @@ -72,7 +70,7 @@ public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDia showInstance(fragmentManager); } else { startRecording(app); - TripRecordingBottomSheetFragment.showInstance(fragmentManager, selectedGpxFile); + TripRecordingBottomSheet.showInstance(fragmentManager); } } } @@ -106,7 +104,7 @@ public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDia LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon); createShowTrackItem(showTrackContainer, trackAppearanceIcon, R.string.shared_string_show_on_map, - TripRecordingStartingBottomSheetFragment.this, nightMode, new Runnable() { + TripRecordingStartingBottomSheet.this, nightMode, new Runnable() { @Override public void run() { hide(); @@ -142,7 +140,7 @@ public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDia if (mapActivity != null) { hide(); BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.MONITORING_SETTINGS, - null, new Bundle(), TripRecordingStartingBottomSheetFragment.this); + null, new Bundle(), TripRecordingStartingBottomSheet.this); } } }); @@ -221,10 +219,8 @@ public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDia } private static void startRecording(OsmandApplication app) { - OsmandSettings settings = app.getSettings(); - SavingTrackHelper helper = app.getSavingTrackHelper(); - helper.startNewSegment(); - settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true); + app.getSavingTrackHelper().startNewSegment(); + app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.set(true); app.startNavigationService(NavigationService.USED_BY_GPX); } @@ -232,8 +228,7 @@ public class TripRecordingStartingBottomSheetFragment extends MenuBottomSheetDia startRecording(app); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - SavingTrackHelper helper = app.getSavingTrackHelper(); - TripRecordingBottomSheetFragment.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack()); + TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager()); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java index 8a37c9c239..2f4ca39f84 100644 --- a/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/settings/bottomsheets/BooleanPreferenceBottomSheet.java @@ -34,7 +34,7 @@ import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import org.apache.commons.logging.Log; import static net.osmand.plus.liveupdates.LiveUpdatesSettingsDialogFragmentNew.getActivePrimaryColorId; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.getSecondaryIconColorId; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.getSecondaryIconColorId; public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java index 8b1f5fb09b..7329c58105 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackAppearanceFragment.java @@ -36,8 +36,8 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter; import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem; import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.monitoring.TripRecordingBottomSheetFragment; -import net.osmand.plus.monitoring.TripRecordingStartingBottomSheetFragment; +import net.osmand.plus.monitoring.TripRecordingBottomSheet; +import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.settings.backend.CommonPreference; @@ -64,7 +64,7 @@ import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_COLOR_ATTR; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_BOLD; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.TRACK_WIDTH_MEDIUM; import static net.osmand.plus.dialogs.GpxAppearanceAdapter.getAppearanceItems; -import static net.osmand.plus.monitoring.TripRecordingBottomSheetFragment.UPDATE_TRACK_ICON; +import static net.osmand.plus.monitoring.TripRecordingBottomSheet.UPDATE_TRACK_ICON; public class TrackAppearanceFragment extends ContextMenuScrollFragment implements CardListener, ColorPickerListener { @@ -398,10 +398,10 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement @Override public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) { Fragment target = getTargetFragment(); - if (target instanceof TripRecordingStartingBottomSheetFragment) { - ((TripRecordingStartingBottomSheetFragment) target).show(); - } else if (target instanceof TripRecordingBottomSheetFragment) { - ((TripRecordingBottomSheetFragment) target).show(UPDATE_TRACK_ICON); + if (target instanceof TripRecordingStartingBottomSheet) { + ((TripRecordingStartingBottomSheet) target).show(); + } else if (target instanceof TripRecordingBottomSheet) { + ((TripRecordingBottomSheet) target).show(UPDATE_TRACK_ICON); } } From 573b2cec9db71bbe2225349169af62cb8e8eab96 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 22 Mar 2021 22:36:53 +0200 Subject: [PATCH 71/96] fix "save to settings and restore" --- .../fragments/ProfileAppearanceFragment.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 5c9c787100..6621485192 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -57,6 +57,7 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.fragments.RouteLineAppearanceFragment.OnApplyRouteLineListener; @@ -1018,28 +1019,30 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } private RouteLineDrawInfo createRouteLineDrawInfo(@NonNull ApplicationMode appMode) { - Integer color = null; - Integer width = null; - if (settings.ROUTE_LINE_COLOR.isSetForMode(appMode)) { - color = settings.ROUTE_LINE_COLOR.getModeValue(appMode); - } - if (settings.ROUTE_LINE_WIDTH.isSetForMode(appMode)) { - width = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); - } + Integer color = getRouteLineAttribute(appMode, settings.ROUTE_LINE_COLOR); + Integer width = getRouteLineAttribute(appMode, settings.ROUTE_LINE_WIDTH); return new RouteLineDrawInfo(color, width); } + private Integer getRouteLineAttribute(@NonNull ApplicationMode appMode, + @NonNull CommonPreference preference) { + int value = preference.getModeValue(appMode); + return value != 0 ? value : null; + } + private void saveRouteLineAppearance(@NonNull ApplicationMode appMode, - @NonNull RouteLineDrawInfo routeLineDrawInfo) { - if (routeLineDrawInfo.getColor() != null) { - settings.ROUTE_LINE_COLOR.setModeValue(appMode, routeLineDrawInfo.getColor()); + @NonNull RouteLineDrawInfo drawInfo) { + saveRouteLineAttribute(appMode, settings.ROUTE_LINE_COLOR, drawInfo.getColor()); + saveRouteLineAttribute(appMode, settings.ROUTE_LINE_WIDTH, drawInfo.getWidth()); + } + + private void saveRouteLineAttribute(@NonNull ApplicationMode appMode, + @NonNull CommonPreference preference, + @Nullable Integer value) { + if (value != null) { + preference.setModeValue(appMode, value); } else { - settings.ROUTE_LINE_COLOR.resetToDefault(); - } - if (routeLineDrawInfo.getWidth() != null) { - settings.ROUTE_LINE_WIDTH.setModeValue(appMode, routeLineDrawInfo.getWidth()); - } else { - settings.ROUTE_LINE_WIDTH.resetToDefault(); + preference.resetModeToDefault(appMode); } } From 0cda81127d84ebd4a7f0b72065f5a4f61a63037f Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Mon, 22 Mar 2021 23:41:55 +0200 Subject: [PATCH 72/96] show line and navigation icon in preview mode --- .../plus/routing/RouteLineDrawInfo.java | 73 ++++++++++++++++++- .../fragments/ProfileAppearanceFragment.java | 5 +- .../RouteLineAppearanceFragment.java | 20 +++++ .../osmand/plus/views/layers/RouteLayer.java | 64 ++++++++++------ 4 files changed, 138 insertions(+), 24 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java index 66fd7e28f8..ddc086e2e2 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java @@ -12,11 +12,25 @@ public class RouteLineDrawInfo { private static final String LINE_COLOR = "line_color"; private static final String LINE_WIDTH = "line_width"; + private static final String NAVIGATION_ICON_ID = "navigation_icon_id"; + private static final String NAVIGATION_ICON_COLOR = "navigation_icon_color"; + private static final String CENTER_X = "center_x"; + private static final String CENTER_Y = "center_y"; + private static final String SCREEN_HEIGHT = "screen_height"; + // parameters to save @ColorInt private Integer color; private Integer width; + // temporally parameters to show in preview + @ColorInt + private int iconColor; + private int iconId; + private int centerX; + private int centerY; + private int screenHeight; + public RouteLineDrawInfo(@Nullable @ColorInt Integer color, @Nullable Integer width) { this.color = color; @@ -28,7 +42,13 @@ public class RouteLineDrawInfo { } public RouteLineDrawInfo(@NonNull RouteLineDrawInfo existed) { - this(existed.getColor(), existed.getWidth()); + this.color = existed.getColor(); + this.width = existed.getWidth(); + this.iconId = existed.iconId; + this.iconColor = existed.iconColor; + this.centerX = existed.centerX; + this.centerY = existed.centerY; + this.screenHeight = existed.screenHeight; } @Nullable @@ -49,9 +69,55 @@ public class RouteLineDrawInfo { this.width = width; } + public void setIconId(int iconId) { + this.iconId = iconId; + } + + public void setIconColor(int iconColor) { + this.iconColor = iconColor; + } + + public void setCenterX(int centerX) { + this.centerX = centerX; + } + + public void setCenterY(int centerY) { + this.centerY = centerY; + } + + public void setScreenHeight(int screenHeight) { + this.screenHeight = screenHeight; + } + + public int getIconId() { + return iconId; + } + + @ColorInt + public int getIconColor() { + return iconColor; + } + + public int getCenterX() { + return centerX; + } + + public int getCenterY() { + return centerY; + } + + public int getScreenHeight() { + return screenHeight; + } + private void readBundle(@NonNull Bundle bundle) { color = bundle.getInt(LINE_COLOR); width = bundle.getInt(LINE_WIDTH); + iconId = bundle.getInt(NAVIGATION_ICON_ID); + iconColor = bundle.getInt(NAVIGATION_ICON_COLOR); + centerX = bundle.getInt(CENTER_X); + centerY = bundle.getInt(CENTER_Y); + screenHeight = bundle.getInt(SCREEN_HEIGHT); } public void saveToBundle(@NonNull Bundle bundle) { @@ -61,6 +127,11 @@ public class RouteLineDrawInfo { if (width != null) { bundle.putInt(LINE_WIDTH, width); } + bundle.putInt(NAVIGATION_ICON_ID, iconId); + bundle.putInt(NAVIGATION_ICON_COLOR, iconColor); + bundle.putInt(CENTER_X, (int) centerX); + bundle.putInt(CENTER_Y, (int) centerY); + bundle.putInt(SCREEN_HEIGHT, screenHeight); } @Override diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 6621485192..1ecc9e32c4 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -997,7 +997,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O MapActivity mapActivity = getMapActivity(); ApplicationMode appMode = getSelectedAppMode(); if (mapActivity != null && appMode != null) { - RouteLineAppearanceFragment.showInstance(mapActivity, changedProfile.routeLineDrawInfo, appMode, this); + RouteLineDrawInfo drawInfo = changedProfile.routeLineDrawInfo; + drawInfo.setIconId(changedProfile.navigationIcon.getIconId()); + drawInfo.setIconColor(changedProfile.getActualColor()); + RouteLineAppearanceFragment.showInstance(mapActivity, drawInfo, appMode, this); } } return super.onPreferenceClick(preference); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java index 39d9c853ca..4bb5b64156 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -160,6 +160,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple @Override public void run() { updateMapControlsPos(RouteLineAppearanceFragment.this, getViewY(), true); + initVisibleRect(); } }); } @@ -286,6 +287,25 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple .setDuration(200); } + private void initVisibleRect() { + MapActivity ctx = getMapActivity(); + int screenHeight = AndroidUtils.getScreenHeight(ctx); + int screenWidth = AndroidUtils.getScreenWidth(ctx); + int statusBarHeight = AndroidUtils.getStatusBarHeight(ctx); + int x; + int y; + if (AndroidUiHelper.isOrientationPortrait(ctx)) { + x = screenWidth / 2; + y = (getViewY() + toolbarContainer.getHeight() + statusBarHeight) / 2; + } else { + x = (int) (AndroidUtils.isLayoutRtl(ctx) ? screenWidth/4 : screenWidth * 0.75); + y = (screenHeight + statusBarHeight) / 2 ; + } + routeLineDrawInfo.setCenterX(x); + routeLineDrawInfo.setCenterY(y); + routeLineDrawInfo.setScreenHeight(screenHeight); + } + @Override public void onResume() { super.onResume(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index ed7fbe173f..1296d9df55 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -17,6 +17,7 @@ import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; +import androidx.core.graphics.drawable.DrawableCompat; import net.osmand.AndroidUtils; import net.osmand.Location; @@ -287,31 +288,50 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont @Override public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (routeLineDrawInfo != null) { - // draw route line on map - updateAttrs(settings, tileBox); - Integer color = routeLineDrawInfo.getColor(); - if (color == null) { - color = attrs.paint.getColor(); - } - Integer width = routeLineDrawInfo.getWidth(); - if (width == null) { - width = (int) attrs.paint.getStrokeWidth(); - } - routeLinePaint.setColor(color); - routeLinePaint.setStrokeWidth(width); - MapActivity mapActivity = getMapActivity(); - int screenWidth = AndroidUtils.getScreenWidth(mapActivity); - int screenHeight = AndroidUtils.getScreenHeight(mapActivity); - int x; - if (AndroidUiHelper.isOrientationPortrait(mapActivity)) { - x = screenWidth / 2; - } else { - x = (int) (AndroidUtils.isLayoutRtl(mapActivity) ? screenWidth/4 : screenWidth * 0.75); - } - canvas.drawLine(x, 0, x, screenHeight, routeLinePaint); + drawRouteLinePreview(canvas, tileBox, settings, routeLineDrawInfo); } } + private void drawRouteLinePreview(Canvas canvas, + RotatedTileBox tileBox, + DrawSettings settings, + RouteLineDrawInfo drawInfo) { + MapActivity mapActivity = getMapActivity(); + updateAttrs(settings, tileBox); + + int x = drawInfo.getCenterX(); + int y = drawInfo.getCenterY(); + int screenHeight = drawInfo.getScreenHeight(); + + // draw line + Integer color = drawInfo.getColor(); + if (color == null) { + color = attrs.paint.getColor(); + } + Integer width = drawInfo.getWidth(); + if (width == null) { + width = (int) attrs.paint.getStrokeWidth(); + } + routeLinePaint.setColor(color); + routeLinePaint.setStrokeWidth(width); + canvas.drawLine(x, 0, x, screenHeight, routeLinePaint); + + // draw image + LayerDrawable navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(mapActivity, drawInfo.getIconId()); + if (navigationIcon != null) { + DrawableCompat.setTint(navigationIcon.getDrawable(1), drawInfo.getIconColor()); + } + int left = x - navigationIcon.getIntrinsicWidth() / 2; + int right = x + navigationIcon.getIntrinsicWidth() / 2; + int top = y - navigationIcon.getIntrinsicHeight() / 2; + int bottom = y + navigationIcon.getIntrinsicHeight() / 2; + navigationIcon.setBounds(left, top, right, bottom); + canvas.rotate(-90, x, y); + navigationIcon.draw(canvas); + canvas.save(); + canvas.restore(); + } + private void drawAction(RotatedTileBox tb, Canvas canvas, List actionPoints) { if (actionPoints.size() > 0) { canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); From 0ea47b985a3a99f6fb7891412ed1dc9562aa9f5d Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 23 Mar 2021 00:06:08 +0200 Subject: [PATCH 73/96] return inner scroll --- OsmAnd/res/layout/route_line_appearance.xml | 42 ++++++++++++++++++- .../RouteLineAppearanceFragment.java | 5 --- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/OsmAnd/res/layout/route_line_appearance.xml b/OsmAnd/res/layout/route_line_appearance.xml index de3ba175b0..ca822afb37 100644 --- a/OsmAnd/res/layout/route_line_appearance.xml +++ b/OsmAnd/res/layout/route_line_appearance.xml @@ -13,10 +13,50 @@ + + + + + + + + + + + + + android:layout_height="match_parent" + android:foreground="@drawable/bg_contextmenu_shadow" + android:foregroundGravity="top|fill_horizontal"> Date: Tue, 23 Mar 2021 00:29:34 +0200 Subject: [PATCH 74/96] use the same paint for calculated route and preview --- .../osmand/plus/views/layers/RouteLayer.java | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 1296d9df55..1491a7791c 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -38,6 +38,9 @@ import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; +import net.osmand.plus.settings.backend.ApplicationMode; +import net.osmand.plus.settings.backend.CommonPreference; +import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay; @@ -253,6 +256,37 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont routeWayContext.updatePaints(nightMode, attrs); publicTransportWayContext.updatePaints(nightMode, attrs, attrsPT, attrsW); } + + updateRouteLineAppearance(); + } + + private void updateRouteLineAppearance() { + OsmandSettings settings = view.getApplication().getSettings(); + ApplicationMode appMode = settings.getApplicationMode(); + Integer color = null; + Integer width = null; + if (routeLineDrawInfo != null) { + color = routeLineDrawInfo.getColor(); + width = routeLineDrawInfo.getWidth(); + } + if (color == null) { + color = getRouteLineAttribute(appMode, settings.ROUTE_LINE_COLOR); + } + if (width == null) { + width = getRouteLineAttribute(appMode, settings.ROUTE_LINE_WIDTH); + } + if (color != null) { + attrs.paint.setColor(color); + } + if (width != null) { + attrs.paint.setStrokeWidth(color); + } + } + + private Integer getRouteLineAttribute(@NonNull ApplicationMode appMode, + @NonNull CommonPreference preference) { + int value = preference.getModeValue(appMode); + return value != 0 ? value : null; } private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) { @@ -283,8 +317,6 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } } - private Paint routeLinePaint = new Paint(); - @Override public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (routeLineDrawInfo != null) { @@ -304,17 +336,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont int screenHeight = drawInfo.getScreenHeight(); // draw line - Integer color = drawInfo.getColor(); - if (color == null) { - color = attrs.paint.getColor(); - } - Integer width = drawInfo.getWidth(); - if (width == null) { - width = (int) attrs.paint.getStrokeWidth(); - } - routeLinePaint.setColor(color); - routeLinePaint.setStrokeWidth(width); - canvas.drawLine(x, 0, x, screenHeight, routeLinePaint); + canvas.drawLine(x, 0, x, screenHeight, attrs.paint); // draw image LayerDrawable navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(mapActivity, drawInfo.getIconId()); From 7c9bdb70f124064fefed7f8945b906cd70be1953 Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 23 Mar 2021 12:13:00 +0500 Subject: [PATCH 75/96] Fix 'Open track' button of newly created Waypoint --- .../plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 0e583392ba..88052adf4e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -213,6 +213,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { String description = Algorithms.isEmpty(getDescriptionTextValue()) ? null : getDescriptionTextValue(); if (editor.isNew()) { doAddWpt(name, category, description); + wpt = getWpt(); } else { doUpdateWpt(name, category, description); } @@ -222,7 +223,7 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } MapContextMenu menu = mapActivity.getContextMenu(); - if (menu.getLatLon() != null && menu.isActive()) { + if (menu.getLatLon() != null && menu.isActive() && wpt != null) { LatLon latLon = new LatLon(wpt.getLatitude(), wpt.getLongitude()); if (menu.getLatLon().equals(latLon)) { menu.update(latLon, new WptLocationPoint(wpt).getPointDescription(mapActivity), wpt); From 63b588d0b1490d52e5b801df0add77e4cf12ad23 Mon Sep 17 00:00:00 2001 From: cepprice Date: Tue, 23 Mar 2021 12:36:50 +0500 Subject: [PATCH 76/96] Notify that track waypoint group is hidden --- .../editors/WptPtEditorFragmentNew.java | 19 ++++++++++++++++++- .../osmand/plus/track/TrackMenuFragment.java | 3 +++ .../osmand/plus/track/TrackPointsCard.java | 10 +++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 88052adf4e..11eaa90bbd 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -20,6 +20,7 @@ import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -403,7 +404,9 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { } @Override - public String getAddressInitValue() { return ""; } + public String getAddressInitValue() { + return ""; + } @Override public Drawable getNameIcon() { @@ -481,6 +484,20 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { return 0; } + @Override + protected boolean isCategoryVisible(String name) { + WptPtEditor editor = getWptPtEditor(); + if (selectedGpxHelper == null || editor == null || editor.getGpxFile() == null) { + return true; + } + SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(editor.getGpxFile().path); + if (selectedGpxFile != null) { + Set hiddenGroups = selectedGpxFile.getHiddenGroups(); + return !hiddenGroups.contains(name); + } + return true; + } + private void saveGpx(final OsmandApplication app, final GPXFile gpxFile, final boolean gpxSelected) { new SaveGpxAsyncTask(new File(gpxFile.path), gpxFile, new SaveGpxListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index bb738a8e00..45a30465f0 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -1250,6 +1250,9 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (mapActivity != null) { FragmentManager fragmentManager = mapActivity.getSupportFragmentManager(); fragmentManager.beginTransaction().show(this).commit(); + if (pointsCard != null && menuType == TrackMenuType.POINTS) { + pointsCard.updateGroups(); + } } } catch (Exception e) { log.error(e); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackPointsCard.java b/OsmAnd/src/net/osmand/plus/track/TrackPointsCard.java index 7af804ef84..95cd54364c 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackPointsCard.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackPointsCard.java @@ -114,6 +114,12 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O this.selectedGroup = selectedGroup; } + public void updateGroups() { + selectedItems.clear(); + selectedGroups.clear(); + adapter.synchronizeGroups(getDisplayGroups()); + } + public List getGroups() { return adapter.groups; } @@ -263,9 +269,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O @Override public void onPointsDeleted() { - selectedItems.clear(); - selectedGroups.clear(); - adapter.synchronizeGroups(getDisplayGroups()); + updateGroups(); } public void filter(String text) { From e7e78d8449ed28e5b23402f4deec45fd79aaecd7 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 23 Mar 2021 10:19:26 +0200 Subject: [PATCH 77/96] use width modes defined for track appearance --- .../plus/routing/RouteLineDrawInfo.java | 12 +- .../routing/cards/RouteLineWidthCard.java | 57 ++++---- .../plus/settings/backend/OsmandSettings.java | 2 +- .../fragments/ProfileAppearanceFragment.java | 28 ++-- .../osmand/plus/views/layers/RouteLayer.java | 122 ++++++++++++++---- 5 files changed, 136 insertions(+), 85 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java index ddc086e2e2..d4660bffc9 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java @@ -21,7 +21,7 @@ public class RouteLineDrawInfo { // parameters to save @ColorInt private Integer color; - private Integer width; + private String width; // temporally parameters to show in preview @ColorInt @@ -32,7 +32,7 @@ public class RouteLineDrawInfo { private int screenHeight; public RouteLineDrawInfo(@Nullable @ColorInt Integer color, - @Nullable Integer width) { + @Nullable String width) { this.color = color; this.width = width; } @@ -57,7 +57,7 @@ public class RouteLineDrawInfo { } @Nullable - public Integer getWidth() { + public String getWidth() { return width; } @@ -65,7 +65,7 @@ public class RouteLineDrawInfo { this.color = color; } - public void setWidth(@Nullable Integer width) { + public void setWidth(@Nullable String width) { this.width = width; } @@ -112,7 +112,7 @@ public class RouteLineDrawInfo { private void readBundle(@NonNull Bundle bundle) { color = bundle.getInt(LINE_COLOR); - width = bundle.getInt(LINE_WIDTH); + width = bundle.getString(LINE_WIDTH); iconId = bundle.getInt(NAVIGATION_ICON_ID); iconColor = bundle.getInt(NAVIGATION_ICON_COLOR); centerX = bundle.getInt(CENTER_X); @@ -125,7 +125,7 @@ public class RouteLineDrawInfo { bundle.putInt(LINE_COLOR, color); } if (width != null) { - bundle.putInt(LINE_WIDTH, width); + bundle.putString(LINE_WIDTH, width); } bundle.putInt(NAVIGATION_ICON_ID, iconId); bundle.putInt(NAVIGATION_ICON_COLOR, iconColor); diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java index d8bac7f25c..dbe563175f 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -10,6 +10,7 @@ import android.widget.TextView; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.LinearLayoutManager; @@ -28,6 +29,7 @@ import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.TrackAppearanceFragment.OnNeedScrollListener; +import net.osmand.util.Algorithms; import java.util.Arrays; import java.util.List; @@ -50,20 +52,20 @@ public class RouteLineWidthCard extends BaseCard { private enum WidthMode { DEFAULT(R.string.map_widget_renderer, R.drawable.ic_action_map_style, null), - THIN(R.string.rendering_value_thin_name, R.drawable.ic_action_track_line_thin_color, 5), - MEDIUM(R.string.rendering_value_medium_name, R.drawable.ic_action_track_line_medium_color, 13), - THICK(R.string.rendering_value_bold_name, R.drawable.ic_action_track_line_bold_color, 28), + THIN(R.string.rendering_value_thin_name, R.drawable.ic_action_track_line_thin_color, "thin"), + MEDIUM(R.string.rendering_value_medium_name, R.drawable.ic_action_track_line_medium_color, "medium"), + THICK(R.string.rendering_value_bold_name, R.drawable.ic_action_track_line_bold_color, "bold"), CUSTOM(R.string.shared_string_custom, R.drawable.ic_action_settings, null); - WidthMode(int titleId, int iconId, Integer width) { + WidthMode(int titleId, int iconId, String widthKey) { this.titleId = titleId; this.iconId = iconId; - this.width = width; + this.widthKey = widthKey; } int titleId; int iconId; - Integer width; + String widthKey; } public RouteLineWidthCard(@NonNull MapActivity mapActivity, @@ -112,12 +114,12 @@ public class RouteLineWidthCard extends BaseCard { } } - private void setRouteLineWidth(Integer width) { - routeLineDrawInfo.setWidth(width); + private void setRouteLineWidth(String widthKey) { + routeLineDrawInfo.setWidth(widthKey); mapActivity.refreshMap(); } - private Integer getRouteLineWidth() { + private String getRouteLineWidth() { return routeLineDrawInfo.getWidth(); } @@ -148,21 +150,20 @@ public class RouteLineWidthCard extends BaseCard { ((TextView) view.findViewById(R.id.width_value_min)).setText(String.valueOf(CUSTOM_WIDTH_MIN)); ((TextView) view.findViewById(R.id.width_value_max)).setText(String.valueOf(CUSTOM_WIDTH_MAX)); - Integer width = getRouteLineWidth(); - if (width == null || width > CUSTOM_WIDTH_MAX || width < CUSTOM_WIDTH_MIN) { - width = CUSTOM_WIDTH_MIN; - setRouteLineWidth(width); - } - tvCustomWidth.setText(String.valueOf(width)); + String widthKey = getRouteLineWidth(); + int width = Algorithms.parseIntSilently(widthKey, 1); + widthKey = String.valueOf(width); + setRouteLineWidth(widthKey); + tvCustomWidth.setText(widthKey); slider.setValue(width); slider.addOnChangeListener(new Slider.OnChangeListener() { @Override public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) { if (fromUser) { - Integer newWidth = (int) value; + String newWidth = String.valueOf((int) value); setRouteLineWidth(newWidth); - tvCustomWidth.setText(String.valueOf(newWidth)); + tvCustomWidth.setText(newWidth); } } }); @@ -188,22 +189,16 @@ public class RouteLineWidthCard extends BaseCard { } } - private static WidthMode findAppropriateMode(Integer width) { - WidthMode result = null; - if (width != null) { + private static WidthMode findAppropriateMode(@Nullable String widthKey) { + if (widthKey != null) { for (WidthMode mode : WidthMode.values()) { - if (mode.width != null && (int) width == mode.width) { - result = mode; - break; + if (mode.widthKey != null && mode.widthKey.equals(widthKey)) { + return mode; } } - if (result == null) { - result = WidthMode.CUSTOM; - } - } else { - result = WidthMode.DEFAULT; + return WidthMode.CUSTOM; } - return result; + return WidthMode.DEFAULT; } private class WidthAdapter extends RecyclerView.Adapter { @@ -243,7 +238,7 @@ public class RouteLineWidthCard extends BaseCard { notifyItemChanged(prevSelectedPosition); if (selectedMode != WidthMode.CUSTOM) { - setRouteLineWidth(selectedMode.width); + setRouteLineWidth(selectedMode.widthKey); } modeChanged(); @@ -273,7 +268,7 @@ public class RouteLineWidthCard extends BaseCard { } private int getIconColor(@NonNull WidthMode mode, @ColorInt int defaultColor) { - return mode.width != null ? getRouteLineColor() : defaultColor; + return mode.widthKey != null ? getRouteLineColor() : defaultColor; } private int getRouteLineColor() { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 797cdb05c3..be65250165 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -2692,7 +2692,7 @@ public class OsmandSettings { public final CommonPreference ROUTE_STRAIGHT_ANGLE = new FloatPreference(this, "routing_straight_angle", 30.f).makeProfile(); public final ListStringPreference CUSTOM_ROUTE_LINE_COLORS = (ListStringPreference) new ListStringPreference(this, "custom_route_line_colors", null, ",").makeShared().makeGlobal(); public final CommonPreference ROUTE_LINE_COLOR = new IntPreference(this, "route_line_color", 0).makeProfile(); - public final CommonPreference ROUTE_LINE_WIDTH = new IntPreference(this, "route_line_width", 0).makeProfile(); + public final CommonPreference ROUTE_LINE_WIDTH = new StringPreference(this, "route_line_width", null).makeProfile(); public final OsmandPreference USE_OSM_LIVE_FOR_ROUTING = new BooleanPreference(this, "enable_osmc_routing", true).makeProfile(); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 1ecc9e32c4..bcb0a120eb 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -1022,31 +1022,21 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O } private RouteLineDrawInfo createRouteLineDrawInfo(@NonNull ApplicationMode appMode) { - Integer color = getRouteLineAttribute(appMode, settings.ROUTE_LINE_COLOR); - Integer width = getRouteLineAttribute(appMode, settings.ROUTE_LINE_WIDTH); - return new RouteLineDrawInfo(color, width); - } - - private Integer getRouteLineAttribute(@NonNull ApplicationMode appMode, - @NonNull CommonPreference preference) { - int value = preference.getModeValue(appMode); - return value != 0 ? value : null; + int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); + Integer color = storedValue != 0 ? storedValue : null; + String widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); + return new RouteLineDrawInfo(color, widthKey); } private void saveRouteLineAppearance(@NonNull ApplicationMode appMode, @NonNull RouteLineDrawInfo drawInfo) { - saveRouteLineAttribute(appMode, settings.ROUTE_LINE_COLOR, drawInfo.getColor()); - saveRouteLineAttribute(appMode, settings.ROUTE_LINE_WIDTH, drawInfo.getWidth()); - } - - private void saveRouteLineAttribute(@NonNull ApplicationMode appMode, - @NonNull CommonPreference preference, - @Nullable Integer value) { - if (value != null) { - preference.setModeValue(appMode, value); + Integer color = drawInfo.getColor(); + if (drawInfo.getColor() != null) { + settings.ROUTE_LINE_COLOR.setModeValue(appMode, color); } else { - preference.resetModeToDefault(appMode); + settings.ROUTE_LINE_COLOR.resetModeToDefault(appMode); } + settings.ROUTE_LINE_WIDTH.setModeValue(appMode, drawInfo.getWidth()); } public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable String appMode, boolean imported) { diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 1491a7791c..5049789fe6 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -21,17 +21,20 @@ import androidx.core.graphics.drawable.DrawableCompat; import net.osmand.AndroidUtils; import net.osmand.Location; +import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; +import net.osmand.data.QuadPoint; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.data.TransportStop; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapcontextmenu.other.TrackChartPoints; import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.profiles.LocationIcon; +import net.osmand.plus.render.OsmandRenderer; +import net.osmand.plus.render.OsmandRenderer.RenderingContext; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RouteLineDrawInfo; @@ -39,7 +42,6 @@ import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; @@ -47,18 +49,29 @@ import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWayContext; import net.osmand.plus.views.layers.geometry.RouteGeometryWay; import net.osmand.plus.views.layers.geometry.RouteGeometryWayContext; +import net.osmand.render.RenderingRuleProperty; +import net.osmand.render.RenderingRuleSearchRequest; +import net.osmand.render.RenderingRulesStorage; import net.osmand.router.TransportRouteResult; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; +import org.apache.commons.logging.Log; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; + public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider { + private static final Log log = PlatformUtil.getLog(RouteLayer.class); + + private static final int DEFAULT_WIDTH_MULTIPLIER = 7; + private OsmandMapTileView view; - + private final RoutingHelper helper; private final TransportRoutingHelper transportHelper; // keep array lists created @@ -78,6 +91,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private RenderingLineAttributes attrs; private RenderingLineAttributes attrsPT; private RenderingLineAttributes attrsW; + private Integer defaultRouteLineColor; + private Float defaultRouteLineWidth; private boolean nightMode; private RouteGeometryWayContext routeWayContext; @@ -256,37 +271,83 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont routeWayContext.updatePaints(nightMode, attrs); publicTransportWayContext.updatePaints(nightMode, attrs, attrsPT, attrsW); } - - updateRouteLineAppearance(); + updateRouteLineAppearance(tileBox, nightMode); } - private void updateRouteLineAppearance() { + private void updateRouteLineAppearance(RotatedTileBox tileBox, boolean night) { OsmandSettings settings = view.getApplication().getSettings(); ApplicationMode appMode = settings.getApplicationMode(); - Integer color = null; - Integer width = null; - if (routeLineDrawInfo != null) { - color = routeLineDrawInfo.getColor(); - width = routeLineDrawInfo.getWidth(); - } - if (color == null) { - color = getRouteLineAttribute(appMode, settings.ROUTE_LINE_COLOR); - } - if (width == null) { - width = getRouteLineAttribute(appMode, settings.ROUTE_LINE_WIDTH); - } - if (color != null) { - attrs.paint.setColor(color); - } - if (width != null) { - attrs.paint.setStrokeWidth(color); - } + + int color = getRouteLineColor(settings, appMode); + attrs.paint.setColor(color); + + float width = getRouteLineWidth(settings, appMode, tileBox); + attrs.paint.setStrokeWidth(width); } - private Integer getRouteLineAttribute(@NonNull ApplicationMode appMode, - @NonNull CommonPreference preference) { - int value = preference.getModeValue(appMode); - return value != 0 ? value : null; + @ColorInt + private int getRouteLineColor(@NonNull OsmandSettings settings, + @NonNull ApplicationMode appMode) { + if (defaultRouteLineColor == null) { + defaultRouteLineColor = attrs.paint.getColor(); + } + + int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); + Integer fromSettings = storedValue != 0 ? storedValue : null; + + Integer color = null; + if (routeLineDrawInfo != null) { + color = routeLineDrawInfo.getColor(); + } + if (color == null) { + color = fromSettings; + } + return color != null ? color : defaultRouteLineColor; + } + + private float getRouteLineWidth(@NonNull OsmandSettings settings, + @NonNull ApplicationMode appMode, + @NonNull RotatedTileBox tileBox) { + if (defaultRouteLineWidth == null) { + defaultRouteLineWidth = attrs.paint.getStrokeWidth(); + } + + String fromSettings = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); + String widthKey = null; + if (routeLineDrawInfo != null) { + widthKey = routeLineDrawInfo.getWidth(); + } + if (widthKey == null) { + widthKey = fromSettings; + } + return widthKey != null ? getWidthByKey(tileBox, widthKey) : defaultRouteLineWidth; + } + + private float getWidthByKey(RotatedTileBox tileBox, String widthKey) { + if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) { + try { + int widthDp = Integer.parseInt(widthKey); + return AndroidUtils.dpToPx(view.getApplication(), widthDp); + } catch (NumberFormatException e) { + log.error(e.getMessage(), e); + } + } else { + RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); + RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); + req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); + RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); + req.setIntFilter(rrs.PROPS.R_MINZOOM, tileBox.getZoom()); + req.setIntFilter(rrs.PROPS.R_MAXZOOM, tileBox.getZoom()); + if (ctWidth != null) { + req.setStringFilter(ctWidth, widthKey); + } + if (req.searchRenderingAttribute("gpx")) { + RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); + rc.setDensityValue((float) tileBox.getMapDensity()); + return rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); + } + } + return DEFAULT_WIDTH_MULTIPLIER * view.getDensity(); } private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) { @@ -320,7 +381,12 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont @Override public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { if (routeLineDrawInfo != null) { + float angle = tileBox.getRotate(); + QuadPoint c = tileBox.getCenterPixelPoint(); + + canvas.rotate(-angle, c.x, c.y); drawRouteLinePreview(canvas, tileBox, settings, routeLineDrawInfo); + canvas.rotate(angle, c.x, c.y); } } From a3d499b8d14479ba3ee7497a88e47b88ae0011f3 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 23 Mar 2021 10:43:16 +0200 Subject: [PATCH 78/96] update default value when map style changed --- .../osmand/plus/views/layers/RouteLayer.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 5049789fe6..9fb0816b7c 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -271,24 +271,25 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont routeWayContext.updatePaints(nightMode, attrs); publicTransportWayContext.updatePaints(nightMode, attrs, attrsPT, attrsW); } - updateRouteLineAppearance(tileBox, nightMode); + updateRouteLineAppearance(tileBox, updatePaints, nightMode); } - private void updateRouteLineAppearance(RotatedTileBox tileBox, boolean night) { + private void updateRouteLineAppearance(RotatedTileBox tileBox, boolean defaultPaintUpdated, boolean night) { OsmandSettings settings = view.getApplication().getSettings(); ApplicationMode appMode = settings.getApplicationMode(); - int color = getRouteLineColor(settings, appMode); + int color = getRouteLineColor(settings, appMode, defaultPaintUpdated); attrs.paint.setColor(color); - float width = getRouteLineWidth(settings, appMode, tileBox); + float width = getRouteLineWidth(settings, appMode, tileBox, defaultPaintUpdated); attrs.paint.setStrokeWidth(width); } @ColorInt private int getRouteLineColor(@NonNull OsmandSettings settings, - @NonNull ApplicationMode appMode) { - if (defaultRouteLineColor == null) { + @NonNull ApplicationMode appMode, + boolean defaultPaintUpdated) { + if (defaultPaintUpdated || defaultRouteLineColor == null) { defaultRouteLineColor = attrs.paint.getColor(); } @@ -307,8 +308,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private float getRouteLineWidth(@NonNull OsmandSettings settings, @NonNull ApplicationMode appMode, - @NonNull RotatedTileBox tileBox) { - if (defaultRouteLineWidth == null) { + @NonNull RotatedTileBox tileBox, + boolean defaultPaintUpdated) { + if (defaultPaintUpdated || defaultRouteLineWidth == null) { defaultRouteLineWidth = attrs.paint.getStrokeWidth(); } From 1b0b76d5b2868f7544f237b525408c512ce57686 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 23 Mar 2021 11:13:22 +0200 Subject: [PATCH 79/96] Small fix --- OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java | 3 --- .../net/osmand/plus/views/AddGpxPointBottomSheetHelper.java | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 45a30465f0..bb738a8e00 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -1250,9 +1250,6 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card if (mapActivity != null) { FragmentManager fragmentManager = mapActivity.getSupportFragmentManager(); fragmentManager.beginTransaction().show(this).commit(); - if (pointsCard != null && menuType == TrackMenuType.POINTS) { - pointsCard.updateGroups(); - } } } catch (Exception e) { log.error(e); diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index f525c60fbd..d5da3f9c6d 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -147,6 +147,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { private void onClose() { TrackMenuFragment fragment = mapActivity.getTrackMenuFragment(); if (fragment != null) { + fragment.updateContent(); fragment.show(); } else { TrackMenuFragment.openTrack(mapActivity, new File(newGpxPoint.getGpx().path), null); From fef3af8e5f9ddcc304fccd5b3212de52ddaadce0 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 23 Mar 2021 11:28:47 +0200 Subject: [PATCH 80/96] Fix current track --- .../mapcontextmenu/editors/WptPtEditorFragmentNew.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index 11eaa90bbd..827151a691 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -27,9 +27,9 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.PointImageDrawable; +import net.osmand.plus.itinerary.ItineraryGroup; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; -import net.osmand.plus.itinerary.ItineraryGroup; import net.osmand.plus.track.SaveGpxAsyncTask; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; @@ -490,7 +490,12 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { if (selectedGpxHelper == null || editor == null || editor.getGpxFile() == null) { return true; } - SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(editor.getGpxFile().path); + SelectedGpxFile selectedGpxFile; + if (editor.getGpxFile().showCurrentTrack) { + selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + } else { + selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(editor.getGpxFile().path); + } if (selectedGpxFile != null) { Set hiddenGroups = selectedGpxFile.getHiddenGroups(); return !hiddenGroups.contains(name); From 1da3c93e5c98a1c9823343824800d293df6541cf Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 23 Mar 2021 16:25:09 +0200 Subject: [PATCH 81/96] Fix logic --- .../plus/routing/RouteLineDrawInfo.java | 34 +++++++++++++------ .../routing/cards/RouteLineColorCard.java | 5 +-- .../fragments/ProfileAppearanceFragment.java | 8 ++--- .../RouteLineAppearanceFragment.java | 6 +--- .../osmand/plus/views/layers/RouteLayer.java | 33 +++++++++++------- 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java index d4660bffc9..627be2d9e8 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java @@ -17,6 +17,7 @@ public class RouteLineDrawInfo { private static final String CENTER_X = "center_x"; private static final String CENTER_Y = "center_y"; private static final String SCREEN_HEIGHT = "screen_height"; + private static final String APP_MODE_KEY = "app_mode_key"; // parameters to save @ColorInt @@ -30,6 +31,7 @@ public class RouteLineDrawInfo { private int centerX; private int centerY; private int screenHeight; + private String appModeKey; public RouteLineDrawInfo(@Nullable @ColorInt Integer color, @Nullable String width) { @@ -49,16 +51,7 @@ public class RouteLineDrawInfo { this.centerX = existed.centerX; this.centerY = existed.centerY; this.screenHeight = existed.screenHeight; - } - - @Nullable - public Integer getColor() { - return color; - } - - @Nullable - public String getWidth() { - return width; + this.appModeKey = existed.appModeKey; } public void setColor(@Nullable Integer color) { @@ -89,6 +82,20 @@ public class RouteLineDrawInfo { this.screenHeight = screenHeight; } + public void setAppModeKey(@Nullable String appModeKey) { + this.appModeKey = appModeKey; + } + + @Nullable + public Integer getColor() { + return color; + } + + @Nullable + public String getWidth() { + return width; + } + public int getIconId() { return iconId; } @@ -110,6 +117,11 @@ public class RouteLineDrawInfo { return screenHeight; } + @Nullable + public String getAppModeKey() { + return appModeKey; + } + private void readBundle(@NonNull Bundle bundle) { color = bundle.getInt(LINE_COLOR); width = bundle.getString(LINE_WIDTH); @@ -118,6 +130,7 @@ public class RouteLineDrawInfo { centerX = bundle.getInt(CENTER_X); centerY = bundle.getInt(CENTER_Y); screenHeight = bundle.getInt(SCREEN_HEIGHT); + appModeKey = bundle.getString(APP_MODE_KEY); } public void saveToBundle(@NonNull Bundle bundle) { @@ -132,6 +145,7 @@ public class RouteLineDrawInfo { bundle.putInt(CENTER_X, (int) centerX); bundle.putInt(CENTER_Y, (int) centerY); bundle.putInt(SCREEN_HEIGHT, screenHeight); + bundle.putString(APP_MODE_KEY, appModeKey); } @Override diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java index e94ca1d00a..dc33b3d113 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java @@ -47,7 +47,6 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP private static final int NIGHT_TITLE_ID = R.string.night; private final Fragment targetFragment; - private ApplicationMode appMode; private ColorsCard colorsCard; private ColorTypeAdapter colorAdapter; @@ -78,13 +77,11 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP public RouteLineColorCard(@NonNull MapActivity mapActivity, @NonNull Fragment targetFragment, @NonNull RouteLineDrawInfo routeLineDrawInfo, - @NonNull ApplicationMode appMode, @NonNull DayNightMode initMapTheme, @NonNull DayNightMode selectedMapTheme) { super(mapActivity); this.targetFragment = targetFragment; this.routeLineDrawInfo = routeLineDrawInfo; - this.appMode = appMode; this.initMapTheme = initMapTheme; this.selectedMapTheme = selectedMapTheme; } @@ -179,7 +176,7 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP selectedColor = colors.get(0); } ListStringPreference preference = app.getSettings().CUSTOM_ROUTE_LINE_COLORS; - colorsCard = new ColorsCard(mapActivity, selectedColor, targetFragment, colors, preference, appMode); + colorsCard = new ColorsCard(mapActivity, selectedColor, targetFragment, colors, preference, null); colorsCard.setListener(this); container.addView(colorsCard.build(mapActivity)); } diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index bcb0a120eb..7635a7f046 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -730,7 +730,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O private void updateRouteLinePreference() { Preference preference = findPreference(CUSTOMIZE_ROUTE_LINE); if (preference != null) { - boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT); + boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile; boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile); preference.setVisible(!isDefaultProfile && !isPublicTransport); preference.setIcon(getIcon(R.drawable.ic_action_route_distance, getActiveColorRes())); @@ -995,12 +995,12 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O String prefId = preference.getKey(); if (CUSTOMIZE_ROUTE_LINE.equals(prefId)) { MapActivity mapActivity = getMapActivity(); - ApplicationMode appMode = getSelectedAppMode(); - if (mapActivity != null && appMode != null) { + if (mapActivity != null) { RouteLineDrawInfo drawInfo = changedProfile.routeLineDrawInfo; drawInfo.setIconId(changedProfile.navigationIcon.getIconId()); drawInfo.setIconColor(changedProfile.getActualColor()); - RouteLineAppearanceFragment.showInstance(mapActivity, drawInfo, appMode, this); + drawInfo.setAppModeKey(profile.stringKey); + RouteLineAppearanceFragment.showInstance(mapActivity, drawInfo, this); } } return super.onPreferenceClick(preference); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java index 0baf7bed3d..44765dfc05 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -43,8 +43,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple private static final String INIT_MAP_THEME = "init_map_theme"; private static final String SELECTED_MAP_THEME = "selected_map_theme"; - private ApplicationMode appMode; - private RouteLineDrawInfo routeLineDrawInfo; private int toolbarHeightPx; @@ -164,7 +162,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple MapActivity mapActivity = requireMapActivity(); ViewGroup cardsContainer = getCardsContainer(); - colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, appMode, initMapTheme, selectedMapTheme); + colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme); cardsContainer.addView(colorCard.build(mapActivity)); widthCard = new RouteLineWidthCard(mapActivity, routeLineDrawInfo, createScrollListener()); @@ -392,14 +390,12 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull RouteLineDrawInfo drawInfo, - @NonNull ApplicationMode appMode, @NonNull Fragment target) { try { RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment(); fragment.setRetainInstance(true); fragment.setTargetFragment(target, 0); fragment.routeLineDrawInfo = new RouteLineDrawInfo(drawInfo); - fragment.appMode = appMode; mapActivity.getSupportFragmentManager() .beginTransaction() diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 9fb0816b7c..2d38319c39 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -276,7 +276,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private void updateRouteLineAppearance(RotatedTileBox tileBox, boolean defaultPaintUpdated, boolean night) { OsmandSettings settings = view.getApplication().getSettings(); - ApplicationMode appMode = settings.getApplicationMode(); + ApplicationMode appMode = getApplicationMode(); int color = getRouteLineColor(settings, appMode, defaultPaintUpdated); attrs.paint.setColor(color); @@ -293,15 +293,12 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont defaultRouteLineColor = attrs.paint.getColor(); } - int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); - Integer fromSettings = storedValue != 0 ? storedValue : null; - - Integer color = null; + Integer color; if (routeLineDrawInfo != null) { color = routeLineDrawInfo.getColor(); - } - if (color == null) { - color = fromSettings; + } else { + int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); + color = storedValue != 0 ? storedValue : null; } return color != null ? color : defaultRouteLineColor; } @@ -314,13 +311,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont defaultRouteLineWidth = attrs.paint.getStrokeWidth(); } - String fromSettings = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); - String widthKey = null; + String widthKey; if (routeLineDrawInfo != null) { widthKey = routeLineDrawInfo.getWidth(); - } - if (widthKey == null) { - widthKey = fromSettings; + } else { + widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); } return widthKey != null ? getWidthByKey(tileBox, widthKey) : defaultRouteLineWidth; } @@ -352,6 +347,18 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont return DEFAULT_WIDTH_MULTIPLIER * view.getDensity(); } + @NonNull + private ApplicationMode getApplicationMode() { + ApplicationMode appMode = null; + if (routeLineDrawInfo != null) { + String modeKey = routeLineDrawInfo.getAppModeKey(); + if (modeKey != null) { + appMode = ApplicationMode.valueOfStringKey(modeKey, null); + } + } + return appMode != null ? appMode : helper.getAppMode(); + } + private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) { QuadRect latLonBounds = tileBox.getLatLonBounds(); List xAxisPoints = trackChartPoints.getXAxisPoints(); From de93f862a7270382e5c6678aef09bb4b3c44ffe4 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Tue, 23 Mar 2021 21:15:35 +0200 Subject: [PATCH 82/96] Change logic of preparation route line appearance on the map --- .../net/osmand/plus/views/OsmandMapLayer.java | 10 +- .../osmand/plus/views/layers/RouteLayer.java | 176 +++++++++--------- .../layers/geometry/GeometryWayDrawer.java | 1 + .../layers/geometry/GeometryWayStyle.java | 11 ++ .../layers/geometry/RouteGeometryWay.java | 21 ++- 5 files changed, 123 insertions(+), 96 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java index 67e046c1de..f79489b52d 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapLayer.java @@ -377,6 +377,7 @@ public abstract class OsmandMapLayer { public Paint paint; public Paint customColorPaint; public int customColor = 0; + public float customWidth = 0; public int defaultWidth = 0; public int defaultColor = 0; public boolean isPaint2; @@ -481,8 +482,13 @@ public abstract class OsmandMapLayer { if (isShadowPaint) { canvas.drawPath(path, shadowPaint); } - if (customColor != 0) { - customColorPaint.setColor(customColor); + if (customColor != 0 || customWidth != 0) { + if (customColor != 0) { + customColorPaint.setColor(customColor); + } + if (customWidth != 0) { + customColorPaint.setStrokeWidth(customWidth); + } canvas.drawPath(path, customColorPaint); } else { canvas.drawPath(path, paint); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index 2d38319c39..b6fae1830b 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -59,8 +59,10 @@ import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import static net.osmand.plus.dialogs.ConfigureMapMenu.CURRENT_TRACK_WIDTH_ATTR; @@ -83,6 +85,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private Paint paintIconAction; private Paint paintGridOuterCircle; private Paint paintGridCircle; + private Paint paintRouteLinePreview; private LayerDrawable selectedPoint; private TrackChartPoints trackChartPoints; @@ -91,8 +94,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private RenderingLineAttributes attrs; private RenderingLineAttributes attrsPT; private RenderingLineAttributes attrsW; - private Integer defaultRouteLineColor; - private Float defaultRouteLineWidth; + private Map cachedRouteLineWidth = new HashMap<>(); private boolean nightMode; private RouteGeometryWayContext routeWayContext; @@ -171,6 +173,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont paintGridOuterCircle.setAntiAlias(true); paintGridOuterCircle.setColor(Color.WHITE); paintGridOuterCircle.setAlpha(204); + + paintRouteLinePreview = new Paint(); } @Override @@ -271,92 +275,6 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont routeWayContext.updatePaints(nightMode, attrs); publicTransportWayContext.updatePaints(nightMode, attrs, attrsPT, attrsW); } - updateRouteLineAppearance(tileBox, updatePaints, nightMode); - } - - private void updateRouteLineAppearance(RotatedTileBox tileBox, boolean defaultPaintUpdated, boolean night) { - OsmandSettings settings = view.getApplication().getSettings(); - ApplicationMode appMode = getApplicationMode(); - - int color = getRouteLineColor(settings, appMode, defaultPaintUpdated); - attrs.paint.setColor(color); - - float width = getRouteLineWidth(settings, appMode, tileBox, defaultPaintUpdated); - attrs.paint.setStrokeWidth(width); - } - - @ColorInt - private int getRouteLineColor(@NonNull OsmandSettings settings, - @NonNull ApplicationMode appMode, - boolean defaultPaintUpdated) { - if (defaultPaintUpdated || defaultRouteLineColor == null) { - defaultRouteLineColor = attrs.paint.getColor(); - } - - Integer color; - if (routeLineDrawInfo != null) { - color = routeLineDrawInfo.getColor(); - } else { - int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); - color = storedValue != 0 ? storedValue : null; - } - return color != null ? color : defaultRouteLineColor; - } - - private float getRouteLineWidth(@NonNull OsmandSettings settings, - @NonNull ApplicationMode appMode, - @NonNull RotatedTileBox tileBox, - boolean defaultPaintUpdated) { - if (defaultPaintUpdated || defaultRouteLineWidth == null) { - defaultRouteLineWidth = attrs.paint.getStrokeWidth(); - } - - String widthKey; - if (routeLineDrawInfo != null) { - widthKey = routeLineDrawInfo.getWidth(); - } else { - widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); - } - return widthKey != null ? getWidthByKey(tileBox, widthKey) : defaultRouteLineWidth; - } - - private float getWidthByKey(RotatedTileBox tileBox, String widthKey) { - if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) { - try { - int widthDp = Integer.parseInt(widthKey); - return AndroidUtils.dpToPx(view.getApplication(), widthDp); - } catch (NumberFormatException e) { - log.error(e.getMessage(), e); - } - } else { - RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); - RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); - req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); - RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); - req.setIntFilter(rrs.PROPS.R_MINZOOM, tileBox.getZoom()); - req.setIntFilter(rrs.PROPS.R_MAXZOOM, tileBox.getZoom()); - if (ctWidth != null) { - req.setStringFilter(ctWidth, widthKey); - } - if (req.searchRenderingAttribute("gpx")) { - RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); - rc.setDensityValue((float) tileBox.getMapDensity()); - return rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); - } - } - return DEFAULT_WIDTH_MULTIPLIER * view.getDensity(); - } - - @NonNull - private ApplicationMode getApplicationMode() { - ApplicationMode appMode = null; - if (routeLineDrawInfo != null) { - String modeKey = routeLineDrawInfo.getAppModeKey(); - if (modeKey != null) { - appMode = ApplicationMode.valueOfStringKey(modeKey, null); - } - } - return appMode != null ? appMode : helper.getAppMode(); } private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) { @@ -405,13 +323,15 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont RouteLineDrawInfo drawInfo) { MapActivity mapActivity = getMapActivity(); updateAttrs(settings, tileBox); + paintRouteLinePreview.setColor(getRouteLineColor(nightMode)); + paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox)); int x = drawInfo.getCenterX(); int y = drawInfo.getCenterY(); int screenHeight = drawInfo.getScreenHeight(); // draw line - canvas.drawLine(x, 0, x, screenHeight, attrs.paint); + canvas.drawLine(x, 0, x, screenHeight, paintRouteLinePreview); // draw image LayerDrawable navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(mapActivity, drawInfo.getIconId()); @@ -501,8 +421,81 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont @ColorInt public int getRouteLineColor(boolean night) { - updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox()); - return attrs.paint.getColor(); + OsmandSettings settings = view.getSettings(); + ApplicationMode appMode = getApplicationMode(); + + Integer color; + if (routeLineDrawInfo != null) { + color = routeLineDrawInfo.getColor(); + } else { + int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); + color = storedValue != 0 ? storedValue : null; + } + + if (color == null) { + updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox()); + color = attrs.paint.getColor(); + } + return color; + } + + private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) { + OsmandSettings settings = view.getSettings(); + ApplicationMode appMode = getApplicationMode(); + + String widthKey; + if (routeLineDrawInfo != null) { + widthKey = routeLineDrawInfo.getWidth(); + } else { + widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); + } + return widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth(); + } + + @Nullable + private Float getWidthByKey(RotatedTileBox tileBox, String widthKey) { + Float resultValue = cachedRouteLineWidth.get(widthKey); + if (resultValue != null) { + return resultValue; + } + if (!Algorithms.isEmpty(widthKey) && Algorithms.isInt(widthKey)) { + try { + int widthDp = Integer.parseInt(widthKey); + resultValue = (float) AndroidUtils.dpToPx(view.getApplication(), widthDp); + } catch (NumberFormatException e) { + log.error(e.getMessage(), e); + resultValue = DEFAULT_WIDTH_MULTIPLIER * view.getDensity(); + } + } else { + RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); + RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); + req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); + RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); + req.setIntFilter(rrs.PROPS.R_MINZOOM, tileBox.getZoom()); + req.setIntFilter(rrs.PROPS.R_MAXZOOM, tileBox.getZoom()); + if (ctWidth != null) { + req.setStringFilter(ctWidth, widthKey); + } + if (req.searchRenderingAttribute("gpx")) { + RenderingContext rc = new OsmandRenderer.RenderingContext(view.getContext()); + rc.setDensityValue((float) tileBox.getMapDensity()); + resultValue = rc.getComplexValue(req, req.ALL.R_STROKE_WIDTH); + } + } + cachedRouteLineWidth.put(widthKey, resultValue); + return resultValue; + } + + @NonNull + private ApplicationMode getApplicationMode() { + ApplicationMode appMode = null; + if (routeLineDrawInfo != null) { + String modeKey = routeLineDrawInfo.getAppModeKey(); + if (modeKey != null) { + appMode = ApplicationMode.valueOfStringKey(modeKey, null); + } + } + return appMode != null ? appMode : helper.getAppMode(); } public void drawLocations(RotatedTileBox tb, Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) { @@ -526,6 +519,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont boolean straight = route.getRouteService() == RouteService.STRAIGHT; publicTransportRouteGeometry.clearRoute(); routeGeometry.updateRoute(tb, route); + routeGeometry.setRouteStyleParams(getRouteLineColor(nightMode), getRouteLineWidth(tb)); if (directTo) { routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, null, 0); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayDrawer.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayDrawer.java index 0bfa86f43b..494375d404 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayDrawer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayDrawer.java @@ -95,6 +95,7 @@ public class GeometryWayDrawer { public void drawPath(Canvas canvas, Path path, GeometryWayStyle style) { context.getAttrs().customColor = style.getColor(); + context.getAttrs().customWidth = style.getWidth(); context.getAttrs().drawPath(canvas, path); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java index 27e37132db..d5a38ccd5d 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/GeometryWayStyle.java @@ -7,6 +7,7 @@ public abstract class GeometryWayStyle { private T context; protected Integer color; + protected Float width; public GeometryWayStyle(T context) { this.context = context; @@ -17,6 +18,12 @@ public abstract class GeometryWayStyle { this.color = color; } + public GeometryWayStyle(T context, Integer color, Float width) { + this.context = context; + this.color = color; + this.width = width; + } + public T getContext() { return context; } @@ -29,6 +36,10 @@ public abstract class GeometryWayStyle { return color; } + public Float getWidth() { + return width; + } + public Integer getStrokeColor() { return context.getStrokeColor(color); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java index 610ea41454..ac81e021d5 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java @@ -1,7 +1,9 @@ package net.osmand.plus.views.layers.geometry; import android.graphics.Bitmap; +import android.graphics.Paint; +import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import net.osmand.Location; @@ -16,16 +18,29 @@ public class RouteGeometryWay extends GeometryWay(context)); this.helper = context.getApp().getRoutingHelper(); } + public void setRouteStyleParams(@ColorInt int color, + float width) { + this.customColor = color; + this.customWidth = width; + } + @NonNull @Override public GeometryWayStyle getDefaultWayStyle() { - return new GeometrySolidWayStyle(getContext(), getContext().getAttrs().paint.getColor()); + Paint paint = getContext().getAttrs().paint; + int paintColor = paint.getColor(); + int color = customColor != null ? customColor : paintColor; + float paintWidth = paint.getStrokeWidth(); + float width = customWidth != null ? customWidth : paintWidth; + return new GeometrySolidWayStyle(getContext(), color, width); } public void updateRoute(RotatedTileBox tb, RouteCalculationResult route) { @@ -50,8 +65,8 @@ public class RouteGeometryWay extends GeometryWay { - GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color) { - super(context, color); + GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width) { + super(context, color, width); } @Override From 509bf2b8b21d69d00c3158b4ebf4ee8e9f805338 Mon Sep 17 00:00:00 2001 From: Shjosan Date: Tue, 23 Mar 2021 14:21:56 +0000 Subject: [PATCH 83/96] Translated using Weblate (Swedish) Currently translated at 68.9% (2542 of 3688 strings) --- OsmAnd/res/values-sv/strings.xml | 210 +++++++++++++++++++++---------- 1 file changed, 142 insertions(+), 68 deletions(-) diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index 0dd3173583..c84d961139 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -84,7 +84,8 @@ Välj animerad ruttacceleration Allokerat minne %1$s MB (Android-gräns %2$s MB, Dalvik %3$s MB). Allokerat minne - Totalt inbyggt minne allokerat av appen %1$s MB (Dalvik %2$s MB, övrigt %3$s MB). Proportionellt minne %4$s MB (Android-gräns %5$s MB, Dalvik %6$s MB). + Totalt inbyggt minne allokerat av appen %1$s MB (Dalvik %2$s MB, övrigt %3$s MB). +\nProportionellt minne %4$s MB (Android-gräns %5$s MB, Dalvik %6$s MB). Totalt inbyggt minne Startpunkten ligger för långt från närmaste väg. Delad plats @@ -165,9 +166,8 @@ em fm Parkeringsplats - Modulen Parkeringsplats hjälper dig att hålla reda på var din bil är parkerad och vid behov hur mycket parkeringstid det är kvar. - -Du hittar din parkeringsplats och -tid på instrumentbrädan och i widgeten på kartskärmen. Du kan lägga till ett larm i kalendern som en påminnelse. + Låter dig spara var din bil är parkerad, inklusive hur mycket parkeringstid som finns kvar. +\nBåde plats och tid är synliga både på instrumentpanelen och i en kartwidget. En larmpåminnelse kan läggas till i Android-kalendern. Parkeringsplats Markera som parkeringsplats Ta bort P-markering @@ -192,11 +192,11 @@ Du hittar din parkeringsplats och -tid på instrumentbrädan och i widgeten på Online-kartor och kartrutor Använd online-kartor (hämta och cacha kartbitar på SD-kortet). Konfigurera online- eller cachade källor för kartbitar. - "Med denna modul får man tillgång till många typer av online-kartor, från fördefinierade Openstreetmap-rutor (som Mapnik) till satellitbilder och speciella lager såsom väderkartor, klimatkartor, geologiska kartor, reliefkartor o.s.v. + Med denna modul får man tillgång till många typer av online-kartor, från fördefinierade Openstreetmap-rutor (som Mapnik) till satellitbilder och speciella lager såsom väderkartor, klimatkartor, geologiska kartor, reliefkartor o.s.v. \n -\nDessa kartor kan användas antingen som huvudkarta (baskarta) och visas på kartskärmen i OsmAnd eller som ett över- eller underlägg till en annan baskarta (som OsmAnds vanliga offline-kartor). För att göra en underliggande karta tydligare kan vissa element i OsmAnds vektorkartor lätt döljas via menyn \'Konfigurera karta\'. +\nDessa kartor kan användas antingen som huvudkarta (baskarta) och visas på kartskärmen i OsmAnd eller som ett över- eller underlägg till en annan baskarta (som OsmAnds vanliga offline-kartor). För att göra en underliggande karta tydligare kan vissa element i OsmAnds vektorkartor lätt döljas via menyn \'Konfigurera karta\'. \n -\nKartbitar (tile maps) kan hämtas direkt på nätet eller förberedas för användning frånkopplad (och kopieras manuellt till OsmAnds datamapp) som en SQLite-databas som kan skapas med olika tredjepartsverktyg. " +\nKartbitar (tile maps) kan hämtas direkt på nätet eller förberedas för användning frånkopplad (och kopieras manuellt till OsmAnds datamapp) som en SQLite-databas som kan skapas med olika tredjepartsverktyg. Visa inställningarna för att aktivera spårning och navigering i bakgrundsläge (skärm av) genom att periodvis väcka GPS-enheten. Denna modul visar inställningarna för utvecklings- och felsökningsfunktioner som rutt-testning och -simulering eller visning av renderingsprestanda eller röststyrning. Dessa inställningar är avsedda för utvecklare och behövs inte för den vanliga användaren. Hantera insticksmoduler @@ -208,19 +208,33 @@ Du hittar din parkeringsplats och -tid på instrumentbrädan och i widgeten på Din parkerade bils plats. %1$s Insticksmoduler aktiverar avancerade inställningar samt ger ytterligare funktionalitet. Insticksmoduler - "Med denna modul kan OsmAnd användas för att göra bidrag till OSM såsom skapa eller modifiera OSM POI-objekt, öppna eller kommentera OSM-anteckningar, och bidra med inspelade GPX-filer. OSM är ett globalt kartprojekt inom public domain, För mer info, se https://openstreetmap.org. Aktivt deltagande uppskattas och bidrag kan göras direkt från OsmAnd om du anger dina autentiseringsuppgifter till OSM i appen." + Ge OSM-bidrag som att skapa eller modifiera OSM POI-objekt, öppna eller kommentera OSM-anteckningar och bidra med inspelade GPX-filer i OsmAnd genom att ange ditt användarnamn och lösenord. OpenStreetMap.org är ett community-driven, globalt kartläggningsprojekt för allmän domän. Vektorkartor ritas sannolikt upp snabbare. Fungerar kanske inte så bra på vissa enheter. Spela upp kommandon med vald röst Test av röstmeddelanden Det finns ingen offline vektorkarta för den här platsen. Du kan hämta en i Inställningar (Hantera kartfiler) eller byta till online-kartor (aktivera modulen för online-kartor för detta). - "OsmAnd (Open Street Maps Automated Navigation Directions) -\n -\nOsmAnd är ett öppen källkodsprogram med tillgång till ett brett utbud av global OpenStreetMap-data. Alla kartdata (vektor- eller rasterkartor) kan lagras i telefonens minneskort för offlineanvändning. OsmAnd erbjuder även navigering offline och online, inklusive röstguidning. Några av de viktigaste funktionerna: - Komplett offline-funktionalitet (lagra nedladdade vektorkartor eller kartbitar på enheten) - Kompakta offline-vektorkartor för hela världen finns tillgängliga - Nedladdning av land- eller regionkartor direkt från appen - Överlägg av flera kartlager möjligt, som GPX- eller navigationsspår, sevärdheter, favoriter, höjddata, offentliga hållplatser, extra kartor med anpassningsbara transparens - Sökning offline efter adresser och platser (POIs) - Offline-dirigering för medellånga sträckor (experimentell) - Bil-, cykel- och fotgängarlägen med: - Tillval automatisk växling mellan dag- och nattvisning - Tillval hastighetsberoende zoomning - Valfri inställningen enligt kompass eller färdriktningen - Frivillig körfältsvägledning, visning av hastighetsgräns, inspelade röster samt TTS-röster -\n -\nBegränsningar i denna gratisversion av OsmAnd: - Antalet hämtningar av kartor är begränsat - Ingen tillgång till Wikipedia offline POIs -\n -\nOsmAnd utvecklas aktivt och vårt projekt och dess fortsatta framsteg bygger på ekonomiska bidrag för att finansiera utveckling och testning av ny funktionalitet. Vänligen överväg att köpa OsmAnd+, finansiera specifika nya funktioner eller göra en allmän donation på osmand.net. -\n " + OsmAnd (OSM Automated Navigation Directions) +\n +\nOsmAnd är en programvara för öppen källkodsnavigering med tillgång till ett stort antal globala OSM-data. Alla kartdata (vektor- eller brickor) kan lagras på telefonens minneskort för offline-användning. Offline- och online-dirigeringsfunktioner erbjuds också, inklusive röstvägledning för sväng. +\n +\nNågra av kärnfunktionerna: +\n- Komplett offline-funktionalitet (lagra nedladdad vektor eller kakelkartor i enhetens lagring) +\n- Kompakta offlinevektorkartor för hela världen +\n- Ladda ner land- eller regionkartor direkt från appen +\n- Överlagring av flera kartlager möjliga, som GPX eller navigationsspår, intressanta platser, favoriter, konturlinjer, kollektivtrafikstopp, ytterligare kartor med anpassningsbar transparens +\n- Offline sökning efter adresser och platser (POI) +\n- Offline-dirigering för medelstora avstånd +\n- Lägen för bil, cykel och fotgängare med tillval: +\n- Automatisk växling mellan dag och natt +\n- Hastighetsberoende kartzoomning +\n- Kartinriktning enligt kompass eller rörelseriktning +\n- Fältvägledning, hastighetsgränsvisning, inspelade och text-till-tal-röster +\n +\nBegränsningar av denna gratisversion av OsmAnd: +\n- Antalet nedladdningar av kartor begränsat +\n- Ingen offlineåtkomst till Wikipedia-intressepunkter +\n +\nOsmAnd utvecklas aktivt och vårt projekt och dess fortsatta framsteg är beroende av ekonomiska bidrag för utveckling och testning av ny funktionalitet. Överväg att köpa OsmAnd +, eller finansiera specifika nya funktioner eller göra en allmän donation på https://osmand.net. Inbyggd rendering Support Ge stöd till nya funktioner @@ -297,9 +311,8 @@ Du hittar din parkeringsplats och -tid på instrumentbrädan och i widgeten på Bakgrundsläge OsmAnd körs i bakgrunden medan skärmen är avstängd. Det finns inte tillräckligt med ledigt utrymme för att hämta %1$s MB (ledigt: %2$s). - Hämta {0} fil(er)? -Nyttjat utrymme är {1} MB. -(Tillgängligt utrymme är {2} MB.) + Hämta {0} fil(er)\? +\n{1} MB (av {2} MB) kommer att användas. Genomskinligt tema Inbyggt bibliotek stöds inte på den här enheten. Initierar inbyggt bibliotek … @@ -382,7 +395,7 @@ Nyttjat utrymme är {1} MB. Packar upp nya data … En online-navigeringstjänst är vald men ingen internetanslutning är tillgänglig. Språket stöds inte - Det valda språket stöds inte av den installerade Android TTS (text-till-tal)-motorn. Vill du söka efter en annan TTS-motor på Market? Annars kommer det förinställda TTS-språket att användas. + Det valda språket stöds inte av Android TTS (text-till-tal) -motorn installerad, dess förinställda TTS-språk används istället. Leta efter en annan TTS-motor i butiken\? Data saknas Inga data för det valda språket är installerade. Vill du besöka Google Play för att installera? Omvänd GPX-riktning @@ -701,7 +714,7 @@ Nyttjat utrymme är {1} MB. Sök efter fler byar/postnummer Välj när du vill visa kartor som endast har vägar: Kartor med enbart vägar - "Vägar " + Bara vägar Standardkartor Karta med enbart vägar Kör appen i felsäkert läge (för långsammare Android istället för intern kod). @@ -783,9 +796,9 @@ Nyttjat utrymme är {1} MB. Inställningar för ljud och video Ett fel uppstod under inspelningen Ingen kamera tillgänglig - "Denna modul erbjuder överlägg med höjdkurvor som kan visas i kombination med OsmAnds standardkartor. Denna funktion kommer att uppskattas av idrottsmän, vandrare och alla som är intresserade av höjdskillnader i landskapet. -\n -\nDessa globala data (mellan 70 grader norr och 70 grader syd) baseras på mätningar av SRTM (Shuttle Radar Topography Mission) och ASTER (Advanced Spaceborne Thermal Emission and Reflection Radiometer), ett bildinstrument ombord Terra, flaggskeppet i NASA:s Earth Observing System. ASTER är ett samprojekt mellan NASA, Japans Ministry of Economy, Trade and Industry (METI), and Japan Space Systems (J-spacesystems). " + Denna modul erbjuder överlägg med höjdkurvor som kan visas i kombination med OsmAnds standardkartor. Denna funktion kommer att uppskattas av idrottsmän, vandrare och alla som är intresserade av höjdskillnader i landskapet. +\n +\nDessa globala data (mellan 70 grader norr och 70 grader syd) baseras på mätningar av SRTM (Shuttle Radar Topography Mission) och ASTER (Advanced Spaceborne Thermal Emission and Reflection Radiometer), ett bildinstrument ombord Terra, flaggskeppet i NASA:s Earth Observing System. ASTER är ett samprojekt mellan NASA, Japans Ministry of Economy, Trade and Industry (METI), and Japan Space Systems (J-spacesystems). Ta bort destination Mellanliggande destination %1$s Online Nominatim @@ -874,11 +887,11 @@ Nyttjat utrymme är {1} MB. Föredra motorvägar. markerad ej markerad - Välj vid användning + På förfrågan\? Aktivera Trippinspelningspluginen för att använda positionsloggningstjänster (GPX-loggning, online-spårning) - "Denna modul erbjuder både ett överlägg med konturlinjer och ett höjdkurvslager som kan visas ovanpå OsmAnds offline-kartor. Denna funktion kommer att uppskattas av idrottsmän, vandrare och alla som är intresserade av höjdskillnader i landskapet. + Denna modul erbjuder både ett överlägg med konturlinjer och ett höjdkurvslager som kan visas ovanpå OsmAnds offline-kartor. Denna funktion kommer att uppskattas av idrottsmän, vandrare och alla som är intresserade av höjdskillnader i landskapet. \n -\nDessa globala data (mellan 70 grader norr och 70 grader syd) är baserade på SRTM (Shuttle Radar Topography Mission) och ASTER (Advanced Spaceborne Thermal Emission and Reflection Radiometer), ett bildinstrument på Terra, NASA:s Earth Observing Systems satellit. ASTER är ett samarbete mellan NASA, Japans finansdepartement, Trade and Industry (METI) och Japan Space Systems (J-spacesystems). " +\nDessa globala data (mellan 70 grader norr och 70 grader syd) är baserade på SRTM (Shuttle Radar Topography Mission) och ASTER (Advanced Spaceborne Thermal Emission and Reflection Radiometer), ett bildinstrument på Terra, NASA:s Earth Observing Systems satellit. ASTER är ett samarbete mellan NASA, Japans finansdepartement, Trade and Industry (METI) och Japan Space Systems (J-spacesystems). Ankomsttid OpenMaps EU Skuggad relief-lager @@ -892,7 +905,7 @@ Nyttjat utrymme är {1} MB. %1$d filer kvar Du har %1$d filer kvar att hämta Fullversion - Avbryt rutten + Avbryt rutten\? Avbryt navigeringen Ta bort destinationen Wi-Fi är för tillfället inte anslutet. Vill du hämta med din nuvarande anslutning till Internet? @@ -1218,9 +1231,9 @@ Nyttjat utrymme är {1} MB. Närbelägna intresssepunkter Rundturer Alla - "Denna modul aktiverar funktionen att antingen spela in och spara dina spår genom att du trycker på widgeten GPX-loggning på kartskärmen eller att alla dina rutter sparas automatiskt i en GPX-fil. + Denna modul aktiverar funktionen att antingen spela in och spara dina spår genom att du trycker på widgeten GPX-loggning på kartskärmen eller att alla dina rutter sparas automatiskt i en GPX-fil. \n -\nInspelade spår kan delas ut till vänner eller användas som bidrag till OSM. Idrottsmän kan använda inspelade spår för att följa sin träning. Viss grundläggande spåranalys kan göras direkt i OsmAnd, såsom varvtider, genomsnittshastighet o.s.v. och spår kan givetvis också analyseras i efterhand i speciella analysverktyg från tredje part. " +\nInspelade spår kan delas ut till vänner eller användas som bidrag till OSM. Idrottsmän kan använda inspelade spår för att följa sin träning. Viss grundläggande spåranalys kan göras direkt i OsmAnd, såsom varvtider, genomsnittshastighet o.s.v. och spår kan givetvis också analyseras i efterhand i speciella analysverktyg från tredje part. Inspelning av resa h Längd @@ -1279,7 +1292,7 @@ Nyttjat utrymme är {1} MB. Alla filer är uppdaterade Använd OpenGL-rendering Använd hårdvaruaccelererad OpenGL-rendering (fungerar kanske inte på vissa enheter). - Kan inte hämta; kontrollera din internetsanslutning. + Kan inte hämta, kontrollera din internetsanslutning. Vägtyp Standard Brandgul @@ -1349,13 +1362,20 @@ Nyttjat utrymme är {1} MB. \nEn kartfil som innehåller alla nautiska symboler globalt finns tillgänglig som en enda nedladdning med namnet \'World seamarks\'. \n \nDenna vy kan ändras genom att antingen inaktivera den här igen eller genom att ändra kartstilen under Konfigurera kartor. - "Om du aktiverar denna vy ändras kartstilen till Vinter och skidor, och visar landskapet i vinterskrud. -\n\nEn global karta med alla pister och längdskidspår i denna vy finns tillgänglig under Alla kartor som \'World ski map\'. -\n\nDenna vy kan ändras genom att antingen inaktivera den här igen eller genom att ändra kartstilen under Konfigurera kartor. " - "Om du aktiverar denna vy ändras kartan till \'Vägkartsvy\', som är en speciell vy med mycket detaljer för resenärer och yrkesförare. -\n\nDenna vy ger, vid varje zoomnivå, maximalt antal detaljer som är tillgängliga i kartdatat (speciellt vägar, stigar och orienteringsmärken).\n\nDen visar också alla vägtyper på ett mycket tydligt sätt via färgkoder något som är användbart t.ex vid framförande av stora fordon. -\n\nOch den erbjuder också speciella alternativ såsom visning av cykelrutter eller rutter i Alperna.\n\nIngen speciell hämtning av någon karta krävs; denna vy skapas med våra standardkartor. -\n\nDenna vy kan ändras genom att antingen inaktivera den här igen eller genom att ändra kartstilen under Konfigurera kartor. " + Detta plugin för OsmAnd ger dig detaljer om globala utförsåkning, längdskidspår, alpina skidvägar, linbanor och skidliftar. Rutter och pister visas färgkodade av svårigheter och avbildas i en speciell \"vinter\" -stil som liknar ett snöfärgat vinterlandskap. +\n +\nOm du aktiverar den här vyn ändras kartstilen till \"Vinter och skidor\" och visar alla landskapsfunktioner under vinterförhållanden. Denna vy kan återställas genom att antingen avaktivera den igen här, eller genom att ändra \'Kartstil\' under \'Konfigurera karta\' efter önskemål. + Om du aktiverar denna vy ändras kartan till \'Vägkartsvy\', som är en speciell vy med mycket detaljer för resenärer och yrkesförare. +\n +\nDenna vy ger, vid varje zoomnivå, maximalt antal detaljer som är tillgängliga i kartdatat (speciellt vägar, stigar och orienteringsmärken). +\n +\nDen visar också alla vägtyper på ett mycket tydligt sätt via färgkoder något som är användbart t.ex vid framförande av stora fordon. +\n +\nOch den erbjuder också speciella alternativ såsom visning av cykelrutter eller rutter i Alperna. +\n +\nIngen speciell hämtning av någon karta krävs; denna vy skapas med våra standardkartor. +\n +\nDenna vy kan ändras genom att antingen inaktivera den här igen eller genom att ändra kartstilen under Konfigurera kartor. Plats:\n Lat %1$s\n Lon %2$s Vägkartsvy dagar efter @@ -1423,7 +1443,7 @@ Nyttjat utrymme är {1} MB. Simulera din plats Platt lista Lat %1$s -Long %2$s +\nLong %2$s Frågor och svar, nyliga förändringar och annat. Navigeringsinställningar Allmänna inställningar @@ -1495,7 +1515,7 @@ Long %2$s Du håller på att ta bort %1$d anteckningar. Är du säker? Wikipedia Importera till OsmAnd - Platstjänsten är inte aktiverad. Vill du slå på den? + Platstjänsten är av. Vill du slå på den\? Du har gamla och inkompatibla data från Wikipedia. Vill du arkivera dem? Hämta ytterligare data från Wikipedia (%1$s MB)? Volapük @@ -1611,7 +1631,7 @@ Long %2$s Meter per sekund Minuter per kilometer Minuter per mile - Sjömil i timmen (knop) + Sjömil per timme (knop) Inspelning av resa Navigering Körs i bakgrunden @@ -1619,7 +1639,7 @@ Long %2$s Välj kategori Antal rader di - nmi/h + M min/mi min/km m/s @@ -1746,7 +1766,7 @@ Long %2$s Avstånd: Tid: Appen har inte tillåtelse att använda SD-kortet - Appen har inte tillräckliga behörigheter för att komma åt platsdata. + Appen saknar behörigheter för att komma åt platsdata. Appen har inte tillräckliga behörigheter för att komma åt kameran. Appen har inte tillräckliga behörigheter för att komma åt mikrofonen. Välj röstvägledning @@ -1807,9 +1827,10 @@ Long %2$s Verktygsfält Widgetar Inte tillräckligt med utrymme! -Detta skulle kräva {3} MB temporärt och {1} MB permanent. -Tillgängligt utrymme är blott {2} MB. - Hämta {0} fil(er)? Nyttjat utrymme är {3} MB temporärt och {1} MB permanent. (Tillgängligt utrymme är {2} MB.) +\n{3} MB temporärt och {1} MB permanent. +\n(Bara {2} MB tillgängligt.) + Hämta {0} fil(er)\? +\n{3} MB används temporärt och {1} MB permanent. (Av{2} MB.) Ladda upp OSM-anteckning Ladda upp anonymt Välj kartmarkör @@ -1879,8 +1900,8 @@ Tillgängligt utrymme är blott {2} MB. Nu har appen tillåtelse att skriva till extern lagringsplats. En manuell omstart av appen krävs. Stödregion Denna prenumeration aktiverar uppdateringar varje timme av kartor runt omkring i världen. -En del av inkomsterna går tillbaka till OSM-gemenskapen och betalas ut för varje OSM-bidrag. -Om du tycker om OsmAnd och OSM och vill stödja dem så är detta ett utmärkt sätt att göra det på. +\nEn del av inkomsterna går tillbaka till OSM-gemenskapen och betalas ut för varje OSM-bidrag. +\nOm du tycker om OsmAnd och OSM och vill stödja och stödjas av dem så är detta ett utmärkt sätt att göra det på. Destinationen är inte fastställd Magnetisk bäring Klipplängd @@ -1936,7 +1957,7 @@ Om du tycker om OsmAnd och OSM och vill stödja dem så är detta ett utmärkt s Ta bort filter Nytt filter Ange ett namn på det nya filtret. Det kommer att läggas till på fliken ’Kategorier’. - "Transkribera om %1$s namn saknas" + Transkribera om %1$s namn saknas Hoppa över nerladdning av kartor Välj en annan region Obegränsade nedladdningar av kartor, uppdateringar och Wikipedia-plugin. @@ -1960,7 +1981,7 @@ Om du tycker om OsmAnd och OSM och vill stödja dem så är detta ett utmärkt s Donation till OpenStreetMap-gemenskapen Skaffa det Skaffa för %1$s - "Du har inte några offline-kartor installerade. Du kan välja en karta från listan eller hämta kartor senare via \'Meny - %1$s\'." + Du har inte några offline-kartor installerade. Du kan välja en karta från listan eller hämta kartor senare via \'Meny - %1$s\'. Söker efter kartor … Erhåll vägbeskrivningar och upptäck nya platser utan Internetuppkoppling Sök efter min plats @@ -2047,7 +2068,7 @@ Om du tycker om OsmAnd och OSM och vill stödja dem så är detta ett utmärkt s Ogiltig OLC \n Kort OLC -Vänligen tillhandahåll fullständig kod +\nVänligen tillhandahåll fullständig kod Filen kan inte flyttas. Flytta Spår @@ -2090,7 +2111,7 @@ Vänligen tillhandahåll fullständig kod Åtgärdsnamn Kartöverlägg Lägg till överlägg - "Kartöverlägget har ändrats till \"%s\"." + Kartöverlägget har ändrats till \"%s\". Tryck länge och dra knappen för att ändra dess position på skärmen. Använd höjddata Visa djupkonturer och punkter. @@ -2420,7 +2441,9 @@ Vänligen tillhandahåll fullständig kod Max/Min Min/Max Denna väg kan vara för lång tid att beräkna. Lägg till mellanliggande destinationer om inget resultat finns inom 10 minuter. - "OsmAnd (OSM Automated Navigation Directions) är en kartnavigationsapp med tillgång till gratis, världsomfattande OpenStreetMap (OSM)-data av hög kvalitet. Njut av röstnavigation eller visuell navigation, visning av POI (points of interest - nyttoplatser), att skapa och hantera GPX-spår, visa höjdkurvor och höjdinfo (via plugin), val mellan bil-, cykel-, fotgängar-lägen, OSM-redigering och mycket mer." + OsmAnd (OSM Automated Navigation Directions) är en kartnavigationsapp med tillgång till gratis, världsomfattande OpenStreetMap (OSM)-data av hög kvalitet. +\n +\nNjut av röstnavigation eller visuell navigation, visning av POI (points of interest - nyttoplatser), att skapa och hantera GPX-spår, visa höjdkurvor och höjdinfo (via plugin), val mellan bil-, cykel-, fotgängar-lägen, OSM-redigering och mycket mer. GPS-navigering \n• Välj mellan offline- (inga roaming-avgifter när du är utomlands) eller online-läge a(snabbare) \n• Steg-för-steg röstguidning leder dig längs vägen (inspelade och genererade röster) @@ -2442,8 +2465,14 @@ Vänligen tillhandahåll fullständig kod \n • Låter dig välja hur du vill visa namn på kartan: på svenska, lokala, eller fonetisk stavning \n • Visar specialiserade online-rutor, satellitvy (från Bing), olika överlägg som tour/navigering GPX-spår och ytterligare lager med anpassningsbar transparens \n - Skidåkning OsmAnd skidkartor plugin gör att du kan se skidspår svårighetsgrad och en del kompletterande information, som plats för liftar och andra faciliteter. - Cykling • Du kan hitta cykelstigar på kartan • GPS-navigering i cykelläge skapar din rutt med hjälp av cykelvägar • Du kan se din hastighet och höjd • Med GPX-inspelningsalternativet kan du spela in din resa och dela den • Via ytterligare plugin kan du aktivera visning av höjdkurvor och höjdrelief + Skidåkning +\nOsmAnd skidkartor plugin gör att du kan se skidspår svårighetsgrad och en del kompletterande information, som plats för liftar och andra faciliteter. + Cykling +\n• Hitta cykelvägar på kartan +\n• GPS-navigering i cykelläge bygger din rutt med cykelvägar +\n• Se din hastighet och höjd +\n• Med GPX-inspelningsalternativ kan du spela in din resa och dela den +\n• Via ett extra plugin kan du aktivera konturlinjer och backskuggning Promenader, vandring, stadsrundtur \n • Kartan visar promenad- och vandringsleder \n • Wikipedia på ditt föredragna språk kan berätta en hel del under en stadsrundtur @@ -2458,23 +2487,58 @@ Vänligen tillhandahåll fullständig kod \n Rensa alla mellanliggande punkter Strömsporter - OsmAnd är open-source och är utvecklas aktivt. Alla kan bidra till appen genom att rapportera buggar, förbättra översättningar eller programmera nya funktioner. Projektet är i ett dynamiskt tillstånd av kontinuerlig förbättring av alla dessa former genom utvecklare och interaktion med användare. Projektet är också beroende av ekonomiska bidrag för att finansiera kodning och testning av nya funktioner. Ungefärlig karttäckning och kvalitet: • Västeuropa: **** • Östeuropa: *** • Ryssland: *** • Nordamerika: *** • Sydamerika: ** • Asien: ** • Japan & Korea: *** • Mellanöstern: ** • Afrika: ** • Antarktis: * De flesta länder runt om i världen finns tillgängliga för hämtning! Få en tillförlitlig navigator i ditt land - det kan vara Tyskland, Frankrike, Mexiko, Storbritannien, Spanien, Nederländerna, USA, Ryssland, Brasilien eller något annat. - OsmAnd+ (OSM Automated Navigation Directions) + OsmAnd är aktivt utvecklad programvara med öppen källkod. Alla kan bidra till appen genom att rapportera fel, förbättra översättningar eller koda nya funktioner. Dessutom bygger projektet på ekonomiska bidrag för att finansiera kodning och testning av nya funktioner. +\nUngefärlig karttäckning och kvalitet: +\n• Västeuropa: **** +\n• Östeuropa: *** +\n• Ryssland: *** +\n• Nordamerika: *** +\n• Sydamerika: ** +\n• Asien: ** +\n• Japan och Korea: *** +\n• Mellanöstern: ** +\n• Afrika: ** +\n• Antarktis: * +\nDe flesta länder runt om i världen är tillgängliga för nedladdning! +\nFå en pålitlig navigatör i ditt land - vare sig det är Frankrike, Tyskland, Mexiko, Storbritannien, Spanien, Nederländerna, USA, Ryssland, Brasilien eller något annat. + OsmAnd + (OSM Automated Navigation Directions) \n -\nOsmAnd+ är ett open source-navigationsapp med tillgång till ett brett utbud av global OpenStreetMap(OSM)-data. Alla kartdata (vektor- eller rasterkartor) kan sparas på telefonens minneskort för användning offline. OsmAnd erbjuder även offline och online-ruttunktioner, inklusive turn-by-turn röstguidning. +\nOsmAnd + är en programvara för programvara med öppen källkod för navigering med tillgång till ett stort antal globala OSM-data. Alla kartdata (vektor- eller brickor) kan lagras på telefonens minneskort för offline-användning. Offline- och online-dirigeringsfunktioner erbjuds också, inklusive röstvägledning för sväng. \n -\nOsmAnd+ är den betalversionenen av appeb, genom att köpa det stödjer du projektet, finansierar utveckling av nya funktioner, och får de senaste uppdateringarna. +\nOsmAnd + är den betalda appversionen, genom att köpa den stöder du projektet, finansierar utvecklingen av nya funktioner och får de senaste uppdateringarna. \n -\nNågra av de centrala funktionerna: - Komplett offline-funktionalitet (spara vektor- eller rasterkartor i enhetens lagring) - Kompakta offline vektorkartor för hela världen finns tillgängliga - Obegränsad hämtning av land- eller regionkartor direkt från appen - Offline Wikipedia-artiklar (hämta Wikipedia-POI), utmärkt för sightseeing +\nNågra av kärnfunktionerna: +\n- Komplett offline-funktionalitet (lagra nedladdad vektor eller kakelkartor i enhetens lagring) +\n- Kompakta offlinevektorkartor för hela världen +\n- Obegränsad nedladdning av land- eller regionkartor direkt från appen +\n- Offline Wikipedia-funktion (ladda ner Wikipedia POI), perfekt för sightseeing +\n- Överlagring av flera kartlager möjliga, som GPX eller navigationsspår, intressanta platser, favoriter, konturlinjer, kollektivtrafikstopp, ytterligare kartor med anpassningsbar transparens \n -\n - Överlagring av flera kartskikt är möjligt, som GPX eller navigeringsspår, Punkter av Intresse, favoriter, höjdkurvor, hållplatser för kollektivtrafiken, fler kartor med anpassningsbar genomskinlighet- Offlinesökning efter adresser och intressepunkter (POI) - Offline routing för mediumdistansavstånd - Bil-, cykel- och fotgängarelägen med: - tillval automatiskt byte av dag/nattläge - -\n -\n - Valfri hastighetsbunden kartzoom - valfri kartjustering enligt kompass eller riktning - som tillval körfältsguide, hastighetsgräns visas, inspelade- och TTS-röster +\n- Offline sökning efter adresser och platser (POI) +\n- Offline-dirigering för medelstora avstånd +\n- Lägen för bil, cykel och fotgängare med tillval: +\n- Automatisk växling mellan dag och natt +\n- Hastighetsberoende kartzoomning +\n- Kartinriktning enligt kompass eller rörelseriktning +\n- Fältvägledning, hastighetsgränsvisning, inspelade och text-till-tal-röster +\n Kunde inte hitta något inom: Lägg till alla spårens vägpunkter, eller välj separata kategorier. Totalt - OsmAnd+ (OSM Automated Navigation Directions) är en kartnavigationsapp med tillgång till gratis världsomfattande och högkvalitativa OpenStreetMap (OSM)-data. Njut av röst- och visuell navigation, visning av POI (points of interest - intressepunkter), att skapa och hantera GPX-spår, se höjdkurvor och höjdinfo, välja mellan bil-cykel- och fotgängarlägen, OSM-redigering och mycket mer. OsmAnd+ är en betalversion av appen. Genom att köpa den, stödjer du projektet, finansierar utveckling av nya funktioner, och får de senaste uppdateringarna. Några av de viktigaste funktionerna: - Navigering • Fungerar på nätet (snabb) eller offline (inga roaming-avgifter när du är utomlands) • Sväng-för-sväng-röstguidning (inspelade och syntetiska röster) • Valfri körfältsguide, gatunamn visas, och beräknad ankomsttid • Stödjer mellanliggande punkter på din resplan • Automatisk omdirigering när du avviker från rutten • Sök platser efter adress eller typ (t ex: restaurang, hotell, bensinstation, museum), eller med geografiska koordinater + OsmAnd+ (OSM Automated Navigation Directions) är en kartnavigationsapp med tillgång till gratis världsomfattande och högkvalitativa OSM-data. +\nNjut av röst- och visuell navigation, visning av POI (points of interest - intressepunkter), att skapa och hantera GPX-spår, se höjdkurvor och höjdinfo, välja mellan bil-cykel- och fotgängarlägen, OSM-redigering och mycket mer. +\n +\nOsmAnd+ är en betalversion av appen. Genom att köpa den, stödjer du projektet, finansierar utveckling av nya funktioner, och får de senaste uppdateringarna. +\n +\nNågra av de viktigaste funktionerna: + Navigering +\n• Fungerar online (snabbt) eller offline (inga roamingavgifter när du är utomlands) +\n• Röstvägledning för sväng (inspelade och syntetiserade röster) +\n• Valfri körvägledning, visning av gatunamn och beräknad ankomsttid +\n• Stöder mellanliggande poäng på din resplan +\n• Automatisk omdirigering när du avviker från rutten +\n• Sök efter platser efter adress, efter typ (t.ex. restaurang, hotell, bensinstation, museum) eller efter geografiska koordinater +\n Kartvisning \n • Visa din position och orientering \n • Eventuellt justera bilden i förhållande till kompass eller din riktning @@ -2490,8 +2554,7 @@ Vänligen tillhandahåll fullständig kod Namnet innehåller för många versaler. Vill du fortsätta? Knackning på åtgärdsknappen kommer att lägga till en GPX-punkt vid skärmens mitt. Knackning på åtgärdsknappen kommer att lägga en ljudanteckning vid skärmens mitt. - Att trycka på denna åtgärdsknapp lägger -\ntill en videoanteckning mitt på skärmen. + Att trycka på denna åtgärdsknapp lägger till en videoanteckning mitt på skärmen. Knackning på åtgärdsknappen kommer att lägga till en fotoanteckning vid skärmens mitt. Knackning på åtgärdsknappen kommer att lägga till en OSM-anteckning vid skärmens mitt. Knackning på åtgärdsknappen kommer att lägga till en Intressepunkt vid skärmens mitt. @@ -2600,7 +2663,13 @@ Vänligen tillhandahåll fullständig kod \n• Valfri hastighetsbaserad zoomning \n• Dela din position så att dina vänner kan hitta dig \n - Funktioner för cykel och gående • Se vägar för gående och cyklande samt vandringsstigar, utmärkta för utomhusaktiviteter • Speciella ruttval och visningsläge för cykel och gående • Valfria kollektivtrafiksplatser (buss, spårvagn, tåg) inklusive linjenamn • Valfri reseinspelning till lokal GPX-fil eller onlinetjänst • Valfri visning av hastighet och höjd • Visa konturlinjer och höjdreliefer (via separat plugin) + Funktioner för cykel och gående +\n• Se vägar för gående och cyklande samt vandringsstigar, utmärkta för utomhusaktiviteter +\n• Speciella ruttval och visningsläge för cykel och gående +\n• Valfria kollektivtrafiksplatser (buss, spårvagn, tåg) inklusive linjenamn +\n• Valfri reseinspelning till lokal GPX-fil eller onlinetjänst +\n• Valfri visning av hastighet och höjd +\n• Visa konturlinjer och höjdreliefer (via separat plugin) Bidra direkt till OSM \n• Rapportera databuggar \n• Ladda upp GPX-spår till OSM direkt från appen @@ -3267,4 +3336,9 @@ Vänligen tillhandahåll fullständig kod Spåret innehåller inte höjddata. Spåret innehåller inte hastighetsdata. Välj en annan typ av färgning. + Spara riktning till varje spårningspunkt under inspelning. + Go-cart + Loggningsintervall ställde in den tidsperiod under vilken OsmAnd kommer att be om aktuell positionspositionsdata. + Spara och fortsätt + All osparad data kommer att försvinna. \ No newline at end of file From 6bbed2571f016c2ae1b3ebe842fa0c03bb2bf40c Mon Sep 17 00:00:00 2001 From: Hinagiku Zeppeki Date: Tue, 23 Mar 2021 19:43:29 +0000 Subject: [PATCH 84/96] Translated using Weblate (Japanese) Currently translated at 95.3% (3518 of 3688 strings) --- OsmAnd/res/values-ja/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-ja/strings.xml b/OsmAnd/res/values-ja/strings.xml index 206586cfd1..cc3465ea61 100644 --- a/OsmAnd/res/values-ja/strings.xml +++ b/OsmAnd/res/values-ja/strings.xml @@ -3950,4 +3950,7 @@ POIの更新は利用できません 経路には標高データは含まれていません。 経路には速度データは含まれていません。 別タイプのカラーを選択してください。 + ログ記録間隔は、OsmAndが現在の位置データを要求する期間を設定します。 + 保存して続行 + 保存されていないデータはすべて失われます。 \ No newline at end of file From 0f037d6264bdeed3cb35c27b2b5a669c8721cc06 Mon Sep 17 00:00:00 2001 From: Ldm Public Date: Mon, 22 Mar 2021 22:53:19 +0000 Subject: [PATCH 85/96] Translated using Weblate (French) Currently translated at 100.0% (3688 of 3688 strings) --- OsmAnd/res/values-fr/strings.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index 18cf09a780..702b8f37e1 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1192,11 +1192,11 @@ Fichier GPX vide Traces Favoris - Mes lieux favoris + Lieux favoris \n\nAppui long pour afficher sur la carte Démarrer la navigation pas à pas automatiquement sélectionné(s) - Intervalle de division + Intervalle de fractionnement \n\nAppui long pour afficher les options Sections : %1$s Points de passage : %1$s @@ -4035,4 +4035,7 @@ Appuyer pour afficher ou cacher le widget Coordonnées sur la carte. L’icône de localisation va se déplacer sur le trajet en cours. Veuillez sélectionner un autre type de colorisation. + L\'intervalle d’enregistrement définit la fréquence à laquelle OsmAnd récupérera les données de localisation. + Enregistrer et continuer + Toutes les données non enregistrées seront perdues. \ No newline at end of file From 75affd79172cbdd6d480c8d91ed3753be57e9dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Babos=20G=C3=A1bor?= Date: Tue, 23 Mar 2021 08:22:39 +0000 Subject: [PATCH 86/96] Translated using Weblate (Hungarian) Currently translated at 100.0% (3688 of 3688 strings) --- OsmAnd/res/values-hu/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-hu/strings.xml b/OsmAnd/res/values-hu/strings.xml index 2f81cd1464..f42791d9aa 100644 --- a/OsmAnd/res/values-hu/strings.xml +++ b/OsmAnd/res/values-hu/strings.xml @@ -4039,4 +4039,7 @@ Az alkalmazás hetente ellenőrzi a térképfrissítéseket. Következő ellenőrzés: %1$s (ennyi idő múlva: %2$s). Az alkalmazás naponta ellenőrzi a térképfrissítéseket. Következő ellenőrzés: %1$s (ennyi idő múlva: %2$s). Az alkalmazás óránként ellenőrzi a térképfrissítéseket. Következő ellenőrzés: %1$s (ennyi idő múlva: %2$s). + A naplózási intervallum az az időköz, amelyben az OsmAnd lekéri az aktuális helyadatokat. + Mentés és folytatás + Minden nem mentett adat törlődni fog. \ No newline at end of file From 97735bb598f808e5a1661c885dc64c6778bb865f Mon Sep 17 00:00:00 2001 From: Ihor Hordiichuk Date: Mon, 22 Mar 2021 22:14:03 +0000 Subject: [PATCH 87/96] Translated using Weblate (Ukrainian) Currently translated at 100.0% (3688 of 3688 strings) --- OsmAnd/res/values-uk/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-uk/strings.xml b/OsmAnd/res/values-uk/strings.xml index 054c932cc6..262ec98674 100644 --- a/OsmAnd/res/values-uk/strings.xml +++ b/OsmAnd/res/values-uk/strings.xml @@ -4044,4 +4044,7 @@ Виберіть інший тип забарвлення. Сховати природні заповідники, заповідні території та межі національних парків Межі природи + Інтервал журналювання встановлює проміжок часу, впродовж якого OsmAnd запитуватиме дані про поточне розташування. + Зберегти й продовжити + Усі незбережені дані буде втрачено. \ No newline at end of file From 1310854caaaf7c73895d6327bc4166867fc67067 Mon Sep 17 00:00:00 2001 From: Yaron Shahrabani Date: Mon, 22 Mar 2021 20:41:02 +0000 Subject: [PATCH 88/96] Translated using Weblate (Hebrew) Currently translated at 99.9% (3687 of 3688 strings) --- OsmAnd/res/values-iw/strings.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-iw/strings.xml b/OsmAnd/res/values-iw/strings.xml index c5949f404d..76006696f9 100644 --- a/OsmAnd/res/values-iw/strings.xml +++ b/OsmAnd/res/values-iw/strings.xml @@ -9,7 +9,7 @@ הצגת הכיוון ליעד יש להפעיל את תוסף „מעקב הטיול” כדי להשתמש בשירותי רישום מיקום (מעקב חי, רישום GPX) יש לחשב מסלול בלתי יעיל למרחקים ארוכים - נא להפעיל את רכיב האיכון (GPS) בהגדרות + נא להפעיל את ה־GPS בהגדרות שירותי רישום אין מסלול הסרת יעד @@ -1881,7 +1881,7 @@ מטרים לשנייה דקות לקילומטר דקות למייל - מיל ימי לשעה (קשר) + מייל ימי לשעה (קשר) קשר מ/שנ׳ הקלטת טיול @@ -4047,4 +4047,8 @@ קיים עדכון ל־OpenStreetMap: להסתיר גבולות של שמורות טבע, אזורים מוגנים ופארקים ציבוריים גבולות טבעיים + למחוק את כל העדכונים החיים של %s\? + הגדרת הפרש קבוע בין הבקשות של OsmAnd לקבלת נתוני המיקום הנוכחיים. + לשמור ולהמשיך + כל הנתונים שלא נשמרו יאבדו. \ No newline at end of file From 487d357c2ffa5559193ea365006f4580f6d0ac03 Mon Sep 17 00:00:00 2001 From: iman Date: Tue, 23 Mar 2021 15:29:51 +0000 Subject: [PATCH 89/96] Translated using Weblate (Persian) Currently translated at 99.8% (3682 of 3688 strings) --- OsmAnd/res/values-fa/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values-fa/strings.xml b/OsmAnd/res/values-fa/strings.xml index ff02ab8a68..2d0bce8623 100644 --- a/OsmAnd/res/values-fa/strings.xml +++ b/OsmAnd/res/values-fa/strings.xml @@ -492,7 +492,7 @@ اجرای برنامه در حالت ایمن (به‌جای کد native از کد Android که کُندتر است استفاده می‌کند). برنامه در حالت ایمن اجرا شده است (از طریق تنظیمات آن را غیرفعال کنید). سرویس پس‌زمینهٔ OsmAnd هنوز در حال اجراست. آن را هم متوقف می‌کنید؟ - بستن بستهٔ تغییرات + بستن بستهٔ تغییر برنامهٔ اسکنر بارکد ZXing نصب نشده است. در گوگل‌پلی جست‌وجو می‌کنید؟ یکی از رنگ‌بندی‌های راه را انتخاب کنید: رنگ‌بندی راه @@ -787,8 +787,8 @@ در حال تبدیل اسامی محلی/انگلیسی… ناموفق اجازهٔ دسترسی احراز نشد - بستن بستهٔ تغییرات… - بازکردن بستهٔ تغییرات… + بستن بستهٔ تغییر… + بازکردن بستهٔ تغییر… دریافت لیست مناطق از https://osmand.net ناموفق بود. در حال دانلود لیست مناطق موجود… دادهٔ آفلاینِ {0} از قبل وجود دارد ({1}). آن را روزآمد می‌کنید ({2})؟ @@ -1478,7 +1478,7 @@ برنامهٔ OsmAnd نقشه‌گردی و ناوبری آفلاین را برایتان به ارمغان می‌آورد. خوش آمدید مسیر فعلی - تغییرات OSM به بستهٔ تغییرات محلی اضافه شد + تغییرات OSM به بستهٔ تغییر محلی اضافه شد برای حذف‌کردن علامت بزنید از آپلود این %1$d تغییر در OSM مطمئن هستید؟ سوابق را پاک می‌کنید؟ @@ -2589,7 +2589,7 @@ نشانه‌هایی که به‌عنوان گذرانده مشخص شود در این صفحه نشان داده می‌شود. بیشتر در حال جست‌وجوی ردهای دارای راه‌نشان - اشیای OSM را بسازید یا ویرایش کنید + مکان‌های OSM را ایجاد یا ویرایش کنید ‏POIها را اضافه یا ویرایش کنید، یادداشت‌های OSMای اضافه کنید یا روی آن‌ها نظر بدهید و فایل‌های GPX ضبط‌شده را آپلود کنید. حذف‌شده(ها) ویرایش شد @@ -3479,7 +3479,7 @@ در حال درون‌برد درون‌برد کامل شد همهٔ داده از %1$s درون‌برد شد. با استفاده از دکمه‌های زیر می‌توانید بخش موردنیاز برنامه را برای مدیریت آن باز کنید. - انواع POI + گونه‌های POI %1$s که در زیر آمده، هم‌اکنون در OsmAnd وجود دارد. ‏OsmAnd در حال بررسی ‏%1$s برای چیزهای تکراری موجود در برنامه است. \n @@ -4068,5 +4068,5 @@ مکث کرده دکمه‌ای برای آشکار یا پنهان کردن ابزارک مختصات روی نقشه. بازه - فاصله با لمس دوانگشتی + مسافت با لمس \ No newline at end of file From 51dff2456b09068366cdc4dc0829d462fd5da0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allan=20Nordh=C3=B8y?= Date: Tue, 23 Mar 2021 11:14:32 +0000 Subject: [PATCH 90/96] =?UTF-8?q?Translated=20using=20Weblate=20(Norwegian?= =?UTF-8?q?=20Bokm=C3=A5l)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently translated at 60.8% (2245 of 3688 strings) --- OsmAnd/res/values-nb/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-nb/strings.xml b/OsmAnd/res/values-nb/strings.xml index 38107b6cc1..c902064e98 100644 --- a/OsmAnd/res/values-nb/strings.xml +++ b/OsmAnd/res/values-nb/strings.xml @@ -3939,4 +3939,6 @@ Optimalisert kortere rute (energisparende) Aktuelle posisjonsikon vil bli festet til gjeldende navigeringsrute Ruting kan unngå kraftige oppoverbakker. + Lagre og fortsett + All ulagret data vil gå tapt. \ No newline at end of file From 0aaa004702325b864fb05cac3a0a783ce7ef391c Mon Sep 17 00:00:00 2001 From: Eduardo Addad de Oliveira Date: Tue, 23 Mar 2021 19:06:13 +0000 Subject: [PATCH 91/96] Translated using Weblate (Portuguese (Brazil)) Currently translated at 99.9% (3687 of 3688 strings) --- OsmAnd/res/values-pt-rBR/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index 5cb9de5bb1..1914ba1d48 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -4040,4 +4040,6 @@ Selecione outro tipo de colorização. Limites naturais Segmento %1$d + Salvar e continuar + Todos os dados não salvos serão perdidos. \ No newline at end of file From c3fb538e062be531e34342d2c71968a41f507f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Priit=20J=C3=B5er=C3=BC=C3=BCt?= Date: Mon, 22 Mar 2021 20:23:33 +0000 Subject: [PATCH 92/96] Translated using Weblate (Estonian) Currently translated at 99.9% (3687 of 3688 strings) --- OsmAnd/res/values-et/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-et/strings.xml b/OsmAnd/res/values-et/strings.xml index f78e97a163..e4c91a241f 100644 --- a/OsmAnd/res/values-et/strings.xml +++ b/OsmAnd/res/values-et/strings.xml @@ -4052,4 +4052,6 @@ Kaugus toksamise järgi Peida (loodus)kaitsealade ja rahvusparkide piirid Looduse piirid + Salvesta ja jätka + Kõik salvestamata andmed lähevad kaotsi. \ No newline at end of file From 6d1b6faf20c0cd9c21e550915ae19c0b2b44a618 Mon Sep 17 00:00:00 2001 From: phlostically Date: Mon, 22 Mar 2021 21:53:23 +0000 Subject: [PATCH 93/96] Translated using Weblate (Esperanto) Currently translated at 100.0% (3688 of 3688 strings) --- OsmAnd/res/values-eo/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-eo/strings.xml b/OsmAnd/res/values-eo/strings.xml index 9583371a8e..178af35973 100644 --- a/OsmAnd/res/values-eo/strings.xml +++ b/OsmAnd/res/values-eo/strings.xml @@ -4045,4 +4045,7 @@ Intertempo Kaŝi limojn de naturaj rezervejoj, protektataj areoj kaj naciaj parkoj Limoj de rezervejoj + Agordita periodo de intertempo de registrado, dum kiu OsmAnd petos la nunajn poziciajn datumojn. + Ĉiuj nekonservitaj datumoj perdiĝos. + Konservi kaj daŭrigi \ No newline at end of file From 738d28209184b084ebe31f5b32288715b3e915e5 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Tue, 23 Mar 2021 01:53:01 +0000 Subject: [PATCH 94/96] Translated using Weblate (Chinese (Traditional)) Currently translated at 100.0% (3688 of 3688 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 4ffbbadc5c..4bef29c778 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -4038,4 +4038,7 @@ 請選擇另一種顏色。 隱藏自然保留區、保護區與國家公園界線 自然界線 + 紀錄間隔設定的時段,OsmAnd 將會要求目前位置的位置資料。 + 儲存並繼續 + 所有未儲存的資料都將會遺失。 \ No newline at end of file From b7de6e8a3824c15147b89693c205cf4bc97174d7 Mon Sep 17 00:00:00 2001 From: Shjosan Date: Tue, 23 Mar 2021 13:57:11 +0000 Subject: [PATCH 95/96] Translated using Weblate (Swedish) Currently translated at 100.0% (271 of 271 strings) Translation: OsmAnd/Telegram Translate-URL: https://hosted.weblate.org/projects/osmand/telegram/sv/ --- OsmAnd-telegram/res/values-sv/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd-telegram/res/values-sv/strings.xml b/OsmAnd-telegram/res/values-sv/strings.xml index cbf274305e..7dac55e059 100644 --- a/OsmAnd-telegram/res/values-sv/strings.xml +++ b/OsmAnd-telegram/res/values-sv/strings.xml @@ -13,7 +13,7 @@ Kilomter/meter Miles/yard Miles/fot - Distansminuter per timme (knop) + Sjömil per timme (knop) Minuter per mile Minuter per kilometer Meter per sekund From 90ee2ba501a1160d5a3dee724485344e9df48f9e Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Wed, 24 Mar 2021 01:35:29 +0200 Subject: [PATCH 96/96] After code review fixes 3 --- .../osmand/plus/render/RendererRegistry.java | 5 +- .../plus/routing/RouteLineDrawInfo.java | 26 ++---- .../routing/cards/RouteLineColorCard.java | 4 +- .../routing/cards/RouteLineWidthCard.java | 2 +- .../fragments/ProfileAppearanceFragment.java | 13 ++- .../RouteLineAppearanceFragment.java | 24 +++--- .../plus/views/layers/MapControlsLayer.java | 12 +-- .../osmand/plus/views/layers/RouteLayer.java | 80 +++++++------------ .../layers/geometry/RouteGeometryWay.java | 11 ++- 9 files changed, 69 insertions(+), 108 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java index bc2dd97038..f015e790e0 100644 --- a/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java +++ b/OsmAnd/src/net/osmand/plus/render/RendererRegistry.java @@ -289,9 +289,8 @@ public class RendererRegistry { return renderers; } - public static String getMapStyleName(@NonNull OsmandApplication app) { - RendererRegistry rr = app.getRendererRegistry(); - RenderingRulesStorage storage = rr.getCurrentSelectedRenderer(); + public String getSelectedRendererName() { + RenderingRulesStorage storage = getCurrentSelectedRenderer(); if (storage == null) { return ""; } diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java index 627be2d9e8..92cb926fa1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteLineDrawInfo.java @@ -17,7 +17,6 @@ public class RouteLineDrawInfo { private static final String CENTER_X = "center_x"; private static final String CENTER_Y = "center_y"; private static final String SCREEN_HEIGHT = "screen_height"; - private static final String APP_MODE_KEY = "app_mode_key"; // parameters to save @ColorInt @@ -31,7 +30,6 @@ public class RouteLineDrawInfo { private int centerX; private int centerY; private int screenHeight; - private String appModeKey; public RouteLineDrawInfo(@Nullable @ColorInt Integer color, @Nullable String width) { @@ -44,14 +42,13 @@ public class RouteLineDrawInfo { } public RouteLineDrawInfo(@NonNull RouteLineDrawInfo existed) { - this.color = existed.getColor(); - this.width = existed.getWidth(); + this.color = existed.color; + this.width = existed.width; this.iconId = existed.iconId; this.iconColor = existed.iconColor; this.centerX = existed.centerX; this.centerY = existed.centerY; this.screenHeight = existed.screenHeight; - this.appModeKey = existed.appModeKey; } public void setColor(@Nullable Integer color) { @@ -82,10 +79,6 @@ public class RouteLineDrawInfo { this.screenHeight = screenHeight; } - public void setAppModeKey(@Nullable String appModeKey) { - this.appModeKey = appModeKey; - } - @Nullable public Integer getColor() { return color; @@ -117,20 +110,16 @@ public class RouteLineDrawInfo { return screenHeight; } - @Nullable - public String getAppModeKey() { - return appModeKey; - } - private void readBundle(@NonNull Bundle bundle) { - color = bundle.getInt(LINE_COLOR); + if (bundle.containsKey(LINE_COLOR)) { + color = bundle.getInt(LINE_COLOR); + } width = bundle.getString(LINE_WIDTH); iconId = bundle.getInt(NAVIGATION_ICON_ID); iconColor = bundle.getInt(NAVIGATION_ICON_COLOR); centerX = bundle.getInt(CENTER_X); centerY = bundle.getInt(CENTER_Y); screenHeight = bundle.getInt(SCREEN_HEIGHT); - appModeKey = bundle.getString(APP_MODE_KEY); } public void saveToBundle(@NonNull Bundle bundle) { @@ -142,10 +131,9 @@ public class RouteLineDrawInfo { } bundle.putInt(NAVIGATION_ICON_ID, iconId); bundle.putInt(NAVIGATION_ICON_COLOR, iconColor); - bundle.putInt(CENTER_X, (int) centerX); - bundle.putInt(CENTER_Y, (int) centerY); + bundle.putInt(CENTER_X, centerX); + bundle.putInt(CENTER_Y, centerY); bundle.putInt(SCREEN_HEIGHT, screenHeight); - bundle.putString(APP_MODE_KEY, appModeKey); } @Override diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java index dc33b3d113..3eabe283e3 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineColorCard.java @@ -26,7 +26,6 @@ import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.routing.RouteLineDrawInfo; -import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ListStringPreference; import net.osmand.plus.track.AppearanceViewHolder; import net.osmand.plus.track.ColorsCard; @@ -34,7 +33,6 @@ import net.osmand.plus.track.CustomColorBottomSheet.ColorPickerListener; import net.osmand.plus.widgets.MultiStateToggleButton; import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener; import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; -import net.osmand.render.RenderingRulesStorage; import java.util.ArrayList; import java.util.Arrays; @@ -211,7 +209,7 @@ public class RouteLineColorCard extends BaseCard implements CardListener, ColorP if (selectedMode == ColorMode.DEFAULT) { String pattern = app.getString(R.string.route_line_use_map_style_appearance); String color = app.getString(R.string.shared_string_color).toLowerCase(); - description = String.format(pattern, color, RendererRegistry.getMapStyleName(app)); + description = String.format(pattern, color, app.getRendererRegistry().getSelectedRendererName()); } else { String pattern = app.getString(R.string.specify_color_for_map_mode); String mapModeTitle = app.getString(isNightMap() ? NIGHT_TITLE_ID : DAY_TITLE_ID); diff --git a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java index dbe563175f..95c20783a4 100644 --- a/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java +++ b/OsmAnd/src/net/osmand/plus/routing/cards/RouteLineWidthCard.java @@ -131,7 +131,7 @@ public class RouteLineWidthCard extends BaseCard { if (selectedMode == WidthMode.DEFAULT) { String pattern = app.getString(R.string.route_line_use_map_style_appearance); String width = app.getString(R.string.shared_string_color).toLowerCase(); - String description = String.format(pattern, width, RendererRegistry.getMapStyleName(app)); + String description = String.format(pattern, width, app.getRendererRegistry().getSelectedRendererName()); tvDescription.setText(description); tvDescription.setVisibility(View.VISIBLE); } else { diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 7635a7f046..f4b38a32b8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -729,12 +729,10 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O private void updateRouteLinePreference() { Preference preference = findPreference(CUSTOMIZE_ROUTE_LINE); - if (preference != null) { - boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile; - boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile); - preference.setVisible(!isDefaultProfile && !isPublicTransport); - preference.setIcon(getIcon(R.drawable.ic_action_route_distance, getActiveColorRes())); - } + boolean isDefaultProfile = getSelectedAppMode().equals(ApplicationMode.DEFAULT) && !isNewProfile; + boolean isPublicTransport = PUBLIC_TRANSPORT_KEY.equals(changedProfile.routingProfile); + preference.setVisible(!isDefaultProfile && !isPublicTransport); + preference.setIcon(getIcon(R.drawable.ic_action_route_distance, getActiveColorRes())); } private boolean checkProfileName() { @@ -999,7 +997,6 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O RouteLineDrawInfo drawInfo = changedProfile.routeLineDrawInfo; drawInfo.setIconId(changedProfile.navigationIcon.getIconId()); drawInfo.setIconColor(changedProfile.getActualColor()); - drawInfo.setAppModeKey(profile.stringKey); RouteLineAppearanceFragment.showInstance(mapActivity, drawInfo, this); } } @@ -1031,7 +1028,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O private void saveRouteLineAppearance(@NonNull ApplicationMode appMode, @NonNull RouteLineDrawInfo drawInfo) { Integer color = drawInfo.getColor(); - if (drawInfo.getColor() != null) { + if (color != null) { settings.ROUTE_LINE_COLOR.setModeValue(appMode, color); } else { settings.ROUTE_LINE_COLOR.resetModeToDefault(appMode); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java index 44765dfc05..b0587eacde 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteLineAppearanceFragment.java @@ -161,6 +161,7 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple private void setupCards() { MapActivity mapActivity = requireMapActivity(); ViewGroup cardsContainer = getCardsContainer(); + cardsContainer.removeAllViews(); colorCard = new RouteLineColorCard(mapActivity, this, routeLineDrawInfo, initMapTheme, selectedMapTheme); cardsContainer.addView(colorCard.build(mapActivity)); @@ -285,17 +286,21 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple int screenHeight = AndroidUtils.getScreenHeight(ctx); int screenWidth = AndroidUtils.getScreenWidth(ctx); int statusBarHeight = AndroidUtils.getStatusBarHeight(ctx); - int x; - int y; - if (AndroidUiHelper.isOrientationPortrait(ctx)) { - x = screenWidth / 2; - y = (getViewY() + toolbarContainer.getHeight() + statusBarHeight) / 2; + int centerX; + int centerY; + if (isPortrait()) { + centerX = screenWidth / 2; + centerY = (getViewY() + toolbarContainer.getHeight() + statusBarHeight) / 2; } else { - x = (int) (AndroidUtils.isLayoutRtl(ctx) ? screenWidth/4 : screenWidth * 0.75); - y = (screenHeight + statusBarHeight) / 2 ; + boolean isRtl = AndroidUtils.isLayoutRtl(ctx); + int dialogWidth = getLandscapeNoShadowWidth(); + int left = isRtl ? 0 : dialogWidth; + int right = isRtl ? screenWidth - dialogWidth : screenWidth; + centerX = (left + right) / 2; + centerY = (screenHeight + statusBarHeight) / 2 ; } - routeLineDrawInfo.setCenterX(x); - routeLineDrawInfo.setCenterY(y); + routeLineDrawInfo.setCenterX(centerX); + routeLineDrawInfo.setCenterY(centerY); routeLineDrawInfo.setScreenHeight(screenHeight); } @@ -393,7 +398,6 @@ public class RouteLineAppearanceFragment extends ContextMenuScrollFragment imple @NonNull Fragment target) { try { RouteLineAppearanceFragment fragment = new RouteLineAppearanceFragment(); - fragment.setRetainInstance(true); fragment.setTargetFragment(target, 0); fragment.routeLineDrawInfo = new RouteLineDrawInfo(drawInfo); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java index 37f46e05d8..0bfde7edcf 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/MapControlsLayer.java @@ -873,7 +873,7 @@ public class MapControlsLayer extends OsmandMapLayer { && !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !shouldHideTopControls && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() && !isInTrackAppearanceMode() - && !isInRouteLineCustomizationMode(); + && !isInRouteLineAppearanceMode(); routePlanningBtn.updateVisibility(showBottomMenuButtons); menuControl.updateVisibility(showBottomMenuButtons); @@ -881,7 +881,7 @@ public class MapControlsLayer extends OsmandMapLayer { && !isInTrackAppearanceMode() && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode() - && !isInRouteLineCustomizationMode(); + && !isInRouteLineAppearanceMode(); boolean showZoomButtons = !routeDialogOpened && !shouldHideTopControls && !isInFollowTrackMode() && (additionalDialogsHide || !portrait); @@ -891,7 +891,7 @@ public class MapControlsLayer extends OsmandMapLayer { boolean forceHideCompass = routeDialogOpened || trackDialogOpened || isInMeasurementToolMode() || isInPlanRouteMode() || shouldHideTopControls || isInChoosingRoutesMode() || isInTrackAppearanceMode() || isInWaypointsChoosingMode() || isInFollowTrackMode() - || isInRouteLineCustomizationMode(); + || isInRouteLineAppearanceMode(); compassHud.forceHideCompass = forceHideCompass; compassHud.updateVisibility(!forceHideCompass && shouldShowCompass()); @@ -903,7 +903,7 @@ public class MapControlsLayer extends OsmandMapLayer { boolean showTopButtons = !routeDialogOpened && !trackDialogOpened && !shouldHideTopControls && !isInMeasurementToolMode() && !isInPlanRouteMode() && !isInChoosingRoutesMode() && !isInTrackAppearanceMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() - && !isInRouteLineCustomizationMode(); + && !isInRouteLineAppearanceMode(); layersHud.updateVisibility(showTopButtons); quickSearchHud.updateVisibility(showTopButtons); @@ -1034,7 +1034,7 @@ public class MapControlsLayer extends OsmandMapLayer { && !isInChoosingRoutesMode() && !isInWaypointsChoosingMode() && !isInFollowTrackMode() - && !isInRouteLineCustomizationMode(); + && !isInRouteLineAppearanceMode(); backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode() && (additionalDialogsHide || !isPotrait())); } @@ -1402,7 +1402,7 @@ public class MapControlsLayer extends OsmandMapLayer { return MapRouteInfoMenu.waypointsVisible; } - private boolean isInRouteLineCustomizationMode() { + private boolean isInRouteLineAppearanceMode() { return mapActivity.getMapLayers().getRouteLayer().isInRouteLineAppearanceMode(); } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index b6fae1830b..2a432c8041 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -11,6 +11,7 @@ import android.graphics.Path; import android.graphics.PointF; import android.graphics.PorterDuff.Mode; import android.graphics.PorterDuffColorFilter; +import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import androidx.annotation.ColorInt; @@ -41,8 +42,6 @@ import net.osmand.plus.routing.RouteLineDrawInfo; import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; -import net.osmand.plus.settings.backend.ApplicationMode; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.layers.geometry.PublicTransportGeometryWay; @@ -103,6 +102,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont private PublicTransportGeometryWay publicTransportRouteGeometry; private LayerDrawable projectionIcon; + private LayerDrawable previewIcon; public RouteLayer(RoutingHelper helper) { this.helper = helper; @@ -246,8 +246,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont return routeLineDrawInfo != null; } - public void setRouteLineDrawInfo(RouteLineDrawInfo routeLineDrawInfo) { - this.routeLineDrawInfo = routeLineDrawInfo; + public void setRouteLineDrawInfo(RouteLineDrawInfo drawInfo) { + this.routeLineDrawInfo = drawInfo; + if (drawInfo == null) { + previewIcon = null; + } } private MapActivity getMapActivity() { @@ -312,41 +315,30 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont QuadPoint c = tileBox.getCenterPixelPoint(); canvas.rotate(-angle, c.x, c.y); - drawRouteLinePreview(canvas, tileBox, settings, routeLineDrawInfo); + drawRouteLinePreview(canvas, tileBox, routeLineDrawInfo); canvas.rotate(angle, c.x, c.y); } } private void drawRouteLinePreview(Canvas canvas, RotatedTileBox tileBox, - DrawSettings settings, RouteLineDrawInfo drawInfo) { - MapActivity mapActivity = getMapActivity(); - updateAttrs(settings, tileBox); paintRouteLinePreview.setColor(getRouteLineColor(nightMode)); paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox)); - int x = drawInfo.getCenterX(); - int y = drawInfo.getCenterY(); + int centerX = drawInfo.getCenterX(); + int centerY = drawInfo.getCenterY(); int screenHeight = drawInfo.getScreenHeight(); - // draw line - canvas.drawLine(x, 0, x, screenHeight, paintRouteLinePreview); + canvas.drawLine(centerX, 0, centerX, screenHeight, paintRouteLinePreview); - // draw image - LayerDrawable navigationIcon = (LayerDrawable) AppCompatResources.getDrawable(mapActivity, drawInfo.getIconId()); - if (navigationIcon != null) { - DrawableCompat.setTint(navigationIcon.getDrawable(1), drawInfo.getIconColor()); + if (previewIcon == null) { + previewIcon = (LayerDrawable) AppCompatResources.getDrawable(view.getContext(), drawInfo.getIconId()); + DrawableCompat.setTint(previewIcon.getDrawable(1), drawInfo.getIconColor()); } - int left = x - navigationIcon.getIntrinsicWidth() / 2; - int right = x + navigationIcon.getIntrinsicWidth() / 2; - int top = y - navigationIcon.getIntrinsicHeight() / 2; - int bottom = y + navigationIcon.getIntrinsicHeight() / 2; - navigationIcon.setBounds(left, top, right, bottom); - canvas.rotate(-90, x, y); - navigationIcon.draw(canvas); - canvas.save(); - canvas.restore(); + canvas.rotate(-90, centerX, centerY); + drawIcon(canvas, previewIcon, centerX, centerY); + canvas.rotate(90, centerX, centerY); } private void drawAction(RotatedTileBox tb, Canvas canvas, List actionPoints) { @@ -410,25 +402,24 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } int locationX = (int) projectionXY[0]; int locationY = (int) projectionXY[1]; + drawIcon(canvas, projectionIcon, locationX, locationY); + } - projectionIcon.setBounds(locationX - projectionIcon.getIntrinsicWidth() / 2, - locationY - projectionIcon.getIntrinsicHeight() / 2, - locationX + projectionIcon.getIntrinsicWidth() / 2, - locationY + projectionIcon.getIntrinsicHeight() / 2); - projectionIcon.draw(canvas); - + private static void drawIcon(Canvas canvas, Drawable drawable, int locationX, int locationY) { + drawable.setBounds(locationX - drawable.getIntrinsicWidth() / 2, + locationY - drawable.getIntrinsicHeight() / 2, + locationX + drawable.getIntrinsicWidth() / 2, + locationY + drawable.getIntrinsicHeight() / 2); + drawable.draw(canvas); } @ColorInt public int getRouteLineColor(boolean night) { - OsmandSettings settings = view.getSettings(); - ApplicationMode appMode = getApplicationMode(); - Integer color; if (routeLineDrawInfo != null) { color = routeLineDrawInfo.getColor(); } else { - int storedValue = settings.ROUTE_LINE_COLOR.getModeValue(appMode); + int storedValue = view.getSettings().ROUTE_LINE_COLOR.getModeValue(helper.getAppMode()); color = storedValue != 0 ? storedValue : null; } @@ -440,14 +431,11 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) { - OsmandSettings settings = view.getSettings(); - ApplicationMode appMode = getApplicationMode(); - String widthKey; if (routeLineDrawInfo != null) { widthKey = routeLineDrawInfo.getWidth(); } else { - widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode); + widthKey = view.getSettings().ROUTE_LINE_WIDTH.getModeValue(helper.getAppMode()); } return widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth(); } @@ -470,9 +458,9 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer(); RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs); req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode); - RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); req.setIntFilter(rrs.PROPS.R_MINZOOM, tileBox.getZoom()); req.setIntFilter(rrs.PROPS.R_MAXZOOM, tileBox.getZoom()); + RenderingRuleProperty ctWidth = rrs.PROPS.get(CURRENT_TRACK_WIDTH_ATTR); if (ctWidth != null) { req.setStringFilter(ctWidth, widthKey); } @@ -486,18 +474,6 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont return resultValue; } - @NonNull - private ApplicationMode getApplicationMode() { - ApplicationMode appMode = null; - if (routeLineDrawInfo != null) { - String modeKey = routeLineDrawInfo.getAppModeKey(); - if (modeKey != null) { - appMode = ApplicationMode.valueOfStringKey(modeKey, null); - } - } - return appMode != null ? appMode : helper.getAppMode(); - } - public void drawLocations(RotatedTileBox tb, Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) { if (helper.isPublicTransportMode()) { int currentRoute = transportHelper.getCurrentRoute(); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java index ac81e021d5..f6e26b039f 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/geometry/RouteGeometryWay.java @@ -5,6 +5,7 @@ import android.graphics.Paint; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import net.osmand.Location; import net.osmand.data.RotatedTileBox; @@ -18,6 +19,7 @@ public class RouteGeometryWay extends GeometryWay getDefaultWayStyle() { Paint paint = getContext().getAttrs().paint; - int paintColor = paint.getColor(); - int color = customColor != null ? customColor : paintColor; - float paintWidth = paint.getStrokeWidth(); - float width = customWidth != null ? customWidth : paintWidth; + int color = customColor != null ? customColor : paint.getColor(); + float width = customWidth != null ? customWidth : paint.getStrokeWidth(); return new GeometrySolidWayStyle(getContext(), color, width); }