Small UI fixes

This commit is contained in:
Alexey Kulish 2015-09-11 11:06:04 +03:00
parent 10ad01882b
commit 34c284cab4
4 changed files with 27 additions and 13 deletions

View file

@ -30,6 +30,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/context_menu_top_shadow_all"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_map_context_menu" android:background="?attr/bg_map_context_menu"

View file

@ -5,6 +5,8 @@ import android.app.Activity;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
@ -30,6 +32,8 @@ import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import static android.util.TypedValue.COMPLEX_UNIT_DIP; import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.sections.MenuBuilder.SHADOW_HEIGHT_BOTTOM_DP;
import static net.osmand.plus.mapcontextmenu.sections.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
public class MapContextMenuFragment extends Fragment { public class MapContextMenuFragment extends Fragment {
@ -144,7 +148,7 @@ public class MapContextMenuFragment extends Fragment {
mainView = view.findViewById(R.id.context_menu_main); mainView = view.findViewById(R.id.context_menu_main);
View.OnTouchListener slideTouchListener = new View.OnTouchListener() { final View.OnTouchListener slideTouchListener = new View.OnTouchListener() {
private float dy; private float dy;
private float dyMain; private float dyMain;
private int destinationState; private int destinationState;
@ -162,7 +166,7 @@ public class MapContextMenuFragment extends Fragment {
private boolean isClick(float endX, float endY) { private boolean isClick(float endX, float endY) {
float differenceX = Math.abs(startX - endX); float differenceX = Math.abs(startX - endX);
float differenceY = Math.abs(startY - endY); float differenceY = Math.abs(startY - endY);
if (differenceX > 3 || differenceY > 3 || System.currentTimeMillis() - lastTouchDown > CLICK_ACTION_THRESHHOLD) { if (differenceX > 1 || differenceY > 1 || System.currentTimeMillis() - lastTouchDown > CLICK_ACTION_THRESHHOLD) {
return false; return false;
} }
return true; return true;
@ -227,13 +231,13 @@ public class MapContextMenuFragment extends Fragment {
float posY = 0; float posY = 0;
switch (destinationState) { switch (destinationState) {
case MenuController.MenuState.HEADER_ONLY: case MenuController.MenuState.HEADER_ONLY:
posY = view.getHeight() - (menuFullHeight - menuBottomViewHeight); posY = view.getHeight() - (menuFullHeight - menuBottomViewHeight - dpToPx(SHADOW_HEIGHT_BOTTOM_DP));
break; break;
case MenuController.MenuState.HALF_SCREEN: case MenuController.MenuState.HALF_SCREEN:
posY = view.getHeight() - menuFullHeight; posY = view.getHeight() - menuFullHeight;
break; break;
case MenuController.MenuState.FULL_SCREEN: case MenuController.MenuState.FULL_SCREEN:
posY = -menuTopShadowHeight; posY = -menuTopShadowHeight - dpToPx(SHADOW_HEIGHT_TOP_DP);
break; break;
default: default:
break; break;
@ -270,6 +274,16 @@ public class MapContextMenuFragment extends Fragment {
topView.setOnTouchListener(slideTouchListener); topView.setOnTouchListener(slideTouchListener);
View topShadowView = view.findViewById(R.id.context_menu_top_shadow); View topShadowView = view.findViewById(R.id.context_menu_top_shadow);
topShadowView.setOnTouchListener(slideTouchListener); 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 // Left icon
IconsCache iconsCache = getMyApplication().getIconsCache(); IconsCache iconsCache = getMyApplication().getIconsCache();
@ -375,7 +389,7 @@ public class MapContextMenuFragment extends Fragment {
switch (menuState) { switch (menuState) {
case MenuController.MenuState.HEADER_ONLY: case MenuController.MenuState.HEADER_ONLY:
shadowViewHeight = view.getHeight() - (menuFullHeight - menuBottomViewHeight); shadowViewHeight = view.getHeight() - (menuFullHeight - menuBottomViewHeight) + dpToPx(SHADOW_HEIGHT_BOTTOM_DP);
bottomBorderHeight = 0; bottomBorderHeight = 0;
break; break;
case MenuController.MenuState.HALF_SCREEN: case MenuController.MenuState.HALF_SCREEN:
@ -391,7 +405,7 @@ public class MapContextMenuFragment extends Fragment {
break; break;
case MenuController.MenuState.FULL_SCREEN: case MenuController.MenuState.FULL_SCREEN:
shadowViewHeight = 0; shadowViewHeight = 0;
bottomBorderHeight = view.getHeight() - menuFullHeight + menuTopShadowHeight; bottomBorderHeight = view.getHeight() - menuFullHeight + menuTopShadowHeight + dpToPx(SHADOW_HEIGHT_TOP_DP);
break; break;
default: default:
break; break;
@ -410,8 +424,6 @@ public class MapContextMenuFragment extends Fragment {
lp.height = menuFullHeight; lp.height = menuFullHeight;
mainView.setLayoutParams(lp); mainView.setLayoutParams(lp);
mainView.bringToFront();
} }
public void dismissMenu() { public void dismissMenu() {

View file

@ -24,8 +24,6 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
public class AmenityInfoMenuBuilder extends MenuBuilder { public class AmenityInfoMenuBuilder extends MenuBuilder {
private static final float SHADOW_HEIGHT = 6f; // in dp
private final Amenity amenity; private final Amenity amenity;
public AmenityInfoMenuBuilder(OsmandApplication app, final Amenity amenity) { public AmenityInfoMenuBuilder(OsmandApplication app, final Amenity amenity) {
@ -45,13 +43,13 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
// Icon // Icon
LinearLayout llIcon = new LinearLayout(view.getContext()); LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL); 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); llIcon.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIcon); ll.addView(llIcon);
ImageView icon = new ImageView(view.getContext()); ImageView icon = new ImageView(view.getContext());
LinearLayout.LayoutParams llIconParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) ; 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; llIconParams.gravity = Gravity.CENTER_VERTICAL;
icon.setLayoutParams(llIconParams); icon.setLayoutParams(llIconParams);
icon.setScaleType(ImageView.ScaleType.CENTER); icon.setScaleType(ImageView.ScaleType.CENTER);
@ -65,7 +63,7 @@ public class AmenityInfoMenuBuilder extends MenuBuilder {
TextView textView = new TextView(view.getContext()); TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); 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.setLayoutParams(llTextParams);
textView.setTextSize(16); // todo: create constant 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)); textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));

View file

@ -9,6 +9,9 @@ import net.osmand.plus.R;
public abstract class MenuBuilder { 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; protected OsmandApplication app;
public MenuBuilder(OsmandApplication app) { public MenuBuilder(OsmandApplication app) {