* introduced a new method (getFormattedCurrentDate) which formats
the date for all DatePickerDelegates
* implemented (moved) onPopulateAccessibilityEvent in the
AbstractDatePickerDelegate thus all announcements for date pickers
use the same format
* note: added FORMAT_SHOW_WEEKDAY to the current format because
I find the information valuable
E.g:
* Before: "Thu Jun 16 11:49:14 GMT+01:00 2016"
* Now: "Thursday, 16 June 2016"
Bug:
29099922
Change-Id: I94447067f10659747ae310f9e07cf3f487c97e05
import android.icu.util.TimeZone;
import android.os.Parcel;
import android.os.Parcelable;
+import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.view.View;
// The context
protected Context mContext;
+ protected Calendar mCurrentDate;
+
// The current locale
protected Locale mCurrentLocale;
// Stub.
}
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ event.getText().add(getFormattedCurrentDate());
+ }
+
+ protected String getFormattedCurrentDate() {
+ return DateUtils.formatDateTime(mContext, mCurrentDate.getTimeInMillis(),
+ DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR
+ | DateUtils.FORMAT_SHOW_WEEKDAY);
+ }
+
/**
* Class for managing state storing/restoring.
*/
import android.icu.util.Calendar;
import android.os.Parcelable;
import android.text.format.DateFormat;
-import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.util.StateSet;
import android.view.HapticFeedbackConstants;
private int mCurrentView = UNINITIALIZED;
- private final Calendar mCurrentDate;
private final Calendar mTempDate;
private final Calendar mMinDate;
private final Calendar mMaxDate;
// TODO: This should use live regions.
if (announce) {
- final long millis = mCurrentDate.getTimeInMillis();
- final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
- final String fullDateText = DateUtils.formatDateTime(mContext, millis, flags);
- mAnimator.announceForAccessibility(fullDateText);
+ mAnimator.announceForAccessibility(getFormattedCurrentDate());
}
}
return true;
}
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- event.getText().add(mCurrentDate.getTime().toString());
- }
-
public CharSequence getAccessibilityClassName() {
return DatePicker.class.getName();
}
import android.text.InputType;
import android.text.TextUtils;
import android.text.format.DateFormat;
-import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
private Calendar mMaxDate;
- private Calendar mCurrentDate;
-
private boolean mIsEnabled = DEFAULT_ENABLED_STATE;
DatePickerSpinnerDelegate(DatePicker delegator, Context context, AttributeSet attrs,
return true;
}
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR;
- String selectedDateUtterance = DateUtils.formatDateTime(mContext,
- mCurrentDate.getTimeInMillis(), flags);
- event.getText().add(selectedDateUtterance);
- }
-
/**
* Sets the current locale.
*