From 34c284cab490537d4bcb1be13e72ad0eb95e57d4 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 11 Sep 2015 11:06:04 +0300 Subject: [PATCH] Small UI fixes --- .../res/layout/map_context_menu_fragment.xml | 1 + .../MapContextMenuFragment.java | 28 +++++++++++++------ .../sections/AmenityInfoMenuBuilder.java | 8 ++---- .../mapcontextmenu/sections/MenuBuilder.java | 3 ++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index e3d7f07cea..2f83828f9f 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -30,6 +30,7 @@ 3 || differenceY > 3 || System.currentTimeMillis() - lastTouchDown > CLICK_ACTION_THRESHHOLD) { + if (differenceX > 1 || differenceY > 1 || System.currentTimeMillis() - lastTouchDown > CLICK_ACTION_THRESHHOLD) { return false; } return true; @@ -227,13 +231,13 @@ public class MapContextMenuFragment extends Fragment { float posY = 0; switch (destinationState) { case MenuController.MenuState.HEADER_ONLY: - posY = view.getHeight() - (menuFullHeight - menuBottomViewHeight); + posY = view.getHeight() - (menuFullHeight - menuBottomViewHeight - dpToPx(SHADOW_HEIGHT_BOTTOM_DP)); break; case MenuController.MenuState.HALF_SCREEN: posY = view.getHeight() - menuFullHeight; break; case MenuController.MenuState.FULL_SCREEN: - posY = -menuTopShadowHeight; + posY = -menuTopShadowHeight - dpToPx(SHADOW_HEIGHT_TOP_DP); break; default: break; @@ -270,6 +274,16 @@ public class MapContextMenuFragment extends Fragment { topView.setOnTouchListener(slideTouchListener); View topShadowView = view.findViewById(R.id.context_menu_top_shadow); topShadowView.setOnTouchListener(slideTouchListener); + View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all); + topShadowAllView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getY() <= dpToPx(SHADOW_HEIGHT_TOP_DP) || event.getAction() != MotionEvent.ACTION_DOWN) + return slideTouchListener.onTouch(v, event); + else + return false; + } + }); // Left icon IconsCache iconsCache = getMyApplication().getIconsCache(); @@ -375,7 +389,7 @@ public class MapContextMenuFragment extends Fragment { switch (menuState) { case MenuController.MenuState.HEADER_ONLY: - shadowViewHeight = view.getHeight() - (menuFullHeight - menuBottomViewHeight); + shadowViewHeight = view.getHeight() - (menuFullHeight - menuBottomViewHeight) + dpToPx(SHADOW_HEIGHT_BOTTOM_DP); bottomBorderHeight = 0; break; case MenuController.MenuState.HALF_SCREEN: @@ -391,7 +405,7 @@ public class MapContextMenuFragment extends Fragment { break; case MenuController.MenuState.FULL_SCREEN: shadowViewHeight = 0; - bottomBorderHeight = view.getHeight() - menuFullHeight + menuTopShadowHeight; + bottomBorderHeight = view.getHeight() - menuFullHeight + menuTopShadowHeight + dpToPx(SHADOW_HEIGHT_TOP_DP); break; default: break; @@ -410,8 +424,6 @@ public class MapContextMenuFragment extends Fragment { lp.height = menuFullHeight; mainView.setLayoutParams(lp); - mainView.bringToFront(); - } public void dismissMenu() { diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java index cf5d90571f..01a776972d 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java @@ -24,8 +24,6 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP; public class AmenityInfoMenuBuilder extends MenuBuilder { - private static final float SHADOW_HEIGHT = 6f; // in dp - private final Amenity amenity; public AmenityInfoMenuBuilder(OsmandApplication app, final Amenity amenity) { @@ -45,13 +43,13 @@ public class AmenityInfoMenuBuilder extends MenuBuilder { // Icon LinearLayout llIcon = new LinearLayout(view.getContext()); llIcon.setOrientation(LinearLayout.HORIZONTAL); - llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), firstRow ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT) : dpToPx(48f))); + llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), firstRow ? dpToPx(48f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(48f))); llIcon.setGravity(Gravity.CENTER_VERTICAL); ll.addView(llIcon); ImageView icon = new ImageView(view.getContext()); LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) ; - llIconParams.setMargins(dpToPx(16f), firstRow ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f)); + llIconParams.setMargins(dpToPx(16f), firstRow ? dpToPx(12f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP / 2f) : dpToPx(12f), dpToPx(32f), dpToPx(12f)); llIconParams.gravity = Gravity.CENTER_VERTICAL; icon.setLayoutParams(llIconParams); icon.setScaleType(ImageView.ScaleType.CENTER); @@ -65,7 +63,7 @@ public class AmenityInfoMenuBuilder extends MenuBuilder { TextView textView = new TextView(view.getContext()); LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - llTextParams.setMargins(0, firstRow ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT) : dpToPx(8f), 0, dpToPx(8f)); + llTextParams.setMargins(0, firstRow ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f)); textView.setLayoutParams(llTextParams); textView.setTextSize(16); // todo: create constant textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark)); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java index 55211d041c..a219c0db22 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java @@ -9,6 +9,9 @@ import net.osmand.plus.R; public abstract class MenuBuilder { + public static final float SHADOW_HEIGHT_TOP_DP = 16f; + public static final float SHADOW_HEIGHT_BOTTOM_DP = 6f; + protected OsmandApplication app; public MenuBuilder(OsmandApplication app) {