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 AVOID_UNPAVED = "avoid_unpaved";
public static final String PREFER_MOTORWAYS = "prefer_motorway"; public static final String PREFER_MOTORWAYS = "prefer_motorway";
public static final String ALLOW_PRIVATE = "allow_private"; public static final String ALLOW_PRIVATE = "allow_private";
public static final String ALLOW_MOTORWAYS = "allow_motorway";
private final RouteAttributeContext[] objectAttributes; private final RouteAttributeContext[] objectAttributes;
public final Map<String, String> attributes; public final Map<String, String> attributes;

View file

@ -8,18 +8,13 @@
android:minHeight="@dimen/bottom_sheet_selected_item_title_height" android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:orientation="vertical"> android:orientation="vertical">
<View
android:id="@+id/top_divider"
android:layout_width="match_parent"
android:layout_height="1dp" />
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height" android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<ImageView <ImageView
android:id="@+id/explist_indicator" android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" 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,11 +3,16 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:minHeight="56dp" android:minHeight="56dp"
android:orientation="vertical" android:orientation="vertical">
android:paddingLeft="@dimen/route_info_start_divider_margin"
android:paddingStart="@dimen/route_info_start_divider_margin"> <LinearLayout
android:layout_width="match_parent"
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 <View
android:id="@+id/top_divider" android:id="@+id/top_divider"
@ -16,16 +21,21 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="56dp"
android:baselineAligned="false"
android:orientation="horizontal"> android:orientation="horizontal">
<LinearLayout <LinearLayout
android:id="@+id/firstCellContainer" android:id="@+id/firstCellContainer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -50,13 +60,20 @@
</LinearLayout> </LinearLayout>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/secondCellContainer" android:id="@+id/secondCellContainer"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:background="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
@ -72,7 +89,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:textColor="@color/color_myloc_distance" android:textColor="@color/color_myloc_distance"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
@ -83,9 +99,19 @@
</LinearLayout> </LinearLayout>
</LinearLayout>
<View <View
android:id="@+id/bottom_divider" android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" /> android:layout_height="1dp" />
</LinearLayout> </LinearLayout>
<View
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="8dp" />
</LinearLayout>

View file

