From 1c5d01f391552044090ea05612b07dc26840d5e4 Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 5 Mar 2021 20:03:04 +0200 Subject: [PATCH] Split interval: UI fixes --- ...em_description_long_without_min_height.xml | 17 +++++ OsmAnd/res/layout/track_split_interval.xml | 55 ++-------------- OsmAnd/res/values/strings.xml | 1 + .../LongDescriptionStandardHeightItem.java | 12 ++++ .../plus/track/SplitIntervalBottomSheet.java | 63 +++++++++++-------- 5 files changed, 73 insertions(+), 75 deletions(-) create mode 100644 OsmAnd/res/layout/bottom_sheet_item_description_long_without_min_height.xml create mode 100644 OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/LongDescriptionStandardHeightItem.java diff --git a/OsmAnd/res/layout/bottom_sheet_item_description_long_without_min_height.xml b/OsmAnd/res/layout/bottom_sheet_item_description_long_without_min_height.xml new file mode 100644 index 0000000000..9fe963d78f --- /dev/null +++ b/OsmAnd/res/layout/bottom_sheet_item_description_long_without_min_height.xml @@ -0,0 +1,17 @@ + + diff --git a/OsmAnd/res/layout/track_split_interval.xml b/OsmAnd/res/layout/track_split_interval.xml index ae823012cd..7751d35e0f 100644 --- a/OsmAnd/res/layout/track_split_interval.xml +++ b/OsmAnd/res/layout/track_split_interval.xml @@ -5,57 +5,11 @@ android:layout_height="match_parent" android:orientation="vertical"> - + android:layout_height="@dimen/content_padding" /> - - - - - - - + @@ -143,6 +97,7 @@ android:layout_marginStart="@dimen/content_padding" android:layout_marginEnd="@dimen/content_padding" android:layout_marginBottom="@dimen/content_padding" + android:layout_marginTop="@dimen/content_padding_half" android:lineSpacingExtra="@dimen/line_spacing_extra_description" android:text="@string/gpx_split_interval_none_descr" android:textColor="?android:textColorSecondary" diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index c43425fa92..9208a0deb9 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -12,6 +12,7 @@ --> + Interval Show/hide Copy POI name The recording will be continued. diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/LongDescriptionStandardHeightItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/LongDescriptionStandardHeightItem.java new file mode 100644 index 0000000000..fa2b9808b9 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/simpleitems/LongDescriptionStandardHeightItem.java @@ -0,0 +1,12 @@ +package net.osmand.plus.base.bottomsheetmenu.simpleitems; + +import net.osmand.plus.R; +import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; + +public class LongDescriptionStandardHeightItem extends BottomSheetItemWithDescription { + + public LongDescriptionStandardHeightItem(CharSequence description) { + this.description = description; + this.layoutId =R.layout.bottom_sheet_item_description_long_without_min_height; + } +} diff --git a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java index 15d94db2cc..57d38e2040 100644 --- a/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/SplitIntervalBottomSheet.java @@ -3,7 +3,7 @@ package net.osmand.plus.track; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; -import android.widget.RadioGroup; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -22,9 +22,12 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; -import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionItem; +import net.osmand.plus.base.bottomsheetmenu.simpleitems.LongDescriptionStandardHeightItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.widgets.MultiStateToggleButton; +import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener; +import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem; import org.apache.commons.logging.Log; @@ -93,7 +96,7 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { @Override public void createMenuItems(Bundle savedInstanceState) { items.add(new TitleItem(getString(R.string.gpx_split_interval))); - items.add(new LongDescriptionItem(getString(R.string.gpx_split_interval_descr))); + items.add(new LongDescriptionStandardHeightItem(getString(R.string.gpx_split_interval_descr))); LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode); View view = themedInflater.inflate(R.layout.track_split_interval, null); @@ -106,29 +109,10 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { selectedSplitValue = view.findViewById(R.id.split_value_tv); splitIntervalNoneDescr = view.findViewById(R.id.split_interval_none_descr); - UiUtilities.setupSlider(slider, nightMode, null); + UiUtilities.setupSlider(slider, nightMode, null, true); - RadioGroup splitTypeGroup = view.findViewById(R.id.split_type); - if (selectedSplitType == GpxSplitType.NO_SPLIT) { - splitTypeGroup.check(R.id.no_split); - } else if (selectedSplitType == GpxSplitType.TIME) { - splitTypeGroup.check(R.id.time_split); - } else if (selectedSplitType == GpxSplitType.DISTANCE) { - splitTypeGroup.check(R.id.distance_split); - } - splitTypeGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(RadioGroup group, int checkedId) { - if (checkedId == R.id.no_split) { - selectedSplitType = GpxSplitType.NO_SPLIT; - } else if (checkedId == R.id.time_split) { - selectedSplitType = GpxSplitType.TIME; - } else if (checkedId == R.id.distance_split) { - selectedSplitType = GpxSplitType.DISTANCE; - } - updateSlider(); - } - }); + LinearLayout radioGroup = (LinearLayout) view.findViewById(R.id.custom_radio_buttons); + setupTypeRadioGroup(radioGroup); SimpleBottomSheetItem titleItem = (SimpleBottomSheetItem) new SimpleBottomSheetItem.Builder() .setCustomView(view) @@ -136,6 +120,35 @@ public class SplitIntervalBottomSheet extends MenuBottomSheetDialogFragment { items.add(titleItem); } + private void setupTypeRadioGroup(LinearLayout buttonsContainer) { + RadioItem none = createRadioButton(GpxSplitType.NO_SPLIT, R.string.shared_string_none); + RadioItem time = createRadioButton(GpxSplitType.TIME, R.string.shared_string_time); + RadioItem distance = createRadioButton(GpxSplitType.DISTANCE, R.string.distance); + + MultiStateToggleButton radioGroup = new MultiStateToggleButton(app, buttonsContainer, nightMode); + radioGroup.setItems(none, time, distance); + + if (selectedSplitType == GpxSplitType.NO_SPLIT) { + radioGroup.setSelectedItem(none); + } else { + radioGroup.setSelectedItem(selectedSplitType == GpxSplitType.TIME ? time : distance); + } + } + + private RadioItem createRadioButton(final GpxSplitType splitType, int titleId) { + String title = app.getString(titleId); + RadioItem item = new RadioItem(title); + item.setOnClickListener(new OnRadioItemClickListener() { + @Override + public boolean onRadioItemClick(RadioItem radioItem, View view) { + selectedSplitType = splitType; + updateSlider(); + return true; + } + }); + return item; + } + @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState);