Split interval: UI fixes

This commit is contained in:
nazar-kutz 2021-03-05 20:03:04 +02:00
parent d230a323ce
commit 1c5d01f391
5 changed files with 73 additions and 75 deletions

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:linksClickable="true"
android:lineSpacingMultiplier="@dimen/bottom_sheet_text_spacing_multiplier"
tools:text="Some long description"
android:paddingEnd="@dimen/content_padding"
android:paddingStart="@dimen/content_padding" />

View file

@ -5,57 +5,11 @@
android:layout_height="match_parent"
android:orientation="vertical">
<RadioGroup
android:id="@+id/split_type"
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dialog_button_height"
android:layout_marginStart="@dimen/content_padding"
android:layout_marginTop="@dimen/text_margin_small"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginBottom="@dimen/content_padding_small"
android:background="?attr/btn_bg_border_inactive"
android:baselineAligned="false"
android:orientation="horizontal">
android:layout_height="@dimen/content_padding" />
<RadioButton
android:id="@+id/no_split"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/btn_radio_button_left"
android:button="@android:color/transparent"
android:checked="true"
android:foreground="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/shared_string_none"
android:textColor="@drawable/radio_flat_text_selector_light" />
<RadioButton
android:id="@+id/time_split"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/btn_radio_button_center"
android:button="@android:color/transparent"
android:foreground="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/shared_string_time"
android:textColor="@drawable/radio_flat_text_selector_light" />
<RadioButton
android:id="@+id/distance_split"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/btn_radio_button_right"
android:button="@android:color/transparent"
android:foreground="?attr/selectableItemBackground"
android:gravity="center"
android:text="@string/distance"
android:textColor="@drawable/radio_flat_text_selector_light"
android:textSize="@dimen/default_desc_text_size" />
</RadioGroup>
<include layout="@layout/custom_radio_buttons" />
<LinearLayout
android:id="@+id/slider_container"
@ -77,7 +31,7 @@
android:layout_weight="1"
android:gravity="start"
android:lineSpacingExtra="@dimen/line_spacing_extra_description"
android:text="@string/gpx_split_interval"
android:text="@string/shared_string_interval"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
@ -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"

View file

@ -12,6 +12,7 @@
-->
<string name="shared_string_interval">Interval</string>
<string name="quick_action_showhide_title">Show/hide</string>
<string name="copy_poi_name">Copy POI name</string>
<string name="track_recording_will_be_continued">The recording will be continued.</string>

View file

@ -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;
}
}

View file

@ -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);