Merge pull request #9780 from osmandapp/plan_route_scroll_fixes
Plan route scroll fixes
This commit is contained in:
commit
ce342e03f2
13 changed files with 489 additions and 134 deletions
11
OsmAnd/res/drawable/bottom_sheet_buttons_bg_dark.xml
Normal file
11
OsmAnd/res/drawable/bottom_sheet_buttons_bg_dark.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<nine-patch android:src="@drawable/bg_shadow_bottomsheet_sides"/>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="@color/list_background_color_dark"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
11
OsmAnd/res/drawable/bottom_sheet_buttons_bg_light.xml
Normal file
11
OsmAnd/res/drawable/bottom_sheet_buttons_bg_light.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<nine-patch android:src="@drawable/bg_shadow_bottomsheet_sides"/>
|
||||
</item>
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="@color/list_background_color_light"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
50
OsmAnd/res/layout/bottom_sheet_behaviour_base.xml
Normal file
50
OsmAnd/res/layout/bottom_sheet_behaviour_base.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/scroll_view_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/bottom_sheet_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:behavior_hideable="false"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/items_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small" />
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/bottom_buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/buttons_shadow"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="10dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/bg_contextmenu_shadow_top_light"
|
||||
android:visibility="gone" />
|
||||
|
||||
<include layout="@layout/bottom_buttons" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,16 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -62,5 +57,3 @@
|
|||
tools:listitem="@layout/gpx_track_select_item" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -1,12 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
@ -43,5 +38,3 @@
|
|||
tools:listitem="@layout/gpx_track_select_item" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -1,10 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
|
@ -22,12 +18,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="@dimen/measurement_tool_menu_title_padding_top"
|
||||
android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/measurement_tool_menu_title_padding_top"
|
||||
android:paddingEnd="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom"
|
||||
android:text="@string/route_between_points"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
@ -66,5 +62,3 @@
|
|||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
|
@ -0,0 +1,282 @@
|
|||
package net.osmand.plus.base;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BottomSheetBehaviourDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
private static final String USED_ON_MAP_KEY = "used_on_map";
|
||||
private static final int DEFAULT_VALUE = -1;
|
||||
|
||||
protected List<BaseBottomSheetItem> items = new ArrayList<>();
|
||||
|
||||
protected boolean usedOnMap = true;
|
||||
protected boolean nightMode;
|
||||
protected boolean portrait;
|
||||
|
||||
protected View dismissButton;
|
||||
protected View rightButton;
|
||||
|
||||
private LinearLayout itemsContainer;
|
||||
|
||||
public void setUsedOnMap(boolean usedOnMap) {
|
||||
this.usedOnMap = usedOnMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (savedInstanceState != null) {
|
||||
usedOnMap = savedInstanceState.getBoolean(USED_ON_MAP_KEY);
|
||||
}
|
||||
nightMode = isNightMode(requiredMyApplication());
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(requireActivity());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
|
||||
LayoutInflater themedInflater = UiUtilities.getInflater(requireContext(), nightMode);
|
||||
View mainView = themedInflater.inflate(R.layout.bottom_sheet_behaviour_base, parent, false);
|
||||
itemsContainer = (LinearLayout) mainView.findViewById(R.id.items_container);
|
||||
|
||||
View scrollView = mainView.findViewById(R.id.bottom_sheet_scroll_view);
|
||||
final BottomSheetBehavior behavior = BottomSheetBehavior.from(scrollView);
|
||||
behavior.setPeekHeight(getPeekHeight());
|
||||
|
||||
LinearLayout buttonsContainer = (LinearLayout) mainView.findViewById(R.id.buttons_container);
|
||||
buttonsContainer.setBackgroundResource(getButtonsContainerBg());
|
||||
|
||||
if (!portrait) {
|
||||
Dialog dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
|
||||
@Override
|
||||
public void onShow(DialogInterface dialog) {
|
||||
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
createMenuItems(savedInstanceState);
|
||||
inflateMenuItems();
|
||||
|
||||
dismissButton = mainView.findViewById(R.id.dismiss_button);
|
||||
UiUtilities.setupDialogButton(nightMode, dismissButton, getDismissButtonType(), getDismissButtonTextId());
|
||||
dismissButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onDismissButtonClickAction();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
if (hideButtonsContainer()) {
|
||||
mainView.findViewById(R.id.buttons_container).setVisibility(View.GONE);
|
||||
} else {
|
||||
int rightBottomButtonTextId = getRightBottomButtonTextId();
|
||||
if (rightBottomButtonTextId != DEFAULT_VALUE) {
|
||||
mainView.findViewById(R.id.buttons_divider).setVisibility(View.VISIBLE);
|
||||
rightButton = mainView.findViewById(R.id.right_bottom_button);
|
||||
UiUtilities.setupDialogButton(nightMode, rightButton, getRightBottomButtonType(), rightBottomButtonTextId);
|
||||
rightButton.setVisibility(View.VISIBLE);
|
||||
rightButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onRightBottomButtonClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
updateBackground();
|
||||
updateBottomButtons();
|
||||
return mainView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
FragmentActivity activity = requireActivity();
|
||||
if (!AndroidUiHelper.isOrientationPortrait(activity)) {
|
||||
Dialog dialog = getDialog();
|
||||
Window window = dialog != null ? dialog.getWindow() : null;
|
||||
if (window != null) {
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = activity.getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(USED_ON_MAP_KEY, usedOnMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
items.clear();
|
||||
if (itemsContainer != null) {
|
||||
itemsContainer.removeAllViews();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void createMenuItems(Bundle savedInstanceState);
|
||||
|
||||
protected void inflateMenuItems() {
|
||||
Activity activity = requireActivity();
|
||||
for (BaseBottomSheetItem item : items) {
|
||||
item.inflate(activity, itemsContainer, nightMode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
return getIcon(id, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
|
||||
}
|
||||
|
||||
protected Drawable getActiveIcon(@DrawableRes int id) {
|
||||
return getIcon(id, getActiveColorId());
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
protected int getActiveColorId() {
|
||||
return nightMode ? R.color.osmand_orange : R.color.color_myloc_distance;
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
protected int getResolvedColor(@ColorRes int colorId) {
|
||||
Context ctx = getContext();
|
||||
return ctx != null ? ContextCompat.getColor(ctx, colorId) : 0;
|
||||
}
|
||||
|
||||
private void updateBackground() {
|
||||
if (portrait) {
|
||||
itemsContainer.setBackgroundResource(getPortraitBgResId());
|
||||
} else {
|
||||
itemsContainer.setBackgroundResource(getLandscapeTopsidesBgResId());
|
||||
}
|
||||
}
|
||||
|
||||
protected int getPeekHeight() {
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
protected boolean hideButtonsContainer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_cancel;
|
||||
}
|
||||
|
||||
protected DialogButtonType getDismissButtonType() {
|
||||
return DialogButtonType.SECONDARY;
|
||||
}
|
||||
|
||||
protected void onDismissButtonClickAction() {
|
||||
|
||||
}
|
||||
|
||||
@StringRes
|
||||
protected int getRightBottomButtonTextId() {
|
||||
return DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
protected DialogButtonType getRightBottomButtonType() {
|
||||
return DialogButtonType.PRIMARY;
|
||||
}
|
||||
|
||||
protected void onRightBottomButtonClick() {
|
||||
|
||||
}
|
||||
|
||||
protected boolean isDismissButtonEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean isRightBottomButtonEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void updateBottomButtons() {
|
||||
if (dismissButton != null) {
|
||||
boolean enabled = isDismissButtonEnabled();
|
||||
dismissButton.setEnabled(enabled);
|
||||
dismissButton.findViewById(R.id.button_text).setEnabled(enabled);
|
||||
}
|
||||
if (rightButton != null) {
|
||||
boolean enabled = isRightBottomButtonEnabled();
|
||||
rightButton.setEnabled(enabled);
|
||||
rightButton.findViewById(R.id.button_text).setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
protected int getBgColorId() {
|
||||
return nightMode ? R.color.list_background_color_dark : R.color.list_background_color_light;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
protected int getPortraitBgResId() {
|
||||
return nightMode ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_menu_light;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
protected int getLandscapeTopsidesBgResId() {
|
||||
return nightMode ? R.drawable.bg_bottom_sheet_topsides_landscape_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
protected int getLandscapeSidesBgResId() {
|
||||
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
|
||||
}
|
||||
|
||||
private int getButtonsContainerBg() {
|
||||
if (portrait) {
|
||||
return getBgColorId();
|
||||
}
|
||||
return nightMode ? R.drawable.bottom_sheet_buttons_bg_dark : R.drawable.bottom_sheet_buttons_bg_light;
|
||||
}
|
||||
|
||||
protected boolean isNightMode(@NonNull OsmandApplication app) {
|
||||
if (usedOnMap) {
|
||||
return app.getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
return !app.getSettings().isLightContent();
|
||||
}
|
||||
}
|
|
@ -612,6 +612,10 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
|
||||
protected boolean isHideable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processScreenHeight(ViewParent parent) {
|
||||
View container = (View) parent;
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
@ -783,7 +787,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
|||
|
||||
|
||||
private int getPosY(final int currentY, boolean needCloseMenu, int previousState) {
|
||||
if (needCloseMenu) {
|
||||
if (needCloseMenu && isHideable()) {
|
||||
return screenHeight;
|
||||
}
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
@ -858,7 +862,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
|||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (!canceled) {
|
||||
if (needCloseMenu) {
|
||||
if (needCloseMenu && isHideable()) {
|
||||
dismiss();
|
||||
} else {
|
||||
updateMainViewLayout(posY);
|
||||
|
@ -870,7 +874,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}).start();
|
||||
} else {
|
||||
if (needCloseMenu) {
|
||||
if (needCloseMenu && isHideable()) {
|
||||
dismiss();
|
||||
} else {
|
||||
mainView.setY(posY);
|
||||
|
|
|
@ -56,6 +56,8 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
|||
private View cancelButton;
|
||||
private View applyButton;
|
||||
|
||||
private SliderCard sliderCard;
|
||||
|
||||
@Override
|
||||
public int getMainLayoutId() {
|
||||
return R.layout.fragment_gpx_approximation_bottom_sheet_dialog;
|
||||
|
@ -87,7 +89,7 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
|||
|
||||
@Override
|
||||
public int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,11 +177,17 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
|||
|
||||
@Override
|
||||
protected void calculateLayout(View view, boolean initLayout) {
|
||||
int sliderHeight = sliderCard != null ? sliderCard.getViewHeight() : 0;
|
||||
menuTitleHeight = view.findViewById(R.id.control_buttons).getHeight()
|
||||
- view.findViewById(R.id.buttons_shadow).getHeight();
|
||||
- view.findViewById(R.id.buttons_shadow).getHeight() + sliderHeight;
|
||||
super.calculateLayout(view, initLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isHideable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
@ -265,7 +273,7 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
|
|||
cardsContainer.removeAllViews();
|
||||
|
||||
if (getTopView() != null) {
|
||||
SliderCard sliderCard = new SliderCard(mapActivity, distanceThreshold);
|
||||
sliderCard = new SliderCard(mapActivity, distanceThreshold);
|
||||
sliderCard.setListener(this);
|
||||
getTopView().addView(sliderCard.build(mapActivity));
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import java.util.Map;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.WHOLE_TRACK;
|
||||
import static net.osmand.plus.measurementtool.command.MeasurementModeCommand.MeasurementCommandType.*;
|
||||
import static net.osmand.plus.measurementtool.command.MeasurementModeCommand.MeasurementCommandType.APPROXIMATE_POINTS;
|
||||
|
||||
public class MeasurementEditingContext {
|
||||
|
||||
|
@ -249,8 +249,10 @@ public class MeasurementEditingContext {
|
|||
Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
|
||||
RoadSegmentData data = this.roadSegmentData.get(pair);
|
||||
if (data == null) {
|
||||
if (appMode != MeasurementEditingContext.DEFAULT_APP_MODE || !pair.first.lastPoint || !pair.second.firstPoint) {
|
||||
distance += MapUtils.getDistance(pair.first.getLatitude(), pair.first.getLongitude(),
|
||||
pair.second.getLatitude(), pair.second.getLongitude());
|
||||
}
|
||||
} else {
|
||||
distance += data.getDistance();
|
||||
}
|
||||
|
|
|
@ -13,11 +13,12 @@ import androidx.annotation.NonNull;
|
|||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.BottomSheetBehaviourDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
|
||||
|
@ -29,8 +30,9 @@ import java.util.List;
|
|||
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.LEFT;
|
||||
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.RIGHT;
|
||||
import static net.osmand.plus.measurementtool.MeasurementEditingContext.DEFAULT_APP_MODE;
|
||||
import static net.osmand.plus.measurementtool.SelectFileBottomSheet.BOTTOM_SHEET_HEIGHT_DP;
|
||||
|
||||
public class RouteBetweenPointsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
public class RouteBetweenPointsBottomSheetDialogFragment extends BottomSheetBehaviourDialogFragment {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(RouteBetweenPointsBottomSheetDialogFragment.class);
|
||||
public static final String TAG = RouteBetweenPointsBottomSheetDialogFragment.class.getSimpleName();
|
||||
|
@ -225,6 +227,11 @@ public class RouteBetweenPointsBottomSheetDialogFragment extends MenuBottomSheet
|
|||
items.add(new BaseBottomSheetItem.Builder().setCustomView(mainView).create());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPeekHeight() {
|
||||
return AndroidUtils.dpToPx(getContext(), BOTTOM_SHEET_HEIGHT_DP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_close;
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.IndexConstants;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.BottomSheetBehaviourDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.helpers.GpxTrackAdapter;
|
||||
import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener;
|
||||
|
@ -32,7 +32,7 @@ import java.util.Map;
|
|||
import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo;
|
||||
import static net.osmand.util.Algorithms.collectDirs;
|
||||
|
||||
public class SelectFileBottomSheet extends MenuBottomSheetDialogFragment {
|
||||
public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
|
||||
|
||||
enum Mode {
|
||||
OPEN_TRACK(R.string.plan_route_open_existing_track, R.string.plan_route_select_track_file_for_open),
|
||||
|
@ -174,8 +174,8 @@ public class SelectFileBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int getCustomHeight() {
|
||||
return AndroidUtils.dpToPx(mainView.getContext(), BOTTOM_SHEET_HEIGHT_DP);
|
||||
protected int getPeekHeight() {
|
||||
return AndroidUtils.dpToPx(getContext(), BOTTOM_SHEET_HEIGHT_DP);
|
||||
}
|
||||
|
||||
public static void showInstance(FragmentManager fragmentManager, SelectFileListener listener, Mode mode) {
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.osmand.IndexConstants;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.BottomSheetBehaviourDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
|
||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||
|
||||
import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo;
|
||||
|
||||
public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
|
||||
public class StartPlanRouteBottomSheet extends BottomSheetBehaviourDialogFragment {
|
||||
|
||||
public static final String TAG = StartPlanRouteBottomSheet.class.getSimpleName();
|
||||
private static final Log LOG = PlatformUtil.getLog(StartPlanRouteBottomSheet.class);
|
||||
|
@ -136,8 +136,8 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected int getCustomHeight() {
|
||||
return AndroidUtils.dpToPx(mainView.getContext(), BOTTOM_SHEET_HEIGHT_DP);
|
||||
protected int getPeekHeight() {
|
||||
return AndroidUtils.dpToPx(getContext(), BOTTOM_SHEET_HEIGHT_DP);
|
||||
}
|
||||
|
||||
private void onItemClick(int position, List<GPXInfo> gpxInfoList) {
|
||||
|
|
Loading…
Reference in a new issue