Merge pull request #10617 from osmandapp/Fix-UI-trip-recording

Fix UI trip recording
This commit is contained in:
Vitaliy 2021-01-21 10:30:46 +02:00 committed by GitHub
commit 503868129a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 119 additions and 89 deletions

View file

@ -1,12 +1,16 @@
<?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:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
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:baselineAligned="false"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height" android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:baselineAligned="false"> android:paddingStart="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding">
<LinearLayout <LinearLayout
android:id="@+id/basic_item_body" android:id="@+id/basic_item_body"
@ -28,6 +32,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:paddingTop="@dimen/content_padding_small"
android:paddingBottom="@dimen/content_padding"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Some title" /> tools:text="Some title" />
@ -40,8 +46,8 @@
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/content_padding_half" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/content_padding_half" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
tools:checked="true" /> tools:checked="true" />
</LinearLayout> </LinearLayout>
@ -62,11 +68,11 @@
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/icon_after_divider" android:id="@+id/icon_after_divider"
style="@style/Widget.AppCompat.Toolbar.Button.Navigation" style="@style/Widget.AppCompat.Toolbar.Button.Navigation"
android:layout_width="@dimen/acceptable_touch_radius" android:layout_width="@dimen/favorites_icon_right_margin"
android:layout_height="@dimen/acceptable_touch_radius" android:layout_height="@dimen/favorites_icon_right_margin"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding" android:layout_marginLeft="@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" />
</LinearLayout> </LinearLayout>

View file

@ -1,89 +1,114 @@
<?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: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:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_content_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/content_padding" android:letterSpacing="@dimen/text_button_letter_spacing"
android:letterSpacing="@dimen/text_button_letter_spacing" android:paddingStart="@dimen/content_padding"
android:text="@string/monitoring_settings" android:paddingLeft="@dimen/content_padding"
android:textSize="@dimen/default_list_text_size" android:paddingTop="@dimen/content_padding_small"
osmand:typeface="@string/font_roboto_medium" /> android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding_small"
android:text="@string/monitoring_settings"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium" />
<include <include
android:id="@+id/show_track_on_map" android:id="@+id/show_track_on_map"
layout="@layout/bottom_sheet_with_switch_divider_and_additional_button" /> layout="@layout/bottom_sheet_with_switch_divider_and_additional_button" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_marginBottom="@dimen/bottom_sheet_content_margin_small" android:background="?attr/dashboard_divider" />
android:background="?attr/dashboard_divider" />
<View <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/content_padding_small" /> android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_content_margin"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<LinearLayout <net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent" android:id="@+id/interval_value"
android:layout_height="0dp" android:layout_width="0dp"
android:layout_gravity="center_vertical" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:orientation="horizontal"> android:ellipsize="end"
android:maxLines="1"
android:textSize="@dimen/default_list_text_size"
tools:text="Interval value" />
<net.osmand.plus.widgets.TextViewEx <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/interval_value" android:id="@+id/up_down_button"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:background="@null"
android:ellipsize="end" app:srcCompat="@drawable/ic_action_arrow_down" />
android:maxLines="1" </LinearLayout>
android:textSize="@dimen/default_list_text_size"
tools:text="Interval value" />
<androidx.appcompat.widget.AppCompatImageView <LinearLayout
android:id="@+id/up_down_button" android:id="@+id/always_ask_and_range_slider_container"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@null" android:orientation="vertical"
app:srcCompat="@drawable/ic_action_arrow_down" /> android:paddingStart="@dimen/content_padding"
</LinearLayout> android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<com.google.android.material.slider.RangeSlider <com.google.android.material.slider.RangeSlider
android:id="@+id/interval_slider" android:id="@+id/interval_slider"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:contentDescription="@string/save_track_interval_globally" android:contentDescription="@string/save_track_interval_globally"
android:stepSize="1" android:stepSize="1"
app:labelBehavior="gone" /> app:haloRadius="@dimen/content_padding_small"
app:labelBehavior="gone"
app:thumbColor="@color/profile_icon_color_blue_light"
app:thumbRadius="@dimen/content_padding_small_half"
app:trackColorActive="@color/profile_icon_color_blue_light"
app:trackColorInactive="#4D007EB3"
app:tickColorInactive="#007EB3"
app:trackHeight="@dimen/slider_track_height"
tools:visibility="visible" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/confirm_every_run" android:id="@+id/confirm_every_run"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="@dimen/content_padding" android:letterSpacing="@dimen/text_button_letter_spacing"
android:letterSpacing="@dimen/text_button_letter_spacing" android:minHeight="@dimen/context_menu_buttons_bottom_height"
android:minHeight="@dimen/context_menu_buttons_bottom_height" android:paddingLeft="@dimen/content_padding_small"
android:paddingLeft="@dimen/content_padding_small" android:paddingRight="@dimen/content_padding_small"
android:paddingRight="@dimen/content_padding_small" android:text="@string/confirm_every_run"
android:text="@string/confirm_every_run" android:textColor="?attr/color_dialog_buttons"
android:textColor="?android:textColorPrimary" android:textSize="@dimen/default_list_text_size"
android:textSize="@dimen/default_list_text_size" osmand:typeface="@string/font_roboto_regular"
android:visibility="gone" tools:visibility="visible" />
osmand:typeface="@string/font_roboto_regular" </LinearLayout>
tools:visibility="visible" />
<View
android:id="@+id/second_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/content_padding"
android:layout_marginBottom="@dimen/bottom_sheet_content_margin_small"
android:background="?attr/dashboard_divider" />
</LinearLayout> </LinearLayout>

View file

@ -31,7 +31,6 @@ import net.osmand.plus.UiUtilities.DialogButtonType;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
@ -50,8 +49,9 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
private ImageView upDownBtn; private ImageView upDownBtn;
private SwitchCompat confirmEveryRun; private SwitchCompat confirmEveryRun;
private RangeSlider intervalSlider;
private TextView intervalValueView; private TextView intervalValueView;
private LinearLayout container;
private boolean infoExpanded; private boolean infoExpanded;
@Override @Override
@ -66,11 +66,8 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
.setCustomView(itemView) .setCustomView(itemView)
.create()); .create());
int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
final int paddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small); final int paddingSmall = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
items.add(new DividerSpaceItem(context, padding));
LinearLayout showTrackOnMapView = itemView.findViewById(R.id.show_track_on_map); LinearLayout showTrackOnMapView = itemView.findViewById(R.id.show_track_on_map);
TextView showTrackOnMapTitle = showTrackOnMapView.findViewById(R.id.title); TextView showTrackOnMapTitle = showTrackOnMapView.findViewById(R.id.title);
showTrackOnMapTitle.setText(R.string.show_track_on_map); showTrackOnMapTitle.setText(R.string.show_track_on_map);
@ -110,8 +107,10 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
intervalValueView = itemView.findViewById(R.id.interval_value); intervalValueView = itemView.findViewById(R.id.interval_value);
updateIntervalLegend(); updateIntervalLegend();
RangeSlider intervalSlider = itemView.findViewById(R.id.interval_slider); container = itemView.findViewById(R.id.always_ask_and_range_slider_container);
intervalSlider = itemView.findViewById(R.id.interval_slider);
intervalSlider.setValueTo(secondsLength + minutesLength - 1); intervalSlider.setValueTo(secondsLength + minutesLength - 1);
container.setVisibility(View.GONE);
intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() { intervalSlider.addOnChangeListener(new RangeSlider.OnChangeListener() {
@Override @Override
@ -218,7 +217,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment {
private void toggleInfoView() { private void toggleInfoView() {
infoExpanded = !infoExpanded; infoExpanded = !infoExpanded;
AndroidUiHelper.updateVisibility(confirmEveryRun, infoExpanded); AndroidUiHelper.updateVisibility(container, infoExpanded);
updateUpDownBtn(); updateUpDownBtn();
} }