Merge remote-tracking branch 'origin/active-trip-rec' into trip_recording_process
# Conflicts: # OsmAnd/res/values/strings.xml # OsmAnd/src/net/osmand/plus/monitoring/OsmandMonitoringPlugin.java # OsmAnd/src/net/osmand/plus/monitoring/TripRecordingActiveBottomSheet.java
This commit is contained in:
commit
fcd16ca99f
9 changed files with 568 additions and 37 deletions
|
@ -11,6 +11,7 @@ public interface OsmAndCustomizationConstants {
|
||||||
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
|
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
|
||||||
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
|
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
|
||||||
String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions";
|
String DRAWER_DIRECTIONS_ID = DRAWER_ITEM_ID_SCHEME + "directions";
|
||||||
|
String DRAWER_TRIP_RECORDING_ID = DRAWER_ITEM_ID_SCHEME + "trip_recording";
|
||||||
String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map";
|
String DRAWER_CONFIGURE_MAP_ID = DRAWER_ITEM_ID_SCHEME + "configure_map";
|
||||||
String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
|
String DRAWER_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
|
||||||
String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live";
|
String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live";
|
||||||
|
|
68
OsmAnd/res/layout/bottom_sheet_item_button_with_icon.xml
Normal file
68
OsmAnd/res/layout/bottom_sheet_item_button_with_icon.xml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/button_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:paddingStart="@dimen/content_padding_small"
|
||||||
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:paddingTop="@dimen/text_margin_small"
|
||||||
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:paddingBottom="@dimen/text_margin_small"
|
||||||
|
tools:background="@drawable/dlg_btn_secondary_dark"
|
||||||
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/button_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="Title"
|
||||||
|
tools:textColor="@color/text_color_secondary_light" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:textColor="@color/text_color_secondary_light"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:letterSpacing="@dimen/description_letter_spacing"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="Description"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="@dimen/map_widget_icon"
|
||||||
|
android:layout_height="@dimen/map_widget_icon"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:layout_marginStart="@dimen/context_menu_padding_margin_large"
|
||||||
|
android:layout_marginLeft="@dimen/context_menu_padding_margin_large"
|
||||||
|
tools:srcCompat="@drawable/ic_action_appearance"
|
||||||
|
tools:tint="@color/icon_color_secondary_light" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -413,4 +413,6 @@
|
||||||
|
|
||||||
<dimen name="radioButtonSize">32dp</dimen>
|
<dimen name="radioButtonSize">32dp</dimen>
|
||||||
<dimen name="checkBoxSize">24dp</dimen>
|
<dimen name="checkBoxSize">24dp</dimen>
|
||||||
|
|
||||||
|
<dimen name="zero">0dp</dimen>
|
||||||
</resources>
|
</resources>
|
|
@ -13,6 +13,10 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<string name="on_pause">On pause</string>
|
<string name="on_pause">On pause</string>
|
||||||
|
<string name="track_recording_description">Are you sure you want to stop recording?\nAll unsaved data will be lost.</string>
|
||||||
|
<string name="track_recording_title">Track recording stopped</string>
|
||||||
|
<string name="track_recording_save_and_stop">Save and stop recording</string>
|
||||||
|
<string name="track_recording_stop_without_saving">Stop without saving</string>
|
||||||
<string name="login_open_place_reviews">Login to OpenPlaceReviews</string>
|
<string name="login_open_place_reviews">Login to OpenPlaceReviews</string>
|
||||||
<string name="opr_use_dev_url">Use test.openplacereviews.org</string>
|
<string name="opr_use_dev_url">Use test.openplacereviews.org</string>
|
||||||
<string name="open_place_reviews">OpenPlaceReviews</string>
|
<string name="open_place_reviews">OpenPlaceReviews</string>
|
||||||
|
|
|
@ -22,6 +22,7 @@ import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities;
|
||||||
|
@ -62,6 +63,8 @@ import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||||
import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet;
|
import net.osmand.plus.measurementtool.StartPlanRouteBottomSheet;
|
||||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||||
|
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet;
|
||||||
|
import net.osmand.plus.monitoring.TripRecordingBottomSheet;
|
||||||
import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment;
|
import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment;
|
||||||
import net.osmand.plus.profiles.ProfileDataObject;
|
import net.osmand.plus.profiles.ProfileDataObject;
|
||||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||||
|
@ -98,6 +101,7 @@ import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_P
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_SCREEN_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_CONFIGURE_SCREEN_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DASHBOARD_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DASHBOARD_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DIRECTIONS_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DIRECTIONS_ID;
|
||||||
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_TRIP_RECORDING_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DIVIDER_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DIVIDER_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DOWNLOAD_MAPS_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_DOWNLOAD_MAPS_ID;
|
||||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_HELP_ID;
|
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_HELP_ID;
|
||||||
|
@ -839,6 +843,22 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
}).createItem());
|
}).createItem());
|
||||||
|
|
||||||
|
boolean isTripRecordingPluginOn = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null;
|
||||||
|
if (isTripRecordingPluginOn) {
|
||||||
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_widget_monitoring, mapActivity)
|
||||||
|
.setId(DRAWER_TRIP_RECORDING_ID)
|
||||||
|
.setIcon(R.drawable.ic_action_track_recordable)
|
||||||
|
.setListener(new ItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||||
|
app.logEvent("trip_recording_open");
|
||||||
|
MapActivity.clearPrevActivityIntent();
|
||||||
|
TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}).createItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||||
.setId(DRAWER_DIRECTIONS_ID)
|
.setId(DRAWER_DIRECTIONS_ID)
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
|
import androidx.annotation.DimenRes;
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
public static final String TAG = ClearRecordedDataBottomSheetFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
app = requiredMyApplication();
|
||||||
|
|
||||||
|
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)
|
||||||
|
.setTitle(app.getString(R.string.clear_recorded_data))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_title_with_description)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
||||||
|
|
||||||
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
|
.setCustomView(setupBtn(inflater, ButtonType.CLEAR))
|
||||||
|
.setOnClickListener(this)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
|
.setCustomView(setupBtn(inflater, ButtonType.CANCEL))
|
||||||
|
.setOnClickListener(this)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private View setupBtn(LayoutInflater inflater, ButtonType type) {
|
||||||
|
View button = inflater.inflate(R.layout.bottom_sheet_item_button_with_icon, null);
|
||||||
|
button.setTag(type);
|
||||||
|
Context context = button.getContext();
|
||||||
|
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
int horizontal = context.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
|
int top = context.getResources().getDimensionPixelSize(type.topMarginRes);
|
||||||
|
int bottom = context.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||||
|
params.setMargins(horizontal, top, horizontal, bottom);
|
||||||
|
button.setLayoutParams(params);
|
||||||
|
|
||||||
|
UiUtilities.setupDialogButton(nightMode, button, type.effect, type.titleId);
|
||||||
|
|
||||||
|
TextViewEx title = button.findViewById(R.id.button_text);
|
||||||
|
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
||||||
|
UiUtilities.setMargins(title, 0, margin, 0, margin);
|
||||||
|
|
||||||
|
int colorRes;
|
||||||
|
if (type.effect == UiUtilities.DialogButtonType.SECONDARY_HARMFUL) {
|
||||||
|
colorRes = R.color.color_osm_edit_delete;
|
||||||
|
} else {
|
||||||
|
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
||||||
|
}
|
||||||
|
AppCompatImageView icon = button.findViewById(R.id.icon);
|
||||||
|
icon.setImageDrawable(getIcon(type.iconRes, colorRes));
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Object o = v.getTag();
|
||||||
|
if (!(o instanceof ButtonType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonType tag = (ButtonType) o;
|
||||||
|
if (tag == ButtonType.CLEAR) {
|
||||||
|
app.getSavingTrackHelper().clearRecordedData(true);
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
// Replace later with tTripRecordingActiveBottomSheet.hide()
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||||
|
Dialog dialog = ((TripRecordingActiveBottomSheet) target).getDialog();
|
||||||
|
if (dialog != null) {
|
||||||
|
dialog.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
// Replace later with tTripRecordingActiveBottomSheet.show()
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||||
|
Dialog dialog = ((TripRecordingActiveBottomSheet) target).getDialog();
|
||||||
|
if (dialog != null) {
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ButtonType {
|
||||||
|
CLEAR(R.string.clear_recorded_data, R.drawable.ic_action_delete_dark, R.dimen.dialog_content_margin, UiUtilities.DialogButtonType.SECONDARY_HARMFUL),
|
||||||
|
CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close, R.dimen.content_padding_small, UiUtilities.DialogButtonType.SECONDARY);
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
private final int titleId;
|
||||||
|
@DrawableRes
|
||||||
|
private final int iconRes;
|
||||||
|
@DimenRes
|
||||||
|
private final int topMarginRes;
|
||||||
|
private final UiUtilities.DialogButtonType effect;
|
||||||
|
|
||||||
|
ButtonType(int titleId, int iconRes, int topMarginRes, UiUtilities.DialogButtonType effect) {
|
||||||
|
this.titleId = titleId;
|
||||||
|
this.iconRes = iconRes;
|
||||||
|
this.topMarginRes = topMarginRes;
|
||||||
|
this.effect = effect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hideButtonsContainer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) {
|
||||||
|
if (!fragmentManager.isStateSaved()) {
|
||||||
|
ClearRecordedDataBottomSheetFragment fragment = new ClearRecordedDataBottomSheetFragment();
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
|
fragment.show(fragmentManager, TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,6 @@ import com.google.android.material.slider.Slider;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
|
||||||
import net.osmand.plus.NavigationService;
|
import net.osmand.plus.NavigationService;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
import net.osmand.plus.OsmAndLocationProvider;
|
||||||
|
@ -44,6 +43,7 @@ import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
|
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
|
||||||
|
import net.osmand.plus.track.TrackDisplayHelper;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.layers.MapInfoLayer;
|
import net.osmand.plus.views.layers.MapInfoLayer;
|
||||||
|
@ -183,7 +183,6 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
private TextInfoWidget createMonitoringControl(final MapActivity map) {
|
private TextInfoWidget createMonitoringControl(final MapActivity map) {
|
||||||
monitoringControl = new TextInfoWidget(map) {
|
monitoringControl = new TextInfoWidget(map) {
|
||||||
long lastUpdateTime;
|
long lastUpdateTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateInfo(DrawSettings drawSettings) {
|
public boolean updateInfo(DrawSettings drawSettings) {
|
||||||
if(isSaving){
|
if(isSaving){
|
||||||
|
@ -320,18 +319,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void controlDialog(final Activity activity, final boolean showTrackSelection) {
|
public void controlDialog(final Activity activity, final boolean showTrackSelection) {
|
||||||
|
final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||||
SavingTrackHelper helper = app.getSavingTrackHelper();
|
|
||||||
SelectedGpxFile selectedGpxFile = helper.getCurrentTrack();
|
|
||||||
boolean hasDataToSave = helper.hasDataToSave();
|
|
||||||
boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
|
||||||
OsmAndLocationProvider locationProvider = app.getLocationProvider();
|
|
||||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
|
||||||
FragmentActivity fragmentActivity = (FragmentActivity) activity;
|
|
||||||
TripRecordingActiveBottomSheet.showInstance(fragmentActivity.getSupportFragmentManager(),
|
|
||||||
selectedGpxFile, wasTrackMonitored, hasDataToSave, lastKnownLocation == null);
|
|
||||||
|
|
||||||
/*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
|
||||||
final boolean nightMode;
|
final boolean nightMode;
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||||
|
@ -340,6 +328,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(UiUtilities.getThemedContext(activity, nightMode));
|
AlertDialog.Builder bld = new AlertDialog.Builder(UiUtilities.getThemedContext(activity, nightMode));
|
||||||
final TIntArrayList items = new TIntArrayList();
|
final TIntArrayList items = new TIntArrayList();
|
||||||
|
FragmentActivity fragmentActivity = (FragmentActivity) activity;
|
||||||
|
TripRecordingActiveBottomSheet.showInstance(fragmentActivity.getSupportFragmentManager());
|
||||||
if (wasTrackMonitored) {
|
if (wasTrackMonitored) {
|
||||||
items.add(R.string.gpx_monitoring_stop);
|
items.add(R.string.gpx_monitoring_stop);
|
||||||
items.add(R.string.gpx_start_new_segment);
|
items.add(R.string.gpx_start_new_segment);
|
||||||
|
@ -428,8 +418,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||||
run.run();
|
run.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bld.show();
|
// bld.show();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCurrentTrack() {
|
public void saveCurrentTrack() {
|
||||||
|
|
|
@ -0,0 +1,187 @@
|
||||||
|
package net.osmand.plus.monitoring;
|
||||||
|
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||||
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
|
|
||||||
|
import androidx.annotation.DimenRes;
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragment implements View.OnClickListener {
|
||||||
|
|
||||||
|
public static final String TAG = StopTrackRecordingBottomFragment.class.getSimpleName();
|
||||||
|
|
||||||
|
private OsmandApplication app;
|
||||||
|
private OsmandSettings settings;
|
||||||
|
private OsmandMonitoringPlugin plugin;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
|
app = requiredMyApplication();
|
||||||
|
settings = app.getSettings();
|
||||||
|
plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
|
||||||
|
|
||||||
|
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)
|
||||||
|
.setTitle(app.getString(R.string.track_recording_title))
|
||||||
|
.setLayoutId(R.layout.bottom_sheet_item_title_with_description)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
||||||
|
|
||||||
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
|
.setCustomView(setupButton(inflater, ButtonType.STOP_AND_DISCARD))
|
||||||
|
.setOnClickListener(this)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
|
.setCustomView(setupButton(inflater, ButtonType.SAVE_AND_STOP))
|
||||||
|
.setOnClickListener(this)
|
||||||
|
.create());
|
||||||
|
|
||||||
|
items.add(new BaseBottomSheetItem.Builder()
|
||||||
|
.setCustomView(setupButton(inflater, ButtonType.CANCEL))
|
||||||
|
.setOnClickListener(this)
|
||||||
|
.create());
|
||||||
|
}
|
||||||
|
|
||||||
|
private View setupButton(LayoutInflater inflater, ButtonType type) {
|
||||||
|
View button = inflater.inflate(R.layout.bottom_sheet_item_button_with_icon, null);
|
||||||
|
button.setTag(type);
|
||||||
|
Context context = button.getContext();
|
||||||
|
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
int horizontal = context.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
|
int top = context.getResources().getDimensionPixelSize(type.topMarginRes);
|
||||||
|
int bottom = context.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||||
|
params.setMargins(horizontal, top, horizontal, bottom);
|
||||||
|
button.setLayoutParams(params);
|
||||||
|
|
||||||
|
UiUtilities.setupDialogButton(nightMode, button, type.effect, type.titleId);
|
||||||
|
|
||||||
|
TextViewEx title = button.findViewById(R.id.button_text);
|
||||||
|
int margin = context.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
||||||
|
UiUtilities.setMargins(title, 0, margin, 0, margin);
|
||||||
|
|
||||||
|
int colorRes;
|
||||||
|
if (type.effect == DialogButtonType.SECONDARY_HARMFUL) {
|
||||||
|
colorRes = R.color.color_osm_edit_delete;
|
||||||
|
} else {
|
||||||
|
colorRes = nightMode ? R.color.dlg_btn_secondary_text_dark : R.color.dlg_btn_secondary_text_light;
|
||||||
|
}
|
||||||
|
AppCompatImageView icon = button.findViewById(R.id.icon);
|
||||||
|
icon.setImageDrawable(getIcon(type.iconRes, colorRes));
|
||||||
|
|
||||||
|
if (type == ButtonType.STOP_AND_DISCARD) {
|
||||||
|
int size = context.getResources().getDimensionPixelSize(R.dimen.map_widget_height);
|
||||||
|
LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(size, size);
|
||||||
|
icon.setLayoutParams(iconParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Object o = v.getTag();
|
||||||
|
if (!(o instanceof ButtonType)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonType tag = (ButtonType) o;
|
||||||
|
if (tag == ButtonType.STOP_AND_DISCARD) {
|
||||||
|
if (plugin != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||||
|
plugin.stopRecording();
|
||||||
|
app.getNotificationHelper().refreshNotifications();
|
||||||
|
}
|
||||||
|
app.getSavingTrackHelper().clearRecordedData(true);
|
||||||
|
} else if (tag == ButtonType.SAVE_AND_STOP) {
|
||||||
|
if (plugin != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||||
|
plugin.saveCurrentTrack();
|
||||||
|
app.getNotificationHelper().refreshNotifications();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
// Replace later with tTripRecordingActiveBottomSheet.hide()
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||||
|
Dialog dialog = ((TripRecordingActiveBottomSheet) target).getDialog();
|
||||||
|
if (dialog != null) {
|
||||||
|
dialog.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
// Replace later with tTripRecordingActiveBottomSheet.show()
|
||||||
|
Fragment target = getTargetFragment();
|
||||||
|
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||||
|
Dialog dialog = ((TripRecordingActiveBottomSheet) target).getDialog();
|
||||||
|
if (dialog != null) {
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ButtonType {
|
||||||
|
STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop, R.dimen.dialog_content_margin, DialogButtonType.SECONDARY_HARMFUL),
|
||||||
|
SAVE_AND_STOP(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file, R.dimen.content_padding_small, DialogButtonType.SECONDARY),
|
||||||
|
CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close, R.dimen.zero, DialogButtonType.SECONDARY);
|
||||||
|
|
||||||
|
@StringRes
|
||||||
|
private final int titleId;
|
||||||
|
@DrawableRes
|
||||||
|
private final int iconRes;
|
||||||
|
@DimenRes
|
||||||
|
private final int topMarginRes;
|
||||||
|
private final DialogButtonType effect;
|
||||||
|
|
||||||
|
ButtonType(int titleId, int iconRes, int topMarginRes, DialogButtonType type) {
|
||||||
|
this.titleId = titleId;
|
||||||
|
this.iconRes = iconRes;
|
||||||
|
this.topMarginRes = topMarginRes;
|
||||||
|
this.effect = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean hideButtonsContainer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fragmentManager, @NonNull Fragment target) {
|
||||||
|
if (!fragmentManager.isStateSaved()) {
|
||||||
|
StopTrackRecordingBottomFragment fragment = new StopTrackRecordingBottomFragment();
|
||||||
|
fragment.setTargetFragment(target, 0);
|
||||||
|
fragment.show(fragmentManager, TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,13 +6,17 @@ import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.text.format.DateUtils;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -25,10 +29,15 @@ import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.appcompat.widget.AppCompatImageView;
|
import androidx.appcompat.widget.AppCompatImageView;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.fragment.app.FragmentActivity;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.GPXUtilities;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmAndLocationProvider;
|
import net.osmand.plus.OsmAndLocationProvider;
|
||||||
|
@ -36,16 +45,25 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
import net.osmand.plus.myplaces.SaveCurrentTrackTask;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.track.GpxBlockStatisticsBuilder;
|
import net.osmand.plus.track.GpxBlockStatisticsBuilder;
|
||||||
|
import net.osmand.plus.track.SaveGpxAsyncTask;
|
||||||
import net.osmand.plus.track.TrackAppearanceFragment;
|
import net.osmand.plus.track.TrackAppearanceFragment;
|
||||||
import net.osmand.plus.widgets.TextViewEx;
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
||||||
|
|
||||||
public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment {
|
public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
@ -65,6 +83,44 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
private final Handler handler = new Handler();
|
private final Handler handler = new Handler();
|
||||||
private Runnable updatingGPS;
|
private Runnable updatingGPS;
|
||||||
|
|
||||||
|
SaveGpxAsyncTask.SaveGpxListener saveGpxListener = new SaveGpxAsyncTask.SaveGpxListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gpxSavingStarted() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void gpxSavingFinished(Exception errorMessage) {
|
||||||
|
String gpxFileName = Algorithms.getFileWithoutDirs(app.getSavingTrackHelper().getCurrentTrack().getGpxFile().path);
|
||||||
|
final MapActivity mapActivity = getMapActivity();
|
||||||
|
final Context context = getContext();
|
||||||
|
SavingTrackHelper helper = app.getSavingTrackHelper();
|
||||||
|
final SavingTrackHelper.SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
|
||||||
|
if (mapActivity != null && context != null) {
|
||||||
|
Snackbar snackbar = Snackbar.make(mapActivity.getLayout(),
|
||||||
|
getString(R.string.shared_string_file_is_saved, gpxFileName),
|
||||||
|
Snackbar.LENGTH_LONG)
|
||||||
|
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
|
final FragmentActivity fragmentActivity = mapActivityRef.get();
|
||||||
|
SaveGPXBottomSheetFragment.showInstance(fragmentActivity.getSupportFragmentManager(), result.getFilenames());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
View view = snackbar.getView();
|
||||||
|
FrameLayout.LayoutParams params = (FrameLayout.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) {
|
public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) {
|
||||||
this.selectedGpxFile = selectedGpxFile;
|
this.selectedGpxFile = selectedGpxFile;
|
||||||
}
|
}
|
||||||
|
@ -81,17 +137,46 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
this.searchingGPS = searchingGPS;
|
this.searchingGPS = searchingGPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile,
|
||||||
|
boolean wasTrackMonitored, boolean hasDataToSave, boolean searchingGPS) {
|
||||||
|
if (!fragmentManager.isStateSaved()) {
|
||||||
|
TripRecordingActiveBottomSheet fragment = new TripRecordingActiveBottomSheet();
|
||||||
|
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||||
|
fragment.setWasTrackMonitored(wasTrackMonitored);
|
||||||
|
fragment.setHasDataToSave(hasDataToSave);
|
||||||
|
fragment.setSearchingGPS(searchingGPS);
|
||||||
|
fragment.show(fragmentManager, TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
app = requiredMyApplication();
|
app = requiredMyApplication();
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
||||||
|
final FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
final Fragment targetFragment = getTargetFragment();
|
||||||
|
|
||||||
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
||||||
items.add(new BottomSheetItemWithDescription.Builder()
|
items.add(new BottomSheetItemWithDescription.Builder()
|
||||||
.setCustomView(itemView)
|
.setCustomView(itemView)
|
||||||
.create());
|
.create());
|
||||||
|
|
||||||
|
long timeTrackSaved = app.getSavingTrackHelper().getLastTimeUpdated();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss:SSS Z");
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||||
|
Date resultDate = new Date(timeTrackSaved);
|
||||||
|
String sdfFormatted = sdf.format(resultDate);
|
||||||
|
CharSequence formattedTimeTrackSaved = null;
|
||||||
|
try {
|
||||||
|
long time = sdf.parse(sdfFormatted).getTime();
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
formattedTimeTrackSaved =
|
||||||
|
DateUtils.getRelativeTimeSpanString(time, now, DateUtils.MINUTE_IN_MILLIS);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
View buttonClear = itemView.findViewById(R.id.button_clear);
|
View buttonClear = itemView.findViewById(R.id.button_clear);
|
||||||
View buttonStart = itemView.findViewById(R.id.button_start);
|
View buttonStart = itemView.findViewById(R.id.button_start);
|
||||||
View buttonSave = itemView.findViewById(R.id.button_save);
|
View buttonSave = itemView.findViewById(R.id.button_save);
|
||||||
|
@ -100,7 +185,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
|
|
||||||
createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave, null);
|
createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave, null);
|
||||||
createItem(buttonStart, ItemType.START_SEGMENT, wasTrackMonitored, null);
|
createItem(buttonStart, ItemType.START_SEGMENT, wasTrackMonitored, null);
|
||||||
createItem(buttonSave, ItemType.SAVE, hasDataToSave, "...");
|
createItem(buttonSave, ItemType.SAVE, hasDataToSave, (String) formattedTimeTrackSaved);
|
||||||
createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true, null);
|
createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true, null);
|
||||||
createItem(buttonStop, ItemType.STOP, true, null);
|
createItem(buttonStop, ItemType.STOP, true, null);
|
||||||
|
|
||||||
|
@ -179,6 +264,32 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
createItem(additionalButton, ItemType.APPEARANCE, checked, null);
|
createItem(additionalButton, ItemType.APPEARANCE, checked, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttonSave.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final GPXUtilities.GPXFile gpxFile = app.getSavingTrackHelper().getCurrentTrack().getGpxFile();
|
||||||
|
new SaveCurrentTrackTask(app, gpxFile, saveGpxListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonStop.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (fragmentManager != null) {
|
||||||
|
StopTrackRecordingBottomFragment.showInstance(fragmentManager, targetFragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonClear.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (fragmentManager != null) {
|
||||||
|
ClearRecordedDataBottomSheetFragment.showInstance(fragmentManager, targetFragment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStatus() {
|
private void updateStatus() {
|
||||||
|
@ -421,16 +532,4 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
|
||||||
protected boolean useVerticalButtons() {
|
protected boolean useVerticalButtons() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fragmentManager, SelectedGpxFile selectedGpxFile,
|
|
||||||
boolean wasTrackMonitored, boolean hasDataToSave, boolean searchingGPS) {
|
|
||||||
if (!fragmentManager.isStateSaved()) {
|
|
||||||
TripRecordingActiveBottomSheet fragment = new TripRecordingActiveBottomSheet();
|
|
||||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
|
||||||
fragment.setWasTrackMonitored(wasTrackMonitored);
|
|
||||||
fragment.setHasDataToSave(hasDataToSave);
|
|
||||||
fragment.setSearchingGPS(searchingGPS);
|
|
||||||
fragment.show(fragmentManager, TAG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue