Merge pull request #10293 from osmandapp/PlanRouteFixUiBugs
Fix Plan Route Ui bugs, add HorizontalRadioGroup
This commit is contained in:
commit
5cfefc7f34
13 changed files with 396 additions and 192 deletions
20
OsmAnd/res/layout/custom_radio_btn_text_item.xml
Normal file
20
OsmAnd/res/layout/custom_radio_btn_text_item.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout 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:orientation="vertical"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="@string/shared_string_left"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
|
@ -130,25 +130,32 @@
|
||||||
tools:text="@string/add_point_after"/>
|
tools:text="@string/add_point_after"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:id="@+id/additional_info_container"
|
android:id="@+id/info_type_buttons_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:orientation="vertical"
|
|
||||||
android:visibility="gone" >
|
|
||||||
|
|
||||||
<include layout="@layout/custom_radio_buttons" />
|
<include
|
||||||
|
layout="@layout/custom_radio_buttons"
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/content_padding_small" />
|
android:layout_height="@dimen/measurement_tool_button_height"
|
||||||
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:layout_marginBottom="@dimen/measurement_tool_content_padding_medium" />
|
||||||
|
|
||||||
<FrameLayout
|
</FrameLayout>
|
||||||
android:id="@+id/cards_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
<FrameLayout
|
||||||
|
android:id="@+id/cards_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/measurement_tool_info_cards_container_height"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/bottom_panel_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/measure_mode_controls"
|
android:id="@+id/measure_mode_controls"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/markers_list_container"
|
android:id="@+id/markers_list_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/measurement_tool_points_list_container_height"
|
android:layout_height="@dimen/measurement_tool_info_cards_container_height"
|
||||||
tools:background="@color/activity_background_color_dark">
|
tools:background="@color/activity_background_color_dark">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
|
|
@ -136,11 +136,11 @@
|
||||||
<View
|
<View
|
||||||
android:layout_width="@dimen/standard_icon_size"
|
android:layout_width="@dimen/standard_icon_size"
|
||||||
android:layout_height="@dimen/standard_icon_size"
|
android:layout_height="@dimen/standard_icon_size"
|
||||||
android:layout_marginLeft="@dimen/content_padding"
|
|
||||||
android:layout_marginStart="@dimen/content_padding"
|
android:layout_marginStart="@dimen/content_padding"
|
||||||
|
android:layout_marginLeft="@dimen/content_padding"
|
||||||
android:layout_marginEnd="@dimen/content_padding"
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
android:layout_marginRight="@dimen/content_padding"
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -173,12 +173,4 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.appcompat.widget.AppCompatImageView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="5dp"
|
|
||||||
android:layout_gravity="bottom"
|
|
||||||
android:alpha="0.5"
|
|
||||||
android:scaleType="fitXY"
|
|
||||||
osmand:srcCompat="@drawable/bg_shadow_onmap" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -3,7 +3,7 @@
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/points_list_container"
|
android:id="@+id/points_list_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/measurement_tool_points_list_container_height"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/activity_background_color">
|
android:background="?attr/activity_background_color">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
|
@ -78,7 +78,7 @@
|
||||||
<dimen name="measurement_tool_divider_margin">12dp</dimen>
|
<dimen name="measurement_tool_divider_margin">12dp</dimen>
|
||||||
<dimen name="measurement_tool_content_padding_medium">18dp</dimen>
|
<dimen name="measurement_tool_content_padding_medium">18dp</dimen>
|
||||||
<dimen name="measurement_tool_text_margin">12dp</dimen>
|
<dimen name="measurement_tool_text_margin">12dp</dimen>
|
||||||
<dimen name="measurement_tool_points_list_container_height">330dp</dimen>
|
<dimen name="measurement_tool_info_cards_container_height">330dp</dimen>
|
||||||
<dimen name="measurement_tool_up_down_row_height">48dp</dimen>
|
<dimen name="measurement_tool_up_down_row_height">48dp</dimen>
|
||||||
<dimen name="measurement_tool_text_button_padding_small">18dp</dimen>
|
<dimen name="measurement_tool_text_button_padding_small">18dp</dimen>
|
||||||
<dimen name="measurement_tool_text_button_padding">24dp</dimen>
|
<dimen name="measurement_tool_text_button_padding">24dp</dimen>
|
||||||
|
|
|
@ -257,7 +257,7 @@
|
||||||
<dimen name="measurement_tool_content_padding_medium">12dp</dimen>
|
<dimen name="measurement_tool_content_padding_medium">12dp</dimen>
|
||||||
<dimen name="text_margin_small">4dp</dimen>
|
<dimen name="text_margin_small">4dp</dimen>
|
||||||
<dimen name="measurement_tool_text_margin">8dp</dimen>
|
<dimen name="measurement_tool_text_margin">8dp</dimen>
|
||||||
<dimen name="measurement_tool_points_list_container_height">220dp</dimen>
|
<dimen name="measurement_tool_info_cards_container_height">220dp</dimen>
|
||||||
<dimen name="measurement_tool_up_down_row_height">60dp</dimen>
|
<dimen name="measurement_tool_up_down_row_height">60dp</dimen>
|
||||||
<dimen name="measurement_tool_controls_height">52dp</dimen>
|
<dimen name="measurement_tool_controls_height">52dp</dimen>
|
||||||
<dimen name="measurement_tool_text_button_padding_small">8dp</dimen>
|
<dimen name="measurement_tool_text_button_padding_small">8dp</dimen>
|
||||||
|
|
|
@ -63,6 +63,8 @@ public class HorizontalSelectionAdapter extends RecyclerView.Adapter<HorizontalS
|
||||||
public void onBindViewHolder(@NonNull ItemViewHolder holder, final int position) {
|
public void onBindViewHolder(@NonNull ItemViewHolder holder, final int position) {
|
||||||
final HorizontalSelectionItem item = items.get(holder.getAdapterPosition());
|
final HorizontalSelectionItem item = items.get(holder.getAdapterPosition());
|
||||||
TextView textView = holder.buttonText;
|
TextView textView = holder.buttonText;
|
||||||
|
int innerPadding = app.getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
|
textView.setPadding(innerPadding, 0, innerPadding, 0);
|
||||||
int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
int activeColorResId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||||
if (item.equals(selectedItem) && item.isEnabled()) {
|
if (item.equals(selectedItem) && item.isEnabled()) {
|
||||||
AndroidUtils.setBackground(holder.button, app.getUIUtilities().getPaintedIcon(
|
AndroidUtils.setBackground(holder.button, app.getUIUtilities().getPaintedIcon(
|
||||||
|
|
|
@ -518,7 +518,9 @@ public class TrackDetailsMenu {
|
||||||
} else {
|
} else {
|
||||||
gpxItem.chartHighlightPos = -1;
|
gpxItem.chartHighlightPos = -1;
|
||||||
}
|
}
|
||||||
trackChartPoints.setXAxisPoints(getXAxisPoints(chart));
|
if (shouldShowXAxisPoints()) {
|
||||||
|
trackChartPoints.setXAxisPoints(getXAxisPoints(chart));
|
||||||
|
}
|
||||||
if (gpxItem.route) {
|
if (gpxItem.route) {
|
||||||
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
|
mapActivity.getMapLayers().getMapInfoLayer().setTrackChartPoints(trackChartPoints);
|
||||||
} else {
|
} else {
|
||||||
|
@ -530,6 +532,10 @@ public class TrackDetailsMenu {
|
||||||
fitTrackOnMap(chart, location, forceFit);
|
fitTrackOnMap(chart, location, forceFit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldShowXAxisPoints () {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
segment = null;
|
segment = null;
|
||||||
trackChartPoints = null;
|
trackChartPoints = null;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import net.osmand.plus.helpers.GpxUiHelper.LineGraphType;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||||
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment.OnUpdateAdditionalInfoListener;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment.OnUpdateInfoListener;
|
||||||
import net.osmand.plus.measurementtool.graph.CommonGraphAdapter;
|
import net.osmand.plus.measurementtool.graph.CommonGraphAdapter;
|
||||||
import net.osmand.plus.measurementtool.graph.CustomGraphAdapter;
|
import net.osmand.plus.measurementtool.graph.CustomGraphAdapter;
|
||||||
import net.osmand.plus.measurementtool.graph.CustomGraphAdapter.LegendViewType;
|
import net.osmand.plus.measurementtool.graph.CustomGraphAdapter.LegendViewType;
|
||||||
|
@ -53,7 +53,7 @@ import static net.osmand.plus.helpers.GpxUiHelper.LineGraphType.SPEED;
|
||||||
import static net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
import static net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
||||||
import static net.osmand.router.RouteStatisticsHelper.RouteStatistics;
|
import static net.osmand.router.RouteStatisticsHelper.RouteStatistics;
|
||||||
|
|
||||||
public class GraphsCard extends BaseCard implements OnUpdateAdditionalInfoListener {
|
public class GraphsCard extends BaseCard implements OnUpdateInfoListener {
|
||||||
|
|
||||||
private static String GRAPH_DATA_GPX_FILE_NAME = "graph_data_tmp";
|
private static String GRAPH_DATA_GPX_FILE_NAME = "graph_data_tmp";
|
||||||
private static int INVALID_ID = -1;
|
private static int INVALID_ID = -1;
|
||||||
|
@ -114,11 +114,11 @@ public class GraphsCard extends BaseCard implements OnUpdateAdditionalInfoListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCardLayoutId() {
|
public int getCardLayoutId() {
|
||||||
return R.layout.fragment_measurement_tool_graph;
|
return R.layout.measurement_tool_graph_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateAdditionalInfo() {
|
public void onUpdateInfo() {
|
||||||
if (editingCtx != null) {
|
if (editingCtx != null) {
|
||||||
fullUpdate();
|
fullUpdate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,9 @@ import net.osmand.plus.views.layers.MapControlsLayer;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
||||||
|
import net.osmand.plus.widgets.MultiStateToggleButton;
|
||||||
|
import net.osmand.plus.widgets.MultiStateToggleButton.RadioItem;
|
||||||
|
import net.osmand.plus.widgets.MultiStateToggleButton.OnRadioItemClickListener;
|
||||||
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
|
import net.osmand.router.RoutePlannerFrontEnd.GpxRouteApproximation;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -88,8 +91,6 @@ import java.util.Locale;
|
||||||
|
|
||||||
import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
import static net.osmand.IndexConstants.GPX_FILE_EXT;
|
||||||
import static net.osmand.IndexConstants.GPX_INDEX_DIR;
|
import static net.osmand.IndexConstants.GPX_INDEX_DIR;
|
||||||
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.END;
|
|
||||||
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.START;
|
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode;
|
||||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.SnapToRoadProgressListener;
|
import static net.osmand.plus.measurementtool.MeasurementEditingContext.SnapToRoadProgressListener;
|
||||||
import static net.osmand.plus.measurementtool.SaveAsNewTrackBottomSheetDialogFragment.SaveAsNewTrackFragmentListener;
|
import static net.osmand.plus.measurementtool.SaveAsNewTrackBottomSheetDialogFragment.SaveAsNewTrackFragmentListener;
|
||||||
|
@ -113,25 +114,25 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private TextView pointsTv;
|
private TextView pointsTv;
|
||||||
private TextView distanceToCenterTv;
|
private TextView distanceToCenterTv;
|
||||||
private String pointsSt;
|
private String pointsSt;
|
||||||
private View additionalInfoContainer;
|
|
||||||
private ViewGroup cardsContainer;
|
private ViewGroup cardsContainer;
|
||||||
private BaseCard visibleCard;
|
private BaseCard visibleCard;
|
||||||
private PointsCard pointsCard;
|
private PointsCard pointsCard;
|
||||||
private GraphsCard graphsCard;
|
private GraphsCard graphsCard;
|
||||||
private LinearLayout customRadioButton;
|
private MultiStateToggleButton infoTypeBtn;
|
||||||
|
private RadioItem pointsBtn;
|
||||||
|
private RadioItem graphBtn;
|
||||||
private View mainView;
|
private View mainView;
|
||||||
private ImageView upDownBtn;
|
private ImageView upDownBtn;
|
||||||
private ImageView undoBtn;
|
private ImageView undoBtn;
|
||||||
private ImageView redoBtn;
|
private ImageView redoBtn;
|
||||||
private ImageView mainIcon;
|
private ImageView mainIcon;
|
||||||
private Snackbar snackbar;
|
|
||||||
private String fileName;
|
private String fileName;
|
||||||
|
|
||||||
private AdditionalInfoType currentAdditionalInfoType;
|
private InfoType currentInfoType;
|
||||||
|
|
||||||
private boolean wasCollapseButtonVisible;
|
private boolean wasCollapseButtonVisible;
|
||||||
private boolean progressBarVisible;
|
private boolean progressBarVisible;
|
||||||
private boolean additionalInfoExpanded;
|
private boolean infoExpanded;
|
||||||
|
|
||||||
private static final int PLAN_ROUTE_MODE = 0x1;
|
private static final int PLAN_ROUTE_MODE = 0x1;
|
||||||
private static final int DIRECTION_MODE = 0x2;
|
private static final int DIRECTION_MODE = 0x2;
|
||||||
|
@ -148,18 +149,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
private LatLon initialPoint;
|
private LatLon initialPoint;
|
||||||
|
|
||||||
enum SaveType {
|
|
||||||
ROUTE,
|
|
||||||
LINE
|
|
||||||
}
|
|
||||||
|
|
||||||
enum FinalSaveAction {
|
enum FinalSaveAction {
|
||||||
SHOW_SNACK_BAR_AND_CLOSE,
|
SHOW_SNACK_BAR_AND_CLOSE,
|
||||||
SHOW_TOAST,
|
SHOW_TOAST,
|
||||||
SHOW_IS_SAVED_FRAGMENT
|
SHOW_IS_SAVED_FRAGMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum AdditionalInfoType {
|
private enum InfoType {
|
||||||
POINTS,
|
POINTS,
|
||||||
GRAPH
|
GRAPH
|
||||||
}
|
}
|
||||||
|
@ -175,6 +171,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
protected int getFragmentHeight() {
|
protected int getFragmentHeight() {
|
||||||
return mainView.getHeight();
|
return mainView.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldShowXAxisPoints () {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEditingCtx(MeasurementEditingContext editingCtx) {
|
private void setEditingCtx(MeasurementEditingContext editingCtx) {
|
||||||
|
@ -230,13 +230,14 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
|
||||||
|
OsmandApplication app = mapActivity.getMyApplication();
|
||||||
|
|
||||||
editingCtx.setApplication(mapActivity.getMyApplication());
|
editingCtx.setApplication(mapActivity.getMyApplication());
|
||||||
editingCtx.setProgressListener(new SnapToRoadProgressListener() {
|
editingCtx.setProgressListener(new SnapToRoadProgressListener() {
|
||||||
@Override
|
@Override
|
||||||
public void showProgressBar() {
|
public void showProgressBar() {
|
||||||
MeasurementToolFragment.this.showProgressBar();
|
MeasurementToolFragment.this.showProgressBar();
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -248,7 +249,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
public void hideProgressBar() {
|
public void hideProgressBar() {
|
||||||
((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setVisibility(View.GONE);
|
((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setVisibility(View.GONE);
|
||||||
progressBarVisible = false;
|
progressBarVisible = false;
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -262,6 +263,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||||
|
int btnWidth = getResources().getDimensionPixelOffset(R.dimen.gpx_group_button_width);
|
||||||
|
|
||||||
pointsSt = getString(R.string.shared_string_gpx_points).toLowerCase();
|
pointsSt = getString(R.string.shared_string_gpx_points).toLowerCase();
|
||||||
|
|
||||||
|
@ -271,30 +273,19 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
mainView = view.findViewById(R.id.main_view);
|
mainView = view.findViewById(R.id.main_view);
|
||||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
detailsMenu = new GraphDetailsMenu();
|
detailsMenu = new GraphDetailsMenu();
|
||||||
additionalInfoContainer = mainView.findViewById(R.id.additional_info_container);
|
|
||||||
cardsContainer = mainView.findViewById(R.id.cards_container);
|
cardsContainer = mainView.findViewById(R.id.cards_container);
|
||||||
if (portrait) {
|
if (portrait) {
|
||||||
customRadioButton = mainView.findViewById(R.id.custom_radio_buttons);
|
String pointsBtnTitle = getString(R.string.shared_string_gpx_points);
|
||||||
|
pointsBtn = new RadioItem(pointsBtnTitle);
|
||||||
|
pointsBtn.setOnClickListener(getInfoTypeBtnListener(InfoType.POINTS));
|
||||||
|
|
||||||
View pointListBtn = customRadioButton.findViewById(R.id.left_button_container);
|
String graphBtnTitle = getString(R.string.shared_string_graph);
|
||||||
TextView tvPointListBtn = customRadioButton.findViewById(R.id.left_button);
|
graphBtn = new RadioItem(graphBtnTitle);
|
||||||
tvPointListBtn.setText(R.string.shared_string_gpx_points);
|
graphBtn.setOnClickListener(getInfoTypeBtnListener(InfoType.GRAPH));
|
||||||
pointListBtn.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
changeAdditionalInfoType(AdditionalInfoType.POINTS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
View graphBtn = customRadioButton.findViewById(R.id.right_button_container);
|
LinearLayout infoButtonsContainer = mainView.findViewById(R.id.custom_radio_buttons);
|
||||||
TextView tvGraphBtn = customRadioButton.findViewById(R.id.right_button);
|
infoTypeBtn = new MultiStateToggleButton(app, infoButtonsContainer, nightMode);
|
||||||
tvGraphBtn.setText(R.string.shared_string_graph);
|
infoTypeBtn.setItems(pointsBtn, graphBtn);
|
||||||
graphBtn.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
changeAdditionalInfoType(AdditionalInfoType.GRAPH);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
pointsCard = new PointsCard(mapActivity, this);
|
pointsCard = new PointsCard(mapActivity, this);
|
||||||
graphsCard = new GraphsCard(mapActivity, detailsMenu, this);
|
graphsCard = new GraphsCard(mapActivity, detailsMenu, this);
|
||||||
|
@ -328,18 +319,21 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
View upDownRow = mainView.findViewById(R.id.up_down_row);
|
View upDownRow = mainView.findViewById(R.id.up_down_row);
|
||||||
upDownRow.setOnClickListener(new OnClickListener() {
|
upDownRow.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View v) {
|
||||||
if (!additionalInfoExpanded && editingCtx.getPointsCount() > 0 && editingCtx.getSelectedPointPosition() == -1) {
|
if (portrait) {
|
||||||
expandAdditionalInfoView();
|
if (infoExpanded) {
|
||||||
} else {
|
collapseInfoView();
|
||||||
collapseAdditionalInfoView();
|
} else if (setInfoType(InfoType.POINTS)) {
|
||||||
|
infoTypeBtn.setSelectedItem(pointsBtn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
View applyMovePointButton = mainView.findViewById(R.id.apply_move_point_button);
|
View applyMovePointButton = mainView.findViewById(R.id.apply_move_point_button);
|
||||||
UiUtilities.setupDialogButton(nightMode, applyMovePointButton, UiUtilities.DialogButtonType.PRIMARY,
|
UiUtilities.setupDialogButton(nightMode, applyMovePointButton,
|
||||||
R.string.shared_string_apply);
|
UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply);
|
||||||
|
applyMovePointButton.setMinimumWidth(btnWidth);
|
||||||
applyMovePointButton.setOnClickListener(new OnClickListener() {
|
applyMovePointButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -349,8 +343,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
|
|
||||||
View applyPointBeforeAfterButton = mainView.findViewById(R.id.apply_point_before_after_point_button);
|
View applyPointBeforeAfterButton = mainView.findViewById(R.id.apply_point_before_after_point_button);
|
||||||
UiUtilities.setupDialogButton(nightMode, applyPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY,
|
UiUtilities.setupDialogButton(nightMode, applyPointBeforeAfterButton,
|
||||||
R.string.shared_string_apply);
|
UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_apply);
|
||||||
|
applyPointBeforeAfterButton.setMinimumWidth(btnWidth);
|
||||||
applyPointBeforeAfterButton.setOnClickListener(new OnClickListener() {
|
applyPointBeforeAfterButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -359,8 +354,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
});
|
});
|
||||||
|
|
||||||
View addPointBeforeAfterButton = mainView.findViewById(R.id.add_point_before_after_button);
|
View addPointBeforeAfterButton = mainView.findViewById(R.id.add_point_before_after_button);
|
||||||
UiUtilities.setupDialogButton(nightMode, addPointBeforeAfterButton, UiUtilities.DialogButtonType.PRIMARY,
|
UiUtilities.setupDialogButton(nightMode, addPointBeforeAfterButton,
|
||||||
R.string.shared_string_add);
|
UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_add);
|
||||||
|
addPointBeforeAfterButton.setMinimumWidth(btnWidth);
|
||||||
addPointBeforeAfterButton.setOnClickListener(new OnClickListener() {
|
addPointBeforeAfterButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -408,8 +404,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
});
|
});
|
||||||
|
|
||||||
View addPointButton = mainView.findViewById(R.id.add_point_button);
|
View addPointButton = mainView.findViewById(R.id.add_point_button);
|
||||||
UiUtilities.setupDialogButton(nightMode, addPointButton, UiUtilities.DialogButtonType.PRIMARY,
|
UiUtilities.setupDialogButton(nightMode, addPointButton,
|
||||||
R.string.shared_string_add);
|
UiUtilities.DialogButtonType.PRIMARY, R.string.shared_string_add);
|
||||||
|
addPointButton.setMinimumWidth(btnWidth);
|
||||||
addPointButton.setOnClickListener(new OnClickListener() {
|
addPointButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
@ -425,9 +422,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelectPoint(int selectedPointPos) {
|
public void onSelectPoint(int selectedPointPos) {
|
||||||
if (additionalInfoExpanded) {
|
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
if (selectedPointPos != -1) {
|
if (selectedPointPos != -1) {
|
||||||
openSelectedPointMenu(mapActivity);
|
openSelectedPointMenu(mapActivity);
|
||||||
}
|
}
|
||||||
|
@ -449,9 +443,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
measurementLayer.setOnEnterMovePointModeListener(new MeasurementToolLayer.OnEnterMovePointModeListener() {
|
measurementLayer.setOnEnterMovePointModeListener(new MeasurementToolLayer.OnEnterMovePointModeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onEnterMovePointMode() {
|
public void onEnterMovePointMode() {
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
switchMovePointMode(true);
|
switchMovePointMode(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -529,37 +521,90 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeAdditionalInfoType(@NonNull AdditionalInfoType type) {
|
private OnRadioItemClickListener getInfoTypeBtnListener(@NonNull final InfoType type) {
|
||||||
if (!additionalInfoExpanded || !isCurrentAdditionalInfoType(type)) {
|
return new OnRadioItemClickListener() {
|
||||||
MapActivity ma = getMapActivity();
|
@Override
|
||||||
if (ma == null) return;
|
public boolean onRadioItemClick(RadioItem radioItem, View view) {
|
||||||
|
if (isCurrentInfoType(type)) {
|
||||||
OsmandApplication app = ma.getMyApplication();
|
collapseInfoView();
|
||||||
if (AdditionalInfoType.POINTS == type) {
|
return false;
|
||||||
visibleCard = pointsCard;
|
}
|
||||||
UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, START);
|
return setInfoType(type);
|
||||||
} else if (AdditionalInfoType.GRAPH == type) {
|
|
||||||
visibleCard = graphsCard;
|
|
||||||
UiUtilities.updateCustomRadioButtons(app, customRadioButton, nightMode, END);
|
|
||||||
}
|
}
|
||||||
cardsContainer.removeAllViews();
|
};
|
||||||
View cardView = visibleCard.getView() != null ? visibleCard.getView() : visibleCard.build(ma);
|
}
|
||||||
cardsContainer.addView(cardView);
|
|
||||||
|
|
||||||
currentAdditionalInfoType = type;
|
private boolean setInfoType(@NonNull InfoType type) {
|
||||||
additionalInfoExpanded = true;
|
OsmandApplication app = getMyApplication();
|
||||||
|
if ((!infoExpanded || !isCurrentInfoType(type)) && app != null) {
|
||||||
|
if (editingCtx.getPointsCount() > 0 && editingCtx.getSelectedPointPosition() == -1) {
|
||||||
|
expandInfoView();
|
||||||
|
currentInfoType = type;
|
||||||
|
if (InfoType.POINTS == type) {
|
||||||
|
visibleCard = pointsCard;
|
||||||
|
} else if (InfoType.GRAPH == type) {
|
||||||
|
visibleCard = graphsCard;
|
||||||
|
}
|
||||||
|
cardsContainer.removeAllViews();
|
||||||
|
View cardView = visibleCard.getView() != null ? visibleCard.getView() : visibleCard.build(app);
|
||||||
|
cardsContainer.addView(cardView);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
collapseInfoView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void expandInfoView() {
|
||||||
|
if (portrait) {
|
||||||
|
infoExpanded = true;
|
||||||
|
cardsContainer.setVisibility(View.VISIBLE);
|
||||||
|
setMapPosition(portrait
|
||||||
|
? OsmandSettings.MIDDLE_TOP_CONSTANT
|
||||||
|
: OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
|
||||||
updateUpDownBtn();
|
updateUpDownBtn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAdditionalInfoView() {
|
private void collapseInfoViewIfExpanded() {
|
||||||
updateAdditionalInfoView(pointsCard);
|
if (infoExpanded) {
|
||||||
updateAdditionalInfoView(graphsCard);
|
collapseInfoView();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAdditionalInfoView(OnUpdateAdditionalInfoListener listener) {
|
private void collapseInfoView() {
|
||||||
|
if (portrait) {
|
||||||
|
infoExpanded = false;
|
||||||
|
currentInfoType = null;
|
||||||
|
infoTypeBtn.setSelectedItem(null);
|
||||||
|
cardsContainer.setVisibility(View.GONE);
|
||||||
|
setDefaultMapPosition();
|
||||||
|
updateUpDownBtn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void collapseInfoIfNotEnoughPoints() {
|
||||||
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
|
if (measurementLayer != null) {
|
||||||
|
int pointsCount = editingCtx.getPointsCount();
|
||||||
|
if (isCurrentInfoType(InfoType.GRAPH) && pointsCount < 2) {
|
||||||
|
collapseInfoView();
|
||||||
|
} else if (pointsCount < 1) {
|
||||||
|
disable(upDownBtn);
|
||||||
|
collapseInfoViewIfExpanded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateInfoView() {
|
||||||
|
updateInfoView(pointsCard);
|
||||||
|
updateInfoView(graphsCard);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateInfoView(OnUpdateInfoListener listener) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onUpdateAdditionalInfo();
|
listener.onUpdateInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,11 +621,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUndoRedoCommonStuff() {
|
private void updateUndoRedoCommonStuff() {
|
||||||
collapseAdditionalInfoIfNoPointsEnough();
|
collapseInfoIfNotEnoughPoints();
|
||||||
if (editingCtx.getPointsCount() > 0) {
|
if (editingCtx.getPointsCount() > 0) {
|
||||||
enable(upDownBtn);
|
enable(upDownBtn);
|
||||||
}
|
}
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
updateSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
}
|
}
|
||||||
|
@ -638,9 +683,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
cancelModes();
|
cancelModes();
|
||||||
exitMeasurementMode();
|
exitMeasurementMode();
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
MeasurementToolLayer layer = getMeasurementLayer();
|
MeasurementToolLayer layer = getMeasurementLayer();
|
||||||
if (layer != null) {
|
if (layer != null) {
|
||||||
layer.setOnSingleTapListener(null);
|
layer.setOnSingleTapListener(null);
|
||||||
|
@ -891,9 +934,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer, ALL));
|
editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer, ALL));
|
||||||
editingCtx.cancelSnapToRoad();
|
editingCtx.cancelSnapToRoad();
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
disable(upDownBtn);
|
disable(upDownBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
|
@ -907,9 +948,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
if (points.size() > 1) {
|
if (points.size() > 1) {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
editingCtx.getCommandManager().execute(new ReversePointsCommand(measurementLayer));
|
editingCtx.getCommandManager().execute(new ReversePointsCommand(measurementLayer));
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateUndoRedoButton(true, undoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
|
@ -976,9 +1015,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private void trimRoute(ClearCommandMode before) {
|
private void trimRoute(ClearCommandMode before) {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer, before));
|
editingCtx.getCommandManager().execute(new ClearPointsCommand(measurementLayer, before));
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
editingCtx.setSelectedPointPosition(-1);
|
editingCtx.setSelectedPointPosition(-1);
|
||||||
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
editingCtx.splitSegments(editingCtx.getBeforePoints().size() + editingCtx.getAfterPoints().size());
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
|
@ -1130,11 +1167,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
private void removePoint(MeasurementToolLayer measurementLayer, int position) {
|
private void removePoint(MeasurementToolLayer measurementLayer, int position) {
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
editingCtx.getCommandManager().execute(new RemovePointCommand(measurementLayer, position));
|
editingCtx.getCommandManager().execute(new RemovePointCommand(measurementLayer, position));
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
updateUndoRedoButton(true, undoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
collapseAdditionalInfoIfNoPointsEnough();
|
collapseInfoIfNotEnoughPoints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,9 +1196,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(int position) {
|
public void onItemClick(int position) {
|
||||||
if (mapActivity != null && measurementLayer != null) {
|
if (mapActivity != null && measurementLayer != null) {
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
if (portrait) {
|
if (portrait) {
|
||||||
setMapPosition(OsmandSettings.MIDDLE_TOP_CONSTANT);
|
setMapPosition(OsmandSettings.MIDDLE_TOP_CONSTANT);
|
||||||
}
|
}
|
||||||
|
@ -1182,7 +1217,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
toPosition = holder.getAdapterPosition();
|
toPosition = holder.getAdapterPosition();
|
||||||
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
|
||||||
editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
editingCtx.getCommandManager().execute(new ReorderPointCommand(measurementLayer, fromPosition, toPosition));
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
|
@ -1248,7 +1283,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
if (!isUndoMode()) {
|
if (!isUndoMode()) {
|
||||||
editingCtx.addPoints();
|
editingCtx.addPoints();
|
||||||
}
|
}
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1406,7 +1441,9 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
R.id.measurement_points_text_view,
|
R.id.measurement_points_text_view,
|
||||||
R.id.distance_to_center_text_view,
|
R.id.distance_to_center_text_view,
|
||||||
R.id.up_down_button,
|
R.id.up_down_button,
|
||||||
R.id.measure_mode_controls);
|
R.id.measure_mode_controls,
|
||||||
|
R.id.info_type_buttons_container,
|
||||||
|
R.id.bottom_panel_divider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1444,46 +1481,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
updateUndoRedoButton(true, undoBtn);
|
updateUndoRedoButton(true, undoBtn);
|
||||||
updateUndoRedoButton(false, redoBtn);
|
updateUndoRedoButton(false, redoBtn);
|
||||||
updateDistancePointsText();
|
updateDistancePointsText();
|
||||||
updateAdditionalInfoView();
|
updateInfoView();
|
||||||
}
|
|
||||||
|
|
||||||
private void expandAdditionalInfoView() {
|
|
||||||
if (portrait) {
|
|
||||||
MapActivity mapActivity = getMapActivity();
|
|
||||||
if (mapActivity != null) {
|
|
||||||
additionalInfoContainer.setVisibility(View.VISIBLE);
|
|
||||||
AdditionalInfoType typeToShow = currentAdditionalInfoType == null
|
|
||||||
? AdditionalInfoType.POINTS : currentAdditionalInfoType;
|
|
||||||
changeAdditionalInfoType(typeToShow);
|
|
||||||
setMapPosition(portrait
|
|
||||||
? OsmandSettings.MIDDLE_TOP_CONSTANT
|
|
||||||
: OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void collapseAdditionalInfoView() {
|
|
||||||
if (portrait) {
|
|
||||||
additionalInfoExpanded = false;
|
|
||||||
updateUpDownBtn();
|
|
||||||
additionalInfoContainer.setVisibility(View.GONE);
|
|
||||||
setDefaultMapPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void collapseAdditionalInfoIfNoPointsEnough() {
|
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
|
||||||
if (measurementLayer != null) {
|
|
||||||
int pointsCount = editingCtx.getPointsCount();
|
|
||||||
if (isCurrentAdditionalInfoType(AdditionalInfoType.GRAPH) && pointsCount < 2) {
|
|
||||||
collapseAdditionalInfoView();
|
|
||||||
} else if (pointsCount < 1) {
|
|
||||||
disable(upDownBtn);
|
|
||||||
if (additionalInfoExpanded) {
|
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultMapPosition() {
|
private void setDefaultMapPosition() {
|
||||||
|
@ -1510,13 +1508,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateUpDownBtn() {
|
private void updateUpDownBtn() {
|
||||||
Drawable icon = getContentIcon(additionalInfoExpanded
|
Drawable icon = getContentIcon(infoExpanded
|
||||||
? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up);
|
? R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up);
|
||||||
upDownBtn.setImageDrawable(icon);
|
upDownBtn.setImageDrawable(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCurrentAdditionalInfoType(@NonNull AdditionalInfoType type) {
|
private boolean isCurrentInfoType(@NonNull InfoType type) {
|
||||||
return type.equals(currentAdditionalInfoType);
|
return Algorithms.objectEquals(currentInfoType, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasVisibleGraph() {
|
public boolean hasVisibleGraph() {
|
||||||
|
@ -1600,7 +1598,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
switch (finalSaveAction) {
|
switch (finalSaveAction) {
|
||||||
case SHOW_SNACK_BAR_AND_CLOSE:
|
case SHOW_SNACK_BAR_AND_CLOSE:
|
||||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||||
snackbar = Snackbar.make(mapActivity.getLayout(),
|
Snackbar snackbar = Snackbar.make(mapActivity.getLayout(),
|
||||||
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), outFile.getName()),
|
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), outFile.getName()),
|
||||||
Snackbar.LENGTH_LONG)
|
Snackbar.LENGTH_LONG)
|
||||||
.setAction(R.string.shared_string_undo, new OnClickListener() {
|
.setAction(R.string.shared_string_undo, new OnClickListener() {
|
||||||
|
@ -1778,7 +1776,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void quit(boolean hidePointsListFirst) {
|
public void quit(boolean hideInfoViewFirst) {
|
||||||
if (editingCtx.getOriginalPointToMove() != null) {
|
if (editingCtx.getOriginalPointToMove() != null) {
|
||||||
cancelMovePointMode();
|
cancelMovePointMode();
|
||||||
return;
|
return;
|
||||||
|
@ -1793,16 +1791,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
dismiss(mapActivity);
|
dismiss(mapActivity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showQuitDialog(hidePointsListFirst);
|
showQuitDialog(hideInfoViewFirst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showQuitDialog(boolean hidePointsListFirst) {
|
private void showQuitDialog(boolean hideInfoViewFirst) {
|
||||||
final MapActivity mapActivity = getMapActivity();
|
final MapActivity mapActivity = getMapActivity();
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (mapActivity != null && measurementLayer != null) {
|
if (mapActivity != null && measurementLayer != null) {
|
||||||
if (additionalInfoExpanded && hidePointsListFirst) {
|
if (infoExpanded && hideInfoViewFirst) {
|
||||||
collapseAdditionalInfoView();
|
collapseInfoView();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!editingCtx.hasChanges()) {
|
if (!editingCtx.hasChanges()) {
|
||||||
|
@ -1822,9 +1820,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
if (clearContext) {
|
if (clearContext) {
|
||||||
editingCtx.clearSegments();
|
editingCtx.clearSegments();
|
||||||
}
|
}
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
resetAppMode();
|
resetAppMode();
|
||||||
hideSnapToRoadIcon();
|
hideSnapToRoadIcon();
|
||||||
if (isInEditMode()) {
|
if (isInEditMode()) {
|
||||||
|
@ -1961,9 +1957,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
if (!approximationMode || !editingCtx.getCommandManager().update(command)) {
|
if (!approximationMode || !editingCtx.getCommandManager().update(command)) {
|
||||||
editingCtx.getCommandManager().execute(command);
|
editingCtx.getCommandManager().execute(command);
|
||||||
}
|
}
|
||||||
if (additionalInfoExpanded) {
|
collapseInfoViewIfExpanded();
|
||||||
collapseAdditionalInfoView();
|
|
||||||
}
|
|
||||||
updateSnapToRoadControls();
|
updateSnapToRoadControls();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2036,7 +2030,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
||||||
return nightMode;
|
return nightMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnUpdateAdditionalInfoListener {
|
public interface OnUpdateInfoListener {
|
||||||
void onUpdateAdditionalInfo();
|
void onUpdateInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,12 +7,12 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment.OnUpdateAdditionalInfoListener;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment.OnUpdateInfoListener;
|
||||||
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter;
|
import net.osmand.plus.measurementtool.adapter.MeasurementToolAdapter;
|
||||||
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||||
|
|
||||||
public class PointsCard extends BaseCard implements OnUpdateAdditionalInfoListener {
|
public class PointsCard extends BaseCard implements OnUpdateInfoListener {
|
||||||
|
|
||||||
private MeasurementToolAdapter adapter;
|
private MeasurementToolAdapter adapter;
|
||||||
private MeasurementToolFragment fragment;
|
private MeasurementToolFragment fragment;
|
||||||
|
@ -23,7 +23,7 @@ public class PointsCard extends BaseCard implements OnUpdateAdditionalInfoListen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdateAdditionalInfo() {
|
public void onUpdateInfo() {
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class PointsCard extends BaseCard implements OnUpdateAdditionalInfoListen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCardLayoutId() {
|
public int getCardLayoutId() {
|
||||||
return R.layout.fragment_measurement_tool_points_list;
|
return R.layout.measurement_tool_points_card;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
183
OsmAnd/src/net/osmand/plus/widgets/MultiStateToggleButton.java
Normal file
183
OsmAnd/src/net/osmand/plus/widgets/MultiStateToggleButton.java
Normal file
|
@ -0,0 +1,183 @@
|
||||||
|
package net.osmand.plus.widgets;
|
||||||
|
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class MultiStateToggleButton {
|
||||||
|
|
||||||
|
private List<RadioItem> items = new ArrayList<>();
|
||||||
|
private OsmandApplication app;
|
||||||
|
private List<ViewGroup> buttons = new ArrayList<>();
|
||||||
|
private List<View> dividers = new ArrayList<>();
|
||||||
|
private RadioItem selectedItem;
|
||||||
|
|
||||||
|
private LinearLayout container;
|
||||||
|
private boolean nightMode;
|
||||||
|
|
||||||
|
public MultiStateToggleButton(OsmandApplication app, LinearLayout container, boolean nightMode) {
|
||||||
|
this.app = app;
|
||||||
|
this.container = container;
|
||||||
|
this.nightMode = nightMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItems(RadioItem firstBtn, RadioItem secondBtn, RadioItem ... other) {
|
||||||
|
items.clear();
|
||||||
|
items.add(firstBtn);
|
||||||
|
items.add(secondBtn);
|
||||||
|
if (other != null && other.length > 0) {
|
||||||
|
items.addAll(Arrays.asList(other));
|
||||||
|
}
|
||||||
|
initView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
buttons.clear();
|
||||||
|
dividers.clear();
|
||||||
|
container.removeAllViews();
|
||||||
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
createBtn(items.get(i));
|
||||||
|
if (!isLastItem(i)) {
|
||||||
|
createDivider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isLastItem(int index) {
|
||||||
|
return index == items.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createBtn(@NonNull final RadioItem item) {
|
||||||
|
LayoutInflater inflater = UiUtilities.getInflater(app, nightMode);
|
||||||
|
ViewGroup button = (ViewGroup) inflater.inflate(
|
||||||
|
R.layout.custom_radio_btn_text_item, container, false);
|
||||||
|
TextView title = button.findViewById(R.id.title);
|
||||||
|
title.setText(item.getTitle());
|
||||||
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
OnRadioItemClickListener l = item.getListener();
|
||||||
|
if (l != null && l.onRadioItemClick(item, container)) {
|
||||||
|
setSelectedItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttons.add(button);
|
||||||
|
container.addView(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDivider() {
|
||||||
|
int dividerColor = nightMode ?
|
||||||
|
R.color.stroked_buttons_and_links_outline_dark :
|
||||||
|
R.color.stroked_buttons_and_links_outline_light;
|
||||||
|
int width = AndroidUtils.dpToPx(app, 1.0f);
|
||||||
|
View divider = new View(app);
|
||||||
|
divider.setLayoutParams(new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
|
divider.setBackgroundColor(ContextCompat.getColor(app, dividerColor));
|
||||||
|
dividers.add(divider);
|
||||||
|
container.addView(divider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedItem(RadioItem selectedItem) {
|
||||||
|
this.selectedItem = selectedItem;
|
||||||
|
updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateView() {
|
||||||
|
int activeColor = ContextCompat.getColor(app, nightMode
|
||||||
|
? R.color.active_color_primary_dark
|
||||||
|
: R.color.active_color_primary_light);
|
||||||
|
int textColor = ContextCompat.getColor(app, nightMode
|
||||||
|
? R.color.text_color_primary_dark
|
||||||
|
: R.color.text_color_primary_light);
|
||||||
|
int radius = AndroidUtils.dpToPx(app, 4);
|
||||||
|
float[] leftBtnRadii = new float[]{radius, radius, 0, 0, 0, 0, radius, radius};
|
||||||
|
float[] rightBtnRadii = new float[]{0, 0, radius, radius, radius, radius, 0, 0};
|
||||||
|
float[] centerBtnRadii = new float[]{0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
boolean isLayoutRtl = AndroidUtils.isLayoutRtl(app);
|
||||||
|
|
||||||
|
GradientDrawable background = new GradientDrawable();
|
||||||
|
background.setColor(UiUtilities.getColorWithAlpha(activeColor, 0.1f));
|
||||||
|
background.setStroke(AndroidUtils.dpToPx(app, 1), UiUtilities.getColorWithAlpha(activeColor, 0.5f));
|
||||||
|
|
||||||
|
showAllDividers();
|
||||||
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
RadioItem item = items.get(i);
|
||||||
|
ViewGroup container = buttons.get(i);
|
||||||
|
TextView tvTitle = (TextView) container.findViewById(R.id.title);
|
||||||
|
if (selectedItem == item) {
|
||||||
|
if (i == 0) {
|
||||||
|
background.setCornerRadii(isLayoutRtl ? rightBtnRadii : leftBtnRadii);
|
||||||
|
hideDividers(0);
|
||||||
|
} else if (i == items.size() - 1) {
|
||||||
|
background.setCornerRadii(isLayoutRtl ? leftBtnRadii : rightBtnRadii);
|
||||||
|
hideDividers(dividers.size() - 1);
|
||||||
|
} else {
|
||||||
|
background.setCornerRadii(centerBtnRadii);
|
||||||
|
hideDividers(i - 1, i);
|
||||||
|
}
|
||||||
|
container.setBackgroundDrawable(background);
|
||||||
|
tvTitle.setTextColor(textColor);
|
||||||
|
} else {
|
||||||
|
container.setBackgroundColor(Color.TRANSPARENT);
|
||||||
|
tvTitle.setTextColor(activeColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAllDividers() {
|
||||||
|
for (View divider : dividers) {
|
||||||
|
divider.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void hideDividers(int ... dividerIndexes) {
|
||||||
|
for (int dividerIndex : dividerIndexes) {
|
||||||
|
if (dividerIndex >= 0 && dividerIndex < dividers.size()) {
|
||||||
|
dividers.get(dividerIndex).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RadioItem {
|
||||||
|
private String title;
|
||||||
|
private OnRadioItemClickListener listener;
|
||||||
|
|
||||||
|
public RadioItem(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnClickListener(OnRadioItemClickListener listener) {
|
||||||
|
this.listener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OnRadioItemClickListener getListener() {
|
||||||
|
return listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface OnRadioItemClickListener {
|
||||||
|
boolean onRadioItemClick(RadioItem radioItem, View view);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue