Fix context menu landscape mode
This commit is contained in:
parent
45b54e765b
commit
2fa410947d
2 changed files with 63 additions and 25 deletions
|
@ -126,7 +126,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
|
||||
markerPaddingPx = dpToPx(MARKER_PADDING_DP);
|
||||
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
|
||||
topScreenPosY = -dpToPx(SHADOW_HEIGHT_TOP_DP);
|
||||
topScreenPosY = addStatusBarHeightIfNeeded(-dpToPx(SHADOW_HEIGHT_TOP_DP));
|
||||
|
||||
menu = getMapActivity().getContextMenu();
|
||||
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
|
||||
|
@ -272,11 +272,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
openMenuHalfScreen();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if (menu.isLandscapeLayout()) {
|
||||
if (swipeDetector.onTouchEvent(event)) {
|
||||
menu.close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -301,6 +300,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
hasMoved = true;
|
||||
float y = event.getY();
|
||||
float newY = getViewY() + (y - dy);
|
||||
if (menu.isLandscapeLayout() && newY > 0) {
|
||||
newY = 0;
|
||||
}
|
||||
setViewY((int) newY, false, false);
|
||||
|
||||
menuFullHeight = view.getHeight() - (int) newY + 10;
|
||||
|
@ -309,12 +311,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
mainView.setLayoutParams(lp);
|
||||
mainView.requestLayout();
|
||||
|
||||
if (velocity != null) {
|
||||
velocity.addMovement(event);
|
||||
velocity.computeCurrentVelocity(1000);
|
||||
velocityY = Math.abs(velocity.getYVelocity());
|
||||
if (velocityY > maxVelocityY)
|
||||
if (velocityY > maxVelocityY) {
|
||||
maxVelocityY = velocityY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -327,7 +332,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
|
||||
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
|
||||
|
||||
if (velocity != null) {
|
||||
velocity.recycle();
|
||||
}
|
||||
|
||||
boolean skipScreenState = Math.abs(currentY - dyMain) > skipScreenStateLimit;
|
||||
changeMenuState(currentY, skipScreenState, slidingUp, slidingDown);
|
||||
|
@ -603,6 +610,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
boolean needCloseMenu = false;
|
||||
|
||||
int oldMenuState = menu.getCurrentMenuState();
|
||||
if (!menu.isLandscapeLayout()) {
|
||||
if (slidingDown && !skipScreenState && oldMenuState == MenuState.FULL_SCREEN && currentY < topScreenPosY) {
|
||||
slidingDown = false;
|
||||
}
|
||||
|
@ -617,6 +625,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
menu.slideDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
int newMenuState = menu.getCurrentMenuState();
|
||||
boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
|
||||
|
||||
|
@ -1290,7 +1299,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
case MenuState.FULL_SCREEN:
|
||||
if (currentY != CURRENT_Y_UNDEFINED) {
|
||||
int maxPosY = viewHeight - menuFullHeightMax;
|
||||
int minPosY = addStatusBarHeightIfNeeded(topScreenPosY);
|
||||
int minPosY = topScreenPosY;
|
||||
if (maxPosY > minPosY) {
|
||||
maxPosY = minPosY;
|
||||
}
|
||||
|
@ -1302,7 +1311,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
posY = currentY;
|
||||
}
|
||||
} else {
|
||||
posY = addStatusBarHeightIfNeeded(topScreenPosY);
|
||||
posY = topScreenPosY;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -130,6 +130,34 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
this.builder.setLight(isLight());
|
||||
}
|
||||
|
||||
public void onCreated() {
|
||||
/*
|
||||
toolbarController = new ContextMenuToolbarController(this);
|
||||
toolbarController.setTitle(getNameStr());
|
||||
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mapContextMenu != null) {
|
||||
mapContextMenu.backToolbarAction(MenuController.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
toolbarController.setOnTitleClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
}
|
||||
});
|
||||
toolbarController.setOnCloseButtonClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mapContextMenu != null) {
|
||||
mapContextMenu.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCollapseExpand(boolean collapsed) {
|
||||
if (mapContextMenu != null) {
|
||||
|
@ -217,6 +245,7 @@ public abstract class MenuController extends BaseMenuController implements Colla
|
|||
}
|
||||
menuController.menuType = menuType;
|
||||
menuController.setLatLon(latLon);
|
||||
menuController.onCreated();
|
||||
return menuController;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue