Merge pull request #10764 from osmandapp/trip_recording_process
Basis for redesigned track recording
This commit is contained in:
commit
8ff6eff178
22 changed files with 1259 additions and 31 deletions
|
@ -11,6 +11,7 @@ public interface OsmAndCustomizationConstants {
|
|||
String DRAWER_MY_PLACES_ID = DRAWER_ITEM_ID_SCHEME + "my_places";
|
||||
String DRAWER_SEARCH_ID = DRAWER_ITEM_ID_SCHEME + "search";
|
||||
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_DOWNLOAD_MAPS_ID = DRAWER_ITEM_ID_SCHEME + "download_maps";
|
||||
String DRAWER_OSMAND_LIVE_ID = DRAWER_ITEM_ID_SCHEME + "osmand_live";
|
||||
|
|
6
OsmAnd/res/drawable-mdpi/btn_background_active_dark.xml
Normal file
6
OsmAnd/res/drawable-mdpi/btn_background_active_dark.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/active_buttons_and_links_bg_pressed_dark" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/inactive_buttons_and_links_bg_dark" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/inactive_buttons_and_links_bg_light" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_bg_pressed_dark" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_bg_pressed_light" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:width="1dp" android:color="@color/inactive_buttons_and_links_bg_dark" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:width="1dp" android:color="@color/inactive_buttons_and_links_bg_light" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
6
OsmAnd/res/drawable/btn_background_active_light.xml
Normal file
6
OsmAnd/res/drawable/btn_background_active_light.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="@color/active_buttons_and_links_bg_pressed_light" />
|
||||
<corners android:radius="3dp" />
|
||||
</shape>
|
70
OsmAnd/res/layout/bottom_sheet_button_with_icon.xml
Normal file
70
OsmAnd/res/layout/bottom_sheet_button_with_icon.xml
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/button_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
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/btn_background_inactive_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:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Title"
|
||||
tools:textColor="@color/active_color_primary_dark" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:duplicateParentState="true"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:visibility="gone"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Description"
|
||||
tools:textColor="@color/text_color_secondary_dark"
|
||||
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:layout_marginStart="@dimen/context_menu_padding_margin_large"
|
||||
android:layout_marginLeft="@dimen/context_menu_padding_margin_large"
|
||||
android:duplicateParentState="true"
|
||||
tools:srcCompat="@drawable/ic_action_appearance"
|
||||
tools:tint="@color/icon_color_active_dark" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -30,6 +30,7 @@
|
|||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:lines="1"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
|
@ -60,6 +61,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:letterSpacing="@dimen/description_letter_spacing"
|
||||
android:gravity="start|center_vertical"
|
||||
android:lines="1"
|
||||
android:maxWidth="@dimen/grid_menu_item_width"
|
||||
|
|
159
OsmAnd/res/layout/trip_recording_active_fragment.xml
Normal file
159
OsmAnd/res/layout/trip_recording_active_fragment.xml
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?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_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>
|
|
@ -12,6 +12,11 @@
|
|||
|
||||
-->
|
||||
|
||||
<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="delete_number_files_question">Delete %1$d files?</string>
|
||||
<string name="shared_strings_all_regions">All regions</string>
|
||||
<string name="restart">Restart</string>
|
||||
|
|
|
@ -62,6 +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.TripRecordingBottomSheet;
|
||||
import net.osmand.plus.osmedit.dialogs.DismissRouteBottomSheetFragment;
|
||||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.profiles.ProfileDataUtils;
|
||||
|
@ -98,6 +100,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_DASHBOARD_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_DOWNLOAD_MAPS_ID;
|
||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_HELP_ID;
|
||||
|
@ -356,10 +359,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public void addActionsToAdapter(final double latitude,
|
||||
final double longitude,
|
||||
final ContextMenuAdapter adapter,
|
||||
Object selectedObj,
|
||||
boolean configureMenu) {
|
||||
final double longitude,
|
||||
final ContextMenuAdapter adapter,
|
||||
Object selectedObj,
|
||||
boolean configureMenu) {
|
||||
ItemBuilder itemBuilder = new ItemBuilder();
|
||||
|
||||
adapter.addItem(itemBuilder
|
||||
|
@ -540,17 +543,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu) {
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFile, from, fromName, useIntermediatePointsByDefault, showMenu, MapRouteInfoMenu.DEFAULT_MENU_STATE);
|
||||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, LatLon from, PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu, int menuState) {
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu, int menuState) {
|
||||
enterRoutePlanningModeGivenGpx(gpxFile, null, from, fromName, useIntermediatePointsByDefault, showMenu, menuState);
|
||||
}
|
||||
|
||||
public void enterRoutePlanningModeGivenGpx(GPXFile gpxFile, ApplicationMode appMode, LatLon from, PointDescription fromName,
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu, int menuState) {
|
||||
boolean useIntermediatePointsByDefault, boolean showMenu, int menuState) {
|
||||
settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(useIntermediatePointsByDefault);
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
TargetPointsHelper targets = app.getTargetPointsHelper();
|
||||
|
@ -840,6 +843,26 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
final OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
|
||||
if (monitoringPlugin != null) {
|
||||
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();
|
||||
if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) {
|
||||
TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack());
|
||||
} else {
|
||||
TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
}
|
||||
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setId(DRAWER_DIRECTIONS_ID)
|
||||
|
@ -1088,7 +1111,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
private String getProfileDescription(OsmandApplication app, ApplicationMode mode,
|
||||
Map<String, ProfileDataObject> profilesObjects, String defaultDescription) {
|
||||
Map<String, ProfileDataObject> profilesObjects, String defaultDescription) {
|
||||
String description = defaultDescription;
|
||||
|
||||
String routingProfileKey = mode.getRoutingProfile();
|
||||
|
|
|
@ -79,6 +79,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
private SelectedGpxFile currentTrack;
|
||||
private int points;
|
||||
private int trkPoints = 0;
|
||||
private long lastTimeFileSaved;
|
||||
|
||||
private ApplicationMode lastRoutingApplicationMode;
|
||||
|
||||
|
@ -258,6 +259,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
GPXTrackAnalysis analysis = gpx.getAnalysis(fout.lastModified());
|
||||
GpxDataItem item = new GpxDataItem(fout, analysis);
|
||||
ctx.getGpxDbHelper().add(item);
|
||||
lastTimeFileSaved = fout.lastModified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -737,6 +739,14 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
return lastTimeUpdated;
|
||||
}
|
||||
|
||||
public long getLastTimeFileSaved() {
|
||||
return lastTimeFileSaved;
|
||||
}
|
||||
|
||||
public void setLastTimeFileSaved(long lastTimeFileSaved) {
|
||||
this.lastTimeFileSaved = lastTimeFileSaved;
|
||||
}
|
||||
|
||||
public GPXFile getCurrentGpx() {
|
||||
return currentTrack.getGpxFile();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
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.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
public class ClearRecordedDataBottomSheetFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = ClearRecordedDataBottomSheetFragment.class.getSimpleName();
|
||||
|
||||
private OsmandApplication app;
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
app = requiredMyApplication();
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
|
||||
int verticalSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||
|
||||
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());
|
||||
|
||||
items.add(new DividerSpaceItem(app, verticalBig));
|
||||
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.CLEAR_DATA, nightMode))
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
app.getSavingTrackHelper().clearRecordedData(true);
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
||||
items.add(new DividerSpaceItem(app, verticalBig));
|
||||
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.CANCEL, nightMode))
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
||||
items.add(new DividerSpaceItem(app, verticalSmall));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||
((TripRecordingActiveBottomSheet) target).hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||
((TripRecordingActiveBottomSheet) target).show();
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -19,18 +17,18 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.AppCompatCheckBox;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmAndTaskManager.OsmAndTaskRunnable;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -52,8 +50,6 @@ import net.osmand.util.Algorithms;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
||||
|
||||
public class OsmandMonitoringPlugin extends OsmandPlugin {
|
||||
|
@ -162,9 +158,9 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static final int[] SECONDS = new int[] {0, 1, 2, 3, 5, 10, 15, 20, 30, 60, 90};
|
||||
public static final int[] MINUTES = new int[] {2, 3, 5};
|
||||
public static final int[] MAX_INTERVAL_TO_SEND_MINUTES = new int[] {1, 2, 5, 10, 15, 20, 30, 60, 90, 2 * 60, 3 * 60, 4 * 60, 6 * 60, 12 * 60, 24 * 60};
|
||||
public static final int[] SECONDS = new int[]{0, 1, 2, 3, 5, 10, 15, 20, 30, 60, 90};
|
||||
public static final int[] MINUTES = new int[]{2, 3, 5};
|
||||
public static final int[] MAX_INTERVAL_TO_SEND_MINUTES = new int[]{1, 2, 5, 10, 15, 20, 30, 60, 90, 2 * 60, 3 * 60, 4 * 60, 6 * 60, 12 * 60, 24 * 60};
|
||||
|
||||
@Override
|
||||
public SettingsScreenType getSettingsScreenType() {
|
||||
|
@ -182,9 +178,10 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
private TextInfoWidget createMonitoringControl(final MapActivity map) {
|
||||
monitoringControl = new TextInfoWidget(map) {
|
||||
long lastUpdateTime;
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
if(isSaving){
|
||||
if (isSaving) {
|
||||
setText(map.getString(R.string.shared_string_save), "");
|
||||
setIcons(R.drawable.widget_monitoring_rec_big_day, R.drawable.widget_monitoring_rec_big_night);
|
||||
return true;
|
||||
|
@ -212,7 +209,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
final boolean liveMonitoringEnabled = liveMonitoringHelper.isLiveMonitoringEnabled();
|
||||
if(globalRecord) {
|
||||
if (globalRecord) {
|
||||
//indicates global recording (+background recording)
|
||||
if (liveMonitoringEnabled) {
|
||||
dn = R.drawable.widget_live_monitoring_rec_big_night;
|
||||
|
@ -317,8 +314,27 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public SelectedGpxFile getCurrentTrack() {
|
||||
return app.getSavingTrackHelper().getCurrentTrack();
|
||||
}
|
||||
|
||||
public boolean wasTrackMonitored() {
|
||||
return settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||
}
|
||||
|
||||
public boolean hasDataToSave() {
|
||||
return app.getSavingTrackHelper().hasDataToSave();
|
||||
}
|
||||
|
||||
public void controlDialog(final Activity activity, final boolean showTrackSelection) {
|
||||
final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||
FragmentManager fragmentManager = ((FragmentActivity) activity).getSupportFragmentManager();
|
||||
if (hasDataToSave() || wasTrackMonitored()) {
|
||||
TripRecordingActiveBottomSheet.showInstance(fragmentManager, getCurrentTrack());
|
||||
} else {
|
||||
TripRecordingBottomSheet.showInstance(fragmentManager);
|
||||
}
|
||||
|
||||
/*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
|
||||
final boolean nightMode;
|
||||
if (activity instanceof MapActivity) {
|
||||
nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
|
@ -415,8 +431,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
run.run();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
}
|
||||
// bld.show();
|
||||
}*/
|
||||
}
|
||||
|
||||
public void saveCurrentTrack() {
|
||||
|
@ -478,7 +494,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public void stopRecording(){
|
||||
public void stopRecording() {
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(false);
|
||||
if (app.getNavigationService() != null) {
|
||||
app.getNavigationService().stopIfNeeded(app, NavigationService.USED_BY_GPX);
|
||||
|
@ -536,7 +552,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
public static LinearLayout createIntervalChooseLayout(final OsmandApplication app,
|
||||
final Context uiCtx,
|
||||
final Context uiCtx,
|
||||
final String patternMsg, final int[] seconds,
|
||||
final int[] minutes, final ValueHolder<Boolean> choice,
|
||||
final ValueHolder<Integer> v,
|
||||
|
@ -567,11 +583,11 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
String s;
|
||||
int progress = (int) value;
|
||||
if(progress == 0) {
|
||||
if (progress == 0) {
|
||||
s = uiCtx.getString(R.string.int_continuosly);
|
||||
v.value = 0;
|
||||
} else {
|
||||
if(progress < secondsLength) {
|
||||
if (progress < secondsLength) {
|
||||
s = seconds[progress] + " " + uiCtx.getString(R.string.int_seconds);
|
||||
v.value = seconds[progress] * 1000;
|
||||
} else {
|
||||
|
@ -596,7 +612,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(tv);
|
||||
ll.addView(sliderContainer);
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
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 androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
public class StopTrackRecordingBottomFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = StopTrackRecordingBottomFragment.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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
plugin = OsmandPlugin.getPlugin(OsmandMonitoringPlugin.class);
|
||||
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||
int verticalBig = getResources().getDimensionPixelSize(R.dimen.dialog_content_margin);
|
||||
int verticalSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||
|
||||
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());
|
||||
|
||||
items.add(new DividerSpaceItem(app, verticalBig));
|
||||
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.STOP_AND_DISCARD, nightMode))
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
tag = ItemType.STOP_AND_DISCARD;
|
||||
if (plugin != null && settings.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(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.SAVE_AND_STOP, nightMode))
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
tag = ItemType.SAVE_AND_STOP;
|
||||
if (plugin != null && settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
|
||||
plugin.saveCurrentTrack(null, mapActivity);
|
||||
app.getNotificationHelper().refreshNotifications();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
||||
items.add(new DividerSpaceItem(app, verticalSmall));
|
||||
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(TripRecordingActiveBottomSheet.createButton(inflater, ItemType.CANCEL, nightMode))
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
tag = ItemType.CANCEL;
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create());
|
||||
|
||||
items.add(new DividerSpaceItem(app, verticalSmall));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||
((TripRecordingActiveBottomSheet) target).hide();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (tag == ItemType.CANCEL) {
|
||||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingActiveBottomSheet) {
|
||||
((TripRecordingActiveBottomSheet) target).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hideButtonsContainer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void showInstance(MapActivity mapActivity, @NonNull FragmentManager fragmentManager, @NonNull Fragment target) {
|
||||
if (!fragmentManager.isStateSaved()) {
|
||||
StopTrackRecordingBottomFragment fragment = new StopTrackRecordingBottomFragment();
|
||||
fragment.setMapActivity(mapActivity);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,645 @@
|
|||
package net.osmand.plus.monitoring;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.TypedValue;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.graphics.drawable.DrawableCompat;
|
||||
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.PlatformUtil;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
import net.osmand.plus.myplaces.SaveCurrentTrackTask;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.track.GpxBlockStatisticsBuilder;
|
||||
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 static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
|
||||
|
||||
public class TripRecordingActiveBottomSheet 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";
|
||||
private static final int GENERAL_UPDATE_GPS_INTERVAL = 1000;
|
||||
private static final int GENERAL_UPDATE_SAVE_INTERVAL = 1000;
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
private SavingTrackHelper helper;
|
||||
private SelectedGpxFile selectedGpxFile;
|
||||
|
||||
private View statusContainer;
|
||||
private View buttonSave;
|
||||
private GpxBlockStatisticsBuilder blockStatisticsBuilder;
|
||||
|
||||
private final Handler handler = new Handler();
|
||||
private Runnable updatingGPS;
|
||||
private Runnable updatingTimeTrackSaved;
|
||||
|
||||
private GPXFile getGPXFile() {
|
||||
return selectedGpxFile.getGpxFile();
|
||||
}
|
||||
|
||||
public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) {
|
||||
this.selectedGpxFile = selectedGpxFile;
|
||||
}
|
||||
|
||||
public boolean hasDataToSave() {
|
||||
return app.getSavingTrackHelper().hasDataToSave();
|
||||
}
|
||||
|
||||
public boolean searchingGPS() {
|
||||
return app.getLocationProvider().getLastKnownLocation() == null;
|
||||
}
|
||||
|
||||
public 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();
|
||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
app = requiredMyApplication();
|
||||
settings = app.getSettings();
|
||||
helper = app.getSavingTrackHelper();
|
||||
LayoutInflater inflater = UiUtilities.getInflater(getContext(), nightMode);
|
||||
final FragmentManager fragmentManager = getFragmentManager();
|
||||
|
||||
View itemView = inflater.inflate(R.layout.trip_recording_active_fragment, null, false);
|
||||
items.add(new BaseBottomSheetItem.Builder()
|
||||
.setCustomView(itemView)
|
||||
.create());
|
||||
|
||||
View buttonClear = itemView.findViewById(R.id.button_clear);
|
||||
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(), null);
|
||||
createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored(), null);
|
||||
createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true, null);
|
||||
createItem(buttonStop, ItemType.STOP, true, null);
|
||||
|
||||
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);
|
||||
blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode);
|
||||
|
||||
LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map);
|
||||
showTrackContainer.setMinimumHeight(app.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_list_item_height));
|
||||
|
||||
final LinearLayout buttonShow = showTrackContainer.findViewById(R.id.basic_item_body);
|
||||
TextView showTrackTitle = buttonShow.findViewById(R.id.title);
|
||||
Integer showTitle = ItemType.SHOW_TRACK.getTitleId();
|
||||
if (showTitle != null) {
|
||||
showTrackTitle.setText(showTitle);
|
||||
}
|
||||
showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode)));
|
||||
showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size));
|
||||
Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium));
|
||||
showTrackTitle.setTypeface(typeface);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
float letterSpacing = AndroidUtils.getFloatValueFromRes(app, R.dimen.description_letter_spacing);
|
||||
showTrackTitle.setLetterSpacing(letterSpacing);
|
||||
}
|
||||
final SwitchCompat showTrackOnMapButton = buttonShow.findViewById(R.id.switch_button);
|
||||
showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
|
||||
UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT);
|
||||
|
||||
final LinearLayout buttonAppearance = showTrackContainer.findViewById(R.id.additional_button);
|
||||
View divider = buttonAppearance.getChildAt(0);
|
||||
AndroidUiHelper.setVisibility(View.GONE, divider);
|
||||
int marginS = app.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_small);
|
||||
UiUtilities.setMargins(buttonAppearance, marginS, 0, 0, 0);
|
||||
String width = settings.CURRENT_TRACK_WIDTH.get();
|
||||
boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get();
|
||||
int color = settings.CURRENT_TRACK_COLOR.get();
|
||||
Drawable appearanceDrawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color);
|
||||
AppCompatImageView appearanceIcon = buttonAppearance.findViewById(R.id.icon_after_divider);
|
||||
int marginTrackIconH = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||
UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0);
|
||||
appearanceIcon.setImageDrawable(appearanceDrawable);
|
||||
buttonAppearance.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (showTrackOnMapButton.isChecked()) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
hide();
|
||||
SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
|
||||
TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingActiveBottomSheet.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
createItem(buttonAppearance, ItemType.APPEARANCE, showTrackOnMapButton.isChecked(), null);
|
||||
setShowOnMapBackground(buttonShow, app, showTrackOnMapButton.isChecked(), nightMode);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
buttonShow.setBackgroundTintList(null);
|
||||
}
|
||||
buttonShow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean checked = !showTrackOnMapButton.isChecked();
|
||||
showTrackOnMapButton.setChecked(checked);
|
||||
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false);
|
||||
createItem(buttonAppearance, ItemType.APPEARANCE, checked, null);
|
||||
setShowOnMapBackground(buttonShow, app, checked, nightMode);
|
||||
}
|
||||
});
|
||||
|
||||
buttonClear.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (fragmentManager != null && hasDataToSave()) {
|
||||
ClearRecordedDataBottomSheetFragment.showInstance(fragmentManager, TripRecordingActiveBottomSheet.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean wasTrackMonitored = !wasTrackMonitored();
|
||||
if (!wasTrackMonitored) {
|
||||
blockStatisticsBuilder.stopUpdatingStatBlocks();
|
||||
} else {
|
||||
blockStatisticsBuilder.runUpdatingStatBlocksIfNeeded();
|
||||
}
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored);
|
||||
updateStatus();
|
||||
createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true, null);
|
||||
}
|
||||
});
|
||||
|
||||
buttonStop.findViewById(R.id.button_container).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (fragmentManager != null) {
|
||||
StopTrackRecordingBottomFragment.showInstance(getMapActivity(), fragmentManager, TripRecordingActiveBottomSheet.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(UPDATE_CURRENT_GPX_FILE, true);
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
TextView statusTitle = statusContainer.findViewById(R.id.text_status);
|
||||
AppCompatImageView statusIcon = statusContainer.findViewById(R.id.icon_status);
|
||||
ItemType status = searchingGPS() ? ItemType.SEARCHING_GPS : !wasTrackMonitored() ? ItemType.ON_PAUSE : ItemType.RECORDING;
|
||||
Integer titleId = status.getTitleId();
|
||||
if (titleId != null) {
|
||||
statusTitle.setText(titleId);
|
||||
}
|
||||
int colorText = status.equals(ItemType.SEARCHING_GPS) ? getSecondaryTextColorId(nightMode) : getOsmandIconColorId(nightMode);
|
||||
statusTitle.setTextColor(ContextCompat.getColor(app, colorText));
|
||||
Integer iconId = status.getIconId();
|
||||
if (iconId != null) {
|
||||
int colorDrawable = ContextCompat.getColor(app,
|
||||
status.equals(ItemType.SEARCHING_GPS) ? getSecondaryIconColorId(nightMode) : getOsmandIconColorId(nightMode));
|
||||
Drawable statusDrawable = UiUtilities.tintDrawable(AppCompatResources.getDrawable(app, iconId), colorDrawable);
|
||||
statusIcon.setImageDrawable(statusDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
private void createItem(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) {
|
||||
setTintedIcon(icon, enabled, nightMode, type);
|
||||
}
|
||||
|
||||
TextView title = view.findViewById(R.id.button_text);
|
||||
Integer titleId = type.getTitleId();
|
||||
if (title != null && titleId != null) {
|
||||
title.setText(titleId);
|
||||
setTextColor(title, enabled, nightMode, type);
|
||||
}
|
||||
|
||||
TextViewEx desc = view.findViewById(R.id.desc);
|
||||
if (desc != null) {
|
||||
boolean isShowDesc = !Algorithms.isBlank(description);
|
||||
int marginDesc = isShowDesc ? 0 : app.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_medium);
|
||||
AndroidUiHelper.updateVisibility(desc, isShowDesc);
|
||||
if (title != null) {
|
||||
UiUtilities.setMargins(title, 0, marginDesc, 0, marginDesc);
|
||||
}
|
||||
desc.setText(description);
|
||||
setTextColor(desc, false, nightMode, type);
|
||||
}
|
||||
|
||||
setItemBackground(button != null ? button : (LinearLayout) view, enabled);
|
||||
}
|
||||
|
||||
protected static View createButton(LayoutInflater inflater, ItemType type, boolean nightMode) {
|
||||
View button = inflater.inflate(R.layout.bottom_sheet_button_with_icon, null);
|
||||
button.setTag(type);
|
||||
Context context = button.getContext();
|
||||
LinearLayout container = button.findViewById(R.id.button_container);
|
||||
container.setClickable(false);
|
||||
container.setFocusable(false);
|
||||
|
||||
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);
|
||||
|
||||
if (type.getTitleId() != null) {
|
||||
UiUtilities.setupDialogButton(nightMode, button, type.getEffect(), type.getTitleId());
|
||||
}
|
||||
|
||||
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.getEffect() == 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);
|
||||
if (type.getIconId() != null) {
|
||||
Drawable drawable = AppCompatResources.getDrawable(context, type.getIconId());
|
||||
UiUtilities.tintDrawable(drawable, ContextCompat.getColor(context, colorRes));
|
||||
icon.setImageDrawable(drawable);
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
String gpxFileName = Algorithms.getFileWithoutDirs(getGPXFile().path);
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
final Context context = getContext();
|
||||
final SaveGpxResult result = helper.saveDataToGpx(app.getAppCustomization().getTracksDir());
|
||||
if (mapActivity != null && context != null) {
|
||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||
final FragmentManager fragmentManager = mapActivityRef.get().getSupportFragmentManager();
|
||||
@SuppressLint({"StringFormatInvalid", "LocalSuppress"})
|
||||
Snackbar snackbar = Snackbar.make(getView(),
|
||||
app.getResources().getString(R.string.shared_string_file_is_saved, gpxFileName),
|
||||
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 hide() {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.hide();
|
||||
}
|
||||
}
|
||||
|
||||
public enum ItemType {
|
||||
SHOW_TRACK(R.string.shared_string_show_on_map, null, null),
|
||||
APPEARANCE(null, null, null),
|
||||
SEARCHING_GPS(R.string.searching_gps, R.drawable.ic_action_gps_info, null),
|
||||
RECORDING(R.string.recording_default_name, R.drawable.ic_action_track_recordable, null),
|
||||
ON_PAUSE(R.string.on_pause, R.drawable.ic_pause, null),
|
||||
CLEAR_DATA(R.string.clear_recorded_data, R.drawable.ic_action_delete_dark, UiUtilities.DialogButtonType.SECONDARY_HARMFUL),
|
||||
START_SEGMENT(R.string.gpx_start_new_segment, R.drawable.ic_action_new_segment, null),
|
||||
SAVE(R.string.shared_string_save, R.drawable.ic_action_save_to_file, null),
|
||||
PAUSE(R.string.shared_string_pause, R.drawable.ic_pause, null),
|
||||
RESUME(R.string.shared_string_resume, R.drawable.ic_play_dark, null),
|
||||
STOP(R.string.shared_string_control_stop, R.drawable.ic_action_rec_stop, null),
|
||||
STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop, DialogButtonType.SECONDARY_HARMFUL),
|
||||
SAVE_AND_STOP(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file, DialogButtonType.SECONDARY),
|
||||
CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close, DialogButtonType.SECONDARY);
|
||||
|
||||
@StringRes
|
||||
private final Integer titleId;
|
||||
@DrawableRes
|
||||
private final Integer iconId;
|
||||
private final DialogButtonType effect;
|
||||
|
||||
ItemType(@Nullable @StringRes Integer titleId, @Nullable @DrawableRes Integer iconId, @Nullable DialogButtonType effect) {
|
||||
this.titleId = titleId;
|
||||
this.iconId = iconId;
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getTitleId() {
|
||||
return titleId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getIconId() {
|
||||
return iconId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DialogButtonType getEffect() {
|
||||
return effect;
|
||||
}
|
||||
}
|
||||
|
||||
private void setItemBackground(LinearLayout view, boolean enabled) {
|
||||
Drawable background = AppCompatResources.getDrawable(app, R.drawable.btn_background_inactive_light);
|
||||
if (background != null && enabled) {
|
||||
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
|
||||
app, getInactiveButtonColorId(nightMode), getActiveButtonColorId(nightMode)
|
||||
);
|
||||
DrawableCompat.setTintList(background, iconColorStateList);
|
||||
} else {
|
||||
UiUtilities.tintDrawable(background, ContextCompat.getColor(app, getInactiveButtonColorId(nightMode)));
|
||||
}
|
||||
view.setBackgroundDrawable(background);
|
||||
}
|
||||
|
||||
private static void setShowOnMapBackground(LinearLayout view, Context context, boolean checked, boolean nightMode) {
|
||||
Drawable background = AppCompatResources.getDrawable(context,
|
||||
nightMode ? checked ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_stroked_inactive_dark
|
||||
: checked ? R.drawable.btn_background_inactive_light : R.drawable.btn_background_stroked_inactive_light);
|
||||
view.setBackgroundDrawable(background);
|
||||
}
|
||||
|
||||
public void setTextColor(TextView tv, boolean enabled, boolean nightMode, ItemType type) {
|
||||
if (tv != null) {
|
||||
int activeColorId = type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete : getActiveTextColorId(nightMode);
|
||||
int normalColorId = enabled ? activeColorId : getSecondaryTextColorId(nightMode);
|
||||
ColorStateList textColorStateList = AndroidUtils.createPressedColorStateList(app, normalColorId, getPressedColorId(nightMode));
|
||||
tv.setTextColor(textColorStateList);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTintedIcon(AppCompatImageView iv, boolean enabled, boolean nightMode, ItemType type) {
|
||||
Integer iconId = type.getIconId();
|
||||
if (iv != null && iconId != null) {
|
||||
Drawable icon = AppCompatResources.getDrawable(app, iconId);
|
||||
int activeColorId = type == ItemType.CLEAR_DATA ? R.color.color_osm_edit_delete : getActiveIconColorId(nightMode);
|
||||
int normalColorId = enabled ? activeColorId : getSecondaryIconColorId(nightMode);
|
||||
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(app, normalColorId, getPressedColorId(nightMode));
|
||||
if (icon != null) {
|
||||
DrawableCompat.setTintList(icon, iconColorStateList);
|
||||
}
|
||||
iv.setImageDrawable(icon);
|
||||
if (type == ItemType.STOP) {
|
||||
int stopSize = iv.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(stopSize, stopSize);
|
||||
iv.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getActiveTextColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getSecondaryTextColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.text_color_secondary_dark : R.color.text_color_secondary_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getActiveIconColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.icon_color_active_dark : R.color.icon_color_active_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getSecondaryIconColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_secondary_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getActiveButtonColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.active_buttons_and_links_bg_pressed_dark : R.color.active_buttons_and_links_bg_pressed_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getInactiveButtonColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.inactive_buttons_and_links_bg_dark : R.color.inactive_buttons_and_links_bg_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getOsmandIconColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light;
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
private static int getPressedColorId(boolean nightMode) {
|
||||
return nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonHeight() {
|
||||
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_close;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean useVerticalButtons() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.SavingTrackHelper;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -246,12 +247,12 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int getRightButtonHeight(){
|
||||
protected int getRightButtonHeight() {
|
||||
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonHeight(){
|
||||
protected int getDismissButtonHeight() {
|
||||
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
|
||||
}
|
||||
|
||||
|
@ -277,9 +278,14 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
|
||||
@Override
|
||||
protected void onRightBottomButtonClick() {
|
||||
app.getSavingTrackHelper().startNewSegment();
|
||||
SavingTrackHelper helper = app.getSavingTrackHelper();
|
||||
helper.startNewSegment();
|
||||
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
|
||||
app.startNavigationService(NavigationService.USED_BY_GPX);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack());
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,10 @@ public class SaveCurrentTrackTask extends AsyncTask<Void, Void, Boolean> {
|
|||
}
|
||||
for (final String f : files.keySet()) {
|
||||
File fout = new File(dir, f + IndexConstants.GPX_FILE_EXT);
|
||||
GPXUtilities.writeGpxFile(fout, gpx);
|
||||
Exception exception = GPXUtilities.writeGpxFile(fout, gpx);
|
||||
if (exception == null) {
|
||||
app.getSavingTrackHelper().setLastTimeFileSaved(fout.lastModified());
|
||||
}
|
||||
}
|
||||
return shouldClearPath;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ 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.TripRecordingBottomSheet;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
|
||||
|
@ -383,6 +384,8 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
|
|||
Fragment target = getTargetFragment();
|
||||
if (target instanceof TripRecordingBottomSheet) {
|
||||
((TripRecordingBottomSheet) target).show();
|
||||
} else if (target instanceof TripRecordingActiveBottomSheet) {
|
||||
((TripRecordingActiveBottomSheet) target).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue