Fix #9325
This commit is contained in:
parent
a7010faa16
commit
c6bddc22d1
1 changed files with 31 additions and 13 deletions
|
@ -172,25 +172,43 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setQuickActionButtonMargin() {
|
private void setQuickActionButtonMargin() {
|
||||||
|
int defRightMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing_land) * 2;
|
||||||
|
int defBottomMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing) * 2;
|
||||||
FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) quickActionButton.getLayoutParams();
|
FrameLayout.LayoutParams param = (FrameLayout.LayoutParams) quickActionButton.getLayoutParams();
|
||||||
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
|
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
|
||||||
Pair<Integer, Integer> fabMargin = settings.getPortraitFabMargin();
|
Pair<Integer, Integer> fabMargin = settings.getPortraitFabMargin();
|
||||||
if (fabMargin != null) {
|
setQuickActionButtonMargin(param, fabMargin, 0, defBottomMargin);
|
||||||
param.rightMargin = fabMargin.first;
|
|
||||||
param.bottomMargin = fabMargin.second;
|
|
||||||
} else {
|
|
||||||
param.bottomMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing) * 2;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Pair<Integer, Integer> fabMargin = settings.getLandscapeFabMargin();
|
Pair<Integer, Integer> fabMargin = settings.getLandscapeFabMargin();
|
||||||
|
setQuickActionButtonMargin(param, fabMargin, defRightMargin, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setQuickActionButtonMargin(FrameLayout.LayoutParams params,
|
||||||
|
Pair<Integer, Integer> fabMargin,
|
||||||
|
int defRightMargin, int defBottomMargin) {
|
||||||
|
int screenHeight = AndroidUtils.getScreenHeight(mapActivity);
|
||||||
|
int screenWidth = AndroidUtils.getScreenWidth(mapActivity);
|
||||||
|
int btnHeight = quickActionButton.getHeight();
|
||||||
|
int btnWidth = quickActionButton.getWidth();
|
||||||
|
int rightMargin;
|
||||||
|
int bottomMargin;
|
||||||
if (fabMargin != null) {
|
if (fabMargin != null) {
|
||||||
param.rightMargin = fabMargin.first;
|
rightMargin = fabMargin.first;
|
||||||
param.bottomMargin = fabMargin.second;
|
bottomMargin = fabMargin.second;
|
||||||
|
if (rightMargin < 0 || rightMargin > screenWidth - btnWidth) {
|
||||||
|
rightMargin = defRightMargin;
|
||||||
|
}
|
||||||
|
if (bottomMargin < 0 || bottomMargin > screenHeight - btnHeight) {
|
||||||
|
bottomMargin = defBottomMargin;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
param.rightMargin = calculateTotalSizePx(R.dimen.map_button_size, R.dimen.map_button_spacing_land) * 2;
|
rightMargin = defRightMargin;
|
||||||
|
bottomMargin = defBottomMargin;
|
||||||
}
|
}
|
||||||
}
|
params.rightMargin = rightMargin;
|
||||||
quickActionButton.setLayoutParams(param);
|
params.bottomMargin = bottomMargin;
|
||||||
|
quickActionButton.setLayoutParams(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateTotalSizePx(@DimenRes int... dimensId) {
|
private int calculateTotalSizePx(@DimenRes int... dimensId) {
|
||||||
|
|
Loading…
Reference in a new issue