redesign trip recording start dialog

This commit is contained in:
Skalii 2021-03-17 20:16:44 +02:00
parent 130a2889c3
commit c90a74956a
17 changed files with 712 additions and 450 deletions

View 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/switch_button_active_light" />
<corners android:radius="4dp" />
</shape>

View 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/switch_button_active_dark" />
<corners android:radius="4dp" />
</shape>

View file

@ -4,48 +4,58 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:baselineAligned="false" android:baselineAligned="false"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"> android:minHeight="@dimen/bottom_sheet_list_item_height">
<androidx.cardview.widget.CardView
android:id="@+id/compound_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/content_padding_half"
android:layout_marginRight="@dimen/content_padding_half"
android:layout_weight="1"
android:gravity="center_vertical"
app:cardBackgroundColor="?attr/switch_button_active"
app:cardCornerRadius="4dp"
app:cardElevation="0dp">
<LinearLayout <LinearLayout
android:id="@+id/basic_item_body" android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/content_padding" android:orientation="horizontal">
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<LinearLayout <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginTop="@dimen/context_menu_first_line_top_margin"
android:layout_marginBottom="@dimen/context_menu_first_line_top_margin"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="1" android:maxLines="1"
android:paddingTop="@dimen/content_padding_small" android:textColor="?attr/active_color_basic"
android:paddingBottom="@dimen/content_padding" android:textSize="@dimen/default_desc_text_size"
android:textAppearance="@style/TextAppearance.ListItemTitle" app:typeface="@string/font_roboto_medium"
tools:text="Some title" /> tools:text="Some title" />
</LinearLayout>
<com.google.android.material.switchmaterial.SwitchMaterial <com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switch_button" android:id="@+id/compound_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/bottom_sheet_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
android:focusableInTouchMode="false" android:focusableInTouchMode="false"
@ -53,31 +63,37 @@
</LinearLayout> </LinearLayout>
<LinearLayout </androidx.cardview.widget.CardView>
android:id="@+id/additional_button"
<androidx.cardview.widget.CardView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"> app:cardBackgroundColor="?attr/switch_button_active"
app:cardCornerRadius="4dp"
app:cardElevation="0dp">
<View <LinearLayout
android:layout_width="1dp" android:id="@+id/additional_button"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="@dimen/content_padding_half" android:background="?android:attr/selectableItemBackground"
android:layout_marginBottom="@dimen/content_padding_half" android:clickable="true"
android:background="?attr/divider_color_basic" /> android:focusable="true"
android:gravity="center">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon_after_divider" android:id="@+id/additional_button_icon"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/favorites_icon_right_margin" android:layout_width="@dimen/favorites_icon_right_margin"
android:layout_height="@dimen/favorites_icon_right_margin" android:layout_height="@dimen/favorites_icon_right_margin"
android:layout_gravity="center"
android:layout_marginStart="@dimen/content_padding" android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding" android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding" android:layout_marginRight="@dimen/content_padding"
app:srcCompat="@drawable/ic_action_track_line_bold_color" /> app:srcCompat="@drawable/ic_action_track_line_bold_color"
tools:tint="?attr/active_color_basic" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height"
app:cardCornerRadius="4dp"
app:cardElevation="0dp"
tools:cardBackgroundColor="?attr/switch_button_active">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginBottom="@dimen/content_padding_small_half"
tools:srcCompat="@drawable/ic_action_close"
tools:tint="?attr/active_color_basic" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding_small_half"
android:layout_marginLeft="@dimen/content_padding_small_half"
android:layout_marginEnd="@dimen/content_padding_small_half"
android:layout_marginRight="@dimen/content_padding_small_half"
android:layout_marginBottom="@dimen/content_padding_small_half"
android:letterSpacing="@dimen/description_letter_spacing"
app:typeface="@string/font_roboto_medium"
tools:text="Title"
tools:textColor="?attr/active_color_basic" />
</LinearLayout>
</androidx.cardview.widget.CardView>

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:baselineAligned="false"
android:minHeight="@dimen/setting_list_item_large_height"
android:orientation="horizontal">
<include
android:id="@+id/button_left"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" />
<include
android:id="@+id/button_center_left"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" />
<include
android:id="@+id/button_center_right"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_weight="1"
android:layout_marginLeft="@dimen/content_padding_half"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" />
<include
android:id="@+id/button_right"
android:layout_weight="1"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" />
</LinearLayout>

