Merge pull request #9780 from osmandapp/plan_route_scroll_fixes

Plan route scroll fixes
This commit is contained in:
vshcherb 2020-09-11 12:38:36 +02:00 committed by GitHub
commit ce342e03f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 489 additions and 134 deletions

View 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>

View 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>

View 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>

View file

@ -1,66 +1,59 @@
<?xml version="1.0" encoding="utf-8"?> <?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:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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/plan_route_open_existing_track"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding"
android:text="@string/plan_route_select_track_file_for_open"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/folder_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:clipToPadding="false"
android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:itemCount="3"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/point_editor_icon_category_item"
tools:orientation="horizontal" />
<net.osmand.plus.widgets.TextViewEx <androidx.recyclerview.widget.RecyclerView
android:id="@+id/title" android:id="@+id/gpx_track_list"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding" tools:itemCount="1"
android:paddingLeft="@dimen/content_padding" tools:listitem="@layout/gpx_track_select_item" />
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/plan_route_open_existing_track"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx </LinearLayout>
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/content_padding"
android:text="@string/plan_route_select_track_file_for_open"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_regular" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/folder_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
tools:itemCount="3"
tools:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/point_editor_icon_category_item"
tools:orientation="horizontal" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/gpx_track_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="1"
tools:listitem="@layout/gpx_track_select_item" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -1,47 +1,40 @@
<?xml version="1.0" encoding="utf-8"?> <?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:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="horizontal"
android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingTop="@dimen/bottom_sheet_title_padding_top"
android:paddingEnd="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/bottom_sheet_title_padding_bottom">
<LinearLayout <net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent" android:id="@+id/last_edited"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:letterSpacing="@dimen/description_letter_spacing"
android:paddingStart="@dimen/content_padding" android:text="@string/plan_route_last_edited"
android:paddingLeft="@dimen/content_padding" android:textColor="?attr/active_color_basic"
android:paddingTop="@dimen/bottom_sheet_title_padding_top" android:textSize="@dimen/default_desc_text_size"
android:paddingEnd="@dimen/content_padding" osmand:typeface="@string/font_roboto_medium" />
android:paddingRight="@dimen/content_padding"
android:paddingBottom="@dimen/bottom_sheet_title_padding_bottom">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/last_edited"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:letterSpacing="@dimen/description_letter_spacing"
android:text="@string/plan_route_last_edited"
android:textColor="?attr/active_color_basic"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/gpx_track_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:itemCount="1"
tools:listitem="@layout/gpx_track_select_item" />
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView> <androidx.recyclerview.widget.RecyclerView
android:id="@+id/gpx_track_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:itemCount="1"
tools:listitem="@layout/gpx_track_select_item" />
</LinearLayout>

View file

@ -1,36 +1,32 @@
<?xml version="1.0" encoding="utf-8"?> <?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:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/navigation_types_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:orientation="vertical"
android:orientation="vertical"> android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<LinearLayout <net.osmand.plus.widgets.TextViewEx
android:id="@+id/navigation_types_container" android:id="@+id/choose_navigation_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:gravity="center_vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> android:paddingStart="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
<net.osmand.plus.widgets.TextViewEx android:paddingTop="@dimen/measurement_tool_menu_title_padding_top"
android:id="@+id/choose_navigation_title" android:paddingEnd="@dimen/content_padding"
android:layout_width="match_parent" android:paddingRight="@dimen/content_padding"
android:layout_height="wrap_content" android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom"
android:gravity="center_vertical" android:text="@string/route_between_points"
android:paddingTop="@dimen/measurement_tool_menu_title_padding_top" android:textAppearance="@style/TextAppearance.ListItemTitle"
android:paddingBottom="@dimen/measurement_tool_menu_title_padding_bottom" osmand:typeface="@string/font_roboto_medium" />
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/route_between_points"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent" android:layout_width="match_parent"
@ -46,7 +42,7 @@
osmand:typeface="@string/font_roboto_regular" osmand:typeface="@string/font_roboto_regular"
android:textSize="@dimen/default_desc_text_size" /> android:textSize="@dimen/default_desc_text_size" />
<include layout="@layout/custom_radio_buttons" /> <include layout="@layout/custom_radio_buttons" />
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/button_description" android:id="@+id/button_description"
@ -65,6 +61,4 @@
android:textSize="@dimen/default_desc_text_size" /> android:textSize="@dimen/default_desc_text_size" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -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();
}
}

View file

@ -612,6 +612,10 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
} }
} }
protected boolean isHideable() {
return true;
}
private void processScreenHeight(ViewParent parent) { private void processScreenHeight(ViewParent parent) {
View container = (View) parent; View container = (View) parent;
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
@ -783,7 +787,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
private int getPosY(final int currentY, boolean needCloseMenu, int previousState) { private int getPosY(final int currentY, boolean needCloseMenu, int previousState) {
if (needCloseMenu) { if (needCloseMenu && isHideable()) {
return screenHeight; return screenHeight;
} }
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
@ -858,7 +862,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
if (!canceled) { if (!canceled) {
if (needCloseMenu) { if (needCloseMenu && isHideable()) {
dismiss(); dismiss();
} else { } else {
updateMainViewLayout(posY); updateMainViewLayout(posY);
@ -870,7 +874,7 @@ public abstract class ContextMenuFragment extends BaseOsmAndFragment {
} }
}).start(); }).start();
} else { } else {
if (needCloseMenu) { if (needCloseMenu && isHideable()) {
dismiss(); dismiss();
} else { } else {
mainView.setY(posY); mainView.setY(posY);

View file

@ -56,6 +56,8 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
private View cancelButton; private View cancelButton;
private View applyButton; private View applyButton;
private SliderCard sliderCard;
@Override @Override
public int getMainLayoutId() { public int getMainLayoutId() {
return R.layout.fragment_gpx_approximation_bottom_sheet_dialog; return R.layout.fragment_gpx_approximation_bottom_sheet_dialog;
@ -87,7 +89,7 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
@Override @Override
public int getSupportedMenuStatesPortrait() { public int getSupportedMenuStatesPortrait() {
return MenuState.HALF_SCREEN | MenuState.FULL_SCREEN; return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
} }
@Override @Override
@ -175,11 +177,17 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
@Override @Override
protected void calculateLayout(View view, boolean initLayout) { protected void calculateLayout(View view, boolean initLayout) {
int sliderHeight = sliderCard != null ? sliderCard.getViewHeight() : 0;
menuTitleHeight = view.findViewById(R.id.control_buttons).getHeight() 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); super.calculateLayout(view, initLayout);
} }
@Override
protected boolean isHideable() {
return false;
}
@Override @Override
public void onSaveInstanceState(@NonNull Bundle outState) { public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
@ -265,7 +273,7 @@ public class GpxApproximationFragment extends ContextMenuScrollFragment
cardsContainer.removeAllViews(); cardsContainer.removeAllViews();
if (getTopView() != null) { if (getTopView() != null) {
SliderCard sliderCard = new SliderCard(mapActivity, distanceThreshold); sliderCard = new SliderCard(mapActivity, distanceThreshold);
sliderCard.setListener(this); sliderCard.setListener(this);
getTopView().addView(sliderCard.build(mapActivity)); getTopView().addView(sliderCard.build(mapActivity));
} }

View file

@ -43,7 +43,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import static net.osmand.plus.measurementtool.MeasurementEditingContext.CalculationMode.WHOLE_TRACK; 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 { public class MeasurementEditingContext {
@ -249,8 +249,10 @@ public class MeasurementEditingContext {
Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1)); Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
RoadSegmentData data = this.roadSegmentData.get(pair); RoadSegmentData data = this.roadSegmentData.get(pair);
if (data == null) { if (data == null) {
distance += MapUtils.getDistance(pair.first.getLatitude(), pair.first.getLongitude(), if (appMode != MeasurementEditingContext.DEFAULT_APP_MODE || !pair.first.lastPoint || !pair.second.firstPoint) {
pair.second.getLatitude(), pair.second.getLongitude()); distance += MapUtils.getDistance(pair.first.getLatitude(), pair.first.getLongitude(),
pair.second.getLatitude(), pair.second.getLongitude());
}
} else { } else {
distance += data.getDistance(); distance += data.getDistance();
} }

View file

@ -13,11 +13,12 @@ import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; 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.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.settings.backend.ApplicationMode; 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.LEFT;
import static net.osmand.plus.UiUtilities.CustomRadioButtonType.RIGHT; import static net.osmand.plus.UiUtilities.CustomRadioButtonType.RIGHT;
import static net.osmand.plus.measurementtool.MeasurementEditingContext.DEFAULT_APP_MODE; 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); private static final Log LOG = PlatformUtil.getLog(RouteBetweenPointsBottomSheetDialogFragment.class);
public static final String TAG = RouteBetweenPointsBottomSheetDialogFragment.class.getSimpleName(); 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()); items.add(new BaseBottomSheetItem.Builder().setCustomView(mainView).create());
} }
@Override
protected int getPeekHeight() {
return AndroidUtils.dpToPx(getContext(), BOTTOM_SHEET_HEIGHT_DP);
}
@Override @Override
protected int getDismissButtonTextId() { protected int getDismissButtonTextId() {
return R.string.shared_string_close; return R.string.shared_string_close;

View file

@ -15,7 +15,7 @@ import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; 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.BaseBottomSheetItem;
import net.osmand.plus.helpers.GpxTrackAdapter; import net.osmand.plus.helpers.GpxTrackAdapter;
import net.osmand.plus.helpers.GpxTrackAdapter.OnItemClickListener; 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.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo;
import static net.osmand.util.Algorithms.collectDirs; import static net.osmand.util.Algorithms.collectDirs;
public class SelectFileBottomSheet extends MenuBottomSheetDialogFragment { public class SelectFileBottomSheet extends BottomSheetBehaviourDialogFragment {
enum Mode { enum Mode {
OPEN_TRACK(R.string.plan_route_open_existing_track, R.string.plan_route_select_track_file_for_open), 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 @Override
protected int getCustomHeight() { protected int getPeekHeight() {
return AndroidUtils.dpToPx(mainView.getContext(), BOTTOM_SHEET_HEIGHT_DP); return AndroidUtils.dpToPx(getContext(), BOTTOM_SHEET_HEIGHT_DP);
} }
public static void showInstance(FragmentManager fragmentManager, SelectFileListener listener, Mode mode) { public static void showInstance(FragmentManager fragmentManager, SelectFileListener listener, Mode mode) {

View file

@ -19,7 +19,7 @@ import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; 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.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem;
@ -38,7 +38,7 @@ import java.util.List;
import static net.osmand.plus.helpers.GpxUiHelper.getSortedGPXFilesInfo; 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(); public static final String TAG = StartPlanRouteBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(StartPlanRouteBottomSheet.class); private static final Log LOG = PlatformUtil.getLog(StartPlanRouteBottomSheet.class);
@ -136,8 +136,8 @@ public class StartPlanRouteBottomSheet extends MenuBottomSheetDialogFragment {
} }
@Override @Override
protected int getCustomHeight() { protected int getPeekHeight() {
return AndroidUtils.dpToPx(mainView.getContext(), BOTTOM_SHEET_HEIGHT_DP); return AndroidUtils.dpToPx(getContext(), BOTTOM_SHEET_HEIGHT_DP);
} }
private void onItemClick(int position, List<GPXInfo> gpxInfoList) { private void onItemClick(int position, List<GPXInfo> gpxInfoList) {