Merge pull request #11201 from osmandapp/trip_recording
Redesign trip recording base dialog (added options dialog)
This commit is contained in:
commit
e301eebcf9
17 changed files with 716 additions and 593 deletions
|
@ -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">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:orientation="horizontal"
|
||||
|
@ -20,7 +19,6 @@
|
|||
android:paddingEnd="@dimen/content_padding_small"
|
||||
android:paddingRight="@dimen/content_padding_small"
|
||||
android:paddingBottom="@dimen/text_margin_small"
|
||||
tools:background="@drawable/btn_background_inactive_dark"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -1,172 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding_small"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding_small"
|
||||
android:weightSum="2">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:text="@string/monitoring_settings"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/status_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="end|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/text_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/recording_default_name"
|
||||
tools:textColor="@color/icon_color_osmand_light" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/icon_status"
|
||||
android:layout_width="@dimen/map_widget_icon"
|
||||
android:layout_height="@dimen/map_widget_icon"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
tools:srcCompat="@drawable/ic_action_polygom_dark"
|
||||
tools:tint="@color/icon_color_osmand_light" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/block_statistics"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_marginTop="@dimen/content_padding_small_half"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
tools:itemCount="4"
|
||||
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_gpx_stat_block" />
|
||||
|
||||
<include
|
||||
android:id="@+id/show_track_on_map"
|
||||
layout="@layout/bottom_sheet_with_switch_divider_and_additional_button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<include
|
||||
android:id="@+id/button_clear"
|
||||
layout="@layout/bottom_sheet_button_with_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/content_padding"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding" />
|
||||
|
||||
<include
|
||||
android:id="@+id/button_online"
|
||||
layout="@layout/bottom_sheet_button_with_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include
|
||||
android:id="@+id/button_segment"
|
||||
layout="@layout/bottom_sheet_button_with_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding" />
|
||||
|
||||
<include
|
||||
android:id="@+id/button_save"
|
||||
layout="@layout/bottom_sheet_button_with_icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/content_padding_small"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:layout_marginEnd="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
android:layout_marginBottom="@dimen/content_padding"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal"
|
||||
android:weightSum="2">
|
||||
|
||||
<include
|
||||
android:id="@+id/button_pause"
|
||||
layout="@layout/bottom_sheet_button_with_icon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<include
|
||||
android:id="@+id/button_stop"
|
||||
layout="@layout/bottom_sheet_button_with_icon"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/content_padding"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
91
OsmAnd/res/layout/trip_recording_fragment.xml
Normal file
91
OsmAnd/res/layout/trip_recording_fragment.xml
Normal file
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/content_padding">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding_small"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding"
|
||||
android:weightSum="2">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:text="@string/monitoring_settings"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/status_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="end|center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/text_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="@string/recording_default_name"
|
||||
tools:textColor="@color/icon_color_osmand_light" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/icon_status"
|
||||
android:layout_width="@dimen/map_widget_icon"
|
||||
android:layout_height="@dimen/map_widget_icon"
|
||||
android:layout_marginStart="@dimen/content_padding_small"
|
||||
android:layout_marginLeft="@dimen/content_padding_small"
|
||||
tools:srcCompat="@drawable/ic_action_polygom_dark"
|
||||
tools:tint="@color/icon_color_osmand_light" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/show_track_on_map"
|
||||
layout="@layout/bottom_sheet_with_switch_divider_and_additional_button"
|
||||
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:layout_marginBottom="@dimen/dialog_content_margin" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/block_statistics"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/list_header_height"
|
||||
android:layout_marginTop="@dimen/content_padding_small_half"
|
||||
android:layout_marginBottom="@dimen/dialog_content_margin"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
tools:itemCount="4"
|
||||
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_gpx_stat_block" />
|
||||
|
||||
<include layout="@layout/preference_button_with_icon_quadruple" />
|
||||
|
||||
</LinearLayout>
|
|
@ -11,6 +11,8 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="lost_data_warning">All unsaved data will be lost.</string>
|
||||
<string name="trip_recording_save_and_continue">Save and continue</string>
|
||||
<string name="trip_recording_logging_interval_info">Logging interval set time period in which OsmAnd will ask for the current location position data.</string>
|
||||
<string name="select_another_colorization">Please select another type of colorization.</string>
|
||||
<string name="track_has_no_speed">The track does not contain speed data.</string>
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.LinkedHashMap;
|
|||
import static net.osmand.plus.activities.PluginInfoFragment.PLUGIN_INFO;
|
||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
|
||||
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
|
||||
import static net.osmand.plus.monitoring.TripRecordingStartingBottomSheet.UPDATE_LOGGING_INTERVAL;
|
||||
import static net.osmand.plus.monitoring.TripRecordingStartingBottomFragment.UPDATE_LOGGING_INTERVAL;
|
||||
import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID;
|
||||
import static net.osmand.plus.settings.backend.OsmandSettings.MONTHLY_DIRECTORY;
|
||||
import static net.osmand.plus.settings.backend.OsmandSettings.REC_DIRECTORY;
|
||||
|
@ -300,8 +300,8 @@ public class MonitoringSettingsFragment extends BaseSettingsFragment
|
|||
FragmentActivity activity = getActivity();
|
||||
if (activity != null && !activity.isChangingConfigurations()) {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingStartingBottomSheet) {
|
||||
((TripRecordingStartingBottomSheet) target).show(UPDATE_LOGGING_INTERVAL);
|
||||
if (target instanceof TripRecordingStartingBottomFragment) {
|
||||
((TripRecordingStartingBottomFragment) target).show();
|
||||
}
|
||||
}
|
||||
super.onDestroy();
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.google.android.material.slider.Slider;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
|
@ -41,19 +42,25 @@ 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 org.apache.commons.logging.Log;
|
||||
|
||||
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;
|
||||
|
||||
public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandMonitoringPlugin.class);
|
||||
public static final String ID = "osmand.monitoring";
|
||||
public final static String OSMAND_SAVE_SERVICE_ACTION = "OSMAND_SAVE_SERVICE_ACTION";
|
||||
public static final int REQUEST_LOCATION_PERMISSION_FOR_GPX_RECORDING = 208;
|
||||
|
@ -329,9 +336,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 +443,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<Activity> activityRef = activity != null ? new WeakReference<>(activity) : null;
|
||||
|
||||
app.getTaskManager().runInBackground(new OsmAndTaskRunnable<Void, Void, SaveGpxResult>() {
|
||||
|
@ -464,7 +477,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
helper.close();
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -474,10 +487,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<String> singleName = Collections.singletonList(Algorithms.getFileNameWithoutExtension(file));
|
||||
SaveGPXBottomSheetFragment.showInstance(((FragmentActivity) a)
|
||||
.getSupportFragmentManager(), singleName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TrackMenuFragment.openTrack(mapActivity, file, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -523,7 +557,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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 +22,6 @@ 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;
|
||||
|
@ -33,62 +29,53 @@ import androidx.fragment.app.FragmentActivity;
|
|||
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);
|
||||
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 SelectedGpxFile selectedGpxFile;
|
||||
private OsmandMonitoringPlugin plugin;
|
||||
|
||||
private View statusContainer;
|
||||
private AppCompatImageView trackAppearanceIcon;
|
||||
private View buttonSave;
|
||||
private GpxBlockStatisticsBuilder blockStatisticsBuilder;
|
||||
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
private final Handler handler = new Handler();
|
||||
private Runnable updatingGPS;
|
||||
private Runnable updatingTimeTrackSaved;
|
||||
|
||||
private GPXFile getGPXFile() {
|
||||
return selectedGpxFile.getGpxFile();
|
||||
|
@ -98,21 +85,21 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
this.selectedGpxFile = selectedGpxFile;
|
||||
}
|
||||
|
||||
public boolean hasDataToSave() {
|
||||
return app.getSavingTrackHelper().hasDataToSave();
|
||||
private boolean hasDataToSave() {
|
||||
return helper.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);
|
||||
}
|
||||
|
@ -123,39 +110,20 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
helper = app.getSavingTrackHelper();
|
||||
plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
|
||||
selectedGpxFile = helper.getCurrentTrack();
|
||||
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)) {
|
||||
selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
}
|
||||
}
|
||||
blockStatisticsBuilder = new GpxBlockStatisticsBuilder(app, selectedGpxFile);
|
||||
blockStatisticsBuilder.setBlocksView(statBlocks);
|
||||
blockStatisticsBuilder.setBlocksClickable(false);
|
||||
|
@ -164,60 +132,25 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
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(),
|
||||
TripRecordingActiveBottomSheet.this, nightMode, new Runnable() {
|
||||
TripRecordingBottomFragment.this, nightMode, 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 +161,88 @@ 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 && 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@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() {
|
||||
|
@ -295,14 +297,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);
|
||||
}
|
||||
});
|
||||
|
@ -321,30 +323,32 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
});
|
||||
}
|
||||
|
||||
private void createItem(View view, ItemType type, boolean enabled) {
|
||||
createItem(app, nightMode, view, type, enabled, null);
|
||||
public static void setShowTrackItemBackground(View view, boolean checked, boolean nightMode) {
|
||||
Drawable background = AppCompatResources.getDrawable(view.getContext(),
|
||||
checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode));
|
||||
view.setBackgroundDrawable(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) {
|
||||
|
@ -370,151 +374,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) {
|
||||
if (view instanceof CardView) {
|
||||
int colorId = enabled ? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
|
||||
((CardView) view).setCardBackgroundColor(AndroidUtils.createPressedColorStateList(
|
||||
context, colorId, getActiveTextColorId(nightMode)
|
||||
));
|
||||
return;
|
||||
}
|
||||
Drawable background = AppCompatResources.getDrawable(context, getInactiveButtonBackgroundId(nightMode));
|
||||
if (background != null && enabled) {
|
||||
DrawableCompat.setTintList(background, AndroidUtils.createPressedColorStateList(
|
||||
context, getInactiveButtonColorId(nightMode), getActiveTextColorId(nightMode)
|
||||
));
|
||||
} 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<String> 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<MapActivity> 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 {
|
||||
|
@ -525,7 +404,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),
|
||||
|
@ -534,7 +413,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;
|
||||
|
@ -562,32 +443,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) {
|
||||
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) {
|
||||
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);
|
||||
|
@ -596,7 +452,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);
|
||||
|
@ -611,10 +467,17 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface DismissTargetFragment {
|
||||
void dismissTarget();
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public static int getActiveTextColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
|
@ -645,7 +508,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
@ColorRes
|
||||
public static int getActiveTransparentColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.switch_button_active_dark : R.color.switch_button_active_light;
|
||||
}
|
||||
|
@ -665,18 +528,22 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
|||
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);
|
||||
@DrawableRes
|
||||
public static int getInactiveButtonBackgroundId(boolean nightMode) {
|
||||
return nightMode ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_inactive_light;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -11,21 +11,23 @@ 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;
|
||||
|
||||
public static final String TAG = ClearRecordedDataBottomSheetFragment.class.getSimpleName();
|
||||
public class TripRecordingClearDataBottomFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomFragment.DismissTargetFragment {
|
||||
|
||||
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 +39,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("\n").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 +60,7 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
|||
public void onClick(View v) {
|
||||
app.getSavingTrackHelper().clearRecordedData(true);
|
||||
dismiss();
|
||||
dismissTarget();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
@ -78,15 +81,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 +97,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 +106,12 @@ public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogF
|
|||
protected boolean hideButtonsContainer() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissTarget() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingOptionsBottomFragment) {
|
||||
((TripRecordingOptionsBottomFragment) target).dismiss();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,36 +8,28 @@ 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_DISMISS;
|
||||
|
||||
public static final String TAG = StopTrackRecordingBottomFragment.class.getSimpleName();
|
||||
public class TripRecordingDiscardBottomFragment extends MenuBottomSheetDialogFragment implements TripRecordingBottomFragment.DismissTargetFragment {
|
||||
|
||||
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 +38,52 @@ 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);
|
||||
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(getString(R.string.track_recording_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();
|
||||
}
|
||||
})
|
||||
.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();
|
||||
Fragment target = getTargetFragment();
|
||||
if (target != null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||
target.setArguments(args);
|
||||
}
|
||||
dismissTarget();
|
||||
}
|
||||
})
|
||||
.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 +93,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 +109,16 @@ 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();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissTarget() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingOptionsBottomFragment) {
|
||||
((TripRecordingOptionsBottomFragment) target).dismiss();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
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.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 implements TripRecordingBottomFragment.DismissTargetFragment {
|
||||
|
||||
public static final String TAG = TripRecordingOptionsBottomFragment.class.getSimpleName();
|
||||
public static final String ACTION_STOP_AND_DISMISS = "action_stop_and_discard";
|
||||
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) {
|
||||
if (!fragmentManager.isStateSaved()) {
|
||||
TripRecordingOptionsBottomFragment fragment = new TripRecordingOptionsBottomFragment();
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
helper = app.getSavingTrackHelper();
|
||||
selectedGpxFile = helper.getCurrentTrack();
|
||||
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);
|
||||
|
||||
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 onResume() {
|
||||
super.onResume();
|
||||
runUpdatingTimeTrackSaved();
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingBottomFragment) {
|
||||
((TripRecordingBottomFragment) target).hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
stopUpdatingTimeTrackSaved();
|
||||
dismissTarget();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.hide();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
plugin.saveCurrentTrack(null, mapActivity, false, true);
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||
setArguments(args);
|
||||
dismiss();
|
||||
dismissTarget();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private boolean isDiscard() {
|
||||
Bundle args = getArguments();
|
||||
if (args != null) {
|
||||
return args.getBoolean(ACTION_STOP_AND_DISMISS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismissTarget() {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingBottomFragment) {
|
||||
if (isDiscard()) {
|
||||
((TripRecordingBottomFragment) target).dismiss();
|
||||
} else {
|
||||
((TripRecordingBottomFragment) target).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
|
@ -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(showTrackContainer, trackAppearanceIcon, R.string.shared_string_show_on_map,
|
||||
TripRecordingStartingBottomSheet.this, nightMode, new Runnable() {
|
||||
TripRecordingStartingBottomFragment.this, nightMode, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hide();
|
||||
|
@ -130,7 +129,7 @@ public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragm
|
|||
if (mapActivity != null) {
|
||||
hide();
|
||||
BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.MONITORING_SETTINGS,
|
||||
null, new Bundle(), TripRecordingStartingBottomSheet.this);
|
||||
null, new Bundle(), TripRecordingStartingBottomFragment.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -215,24 +214,18 @@ 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();
|
||||
}
|
||||
|
||||
public void show(String... keys) {
|
||||
public void show() {
|
||||
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)) {
|
||||
updateIntervalValue();
|
||||
AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded);
|
||||
}
|
||||
}
|
||||
updateTrackIcon(app, trackAppearanceIcon);
|
||||
updateIntervalValue();
|
||||
AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded);
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
private final Class<? extends LocalRoutingParameter>[] excludeParameters;
|
||||
|
||||
@SafeVarargs
|
||||
DialogMode(Class<? extends LocalRoutingParameter> ... excludeParameters) {
|
||||
DialogMode(Class<? extends LocalRoutingParameter>... excludeParameters) {
|
||||
this.excludeParameters = excludeParameters;
|
||||
}
|
||||
|
||||
|
@ -693,9 +693,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
public static void showInstance(MapActivity mapActivity,
|
||||
Fragment targetFragment,
|
||||
DialogMode dialogMode,
|
||||
String appModeKey) {
|
||||
Fragment targetFragment,
|
||||
DialogMode dialogMode,
|
||||
String appModeKey) {
|
||||
try {
|
||||
FragmentManager fm = mapActivity.getSupportFragmentManager();
|
||||
if (!fm.isStateSaved()) {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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();
|
||||
} else if (target instanceof TripRecordingBottomFragment) {
|
||||
((TripRecordingBottomFragment) target).show(UPDATE_TRACK_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue