Track Appearance: adjust track on map when header clicked

This commit is contained in:
nazar-kutz 2021-03-05 20:10:40 +02:00
parent df95dbec7f
commit 6883bf722b
2 changed files with 10 additions and 4 deletions

View file

@ -409,15 +409,17 @@ public class TrackAppearanceFragment extends ContextMenuScrollFragment implement
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy(); RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
int tileBoxWidthPx = 0; int tileBoxWidthPx = 0;
int tileBoxHeightPx = 0; int tileBoxHeightPx = 0;
int marginLeftPx = 0;
if (!isPortrait()) { if (!isPortrait()) {
tileBoxWidthPx = tb.getPixWidth() - getWidth(); tileBoxWidthPx = tb.getPixWidth() - getWidth();
marginLeftPx = getWidth();
} else { } else {
int fHeight = getViewHeight() - y - AndroidUtils.getStatusBarHeight(mapActivity); int fHeight = getViewHeight() - y - AndroidUtils.getStatusBarHeight(mapActivity);
tileBoxHeightPx = tb.getPixHeight() - fHeight; tileBoxHeightPx = tb.getPixHeight() - fHeight;
} }
if (r.left != 0 && r.right != 0) { if (r.left != 0 && r.right != 0) {
mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0); mapActivity.getMapView().fitRectToMap(r.left, r.right, r.top, r.bottom, tileBoxWidthPx, tileBoxHeightPx, 0, marginLeftPx);
} }
} }
} }

View file

@ -638,8 +638,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} else if (mapPosition == OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT) { } else if (mapPosition == OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT) {
ratiox = 0.7f; ratiox = 0.7f;
} else { } else {
boolean isLayoutRtl = AndroidUtils.isLayoutRtl(application); ratiox = mapPositionX == 0 ? 0.5f : (isLayoutRtl() ? 0.25f : 0.75f);
ratiox = mapPositionX == 0 ? 0.5f : (isLayoutRtl ? 0.25f : 0.75f);
} }
final int cy = (int) (ratioy * view.getHeight()); final int cy = (int) (ratioy * view.getHeight());
final int cx = (int) (ratiox * view.getWidth()); final int cx = (int) (ratiox * view.getWidth());
@ -959,7 +958,8 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
if (tileBoxWidthPx > 0) { if (tileBoxWidthPx > 0) {
tbw = (int) (tileBoxWidthPx * border); tbw = (int) (tileBoxWidthPx * border);
if (marginLeftPx > 0) { if (marginLeftPx > 0) {
dx = (tb.getPixWidth() - tileBoxWidthPx) / 2 - marginLeftPx; int offset = (tb.getPixWidth() - tileBoxWidthPx) / 2 - marginLeftPx;
dx = isLayoutRtl() ? -offset : offset;
} }
} else if (tileBoxHeightPx > 0) { } else if (tileBoxHeightPx > 0) {
tbh = (int) (tileBoxHeightPx * border); tbh = (int) (tileBoxHeightPx * border);
@ -1425,4 +1425,8 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public Context getContext() { public Context getContext() {
return activity; return activity;
} }
public boolean isLayoutRtl() {
return AndroidUtils.isLayoutRtl(application);
}
} }