From becf77ca6062b500122874719556dc223ff00623 Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 25 Jan 2021 17:26:03 +0200 Subject: [PATCH 1/4] fix align title text to the left side --- .../net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java | 2 ++ OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java index b18ee19fdb..39951b4c2c 100644 --- a/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java +++ b/OsmAnd/src/net/osmand/plus/onlinerouting/ui/OnlineRoutingCard.java @@ -2,6 +2,7 @@ package net.osmand.plus.onlinerouting.ui; import android.text.Editable; import android.text.TextWatcher; +import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; @@ -79,6 +80,7 @@ public class OnlineRoutingCard extends BaseCard { int activeColor = ContextCompat.getColor(app, appMode.getIconColorInfo().getColor(nightMode)); textFieldBoxes.setPrimaryColor(activeColor); + textFieldBoxes.setGravityFloatingLabel(Gravity.START); editText.addTextChangedListener(new TextWatcher() { @Override diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index 612d293271..b2ab7de5a5 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -29,4 +29,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); inputLayout.setPadding(0, paddingH, 0, paddingH); } + + public void setGravityFloatingLabel(int gravity) { + floatingLabel.setGravity(gravity); + } } From af828884247e3dd62ecf0d133ca4da4a0c90d358 Mon Sep 17 00:00:00 2001 From: Skalii Date: Mon, 25 Jan 2021 18:30:26 +0200 Subject: [PATCH 2/4] fix bottom padding if title text has more than one line --- .../net/osmand/plus/widgets/OsmandTextFieldBoxes.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index b2ab7de5a5..bbc94d126e 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -3,6 +3,7 @@ package net.osmand.plus.widgets; import android.content.Context; import android.util.AttributeSet; import android.view.View; +import android.widget.RelativeLayout; import net.osmand.plus.R; @@ -33,4 +34,13 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { public void setGravityFloatingLabel(int gravity) { floatingLabel.setGravity(gravity); } + + @Override + public void setLabelText(String labelText) { + super.setLabelText(labelText); + if (!floatingLabel.isSingleLine()) { + RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) floatingLabel.getLayoutParams(); + rl.bottomMargin = rl.topMargin; + } + } } From 6fa05b0748f6cefa5a7e5390997ff130a70a2268 Mon Sep 17 00:00:00 2001 From: Skalii Date: Tue, 26 Jan 2021 04:02:49 +0200 Subject: [PATCH 3/4] fix padding between title and input text if title has more than one line --- .../plus/widgets/OsmandTextFieldBoxes.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index bbc94d126e..45eb6a703b 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -3,7 +3,6 @@ package net.osmand.plus.widgets; import android.content.Context; import android.util.AttributeSet; import android.view.View; -import android.widget.RelativeLayout; import net.osmand.plus.R; @@ -38,9 +37,18 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { @Override public void setLabelText(String labelText) { super.setLabelText(labelText); - if (!floatingLabel.isSingleLine()) { - RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) floatingLabel.getLayoutParams(); - rl.bottomMargin = rl.topMargin; - } + floatingLabel.post(new Runnable() { + @Override + public void run() { + if (floatingLabel.getLineCount() > 1) { + inputLayout.setPadding( + inputLayout.getPaddingLeft(), + inputLayout.getPaddingTop() + getResources().getDimensionPixelSize(R.dimen.pages_item_padding), + inputLayout.getPaddingRight(), + inputLayout.getPaddingBottom() + ); + } + } + }); } } From 069f526a571156d5be281c003800371b1ab306c1 Mon Sep 17 00:00:00 2001 From: Skalii Date: Wed, 27 Jan 2021 01:31:44 +0200 Subject: [PATCH 4/4] fix re-adding top padding --- .../src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java index 45eb6a703b..64cae466c4 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java +++ b/OsmAnd/src/net/osmand/plus/widgets/OsmandTextFieldBoxes.java @@ -26,8 +26,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { floatingLabel.setVisibility(View.GONE); labelSpace.setVisibility(View.GONE); labelSpaceBelow.setVisibility(View.GONE); - int paddingH = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); - inputLayout.setPadding(0, paddingH, 0, paddingH); + int paddingV = getResources().getDimensionPixelSize(R.dimen.route_info_card_details_margin); + inputLayout.setPadding(0, paddingV, 0, paddingV); } public void setGravityFloatingLabel(int gravity) { @@ -43,7 +43,8 @@ public class OsmandTextFieldBoxes extends TextFieldBoxes { if (floatingLabel.getLineCount() > 1) { inputLayout.setPadding( inputLayout.getPaddingLeft(), - inputLayout.getPaddingTop() + getResources().getDimensionPixelSize(R.dimen.pages_item_padding), + getResources().getDimensionPixelOffset(useDenseSpacing ? R.dimen.dense_editTextLayout_padding_top : R.dimen.editTextLayout_padding_top) + + getResources().getDimensionPixelSize(useDenseSpacing ? R.dimen.context_menu_first_line_top_margin : R.dimen.content_padding_small), inputLayout.getPaddingRight(), inputLayout.getPaddingBottom() );