Rewrite UI in SelectedPointBottomSheetDialogFragment
This commit is contained in:
parent
6dd0e35702
commit
3f2c1f7a6f
4 changed files with 198 additions and 366 deletions
|
@ -1,261 +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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/selected_point_options_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
|
||||
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:id="@+id/selected_point_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_measure_point"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toEndOf="@id/selected_point_icon"
|
||||
android:layout_toRightOf="@id/selected_point_icon"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/selected_point_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Point 2"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/selected_point_distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="386 m"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:maxLines="1"
|
||||
android:id="@+id/selected_point_ele"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
||||
tools:text="A: 345 m"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:maxLines="1"
|
||||
android:id="@+id/selected_point_speed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="S: 45 km/h"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/measurement_tool_divider_margin"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/move_point_row"
|
||||
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:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/move_point_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_move_point"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/move_point_icon"
|
||||
android:layout_toRightOf="@id/move_point_icon"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_move"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/delete_point_row"
|
||||
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:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_point_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/delete_point_icon"
|
||||
android:layout_toRightOf="@id/delete_point_icon"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_delete"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="@dimen/bottom_sheet_divider_margin_bottom"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_divider_margin_top"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/add_point_after_row"
|
||||
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:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_point_after_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_addpoint_above"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/add_point_after_icon"
|
||||
android:layout_toRightOf="@id/add_point_after_icon"
|
||||
android:maxLines="1"
|
||||
android:text="@string/add_point_after"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/add_point_before_row"
|
||||
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:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_point_before_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_addpoint_below"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/add_point_before_icon"
|
||||
android:layout_toRightOf="@id/add_point_before_icon"
|
||||
android:maxLines="1"
|
||||
android:text="@string/add_point_before"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/cancel_row_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_close"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -78,6 +78,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onCloseRowClickAction();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
@ -175,6 +176,10 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
return R.string.shared_string_cancel;
|
||||
}
|
||||
|
||||
protected void onCloseRowClickAction() {
|
||||
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
protected int getPortraitBgResId() {
|
||||
return nightMode ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_menu_light;
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package net.osmand.plus.base.bottomsheetmenu.simpleitems;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.annotation.ColorRes;
|
||||
|
||||
public class TitleDividerItem extends DividerItem {
|
||||
|
||||
public TitleDividerItem(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public TitleDividerItem(Context context, @ColorRes int colorId) {
|
||||
super(context, colorId);
|
||||
}
|
||||
|
||||
public TitleDividerItem(Context context, @ColorRes int colorId, int position) {
|
||||
super(context, colorId, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getTopMargin(Context context) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,20 +1,25 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
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.TitleDividerItem;
|
||||
import net.osmand.plus.measurementtool.NewGpxData.ActionType;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -32,114 +37,83 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
|
||||
@Override
|
||||
public View createMenuItems(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
final MapActivity mapActivity = (MapActivity) getActivity();
|
||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
BaseBottomSheetItem titleItem = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(getDescription())
|
||||
.setIcon(getActiveIcon(R.drawable.ic_action_measure_point))
|
||||
.setTitle(getTitle())
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||
.create();
|
||||
items.add(titleItem);
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_selected_menu_bottom_sheet_dialog, null);
|
||||
items.add(new TitleDividerItem(getContext()));
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.selected_point_icon)).setImageDrawable(getActiveIcon(R.drawable.ic_action_measure_point));
|
||||
((ImageView) mainView.findViewById(R.id.move_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_move_point));
|
||||
((ImageView) mainView.findViewById(R.id.delete_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_remove_dark));
|
||||
((ImageView) mainView.findViewById(R.id.add_point_after_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_addpoint_above));
|
||||
((ImageView) mainView.findViewById(R.id.add_point_before_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_addpoint_below));
|
||||
|
||||
mainView.findViewById(R.id.move_point_row).setOnClickListener(new View.OnClickListener() {
|
||||
BaseBottomSheetItem moveItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_move_point))
|
||||
.setTitle(getString(R.string.shared_string_move))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.moveOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.delete_point_row).setOnClickListener(new View.OnClickListener() {
|
||||
})
|
||||
.create();
|
||||
items.add(moveItem);
|
||||
|
||||
BaseBottomSheetItem deleteItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_remove_dark))
|
||||
.setTitle(getString(R.string.shared_string_delete))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.deleteOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.add_point_after_row).setOnClickListener(new View.OnClickListener() {
|
||||
})
|
||||
.create();
|
||||
items.add(deleteItem);
|
||||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
BaseBottomSheetItem addAfterItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_addpoint_above))
|
||||
.setTitle(getString(R.string.add_point_after))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.addPointAfterOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.add_point_before_row).setOnClickListener(new View.OnClickListener() {
|
||||
})
|
||||
.create();
|
||||
items.add(addAfterItem);
|
||||
|
||||
BaseBottomSheetItem addBeforeItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_addpoint_below))
|
||||
.setTitle(getString(R.string.add_point_before))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.addPointBeforeOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.onClearSelection();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
})
|
||||
.create();
|
||||
items.add(addBeforeItem);
|
||||
|
||||
List<WptPt> points = measurementLayer.getEditingCtx().getPoints();
|
||||
int pos = measurementLayer.getEditingCtx().getSelectedPointPosition();
|
||||
WptPt pt = points.get(pos);
|
||||
String pointTitle = pt.name;
|
||||
if (!TextUtils.isEmpty(pointTitle)) {
|
||||
((TextView) mainView.findViewById(R.id.selected_point_title)).setText(pointTitle);
|
||||
} else {
|
||||
NewGpxData newGpxData = measurementLayer.getEditingCtx().getNewGpxData();
|
||||
if (newGpxData != null) {
|
||||
ActionType actionType = measurementLayer.getEditingCtx().getNewGpxData().getActionType();
|
||||
if (actionType == ActionType.ADD_ROUTE_POINTS) {
|
||||
((TextView) mainView.findViewById(R.id.selected_point_title)).setText(mapActivity.getString(R.string.route_point) + " - " + (pos + 1));
|
||||
} else {
|
||||
((TextView) mainView.findViewById(R.id.selected_point_title)).setText(mapActivity.getString(R.string.plugin_distance_point) + " - " + (pos + 1));
|
||||
}
|
||||
} else {
|
||||
((TextView) mainView.findViewById(R.id.selected_point_title)).setText(mapActivity.getString(R.string.plugin_distance_point) + " - " + (pos + 1));
|
||||
}
|
||||
}
|
||||
String pointDesc = pt.desc;
|
||||
if (!TextUtils.isEmpty(pointDesc)) {
|
||||
((TextView) mainView.findViewById(R.id.selected_point_distance)).setText(pointDesc);
|
||||
} else {
|
||||
if (pos < 1) {
|
||||
((TextView) mainView.findViewById(R.id.selected_point_distance)).setText(mapActivity.getString(R.string.shared_string_control_start));
|
||||
} else {
|
||||
float dist = 0;
|
||||
for (int i = 1; i <= pos; i++) {
|
||||
dist += MapUtils.getDistance(points.get(i - 1).lat, points.get(i - 1).lon, points.get(i).lat, points.get(i).lon);
|
||||
}
|
||||
((TextView) mainView.findViewById(R.id.selected_point_distance)).setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
|
||||
}
|
||||
}
|
||||
NewGpxData newGpxData = measurementLayer.getEditingCtx().getNewGpxData();
|
||||
if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT) {
|
||||
double elevation = pt.ele;
|
||||
if (!Double.isNaN(elevation)) {
|
||||
String eleStr = (mapActivity.getString(R.string.altitude)).substring(0, 1);
|
||||
((TextView) mainView.findViewById(R.id.selected_point_ele)).setText(eleStr + ": " + OsmAndFormatter.getFormattedAlt(elevation, mapActivity.getMyApplication()));
|
||||
}
|
||||
float speed = (float) pt.speed;
|
||||
if (speed != 0) {
|
||||
String speedStr = (mapActivity.getString(R.string.map_widget_speed)).substring(0, 1);
|
||||
((TextView) mainView.findViewById(R.id.selected_point_speed)).setText(speedStr + ": " + OsmAndFormatter.getFormattedSpeed(speed, mapActivity.getMyApplication()));
|
||||
}
|
||||
}
|
||||
|
||||
setupHeightAndBackground(mainView, R.id.selected_point_options_scroll_view);
|
||||
|
||||
return mainView;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,6 +133,96 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCloseRowTextId() {
|
||||
return R.string.shared_string_close;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCloseRowClickAction() {
|
||||
if (listener != null) {
|
||||
listener.onClearSelection();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MapActivity getMapActivity() {
|
||||
Activity activity = getActivity();
|
||||
if (activity instanceof MapActivity) {
|
||||
return (MapActivity) activity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getTitle() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
MeasurementEditingContext editingCtx = mapActivity.getMapLayers().getMeasurementToolLayer().getEditingCtx();
|
||||
int pos = editingCtx.getSelectedPointPosition();
|
||||
|
||||
String pointName = editingCtx.getPoints().get(pos).name;
|
||||
if (!TextUtils.isEmpty(pointName)) {
|
||||
return pointName;
|
||||
}
|
||||
|
||||
NewGpxData newGpxData = editingCtx.getNewGpxData();
|
||||
if (newGpxData != null && newGpxData.getActionType() == ActionType.ADD_ROUTE_POINTS) {
|
||||
return getString(R.string.route_point) + " - " + (pos + 1);
|
||||
}
|
||||
|
||||
return getString(R.string.plugin_distance_point) + " - " + (pos + 1);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getDescription() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder description = new StringBuilder();
|
||||
|
||||
MeasurementEditingContext editingCtx = mapActivity.getMapLayers().getMeasurementToolLayer().getEditingCtx();
|
||||
int pos = editingCtx.getSelectedPointPosition();
|
||||
List<WptPt> points = editingCtx.getPoints();
|
||||
WptPt pt = points.get(pos);
|
||||
|
||||
String pointDesc = pt.desc;
|
||||
if (!TextUtils.isEmpty(pointDesc)) {
|
||||
description.append(pointDesc);
|
||||
} else if (pos < 1) {
|
||||
description.append(getString(R.string.shared_string_control_start));
|
||||
} else {
|
||||
float dist = 0;
|
||||
for (int i = 1; i <= pos; i++) {
|
||||
WptPt first = points.get(i - 1);
|
||||
WptPt second = points.get(i);
|
||||
dist += MapUtils.getDistance(first.lat, first.lon, second.lat, second.lon);
|
||||
}
|
||||
description.append(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
|
||||
}
|
||||
|
||||
NewGpxData newGpxData = editingCtx.getNewGpxData();
|
||||
if (newGpxData != null && newGpxData.getActionType() == ActionType.EDIT_SEGMENT) {
|
||||
double elevation = pt.ele;
|
||||
if (!Double.isNaN(elevation)) {
|
||||
description.append(" ").append((getString(R.string.altitude)).substring(0, 1)).append(": ");
|
||||
description.append(OsmAndFormatter.getFormattedAlt(elevation, mapActivity.getMyApplication()));
|
||||
}
|
||||
float speed = (float) pt.speed;
|
||||
if (speed != 0) {
|
||||
description.append(" ").append((getString(R.string.map_widget_speed)).substring(0, 1)).append(": ");
|
||||
description.append(OsmAndFormatter.getFormattedSpeed(speed, mapActivity.getMyApplication()));
|
||||
}
|
||||
}
|
||||
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
interface SelectedPointFragmentListener {
|
||||
|
||||
void moveOnClick();
|
||||
|
|
Loading…
Reference in a new issue