Loading core/java/android/widget/TextInputTimePickerView.java +29 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.os.LocaleList; import android.text.Editable; import android.text.InputFilter; import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; import android.util.MathUtils; Loading Loading @@ -55,6 +56,7 @@ public class TextInputTimePickerView extends RelativeLayout { private OnValueTypedListener mListener; private boolean mErrorShowing; private boolean mTimeSet; interface OnValueTypedListener { void onValueChanged(int inputType, int newValue); Loading Loading @@ -155,8 +157,15 @@ public class TextInputTimePickerView extends RelativeLayout { } boolean validateInput() { final boolean inputValid = parseAndSetHourInternal(mHourEditText.getText().toString()) && parseAndSetMinuteInternal(mMinuteEditText.getText().toString()); final String hourText = TextUtils.isEmpty(mHourEditText.getText()) ? mHourEditText.getHint().toString() : mHourEditText.getText().toString(); final String minuteText = TextUtils.isEmpty(mMinuteEditText.getText()) ? mMinuteEditText.getHint().toString() : mMinuteEditText.getText().toString(); final boolean inputValid = parseAndSetHourInternal(hourText) && parseAndSetMinuteInternal(minuteText); setError(!inputValid); return inputValid; } Loading @@ -173,6 +182,14 @@ public class TextInputTimePickerView extends RelativeLayout { mMinuteLabel.setVisibility(enabled ? View.INVISIBLE : View.VISIBLE); } private void setTimeSet(boolean timeSet) { mTimeSet = mTimeSet || timeSet; } private boolean isTimeSet() { return mTimeSet; } /** * Computes the display value and updates the text of the view. * <p> Loading @@ -195,8 +212,14 @@ public class TextInputTimePickerView extends RelativeLayout { mAmPmSpinner.setSelection(1); } if (isTimeSet()) { mHourEditText.setText(String.format(hourFormat, localizedHour)); mMinuteEditText.setText(String.format(minuteFormat, minute)); } else { mHourEditText.setHint(String.format(hourFormat, localizedHour)); mMinuteEditText.setHint(String.format(minuteFormat, minute)); } if (mErrorShowing) { validateInput(); Loading @@ -214,6 +237,7 @@ public class TextInputTimePickerView extends RelativeLayout { return false; } mListener.onValueChanged(HOURS, getHourOfDayFromLocalizedHour(hour)); setTimeSet(true); return true; } catch (NumberFormatException e) { // Do nothing since we cannot parse the input. Loading @@ -229,6 +253,7 @@ public class TextInputTimePickerView extends RelativeLayout { return false; } mListener.onValueChanged(MINUTES, minutes); setTimeSet(true); return true; } catch (NumberFormatException e) { // Do nothing since we cannot parse the input. Loading core/res/res/layout/time_picker_header_material.xml +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ android:textAppearance="@style/TextAppearance.Material.TimePicker.TimeLabel" android:importantForAccessibility="no" /> <!-- The minutes should always be to the left of the separator, <!-- The minutes should always be to the right of the separator, regardless of the current locale's layout direction. --> <com.android.internal.widget.NumericTextView android:id="@+id/minutes" Loading Loading
core/java/android/widget/TextInputTimePickerView.java +29 −4 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import android.content.Context; import android.os.LocaleList; import android.text.Editable; import android.text.InputFilter; import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; import android.util.MathUtils; Loading Loading @@ -55,6 +56,7 @@ public class TextInputTimePickerView extends RelativeLayout { private OnValueTypedListener mListener; private boolean mErrorShowing; private boolean mTimeSet; interface OnValueTypedListener { void onValueChanged(int inputType, int newValue); Loading Loading @@ -155,8 +157,15 @@ public class TextInputTimePickerView extends RelativeLayout { } boolean validateInput() { final boolean inputValid = parseAndSetHourInternal(mHourEditText.getText().toString()) && parseAndSetMinuteInternal(mMinuteEditText.getText().toString()); final String hourText = TextUtils.isEmpty(mHourEditText.getText()) ? mHourEditText.getHint().toString() : mHourEditText.getText().toString(); final String minuteText = TextUtils.isEmpty(mMinuteEditText.getText()) ? mMinuteEditText.getHint().toString() : mMinuteEditText.getText().toString(); final boolean inputValid = parseAndSetHourInternal(hourText) && parseAndSetMinuteInternal(minuteText); setError(!inputValid); return inputValid; } Loading @@ -173,6 +182,14 @@ public class TextInputTimePickerView extends RelativeLayout { mMinuteLabel.setVisibility(enabled ? View.INVISIBLE : View.VISIBLE); } private void setTimeSet(boolean timeSet) { mTimeSet = mTimeSet || timeSet; } private boolean isTimeSet() { return mTimeSet; } /** * Computes the display value and updates the text of the view. * <p> Loading @@ -195,8 +212,14 @@ public class TextInputTimePickerView extends RelativeLayout { mAmPmSpinner.setSelection(1); } if (isTimeSet()) { mHourEditText.setText(String.format(hourFormat, localizedHour)); mMinuteEditText.setText(String.format(minuteFormat, minute)); } else { mHourEditText.setHint(String.format(hourFormat, localizedHour)); mMinuteEditText.setHint(String.format(minuteFormat, minute)); } if (mErrorShowing) { validateInput(); Loading @@ -214,6 +237,7 @@ public class TextInputTimePickerView extends RelativeLayout { return false; } mListener.onValueChanged(HOURS, getHourOfDayFromLocalizedHour(hour)); setTimeSet(true); return true; } catch (NumberFormatException e) { // Do nothing since we cannot parse the input. Loading @@ -229,6 +253,7 @@ public class TextInputTimePickerView extends RelativeLayout { return false; } mListener.onValueChanged(MINUTES, minutes); setTimeSet(true); return true; } catch (NumberFormatException e) { // Do nothing since we cannot parse the input. Loading
core/res/res/layout/time_picker_header_material.xml +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ android:textAppearance="@style/TextAppearance.Material.TimePicker.TimeLabel" android:importantForAccessibility="no" /> <!-- The minutes should always be to the left of the separator, <!-- The minutes should always be to the right of the separator, regardless of the current locale's layout direction. --> <com.android.internal.widget.NumericTextView android:id="@+id/minutes" Loading