View file

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:baselineAligned="false"
android:minHeight="@dimen/setting_list_item_large_height"
android:orientation="horizontal">
<include
android:id="@+id/button_left"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" />
<include
android:id="@+id/button_center"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_weight="0.5"
android:minWidth="@dimen/button_triple_center_width"
android:minHeight="@dimen/setting_list_item_large_height" />
<include
android:id="@+id/button_right"
layout="@layout/preference_button_with_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/content_padding_half"
android:layout_marginLeft="@dimen/content_padding_half"
android:layout_weight="0.25"
android:minWidth="@dimen/context_menu_top_right_button_min_width"
android:minHeight="@dimen/setting_list_item_large_height" />
</LinearLayout>

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical"
android:paddingBottom="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title" android:id="@+id/title"
@ -20,7 +20,7 @@
android:paddingBottom="@dimen/content_padding_small" android:paddingBottom="@dimen/content_padding_small"
android:text="@string/monitoring_settings" android:text="@string/monitoring_settings"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" /> app:typeface="@string/font_roboto_medium" />
<include <include
android:id="@+id/show_track_on_map" android:id="@+id/show_track_on_map"
@ -29,22 +29,23 @@
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding"
android:background="?attr/dashboard_divider" /> android:background="?attr/dashboard_divider" />
<LinearLayout <LinearLayout
android:id="@+id/interval_view_container" android:id="@+id/interval_view_container"
android:background="?attr/selectableItemBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingStart="@dimen/content_padding" android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding" android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_content_margin" android:paddingTop="@dimen/bottom_sheet_content_margin"
android:paddingBottom="@dimen/bottom_sheet_content_margin"
android:paddingEnd="@dimen/content_padding" android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"> android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/bottom_sheet_content_margin">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/interval_value" android:id="@+id/interval_value"
@ -62,6 +63,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null" android:background="@null"
app:srcCompat="@drawable/ic_action_arrow_down" /> app:srcCompat="@drawable/ic_action_arrow_down" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@ -84,34 +86,71 @@
app:labelBehavior="gone" app:labelBehavior="gone"
app:thumbColor="@color/profile_icon_color_blue_light" app:thumbColor="@color/profile_icon_color_blue_light"
app:thumbRadius="@dimen/content_padding_small_half" app:thumbRadius="@dimen/content_padding_small_half"
app:tickColorInactive="#007EB3"
app:trackColorActive="@color/profile_icon_color_blue_light" app:trackColorActive="@color/profile_icon_color_blue_light"
app:trackColorInactive="#4D007EB3" app:trackColorInactive="#4D007EB3"
app:tickColorInactive="#007EB3"
app:trackHeight="@dimen/slider_track_height" app:trackHeight="@dimen/slider_track_height"
tools:visibility="visible" /> tools:visibility="visible" />
<androidx.appcompat.widget.SwitchCompat <androidx.cardview.widget.CardView
android:id="@+id/confirm_every_run" android:id="@+id/confirm_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/switch_button_active"
app:cardCornerRadius="4dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:letterSpacing="@dimen/text_button_letter_spacing" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/context_menu_buttons_bottom_height" android:orientation="horizontal">
android:paddingLeft="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small" <net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/content_padding_small"
android:layout_marginTop="@dimen/context_menu_first_line_top_margin"
android:layout_marginBottom="@dimen/context_menu_first_line_top_margin"
android:layout_weight="1"
android:ellipsize="end"
android:letterSpacing="@dimen/description_letter_spacing"
android:maxLines="1"
android:text="@string/confirm_every_run" android:text="@string/confirm_every_run"
android:textColor="?attr/color_dialog_buttons" android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular" app:typeface="@string/font_roboto_regular" />
tools:visibility="visible" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/confirm_compound_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginEnd="@dimen/content_padding_small"
android:layout_marginRight="@dimen/content_padding_small"
tools:checked="true" />
</LinearLayout> </LinearLayout>
<View </androidx.cardview.widget.CardView>
android:id="@+id/second_divider"
<TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="wrap_content"
android:background="?attr/dashboard_divider" /> android:layout_marginTop="@dimen/content_padding_small_half"
android:letterSpacing="@dimen/description_letter_spacing"
android:text="@string/trip_recording_logging_interval_info"
android:textColor="?attr/dialog_text_description_color" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="@dimen/content_padding" />
<include layout="@layout/preference_button_with_icon_triple" />
</LinearLayout> </LinearLayout>

View file

@ -418,4 +418,5 @@
<dimen name="descriptionLineSpacingExtra">3sp</dimen> <dimen name="descriptionLineSpacingExtra">3sp</dimen>
<dimen name="list_item_triple_row_height">80dp</dimen> <dimen name="list_item_triple_row_height">80dp</dimen>
<dimen name="button_triple_center_width">160dp</dimen>
</resources> </resources>

View file

@ -11,6 +11,7 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="trip_recording_logging_interval_info">Logging interval set time period in which OsmAnd will ask for the current location position data.</string>
<string name="select_another_colorization">Please select another type of colorization.</string> <string name="select_another_colorization">Please select another type of colorization.</string>
<string name="track_has_no_speed">The track does not contain speed data.</string> <string name="track_has_no_speed">The track does not contain speed data.</string>
<string name="track_has_no_altitude">The track does not contain altitude data.</string> <string name="track_has_no_altitude">The track does not contain altitude data.</string>

View file

@ -93,7 +93,6 @@ import net.osmand.plus.importfiles.ImportHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment; import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment;
import net.osmand.plus.mapcontextmenu.editors.SelectFavoriteCategoryBottomSheet;
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu; import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu; import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.mapmarkers.MapMarker; import net.osmand.plus.mapmarkers.MapMarker;
@ -105,7 +104,7 @@ import net.osmand.plus.measurementtool.LoginBottomSheetFragment;
import net.osmand.plus.measurementtool.MeasurementEditingContext; import net.osmand.plus.measurementtool.MeasurementEditingContext;
import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.measurementtool.SnapTrackWarningFragment; import net.osmand.plus.measurementtool.SnapTrackWarningFragment;
import net.osmand.plus.monitoring.TripRecordingBottomSheet; import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.resources.ResourceManager;
import net.osmand.plus.routepreparationmenu.ChooseRouteFragment; import net.osmand.plus.routepreparationmenu.ChooseRouteFragment;
@ -2242,8 +2241,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
return getFragment(MeasurementToolFragment.TAG); return getFragment(MeasurementToolFragment.TAG);
} }
public TripRecordingBottomSheet getTripRecordingBottomSheet() { public TripRecordingStartingBottomSheet getTripRecordingBottomSheet() {
return getFragment(TripRecordingBottomSheet.TAG); return getFragment(TripRecordingStartingBottomSheet.TAG);
} }
public ChooseRouteFragment getChooseRouteFragment() { public ChooseRouteFragment getChooseRouteFragment() {

View file

@ -63,7 +63,7 @@ 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.TripRecordingActiveBottomSheet;
import net.osmand.plus.monitoring.TripRecordingBottomSheet; import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet;
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;
@ -856,7 +856,7 @@ public class MapActivityActions implements DialogProvider {
if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) { if (monitoringPlugin.hasDataToSave() || monitoringPlugin.wasTrackMonitored()) {
TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack()); TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), monitoringPlugin.getCurrentTrack());
} else { } else {
TripRecordingBottomSheet.showInstance(mapActivity.getSupportFragmentManager()); TripRecordingStartingBottomSheet.showInstance(mapActivity.getSupportFragmentManager());
} }
return true; return true;
} }

