Directions > Options
This commit is contained in:
parent
81c32ad4ce
commit
8b74ded620
2 changed files with 134 additions and 0 deletions
87
OsmAnd/res/layout/elevation_preference.xml
Normal file
87
OsmAnd/res/layout/elevation_preference.xml
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
<?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:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/list_background_color"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/selectable_list_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/setting_list_item_large_height"
|
||||||
|
tools:background="?android:attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/icon_elevation"
|
||||||
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
|
android:layout_marginTop="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginBottom="@dimen/bottom_sheet_icon_margin"
|
||||||
|
osmand:srcCompat="@drawable/ic_action_altitude_average" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@android:id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:fadingEdge="horizontal"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="?android:textColorPrimary"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@android:id/summary"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:letterSpacing="@dimen/description_letter_spacing"
|
||||||
|
android:textColor="?android:textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_regular" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="18dp"
|
||||||
|
android:layout_marginBottom="18dp"
|
||||||
|
android:background="?attr/divider_color_basic" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/switchWidget"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -12,6 +12,7 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.ColorRes;
|
import androidx.annotation.ColorRes;
|
||||||
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
|
@ -49,6 +50,7 @@ import net.osmand.plus.settings.backend.CommonPreference;
|
||||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||||
import net.osmand.plus.settings.bottomsheets.ElevationDateBottomSheet;
|
import net.osmand.plus.settings.bottomsheets.ElevationDateBottomSheet;
|
||||||
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
||||||
|
import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
import net.osmand.router.GeneralRouter.RoutingParameter;
|
import net.osmand.router.GeneralRouter.RoutingParameter;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -130,6 +132,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
items.add(createTimeConditionalRoutingItem(optionsItem));
|
items.add(createTimeConditionalRoutingItem(optionsItem));
|
||||||
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
|
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
|
||||||
items.add(createOtherSettingsRoutingItem(optionsItem));
|
items.add(createOtherSettingsRoutingItem(optionsItem));
|
||||||
|
} else if (USE_HEIGHT_OBSTACLES.equals(optionsItem.getKey()) && hasReliefParameters()) {
|
||||||
|
items.add(inflateElevationParameter(optionsItem));
|
||||||
} else {
|
} else {
|
||||||
inflateRoutingParameter(optionsItem);
|
inflateRoutingParameter(optionsItem);
|
||||||
}
|
}
|
||||||
|
@ -256,6 +260,49 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BaseBottomSheetItem inflateElevationParameter(final LocalRoutingParameter optionsItem) {
|
||||||
|
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
|
||||||
|
final boolean active = !useHeightPref.getModeValue(applicationMode);
|
||||||
|
final View itemView = UiUtilities.getInflater(app, nightMode).inflate(
|
||||||
|
R.layout.elevation_preference, null, false);
|
||||||
|
final ImageView iconView = itemView.findViewById(R.id.icon_elevation);
|
||||||
|
final SwitchCompat switchButton = itemView.findViewById(R.id.switchWidget);
|
||||||
|
int selectedModeColor = ContextCompat.getColor(app, selectedModeColorId);
|
||||||
|
iconView.setImageDrawable(getContentIcon(active ?
|
||||||
|
optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()));
|
||||||
|
TextView title = itemView.findViewById(android.R.id.title);
|
||||||
|
title.setText(getString(R.string.routing_attr_height_obstacles_name));
|
||||||
|
final TextView description = itemView.findViewById(android.R.id.summary);
|
||||||
|
description.setText(getString(R.string.routing_attr_height_obstacles_name));
|
||||||
|
View itemsContainer = itemView.findViewById(R.id.selectable_list_item);
|
||||||
|
switchButton.setChecked(!active);
|
||||||
|
switchButton.setFocusable(false);
|
||||||
|
UiUtilities.setupCompoundButton(nightMode, selectedModeColor, switchButton);
|
||||||
|
itemsContainer.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (USE_HEIGHT_OBSTACLES.equals(optionsItem.getKey()) && hasReliefParameters()) {
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
if (fm != null) {
|
||||||
|
ElevationDateBottomSheet.showInstance(fm, applicationMode, RouteOptionsBottomSheet.this, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
applyParameter(item[0], optionsItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||||
|
.setCustomView(itemView)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
return item[0];
|
||||||
|
}
|
||||||
|
|
||||||
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
|
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
|
||||||
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
|
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
|
||||||
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||||
|
|
Loading…
Reference in a new issue