From 7a98b5304da8448a982942f1f2b643c5f3292314 Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Thu, 15 Mar 2018 10:02:00 +0200 Subject: [PATCH] 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); }