diff --git a/OsmAnd/res/color/bottom_navigation_color_selector.xml b/OsmAnd/res/drawable/bottom_navigation_color_selector.xml similarity index 100% rename from OsmAnd/res/color/bottom_navigation_color_selector.xml rename to OsmAnd/res/drawable/bottom_navigation_color_selector.xml diff --git a/OsmAnd/res/layout-land/fragment_measurement_tool.xml b/OsmAnd/res/layout-land/fragment_measurement_tool.xml index 9dd92bdcca..88782a4fb5 100644 --- a/OsmAnd/res/layout-land/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout-land/fragment_measurement_tool.xml @@ -46,10 +46,10 @@ android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_content_margin" - android:layout_marginLeft="@dimen/measurement_tool_content_margin" - android:layout_marginRight="@dimen/measurement_tool_content_margin" - android:layout_marginStart="@dimen/measurement_tool_content_margin" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:layout_marginStart="@dimen/bottom_sheet_content_margin" android:background="@null" tools:src="@drawable/ic_action_ruler"/> @@ -60,10 +60,10 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_content_margin" - android:layout_marginLeft="@dimen/measurement_tool_content_margin" - android:layout_marginRight="@dimen/measurement_tool_content_margin" - android:layout_marginStart="@dimen/measurement_tool_content_margin" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:layout_marginStart="@dimen/bottom_sheet_content_margin" android:background="@null" tools:src="@drawable/ic_action_arrow_down"/> diff --git a/OsmAnd/res/layout/close_measurement_tool_dialog.xml b/OsmAnd/res/layout/close_measurement_tool_dialog.xml index 6485e8582f..e1c823056a 100644 --- a/OsmAnd/res/layout/close_measurement_tool_dialog.xml +++ b/OsmAnd/res/layout/close_measurement_tool_dialog.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" - android:padding="@dimen/measurement_tool_content_padding"> + android:padding="@dimen/bottom_sheet_content_padding"> + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginStart="@dimen/bottom_sheet_content_margin"/> \ No newline at end of file diff --git a/OsmAnd/res/layout/fragment_map_markers_dialog.xml b/OsmAnd/res/layout/fragment_map_markers_dialog.xml index 00e5f1ba8d..05173d51a0 100644 --- a/OsmAnd/res/layout/fragment_map_markers_dialog.xml +++ b/OsmAnd/res/layout/fragment_map_markers_dialog.xml @@ -74,7 +74,7 @@ android:layout_height="wrap_content" android:background="?attr/bg_color" app:itemBackground="?attr/bg_color" - app:itemIconTint="@color/bottom_navigation_color_selector" - app:itemTextColor="@color/bottom_navigation_color_selector" + app:itemIconTint="@drawable/bottom_navigation_color_selector" + app:itemTextColor="@drawable/bottom_navigation_color_selector" app:menu="@menu/map_markers_bottom_navigation"/> diff --git a/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml index e77703ddfc..88ae0b8cc1 100644 --- a/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml @@ -21,12 +21,12 @@ @@ -34,21 +34,21 @@ + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/fragment_measurement_tool.xml b/OsmAnd/res/layout/fragment_measurement_tool.xml index 57ddf558b8..6b5a3da674 100644 --- a/OsmAnd/res/layout/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout/fragment_measurement_tool.xml @@ -41,10 +41,10 @@ android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_content_margin" - android:layout_marginLeft="@dimen/measurement_tool_content_margin" - android:layout_marginRight="@dimen/measurement_tool_content_margin" - android:layout_marginStart="@dimen/measurement_tool_content_margin" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:layout_marginStart="@dimen/bottom_sheet_content_margin" android:background="@null" tools:src="@drawable/ic_action_ruler"/> @@ -55,10 +55,10 @@ android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_content_margin" - android:layout_marginLeft="@dimen/measurement_tool_content_margin" - android:layout_marginRight="@dimen/measurement_tool_content_margin" - android:layout_marginStart="@dimen/measurement_tool_content_margin" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:layout_marginStart="@dimen/bottom_sheet_content_margin" android:background="@null" tools:src="@drawable/ic_action_arrow_down"/> diff --git a/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml index ed0730b8d2..4e1a338a84 100644 --- a/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_options_bottom_sheet_dialog.xml @@ -22,12 +22,12 @@ @@ -35,21 +35,21 @@ + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> @@ -46,16 +46,16 @@ android:id="@+id/images_row" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" + android:layout_marginBottom="@dimen/bottom_sheet_content_margin" android:orientation="horizontal"> @@ -84,10 +84,10 @@ @@ -118,21 +118,21 @@ + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> @@ -50,7 +50,7 @@ + android:minHeight="@dimen/bottom_sheet_list_item_height" + android:paddingEnd="@dimen/bottom_sheet_content_padding" + android:paddingLeft="@dimen/bottom_sheet_content_padding" + android:paddingRight="@dimen/bottom_sheet_content_padding" + android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:padding="@dimen/bottom_sheet_content_padding"> + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginStart="@dimen/bottom_sheet_content_margin"/> 90dp 96dp - 72dp + 72dp 540dp 30dp - 24dp - 12dp - 24dp - 12dp + 24dp + 12dp + 24dp + 12dp 12dp 18dp 6dp @@ -113,14 +113,14 @@ 12dp 12dp 54dp - 78dp - 66dp - 72dp - 36dp + 78dp + 66dp + 72dp + 36dp 11dp 12dp 96dp - 15dp + 15dp 84dp \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index aed0718f34..9ca00d5e8c 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -156,14 +156,14 @@ 60dp 64dp - 48dp + 48dp 360dp 20dp - 16dp - 8dp - 16dp - 8dp + 16dp + 8dp + 16dp + 8dp 8dp 12dp 4dp @@ -178,13 +178,13 @@ 8dp 8dp 36dp - 52dp - 44dp - 48dp - 24dp + 52dp + 44dp + 48dp + 24dp 7dp 8dp 64dp - 10dp + 10dp 56dp \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 7565a99cb9..0de4778165 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Widget + Top bar Move all to history Build route Show direction diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index 3b2fb3d96d..969ea3b641 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -141,7 +141,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL adapter.setUseCenter(useCenter); adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude())); - adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading); + adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99); adapter.notifyDataSetChanged(); } }); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 99c05a9550..24cdfac25b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -106,6 +106,9 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm private MarkerOptionsFragmentListener createMarkerOptionsFragmentListener() { return new MarkerOptionsFragmentListener() { + + final MapActivity mapActivity = getMapActivity(); + @Override public void sortByOnClick() { Toast.makeText(getContext(), "Sort by", Toast.LENGTH_SHORT).show(); @@ -113,7 +116,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm @Override public void showDirectionOnClick() { - Toast.makeText(getContext(), "Show direction", Toast.LENGTH_SHORT).show(); + openShowDirectionMenu(mapActivity); } @Override @@ -133,6 +136,14 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm }; } + private void openShowDirectionMenu(MapActivity mapActivity) { + ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment(); + fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG); + } + + private MapActivity getMapActivity() { + return (MapActivity) getActivity(); + } public static boolean showInstance(@NonNull MapActivity mapActivity) { try { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java index 2bcf3d1325..5df7fc263f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerOptionsBottomSheetDialogFragment.java @@ -3,6 +3,7 @@ package net.osmand.plus.mapmarkers; import android.os.Build; import android.os.Bundle; import android.support.annotation.Nullable; +import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -32,10 +33,12 @@ public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFra @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); + boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); + final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; - final View mainView = inflater.inflate(R.layout.fragment_marker_options_bottom_sheet_dialog, container); + final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, container); if (portrait) { - AndroidUtils.setBackground(getActivity(), mainView, false, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); + AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); } ((ImageView) mainView.findViewById(R.id.sort_by_icon)) @@ -113,7 +116,7 @@ public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFra final View scrollView = mainView.findViewById(R.id.marker_options_scroll_view); int scrollViewHeight = scrollView.getHeight(); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); - int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); + int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; if (scrollViewHeight > spaceForScrollView) { scrollView.getLayoutParams().height = spaceForScrollView; diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java new file mode 100644 index 0000000000..9a6407944b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java @@ -0,0 +1,149 @@ +package net.osmand.plus.mapmarkers; + +import android.os.Build; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; +import android.widget.TextView; + +import net.osmand.AndroidUtils; +import net.osmand.plus.R; +import net.osmand.plus.base.BottomSheetDialogFragment; +import net.osmand.plus.helpers.AndroidUiHelper; + +public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFragment { + + public final static String TAG = "ShowDirectionBottomSheetDialogFragment"; + + private ShowDirectionFragmentListener listener; + private boolean portrait; + + public void setListener(ShowDirectionFragmentListener listener) { + this.listener = listener; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); + boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls(); + final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + + final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container); + if (portrait) { + AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); + } + + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + mainView.findViewById(R.id.images_row).setVisibility(View.GONE); + } else { + ImageView topBarImage = (ImageView) mainView.findViewById(R.id.top_bar_image); + ImageView widgetImage = (ImageView) mainView.findViewById(R.id.widget_image); + if (nightMode) { + topBarImage.setImageResource(R.drawable.img_help_markers_topbar_night); + widgetImage.setImageResource(R.drawable.img_help_markers_widgets_night); + } else { + topBarImage.setImageResource(R.drawable.img_help_markers_topbar_day); + widgetImage.setImageResource(R.drawable.img_help_markers_widgets_day); + } + + mainView.findViewById(R.id.top_bar_text).setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + return false; + } + }); + + mainView.findViewById(R.id.widget_text).setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + return false; + } + }); + } + + if (nightMode) { + ((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark)); + } + + ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon); + topBarIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color)); + topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue)); + + ImageView widgetIcon = (ImageView) mainView.findViewById(R.id.widget_icon); + widgetIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color)); + widgetIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_widget, R.color.dashboard_blue)); + + ImageView noneIcon = (ImageView) mainView.findViewById(R.id.none_icon); + noneIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color)); + + mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + } + }); + + final int screenHeight = AndroidUtils.getScreenHeight(getActivity()); + final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity()); + final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity()); + + mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + final View scrollView = mainView.findViewById(R.id.marker_show_direction_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; + if (scrollViewHeight > spaceForScrollView) { + scrollView.getLayoutParams().height = spaceForScrollView; + scrollView.requestLayout(); + } + + if (!portrait) { + if (screenHeight - statusBarHeight - mainView.getHeight() + >= AndroidUtils.dpToPx(getActivity(), 8)) { + AndroidUtils.setBackground(getActivity(), mainView, false, + R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); + } else { + AndroidUtils.setBackground(getActivity(), mainView, false, + R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark); + } + } + + ViewTreeObserver obs = mainView.getViewTreeObserver(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + obs.removeOnGlobalLayoutListener(this); + } else { + obs.removeGlobalOnLayoutListener(this); + } + } + }); + + return mainView; + } + + @Override + public void onStart() { + super.onStart(); + if (!portrait) { + final Window window = getDialog().getWindow(); + WindowManager.LayoutParams params = window.getAttributes(); + params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width); + window.setAttributes(params); + } + } + + interface ShowDirectionFragmentListener { + + } +} diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java index 63b68e4191..81bb38aac4 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/OptionsBottomSheetDialogFragment.java @@ -141,7 +141,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment final View scrollView = mainView.findViewById(R.id.measure_options_scroll_view); int scrollViewHeight = scrollView.getHeight(); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); - int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); + int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; if (scrollViewHeight > spaceForScrollView) { scrollView.getLayoutParams().height = spaceForScrollView; diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java index 568e083cbf..91e143c1eb 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SaveAsNewTrackBottomSheetDialogFragment.java @@ -102,7 +102,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr final View scrollView = mainView.findViewById(R.id.save_as_new_track_scroll_view); int scrollViewHeight = scrollView.getHeight(); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); - int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); + int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; if (scrollViewHeight > spaceForScrollView) { scrollView.getLayoutParams().height = spaceForScrollView; diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java index 595f701073..b196f1410c 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java @@ -167,7 +167,7 @@ public class SelectedPointBottomSheetDialogFragment extends BottomSheetDialogFra final View scrollView = mainView.findViewById(R.id.selected_point_options_scroll_view); int scrollViewHeight = scrollView.getHeight(); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); - int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); + int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height); int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; if (scrollViewHeight > spaceForScrollView) { scrollView.getLayoutParams().height = spaceForScrollView;