forked from organicmaps/organicmaps
[android] Fixed navigation buttons collision with compass. Fixed tablet navigation search buttons layout.
This commit is contained in:
parent
ff5ea56964
commit
0894313c17
5 changed files with 25 additions and 13 deletions
|
@ -5,9 +5,10 @@
|
|||
android:id="@+id/search_button_frame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="@dimen/nav_frame_padding"
|
||||
android:clipToPadding="false"
|
||||
android:theme="?navButtonsTheme"
|
||||
tools:background="@color/bg_primary"
|
||||
tools:showIn="@layout/activity_map">
|
||||
tools:background="@color/bg_primary">
|
||||
|
||||
<Space
|
||||
android:id="@id/anchor_center"
|
||||
|
@ -27,8 +28,6 @@
|
|||
android:layout_width="@dimen/margin_quadruple"
|
||||
android:layout_height="@dimen/margin_quadruple"
|
||||
android:layout_marginTop="@dimen/nav_zoom_top"
|
||||
android:layout_marginStart="@dimen/margin_eighth"
|
||||
android:layout_marginLeft="@dimen/margin_eighth"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:background="?nav_background"
|
||||
|
@ -43,8 +42,8 @@
|
|||
android:layout_alignParentStart="true"
|
||||
android:layout_marginTop="-68dp"
|
||||
android:layout_below="@id/btn_bookmarks"
|
||||
android:layout_marginLeft="-70dp"
|
||||
android:layout_marginStart="-70dp"
|
||||
android:layout_marginLeft="-68dp"
|
||||
android:layout_marginStart="-68dp"
|
||||
android:background="?searchLayoutBackground"
|
||||
android:visibility="invisible"
|
||||
tools:visibility="visible">
|
||||
|
@ -103,8 +102,6 @@
|
|||
style="@style/MwmWidget.SearchNavigationButton"
|
||||
android:layout_width="@dimen/margin_quadruple"
|
||||
android:layout_height="@dimen/margin_quadruple"
|
||||
android:layout_marginStart="@dimen/margin_eighth"
|
||||
android:layout_marginLeft="@dimen/margin_eighth"
|
||||
android:layout_below="@id/btn_bookmarks"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
<dimen name="direction_frame_min_height">36dp</dimen>
|
||||
|
||||
<!-- map widgets -->
|
||||
<dimen name="margin_compass">34dp</dimen>
|
||||
<dimen name="margin_compass_top">28dp</dimen>
|
||||
<dimen name="margin_compass">32dp</dimen>
|
||||
<dimen name="margin_compass_top">26dp</dimen>
|
||||
<dimen name="margin_ruler_left">10dp</dimen>
|
||||
<dimen name="margin_ruler_bottom">58dp</dimen>
|
||||
<dimen name="compass_height">40dp</dimen>
|
||||
|
|
|
@ -96,9 +96,12 @@ public class MapFragment extends BaseMwmFragment
|
|||
|
||||
void setupCompass(int offsetY, boolean forceRedraw)
|
||||
{
|
||||
int navPadding = UiUtils.dimen(R.dimen.nav_frame_padding);
|
||||
int marginX = UiUtils.dimen(R.dimen.margin_compass) + navPadding;
|
||||
int marginY = UiUtils.dimen(R.dimen.margin_compass_top) + navPadding;
|
||||
nativeSetupWidget(WIDGET_COMPASS,
|
||||
mWidth - UiUtils.dimen(R.dimen.margin_compass),
|
||||
offsetY + UiUtils.dimen(R.dimen.margin_compass_top),
|
||||
mWidth - marginX,
|
||||
offsetY + marginY,
|
||||
ANCHOR_CENTER);
|
||||
if (forceRedraw && mContextCreated)
|
||||
nativeApplyWidgets();
|
||||
|
|
|
@ -1521,7 +1521,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
if (mMapFragment == null || !mMapFragment.isAdded())
|
||||
return;
|
||||
|
||||
mMapFragment.setupCompass(offsetY, true);
|
||||
int resultOffset = offsetY;
|
||||
if (mNavAnimationController != null && mNavAnimationController.isCollideWithCompass(offsetY))
|
||||
resultOffset = -offsetY;
|
||||
|
||||
mMapFragment.setupCompass(resultOffset, true);
|
||||
|
||||
CompassData compass = LocationHelper.INSTANCE.getCompassData();
|
||||
if (compass != null)
|
||||
|
|
|
@ -43,6 +43,7 @@ class NavigationButtonsAnimationController
|
|||
private float mBottomLimit;
|
||||
|
||||
private float mCurrentOffset;
|
||||
private float mCompassHeight;
|
||||
|
||||
NavigationButtonsAnimationController(@NonNull View zoomIn, @NonNull View zoomOut,
|
||||
@NonNull View myPosition, @NonNull final View contentView,
|
||||
|
@ -56,6 +57,7 @@ class NavigationButtonsAnimationController
|
|||
Resources res = mZoomIn.getResources();
|
||||
mMargin = res.getDimension(R.dimen.margin_base_plus);
|
||||
mBottomLimit = res.getDimension(R.dimen.menu_line_height);
|
||||
mCompassHeight = res.getDimension(R.dimen.compass_height);
|
||||
calculateLimitTranslations();
|
||||
contentView.addOnLayoutChangeListener(new View.OnLayoutChangeListener()
|
||||
{
|
||||
|
@ -308,6 +310,12 @@ class NavigationButtonsAnimationController
|
|||
mZoomVisible = state.getBoolean(STATE_VISIBLE, false);
|
||||
}
|
||||
|
||||
boolean isCollideWithCompass(int compassOffset)
|
||||
{
|
||||
int zoomTop = mZoomIn.getTop();
|
||||
return zoomTop != 0 && zoomTop <= compassOffset + mCompassHeight;
|
||||
}
|
||||
|
||||
interface OnTranslationChangedListener
|
||||
{
|
||||
void onTranslationChanged(float translation);
|
||||
|
|
Loading…
Add table
Reference in a new issue