summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTetsutoki Shiozawa <tetsutoki.shiozawa@sony.com>2017-08-08 04:25:00 (GMT)
committerLuca Stefani <luca.stefani.ge1@gmail.com>2019-07-27 20:57:26 (GMT)
commitf275ab8cfaa7ee7bb34f51b5787c0f0d336fbaa4 (patch)
tree7183b98dc2ec77781dfbf9875dc755ab83d10907
parentc854c29598fccd8bc3eb2b5a1b12c587b4c123e4 (diff)
downloadframeworks_base-f275ab8cfaa7ee7bb34f51b5787c0f0d336fbaa4.zip
frameworks_base-f275ab8cfaa7ee7bb34f51b5787c0f0d336fbaa4.tar.gz
frameworks_base-f275ab8cfaa7ee7bb34f51b5787c0f0d336fbaa4.tar.bz2
Remove unnecessary right padding from time picker
Symptom: When the device language was set to Spanish, "A.M." label was not fully displayed on the time picker widget. "M." was lacked. Root cause: There are unnecessary right paddings on the layout definition of time picker. It uselessly consumes the room for ampm_layout. Bug: 64498105 Change-Id: Ie52fafc0fb7d6d6ea5b0ca2eaeb53755d4aebc19
-rw-r--r--core/java/android/widget/TimePickerClockDelegate.java13
-rw-r--r--core/res/res/layout/time_picker_header_material.xml8
2 files changed, 11 insertions, 10 deletions
diff --git a/core/java/android/widget/TimePickerClockDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java
index 77670b3..6c039d8 100644
--- a/core/java/android/widget/TimePickerClockDelegate.java
+++ b/core/java/android/widget/TimePickerClockDelegate.java
@@ -454,6 +454,7 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate {
(RelativeLayout.LayoutParams) mAmPmLayout.getLayoutParams();
if (params.getRule(RelativeLayout.RIGHT_OF) != 0
|| params.getRule(RelativeLayout.LEFT_OF) != 0) {
+ final int margin = (int) (mContext.getResources().getDisplayMetrics().density * 8);
// Horizontal mode, with AM/PM appearing to left/right of hours and minutes.
final boolean isAmPmAtLeft;
if (TextUtils.getLayoutDirectionFromLocale(mLocale) == View.LAYOUT_DIRECTION_LTR) {
@@ -461,10 +462,6 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate {
} else {
isAmPmAtLeft = !isAmPmAtStart;
}
- if (mIsAmPmAtLeft == isAmPmAtLeft) {
- // AM/PM is already at the correct location. No change needed.
- return;
- }
if (isAmPmAtLeft) {
params.removeRule(RelativeLayout.RIGHT_OF);
@@ -473,6 +470,14 @@ class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate {
params.removeRule(RelativeLayout.LEFT_OF);
params.addRule(RelativeLayout.RIGHT_OF, mMinuteView.getId());
}
+
+ if (isAmPmAtStart) {
+ params.setMarginStart(0);
+ params.setMarginEnd(margin);
+ } else {
+ params.setMarginStart(margin);
+ params.setMarginEnd(0);
+ }
mIsAmPmAtLeft = isAmPmAtLeft;
} else if (params.getRule(RelativeLayout.BELOW) != 0
|| params.getRule(RelativeLayout.ABOVE) != 0) {
diff --git a/core/res/res/layout/time_picker_header_material.xml b/core/res/res/layout/time_picker_header_material.xml
index ced1722..580c913 100644
--- a/core/res/res/layout/time_picker_header_material.xml
+++ b/core/res/res/layout/time_picker_header_material.xml
@@ -76,16 +76,14 @@
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/minutes"
android:layout_alignBaseline="@+id/minutes"
- android:paddingStart="4dp"
- android:paddingEnd="4dp"
+ android:layout_marginStart="8dp"
+ android:layout_marginEnd="0dp"
android:orientation="vertical"
android:baselineAlignedChildIndex="1">
<RadioButton
android:id="@+id/am_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="4dp"
- android:paddingRight="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:layout_marginBottom="-8dp"
@@ -101,8 +99,6 @@
android:id="@+id/pm_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:paddingLeft="4dp"
- android:paddingRight="4dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textAppearance="@style/TextAppearance.Material.TimePicker.AmPmLabel"