Add "Make as Start Point" item to add waypoints menu
This commit is contained in:
parent
6ec8a82bba
commit
2d80f3e4d9
3 changed files with 68 additions and 10 deletions
|
@ -43,13 +43,12 @@
|
||||||
android:paddingStart="@dimen/content_padding">
|
android:paddingStart="@dimen/content_padding">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/current_dest_icon"
|
|
||||||
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_marginEnd="@dimen/bottom_sheet_icon_margin"
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
tools:src="@drawable/ic_action_point_destination"/>
|
android:src="@drawable/list_destination"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -79,6 +78,53 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/replace_start_row"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingStart="@dimen/content_padding">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||||
|
android:src="@drawable/list_startpoint"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/make_as_start_point"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/current_start_text_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textColor="@color/searchbar_text_hint_light"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
tools:text="Current: My location"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/current_dest_divider"
|
android:id="@+id/current_dest_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="make_as_start_point">Make as Start Point</string>
|
||||||
<string name="shared_string_current">Current</string>
|
<string name="shared_string_current">Current</string>
|
||||||
<string name="last_intermediate_dest_description">Adds the last stop along the route</string>
|
<string name="last_intermediate_dest_description">Adds the last stop along the route</string>
|
||||||
<string name="first_intermediate_dest_description">Adds the first stop on the route</string>
|
<string name="first_intermediate_dest_description">Adds the first stop on the route</string>
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
|
|
||||||
|
@ -43,10 +44,10 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
R.layout.fragment_add_waypoint_bottom_sheet_dialog, container);
|
R.layout.fragment_add_waypoint_bottom_sheet_dialog, container);
|
||||||
|
|
||||||
((TextView) mainView.findViewById(R.id.current_dest_text_view))
|
((TextView) mainView.findViewById(R.id.current_dest_text_view))
|
||||||
.setText(getCurrentDestinationName(targetPointsHelper.getPointToNavigate()));
|
.setText(getCurrentPointName(targetPointsHelper.getPointToNavigate(), false));
|
||||||
|
((TextView) mainView.findViewById(R.id.current_start_text_view))
|
||||||
|
.setText(getCurrentPointName(targetPointsHelper.getPointToStart(), true));
|
||||||
|
|
||||||
((ImageView) mainView.findViewById(R.id.current_dest_icon))
|
|
||||||
.setImageDrawable(getBackgroundIcon(R.drawable.ic_action_point_destination));
|
|
||||||
((ImageView) mainView.findViewById(R.id.subsequent_dest_icon)).setImageDrawable(getSubsequentDestIcon());
|
((ImageView) mainView.findViewById(R.id.subsequent_dest_icon)).setImageDrawable(getSubsequentDestIcon());
|
||||||
((ImageView) mainView.findViewById(R.id.first_interm_dest_icon)).setImageDrawable(getFirstIntermDestIcon());
|
((ImageView) mainView.findViewById(R.id.first_interm_dest_icon)).setImageDrawable(getFirstIntermDestIcon());
|
||||||
((ImageView) mainView.findViewById(R.id.last_interm_dest_icon)).setImageDrawable(getLastIntermDistIcon());
|
((ImageView) mainView.findViewById(R.id.last_interm_dest_icon)).setImageDrawable(getLastIntermDistIcon());
|
||||||
|
@ -57,6 +58,13 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
if (id == R.id.replace_dest_row) {
|
if (id == R.id.replace_dest_row) {
|
||||||
targetPointsHelper.navigateToPoint(latLon, true, -1, name);
|
targetPointsHelper.navigateToPoint(latLon, true, -1, name);
|
||||||
|
} else if (id == R.id.replace_start_row) {
|
||||||
|
TargetPoint start = targetPointsHelper.getPointToStart();
|
||||||
|
if (start != null) {
|
||||||
|
targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()),
|
||||||
|
false, 0, start.getOriginalPointDescription());
|
||||||
|
}
|
||||||
|
targetPointsHelper.setStartPoint(latLon, true, name);
|
||||||
} else if (id == R.id.subsequent_dest_row) {
|
} else if (id == R.id.subsequent_dest_row) {
|
||||||
targetPointsHelper.navigateToPoint(latLon, true,
|
targetPointsHelper.navigateToPoint(latLon, true,
|
||||||
targetPointsHelper.getIntermediatePoints().size() + 1, name);
|
targetPointsHelper.getIntermediatePoints().size() + 1, name);
|
||||||
|
@ -70,6 +78,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
};
|
};
|
||||||
|
|
||||||
mainView.findViewById(R.id.replace_dest_row).setOnClickListener(onClickListener);
|
mainView.findViewById(R.id.replace_dest_row).setOnClickListener(onClickListener);
|
||||||
|
mainView.findViewById(R.id.replace_start_row).setOnClickListener(onClickListener);
|
||||||
mainView.findViewById(R.id.subsequent_dest_row).setOnClickListener(onClickListener);
|
mainView.findViewById(R.id.subsequent_dest_row).setOnClickListener(onClickListener);
|
||||||
mainView.findViewById(R.id.first_intermediate_dest_row).setOnClickListener(onClickListener);
|
mainView.findViewById(R.id.first_intermediate_dest_row).setOnClickListener(onClickListener);
|
||||||
mainView.findViewById(R.id.last_intermediate_dest_row).setOnClickListener(onClickListener);
|
mainView.findViewById(R.id.last_intermediate_dest_row).setOnClickListener(onClickListener);
|
||||||
|
@ -135,18 +144,20 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF
|
||||||
R.drawable.ic_action_route_last_intermediate_point);
|
R.drawable.ic_action_route_last_intermediate_point);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCurrentDestinationName(@Nullable TargetPointsHelper.TargetPoint finish) {
|
private String getCurrentPointName(@Nullable TargetPoint point, boolean start) {
|
||||||
Context ctx = getContext();
|
Context ctx = getContext();
|
||||||
StringBuilder builder = new StringBuilder(ctx.getString(R.string.shared_string_current));
|
StringBuilder builder = new StringBuilder(ctx.getString(R.string.shared_string_current));
|
||||||
builder.append(": ");
|
builder.append(": ");
|
||||||
if (finish != null) {
|
if (point != null) {
|
||||||
if (finish.getOnlyName().length() > 0) {
|
if (point.getOnlyName().length() > 0) {
|
||||||
builder.append(finish.getOnlyName());
|
builder.append(point.getOnlyName());
|
||||||
} else {
|
} else {
|
||||||
builder.append(ctx.getString(R.string.route_descr_map_location));
|
builder.append(ctx.getString(R.string.route_descr_map_location));
|
||||||
builder.append(" ");
|
builder.append(" ");
|
||||||
builder.append(ctx.getString(R.string.route_descr_lat_lon, finish.getLatitude(), finish.getLongitude()));
|
builder.append(ctx.getString(R.string.route_descr_lat_lon, point.getLatitude(), point.getLongitude()));
|
||||||
}
|
}
|
||||||
|
} else if (start) {
|
||||||
|
builder.append(ctx.getString(R.string.shared_string_my_location));
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue