From 4cdead7a4d681b28e1dc13e31676d5d4cd1efc1d Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Thu, 26 Sep 2024 19:21:48 +0300 Subject: [PATCH] Implement quick actions for Trip Recording (issue #20800) --- OsmAnd/res/values/strings.xml | 10 +++ .../monitoring/OsmandMonitoringPlugin.java | 68 ++++++++++++++---- .../monitoring/TripRecordingBottomSheet.java | 21 +----- .../TripRecordingOptionsBottomSheet.java | 29 +++----- .../actions/BaseTripRecordingAction.java | 34 +++++++++ .../actions/FinishTripRecordingAction.java | 59 +++++++++++++++ .../SaveRecordedTripAndContinueAction.java | 64 +++++++++++++++++ .../actions/StartNewTripSegmentAction.java | 58 +++++++++++++++ .../actions/TripRecordingAction.java | 71 +++++++++++++++++++ .../plus/quickaction/QuickActionIds.java | 4 ++ .../src/net/osmand/plus/track/GpxDialogs.java | 8 +-- 11 files changed, 373 insertions(+), 53 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/BaseTripRecordingAction.java create mode 100644 OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/FinishTripRecordingAction.java create mode 100644 OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/SaveRecordedTripAndContinueAction.java create mode 100644 OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/StartNewTripSegmentAction.java create mode 100644 OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/TripRecordingAction.java diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index cbd4fb79395..8064a52f340 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -10,6 +10,16 @@ - For wording and consistency, please note https://docs.osmand.net/docs/technical/contributions/translating-osmand Thx - Hardy --> + Track doesn\'t contain data to save. + A button to save the GPX track and finish trip recording. + Please start trip recording first. + Started recording a new track segment. + A button to save the current recorded trip as a GPX file and continue recording a new track without interruption. + Recorded Trip & Continue + A button to start a new segment in the ongoing GPX track recording. + New trip segment + A button to start, pause or resume recording of the GPX track. + Start / Pause Unknown device VIN VIN code over OBD diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/OsmandMonitoringPlugin.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/OsmandMonitoringPlugin.java index e900751bd93..dc1168ed365 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/monitoring/OsmandMonitoringPlugin.java +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/OsmandMonitoringPlugin.java @@ -18,6 +18,11 @@ import net.osmand.Location; import net.osmand.PlatformUtil; import net.osmand.data.ValueHolder; +import net.osmand.plus.plugins.monitoring.actions.FinishTripRecordingAction; +import net.osmand.plus.plugins.monitoring.actions.SaveRecordedTripAndContinueAction; +import net.osmand.plus.plugins.monitoring.actions.StartNewTripSegmentAction; +import net.osmand.plus.plugins.monitoring.actions.TripRecordingAction; +import net.osmand.plus.quickaction.QuickActionType; import net.osmand.shared.gpx.GpxFile; import net.osmand.plus.NavigationService; import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable; @@ -229,17 +234,9 @@ public SelectedGpxFile getCurrentTrack() { return app.getSavingTrackHelper().getCurrentTrack(); } - public boolean wasTrackMonitored() { - return settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); - } - - public boolean hasDataToSave() { - return app.getSavingTrackHelper().hasDataToSave(); - } - public void askShowTripRecordingDialog(@NonNull FragmentActivity activity) { FragmentManager fragmentManager = activity.getSupportFragmentManager(); - if (hasDataToSave() || wasTrackMonitored()) { + if (hasDataToSave() || isRecordingTrack()) { TripRecordingBottomSheet.showInstance(fragmentManager); } else { askStartRecording(activity); @@ -263,7 +260,7 @@ private void askStartRecordingStep2(@NonNull FragmentActivity activity) { public void startRecording(@Nullable FragmentActivity activity) { app.getSavingTrackHelper().startNewSegment(); - app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.set(true); + setRecordingTrack(true); app.startNavigationService(NavigationService.USED_BY_GPX); if (activity != null) { @@ -271,6 +268,15 @@ public void startRecording(@Nullable FragmentActivity activity) { } } + public boolean finishRecording() { + if (mapActivity != null && hasDataToSave()) { + saveCurrentTrack(null, mapActivity); + app.getNotificationHelper().refreshNotifications(); + return true; + } + return false; + } + public void saveCurrentTrack() { saveCurrentTrack(null, null, true, false); } @@ -374,12 +380,28 @@ public void updateWidgets() { } } + public void pauseOrResumeRecording() { + if (isRecordingTrack()) { + setRecordingTrack(false); + NavigationService navigationService = app.getNavigationService(); + if (navigationService != null) { + navigationService.stopIfNeeded(app, NavigationService.USED_BY_GPX); + } + } else { + setRecordingTrack(true); + app.startNavigationService(NavigationService.USED_BY_GPX); + if (mapActivity != null) { + AndroidUtils.requestNotificationPermissionIfNeeded(mapActivity); + } + } + } + public void stopRecording() { stopRecording(false); } public void stopRecording(boolean clearData) { - settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); + setRecordingTrack(false); app.getSavingTrackHelper().onStopRecording(clearData); if (app.getNavigationService() != null) { app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX); @@ -390,6 +412,18 @@ public boolean isSaving() { return isSaving; } + public void setRecordingTrack(boolean recording) { + settings.SAVE_GLOBAL_TRACK_TO_GPX.set(recording); + } + + public boolean isRecordingTrack() { + return settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); + } + + public boolean hasDataToSave() { + return app.getSavingTrackHelper().hasDataToSave(); + } + public boolean isLiveMonitoringEnabled() { return liveMonitoringHelper.isLiveMonitoringEnabled(); } @@ -404,8 +438,8 @@ public void startGPXMonitoring(@Nullable FragmentActivity activity) { if (choice.value || activity == null) { Runnable runnable = () -> { app.getSavingTrackHelper().startNewSegment(); + setRecordingTrack(true); settings.SAVE_GLOBAL_TRACK_INTERVAL.set(vs.value); - settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true); settings.SAVE_GLOBAL_TRACK_REMEMBER.set(choice.value); if (activity != null) { @@ -423,4 +457,14 @@ public void startGPXMonitoring(@Nullable FragmentActivity activity) { public DashFragmentData getCardFragment() { return DashTrackFragment.FRAGMENT_DATA; } + + @Override + protected List getQuickActionTypes() { + List quickActionTypes = new ArrayList<>(); + quickActionTypes.add(TripRecordingAction.TYPE); + quickActionTypes.add(StartNewTripSegmentAction.TYPE); + quickActionTypes.add(SaveRecordedTripAndContinueAction.TYPE); + quickActionTypes.add(FinishTripRecordingAction.TYPE); + return quickActionTypes; + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingBottomSheet.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingBottomSheet.java index 0989d084ca8..1aff447b737 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingBottomSheet.java @@ -217,20 +217,8 @@ private void setupResumePauseButton(View container) { blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded(); handler.startChartUpdatesIfNotRunning(); } - if (isRecordingTrack) { - settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false); - NavigationService navigationService = app.getNavigationService(); - if (navigationService != null) { - navigationService.stopIfNeeded(app, NavigationService.USED_BY_GPX); - } - } else { - app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.set(true); - app.startNavigationService(NavigationService.USED_BY_GPX); - - FragmentActivity activity = getMapActivity(); - if (activity != null) { - AndroidUtils.requestNotificationPermissionIfNeeded(activity); - } + if (plugin != null) { + plugin.pauseOrResumeRecording(); } updateStatus(); createItem(resumePauseButton, !isRecordingTrack ? ItemType.PAUSE : ItemType.RESUME); @@ -241,10 +229,7 @@ private void setupFinishButton(View container) { CardView finishButton = container.findViewById(R.id.button_center_right); createItem(finishButton, ItemType.FINISH); finishButton.setOnClickListener(v -> { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null && plugin != null && hasDataToSave()) { - plugin.saveCurrentTrack(null, mapActivity); - app.getNotificationHelper().refreshNotifications(); + if (plugin != null && plugin.finishRecording()) { dismiss(); } }); diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingOptionsBottomSheet.java index 54ae62b581a..0fa7c0ab5d8 100644 --- a/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/TripRecordingOptionsBottomSheet.java @@ -103,12 +103,9 @@ public void createMenuItems(Bundle savedInstanceState) { items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonClear) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (fragmentManager != null && hasDataToSave()) { - TripRecordingClearDataBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this); - } + .setOnClickListener(v -> { + if (fragmentManager != null && hasDataToSave()) { + TripRecordingClearDataBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this); } }) .create()); @@ -117,12 +114,9 @@ public void onClick(View v) { items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonDiscard) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (fragmentManager != null) { - TripRecordingDiscardBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this); - } + .setOnClickListener(v -> { + if (fragmentManager != null) { + TripRecordingDiscardBottomSheet.showInstance(fragmentManager, TripRecordingOptionsBottomSheet.this); } }) .create()); @@ -131,13 +125,10 @@ public void onClick(View v) { items.add(new BaseBottomSheetItem.Builder() .setCustomView(buttonOnline) - .setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - boolean wasOnlineMonitored = !settings.LIVE_MONITORING.get(); - settings.LIVE_MONITORING.set(wasOnlineMonitored); - createItem(buttonOnline, wasOnlineMonitored ? ItemType.STOP_ONLINE : ItemType.START_ONLINE); - } + .setOnClickListener(v -> { + boolean wasOnlineMonitored = !settings.LIVE_MONITORING.get(); + settings.LIVE_MONITORING.set(wasOnlineMonitored); + createItem(buttonOnline, wasOnlineMonitored ? ItemType.STOP_ONLINE : ItemType.START_ONLINE); }) .create()); diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/BaseTripRecordingAction.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/BaseTripRecordingAction.java new file mode 100644 index 00000000000..f4cffb149b4 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/BaseTripRecordingAction.java @@ -0,0 +1,34 @@ +package net.osmand.plus.plugins.monitoring.actions; + +import androidx.annotation.Nullable; + +import net.osmand.plus.plugins.PluginsHelper; +import net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; + +abstract class BaseTripRecordingAction extends QuickAction { + + public BaseTripRecordingAction(QuickActionType actionType) { + super(actionType); + } + + public BaseTripRecordingAction(QuickAction quickAction) { + super(quickAction); + } + + protected boolean isRecordingTrack() { + OsmandMonitoringPlugin plugin = getPlugin(); + return plugin != null && plugin.isRecordingTrack(); + } + + protected boolean hasDataToSave() { + OsmandMonitoringPlugin plugin = getPlugin(); + return plugin != null && plugin.hasDataToSave(); + } + + @Nullable + protected OsmandMonitoringPlugin getPlugin() { + return PluginsHelper.getPlugin(OsmandMonitoringPlugin.class); + } +} diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/FinishTripRecordingAction.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/FinishTripRecordingAction.java new file mode 100644 index 00000000000..cafcc49348e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/FinishTripRecordingAction.java @@ -0,0 +1,59 @@ +package net.osmand.plus.plugins.monitoring.actions; + +import static net.osmand.plus.quickaction.QuickActionIds.FINISH_TRIP_RECORDING_ACTION; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; + +public class FinishTripRecordingAction extends BaseTripRecordingAction { + + public static final QuickActionType TYPE = new QuickActionType(FINISH_TRIP_RECORDING_ACTION, + "finish.trip.recording", FinishTripRecordingAction.class) + .nameRes(R.string.shared_string_trip_recording) + .iconRes(R.drawable.ic_action_trip_rec_finish) + .nonEditable() + .category(QuickActionType.MY_PLACES) + .nameActionRes(R.string.shared_string_finish); + + public FinishTripRecordingAction() { + super(TYPE); + } + + public FinishTripRecordingAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(@NonNull MapActivity mapActivity) { + OsmandMonitoringPlugin plugin = getPlugin(); + if (plugin != null) { + OsmandApplication app = mapActivity.getMyApplication(); + if (!plugin.isRecordingTrack()) { + app.showToastMessage(R.string.start_trip_recording_first_m); + } else if (!plugin.hasDataToSave()) { + app.showToastMessage(R.string.track_does_not_contain_data_to_save); + } else { + plugin.finishRecording(); + } + } + } + + @Override + public void drawUI(@NonNull ViewGroup parent, @NonNull MapActivity mapActivity) { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.quick_action_with_text, parent, false); + ((TextView) view.findViewById(R.id.text)).setText(R.string.quick_action_finish_trip_recording_summary); + parent.addView(view); + } +} diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/SaveRecordedTripAndContinueAction.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/SaveRecordedTripAndContinueAction.java new file mode 100644 index 00000000000..44d44ea55dd --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/SaveRecordedTripAndContinueAction.java @@ -0,0 +1,64 @@ +package net.osmand.plus.plugins.monitoring.actions; + +import static net.osmand.plus.quickaction.QuickActionIds.SAVE_RECORDED_TRIP_AND_CONTINUE_ACTION; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; +import net.osmand.plus.track.helpers.save.SaveGpxHelper; +import net.osmand.shared.gpx.GpxFile; + +public class SaveRecordedTripAndContinueAction extends BaseTripRecordingAction { + + public static final QuickActionType TYPE = new QuickActionType(SAVE_RECORDED_TRIP_AND_CONTINUE_ACTION, + "save.trip.and.continue", SaveRecordedTripAndContinueAction.class) + .nameRes(R.string.quick_action_save_recorded_trip_and_continue) + .iconRes(R.drawable.ic_action_trip_rec_save) + .nonEditable() + .category(QuickActionType.MY_PLACES) + .nameActionRes(R.string.shared_string_save); + + public SaveRecordedTripAndContinueAction() { + super(TYPE); + } + + public SaveRecordedTripAndContinueAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(@NonNull MapActivity mapActivity) { + OsmandMonitoringPlugin plugin = getPlugin(); + if (plugin != null) { + OsmandApplication app = mapActivity.getMyApplication(); + if (!plugin.isRecordingTrack()) { + app.showToastMessage(R.string.start_trip_recording_first_m); + } else if (!plugin.hasDataToSave()) { + app.showToastMessage(R.string.track_does_not_contain_data_to_save); + } else { + GpxFile gpxFile = app.getSavingTrackHelper().getCurrentTrack().getGpxFile(); + SaveGpxHelper.saveCurrentTrack(app, gpxFile, errorMessage -> { + plugin.saveCurrentTrack(null, mapActivity, false, true); + }); + } + } + } + + @Override + public void drawUI(@NonNull ViewGroup parent, @NonNull MapActivity mapActivity) { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.quick_action_with_text, parent, false); + ((TextView) view.findViewById(R.id.text)).setText(R.string.quick_action_save_recorded_trip_and_continue_summary); + parent.addView(view); + } +} diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/StartNewTripSegmentAction.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/StartNewTripSegmentAction.java new file mode 100644 index 00000000000..9df75b46b45 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/StartNewTripSegmentAction.java @@ -0,0 +1,58 @@ +package net.osmand.plus.plugins.monitoring.actions; + +import static net.osmand.plus.quickaction.QuickActionIds.START_NEW_TRIP_SEGMENT_ACTION; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; + +public class StartNewTripSegmentAction extends BaseTripRecordingAction { + + public static final QuickActionType TYPE = new QuickActionType(START_NEW_TRIP_SEGMENT_ACTION, + "start.new.trip.segment", StartNewTripSegmentAction.class) + .nameRes(R.string.new_trip_segment) + .iconRes(R.drawable.ic_action_trip_rec_new_segment) + .nonEditable() + .category(QuickActionType.MY_PLACES) + .nameActionRes(R.string.shared_string_control_start); + + public StartNewTripSegmentAction() { + super(TYPE); + } + + public StartNewTripSegmentAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(@NonNull MapActivity mapActivity) { + OsmandMonitoringPlugin plugin = getPlugin(); + if (plugin != null) { + OsmandApplication app = mapActivity.getMyApplication(); + if (plugin.isRecordingTrack()) { + app.getSavingTrackHelper().startNewSegment(); + app.showToastMessage(R.string.new_segment_started_m); + } else { + app.showToastMessage(R.string.start_trip_recording_first_m); + } + } + } + + @Override + public void drawUI(@NonNull ViewGroup parent, @NonNull MapActivity mapActivity) { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.quick_action_with_text, parent, false); + ((TextView) view.findViewById(R.id.text)).setText(R.string.quick_action_new_trip_segment); + parent.addView(view); + } +} diff --git a/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/TripRecordingAction.java b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/TripRecordingAction.java new file mode 100644 index 00000000000..0a786c8c13d --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/plugins/monitoring/actions/TripRecordingAction.java @@ -0,0 +1,71 @@ +package net.osmand.plus.plugins.monitoring.actions; + +import static net.osmand.plus.quickaction.QuickActionIds.TRIP_RECORDING_ACTION; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin; +import net.osmand.plus.quickaction.QuickAction; +import net.osmand.plus.quickaction.QuickActionType; + +public class TripRecordingAction extends BaseTripRecordingAction { + + public static final QuickActionType TYPE = new QuickActionType(TRIP_RECORDING_ACTION, + "trip.recording.startpause", TripRecordingAction.class) + .nameRes(R.string.shared_string_trip_recording) + .iconRes(R.drawable.ic_action_trip_rec_start) + .nonEditable() + .category(QuickActionType.MY_PLACES) + .nameActionRes(R.string.quick_action_verb_start_pause); + + public TripRecordingAction() { + super(TYPE); + } + + public TripRecordingAction(QuickAction quickAction) { + super(quickAction); + } + + @Override + public void execute(@NonNull MapActivity mapActivity) { + OsmandMonitoringPlugin plugin = getPlugin(); + if (plugin != null) { + if (plugin.hasDataToSave()) { + plugin.pauseOrResumeRecording(); + } else { + plugin.askShowTripRecordingDialog(mapActivity); + } + } + } + + @Override + public int getIconRes(Context context) { + return isRecordingTrack() + ? R.drawable.ic_action_trip_rec_pause + : R.drawable.ic_action_trip_rec_start; + } + + @Override + public String getActionText(@NonNull OsmandApplication app) { + String nameRes = app.getString(getNameRes()); + String actionName = isRecordingTrack() ? app.getString(R.string.shared_string_pause) : app.getString(R.string.shared_string_control_start); + return app.getString(R.string.ltr_or_rtl_combine_via_dash, actionName, nameRes); + } + + @Override + public void drawUI(@NonNull ViewGroup parent, @NonNull MapActivity mapActivity) { + View view = LayoutInflater.from(parent.getContext()) + .inflate(R.layout.quick_action_with_text, parent, false); + ((TextView) view.findViewById(R.id.text)).setText(R.string.quick_action_start_pause_recording); + parent.addView(view); + } +} diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionIds.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionIds.java index d13e257f912..6b23a209a6d 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionIds.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionIds.java @@ -70,4 +70,8 @@ public class QuickActionIds { public static final int OPEN_SEARCH_VIEW_ACTION = 70; public static final int SHOW_HIDE_DRAWER_ACTION = 71; public static final int NAVIGATE_PREVIOUS_SCREEN_ACTION = 72; + public static final int TRIP_RECORDING_ACTION = 73; + public static final int START_NEW_TRIP_SEGMENT_ACTION = 74; + public static final int SAVE_RECORDED_TRIP_AND_CONTINUE_ACTION = 75; + public static final int FINISH_TRIP_RECORDING_ACTION = 76; } diff --git a/OsmAnd/src/net/osmand/plus/track/GpxDialogs.java b/OsmAnd/src/net/osmand/plus/track/GpxDialogs.java index 1d3b7878fc9..678c4791bad 100644 --- a/OsmAnd/src/net/osmand/plus/track/GpxDialogs.java +++ b/OsmAnd/src/net/osmand/plus/track/GpxDialogs.java @@ -236,8 +236,8 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) { item.setSelected(!item.getSelected()); alertDialogAdapter.notifyDataSetInvalidated(); if (position == 0 && showCurrentGpx && item.getSelected()) { - OsmandMonitoringPlugin monitoringPlugin = PluginsHelper.getActivePlugin(OsmandMonitoringPlugin.class); - if (monitoringPlugin == null) { + OsmandMonitoringPlugin plugin = PluginsHelper.getActivePlugin(OsmandMonitoringPlugin.class); + if (plugin == null) { AlertDialog.Builder confirm = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes)); confirm.setPositiveButton(R.string.shared_string_ok, (dialog, which) -> { Bundle params = new Bundle(); @@ -247,8 +247,8 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) { confirm.setNegativeButton(R.string.shared_string_cancel, null); confirm.setMessage(activity.getString(R.string.enable_plugin_monitoring_services)); confirm.show(); - } else if (!app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) { - monitoringPlugin.askShowTripRecordingDialog(activity); + } else if (!plugin.isRecordingTrack()) { + plugin.askShowTripRecordingDialog(activity); } } } else {