@ -2,6 +2,12 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto" xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="44dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
@ -32,3 +38,11 @@
tools:text="500 m" /> tools:text="500 m" />
</LinearLayout> </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 - For wording and consistency, please note https://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy 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="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="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> <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; protected int titleColorId = INVALID_ID;
private TextView titleTv; private TextView titleTv;
private ImageView iconView;
public SimpleBottomSheetItem(View customView, public SimpleBottomSheetItem(View customView,
@LayoutRes int layoutId, @LayoutRes int layoutId,
@ -45,11 +46,17 @@ public class SimpleBottomSheetItem extends BaseBottomSheetItem {
titleTv.setText(title); titleTv.setText(title);
} }
public void setIcon(Drawable icon) {
this.icon = icon;
iconView.setImageDrawable(icon);
}
@Override @Override
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) { public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
super.inflate(app, container, nightMode); super.inflate(app, container, nightMode);
if (icon != null) { iconView = ((ImageView) view.findViewById(R.id.icon));
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(icon); if (iconView != null) {
iconView.setImageDrawable(icon);
} }
titleTv = (TextView) view.findViewById(R.id.title); titleTv = (TextView) view.findViewById(R.id.title);
if (title != null && titleTv != null) { 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(); bld.show();
} }
private void selectFromMap(final MapActivity mapActivity) { public void selectFromMap(final MapActivity mapActivity) {
ContextMenuLayer cm = mapActivity.getMapLayers().getContextMenuLayer(); ContextMenuLayer cm = mapActivity.getMapLayers().getContextMenuLayer();
cm.setSelectOnMap(new CallbackWithObject<LatLon>() { cm.setSelectOnMap(new CallbackWithObject<LatLon>() {
@Override @Override

View file

@ -206,7 +206,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.switch_select_list_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
((ImageView) v.findViewById(R.id.icon)) ((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); v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
final TextView btn = (TextView) v.findViewById(R.id.select_button); final TextView btn = (TextView) v.findViewById(R.id.select_button);
btn.setTextColor(btn.getLinkTextColors()); btn.setTextColor(btn.getLinkTextColors());
@ -300,7 +300,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final ImageView icon = (ImageView) v.findViewById(R.id.icon); 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); icon.setVisibility(View.VISIBLE);
TextView titleView = (TextView) v.findViewById(R.id.title); TextView titleView = (TextView) v.findViewById(R.id.title);
titleView.setText(R.string.routing_settings_2); titleView.setText(R.string.routing_settings_2);

View file

@ -136,7 +136,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES); mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES);
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide(); mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
app.getAvoidSpecificRoads().showDialog(mapActivity); app.getAvoidSpecificRoads().selectFromMap(mapActivity);
Fragment fragment = getTargetFragment(); Fragment fragment = getTargetFragment();
if (fragment != null) { if (fragment != null) {
fragment.onActivityResult(getTargetRequestCode(), OPEN_AVOID_ROADS_DIALOG_REQUEST_CODE, 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.HorizontalScrollView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; 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.GpxUiHelper;
import net.osmand.plus.helpers.MapMarkerDialogHelper; import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.other.FavouritesBottomSheetMenuFragment; import net.osmand.plus.mapcontextmenu.other.FavouritesBottomSheetMenuFragment;
import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment; import net.osmand.plus.mapmarkers.MapMarkerSelectionFragment;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapControlsLayer;
import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter;
@ -551,15 +549,15 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (mode.parameters.size() <= 2) { if (mode.parameters.size() <= 2) {
text = app.getString(active ? R.string.shared_string_on : R.string.shared_string_off); 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 @Override
public void onClick(View v) { public void onClick(View v) {
routingOptionsHelper.switchSound(); routingOptionsHelper.switchSound();
boolean active = !app.getRoutingHelper().getVoiceRouter().isMute(); boolean active = !app.getRoutingHelper().getVoiceRouter().isMute();
String text = app.getString(active ? R.string.shared_string_on : R.string.shared_string_off); 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 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 ? 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 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) { if (Build.VERSION.SDK_INT >= 21) {
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable); itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
@ -699,7 +697,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
if (selected != null) { if (selected != null) {
text = group.getText(mapActivity); 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 @Override
public void onClick(View v) { public void onClick(View v) {
routingOptionsHelper.showLocalRoutingParameterGroupDialog(group, mapActivity, new RoutingOptionsHelper.OnClickListener() { routingOptionsHelper.showLocalRoutingParameterGroupDialog(group, mapActivity, new RoutingOptionsHelper.OnClickListener() {
@ -722,21 +720,21 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
active = parameter.isSelected(settings); active = parameter.isSelected(settings);
} }
text = parameter.getText(mapActivity); 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 @Override
public void onClick(View v) { public void onClick(View v) {
if (parameter.routingParameter != null) { if (parameter.routingParameter != null) {
boolean selected = parameter.isSelected(settings); boolean selected = !parameter.isSelected(settings);
routingOptionsHelper.applyRoutingParameter(parameter, !selected); 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 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(R.drawable.mx_amenity_fuel, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_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) { if (Build.VERSION.SDK_INT >= 21) {
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable); itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
} }
((ImageView) v.findViewById(R.id.route_option_image_view)).setImageDrawable(!selected ? activeItemDrawable : itemDrawable); ((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); ((TextView) v.findViewById(R.id.route_option_title)).setTextColor(selected ? colorActive : colorDisabled);
} }
} }
}); });
@ -1602,6 +1600,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else { } else {
visible = false; visible = false;
} }
routingHelper.removeListener(this);
} }
public void setShowMenu() { public void setShowMenu() {

View file

@ -6,7 +6,6 @@ import android.support.v4.app.FragmentManager;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.CallbackWithObject; 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.BottomSheetItemWithCompoundButton;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; 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.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
@ -52,14 +51,12 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = "RouteOptionsBottomSheet"; public static final String TAG = "RouteOptionsBottomSheet";
private OsmandSettings settings;
private OsmandApplication app; private OsmandApplication app;
private OsmandSettings settings;
private RoutingHelper routingHelper; private RoutingHelper routingHelper;
private RoutingOptionsHelper routingOptionsHelper; private RoutingOptionsHelper routingOptionsHelper;
private ApplicationMode applicationMode; private ApplicationMode applicationMode;
private MapActivity mapActivity; private MapActivity mapActivity;
private MapRouteInfoMenu mapRouteInfoMenu;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -76,24 +73,66 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
public void createMenuItems(Bundle savedInstanceState) { 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)); 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)) { if (applicationMode.equals(ApplicationMode.CAR)) {
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.CAR.routingParameters); routingParameters = AppModeOptions.CAR.routingParameters;
} else if (applicationMode.equals(ApplicationMode.BICYCLE)) { } else if (applicationMode.equals(ApplicationMode.BICYCLE)) {
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.BICYCLE.routingParameters); routingParameters = AppModeOptions.BICYCLE.routingParameters;
} else if (applicationMode.equals(ApplicationMode.PEDESTRIAN)) { } 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) { for (final LocalRoutingParameter optionsItem : list) {
if (optionsItem instanceof DividerItem) { if (optionsItem instanceof DividerItem) {
items.add(new DividerHalfItem(app)); items.add(new DividerStartItem(app));
} else if (optionsItem instanceof MuteSoundRoutingParameter) { } else if (optionsItem instanceof MuteSoundRoutingParameter) {
final BottomSheetItemWithCompoundButton[] muteSoundRoutingParameter = new BottomSheetItemWithCompoundButton[1]; items.add(createMuteSoundItem(optionsItem));
muteSoundRoutingParameter[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() } else if (optionsItem instanceof ShowAlongTheRouteItem) {
items.add(createShowAlongTheRouteItem(optionsItem));
} else if (optionsItem instanceof RouteSimulationItem) {
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) != null) {
items.add(createRouteSimulationItem(optionsItem));
}
} else if (optionsItem instanceof AvoidRoadsTypesRoutingParameter) {
items.add(createAvoidRoadsTypesItem(optionsItem));
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
items.add(createAvoidRoadsItem(optionsItem));
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
items.add(createGpxRoutingItem(optionsItem));
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
items.add(createOtherSettingsRoutingItem(optionsItem));
} else {
inflateRoutingParameter(optionsItem);
}
}
}
@Override
protected int getDismissButtonTextId() {
return R.string.shared_string_close;
}
@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()) .setChecked(!routingHelper.getVoiceRouter().isMute())
.setDescription(getString(R.string.voice_announcements)) .setDescription(getString(R.string.voice_announcements))
.setIcon(getContentIcon(R.drawable.ic_action_volume_up)) .setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId())))
.setTitle(getString(R.string.shared_string_sound)) .setTitle(getString(R.string.shared_string_sound))
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp) .setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@ -103,26 +142,24 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
boolean mt = !routingHelper.getVoiceRouter().isMute(); boolean mt = !routingHelper.getVoiceRouter().isMute();
settings.VOICE_MUTE.set(mt); settings.VOICE_MUTE.set(mt);
routingHelper.getVoiceRouter().setMute(mt); routingHelper.getVoiceRouter().setMute(mt);
muteSoundRoutingParameter[0].setChecked(!routingHelper.getVoiceRouter().isMute()); muteSoundItem[0].setChecked(!routingHelper.getVoiceRouter().isMute());
muteSoundItem[0].setIcon(getContentIcon((routingHelper.getVoiceRouter().isMute() ? optionsItem.getDisabledIconId() : optionsItem.getActiveIconId())));
updateMenu(); updateMenu();
} }
}) })
.create(); .create();
items.add(muteSoundRoutingParameter[0]); return muteSoundItem[0];
}
} else if (optionsItem instanceof ShowAlongTheRouteItem) { private BaseBottomSheetItem createShowAlongTheRouteItem(final LocalRoutingParameter optionsItem) {
BaseBottomSheetItem showAlongTheRouteItem = new SimpleBottomSheetItem.Builder() return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_show_along_route)) .setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.show_along_the_route)) .setTitle(getString(R.string.show_along_the_route))
.setLayoutId(R.layout.bottom_sheet_item_simple) .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); 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(); FragmentManager fm = getFragmentManager();
if (fm == null) { if (fm == null) {
return; return;
@ -135,17 +172,14 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG); fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG);
updateMenu(); updateMenu();
} }
}) }).create();
.create();
items.add(showAlongTheRouteItem);
} else if (optionsItem instanceof RouteSimulationItem) {
if (OsmandPlugin.getEnabledPlugin(OsmandDevelopmentPlugin.class) == null) {
continue;
} }
BaseBottomSheetItem routeSimulationItem = new SimpleBottomSheetItem.Builder()
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation)) .setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation)) .setTitle(getString(R.string.simulate_navigation))
.setLayoutId(R.layout.bottom_sheet_item_simple) .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -155,12 +189,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
}) })
.create(); .create();
items.add(routeSimulationItem); }
} else if (optionsItem instanceof AvoidRoadsTypesRoutingParameter) {
BaseBottomSheetItem avoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder() private BaseBottomSheetItem createAvoidRoadsTypesItem(final LocalRoutingParameter optionsItem) {
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark)) return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.impassable_road)) .setTitle(getString(R.string.impassable_road))
.setLayoutId(R.layout.bottom_sheet_item_simple) .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -172,12 +207,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
}) })
.create(); .create();
items.add(avoidRoadsRoutingParameter); }
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
BaseBottomSheetItem avoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder() private BaseBottomSheetItem createAvoidRoadsItem(final LocalRoutingParameter optionsItem) {
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark)) return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.impassable_road)) .setTitle(getString(R.string.impassable_road))
.setLayoutId(R.layout.bottom_sheet_item_simple) .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -189,8 +225,9 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
}) })
.create(); .create();
items.add(avoidRoadsRoutingParameter); }
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null); View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.GPXRouteTitle), nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.GPXRouteTitle), nightMode);
@ -199,7 +236,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
((ImageView) v.findViewById(R.id.dropDownIcon)) ((ImageView) v.findViewById(R.id.dropDownIcon))
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode)); .setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
BaseBottomSheetItem gpxLocalRoutingParameter = new BottomSheetItemWithDescription.Builder() return new BottomSheetItemWithDescription.Builder()
.setDescription(getString(R.string.choose_track_file_to_follow)) .setDescription(getString(R.string.choose_track_file_to_follow))
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark)) .setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
.setTitle(getString(R.string.shared_string_gpx_route)) .setTitle(getString(R.string.shared_string_gpx_route))
@ -211,12 +248,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
}) })
.create(); .create();
items.add(gpxLocalRoutingParameter); }
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
BaseBottomSheetItem otherSettingsRoutingParameter = new SimpleBottomSheetItem.Builder() private BaseBottomSheetItem createOtherSettingsRoutingItem(final LocalRoutingParameter optionsItem) {
.setIcon(getContentIcon(R.drawable.map_action_settings)) return new SimpleBottomSheetItem.Builder()
.setIcon(getContentIcon(optionsItem.getActiveIconId()))
.setTitle(getString(R.string.routing_settings_2)) .setTitle(getString(R.string.routing_settings_2))
.setLayoutId(R.layout.bottom_sheet_item_simple) .setLayoutId(R.layout.bottom_sheet_item_simple_56dp)
.setOnClickListener(new View.OnClickListener() { .setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -227,27 +265,18 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
}) })
.create(); .create();
items.add(otherSettingsRoutingParameter);
} else {
inflateRoutingParameter(optionsItem);
}
}
} }
@Override private void inflateRoutingParameter(final LocalRoutingParameter parameter) {
protected int getDismissButtonTextId() { if (parameter != null) {
return R.string.shared_string_close;
}
private void inflateRoutingParameter(final LocalRoutingParameter optionsItem) {
if (optionsItem != null) {
final LocalRoutingParameter parameter = (LocalRoutingParameter) optionsItem;
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder(); BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder();
builder.setIcon(getContentIcon(R.drawable.ic_action_fuel));
if (parameter.routingParameter != null) { if (parameter.routingParameter != null) {
builder.setTitle(parameter.getText(mapActivity)); 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) { if (parameter instanceof LocalRoutingParameterGroup) {
final LocalRoutingParameterGroup group = (LocalRoutingParameterGroup) parameter; final LocalRoutingParameterGroup group = (LocalRoutingParameterGroup) parameter;
@ -274,7 +303,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
}); });
} else { } 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 != null) {
if (parameter.routingParameter.getId().equals("short_way")) { if (parameter.routingParameter.getId().equals("short_way")) {
// if short route settings - it should be inverse of fast_route_mode // if short route settings - it should be inverse of fast_route_mode
@ -287,10 +316,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter); routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter);
boolean selected = !parameter.isSelected(settings);
boolean selected = parameter.isSelected(settings); routingOptionsHelper.applyRoutingParameter(parameter, selected);
routingOptionsHelper.applyRoutingParameter(parameter, !selected); item[0].setChecked(selected);
item[0].setChecked(!selected); int iconId = selected ? parameter.getActiveIconId() : parameter.getDisabledIconId();
if (iconId != -1) {
item[0].setIcon(getContentIcon(iconId));
}
updateMenu(); updateMenu();
} }
}); });
@ -300,19 +332,6 @@ 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(); final MapRouteInfoMenu mapRouteInfoMenu = getMapActivity().getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
if (mapRouteInfoMenu != null) { if (mapRouteInfoMenu != null) {
@ -359,6 +378,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
DRIVING_STYLE, DRIVING_STYLE,
GeneralRouter.USE_HEIGHT_OBSTACLES, GeneralRouter.USE_HEIGHT_OBSTACLES,
DividerItem.KEY, DividerItem.KEY,
GeneralRouter.ALLOW_MOTORWAYS,
AvoidRoadsTypesRoutingParameter.KEY, AvoidRoadsTypesRoutingParameter.KEY,
ShowAlongTheRouteItem.KEY, ShowAlongTheRouteItem.KEY,
DividerItem.KEY, DividerItem.KEY,

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.TypedValue; import android.util.TypedValue;
@ -269,6 +270,7 @@ public class RoutingOptionsHelper {
for (String itemId : routingParameters) { for (String itemId : routingParameters) {
LocalRoutingParameter item = getItem(am, itemId); LocalRoutingParameter item = getItem(am, itemId);
if (item != null) { if (item != null) {
updateRoutingParameterIcons(item);
list.add(item); list.add(item);
} }
} }
@ -455,6 +457,7 @@ public class RoutingOptionsHelper {
} else { } else {
LocalRoutingParameter rp = new LocalRoutingParameter(am); LocalRoutingParameter rp = new LocalRoutingParameter(am);
rp.routingParameter = r; rp.routingParameter = r;
updateRoutingParameterIcons(rp);
list.add(rp); list.add(rp);
} }
} }
@ -463,6 +466,50 @@ public class RoutingOptionsHelper {
return list; 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) { public static LocalRoutingParameterGroup getLocalRoutingParameterGroup(List<LocalRoutingParameter> list, String groupName) {
for (LocalRoutingParameter p : list) { for (LocalRoutingParameter p : list) {
if (p instanceof LocalRoutingParameterGroup && groupName.equals(((LocalRoutingParameterGroup) p).getGroupName())) { if (p instanceof LocalRoutingParameterGroup && groupName.equals(((LocalRoutingParameterGroup) p).getGroupName())) {
@ -506,6 +553,13 @@ public class RoutingOptionsHelper {
private ApplicationMode am; private ApplicationMode am;
@DrawableRes
public
int activeIconId = -1;
@DrawableRes
int disabledIconId = -1;
public boolean canAddToRouteMenu() { public boolean canAddToRouteMenu() {
return true; return true;
} }
@ -517,6 +571,14 @@ public class RoutingOptionsHelper {
return KEY; return KEY;
} }
public int getActiveIconId() {
return activeIconId;
}
public int getDisabledIconId() {
return disabledIconId;
}
public LocalRoutingParameter(ApplicationMode am) { public LocalRoutingParameter(ApplicationMode am) {
this.am = am; this.am = am;
} }
@ -613,12 +675,22 @@ public class RoutingOptionsHelper {
public static final String KEY = "MuteSoundRoutingParameter"; public static final String KEY = "MuteSoundRoutingParameter";
public MuteSoundRoutingParameter() {
super(null);
}
public String getId() { public String getId() {
return KEY; return KEY;
} }
public MuteSoundRoutingParameter() { @Override
super(null); 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 static final String KEY = "ShowAlongTheRouteItem";
public ShowAlongTheRouteItem() {
super(null);
}
public String getId() { public String getId() {
return KEY; return KEY;
} }
public ShowAlongTheRouteItem() { @Override
super(null); 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 static final String KEY = "AvoidRoadsRoutingParameter";
public String getId() {
return KEY;
}
public AvoidRoadsRoutingParameter() { public AvoidRoadsRoutingParameter() {
super(null); 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 class AvoidRoadsTypesRoutingParameter extends LocalRoutingParameter {
public static final String KEY = "AvoidRoadsTypesRoutingParameter"; public static final String KEY = "AvoidRoadsTypesRoutingParameter";
public String getId() {
return KEY;
}
public AvoidRoadsTypesRoutingParameter() { public AvoidRoadsTypesRoutingParameter() {
super(null); 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 { public static class GpxLocalRoutingParameter extends LocalRoutingParameter {
@ -718,6 +818,10 @@ public class RoutingOptionsHelper {
public static final String KEY = "OtherSettingsRoutingParameter"; public static final String KEY = "OtherSettingsRoutingParameter";
public OtherSettingsRoutingParameter() {
super(null);
}
public String getId() { public String getId() {
return KEY; return KEY;
} }
@ -726,8 +830,14 @@ public class RoutingOptionsHelper {
return false; return false;
} }
public OtherSettingsRoutingParameter() { @Override
super(null); 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; package net.osmand.plus.routepreparationmenu;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -22,13 +21,10 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.data.FavouritePoint; import net.osmand.ValueHolder;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; 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.WaypointDialogHelper;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.util.Algorithms; import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.util.MapUtils;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment { public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment implements IRouteInformationListener {
public static final String TAG = "ShowAlongTheRouteBottomSheet"; public static final String TAG = "ShowAlongTheRouteBottomSheet";
@ -61,6 +56,14 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
private ExpandableListView expListView; private ExpandableListView expListView;
private ExpandableListAdapter adapter; private ExpandableListAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
mapActivity = (MapActivity) getActivity();
waypointHelper = app.getWaypointHelper();
}
@Override @Override
public void createMenuItems(Bundle savedInstanceState) { public void createMenuItems(Bundle savedInstanceState) {
Context ctx = getContext(); Context ctx = getContext();
@ -68,9 +71,6 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
if (ctx == null || args == null) { if (ctx == null || args == null) {
return; return;
} }
app = getMyApplication();
mapActivity = (MapActivity) getActivity();
waypointHelper = app.getWaypointHelper();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; 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); final View titleView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.bottom_sheet_item_toolbar_title, null);
@ -92,7 +92,6 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
.create(); .create();
items.add(titleItem); items.add(titleItem);
if (waypointHelper.isRouteCalculated()) {
final ContentItem contentItem = getAdapterContentItems(); final ContentItem contentItem = getAdapterContentItems();
items.add(new SimpleDividerItem(app)); items.add(new SimpleDividerItem(app));
@ -110,39 +109,6 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
items.add(new SimpleBottomSheetItem.Builder().setCustomView(container).create()); 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;
}
@Override @Override
protected boolean useScrollableItemsContainer() { protected boolean useScrollableItemsContainer() {
@ -155,34 +121,63 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} }
private ContentItem getAdapterContentItems() { private ContentItem getAdapterContentItems() {
final ContentItem contentItem = new ContentItem("items", null); final ContentItem contentItem = new ContentItem();
if (waypointHelper.isRouteCalculated()) {
for (int i = 2; i < WaypointHelper.MAX; i++) { for (int i = 2; i < WaypointHelper.MAX; i++) {
List<WaypointHelper.LocationPointWrapper> tp = waypointHelper.getWaypoints(i); List<WaypointHelper.LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
ContentItem headerItem = new ContentItem(getCategotyTitle(i, app), contentItem); ContentItem headerItem = new PointItem(i);
contentItem.subItems.add(headerItem); contentItem.subItems.add(headerItem);
headerItem.type = i; headerItem.type = i;
if (waypointHelper.isRouteCalculated()) {
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES) && waypointHelper.isTypeEnabled(i)) { 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); headerItem.subItems.add(radiusItem);
} }
if (tp != null && tp.size() > 0) { if (tp != null && tp.size() > 0) {
for (int j = 0; j < tp.size(); j++) { for (int j = 0; j < tp.size(); j++) {
WaypointHelper.LocationPointWrapper pointWrapper = tp.get(j); WaypointHelper.LocationPointWrapper pointWrapper = tp.get(j);
String title = pointWrapper.getPoint().getPointDescription(app).getName(); PointItem subheaderItem = new PointItem(pointWrapper.type);
ContentItem subheaderItem = new ContentItem(title, headerItem);
headerItem.subItems.add(subheaderItem); headerItem.subItems.add(subheaderItem);
subheaderItem.point = pointWrapper; subheaderItem.point = pointWrapper;
} }
} }
} else {
ContentItem infoItem = new InfoItem(i);
headerItem.subItems.add(infoItem);
} }
} }
return contentItem; 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() { private void updateAdapter() {
if (adapter != null) { if (adapter != null) {
adapter.contentItem = getAdapterContentItems(); adapter.contentItem = getAdapterContentItems();
@ -203,7 +198,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
@Override @Override
public Object getChild(int groupPosition, int childPosititon) { 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 @Override
@ -214,20 +209,22 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
@Override @Override
public View getChildView(int groupPosition, final int childPosition, public View getChildView(int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) { 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); final ContentItem child = group.getSubItems().get(childPosition);
if (child.name.equals("radius")) { if (child instanceof RadiusItem) {
convertView = createItemForRadiusProximity(group.type, nightMode); convertView = createItemForRadiusProximity(group.type, nightMode);
} else { } else if (child instanceof InfoItem) {
convertView = LayoutInflater.from(context) convertView = createInfoItem();
.inflate(R.layout.bottom_sheet_item_show_along_the_route, parent, false); } else if (child instanceof PointItem) {
updatePointInfoView(app, mapActivity, convertView, group, child); 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 @Override
public void onClick(View v) { public void onClick(View v) {
WaypointDialogHelper.showOnMap(app, mapActivity, child.point.getPoint(), false); WaypointDialogHelper.showOnMap(app, mapActivity, item.point.getPoint(), false);
Fragment fragment = getTargetFragment(); Fragment fragment = getTargetFragment();
if (fragment != null) { if (fragment != null) {
fragment.onActivityResult(getTargetRequestCode(), SHOW_CONTENT_ITEM_REQUEST_CODE, null); fragment.onActivityResult(getTargetRequestCode(), SHOW_CONTENT_ITEM_REQUEST_CODE, null);
@ -235,107 +232,30 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
dismiss(); dismiss();
} }
}); });
}
return convertView; final ImageButton remove = (ImageButton) convertView.findViewById(R.id.info_close);
}
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.setImageDrawable(app.getUIUtilities().getThemedIcon(R.drawable.ic_action_remove_dark));
remove.setOnClickListener(new View.OnClickListener() { remove.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
app.getWaypointHelper().removeVisibleLocationPoint(ps); app.getWaypointHelper().removeVisibleLocationPoint(item.point);
group.subItems.remove(item); group.subItems.remove(item);
adapter.notifyDataSetChanged(); 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) { View bottomDivider = convertView.findViewById(R.id.bottom_divider);
textDist.setText(OsmAndFormatter.getFormattedDistance(dist, app)); if (bottomDivider != null) {
} else { bottomDivider.setVisibility(isLastChild ? View.VISIBLE : View.GONE);
textDist.setText(""); AndroidUtils.setBackground(app, bottomDivider, nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
} }
TextView textDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation); if (child instanceof RadiusItem && group.type == WaypointHelper.POI) {
if (textDeviation != null) { convertView.findViewById(R.id.divider).setVisibility(isLastChild ? View.GONE : View.VISIBLE);
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); return convertView;
} 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 @Override
@ -370,7 +290,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
.inflate(R.layout.along_the_route_category_item, parent, false); .inflate(R.layout.along_the_route_category_item, parent, false);
} }
TextView lblListHeader = (TextView) convertView.findViewById(R.id.title); 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)); 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); adjustIndicator(app, groupPosition, isExpanded, convertView, !nightMode);
@ -387,6 +307,9 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} else { } else {
enableType(type, isChecked); 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); 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); bottomDivider.setVisibility(isExpanded ? View.GONE : View.VISIBLE);
AndroidUtils.setBackground(app, bottomDivider, nightMode, R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
return convertView; 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) { private View createItemForRadiusProximity(final int type, boolean nightMode) {
View v; View v;
if (type == WaypointHelper.POI) { if (type == WaypointHelper.POI) {
@ -450,7 +420,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
}); });
AndroidUtils.setBackground(app, v.findViewById(R.id.top_divider), nightMode, AndroidUtils.setBackground(app, v.findViewById(R.id.top_divider), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark); 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); R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
} else { } else {
v = mapActivity.getLayoutInflater().inflate(R.layout.along_the_route_radius_simple, null); 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); AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode);
final TextView radius = (TextView) v.findViewById(R.id.description); final TextView radius = (TextView) v.findViewById(R.id.description);
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app)); radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app));
radius.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
selectDifferentRadius(type); selectDifferentRadius(type);
@ -468,16 +439,6 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} }
return v; 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) { 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 int type;
private String name;
private ArrayList<ContentItem> subItems = new ArrayList<>(); private ArrayList<ContentItem> subItems = new ArrayList<>();
private ContentItem parent;
private WaypointHelper.LocationPointWrapper point;
private ContentItem(String name, ContentItem parent) { private ContentItem(int type) {
this.parent = parent; this.type = type;
this.name = name;
} }
public String getName() { private ContentItem() {
return name;
} }
public ContentItem getParent() { private ArrayList<ContentItem> getSubItems() {
return parent;
}
public ArrayList<ContentItem> getSubItems() {
return subItems; 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);
}
}
} }