Methods Summary |
---|
public boolean | dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)
onPopulateAccessibilityEvent(event);
return true;
|
public static java.lang.String[] | getAmPmStrings(android.content.Context context)
String[] result = new String[2];
LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
result[0] = d.amPm[0].length() > 2 ? d.narrowAm : d.amPm[0];
result[1] = d.amPm[1].length() > 2 ? d.narrowPm : d.amPm[1];
return result;
|
public int | getBaseline()
return mHourSpinner.getBaseline();
|
public java.lang.Integer | getCurrentHour()
int currentHour = mHourSpinner.getValue();
if (is24HourView()) {
return currentHour;
} else if (mIsAm) {
return currentHour % HOURS_IN_HALF_DAY;
} else {
return (currentHour % HOURS_IN_HALF_DAY) + HOURS_IN_HALF_DAY;
}
|
public java.lang.Integer | getCurrentMinute()
return mMinuteSpinner.getValue();
|
private void | getHourFormatData()
final String bestDateTimePattern = DateFormat.getBestDateTimePattern(mCurrentLocale,
(mIs24HourView) ? "Hm" : "hm");
final int lengthPattern = bestDateTimePattern.length();
mHourWithTwoDigit = false;
char hourFormat = '\0";
// Check if the returned pattern is single or double 'H', 'h', 'K', 'k'. We also save
// the hour format that we found.
for (int i = 0; i < lengthPattern; i++) {
final char c = bestDateTimePattern.charAt(i);
if (c == 'H" || c == 'h" || c == 'K" || c == 'k") {
mHourFormat = c;
if (i + 1 < lengthPattern && c == bestDateTimePattern.charAt(i + 1)) {
mHourWithTwoDigit = true;
}
break;
}
}
|
public boolean | is24HourView()
return mIs24HourView;
|
private boolean | isAmPmAtStart()
final String bestDateTimePattern = DateFormat.getBestDateTimePattern(mCurrentLocale,
"hm" /* skeleton */);
return bestDateTimePattern.startsWith("a");
|
public boolean | isEnabled()
return mIsEnabled;
|
public void | onConfigurationChanged(android.content.res.Configuration newConfig)
setCurrentLocale(newConfig.locale);
|
public void | onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)
event.setClassName(TimePicker.class.getName());
|
public void | onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo info)
info.setClassName(TimePicker.class.getName());
|
public void | onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent event)
int flags = DateUtils.FORMAT_SHOW_TIME;
if (mIs24HourView) {
flags |= DateUtils.FORMAT_24HOUR;
} else {
flags |= DateUtils.FORMAT_12HOUR;
}
mTempCalendar.set(Calendar.HOUR_OF_DAY, getCurrentHour());
mTempCalendar.set(Calendar.MINUTE, getCurrentMinute());
String selectedDateUtterance = DateUtils.formatDateTime(mContext,
mTempCalendar.getTimeInMillis(), flags);
event.getText().add(selectedDateUtterance);
|
public void | onRestoreInstanceState(android.os.Parcelable state)
SavedState ss = (SavedState) state;
setCurrentHour(ss.getHour());
setCurrentMinute(ss.getMinute());
|
public android.os.Parcelable | onSaveInstanceState(android.os.Parcelable superState)
return new SavedState(superState, getCurrentHour(), getCurrentMinute());
|
private void | onTimeChanged()
mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
if (mOnTimeChangedListener != null) {
mOnTimeChangedListener.onTimeChanged(mDelegator, getCurrentHour(),
getCurrentMinute());
}
|
private void | setContentDescriptions()
// Minute
trySetContentDescription(mMinuteSpinner, R.id.increment,
R.string.time_picker_increment_minute_button);
trySetContentDescription(mMinuteSpinner, R.id.decrement,
R.string.time_picker_decrement_minute_button);
// Hour
trySetContentDescription(mHourSpinner, R.id.increment,
R.string.time_picker_increment_hour_button);
trySetContentDescription(mHourSpinner, R.id.decrement,
R.string.time_picker_decrement_hour_button);
// AM/PM
if (mAmPmSpinner != null) {
trySetContentDescription(mAmPmSpinner, R.id.increment,
R.string.time_picker_increment_set_pm_button);
trySetContentDescription(mAmPmSpinner, R.id.decrement,
R.string.time_picker_decrement_set_am_button);
}
|
public void | setCurrentHour(java.lang.Integer currentHour)
setCurrentHour(currentHour, true);
|
private void | setCurrentHour(java.lang.Integer currentHour, boolean notifyTimeChanged)
// why was Integer used in the first place?
if (currentHour == null || currentHour == getCurrentHour()) {
return;
}
if (!is24HourView()) {
// convert [0,23] ordinal to wall clock display
if (currentHour >= HOURS_IN_HALF_DAY) {
mIsAm = false;
if (currentHour > HOURS_IN_HALF_DAY) {
currentHour = currentHour - HOURS_IN_HALF_DAY;
}
} else {
mIsAm = true;
if (currentHour == 0) {
currentHour = HOURS_IN_HALF_DAY;
}
}
updateAmPmControl();
}
mHourSpinner.setValue(currentHour);
if (notifyTimeChanged) {
onTimeChanged();
}
|
public void | setCurrentLocale(java.util.Locale locale)Sets the current locale.
super.setCurrentLocale(locale);
mTempCalendar = Calendar.getInstance(locale);
|
public void | setCurrentMinute(java.lang.Integer currentMinute)
if (currentMinute == getCurrentMinute()) {
return;
}
mMinuteSpinner.setValue(currentMinute);
onTimeChanged();
|
private void | setDividerText()The time separator is defined in the Unicode CLDR and cannot be supposed to be ":".
See http://unicode.org/cldr/trac/browser/trunk/common/main
We pass the correct "skeleton" depending on 12 or 24 hours view and then extract the
separator as the character which is just after the hour marker in the returned pattern.
final String skeleton = (mIs24HourView) ? "Hm" : "hm";
final String bestDateTimePattern = DateFormat.getBestDateTimePattern(mCurrentLocale,
skeleton);
final String separatorText;
int hourIndex = bestDateTimePattern.lastIndexOf('H");
if (hourIndex == -1) {
hourIndex = bestDateTimePattern.lastIndexOf('h");
}
if (hourIndex == -1) {
// Default case
separatorText = ":";
} else {
int minuteIndex = bestDateTimePattern.indexOf('m", hourIndex + 1);
if (minuteIndex == -1) {
separatorText = Character.toString(bestDateTimePattern.charAt(hourIndex + 1));
} else {
separatorText = bestDateTimePattern.substring(hourIndex + 1, minuteIndex);
}
}
mDivider.setText(separatorText);
|
public void | setEnabled(boolean enabled)
mMinuteSpinner.setEnabled(enabled);
if (mDivider != null) {
mDivider.setEnabled(enabled);
}
mHourSpinner.setEnabled(enabled);
if (mAmPmSpinner != null) {
mAmPmSpinner.setEnabled(enabled);
} else {
mAmPmButton.setEnabled(enabled);
}
mIsEnabled = enabled;
|
public void | setIs24HourView(java.lang.Boolean is24HourView)
if (mIs24HourView == is24HourView) {
return;
}
// cache the current hour since spinner range changes and BEFORE changing mIs24HourView!!
int currentHour = getCurrentHour();
// Order is important here.
mIs24HourView = is24HourView;
getHourFormatData();
updateHourControl();
// set value after spinner range is updated
setCurrentHour(currentHour, false);
updateMinuteControl();
updateAmPmControl();
|
public void | setOnTimeChangedListener(TimePicker.OnTimeChangedListener onTimeChangedListener)
mOnTimeChangedListener = onTimeChangedListener;
|
private void | trySetContentDescription(android.view.View root, int viewId, int contDescResId)
View target = root.findViewById(viewId);
if (target != null) {
target.setContentDescription(mContext.getString(contDescResId));
}
|
private void | updateAmPmControl()
if (is24HourView()) {
if (mAmPmSpinner != null) {
mAmPmSpinner.setVisibility(View.GONE);
} else {
mAmPmButton.setVisibility(View.GONE);
}
} else {
int index = mIsAm ? Calendar.AM : Calendar.PM;
if (mAmPmSpinner != null) {
mAmPmSpinner.setValue(index);
mAmPmSpinner.setVisibility(View.VISIBLE);
} else {
mAmPmButton.setText(mAmPmStrings[index]);
mAmPmButton.setVisibility(View.VISIBLE);
}
}
mDelegator.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
|
private void | updateHourControl()
if (is24HourView()) {
// 'k' means 1-24 hour
if (mHourFormat == 'k") {
mHourSpinner.setMinValue(1);
mHourSpinner.setMaxValue(24);
} else {
mHourSpinner.setMinValue(0);
mHourSpinner.setMaxValue(23);
}
} else {
// 'K' means 0-11 hour
if (mHourFormat == 'K") {
mHourSpinner.setMinValue(0);
mHourSpinner.setMaxValue(11);
} else {
mHourSpinner.setMinValue(1);
mHourSpinner.setMaxValue(12);
}
}
mHourSpinner.setFormatter(mHourWithTwoDigit ? NumberPicker.getTwoDigitFormatter() : null);
|
private void | updateInputState()
// Make sure that if the user changes the value and the IME is active
// for one of the inputs if this widget, the IME is closed. If the user
// changed the value via the IME and there is a next input the IME will
// be shown, otherwise the user chose another means of changing the
// value and having the IME up makes no sense.
InputMethodManager inputMethodManager = InputMethodManager.peekInstance();
if (inputMethodManager != null) {
if (inputMethodManager.isActive(mHourSpinnerInput)) {
mHourSpinnerInput.clearFocus();
inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
} else if (inputMethodManager.isActive(mMinuteSpinnerInput)) {
mMinuteSpinnerInput.clearFocus();
inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
} else if (inputMethodManager.isActive(mAmPmSpinnerInput)) {
mAmPmSpinnerInput.clearFocus();
inputMethodManager.hideSoftInputFromWindow(mDelegator.getWindowToken(), 0);
}
}
|
private void | updateMinuteControl()
if (is24HourView()) {
mMinuteSpinnerInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
} else {
mMinuteSpinnerInput.setImeOptions(EditorInfo.IME_ACTION_NEXT);
}
|