View file

@ -331,7 +331,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
if (hasDataToSave() || wasTrackMonitored()) { if (hasDataToSave() || wasTrackMonitored()) {
TripRecordingActiveBottomSheet.showInstance(fragmentManager, getCurrentTrack()); TripRecordingActiveBottomSheet.showInstance(fragmentManager, getCurrentTrack());
} else { } else {
TripRecordingBottomSheet.showInstance(fragmentManager); TripRecordingStartingBottomSheet.showInstance(fragmentManager);
} }
/*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get(); /*final boolean wasTrackMonitored = settings.SAVE_GLOBAL_TRACK_TO_GPX.get();
@ -523,7 +523,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
runnable.run(); runnable.run();
} else if (map instanceof FragmentActivity) { } else if (map instanceof FragmentActivity) {
FragmentActivity activity = (FragmentActivity) map; FragmentActivity activity = (FragmentActivity) map;
TripRecordingBottomSheet.showInstance(activity.getSupportFragmentManager()); TripRecordingStartingBottomSheet.showInstance(activity.getSupportFragmentManager());
} }
} }

View file

@ -4,17 +4,16 @@ import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; 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.text.format.DateUtils; import android.text.format.DateUtils;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.CompoundButton;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
@ -26,7 +25,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.StringRes; import androidx.annotation.StringRes;
import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.content.res.AppCompatResources;
import androidx.appcompat.widget.AppCompatImageView; import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.SwitchCompat; import androidx.cardview.widget.CardView;
import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
@ -49,7 +48,6 @@ import net.osmand.plus.activities.SavingTrackHelper.SaveGpxResult;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.myplaces.SaveCurrentTrackTask; 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;
@ -66,7 +64,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import static net.osmand.AndroidUtils.getSecondaryTextColorId; import static net.osmand.AndroidUtils.getSecondaryTextColorId;
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT; import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL;
public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment { public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragment {
@ -84,6 +82,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
private View statusContainer; private View statusContainer;
private LinearLayout buttonAppearance; private LinearLayout buttonAppearance;
private AppCompatImageView trackAppearanceIcon;
private View buttonSave; private View buttonSave;
private GpxBlockStatisticsBuilder blockStatisticsBuilder; private GpxBlockStatisticsBuilder blockStatisticsBuilder;
@ -141,7 +140,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave()); createItem(buttonClear, ItemType.CLEAR_DATA, hasDataToSave());
createItem(buttonOnline, ItemType.STOP_ONLINE, hasDataToSave()); createItem(buttonOnline, ItemType.STOP_ONLINE, hasDataToSave());
createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored()); createItem(buttonSegment, ItemType.START_NEW_SEGMENT, wasTrackMonitored());
createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true); createItem(buttonPause, wasTrackMonitored() ? ItemType.PAUSE : ItemType.RESUME, true);
createItem(buttonStop, ItemType.STOP, true); createItem(buttonStop, ItemType.STOP, true);
@ -163,37 +162,24 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode); blockStatisticsBuilder.initStatBlocks(null, ContextCompat.getColor(app, getActiveTextColorId(nightMode)), nightMode);
LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map); LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map);
showTrackContainer.setMinimumHeight(app.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_list_item_height));
final LinearLayout buttonShow = showTrackContainer.findViewById(R.id.basic_item_body); final CardView buttonShow = showTrackContainer.findViewById(R.id.compound_container);
TextView showTrackTitle = buttonShow.findViewById(R.id.title); TextView showTrackTitle = buttonShow.findViewById(R.id.title);
Integer showTitle = ItemType.SHOW_TRACK.getTitleId(); Integer showTitle = ItemType.SHOW_TRACK.getTitleId();
if (showTitle != null) { if (showTitle != null) {
showTrackTitle.setText(showTitle); showTrackTitle.setText(showTitle);
} }
AndroidUtils.setPadding(buttonShow, AndroidUtils.dpToPx(app, 12f), 0, buttonShow.getPaddingRight(), 0); final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button);
showTrackTitle.setTextColor(ContextCompat.getColor(app, getActiveIconColorId(nightMode))); showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
showTrackTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.default_desc_text_size)); UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL);
Typeface typeface = FontCache.getFont(app, app.getResources().getString(R.string.font_roboto_medium));
showTrackTitle.setTypeface(typeface);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float letterSpacing = AndroidUtils.getFloatValueFromRes(app, R.dimen.text_button_letter_spacing);
showTrackTitle.setLetterSpacing(letterSpacing);
}
final SwitchCompat showTrackOnMapButton = buttonShow.findViewById(R.id.switch_button);
showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT);
buttonAppearance = showTrackContainer.findViewById(R.id.additional_button); buttonAppearance = showTrackContainer.findViewById(R.id.additional_button);
View divider = buttonAppearance.getChildAt(0); trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon);
AndroidUiHelper.setVisibility(View.GONE, divider); updateTrackIcon(app, trackAppearanceIcon);
int marginS = app.getResources().getDimensionPixelSize(R.dimen.context_menu_padding_margin_small);
UiUtilities.setMargins(buttonAppearance, marginS, 0, 0, 0);
updateTrackIcon(buttonAppearance);
buttonAppearance.setOnClickListener(new View.OnClickListener() { buttonAppearance.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (showTrackOnMapButton.isChecked()) { if (showTrackCompound.isChecked()) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
hide(); hide();
@ -203,19 +189,19 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
} }
} }
}); });
createItem(buttonAppearance, ItemType.APPEARANCE, showTrackOnMapButton.isChecked()); createItem(buttonAppearance, ItemType.APPEARANCE, showTrackCompound.isChecked());
setShowOnMapBackground(buttonShow, app, showTrackOnMapButton.isChecked(), nightMode); setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
buttonShow.setBackgroundTintList(null); buttonShow.setBackgroundTintList(null);
} }
buttonShow.setOnClickListener(new View.OnClickListener() { buttonShow.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
boolean checked = !showTrackOnMapButton.isChecked(); boolean checked = !showTrackCompound.isChecked();
showTrackOnMapButton.setChecked(checked); showTrackCompound.setChecked(checked);
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false); app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false);
createItem(buttonAppearance, ItemType.APPEARANCE, checked); createItem(buttonAppearance, ItemType.APPEARANCE, checked);
setShowOnMapBackground(buttonShow, app, checked, nightMode); setShowOnMapBackground(buttonShow, checked, nightMode);
} }
}); });
@ -277,7 +263,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored); settings.SAVE_GLOBAL_TRACK_TO_GPX.set(wasTrackMonitored);
updateStatus(); updateStatus();
createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true); createItem(buttonPause, wasTrackMonitored ? ItemType.PAUSE : ItemType.RESUME, true);
createItem(buttonSegment, ItemType.START_SEGMENT, wasTrackMonitored); createItem(buttonSegment, ItemType.START_NEW_SEGMENT, wasTrackMonitored);
} }
}); });
@ -310,16 +296,18 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
} }
} }
private void updateTrackIcon(View buttonAppearance) { public static void updateTrackIcon(OsmandApplication app, AppCompatImageView appearanceIcon) {
if (appearanceIcon != null) {
OsmandSettings settings = app.getSettings();
String width = settings.CURRENT_TRACK_WIDTH.get(); String width = settings.CURRENT_TRACK_WIDTH.get();
boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get(); boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get();
int color = settings.CURRENT_TRACK_COLOR.get(); int color = settings.CURRENT_TRACK_COLOR.get();
Drawable appearanceDrawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color); 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); int marginTrackIconH = app.getResources().getDimensionPixelSize(R.dimen.content_padding_small);
UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0); UiUtilities.setMargins(appearanceIcon, marginTrackIconH, 0, marginTrackIconH, 0);
appearanceIcon.setImageDrawable(appearanceDrawable); appearanceIcon.setImageDrawable(appearanceDrawable);
} }
}
private void createItem(View view, ItemType type, boolean enabled) { private void createItem(View view, ItemType type, boolean enabled) {
createItem(app, nightMode, view, type, enabled, null); createItem(app, nightMode, view, type, enabled, null);
@ -370,7 +358,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
setTextColor(context, desc, false, nightMode, type); setTextColor(context, desc, false, nightMode, type);
} }
setItemBackground(context, nightMode, button != null ? button : (LinearLayout) view, enabled); setItemBackground(context, nightMode, button != null ? button : view, enabled);
} }
private String getTimeTrackSaved() { private String getTimeTrackSaved() {
@ -505,7 +493,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
show(); show();
for (String key : keys) { for (String key : keys) {
if (key.equals(UPDATE_TRACK_ICON)) { if (key.equals(UPDATE_TRACK_ICON)) {
updateTrackIcon(buttonAppearance); updateTrackIcon(app, trackAppearanceIcon);
} }
} }
} }
@ -524,7 +512,7 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
RECORDING(R.string.recording_default_name, R.drawable.ic_action_track_recordable), RECORDING(R.string.recording_default_name, R.drawable.ic_action_track_recordable),
ON_PAUSE(R.string.on_pause, R.drawable.ic_pause), ON_PAUSE(R.string.on_pause, R.drawable.ic_pause),
CLEAR_DATA(R.string.clear_recorded_data, R.drawable.ic_action_delete_dark), CLEAR_DATA(R.string.clear_recorded_data, R.drawable.ic_action_delete_dark),
START_SEGMENT(R.string.gpx_start_new_segment, R.drawable.ic_action_new_segment), START_NEW_SEGMENT(R.string.gpx_start_new_segment, R.drawable.ic_action_new_segment),
SAVE(R.string.shared_string_save, R.drawable.ic_action_save_to_file), SAVE(R.string.shared_string_save, R.drawable.ic_action_save_to_file),
PAUSE(R.string.shared_string_pause, R.drawable.ic_pause), PAUSE(R.string.shared_string_pause, R.drawable.ic_pause),
RESUME(R.string.shared_string_resume, R.drawable.ic_play_dark), RESUME(R.string.shared_string_resume, R.drawable.ic_play_dark),
@ -532,7 +520,9 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop), STOP_AND_DISCARD(R.string.track_recording_stop_without_saving, R.drawable.ic_action_rec_stop),
STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file), STOP_AND_SAVE(R.string.track_recording_save_and_stop, R.drawable.ic_action_save_to_file),
STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark), STOP_ONLINE(R.string.live_monitoring_stop, R.drawable.ic_world_globe_dark),
CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close); CANCEL(R.string.shared_string_cancel, R.drawable.ic_action_close),
START_RECORDING(R.string.shared_string_control_start, R.drawable.ic_action_direction_movement),
SETTINGS(R.string.shared_string_settings, R.drawable.ic_action_settings);
@StringRes @StringRes
private final Integer titleId; private final Integer titleId;
@ -560,24 +550,28 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
} }
} }
public static void setItemBackground(Context context, boolean nightMode, LinearLayout view, boolean enabled) { public static void setItemBackground(Context context, boolean nightMode, View view, boolean enabled) {
Drawable background = AppCompatResources.getDrawable(context, R.drawable.btn_background_inactive_light); Drawable background = AppCompatResources.getDrawable(context, R.drawable.btn_background_inactive_light);
if (background != null && enabled) { if (background != null && enabled) {
int normalColorId = view instanceof CardView
? getActiveTransparentColorId(nightMode) : getInactiveButtonColorId(nightMode);
ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList( ColorStateList iconColorStateList = AndroidUtils.createPressedColorStateList(
context, getInactiveButtonColorId(nightMode), getActiveButtonColorId(nightMode) context, normalColorId, getActiveTextColorId(nightMode)
); );
DrawableCompat.setTintList(background, iconColorStateList); DrawableCompat.setTintList(background, iconColorStateList);
if (view instanceof CardView) {
((CardView) view).setCardBackgroundColor(iconColorStateList);
return;
}
} else { } else {
UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode))); UiUtilities.tintDrawable(background, ContextCompat.getColor(context, getInactiveButtonColorId(nightMode)));
} }
view.setBackgroundDrawable(background); view.setBackgroundDrawable(background);
} }
public static void setShowOnMapBackground(LinearLayout view, Context context, boolean checked, boolean nightMode) { public static void setShowOnMapBackground(View view, boolean checked, boolean nightMode) {
Drawable background = AppCompatResources.getDrawable(context, int background = checked ? getActiveTransparentBackgroundId(nightMode) : getInactiveStrokedBackgroundId(nightMode);
nightMode ? checked ? R.drawable.btn_background_inactive_dark : R.drawable.btn_background_stroked_inactive_dark view.setBackgroundResource(background);
: checked ? R.drawable.btn_background_inactive_light : R.drawable.btn_background_stroked_inactive_light);
view.setBackgroundDrawable(background);
} }
public static void setTextColor(Context context, TextView tv, boolean enabled, boolean nightMode, ItemType type) { public static void setTextColor(Context context, TextView tv, boolean enabled, boolean nightMode, ItemType type) {
@ -638,11 +632,26 @@ public class TripRecordingActiveBottomSheet extends MenuBottomSheetDialogFragmen
return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light; return nightMode ? R.color.icon_color_osmand_dark : R.color.icon_color_osmand_light;
} }
@DrawableRes
public static int getActiveTransparentColorId(boolean nightMode) {
return nightMode ? R.color.switch_button_active_dark : R.color.switch_button_active_light;
}
@ColorRes @ColorRes
public static int getPressedColorId(boolean nightMode) { public static int getPressedColorId(boolean nightMode) {
return nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light; return nightMode ? R.color.active_buttons_and_links_text_dark : R.color.active_buttons_and_links_text_light;
} }
@DrawableRes
public static int getActiveTransparentBackgroundId(boolean nightMode) {
return nightMode ? R.drawable.btn_background_active_transparent_dark : R.drawable.btn_background_active_transparent_light;
}
@DrawableRes
public static int getInactiveStrokedBackgroundId(boolean nightMode) {
return nightMode ? R.drawable.btn_background_stroked_inactive_dark : R.drawable.btn_background_stroked_inactive_light;
}
@Override @Override
protected int getDismissButtonHeight() { protected int getDismissButtonHeight() {
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);

View file

@ -1,306 +0,0 @@
package net.osmand.plus.monitoring;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.RangeSlider;
import net.osmand.AndroidUtils;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.track.TrackAppearanceFragment;
import static net.osmand.plus.UiUtilities.CompoundButtonType.PROFILE_DEPENDENT;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = TripRecordingBottomSheet.class.getSimpleName();
private OsmandApplication app;
private OsmandSettings settings;
private ImageView upDownBtn;
private SwitchCompat confirmEveryRun;
private TextView intervalValueView;
private LinearLayout container;
private View divider;
private boolean infoExpanded;
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = requiredMyApplication();
settings = app.getSettings();
Context context = requireContext();
LayoutInflater inflater = UiUtilities.getInflater(context, nightMode);
View itemView = inflater.inflate(R.layout.trip_recording_fragment, null, false);
items.add(new BottomSheetItemWithDescription.Builder()
.setCustomView(itemView)
.create());
final int paddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
LinearLayout showTrackOnMapView = itemView.findViewById(R.id.show_track_on_map);
TextView showTrackOnMapTitle = showTrackOnMapView.findViewById(R.id.title);
showTrackOnMapTitle.setText(R.string.show_track_on_map);
ImageView trackAppearanceIcon = showTrackOnMapView.findViewById(R.id.icon_after_divider);
int color = settings.CURRENT_TRACK_COLOR.get();
String width = settings.CURRENT_TRACK_WIDTH.get();
boolean showArrows = settings.CURRENT_TRACK_SHOW_ARROWS.get();
Drawable drawable = TrackAppearanceFragment.getTrackIcon(app, width, showArrows, color);
trackAppearanceIcon.setImageDrawable(drawable);
trackAppearanceIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
hide();
SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingBottomSheet.this);
}
}
});
divider = itemView.findViewById(R.id.second_divider);
LinearLayout expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container);
upDownBtn = itemView.findViewById(R.id.up_down_button);
expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
toggleInfoView();
}
});
final int secondsLength = SECONDS.length;
final int minutesLength = MINUTES.length;
intervalValueView = itemView.findViewById(R.id.interval_value);
updateIntervalLegend();
container = itemView.findViewById(R.id.always_ask_and_range_slider_container);
RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider);
intervalSlider.setValueTo(secondsLength + minutesLength - 1);
int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode);
UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true);
container.setVisibility(View.GONE);
intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() {
@Override
public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) {
int progress = (int) value;
if (progress == 0) {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(0);
} else if (progress < secondsLength) {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(SECONDS[progress] * 1000);
} else {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(MINUTES[progress - secondsLength] * 60 * 1000);
}
updateIntervalLegend();
}
});
for (int i = 0; i < secondsLength + minutesLength; i++) {
if (i < secondsLength) {
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) {
intervalSlider.setValues((float) i);
break;
}
} else {
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= MINUTES[i - secondsLength] * 1000 * 60) {
intervalSlider.setValues((float) i);
break;
}
}
}
boolean checked = !settings.SAVE_GLOBAL_TRACK_REMEMBER.get();
confirmEveryRun = itemView.findViewById(R.id.confirm_every_run);
confirmEveryRun.setChecked(checked);
setBackgroundAndPadding(checked, paddingSmall);
confirmEveryRun.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
setBackgroundAndPadding(isChecked, paddingSmall);
settings.SAVE_GLOBAL_TRACK_REMEMBER.set(!isChecked);
}
});
final SwitchCompat showTrackOnMapButton = showTrackOnMapView.findViewById(R.id.switch_button);
showTrackOnMapButton.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
View basicItem = itemView.findViewById(R.id.basic_item_body);
basicItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = !showTrackOnMapButton.isChecked();
showTrackOnMapButton.setChecked(checked);
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false);
}
});
UiUtilities.setupCompoundButton(showTrackOnMapButton, nightMode, PROFILE_DEPENDENT);
updateUpDownBtn();
}
private void updateIntervalLegend() {
String text = getString(R.string.save_track_interval_globally);
String textValue;
int interval = settings.SAVE_GLOBAL_TRACK_INTERVAL.get();
if (interval == 0) {
textValue = getString(R.string.int_continuosly);
} else {
int seconds = interval / 1000;
if (seconds <= SECONDS[SECONDS.length - 1]) {
textValue = seconds + " " + getString(R.string.int_seconds);
} else {
textValue = (seconds / 60) + " " + getString(R.string.int_min);
}
}
String textAll = getString(R.string.ltr_or_rtl_combine_via_colon, text, textValue);
Typeface typeface = FontCache.getRobotoMedium(app);
SpannableString spannableString = UiUtilities.createCustomFontSpannable(typeface, textAll, textValue);
intervalValueView.setText(spannableString);
}
public void show() {
Dialog dialog = getDialog();
if (dialog != null) {
dialog.show();
}
}
public void hide() {
Dialog dialog = getDialog();
if (dialog != null) {
dialog.hide();
}
}
private void setBackgroundAndPadding(boolean isChecked, int paddingSmall) {
if (nightMode) {
confirmEveryRun.setBackgroundResource(
isChecked ? R.drawable.layout_bg_dark_solid : R.drawable.layout_bg_dark);
} else {
confirmEveryRun.setBackgroundResource(
isChecked ? R.drawable.layout_bg_solid : R.drawable.layout_bg);
}
confirmEveryRun.setPadding(paddingSmall, 0, paddingSmall, 0);
}
private void updateUpDownBtn() {
int iconId = infoExpanded ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up;
upDownBtn.setImageDrawable(getContentIcon(iconId));
}
private void toggleInfoView() {
infoExpanded = !infoExpanded;
ViewGroup.MarginLayoutParams marginParams = (ViewGroup.MarginLayoutParams) divider.getLayoutParams();
final int dp8 = AndroidUtils.dpToPx(app, 8f);
final int dp16 = AndroidUtils.dpToPx(app, 16f);
if (infoExpanded) {
AndroidUtils.setMargins(marginParams, 0, dp16, 0, dp8);
} else {
AndroidUtils.setMargins(marginParams, 0, 0, 0, dp8);
}
AndroidUiHelper.updateVisibility(container, infoExpanded);
updateUpDownBtn();
}
@Override
protected boolean useVerticalButtons() {
return true;
}
@Override
protected int getRightButtonHeight() {
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
}
@Override
protected int getDismissButtonHeight() {
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
}
@Override
protected int getRightBottomButtonTextId() {
return R.string.start_recording;
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_cancel;
}
@Override
protected DialogButtonType getRightBottomButtonType() {
return DialogButtonType.PRIMARY;
}
@Override
public int getSecondDividerHeight() {
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin);
}
@Override
protected void onRightBottomButtonClick() {
SavingTrackHelper helper = app.getSavingTrackHelper();
helper.startNewSegment();
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
app.startNavigationService(NavigationService.USED_BY_GPX);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack());
}
dismiss();
}
@Nullable
public MapActivity getMapActivity() {
Activity activity = getActivity();
if (activity instanceof MapActivity) {
return (MapActivity) activity;
}
return null;
}
public static void showInstance(@NonNull FragmentManager fragmentManager) {
if (!fragmentManager.isStateSaved()) {
TripRecordingBottomSheet fragment = new TripRecordingBottomSheet();
fragment.show(fragmentManager, TAG);
}
}
}

View file

@ -0,0 +1,314 @@
package net.osmand.plus.monitoring;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.SwitchCompat;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.FragmentManager;
import com.google.android.material.slider.RangeSlider;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.ItemType;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType;
import net.osmand.plus.track.TrackAppearanceFragment;
import static net.osmand.plus.UiUtilities.CompoundButtonType.GLOBAL;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.MINUTES;
import static net.osmand.plus.monitoring.OsmandMonitoringPlugin.SECONDS;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.UPDATE_TRACK_ICON;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.createItem;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.setShowOnMapBackground;
import static net.osmand.plus.monitoring.TripRecordingActiveBottomSheet.updateTrackIcon;
public class TripRecordingStartingBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = TripRecordingStartingBottomSheet.class.getSimpleName();
public static final String UPDATE_LOGGING_INTERVAL = "update_logging_interval";
private OsmandApplication app;
private OsmandSettings settings;
private AppCompatImageView upDownBtn;
private AppCompatImageView trackAppearanceIcon;
private CardView confirmContainer;
private SwitchCompat confirmCompound;
private TextView intervalValueView;
private LinearLayout intervalContainer;
private RangeSlider intervalSlider;
private boolean infoExpanded;
public static void showInstance(@NonNull FragmentManager fragmentManager) {
if (!fragmentManager.isStateSaved()) {
TripRecordingStartingBottomSheet fragment = new TripRecordingStartingBottomSheet();
fragment.show(fragmentManager, TAG);
}
}
@Override
public void createMenuItems(Bundle savedInstanceState) {
app = requiredMyApplication();
settings = app.getSettings();
Context context = requireContext();
LayoutInflater inflater = UiUtilities.getInflater(context, nightMode);
View itemView = inflater.inflate(R.layout.trip_recording_starting_fragment, null, false);
items.add(new BaseBottomSheetItem.Builder()
.setCustomView(itemView)
.create());
LinearLayout expandHideIntervalContainer = itemView.findViewById(R.id.interval_view_container);
upDownBtn = itemView.findViewById(R.id.up_down_button);
expandHideIntervalContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
updateIntervalContainer();
}
});
intervalValueView = itemView.findViewById(R.id.interval_value);
intervalContainer = itemView.findViewById(R.id.always_ask_and_range_slider_container);
intervalSlider = itemView.findViewById(R.id.interval_slider);
updateIntervalValue();
confirmContainer = itemView.findViewById(R.id.confirm_container);
confirmCompound = confirmContainer.findViewById(R.id.confirm_compound_button);
updateGlobalRemember();
confirmContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = !confirmCompound.isChecked();
confirmCompound.setChecked(checked);
settings.SAVE_GLOBAL_TRACK_REMEMBER.set(checked);
setShowOnMapBackground(confirmContainer, checked, nightMode);
}
});
LinearLayout showTrackContainer = itemView.findViewById(R.id.show_track_on_map);
final CardView buttonShow = itemView.findViewById(R.id.compound_container);
TextView showTrackTitle = buttonShow.findViewById(R.id.title);
showTrackTitle.setText(R.string.show_track_on_map);
final CompoundButton showTrackCompound = buttonShow.findViewById(R.id.compound_button);
showTrackCompound.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
UiUtilities.setupCompoundButton(showTrackCompound, nightMode, GLOBAL);
LinearLayout buttonAppearance = showTrackContainer.findViewById(R.id.additional_button);
trackAppearanceIcon = showTrackContainer.findViewById(R.id.additional_button_icon);
updateTrackIcon(app, trackAppearanceIcon);
buttonAppearance.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
hide();
SelectedGpxFile selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack();
TrackAppearanceFragment.showInstance(mapActivity, selectedGpxFile, TripRecordingStartingBottomSheet.this);
}
}
});
setShowOnMapBackground(buttonShow, showTrackCompound.isChecked(), nightMode);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
buttonShow.setBackgroundTintList(null);
}
buttonShow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = !showTrackCompound.isChecked();
showTrackCompound.setChecked(checked);
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), checked, false);
setShowOnMapBackground(buttonShow, checked, nightMode);
}
});
updateUpDownBtn();
CardView cardLeft = itemView.findViewById(R.id.button_left);
createItem(app, nightMode, cardLeft, ItemType.CANCEL, true, null);
cardLeft.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
CardView cardCenter = itemView.findViewById(R.id.button_center);
createItem(app, nightMode, cardCenter, ItemType.START_RECORDING, true, null);
cardCenter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startRecording();
}
});
CardView cardRight = itemView.findViewById(R.id.button_right);
createItem(app, nightMode, cardRight, ItemType.SETTINGS, true, null);
cardRight.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
hide();
BaseSettingsFragment.showInstance(mapActivity, SettingsScreenType.MONITORING_SETTINGS, TripRecordingStartingBottomSheet.this);
}
}
});
}
private void updateIntervalLegend() {
String text = getString(R.string.save_track_interval_globally);
String textValue;
int interval = settings.SAVE_GLOBAL_TRACK_INTERVAL.get();
if (interval == 0) {
textValue = getString(R.string.int_continuosly);
} else {
int seconds = interval / 1000;
if (seconds <= SECONDS[SECONDS.length - 1]) {
textValue = seconds + " " + getString(R.string.int_seconds);
} else {
textValue = (seconds / 60) + " " + getString(R.string.int_min);
}
}
String textAll = getString(R.string.ltr_or_rtl_combine_via_colon, text, textValue);
Typeface typeface = FontCache.getRobotoMedium(app);
SpannableString spannableString = UiUtilities.createCustomFontSpannable(typeface, textAll, textValue);
intervalValueView.setText(spannableString);
}
private void updateIntervalValue() {
if (intervalSlider != null && intervalContainer != null) {
updateIntervalLegend();
final int secondsLength = SECONDS.length;
final int minutesLength = MINUTES.length;
intervalSlider.setValueTo(secondsLength + minutesLength - 1);
int currentModeColor = app.getSettings().getApplicationMode().getProfileColor(nightMode);
UiUtilities.setupSlider(intervalSlider, nightMode, currentModeColor, true);
intervalContainer.setVisibility(View.GONE);
intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() {
@Override
public void onValueChange(@NonNull RangeSlider slider, float value, boolean fromUser) {
int progress = (int) value;
if (progress == 0) {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(0);
} else if (progress < secondsLength) {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(SECONDS[progress] * 1000);
} else {
settings.SAVE_GLOBAL_TRACK_INTERVAL.set(MINUTES[progress - secondsLength] * 60 * 1000);
}
updateIntervalLegend();
}
});
for (int i = 0; i < secondsLength + minutesLength; i++) {
if (i < secondsLength) {
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= SECONDS[i] * 1000) {
intervalSlider.setValues((float) i);
break;
}
} else {
if (settings.SAVE_GLOBAL_TRACK_INTERVAL.get() <= MINUTES[i - secondsLength] * 1000 * 60) {
intervalSlider.setValues((float) i);
break;
}
}
}
}
}
private void updateIntervalContainer() {
infoExpanded = !infoExpanded;
AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded);
updateUpDownBtn();
}
private void updateGlobalRemember() {
if (confirmContainer != null && confirmCompound != null) {
confirmCompound.setChecked(settings.SAVE_GLOBAL_TRACK_REMEMBER.get());
setShowOnMapBackground(confirmContainer, confirmCompound.isChecked(), nightMode);
}
}
private void updateUpDownBtn() {
int iconId = infoExpanded ? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up;
upDownBtn.setImageDrawable(getContentIcon(iconId));
}
private void startRecording() {
SavingTrackHelper helper = app.getSavingTrackHelper();
helper.startNewSegment();
settings.SAVE_GLOBAL_TRACK_TO_GPX.set(true);
app.startNavigationService(NavigationService.USED_BY_GPX);
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
TripRecordingActiveBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), helper.getCurrentTrack());
}
dismiss();
}
public void show(String... keys) {
Dialog dialog = getDialog();
if (dialog != null) {
dialog.show();
for (String key : keys) {
if (key.equals(UPDATE_TRACK_ICON)) {
updateTrackIcon(app, trackAppearanceIcon);
}
if (key.equals(UPDATE_LOGGING_INTERVAL)) {
updateGlobalRemember();
updateIntervalValue();
AndroidUiHelper.updateVisibility(intervalContainer, infoExpanded);
}
}
}
}
public void hide() {
Dialog dialog = getDialog();
if (dialog != null) {
dialog.hide();
}
}
@Nullable
public MapActivity getMapActivity() {
Activity activity = getActivity();
if (activity instanceof MapActivity) {
return (MapActivity) activity;
}
return null;
}
@Override
protected boolean hideButtonsContainer() {
return true;
}
}

View file

@ -61,6 +61,7 @@ import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.audionotes.MultimediaNotesFragment; import net.osmand.plus.audionotes.MultimediaNotesFragment;
import net.osmand.plus.development.DevelopmentSettingsFragment; import net.osmand.plus.development.DevelopmentSettingsFragment;
import net.osmand.plus.monitoring.MonitoringSettingsFragment; import net.osmand.plus.monitoring.MonitoringSettingsFragment;
import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet;
import net.osmand.plus.openplacereviews.OprSettingsFragment; import net.osmand.plus.openplacereviews.OprSettingsFragment;
import net.osmand.plus.osmedit.OsmEditingFragment; import net.osmand.plus.osmedit.OsmEditingFragment;
import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment; import net.osmand.plus.profiles.SelectAppModesBottomSheetDialogFragment;
@ -85,6 +86,7 @@ import java.io.Serializable;
import java.util.Set; import java.util.Set;
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID; import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_SETTINGS_ID;
import static net.osmand.plus.monitoring.TripRecordingStartingBottomSheet.UPDATE_LOGGING_INTERVAL;
public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener, public abstract class BaseSettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener,
OnPreferenceClickListener, AppModeChangedListener, OnConfirmPreferenceChange { OnPreferenceClickListener, AppModeChangedListener, OnConfirmPreferenceChange {
@ -291,6 +293,15 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
} }
} }
@Override
public void onDestroyView() {
super.onDestroyView();
Fragment target = getTargetFragment();
if (target instanceof TripRecordingStartingBottomSheet) {
((TripRecordingStartingBottomSheet) target).show(UPDATE_LOGGING_INTERVAL);
}
}
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();
@ -884,21 +895,37 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
} }
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType) { public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType) {
return showInstance(activity, screenType, null); return showInstance(activity, screenType, (ApplicationMode) null);
}
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, Fragment target) {
return showInstance(activity, screenType, null, target);
} }
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode) { public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode) {
return showInstance(activity, screenType, appMode, new Bundle()); return showInstance(activity, screenType, appMode, new Bundle());
} }
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, @Nullable ApplicationMode appMode, Fragment target) {
return showInstance(activity, screenType, appMode, new Bundle(), target);
}
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType, public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType,
@Nullable ApplicationMode appMode, @NonNull Bundle args) { @Nullable ApplicationMode appMode, @NonNull Bundle args) {
return showInstance(activity, screenType, appMode, args, null);
}
public static boolean showInstance(FragmentActivity activity, SettingsScreenType screenType,
@Nullable ApplicationMode appMode, @NonNull Bundle args, @Nullable Fragment target) {
try { try {
Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName); Fragment fragment = Fragment.instantiate(activity, screenType.fragmentName);
if (appMode != null) { if (appMode != null) {
args.putString(APP_MODE_KEY, appMode.getStringKey()); args.putString(APP_MODE_KEY, appMode.getStringKey());
} }
fragment.setArguments(args); fragment.setArguments(args);
if (target != null) {
fragment.setTargetFragment(target, 0);
}
activity.getSupportFragmentManager().beginTransaction() activity.getSupportFragmentManager().beginTransaction()
.replace(R.id.fragmentContainer, fragment, screenType.fragmentName) .replace(R.id.fragmentContainer, fragment, screenType.fragmentName)
.addToBackStack(DRAWER_SETTINGS_ID + ".new") .addToBackStack(DRAWER_SETTINGS_ID + ".new")

View file

@ -37,7 +37,7 @@ import net.osmand.plus.dialogs.GpxAppearanceAdapter.AppearanceListItem;
import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType; import net.osmand.plus.dialogs.GpxAppearanceAdapter.GpxAppearanceAdapterType;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet; import net.osmand.plus.monitoring.TripRecordingActiveBottomSheet;
import net.osmand.plus.monitoring.TripRecordingBottomSheet; import net.osmand.plus.monitoring.TripRecordingStartingBottomSheet;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener;
import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.CommonPreference;
@ -398,8 +398,8 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
@Override @Override
public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) { public void onContextMenuDismiss(@NonNull ContextMenuFragment fragment) {
Fragment target = getTargetFragment(); Fragment target = getTargetFragment();
if (target instanceof TripRecordingBottomSheet) { if (target instanceof TripRecordingStartingBottomSheet) {
((TripRecordingBottomSheet) target).show(); ((TripRecordingStartingBottomSheet) target).show(UPDATE_TRACK_ICON);
} else if (target instanceof TripRecordingActiveBottomSheet) { } else if (target instanceof TripRecordingActiveBottomSheet) {
((TripRecordingActiveBottomSheet) target).show(UPDATE_TRACK_ICON); ((TripRecordingActiveBottomSheet) target).show(UPDATE_TRACK_ICON);
} }