diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java index 8917d22975..ee0451ef20 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BaseBottomSheetItem.java @@ -13,6 +13,7 @@ public class BaseBottomSheetItem { public static final int INVALID_POSITION = -1; public static final int INVALID_ID = -1; + public static final int INVALID_VALUE = -1; protected View view; @LayoutRes diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java index 12c06b7f65..9fc4da7dc5 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemTitleWithDescrAndButton.java @@ -24,22 +24,34 @@ public class BottomSheetItemTitleWithDescrAndButton extends BottomSheetItemWithD private TextView textButtonTV; public BottomSheetItemTitleWithDescrAndButton(View customView, - @LayoutRes int layoutId, - Object tag, - boolean disabled, - View.OnClickListener onClickListener, - int position, - Drawable icon, - String title, - @ColorRes int titleColorId, - CharSequence description, - @ColorRes int descriptionColorId, - String buttonTitle, - View.OnClickListener onButtonClickListener, - Drawable leftCompoundDrawable, - Drawable rightCompoundDrawable, - @ColorRes int buttonTextColor) { - super(customView, layoutId, tag, disabled, onClickListener, position, icon, title, titleColorId, description, descriptionColorId); + @LayoutRes int layoutId, + Object tag, + boolean disabled, + View.OnClickListener onClickListener, + int position, + Drawable icon, + String title, + @ColorRes int titleColorId, + CharSequence description, + @ColorRes int descriptionColorId, + int descriptionMaxLines, + String buttonTitle, + View.OnClickListener onButtonClickListener, + Drawable leftCompoundDrawable, + Drawable rightCompoundDrawable, + @ColorRes int buttonTextColor) { + super(customView, + layoutId, + tag, + disabled, + onClickListener, + position, + icon, + title, + titleColorId, + description, + descriptionColorId, + descriptionMaxLines); this.buttonTitle = buttonTitle; this.onButtonClickListener = onButtonClickListener; this.leftCompoundDrawable = leftCompoundDrawable; @@ -112,6 +124,7 @@ public class BottomSheetItemTitleWithDescrAndButton extends BottomSheetItemWithD titleColorId, description, descriptionColorId, + descriptionMaxLines, buttonTitle, onButtonClickListener, leftCompoundDrawable, diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java index 07bcb93895..a0b1d87107 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithCompoundButton.java @@ -36,6 +36,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri @ColorRes int titleColorId, CharSequence description, @ColorRes int descriptionColorId, + int descriptionMaxLines, boolean checked, ColorStateList buttonTintList, OnCheckedChangeListener onCheckedChangeListener) { @@ -49,7 +50,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri title, titleColorId, description, - descriptionColorId); + descriptionColorId, + descriptionMaxLines); this.checked = checked; this.buttonTintList = buttonTintList; this.onCheckedChangeListener = onCheckedChangeListener; @@ -102,6 +104,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri titleColorId, description, descriptionColorId, + descriptionMaxLines, checked, buttonTintList, onCheckedChangeListener); diff --git a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java index a0aad799bf..fa26be10e7 100644 --- a/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java +++ b/OsmAnd/src/net/osmand/plus/base/bottomsheetmenu/BottomSheetItemWithDescription.java @@ -16,6 +16,7 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { protected CharSequence description; @ColorRes private int descriptionColorId = INVALID_ID; + private int descriptionMaxLines = INVALID_VALUE; private TextView descriptionTv; @@ -29,10 +30,12 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { String title, @ColorRes int titleColorId, CharSequence description, - @ColorRes int descriptionColorId) { + @ColorRes int descriptionColorId, + int descriptionMaxLines) { super(customView, layoutId, tag, disabled, onClickListener, position, icon, title, titleColorId); this.description = description; this.descriptionColorId = descriptionColorId; + this.descriptionMaxLines = descriptionMaxLines; } protected BottomSheetItemWithDescription() { @@ -44,6 +47,11 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { descriptionTv.setText(description); } + public void setDescriptionMaxLines(int maxLines) { + this.descriptionMaxLines = maxLines; + descriptionTv.setMaxLines(maxLines); + } + @Override public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) { super.inflate(app, container, nightMode); @@ -53,6 +61,9 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { if (descriptionColorId != INVALID_ID) { descriptionTv.setTextColor(ContextCompat.getColor(app, descriptionColorId)); } + if (descriptionMaxLines != INVALID_VALUE) { + descriptionTv.setMaxLines(descriptionMaxLines); + } } } @@ -61,6 +72,7 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { protected CharSequence description; @ColorRes protected int descriptionColorId = INVALID_ID; + protected int descriptionMaxLines = INVALID_POSITION; public Builder setDescription(CharSequence description) { this.description = description; @@ -72,6 +84,11 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { return this; } + public Builder setDescriptionMaxLines(int maxLines) { + this.descriptionMaxLines = maxLines; + return this; + } + public BottomSheetItemWithDescription create() { return new BottomSheetItemWithDescription(customView, layoutId, @@ -83,7 +100,8 @@ public class BottomSheetItemWithDescription extends SimpleBottomSheetItem { title, titleColorId, description, - descriptionColorId); + descriptionColorId, + descriptionMaxLines); } } }