refactor options dialogs and improve ui

This commit is contained in:
Chumva 2018-11-30 17:20:16 +02:00
parent 85e417fb2c
commit c840cedc0f
20 changed files with 902 additions and 668 deletions

View file

@ -32,6 +32,7 @@ public class GeneralRouter implements VehicleRouter {
public static final String AVOID_UNPAVED = "avoid_unpaved";
public static final String PREFER_MOTORWAYS = "prefer_motorway";
public static final String ALLOW_PRIVATE = "allow_private";
public static final String ALLOW_MOTORWAYS = "allow_motorway";
private final RouteAttributeContext[] objectAttributes;
public final Map<String, String> attributes;

View file

@ -8,18 +8,13 @@
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:orientation="vertical">
<View
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/explist_indicator"
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"

View file

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/package_delivered_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/waypoint_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal">
<ImageView
android:id="@+id/waypoint_icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding"
android:src="@drawable/ic_action_fav_dark" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/waypoint_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:maxLines="2"
android:textSize="@dimen/default_list_text_size"
tools:text="Some waypoint text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp">
<TextView
android:id="@+id/waypoint_dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:maxLines="1"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_sub_text_size"
tools:text="12 km" />
<TextView
android:id="@+id/waypoint_deviation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:drawablePadding="2dp"
android:maxLines="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size"
tools:text="Intermediate point " />
<TextView
android:id="@+id/waypoint_desc_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size"
tools:text="some description" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/info_close"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:contentDescription="@string/shared_string_delete"
android:focusable="false"
android:scaleType="center"
android:src="@drawable/ic_action_remove_dark" />
</LinearLayout>
<View
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp" />
</LinearLayout>

View file

@ -3,89 +3,115 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_height="wrap_content"
android:minHeight="56dp"
android:orientation="vertical"
android:paddingLeft="@dimen/route_info_start_divider_margin"
android:paddingStart="@dimen/route_info_start_divider_margin">
<View
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/route_info_start_divider_margin"
android:layout_marginStart="@dimen/route_info_start_divider_margin"
android:orientation="vertical">
<View
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
<LinearLayout
android:id="@+id/firstCellContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="56dp"
android:baselineAligned="false"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/search_radius_proximity"
android:textSize="@dimen/default_desc_text_size" />
<LinearLayout
android:id="@+id/firstCellContainer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/search_radius_proximity"
android:textSize="@dimen/default_desc_text_size" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginTop="2dp"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="500 m" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/secondCellContainer"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="16dp"
android:layout_marginTop="2dp"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="500 m" />
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/titleEx"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/shared_string_type"
android:textSize="@dimen/default_desc_text_size" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descriptionEx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Cinema" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/secondCellContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:orientation="vertical">
<TextView
android:id="@+id/titleEx"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/shared_string_type"
android:textSize="@dimen/default_desc_text_size" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descriptionEx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginTop="2dp"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Cinema" />
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
</LinearLayout>
<View
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
android:layout_height="1dp"
android:layout_marginTop="8dp" />
</LinearLayout>

View file

@ -4,31 +4,45 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="44dp"
android:orientation="horizontal">
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="64dp"
android:layout_marginStart="64dp"
android:layout_weight="1"
android:text="@string/search_radius_proximity"
android:textSize="@dimen/default_desc_text_size" />
android:background="?attr/selectableItemBackground"
android:minHeight="44dp"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="500 m" />
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="64dp"
android:layout_marginStart="64dp"
android:layout_weight="1"
android:text="@string/search_radius_proximity"
android:textSize="@dimen/default_desc_text_size" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="500 m" />
</LinearLayout>
<View
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp" />
</LinearLayout>

View file

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/package_delivered_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:descendantFocusability="blocksDescendants"
android:minHeight="50dp">
<ImageView
android:id="@+id/waypoint_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding"
android:src="@drawable/ic_action_fav_dark" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="@+id/waypoint_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:maxLines="2"
android:textSize="@dimen/default_list_text_size"
tools:text="Some waypoint text" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp">
<TextView
android:id="@+id/waypoint_dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:maxLines="1"
android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_sub_text_size"
tools:text="12 km" />
<TextView
android:id="@+id/waypoint_deviation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:drawablePadding="2dp"
android:maxLines="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size"
tools:text="Intermediate point " />
<TextView
android:id="@+id/waypoint_desc_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size"
tools:text="some description" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/info_close"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:contentDescription="@string/shared_string_delete"
android:focusable="false"
android:scaleType="center"
android:src="@drawable/ic_action_remove_dark"/>
</LinearLayout>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/icon"
android:layout_width="@dimen/standard_icon_size"
android:layout_height="@dimen/standard_icon_size"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_info_dark"/>
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Title"/>
</LinearLayout>

View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_coordinates_latitude"/>
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Some Title"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/compound_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>

View file

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:gravity="center_vertical"
android:orientation="vertical">
<View
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/explist_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_marginBottom="@dimen/content_padding"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:layout_marginTop="@dimen/content_padding"
tools:src="@drawable/ic_action_arrow_down" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="64dp"
android:layout_marginRight="64dp"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"
tools:text="Some Title" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/compound_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:layout_marginLeft="@dimen/content_padding"
android:layout_marginRight="@dimen/content_padding"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
</FrameLayout>
<View
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
</LinearLayout>

View file

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/package_delivered_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="64dp"
android:layout_marginStart="64dp"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle" />
<View
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp" />
</LinearLayout>

View file

@ -10,6 +10,8 @@
- For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy
-->
<string name="points_of_interests">Points of interests(POI)</string>
<string name="waiting_for_route_calculation">Waiting for route calculation</string>
<string name="app_mode_public_transport">Public transport</string>
<string name="avoid_roads_descr">Select road on the map or from the list below that you want to avoid during navigation:</string>
<string name="show_along_the_route">Show along the route</string>

View file

@ -20,6 +20,7 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
protected int titleColorId = INVALID_ID;
private TextView titleTv;
private ImageView iconView;
public SimpleBottomSheetItem(View customView,
@LayoutRes int layoutId,
@ -45,11 +46,17 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
titleTv.setText(title);
}
public void setIcon(Drawable icon) {
this.icon = icon;
iconView.setImageDrawable(icon);
}
@Override
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
super.inflate(app, container, nightMode);
if (icon != null) {
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(icon);
iconView = ((ImageView) view.findViewById(R.id.icon));
if (iconView != null) {
iconView.setImageDrawable(icon);
}
titleTv = (TextView) view.findViewById(R.id.title);
if (title != null && titleTv != null) {

View file

@ -0,0 +1,31 @@
package net.osmand.plus.base.bottomsheetmenu.simpleitems;
import android.content.Context;
import android.support.annotation.ColorRes;
import net.osmand.plus.R;
public class DividerStartItem extends DividerItem {
public DividerStartItem(Context context) {
super(context);
}
public DividerStartItem(Context context, @ColorRes int colorId) {
super(context, colorId);
}
public DividerStartItem(Context context, @ColorRes int colorId, int position) {
super(context, colorId, position);
}
@Override
protected int getBottomMargin(Context context) {
return context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_divider_margin_top);
}
@Override
protected int getLeftMargin(Context context) {
return context.getResources().getDimensionPixelSize(R.dimen.bottom_sheet_divider_margin_start);
}
}

View file

@ -186,7 +186,7 @@ public class AvoidSpecificRoads {
bld.show();
}
private void selectFromMap(final MapActivity mapActivity) {
public void selectFromMap(final MapActivity mapActivity) {
ContextMenuLayer cm = mapActivity.getMapLayers().getContextMenuLayer();
cm.setSelectOnMap(new CallbackWithObject<LatLon>() {
@Override

View file

@ -206,7 +206,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
((ImageView) v.findViewById(R.id.icon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_road_works_dark, !nightMode));
.setImageDrawable(app.getUIUtilities().getIcon(parameter.getActiveIconId(), !nightMode));
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
final TextView btn = (TextView) v.findViewById(R.id.select_button);
btn.setTextColor(btn.getLinkTextColors());
@ -300,7 +300,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.map_action_settings, !nightMode));
icon.setImageDrawable(app.getUIUtilities().getIcon(parameter.getActiveIconId(), !nightMode));
icon.setVisibility(View.VISIBLE);
TextView titleView = (TextView) v.findViewById(R.id.title);
titleView.setText(R.string.routing_settings_2);

View file

@ -136,7 +136,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
if (mapActivity != null) {
mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES);
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
app.getAvoidSpecificRoads().showDialog(mapActivity);
app.getAvoidSpecificRoads().selectFromMap(mapActivity);
Fragment fragment = getTargetFragment();
if (fragment != null) {
fragment.onActivityResult(getTargetRequestCode(), OPEN_AVOID_ROADS_DIALOG_REQUEST_CODE, null);

View file

@ -25,7 +25,6 @@ import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;
@ -64,13 +63,12 @@ import net.osmand.plus.helpers.AvoidSpecificRoads;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.FavouritesBottomSheetMenuFragment;
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.views.MapControlsLayer;
import net.osmand.router.GeneralRouter;
@ -551,15 +549,15 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (mode.parameters.size() <= 2) {
text = app.getString(active ? R.string.shared_string_on : R.string.shared_string_off);
}
View item = createToolbarOptionView(active, text, R.drawable.ic_action_volume_up, R.drawable.ic_action_volume_mute, new View.OnClickListener() {
View item = createToolbarOptionView(active, text, parameter.getActiveIconId(), parameter.getDisabledIconId(), new View.OnClickListener() {
@Override
public void onClick(View v) {
routingOptionsHelper.switchSound();
boolean active = !app.getRoutingHelper().getVoiceRouter().isMute();
String text = app.getString(active ? R.string.shared_string_on : R.string.shared_string_off);
Drawable itemDrawable = app.getUIUtilities().getIcon(active ? R.drawable.ic_action_volume_up : R.drawable.ic_action_volume_mute, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
Drawable activeItemDrawable = app.getUIUtilities().getIcon(active ? R.drawable.ic_action_volume_up : R.drawable.ic_action_volume_mute, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
Drawable itemDrawable = app.getUIUtilities().getIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
Drawable activeItemDrawable = app.getUIUtilities().getIcon(active ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
if (Build.VERSION.SDK_INT >= 21) {
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
@ -699,7 +697,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (selected != null) {
text = group.getText(mapActivity);
}
View item = createToolbarOptionView(false, text, R.drawable.mx_amenity_fuel, R.drawable.mx_amenity_fuel, new View.OnClickListener() {
View item = createToolbarOptionView(false, text, parameter.getActiveIconId(), parameter.getDisabledIconId(), new View.OnClickListener() {
@Override
public void onClick(View v) {
routingOptionsHelper.showLocalRoutingParameterGroupDialog(group, mapActivity, new RoutingOptionsHelper.OnClickListener() {
@ -722,21 +720,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
active = parameter.isSelected(settings);
}
text = parameter.getText(mapActivity);
View item = createToolbarOptionView(active, text, R.drawable.mx_amenity_fuel, R.drawable.mx_amenity_fuel, new View.OnClickListener() {
View item = createToolbarOptionView(active, text, parameter.getActiveIconId(), parameter.getDisabledIconId(), new View.OnClickListener() {
@Override
public void onClick(View v) {
if (parameter.routingParameter != null) {
boolean selected = parameter.isSelected(settings);
routingOptionsHelper.applyRoutingParameter(parameter, !selected);
boolean selected = !parameter.isSelected(settings);
routingOptionsHelper.applyRoutingParameter(parameter, selected);
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.mx_amenity_fuel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.mx_amenity_fuel, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
Drawable itemDrawable = app.getUIUtilities().getIcon(selected ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
Drawable activeItemDrawable = app.getUIUtilities().getIcon(selected ? parameter.getActiveIconId() : parameter.getDisabledIconId(), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
if (Build.VERSION.SDK_INT >= 21) {
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
}
((ImageView) v.findViewById(R.id.route_option_image_view)).setImageDrawable(!selected ? activeItemDrawable : itemDrawable);
((TextView) v.findViewById(R.id.route_option_title)).setTextColor(parameter.isSelected(settings) ? colorActive : colorDisabled);
((ImageView) v.findViewById(R.id.route_option_image_view)).setImageDrawable(selected ? activeItemDrawable : itemDrawable);
((TextView) v.findViewById(R.id.route_option_title)).setTextColor(selected ? colorActive : colorDisabled);
}
}
});
@ -1602,6 +1600,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
visible = false;
}
routingHelper.removeListener(this);
}
public void setShowMenu() {

View file

@ -6,7 +6,6 @@ import android.support.v4.app.FragmentManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject;
@ -25,7 +24,7 @@ import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.helpers.GpxUiHelper;
@ -52,14 +51,12 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = "RouteOptionsBottomSheet";
private OsmandSettings settings;
private OsmandApplication app;
private OsmandSettings settings;
private RoutingHelper routingHelper;
private RoutingOptionsHelper routingOptionsHelper;
private ApplicationMode applicationMode;
private MapActivity mapActivity;
private MapRouteInfoMenu mapRouteInfoMenu;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -76,159 +73,36 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
public void createMenuItems(Bundle savedInstanceState) {
items.add(new TitleItem(app.getString(R.string.shared_string_settings), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
List<LocalRoutingParameter> list = new ArrayList<>();
List<String> routingParameters = new ArrayList<>();
if (applicationMode.equals(ApplicationMode.CAR)) {
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.CAR.routingParameters);
routingParameters = AppModeOptions.CAR.routingParameters;
} else if (applicationMode.equals(ApplicationMode.BICYCLE)) {
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.BICYCLE.routingParameters);
routingParameters = AppModeOptions.BICYCLE.routingParameters;
} else if (applicationMode.equals(ApplicationMode.PEDESTRIAN)) {
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.PEDESTRIAN.routingParameters);
routingParameters = AppModeOptions.PEDESTRIAN.routingParameters;
}
List<LocalRoutingParameter> list = routingOptionsHelper.getRoutingParameters(applicationMode, routingParameters);
for (final LocalRoutingParameter optionsItem : list) {
if (optionsItem instanceof DividerItem) {
items.add(new DividerHalfItem(app));
items.add(new DividerStartItem(app));
} else if (optionsItem instanceof MuteSoundRoutingParameter) {
final BottomSheetItemWithCompoundButton[] muteSoundRoutingParameter = new BottomSheetItemWithCompoundButton[1];
muteSoundRoutingParameter[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!routingHelper.getVoiceRouter().isMute())
.setDescription(getString(R.string.voice_announcements))
.setIcon(getContentIcon(R.drawable.ic_action_volume_up))
.setTitle(getString(R.string.shared_string_sound))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
boolean mt = !routingHelper.getVoiceRouter().isMute();
settings.VOICE_MUTE.set(mt);
routingHelper.getVoiceRouter().setMute(mt);
muteSoundRoutingParameter[0].setChecked(!routingHelper.getVoiceRouter().isMute());
updateMenu();
}
})
.create();
items.add(muteSoundRoutingParameter[0]);
items.add(createMuteSoundItem(optionsItem));
} else if (optionsItem instanceof ShowAlongTheRouteItem) {
BaseBottomSheetItem showAlongTheRouteItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_show_along_route))
.setTitle(getString(R.string.show_along_the_route))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
if (!routingHelper.isRouteCalculated()) {
Toast.makeText(app, getText(R.string.show_along_the_route), Toast.LENGTH_LONG).show();
return;
}
FragmentManager fm = getFragmentManager();
if (fm == null) {
return;
}
Bundle args = new Bundle();
ShowAlongTheRouteBottomSheet fragment = new ShowAlongTheRouteBottomSheet();
fragment.setUsedOnMap(false);
fragment.setArguments(args);
fragment.setTargetFragment(RouteOptionsBottomSheet.this, ShowAlongTheRouteBottomSheet.REQUEST_CODE);
fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG);
updateMenu();
}
})
.create();
items.add(showAlongTheRouteItem);
items.add(createShowAlongTheRouteItem(optionsItem));
} else if (optionsItem instanceof RouteSimulationItem) {
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) == null) {
continue;
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) {
items.add(createRouteSimulationItem(optionsItem));
}
BaseBottomSheetItem routeSimulationItem = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final OsmAndLocationProvider loc = app.getLocationProvider();
loc.getLocationSimulation().startStopRouteAnimation(getActivity());
dismiss();
}
})
.create();
items.add(routeSimulationItem);
} else if (optionsItem instanceof AvoidRoadsTypesRoutingParameter) {
BaseBottomSheetItem avoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark))
.setTitle(getString(R.string.impassable_road))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
}
})
.create();
items.add(avoidRoadsRoutingParameter);
items.add(createAvoidRoadsTypesItem(optionsItem));
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
BaseBottomSheetItem avoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark))
.setTitle(getString(R.string.impassable_road))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
}
})
.create();
items.add(avoidRoadsRoutingParameter);
items.add(createAvoidRoadsItem(optionsItem));
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.GPXRouteTitle), nightMode);
final TextView gpxSpinner = (TextView) v.findViewById(R.id.GPXRouteSpinner);
AndroidUtils.setTextPrimaryColor(mapActivity, gpxSpinner, nightMode);
((ImageView) v.findViewById(R.id.dropDownIcon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
BaseBottomSheetItem gpxLocalRoutingParameter = new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.choose_track_file_to_follow))
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
.setTitle(getString(R.string.shared_string_gpx_route))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openGPXFileSelection();
}
})
.create();
items.add(gpxLocalRoutingParameter);
items.add(createGpxRoutingItem(optionsItem));
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
BaseBottomSheetItem otherSettingsRoutingParameter = new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.map_action_settings))
.setTitle(getString(R.string.routing_settings_2))
.setLayoutId(R.layout.bottom_sheet_item_simple)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
mapActivity.startActivity(settings);
}
})
.create();
items.add(otherSettingsRoutingParameter);
items.add(createOtherSettingsRoutingItem(optionsItem));
} else {
inflateRoutingParameter(optionsItem);
}
@ -240,14 +114,169 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
return R.string.shared_string_close;
}
private void inflateRoutingParameter(final LocalRoutingParameter optionsItem) {
if (optionsItem != null) {
final LocalRoutingParameter parameter = (LocalRoutingParameter) optionsItem;
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE
&& resultCode == AvoidRoadsBottomSheetDialogFragment.OPEN_AVOID_ROADS_DIALOG_REQUEST_CODE) {
dismiss();
}
if (requestCode == ShowAlongTheRouteBottomSheet.REQUEST_CODE
&& resultCode == ShowAlongTheRouteBottomSheet.SHOW_CONTENT_ITEM_REQUEST_CODE) {
dismiss();
}
}
private BaseBottomSheetItem createMuteSoundItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1];
muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(!routingHelper.getVoiceRouter().isMute())
.setDescription(getString(R.string.voice_announcements))
.setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId())))
.setTitle(getString(R.string.shared_string_sound))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
boolean mt = !routingHelper.getVoiceRouter().isMute();
settings.VOICE_MUTE.set(mt);
routingHelper.getVoiceRouter().setMute(mt);
muteSoundItem[0].setChecked(!routingHelper.getVoiceRouter().isMute());
muteSoundItem[0].setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId())));
updateMenu();
}
})
.create();
return muteSoundItem[0];
}
private BaseBottomSheetItem createShowAlongTheRouteItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.show_along_the_route))
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
FragmentManager fm = getFragmentManager();
if (fm == null) {
return;
}
Bundle args = new Bundle();
ShowAlongTheRouteBottomSheet fragment = new ShowAlongTheRouteBottomSheet();
fragment.setUsedOnMap(false);
fragment.setArguments(args);
fragment.setTargetFragment(RouteOptionsBottomSheet.this, ShowAlongTheRouteBottomSheet.REQUEST_CODE);
fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG);
updateMenu();
}
}).create();
}
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation))
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final OsmAndLocationProvider loc = app.getLocationProvider();
loc.getLocationSimulation().startStopRouteAnimation(getActivity());
dismiss();
}
})
.create();
}
private BaseBottomSheetItem createAvoidRoadsTypesItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.impassable_road))
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
}
})
.create();
}
private BaseBottomSheetItem createAvoidRoadsItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.impassable_road))
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu();
}
})
.create();
}
private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.GPXRouteTitle), nightMode);
final TextView gpxSpinner = (TextView) v.findViewById(R.id.GPXRouteSpinner);
AndroidUtils.setTextPrimaryColor(mapActivity, gpxSpinner, nightMode);
((ImageView) v.findViewById(R.id.dropDownIcon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
return new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.choose_track_file_to_follow))
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
.setTitle(getString(R.string.shared_string_gpx_route))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openGPXFileSelection();
}
})
.create();
}
private BaseBottomSheetItem createOtherSettingsRoutingItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(optionsItem.getActiveIconId()))
.setTitle(getString(R.string.routing_settings_2))
.setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
mapActivity.startActivity(settings);
}
})
.create();
}
private void inflateRoutingParameter(final LocalRoutingParameter parameter) {
if (parameter != null) {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder();
builder.setIcon(getContentIcon(R.drawable.ic_action_fuel));
if (parameter.routingParameter != null) {
builder.setTitle(parameter.getText(mapActivity));
int iconId = parameter.isSelected(settings) ? parameter.getActiveIconId() : parameter.getDisabledIconId();
if (iconId != -1) {
builder.setIcon(getContentIcon(iconId));
}
}
if (parameter instanceof LocalRoutingParameterGroup) {
final LocalRoutingParameterGroup group = (LocalRoutingParameterGroup) parameter;
@ -274,7 +303,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
}
});
} else {
builder.setLayoutId(R.layout.bottom_sheet_item_with_switch);
builder.setLayoutId(R.layout.bottom_sheet_item_with_switch_56dp);
if (parameter.routingParameter != null) {
if (parameter.routingParameter.getId().equals("short_way")) {
// if short route settings - it should be inverse of fast_route_mode
@ -287,10 +316,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void onClick(View v) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter);
boolean selected = parameter.isSelected(settings);
routingOptionsHelper.applyRoutingParameter(parameter, !selected);
item[0].setChecked(!selected);
boolean selected = !parameter.isSelected(settings);
routingOptionsHelper.applyRoutingParameter(parameter, selected);
item[0].setChecked(selected);
int iconId = selected ? parameter.getActiveIconId() : parameter.getDisabledIconId();
if (iconId != -1) {
item[0].setIcon(getContentIcon(iconId));
}
updateMenu();
}
});
@ -300,20 +332,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE
&& resultCode == AvoidRoadsBottomSheetDialogFragment.OPEN_AVOID_ROADS_DIALOG_REQUEST_CODE) {
dismiss();
}
if (requestCode == ShowAlongTheRouteBottomSheet.REQUEST_CODE
&& resultCode == ShowAlongTheRouteBottomSheet.SHOW_CONTENT_ITEM_REQUEST_CODE) {
dismiss();
}
}
private void updateMenu(){
private void updateMenu() {
final MapRouteInfoMenu mapRouteInfoMenu = getMapActivity().getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
if (mapRouteInfoMenu != null) {
mapRouteInfoMenu.updateMenu();
@ -359,6 +378,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DRIVING_STYLE,
GeneralRouter.USE_HEIGHT_OBSTACLES,
DividerItem.KEY,
GeneralRouter.ALLOW_MOTORWAYS,
AvoidRoadsTypesRoutingParameter.KEY,
ShowAlongTheRouteItem.KEY,
DividerItem.KEY,

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.util.TypedValue;
@ -269,6 +270,7 @@ public class RoutingOptionsHelper {
for (String itemId : routingParameters) {
LocalRoutingParameter item = getItem(am, itemId);
if (item != null) {
updateRoutingParameterIcons(item);
list.add(item);
}
}
@ -455,6 +457,7 @@ public class RoutingOptionsHelper {
} else {
LocalRoutingParameter rp = new LocalRoutingParameter(am);
rp.routingParameter = r;
updateRoutingParameterIcons(rp);
list.add(rp);
}
}
@ -463,6 +466,50 @@ public class RoutingOptionsHelper {
return list;
}
private static void updateRoutingParameterIcons(LocalRoutingParameter rp) {
if (rp.routingParameter == null) {
return;
}
switch (rp.routingParameter.getId()) {
case GeneralRouter.USE_SHORTEST_WAY:
rp.activeIconId = R.drawable.ic_action_fuel;
rp.disabledIconId = R.drawable.ic_action_fuel;
break;
case GeneralRouter.USE_HEIGHT_OBSTACLES:
rp.activeIconId = R.drawable.ic_action_elevation;
rp.disabledIconId = R.drawable.ic_action_elevation;
break;
case GeneralRouter.AVOID_FERRIES:
rp.activeIconId = R.drawable.ic_action_fuel;
rp.disabledIconId = R.drawable.ic_action_fuel;
break;
case GeneralRouter.AVOID_TOLL:
rp.activeIconId = R.drawable.ic_action_fuel;
rp.disabledIconId = R.drawable.ic_action_fuel;
break;
case GeneralRouter.AVOID_MOTORWAY:
rp.activeIconId = R.drawable.ic_action_motorways;
rp.disabledIconId = R.drawable.ic_action_avoid_motorways;
break;
case GeneralRouter.AVOID_UNPAVED:
rp.activeIconId = R.drawable.ic_action_fuel;
rp.disabledIconId = R.drawable.ic_action_fuel;
break;
case GeneralRouter.PREFER_MOTORWAYS:
rp.activeIconId = R.drawable.ic_action_motorways;
rp.activeIconId = R.drawable.ic_action_avoid_motorways;
break;
case GeneralRouter.ALLOW_PRIVATE:
rp.activeIconId = R.drawable.ic_action_allow_private_access;
rp.disabledIconId = R.drawable.ic_action_forbid_private_access;
break;
case GeneralRouter.ALLOW_MOTORWAYS:
rp.activeIconId = R.drawable.ic_action_motorways;
rp.disabledIconId = R.drawable.ic_action_avoid_motorways;
break;
}
}
public static LocalRoutingParameterGroup getLocalRoutingParameterGroup(List<LocalRoutingParameter> list, String groupName) {
for (LocalRoutingParameter p : list) {
if (p instanceof LocalRoutingParameterGroup && groupName.equals(((LocalRoutingParameterGroup) p).getGroupName())) {
@ -489,7 +536,7 @@ public class RoutingOptionsHelper {
public GeneralRouter.RoutingParameter getRoutingPrefsForAppModeById(ApplicationMode applicationMode, String parameterId) {
GeneralRouter router = getRouter(app.getDefaultRoutingConfig(), applicationMode);
GeneralRouter.RoutingParameter parameter=null;
GeneralRouter.RoutingParameter parameter = null;
if (router != null) {
parameter = router.getParameters().get(parameterId);
@ -506,6 +553,13 @@ public class RoutingOptionsHelper {
private ApplicationMode am;
@DrawableRes
public
int activeIconId = -1;
@DrawableRes
int disabledIconId = -1;
public boolean canAddToRouteMenu() {
return true;
}
@ -517,6 +571,14 @@ public class RoutingOptionsHelper {
return KEY;
}
public int getActiveIconId() {
return activeIconId;
}
public int getDisabledIconId() {
return disabledIconId;
}
public LocalRoutingParameter(ApplicationMode am) {
this.am = am;
}
@ -613,12 +675,22 @@ public class RoutingOptionsHelper {
public static final String KEY = "MuteSoundRoutingParameter";
public MuteSoundRoutingParameter() {
super(null);
}
public String getId() {
return KEY;
}
public MuteSoundRoutingParameter() {
super(null);
@Override
public int getActiveIconId() {
return R.drawable.ic_action_volume_up;
}
@Override
public int getDisabledIconId() {
return R.drawable.ic_action_volume_mute;
}
}
@ -660,12 +732,22 @@ public class RoutingOptionsHelper {
public static final String KEY = "ShowAlongTheRouteItem";
public ShowAlongTheRouteItem() {
super(null);
}
public String getId() {
return KEY;
}
public ShowAlongTheRouteItem() {
super(null);
@Override
public int getActiveIconId() {
return R.drawable.ic_action_show_along_route;
}
@Override
public int getDisabledIconId() {
return R.drawable.ic_action_show_along_route;
}
}
@ -673,28 +755,46 @@ public class RoutingOptionsHelper {
public static final String KEY = "AvoidRoadsRoutingParameter";
public String getId() {
return KEY;
}
public AvoidRoadsRoutingParameter() {
super(null);
}
public String getId() {
return KEY;
}
@Override
public int getActiveIconId() {
return R.drawable.ic_action_road_works_dark;
}
@Override
public int getDisabledIconId() {
return R.drawable.ic_action_road_works_dark;
}
}
public static class AvoidRoadsTypesRoutingParameter extends LocalRoutingParameter {
public static final String KEY = "AvoidRoadsTypesRoutingParameter";
public String getId() {
return KEY;
}
public AvoidRoadsTypesRoutingParameter() {
super(null);
}
public String getId() {
return KEY;
}
@Override
public int getActiveIconId() {
return R.drawable.ic_action_road_works_dark;
}
@Override
public int getDisabledIconId() {
return R.drawable.ic_action_road_works_dark;
}
}
public static class GpxLocalRoutingParameter extends LocalRoutingParameter {
@ -718,6 +818,10 @@ public class RoutingOptionsHelper {
public static final String KEY = "OtherSettingsRoutingParameter";
public OtherSettingsRoutingParameter() {
super(null);
}
public String getId() {
return KEY;
}
@ -726,8 +830,14 @@ public class RoutingOptionsHelper {
return false;
}
public OtherSettingsRoutingParameter() {
super(null);
@Override
public int getActiveIconId() {
return R.drawable.map_action_settings;
}
@Override
public int getDisabledIconId() {
return R.drawable.map_action_settings;
}
}

View file

@ -1,6 +1,5 @@
package net.osmand.plus.routepreparationmenu;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
@ -22,13 +21,10 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.ValueHolder;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
@ -38,14 +34,13 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.SimpleDividerItem;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.plus.routing.IRouteInformationListener;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment {
public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment implements IRouteInformationListener {
public static final String TAG = "ShowAlongTheRouteBottomSheet";
@ -61,6 +56,14 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
private ExpandableListView expListView;
private ExpandableListAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
mapActivity = (MapActivity) getActivity();
waypointHelper = app.getWaypointHelper();
}
@Override
public void createMenuItems(Bundle savedInstanceState) {
Context ctx = getContext();
@ -68,9 +71,6 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
if (ctx == null || args == null) {
return;
}
app = getMyApplication();
mapActivity = (MapActivity) getActivity();
waypointHelper = app.getWaypointHelper();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View titleView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_item_toolbar_title, null);
@ -92,56 +92,22 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
.create();
items.add(titleItem);
if (waypointHelper.isRouteCalculated()) {
final ContentItem contentItem = getAdapterContentItems();
final ContentItem contentItem = getAdapterContentItems();
items.add(new SimpleDividerItem(app));
items.add(new SimpleDividerItem(app));
Drawable transparent = ContextCompat.getDrawable(ctx, R.color.color_transparent);
adapter = new ExpandableListAdapter(ctx, contentItem);
expListView = new ExpandableListView(ctx);
expListView.setAdapter(adapter);
expListView.setDivider(transparent);
expListView.setGroupIndicator(transparent);
expListView.setSelector(transparent);
expListView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
LinearLayout container = new LinearLayout(ctx);
container.addView(expListView);
Drawable transparent = ContextCompat.getDrawable(ctx, R.color.color_transparent);
adapter = new ExpandableListAdapter(ctx, contentItem);
expListView = new ExpandableListView(ctx);
expListView.setAdapter(adapter);
expListView.setDivider(transparent);
expListView.setGroupIndicator(transparent);
expListView.setSelector(transparent);
expListView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
LinearLayout container = new LinearLayout(ctx);
container.addView(expListView);
items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create());
}
}
protected String getCategotyTitle(int type, Context ctx) {
String str = ctx.getString(R.string.shared_string_waypoints);
switch (type) {
case WaypointHelper.TARGETS:
str = ctx.getString(R.string.shared_string_target_points);
break;
case WaypointHelper.ALARMS:
str = ctx.getString(R.string.way_alarms);
break;
case WaypointHelper.FAVORITES:
str = ctx.getString(R.string.shared_string_my_favorites);
break;
case WaypointHelper.WAYPOINTS:
str = ctx.getString(R.string.shared_string_waypoints);
break;
case WaypointHelper.POI:
str = ctx.getString(R.string.poi);
break;
}
return str;
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}
@Override
protected int getBgColorId() {
return nightMode ? R.color.wikivoyage_bottom_bar_bg_dark : R.color.bg_color_light;
items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create());
}
@Override
@ -155,34 +121,63 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
}
private ContentItem getAdapterContentItems() {
final ContentItem contentItem = new ContentItem("items", null);
if (waypointHelper.isRouteCalculated()) {
for (int i = 2; i < WaypointHelper.MAX; i++) {
List<WaypointHelper.LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
ContentItem headerItem = new ContentItem(getCategotyTitle(i, app), contentItem);
contentItem.subItems.add(headerItem);
headerItem.type = i;
final ContentItem contentItem = new ContentItem();
for (int i = 2; i < WaypointHelper.MAX; i++) {
List<WaypointHelper.LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
ContentItem headerItem = new PointItem(i);
contentItem.subItems.add(headerItem);
headerItem.type = i;
if (waypointHelper.isRouteCalculated()) {
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES) && waypointHelper.isTypeEnabled(i)) {
ContentItem radiusItem = new ContentItem("radius", contentItem);
ContentItem radiusItem = new RadiusItem(i);
headerItem.subItems.add(radiusItem);
}
if (tp != null && tp.size() > 0) {
for (int j = 0; j < tp.size(); j++) {
WaypointHelper.LocationPointWrapper pointWrapper = tp.get(j);
String title = pointWrapper.getPoint().getPointDescription(app).getName();
ContentItem subheaderItem = new ContentItem(title, headerItem);
PointItem subheaderItem = new PointItem(pointWrapper.type);
headerItem.subItems.add(subheaderItem);
subheaderItem.point = pointWrapper;
}
}
} else {
ContentItem infoItem = new InfoItem(i);
headerItem.subItems.add(infoItem);
}
}
return contentItem;
}
@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
updateAdapter();
}
@Override
public void routeWasCancelled() {
}
@Override
public void routeWasFinished() {
}
@Override
public void onPause() {
super.onPause();
app.getRoutingHelper().removeListener(this);
}
@Override
public void onResume() {
super.onResume();
app.getRoutingHelper().addListener(this);
}
private void updateAdapter() {
if (adapter != null) {
adapter.contentItem = getAdapterContentItems();
@ -203,7 +198,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
@Override
public Object getChild(int groupPosition, int childPosititon) {
return contentItem.getSubItems().get(groupPosition).getSubItems().get(childPosititon).getName();
return contentItem.getSubItems().get(groupPosition).getSubItems().get(childPosititon);
}
@Override
@ -214,20 +209,22 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
@Override
public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
ContentItem group = contentItem.getSubItems().get(groupPosition);
final ContentItem group = contentItem.getSubItems().get(groupPosition);
final ContentItem child = group.getSubItems().get(childPosition);
if (child.name.equals("radius")) {
if (child instanceof RadiusItem) {
convertView = createItemForRadiusProximity(group.type, nightMode);
} else {
convertView = LayoutInflater.from(context)
.inflate(R.layout.bottom_sheet_item_show_along_the_route, parent, false);
updatePointInfoView(app, mapActivity, convertView, group, child);
} else if (child instanceof InfoItem) {
convertView = createInfoItem();
} else if (child instanceof PointItem) {
final PointItem item = (PointItem) child;
convertView = LayoutInflater.from(context).inflate(R.layout.along_the_route_point_item, parent, false);
WaypointDialogHelper.updatePointInfoView(app, mapActivity, convertView, item.point, true, nightMode, true, false);
convertView.setOnClickListener(new View.OnClickListener() {
convertView.findViewById(R.id.waypoint_container).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WaypointDialogHelper.showOnMap(app, mapActivity, child.point.getPoint(), false);
WaypointDialogHelper.showOnMap(app, mapActivity, item.point.getPoint(), false);
Fragment fragment = getTargetFragment();
if (fragment != null) {
fragment.onActivityResult(getTargetRequestCode(), SHOW_CONTENT_ITEM_REQUEST_CODE, null);
@ -235,109 +232,32 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
dismiss();
}
});
final ImageButton remove = (ImageButton) convertView.findViewById(R.id.info_close);
remove.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark));
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getWaypointHelper().removeVisibleLocationPoint(item.point);
group.subItems.remove(item);
adapter.notifyDataSetChanged();
}
});
}
View bottomDivider = convertView.findViewById(R.id.bottom_divider);
if (bottomDivider != null) {
bottomDivider.setVisibility(isLastChild ? View.VISIBLE : View.GONE);
AndroidUtils.setBackground(app, bottomDivider, nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
}
if (child instanceof RadiusItem && group.type == WaypointHelper.POI) {
convertView.findViewById(R.id.divider).setVisibility(isLastChild ? View.GONE : View.VISIBLE);
}
return convertView;
}
private void updatePointInfoView(final OsmandApplication app, final Activity activity,
View localView, final ContentItem group, final ContentItem item) {
WaypointHelper wh = app.getWaypointHelper();
final WaypointHelper.LocationPointWrapper ps = item.point;
final LocationPoint point = ps.getPoint();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
AndroidUtils.setTextPrimaryColor(activity, text, nightMode);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
final ImageButton remove = (ImageButton) localView.findViewById(R.id.info_close);
remove.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark));
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
app.getWaypointHelper().removeVisibleLocationPoint(ps);
group.subItems.remove(item);
adapter.notifyDataSetChanged();
}
});
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(activity, app, nightMode));
int dist = -1;
boolean startPoint = ps.type == WaypointHelper.TARGETS && ((TargetPointsHelper.TargetPoint) ps.point).start;
if (!startPoint) {
if (!wh.isRouteCalculated()) {
if (activity instanceof MapActivity) {
dist = (int) MapUtils.getDistance(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity)
.getMapView().getLongitude(), point.getLatitude(), point.getLongitude());
}
} else {
dist = wh.getRouteDistance(ps);
}
}
if (dist > 0) {
textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app));
} else {
textDist.setText("");
}
TextView textDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation);
if (textDeviation != null) {
if (dist > 0 && ps.deviationDistance > 0) {
String devStr = "+" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
textDeviation.setText(devStr);
int colorId = nightMode ? R.color.secondary_text_dark : R.color.secondary_text_light;
AndroidUtils.setTextSecondaryColor(activity, textDeviation, nightMode);
if (ps.deviationDirectionRight) {
textDeviation.setCompoundDrawablesWithIntrinsicBounds(
app.getUIUtilities().getIcon(R.drawable.ic_small_turn_right, colorId),
null, null, null);
} else {
textDeviation.setCompoundDrawablesWithIntrinsicBounds(
app.getUIUtilities().getIcon(R.drawable.ic_small_turn_left, colorId),
null, null, null);
}
textDeviation.setVisibility(View.VISIBLE);
} else {
textDeviation.setText("");
textDeviation.setVisibility(View.GONE);
}
}
String descr;
PointDescription pd = point.getPointDescription(app);
if (Algorithms.isEmpty(pd.getName())) {
descr = pd.getTypeName();
} else {
descr = pd.getName();
}
if (textShadow != null) {
textShadow.setText(descr);
}
text.setText(descr);
String pointDescription = "";
TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text);
if (descText != null) {
AndroidUtils.setTextSecondaryColor(activity, descText, nightMode);
if (ps.type == WaypointHelper.FAVORITES) {
FavouritePoint favPoint = (FavouritePoint) ps.point;
pointDescription = Algorithms.isEmpty(favPoint.getCategory()) ? activity.getResources().getString(R.string.shared_string_favorites) : favPoint.getCategory();
}
}
if (Algorithms.objectEquals(descr, pointDescription)) {
pointDescription = "";
}
if (dist > 0 && !Algorithms.isEmpty(pointDescription)) {
pointDescription = "" + pointDescription;
}
if (descText != null) {
descText.setText(pointDescription);
}
}
@Override
public int getChildrenCount(int groupPosition) {
return contentItem.getSubItems().get(groupPosition).getSubItems().size();
@ -370,7 +290,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
.inflate(R.layout.along_the_route_category_item, parent, false);
}
TextView lblListHeader = (TextView) convertView.findViewById(R.id.title);
lblListHeader.setText(group.name);
lblListHeader.setText(getHeader(group.type, mapActivity));
lblListHeader.setTextColor(ContextCompat.getColor(context, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
adjustIndicator(app, groupPosition, isExpanded, convertView, !nightMode);
@ -387,6 +307,9 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} else {
enableType(type, isChecked);
}
if (isChecked) {
expListView.expandGroup(groupPosition);
}
}
});
@ -403,19 +326,66 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
}
});
View topDivider = convertView.findViewById(R.id.top_divider);
View bottomDivider = convertView.findViewById(R.id.bottom_divider);
AndroidUtils.setBackground(app, topDivider, nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
AndroidUtils.setBackground(app, bottomDivider, nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
bottomDivider.setVisibility(isExpanded ? View.GONE : View.VISIBLE);
AndroidUtils.setBackground(app, bottomDivider, nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
@Override
protected void adjustIndicator(OsmandApplication app, int groupPosition, boolean isExpanded, View row, boolean light) {
ImageView indicator = (ImageView) row.findViewById(R.id.icon);
if (!isExpanded) {
indicator.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_down, light));
indicator.setContentDescription(row.getContext().getString(R.string.access_collapsed_list));
} else {
indicator.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_up, light));
indicator.setContentDescription(row.getContext().getString(R.string.access_expanded_list));
}
}
private String getHeader(int type, Context ctx) {
String str = ctx.getString(R.string.shared_string_waypoints);
switch (type) {
case WaypointHelper.TARGETS:
str = ctx.getString(R.string.shared_string_target_points);
break;
case WaypointHelper.ALARMS:
str = ctx.getString(R.string.way_alarms);
break;
case WaypointHelper.FAVORITES:
str = ctx.getString(R.string.shared_string_my_favorites);
break;
case WaypointHelper.WAYPOINTS:
str = ctx.getString(R.string.shared_string_waypoints);
break;
case WaypointHelper.POI:
str = ctx.getString(R.string.points_of_interests);
break;
}
return str;
}
private View createInfoItem() {
View view = mapActivity.getLayoutInflater().inflate(R.layout.show_along_the_route_info_item, null);
TextView titleTv = (TextView) view.findViewById(R.id.title);
titleTv.setText(getText(R.string.waiting_for_route_calculation));
return view;
}
private View createItemForRadiusProximity(final int type, boolean nightMode) {
View v;
if (type == WaypointHelper.POI) {
@ -450,7 +420,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
});
AndroidUtils.setBackground(app, v.findViewById(R.id.top_divider), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
AndroidUtils.setBackground(app, v.findViewById(R.id.bottom_divider), nightMode,
AndroidUtils.setBackground(app, v.findViewById(R.id.divider), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
} else {
v = mapActivity.getLayoutInflater().inflate(R.layout.along_the_route_radius_simple, null);
@ -458,7 +428,8 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode);
final TextView radius = (TextView) v.findViewById(R.id.description);
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app));
radius.setOnClickListener(new View.OnClickListener() {
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
selectDifferentRadius(type);
@ -468,16 +439,6 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
}
return v;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
}
private void selectPoi(final int type, final boolean enable) {
@ -588,29 +549,43 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
}
}
public static class ContentItem {
private static class ContentItem {
private int type;
private String name;
private ArrayList<ContentItem> subItems = new ArrayList<>();
private ContentItem parent;
private WaypointHelper.LocationPointWrapper point;
private ContentItem(String name, ContentItem parent) {
this.parent = parent;
this.name = name;
private ContentItem(int type) {
this.type = type;
}
public String getName() {
return name;
private ContentItem() {
}
public ContentItem getParent() {
return parent;
}
public ArrayList<ContentItem> getSubItems() {
private ArrayList<ContentItem> getSubItems() {
return subItems;
}
}
private static class RadiusItem extends ContentItem {
private RadiusItem(int type) {
super(type);
}
}
private static class InfoItem extends ContentItem {
private InfoItem(int type) {
super(type);
}
}
private static class PointItem extends ContentItem {
private WaypointHelper.LocationPointWrapper point;
private PointItem(int type) {
super(type);
}
}
}