diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml
index 4e73daf26a..01473173a6 100644
--- a/OsmAnd/res/layout/map_context_menu_fragment.xml
+++ b/OsmAnd/res/layout/map_context_menu_fragment.xml
@@ -7,23 +7,17 @@
android:orientation="vertical">
-
-
-
-
+ android:layout_weight="0"
+ android:orientation="vertical"/>
@@ -113,8 +107,7 @@
android:id="@+id/context_menu_buttons"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="64dp"
- android:layout_gravity="bottom">
+ android:layout_height="54dp">
+ android:src="@drawable/ic_overflow_menu_white"/>
@@ -189,4 +182,13 @@
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
index 4b0d13c2f1..7a383cb693 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenu.java
@@ -12,6 +12,8 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.mapcontextmenu.sections.AmenityInfoMenuController;
+import net.osmand.plus.mapcontextmenu.sections.MenuController;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.OsmandMapLayer;
@@ -144,11 +146,11 @@ public class MapContextMenu {
return foundStreetName;
}
- public BottomSectionBuilder getBottomSectionBuilder() {
+ public MenuController getMenuController() {
if (object != null) {
if (object instanceof Amenity) {
- return new InfoSectionBuilder(app, (Amenity)object);
+ return new AmenityInfoMenuController(app, (Amenity)object);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
index 60858352bc..a75aab3e84 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java
@@ -2,13 +2,18 @@ package net.osmand.plus.mapcontextmenu;
import android.annotation.TargetApi;
import android.app.Activity;
+import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
+import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
@@ -19,9 +24,12 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.mapcontextmenu.sections.MenuController;
import org.apache.commons.logging.Log;
+import static android.util.TypedValue.COMPLEX_UNIT_DIP;
+
public class MapContextMenuFragment extends Fragment {
@@ -30,8 +38,16 @@ public class MapContextMenuFragment extends Fragment {
private View view;
private View mainView;
+ private View bottomView;
+ private View shadowView;
+ private View bottomBorder;
- private float mainViewHeight;
+ MenuController menuController;
+
+ private int menuTopHeight;
+ private int menuButtonsHeight;
+ private int menuBottomViewHeight;
+ private int menuFullHeight;
@Override
public void onAttach(Activity activity) {
@@ -74,7 +90,39 @@ public class MapContextMenuFragment extends Fragment {
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
- View shadowView = view.findViewById(R.id.context_menu_shadow_view);
+ ViewTreeObserver vto = view.getViewTreeObserver();
+ vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+
+ @Override
+ public void onGlobalLayout() {
+
+ menuTopHeight = view.findViewById(R.id.context_menu_top_view).getHeight();
+ menuButtonsHeight = view.findViewById(R.id.context_menu_buttons).getHeight();
+ menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
+ menuFullHeight = view.findViewById(R.id.context_menu_main).getHeight();
+
+ ViewTreeObserver obs = view.getViewTreeObserver();
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ obs.removeOnGlobalLayoutListener(this);
+ } else {
+ obs.removeGlobalOnLayoutListener(this);
+ }
+
+ doLayoutMenu();
+ }
+
+ });
+
+ bottomBorder = view.findViewById(R.id.context_menu_bottom_border);
+ bottomBorder.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ shadowView = view.findViewById(R.id.context_menu_shadow_view);
shadowView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent event) {
dismissMenu();
@@ -84,32 +132,103 @@ public class MapContextMenuFragment extends Fragment {
View topView = view.findViewById(R.id.context_menu_top_view);
mainView = view.findViewById(R.id.context_menu_main);
- //LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(400));
- //mainView.setLayoutParams(lp);
topView.setOnTouchListener(new View.OnTouchListener() {
private float dy;
+ private float dyMain;
+ private int destinationState;
+ private VelocityTracker velocity;
+ private boolean slidingUp;
+ private boolean slidingDown;
+
+ private float velocityY;
@Override
public boolean onTouch(View v, MotionEvent event) {
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
dy = event.getY();
- mainViewHeight = mainView.getHeight();
+ dyMain = mainView.getY();
+ velocity = VelocityTracker.obtain();
+ velocityY = 0;
+ velocity.addMovement(event);
break;
case MotionEvent.ACTION_MOVE:
float y = event.getY();
- mainView.setY(mainView.getY() + (y - dy));
+ float newY = mainView.getY() + (y - dy);
+ mainView.setY(newY);
+
+ ViewGroup.LayoutParams lp = bottomBorder.getLayoutParams();
+ lp.height = (int)(view.getHeight() - newY - menuFullHeight) + 10;
+ bottomBorder.setLayoutParams(lp);
+ bottomBorder.setY(newY + menuFullHeight);
+ bottomBorder.requestLayout();
+
+ velocity.addMovement(event);
+ velocity.computeCurrentVelocity(1000);
+ float vel = Math.abs(velocity.getYVelocity());
+ if (vel > velocityY)
+ velocityY = vel;
+
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
- float posY = view.getHeight() - mainViewHeight;
- if (mainView.getY() != posY)
+ slidingUp = Math.abs(velocityY) > 500 && (mainView.getY() - dyMain) < -50;
+ slidingDown = Math.abs(velocityY) > 500 && (mainView.getY() - dyMain) > 50;
+
+ velocity.recycle();
+
+ if (menuController != null) {
+ if (slidingUp) {
+ menuController.slideUp();
+ } else if (slidingDown) {
+ menuController.slideDown();
+ }
+ destinationState = menuController.getCurrentMenuState();
+ } else {
+ destinationState = MenuController.MenuState.HEADER_ONLY;
+ }
+
+ float posY = 0;
+ switch (destinationState) {
+ case MenuController.MenuState.HEADER_ONLY:
+ posY = view.getHeight() - (menuFullHeight - menuBottomViewHeight);
+ break;
+ case MenuController.MenuState.HALF_SCREEN:
+ posY = view.getHeight() - menuFullHeight;
+ break;
+ case MenuController.MenuState.FULL_SCREEN:
+ posY = 0;
+ break;
+ default:
+ break;
+ }
+
+ float minY = Math.min(posY, mainView.getY());
+ lp = bottomBorder.getLayoutParams();
+ lp.height = (int)(view.getHeight() - minY - menuFullHeight) + 10;
+ if (lp.height < 0)
+ lp.height = 0;
+ bottomBorder.setLayoutParams(lp);
+ bottomBorder.requestLayout();
+
+ if (mainView.getY() != posY) {
mainView.animate().y(posY).setDuration(200).setInterpolator(new DecelerateInterpolator()).start();
+ bottomBorder.animate().y(posY + menuFullHeight).setDuration(200).setInterpolator(new DecelerateInterpolator()).start();
+ }
+
+
+ /*
+ lp = shadowView.getLayoutParams();
+ lp.height = view.getHeight() - (int)posY;
+ shadowView.setLayoutParams(lp);
+ shadowView.requestLayout();
+ */
break;
@@ -148,7 +267,7 @@ public class MapContextMenuFragment extends Fragment {
closeButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- ((MapActivity)getActivity()).getMapLayers().getContextMenuLayer().hideMapContextMenuMarker();
+ ((MapActivity) getActivity()).getMapLayers().getContextMenuLayer().hideMapContextMenuMarker();
dismissMenu();
}
});
@@ -185,7 +304,7 @@ public class MapContextMenuFragment extends Fragment {
});
final ImageButton buttonMore = (ImageButton) view.findViewById(R.id.context_menu_more_button);
- buttonMore.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_core_overflow_dark,
+ buttonMore.setImageDrawable(iconsCache.getIcon(R.drawable.ic_overflow_menu_white,
light ? R.color.actionbar_dark_color : R.color.actionbar_light_color));
buttonMore.setOnClickListener(new View.OnClickListener() {
@Override
@@ -194,61 +313,71 @@ public class MapContextMenuFragment extends Fragment {
}
});
- // Bottom view
- BottomSectionBuilder bottomSectionBuilder = MapContextMenu.getInstance().getBottomSectionBuilder();
- if (bottomSectionBuilder != null) {
- View bottomView = view.findViewById(R.id.context_menu_bottom_view);
+ // Menu controller
+ menuController = MapContextMenu.getInstance().getMenuController();
+ bottomView = view.findViewById(R.id.context_menu_bottom_view);
+ if (menuController != null) {
bottomView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
- bottomSectionBuilder.buildSection(bottomView);
+ menuController.build(bottomView);
}
-
- /*
- Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
- toolbar.setTitle(R.string.poi_create_title);
- toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
- fragmentManager.beginTransaction().remove(MapContextMenuFragment.this).commit();
- fragmentManager.popBackStack();
- }
- });
-
- viewPager = (ViewPager) view.findViewById(R.id.viewpager);
- String basicTitle = getResources().getString(R.string.tab_title_basic);
- String extendedTitle = getResources().getString(R.string.tab_title_advanced);
- MyAdapter pagerAdapter = new MyAdapter(getChildFragmentManager(), basicTitle, extendedTitle);
- viewPager.setAdapter(pagerAdapter);
-
- final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tab_layout);
- tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
-
- // Hack due to bug in design support library v22.2.1
- // https://code.google.com/p/android/issues/detail?id=180462
- // TODO remove in new version
- if (ViewCompat.isLaidOut(tabLayout)) {
- tabLayout.setupWithViewPager(viewPager);
- } else {
- tabLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- tabLayout.setupWithViewPager(viewPager);
- tabLayout.removeOnLayoutChangeListener(this);
- }
- });
- }
- */
return view;
}
+ private void doLayoutMenu() {
+ int shadowViewHeight = 0;
+ int bottomBorderHeight = 0;
+
+ int menuState;
+ if (menuController != null)
+ menuState = menuController.getCurrentMenuState();
+ else
+ menuState = MenuController.MenuState.HEADER_ONLY;
+
+ switch (menuState) {
+ case MenuController.MenuState.HEADER_ONLY:
+ shadowViewHeight = view.getHeight() - (menuFullHeight - menuBottomViewHeight);
+ bottomBorderHeight = 0;
+ break;
+ case MenuController.MenuState.HALF_SCREEN:
+ int maxHeight = (int)(menuController.getHalfScreenMaxHeightKoef() * view.getHeight());
+ if (maxHeight > menuFullHeight) {
+ shadowViewHeight = view.getHeight() - menuFullHeight;
+ bottomBorderHeight = 0;
+ } else {
+ shadowViewHeight = view.getHeight() - maxHeight;
+ bottomBorderHeight = 0;
+ mainView.setY(shadowViewHeight);
+ }
+ break;
+ case MenuController.MenuState.FULL_SCREEN:
+ shadowViewHeight = 0;
+ bottomBorderHeight = view.getHeight() - menuFullHeight;
+ break;
+ default:
+ break;
+ }
+
+ ViewGroup.LayoutParams lp = bottomBorder.getLayoutParams();
+ lp.height = bottomBorderHeight + 10;
+ bottomBorder.setLayoutParams(lp);
+ bottomBorder.setY(view.getHeight() - bottomBorderHeight);
+
+ lp = shadowView.getLayoutParams();
+ lp.height = shadowViewHeight;
+ shadowView.setLayoutParams(lp);
+
+ lp = mainView.getLayoutParams();
+ lp.height = menuFullHeight;
+ mainView.setLayoutParams(lp);
+
+ }
+
public void dismissMenu() {
getActivity().getSupportFragmentManager().popBackStack();
}
@@ -267,5 +396,21 @@ public class MapContextMenuFragment extends Fragment {
.add(R.id.fragmentContainer, fragment, "MapContextMenuFragment")
.addToBackStack(null).commit();
}
+
+ // Utils
+ public int getScreenHeight() {
+ DisplayMetrics dm = new DisplayMetrics();
+ getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
+ return dm.heightPixels;
+ }
+
+ public int dpToPx(float dp) {
+ Resources r = getActivity().getResources();
+ return (int) TypedValue.applyDimension(
+ COMPLEX_UNIT_DIP,
+ dp,
+ r.getDisplayMetrics()
+ );
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java
similarity index 72%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java
index fe00e00794..1d83dc33ff 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/InfoSectionBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuBuilder.java
@@ -1,6 +1,7 @@
-package net.osmand.plus.mapcontextmenu;
+package net.osmand.plus.mapcontextmenu.sections;
import android.content.res.Resources;
+import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
@@ -20,32 +21,34 @@ import java.util.Map;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
-public class InfoSectionBuilder extends BottomSectionBuilder {
+public class AmenityInfoMenuBuilder extends MenuBuilder {
private final Amenity amenity;
- public InfoSectionBuilder(OsmandApplication app, final Amenity amenity) {
+ public AmenityInfoMenuBuilder(OsmandApplication app, final Amenity amenity) {
super(app);
this.amenity = amenity;
}
private void buildRow(View view, int iconId, String text) {
+ Resources.Theme theme = view.getContext().getTheme();
LinearLayout ll = new LinearLayout(view.getContext());
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) ;
- llParams.setMargins(0, dpToPx(10f), 0, dpToPx(10f));
+ //llParams.setMargins(0, dpToPx(14f), 0, dpToPx(14f));
ll.setLayoutParams(llParams);
// Icon
LinearLayout llIcon = new LinearLayout(view.getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
- llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(42f), ViewGroup.LayoutParams.MATCH_PARENT));
+ llIcon.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(72f), 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(12f), 0, 0, 0);
+ llIconParams.setMargins(dpToPx(16f), dpToPx(12f), dpToPx(32f), dpToPx(12f));
llIconParams.gravity = Gravity.CENTER_VERTICAL;
icon.setLayoutParams(llIconParams);
icon.setScaleType(ImageView.ScaleType.CENTER);
@@ -62,11 +65,23 @@ public class InfoSectionBuilder extends BottomSectionBuilder {
TextView textView = new TextView(view.getContext());
- LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- llTextViewParams.setMargins(dpToPx(10f), 0, dpToPx(10f), 0);
- llText.setLayoutParams(llTextViewParams);
+// TypedValue typedValueTextSize = new TypedValue();
+// theme.resolveAttribute(R.dimen.default_desc_text_size, typedValueTextSize, true);
+// int textSize = typedValueTextSize.data;
+ textView.setTextSize(14);
+
+// TypedValue typedValueTextColor = new TypedValue();
+// theme.resolveAttribute(android.R.attr.textColorSecondary, typedValueTextColor, true);
+// int textColor = typedValueTextColor.data;
+ //textView.setTextColor(textColor);
+
textView.setText(text);
//textView.setText("sdf dsaf fsdasdfg adsf asdsfd asdf sdf adsfg asdf sdfa sdf dsf agsfdgd fgsfd sdf asdf adg adf sdf asdf dfgdfsg sdfg adsf asdf asdf sdf SDF ASDF ADSF ASDF ASDF DAF SDAF dfg dsfg dfg sdfg rg rth sfghs dfgs dfgsdfg adfg dfg sdfg dfs ");
+
+ LinearLayout.LayoutParams llTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
+ llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
+ llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
+ llText.setLayoutParams(llTextViewParams);
llText.addView(textView);
((LinearLayout)view).addView(ll);
@@ -75,10 +90,10 @@ public class InfoSectionBuilder extends BottomSectionBuilder {
LinearLayout.LayoutParams llHorLineParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(1f));
llHorLineParams.gravity = Gravity.BOTTOM;
horizontalLine.setLayoutParams(llHorLineParams);
- TypedValue typedValue = new TypedValue();
- Resources.Theme theme = view.getContext().getTheme();
- theme.resolveAttribute(R.attr.dashboard_divider, typedValue, true);
- int color = typedValue.data;
+
+ TypedValue typedValueColor = new TypedValue();
+ theme.resolveAttribute(R.attr.dashboard_divider, typedValueColor, true);
+ int color = typedValueColor.data;
horizontalLine.setBackgroundColor(color);
((LinearLayout)view).addView(horizontalLine);
@@ -94,23 +109,27 @@ public class InfoSectionBuilder extends BottomSectionBuilder {
}
@Override
- public void buildSection(View view) {
+ public void build(View view) {
MapPoiTypes poiTypes = app.getPoiTypes();
for(Map.Entry e : amenity.getAdditionalInfo().entrySet()) {
- int iconId = 0;
+ int iconId;
String key = e.getKey();
String vl = e.getValue();
if(key.startsWith("name:")) {
continue;
} else if(Amenity.OPENING_HOURS.equals(key)) {
- iconId = R.drawable.mm_clock; // todo: change icon
+ iconId = R.drawable.ic_action_time;
} else if(Amenity.PHONE.equals(key)) {
- iconId = R.drawable.mm_amenity_telephone; // todo: change icon
+ iconId = R.drawable.ic_action_call_dark;
} else if(Amenity.WEBSITE.equals(key)) {
- iconId = R.drawable.mm_internet_access; // todo: change icon
+ iconId = R.drawable.ic_world_globe_dark;
} else {
- iconId = R.drawable.ic_type_info; // todo: change icon
+ if (Amenity.DESCRIPTION.equals(key)) {
+ iconId = R.drawable.ic_action_note_dark;
+ } else {
+ iconId = R.drawable.ic_action_info_dark;
+ }
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey());
if (pt != null) {
if(pt instanceof PoiType && !((PoiType) pt).isText()) {
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuController.java
new file mode 100644
index 0000000000..ce795e7c87
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/AmenityInfoMenuController.java
@@ -0,0 +1,17 @@
+package net.osmand.plus.mapcontextmenu.sections;
+
+import net.osmand.data.Amenity;
+import net.osmand.plus.OsmandApplication;
+
+public class AmenityInfoMenuController extends MenuController {
+
+ public AmenityInfoMenuController(OsmandApplication app, final Amenity amenity) {
+ super(new AmenityInfoMenuBuilder(app, amenity));
+ }
+
+ @Override
+ public int getSupportedMenuStates() {
+ return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
+ }
+
+}
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java
similarity index 72%
rename from OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java
rename to OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java
index bc393679d9..55211d041c 100644
--- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/BottomSectionBuilder.java
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuBuilder.java
@@ -1,4 +1,4 @@
-package net.osmand.plus.mapcontextmenu;
+package net.osmand.plus.mapcontextmenu.sections;
import android.graphics.drawable.Drawable;
import android.view.View;
@@ -7,15 +7,15 @@ import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
-public abstract class BottomSectionBuilder {
+public abstract class MenuBuilder {
protected OsmandApplication app;
- public BottomSectionBuilder(OsmandApplication app) {
+ public MenuBuilder(OsmandApplication app) {
this.app = app;
}
- public abstract void buildSection(View view);
+ public abstract void build(View view);
public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = app.getIconsCache();
diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuController.java
new file mode 100644
index 0000000000..8e1d138d79
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/sections/MenuController.java
@@ -0,0 +1,72 @@
+package net.osmand.plus.mapcontextmenu.sections;
+
+import android.view.View;
+
+public abstract class MenuController {
+
+ public class MenuState {
+ public static final int HEADER_ONLY = 1;
+ public static final int HALF_SCREEN = 2;
+ public static final int FULL_SCREEN = 4;
+ }
+
+ private MenuBuilder builder;
+ private int currentMenuState;
+
+ public MenuController(MenuBuilder builder) {
+ this.builder = builder;
+ this.currentMenuState = getInitialMenuState();
+ }
+
+ public void build(View rootView) {
+ builder.build(rootView);
+ }
+
+ public int getInitialMenuState() {
+ return MenuState.HEADER_ONLY;
+ }
+
+ public int getSupportedMenuStates() {
+ return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
+ }
+
+ public int getCurrentMenuState() {
+ return currentMenuState;
+ }
+
+ public boolean slideUp() {
+ int v = currentMenuState;
+ for (int i = 0; i < 2; i++) {
+ v = v << 1;
+ if ((v & getSupportedMenuStates()) != 0) {
+ currentMenuState = v;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean slideDown() {
+ int v = currentMenuState;
+ for (int i = 0; i < 2; i++) {
+ v = v >> 1;
+ if ((v & getSupportedMenuStates()) != 0) {
+ currentMenuState = v;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void setCurrentMenuState(int currentMenuState) {
+ this.currentMenuState = currentMenuState;
+ }
+
+ public float getHalfScreenMaxHeightKoef() {
+ return .6f;
+ }
+
+ public boolean shouldShowButtons() {
+ return true;
+ }
+}