forked from organicmaps/organicmaps
[android] Adjust ruler and copyright to transparent nav bar
Signed-off-by: Arnaud Vergnet <arnaud.vergnet@mailo.com>
This commit is contained in:
parent
92d02e926a
commit
490b20fef2
2 changed files with 32 additions and 13 deletions
|
@ -59,10 +59,11 @@ public class MapFragment extends BaseMwmFragment
|
|||
|
||||
private int mCurrentCompassOffsetX;
|
||||
private int mCurrentCompassOffsetY;
|
||||
private int mBottomWidgetOffsetX;
|
||||
private int mBottomWidgetOffsetY;
|
||||
|
||||
private int mHeight;
|
||||
private int mWidth;
|
||||
private int mBottomWidgetOffset;
|
||||
private boolean mRequireResize;
|
||||
private boolean mSurfaceCreated;
|
||||
private boolean mSurfaceAttached;
|
||||
|
@ -82,7 +83,7 @@ public class MapFragment extends BaseMwmFragment
|
|||
Context context = requireContext();
|
||||
|
||||
nativeCleanWidgets();
|
||||
setupBottomWidgetsOffset(mBottomWidgetOffset);
|
||||
setupBottomWidgetsOffset(mBottomWidgetOffsetY, mBottomWidgetOffsetX);
|
||||
|
||||
nativeSetupWidget(WIDGET_SCALE_FPS_LABEL,
|
||||
UiUtils.dimen(context, R.dimen.margin_base),
|
||||
|
@ -119,29 +120,38 @@ public class MapFragment extends BaseMwmFragment
|
|||
mCurrentCompassOffsetY = y;
|
||||
}
|
||||
|
||||
void setupBottomWidgetsOffset(int offset)
|
||||
/**
|
||||
* Moves the ruler and copyright using the given offsets.
|
||||
*
|
||||
* @param offsetY Pixel offset from the bottom. -1 to keep the previous value.
|
||||
* @param offsetX Pixel offset from the left. -1 to keep the previous value.
|
||||
*/
|
||||
void setupBottomWidgetsOffset(int offsetY, int offsetX)
|
||||
{
|
||||
mBottomWidgetOffset = offset;
|
||||
setupRuler(offset, true);
|
||||
setupAttribution(offset, true);
|
||||
int x = offsetX < 0 ? mBottomWidgetOffsetX : offsetX;
|
||||
int y = offsetY < 0 ? mBottomWidgetOffsetY : offsetY;
|
||||
setupRuler(y, x,true);
|
||||
setupAttribution(y, x, true);
|
||||
mBottomWidgetOffsetX = x;
|
||||
mBottomWidgetOffsetY = y;
|
||||
}
|
||||
|
||||
void setupRuler(int offsetY, boolean forceRedraw)
|
||||
private void setupRuler(int offsetY, int offsetX, boolean forceRedraw)
|
||||
{
|
||||
Context context = requireContext();
|
||||
nativeSetupWidget(WIDGET_RULER,
|
||||
UiUtils.dimen(context, R.dimen.margin_ruler),
|
||||
UiUtils.dimen(context, R.dimen.margin_ruler) + offsetX,
|
||||
mHeight - UiUtils.dimen(context, R.dimen.margin_ruler) - offsetY,
|
||||
ANCHOR_LEFT_BOTTOM);
|
||||
if (forceRedraw && mSurfaceCreated)
|
||||
nativeApplyWidgets();
|
||||
}
|
||||
|
||||
void setupAttribution(int offsetY, boolean forceRedraw)
|
||||
private void setupAttribution(int offsetY, int offsetX, boolean forceRedraw)
|
||||
{
|
||||
Context context = requireContext();
|
||||
nativeSetupWidget(WIDGET_COPYRIGHT,
|
||||
UiUtils.dimen(context, R.dimen.margin_ruler),
|
||||
UiUtils.dimen(context, R.dimen.margin_ruler) + offsetX,
|
||||
mHeight - UiUtils.dimen(context, R.dimen.margin_ruler) - offsetY,
|
||||
ANCHOR_LEFT_BOTTOM);
|
||||
if (forceRedraw && mSurfaceCreated)
|
||||
|
|
|
@ -195,6 +195,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
|
||||
private String mDonatesUrl;
|
||||
|
||||
private int navBarHeight;
|
||||
|
||||
public interface LeftAnimationTrackListener
|
||||
{
|
||||
void onTrackStarted(boolean collapsed);
|
||||
|
@ -434,7 +436,9 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
.setOnApplyWindowInsetsListener(this::setViewInsetsSides);
|
||||
|
||||
findViewById(R.id.map_fragment_container).setOnApplyWindowInsetsListener((view, windowInsets) -> {
|
||||
navBarHeight = windowInsets.getSystemWindowInsetBottom();
|
||||
adjustCompass(-1, windowInsets.getSystemWindowInsetRight());
|
||||
adjustBottomWidgets(windowInsets.getSystemWindowInsetLeft());
|
||||
return windowInsets;
|
||||
});
|
||||
}
|
||||
|
@ -1295,6 +1299,11 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
}
|
||||
|
||||
public void adjustBottomWidgets()
|
||||
{
|
||||
adjustBottomWidgets(-1);
|
||||
}
|
||||
|
||||
public void adjustBottomWidgets(int offsetX)
|
||||
{
|
||||
if (mMapFragment == null || !mMapFragment.isAdded())
|
||||
return;
|
||||
|
@ -1302,13 +1311,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
|
|||
int mapButtonsHeight = 0;
|
||||
int mainMenuHeight = 0;
|
||||
if (mMapButtonsController != null)
|
||||
mapButtonsHeight = (int) mMapButtonsController.getBottomButtonsHeight();
|
||||
mapButtonsHeight = (int) mMapButtonsController.getBottomButtonsHeight() + navBarHeight;
|
||||
if (mMainMenu != null)
|
||||
mainMenuHeight = mMainMenu.getMenuHeight();
|
||||
|
||||
int offsetY = Math.max(mapButtonsHeight, mainMenuHeight);
|
||||
int y = Math.max(Math.max(mapButtonsHeight, mainMenuHeight), navBarHeight);
|
||||
|
||||
mMapFragment.setupBottomWidgetsOffset(offsetY);
|
||||
mMapFragment.setupBottomWidgetsOffset(y, offsetX);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue