From 7a98b5304da8448a982942f1f2b643c5f3292314 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 10:02:00 +0200 Subject: [PATCH 1/8] Add small refactoring to bottom sheet menus --- .../plus/base/MenuBottomSheetDialogFragment.java | 9 +++++++-- .../src/net/osmand/plus/helpers/ImportHelper.java | 5 ----- .../CoordinateInputBottomSheetDialogFragment.java | 3 +-- .../ParkingTypeBottomSheetDialogFragment.java | 13 +++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 5a530f6158..f9460560e4 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; +import android.support.annotation.ColorInt; import android.support.annotation.ColorRes; import android.support.annotation.DrawableRes; import android.support.annotation.Nullable; @@ -69,8 +70,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra int closeRowDividerColorId = getCloseRowDividerColorId(); if (closeRowDividerColorId != -1) { - mainView.findViewById(R.id.close_row_divider) - .setBackgroundColor(ContextCompat.getColor(getContext(), closeRowDividerColorId)); + mainView.findViewById(R.id.close_row_divider).setBackgroundColor(getResolvedColor(closeRowDividerColorId)); } mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() { @Override @@ -123,6 +123,11 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra return getIcon(id, nightMode ? R.color.osmand_orange : R.color.color_myloc_distance); } + @ColorInt + protected int getResolvedColor(@ColorRes int colorId) { + return ContextCompat.getColor(getContext(), colorId); + } + protected void setupHeightAndBackground(final View mainView) { final Activity activity = getActivity(); final int screenHeight = AndroidUtils.getScreenHeight(activity); diff --git a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java index 21f4f6a048..af4daaaf47 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ImportHelper.java @@ -790,10 +790,5 @@ public class ImportHelper { .create(); items.add(asGpxItem); } - - @ColorInt - private int getResolvedColor(@ColorRes int colorId) { - return ContextCompat.getColor(getContext(), colorId); - } } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 75472c3b3b..942750701f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -6,7 +6,6 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.annotation.ColorRes; import android.support.annotation.Nullable; -import android.support.v4.content.ContextCompat; import android.view.View; import net.osmand.plus.OsmandSettings; @@ -122,7 +121,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia BaseBottomSheetItem formatItem = new BottomSheetItemWithCompoundButton.Builder() .setChecked(selectedItem) .setButtonTintList(selectedItem - ? ColorStateList.valueOf(ContextCompat.getColor(context, getActiveColorId())) + ? ColorStateList.valueOf(getResolvedColor(getActiveColorId())) : null) .setIcon(selectedItem ? getActiveIcon(R.drawable.ic_action_coordinates_latitude) : formatIcon) .setTitle(CoordinateInputFormats.formatToHumanString(context, format)) diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java index 3db8c6040b..eea40c96be 100644 --- a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingTypeBottomSheetDialogFragment.java @@ -4,7 +4,6 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; -import net.osmand.data.LatLon; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -23,6 +22,7 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF @Override public void createMenuItems(Bundle savedInstanceState) { items.add(new TitleItem(getString(R.string.parking_options))); + BaseBottomSheetItem byTypeItem = new SimpleBottomSheetItem.Builder() .setIcon(getContentIcon(R.drawable.ic_action_time_start)) .setTitle(getString(R.string.osmand_parking_no_lim_text)) @@ -47,17 +47,18 @@ public class ParkingTypeBottomSheetDialogFragment extends MenuBottomSheetDialogF } }) .create(); + items.add(byDateItem); } private void addParkingPosition(boolean limited) { - Bundle args = getArguments(); - double latitude = args.getDouble(LAT_KEY); - double longitude = args.getDouble(LON_KEY); ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class); - MapActivity mapActivity = (MapActivity) getActivity(); - if (plugin != null) { + MapActivity mapActivity = (MapActivity) getActivity(); + Bundle args = getArguments(); + double latitude = args.getDouble(LAT_KEY); + double longitude = args.getDouble(LON_KEY); + if (plugin.isParkingEventAdded()) { plugin.showDeleteEventWarning(mapActivity); } From edbe29f4fb877a36351fa9402fc34a01a7653cb8 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Thu, 15 Mar 2018 11:38:26 +0300 Subject: [PATCH 2/8] Fix --- OsmAnd/res/values/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 8bc71187b8..a7e04b428f 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -3761,6 +3761,6 @@ Name of the river rapids - Shop's delivery point + Shop‘s delivery point From 691cce558f66552a8c158f41f69f9c0557be0557 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Thu, 15 Mar 2018 11:40:39 +0300 Subject: [PATCH 3/8] Fix --- OsmAnd/res/values/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index a7e04b428f..cad629e26e 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -3761,6 +3761,6 @@ Name of the river rapids - Shop‘s delivery point + Shop delivery point From f906b3441aee2bac26107dbb714691a57357adbf Mon Sep 17 00:00:00 2001 From: xmd5a Date: Thu, 15 Mar 2018 11:51:01 +0300 Subject: [PATCH 4/8] Fix --- OsmAnd/res/values/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index cad629e26e..2a9d4217de 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -3761,6 +3761,6 @@ Name of the river rapids - Shop delivery point + Shop\'s delivery point From f16f1a3ac8278db68f05b9f0bc3372c46a23efd8 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 11:26:31 +0200 Subject: [PATCH 5/8] Add second button to BottomSheetMenu bottom row --- OsmAnd/res/layout/bottom_sheet_menu_base.xml | 70 ++++++++++++++----- .../ItemMenuBottomSheetDialogFragment.java | 2 +- .../base/MenuBottomSheetDialogFragment.java | 22 +++--- .../AddWaypointBottomSheetDialogFragment.java | 4 +- .../plus/helpers/WaypointDialogHelper.java | 2 +- ...rdinateInputBottomSheetDialogFragment.java | 2 +- ...ryMarkerMenuBottomSheetDialogFragment.java | 2 +- .../OrderByBottomSheetDialogFragment.java | 2 +- ...RouteOptionsBottomSheetDialogFragment.java | 2 +- ...MarkersGroupBottomSheetDialogFragment.java | 2 +- .../OptionsBottomSheetDialogFragment.java | 2 +- ...electedPointBottomSheetDialogFragment.java | 4 +- ...mEditOptionsBottomSheetDialogFragment.java | 2 +- 13 files changed, 78 insertions(+), 40 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_menu_base.xml b/OsmAnd/res/layout/bottom_sheet_menu_base.xml index 8a575be9ee..6763bb50a6 100644 --- a/OsmAnd/res/layout/bottom_sheet_menu_base.xml +++ b/OsmAnd/res/layout/bottom_sheet_menu_base.xml @@ -1,6 +1,7 @@ - + android:layout_height="@dimen/bottom_sheet_cancel_button_height"> - + - + + + + + + + + + + + + + diff --git a/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java index 26014c4cb7..35bec8bcb0 100644 --- a/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/audionotes/ItemMenuBottomSheetDialogFragment.java @@ -127,7 +127,7 @@ public class ItemMenuBottomSheetDialogFragment extends MenuBottomSheetDialogFrag } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index f9460560e4..6be0eb1d49 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -68,18 +68,18 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra item.inflate(app, itemsContainer, nightMode); } - int closeRowDividerColorId = getCloseRowDividerColorId(); - if (closeRowDividerColorId != -1) { - mainView.findViewById(R.id.close_row_divider).setBackgroundColor(getResolvedColor(closeRowDividerColorId)); + int bottomDividerColorId = getBottomDividerColorId(); + if (bottomDividerColorId != -1) { + mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId)); } - mainView.findViewById(R.id.close_row).setOnClickListener(new View.OnClickListener() { + mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - onCloseRowClickAction(); + onDismissButtonClickAction(); dismiss(); } }); - ((TextView) mainView.findViewById(R.id.close_row_text)).setText(getCloseRowTextId()); + ((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId()); setupHeightAndBackground(mainView); @@ -140,8 +140,8 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra final View scrollView = mainView.findViewById(R.id.scroll_view); int scrollViewHeight = scrollView.getHeight(); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); - int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); - int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; + int bottomRowHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); + int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - bottomRowHeight; if (scrollViewHeight > spaceForScrollView) { scrollView.getLayoutParams().height = spaceForScrollView; scrollView.requestLayout(); @@ -166,16 +166,16 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra } @ColorRes - protected int getCloseRowDividerColorId() { + protected int getBottomDividerColorId() { return -1; } @StringRes - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_cancel; } - protected void onCloseRowClickAction() { + protected void onDismissButtonClickAction() { } diff --git a/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java index 6d09efcfab..771f673ee5 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/AddWaypointBottomSheetDialogFragment.java @@ -75,7 +75,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF .create(); items.add(replaceStartItem); - items.add(new DividerHalfItem(getContext(), getCloseRowDividerColorId())); + items.add(new DividerHalfItem(getContext(), getBottomDividerColorId())); BaseBottomSheetItem subsequentDestItem = new BottomSheetItemWithDescription.Builder() .setDescription(getString(R.string.subsequent_dest_description)) @@ -135,7 +135,7 @@ public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogF } @Override - protected int getCloseRowDividerColorId() { + protected int getBottomDividerColorId() { return nightMode ? R.color.route_info_bottom_view_bg_dark : -1; } diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index eada4a31e7..d0fdd7a19d 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -1068,7 +1068,7 @@ public class WaypointDialogHelper { } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 942750701f..4cc678cfe2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -141,7 +141,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java index 798729d301..01a7ac5d8f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java @@ -92,7 +92,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends MenuBottomSheetD } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java index 7b786261ca..7239b76fcc 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java @@ -116,7 +116,7 @@ public class OrderByBottomSheetDialogFragment extends MenuBottomSheetDialogFragm } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java index 2386569c32..943f998302 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java @@ -121,7 +121,7 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends MenuBottomSheetDi } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java index 2d6923d8d3..f0ad5db9e6 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectionMarkersGroupBottomSheetDialogFragment.java @@ -60,7 +60,7 @@ public class SelectionMarkersGroupBottomSheetDialogFragment extends MenuBottomSh } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java index c171c60f85..7bdba8dbf6 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java @@ -124,7 +124,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java index 893dc62845..77b1a3f42d 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java @@ -130,12 +130,12 @@ public class SelectedPointBottomSheetDialogFragment extends MenuBottomSheetDialo } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } @Override - protected void onCloseRowClickAction() { + protected void onDismissButtonClickAction() { if (listener != null) { listener.onClearSelection(); } diff --git a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java index d95f9e540f..9c1d396ca5 100644 --- a/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/osmedit/OsmEditOptionsBottomSheetDialogFragment.java @@ -119,7 +119,7 @@ public class OsmEditOptionsBottomSheetDialogFragment extends MenuBottomSheetDial } @Override - protected int getCloseRowTextId() { + protected int getDismissButtonTextId() { return R.string.shared_string_close; } From fd43a3c59e5c57db9a583a42cc4b9485ff65ecc9 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 11:56:47 +0200 Subject: [PATCH 6/8] Add ability to using non-scrollable container for BottomSheetMenu items --- OsmAnd/res/layout/bottom_sheet_menu_base.xml | 9 +++++- .../base/MenuBottomSheetDialogFragment.java | 29 ++++++++++++------- .../AddGroupBottomSheetDialogFragment.java | 5 ++++ 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/OsmAnd/res/layout/bottom_sheet_menu_base.xml b/OsmAnd/res/layout/bottom_sheet_menu_base.xml index 6763bb50a6..7e98ba5ca1 100644 --- a/OsmAnd/res/layout/bottom_sheet_menu_base.xml +++ b/OsmAnd/res/layout/bottom_sheet_menu_base.xml @@ -14,7 +14,7 @@ android:layout_height="wrap_content"> + + spaceForScrollView) { - scrollView.getLayoutParams().height = spaceForScrollView; - scrollView.requestLayout(); + final View viewToAdjust = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer; + if (viewToAdjust.getHeight() > availableHeight) { + viewToAdjust.getLayoutParams().height = availableHeight; + viewToAdjust.requestLayout(); } // 8dp is the shadow height @@ -165,6 +170,10 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra }); } + protected boolean useScrollableItemsContainer() { + return true; + } + @ColorRes protected int getBottomDividerColorId() { return -1; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java index 6dc530bef5..2c37c532c2 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/AddGroupBottomSheetDialogFragment.java @@ -77,6 +77,11 @@ public abstract class AddGroupBottomSheetDialogFragment extends MenuBottomSheetD super.onDestroyView(); } + @Override + protected boolean useScrollableItemsContainer() { + return false; + } + private void showProgressBar() { mainView.findViewById(R.id.groups_recycler_view).setVisibility(View.GONE); mainView.findViewById(R.id.progress_bar).setVisibility(View.VISIBLE); From 3a7d6a9626f37b59af013ccceb049a8027dfd91f Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 12:15:53 +0200 Subject: [PATCH 7/8] Add methods for setup the right bottom button in MenuBottomSheetDialogFragment --- .../base/MenuBottomSheetDialogFragment.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java index 327eaadf24..a80d28f5a7 100644 --- a/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/base/MenuBottomSheetDialogFragment.java @@ -78,6 +78,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra if (bottomDividerColorId != -1) { mainView.findViewById(R.id.bottom_row_divider).setBackgroundColor(getResolvedColor(bottomDividerColorId)); } + mainView.findViewById(R.id.dismiss_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -87,6 +88,24 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra }); ((TextView) mainView.findViewById(R.id.dismiss_button_text)).setText(getDismissButtonTextId()); + int rightBottomButtonTextId = getRightBottomButtonTextId(); + if (rightBottomButtonTextId != -1) { + View buttonsDivider = mainView.findViewById(R.id.bottom_buttons_divider); + buttonsDivider.setVisibility(View.VISIBLE); + if (bottomDividerColorId != -1) { + buttonsDivider.setBackgroundColor(getResolvedColor(bottomDividerColorId)); + } + View rightButton = mainView.findViewById(R.id.right_bottom_button); + rightButton.setVisibility(View.VISIBLE); + rightButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onRightBottomButtonClick(); + } + }); + ((TextView) rightButton.findViewById(R.id.right_bottom_button_text)).setText(rightBottomButtonTextId); + } + setupHeightAndBackground(mainView); return mainView; @@ -188,6 +207,15 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra } + @StringRes + protected int getRightBottomButtonTextId() { + return -1; + } + + protected void onRightBottomButtonClick() { + + } + @ColorRes protected int getBgColorId() { return nightMode ? R.color.bg_color_dark : R.color.bg_color_light; From 5424a03ff43c29e99b6654c6dad07469804e8273 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 15:26:11 +0200 Subject: [PATCH 8/8] Fix ConcurrentModificationException --- OsmAnd/src/net/osmand/plus/MapMarkersHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index 2ae81bed21..7feafe89d3 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -939,7 +939,7 @@ public class MapMarkersHelper { } private void updateSyncGroupDisabled(@NonNull MapMarkersGroup group, boolean disabled) { - List groupMarkers = group.getMarkers(); + List groupMarkers = new ArrayList<>(group.getMarkers()); for (MapMarker marker : groupMarkers) { if (marker.history) { if (disabled) {