Small pr fixes
This commit is contained in:
parent
1b930fdadd
commit
447259b80b
3 changed files with 64 additions and 60 deletions
|
@ -1,51 +1,52 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/buttons_container"
|
android:id="@+id/buttons_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="bottom"
|
android:layout_gravity="bottom"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingStart="@dimen/content_padding"
|
android:paddingStart="@dimen/content_padding"
|
||||||
android:paddingLeft="@dimen/content_padding"
|
android:paddingLeft="@dimen/content_padding"
|
||||||
android:paddingTop="@dimen/content_padding_small"
|
android:paddingTop="@dimen/content_padding_small"
|
||||||
android:paddingEnd="@dimen/content_padding"
|
android:paddingEnd="@dimen/content_padding"
|
||||||
android:paddingRight="@dimen/content_padding"
|
android:paddingRight="@dimen/content_padding"
|
||||||
android:paddingBottom="@dimen/content_padding_small">
|
android:paddingBottom="@dimen/content_padding_small">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/third_button"
|
android:id="@+id/third_button"
|
||||||
layout="@layout/bottom_sheet_dialog_button"
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dialog_button_height"
|
android:layout_height="@dimen/dialog_button_height"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/buttons_divider_top"
|
android:id="@+id/buttons_divider_top"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/content_padding"
|
android:layout_height="@dimen/content_padding"
|
||||||
tools:visibility="visible" />
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/right_bottom_button"
|
android:id="@+id/right_bottom_button"
|
||||||
layout="@layout/bottom_sheet_dialog_button"
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dialog_button_height"
|
android:layout_height="@dimen/dialog_button_height"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/buttons_divider"
|
android:id="@+id/buttons_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/content_padding"
|
android:layout_height="@dimen/content_padding"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/dismiss_button"
|
android:id="@+id/dismiss_button"
|
||||||
layout="@layout/bottom_sheet_dialog_button"
|
layout="@layout/bottom_sheet_dialog_button"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dialog_button_height" />
|
android:layout_height="@dimen/dialog_button_height" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
|
@ -52,9 +52,9 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
protected View rightButton;
|
protected View rightButton;
|
||||||
protected View thirdButton;
|
protected View thirdButton;
|
||||||
|
|
||||||
|
private View buttonsShadow;
|
||||||
private LinearLayout itemsContainer;
|
private LinearLayout itemsContainer;
|
||||||
private LinearLayout buttonsContainer;
|
private LinearLayout buttonsContainer;
|
||||||
protected View buttonsShadow;
|
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
protected int dismissButtonStringRes = R.string.shared_string_cancel;
|
protected int dismissButtonStringRes = R.string.shared_string_cancel;
|
||||||
|
@ -162,6 +162,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
final int screenHeight = AndroidUtils.getScreenHeight(activity);
|
||||||
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
final int statusBarHeight = AndroidUtils.getStatusBarHeight(activity);
|
||||||
|
final int contentHeight = getContentHeight(screenHeight - statusBarHeight);
|
||||||
|
|
||||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,7 +173,6 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
} else {
|
} else {
|
||||||
obs.removeGlobalOnLayoutListener(this);
|
obs.removeGlobalOnLayoutListener(this);
|
||||||
}
|
}
|
||||||
final int contentHeight = getContentHeight(screenHeight - statusBarHeight);
|
|
||||||
|
|
||||||
final View contentView = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
|
final View contentView = useScrollableItemsContainer() ? mainView.findViewById(R.id.scroll_view) : itemsContainer;
|
||||||
if (contentView.getHeight() > contentHeight) {
|
if (contentView.getHeight() > contentHeight) {
|
||||||
|
@ -201,9 +201,14 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
|
|
||||||
private int getContentHeight(int availableScreenHeight) {
|
private int getContentHeight(int availableScreenHeight) {
|
||||||
int customHeight = getCustomHeight();
|
int customHeight = getCustomHeight();
|
||||||
int buttonsHeight = 0;
|
int buttonsHeight;
|
||||||
if (useVerticalButtons()) {
|
if (useVerticalButtons()) {
|
||||||
buttonsHeight = AndroidUtils.dpToPx(getContext(), 112);
|
int padding = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||||
|
int buttonHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_height);
|
||||||
|
buttonsHeight = (buttonHeight + padding) * 2 + getFirstDividerHeight();
|
||||||
|
if (getThirdBottomButtonTextId() != DEFAULT_VALUE) {
|
||||||
|
buttonsHeight += buttonHeight + getSecondDividerHeight();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height);
|
buttonsHeight = getResources().getDimensionPixelSize(R.dimen.dialog_button_ex_height);
|
||||||
}
|
}
|
||||||
|
@ -310,10 +315,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
}
|
}
|
||||||
String rightButtonText = getString(rightBottomButtonTextId);
|
String rightButtonText = getString(rightBottomButtonTextId);
|
||||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(activity);
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(activity);
|
||||||
|
int outerPadding = getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
|
int innerPadding = getResources().getDimensionPixelSize(R.dimen.content_padding_small);
|
||||||
int dialogWidth = portrait ? AndroidUtils.getScreenWidth(activity) : getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
int dialogWidth = portrait ? AndroidUtils.getScreenWidth(activity) : getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
|
||||||
int measuredTextWidth = AndroidUtils.getTextWidth(getResources().getDimensionPixelSize(R.dimen.default_desc_text_size), rightButtonText);
|
int availableTextWidth = (dialogWidth - (outerPadding * 3 + innerPadding * 4)) / 2;
|
||||||
int availableTextWidth = (dialogWidth - AndroidUtils.dpToPx(activity, 96)) / 2;
|
|
||||||
|
|
||||||
|
int measuredTextWidth = AndroidUtils.getTextWidth(getResources().getDimensionPixelSize(R.dimen.default_desc_text_size), rightButtonText);
|
||||||
return measuredTextWidth > availableTextWidth;
|
return measuredTextWidth > availableTextWidth;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -366,7 +373,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
AndroidUiHelper.updateVisibility(divider, buttonTextId != DEFAULT_VALUE);
|
AndroidUiHelper.updateVisibility(divider, buttonTextId != DEFAULT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getFirstDividerHeight(){
|
protected int getFirstDividerHeight() {
|
||||||
return getResources().getDimensionPixelSize(R.dimen.content_padding);
|
return getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +395,7 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
|
||||||
AndroidUiHelper.updateVisibility(divider, buttonTextId != DEFAULT_VALUE);
|
AndroidUiHelper.updateVisibility(divider, buttonTextId != DEFAULT_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSecondDividerHeight(){
|
protected int getSecondDividerHeight() {
|
||||||
return getResources().getDimensionPixelSize(R.dimen.content_padding);
|
return getResources().getDimensionPixelSize(R.dimen.content_padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.osmand.plus.measurementtool;
|
package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
@ -9,12 +8,10 @@ import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities.DialogButtonType;
|
||||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton;
|
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerSpaceItem;
|
||||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
import net.osmand.plus.base.bottomsheetmenu.simpleitems.ShortDescriptionItem;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
|
||||||
|
|
||||||
public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@ -29,8 +26,7 @@ public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment
|
||||||
|
|
||||||
items.add(new ShortDescriptionItem.Builder()
|
items.add(new ShortDescriptionItem.Builder()
|
||||||
.setDescription(getString(R.string.plan_route_exit_dialog_descr))
|
.setDescription(getString(R.string.plan_route_exit_dialog_descr))
|
||||||
.setTitle(getString(R.string.
|
.setTitle(getString(R.string.exit_without_saving))
|
||||||
exit_without_saving))
|
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_list_title_with_descr)
|
.setLayoutId(R.layout.bottom_sheet_item_list_title_with_descr)
|
||||||
.create());
|
.create());
|
||||||
|
|
||||||
|
@ -56,7 +52,7 @@ public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSecondDividerHeight() {
|
public int getSecondDividerHeight() {
|
||||||
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large);
|
return getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,8 +74,8 @@ public class ExitBottomSheetDialogFragment extends MenuBottomSheetDialogFragment
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UiUtilities.DialogButtonType getThirdBottomButtonType() {
|
protected DialogButtonType getThirdBottomButtonType() {
|
||||||
return (UiUtilities.DialogButtonType.SECONDARY);
|
return (DialogButtonType.SECONDARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment) {
|
public static void showInstance(@NonNull FragmentManager fragmentManager, @Nullable Fragment targetFragment) {
|
||||||
|
|
Loading…
Reference in a new issue