Merge "resolved conflicts for merge of 99cd6671 to master"
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java
index f8c76f2..3b16994 100644
--- a/core/java/android/widget/CalendarView.java
+++ b/core/java/android/widget/CalendarView.java
@@ -21,6 +21,7 @@
import android.annotation.Widget;
import android.app.Service;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Canvas;
@@ -239,21 +240,11 @@
private String[] mDayLabels;
/**
- * Temporary instance to avoid multiple instantiations.
- */
- private Calendar mTempDate = Calendar.getInstance();
-
- /**
* The first day of the week.
*/
private int mFirstDayOfWeek;
/**
- * The first day of the focused month.
- */
- private Calendar mFirstDayOfMonth = Calendar.getInstance();
-
- /**
* Which month should be displayed/highlighted [0-11].
*/
private int mCurrentMonthDisplayed;
@@ -289,14 +280,24 @@
private ScrollStateRunnable mScrollStateChangedRunnable = new ScrollStateRunnable();
/**
+ * Temporary instance to avoid multiple instantiations.
+ */
+ private Calendar mTempDate;
+
+ /**
+ * The first day of the focused month.
+ */
+ private Calendar mFirstDayOfMonth;
+
+ /**
* The start date of the range supported by this picker.
*/
- private Calendar mMinDate = Calendar.getInstance();
+ private Calendar mMinDate;
/**
* The end date of the range supported by this picker.
*/
- private Calendar mMaxDate = Calendar.getInstance();
+ private Calendar mMaxDate;
/**
* Date format for parsing dates.
@@ -304,6 +305,11 @@
private final java.text.DateFormat mDateFormat = new SimpleDateFormat(DATE_FORMAT);
/**
+ * The current locale.
+ */
+ private Locale mCurrentLocale;
+
+ /**
* The callback used to indicate the user changes the date.
*/
public interface OnDateChangeListener {
@@ -330,6 +336,9 @@
public CalendarView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, 0);
+ // initialization based on locale
+ setCurrentLocale(Locale.getDefault());
+
TypedValue calendarViewStyle = new TypedValue();
context.getTheme().resolveAttribute(R.attr.calendarViewStyle, calendarViewStyle, true);
TypedArray attributesArray = context.obtainStyledAttributes(calendarViewStyle.resourceId,
@@ -413,6 +422,12 @@
return mListView.isEnabled();
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ setCurrentLocale(newConfig.locale);
+ }
+
/**
* Gets the minimal date supported by this {@link CalendarView} in milliseconds
* since January 1, 1970 00:00:00 in {@link TimeZone#getDefault()} time
@@ -624,6 +639,41 @@
}
/**
+ * Sets the current locale.
+ *
+ * @param locale The current locale.
+ */
+ private void setCurrentLocale(Locale locale) {
+ if (locale.equals(mCurrentLocale)) {
+ return;
+ }
+
+ mCurrentLocale = locale;
+
+ mTempDate = getCalendarForLocale(mTempDate, locale);
+ mFirstDayOfMonth = getCalendarForLocale(mFirstDayOfMonth, locale);
+ mMinDate = getCalendarForLocale(mMinDate, locale);
+ mMaxDate = getCalendarForLocale(mMaxDate, locale);
+ }
+
+ /**
+ * Gets a calendar for locale bootstrapped with the value of a given calendar.
+ *
+ * @param oldCalendar The old calendar.
+ * @param locale The locale.
+ */
+ private Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) {
+ if (oldCalendar == null) {
+ return Calendar.getInstance(locale);
+ } else {
+ final long currentTimeMillis = oldCalendar.getTimeInMillis();
+ Calendar newCalendar = Calendar.getInstance(locale);
+ newCalendar.setTimeInMillis(currentTimeMillis);
+ return newCalendar;
+ }
+ }
+
+ /**
* @return True if the <code>firstDate</code> is the same as the <code>
* secondDate</code>.
*/
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 30fb927..4812283 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -16,10 +16,9 @@
package android.widget;
-import com.android.internal.R;
-
import android.annotation.Widget;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
@@ -33,6 +32,8 @@
import android.view.accessibility.AccessibilityEvent;
import android.widget.NumberPicker.OnValueChangeListener;
+import com.android.internal.R;
+
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -89,23 +90,23 @@
private final CalendarView mCalendarView;
+ private Locale mCurrentLocale;
+
private OnDateChangedListener mOnDateChangedListener;
- private Locale mMonthLocale;
-
- private final Calendar mTempDate = Calendar.getInstance();
-
- private final int mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1;
-
- private final String[] mShortMonths = new String[mNumberOfMonths];
+ private String[] mShortMonths;
private final java.text.DateFormat mDateFormat = new SimpleDateFormat(DATE_FORMAT);
- private final Calendar mMinDate = Calendar.getInstance();
+ private int mNumberOfMonths;
- private final Calendar mMaxDate = Calendar.getInstance();
+ private Calendar mTempDate;
- private final Calendar mCurrentDate = Calendar.getInstance();
+ private Calendar mMinDate;
+
+ private Calendar mMaxDate;
+
+ private Calendar mCurrentDate;
private boolean mIsEnabled = DEFAULT_ENABLED_STATE;
@@ -137,6 +138,9 @@
public DatePicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ // initialization based on locale
+ setCurrentLocale(Locale.getDefault());
+
TypedArray attributesArray = context.obtainStyledAttributes(attrs, R.styleable.DatePicker,
defStyle, 0);
boolean spinnersShown = attributesArray.getBoolean(R.styleable.DatePicker_spinnersShown,
@@ -213,7 +217,7 @@
mMonthSpinner = (NumberPicker) findViewById(R.id.month);
mMonthSpinner.setMinValue(0);
mMonthSpinner.setMaxValue(mNumberOfMonths - 1);
- mMonthSpinner.setDisplayedValues(getShortMonths());
+ mMonthSpinner.setDisplayedValues(mShortMonths);
mMonthSpinner.setOnLongPressUpdateInterval(200);
mMonthSpinner.setOnValueChangedListener(onChangeListener);
@@ -363,6 +367,12 @@
event.getText().add(selectedDateUtterance);
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ setCurrentLocale(newConfig.locale);
+ }
+
/**
* Gets whether the {@link CalendarView} is shown.
*
@@ -411,6 +421,48 @@
}
/**
+ * Sets the current locale.
+ *
+ * @param locale The current locale.
+ */
+ private void setCurrentLocale(Locale locale) {
+ if (locale.equals(mCurrentLocale)) {
+ return;
+ }
+
+ mCurrentLocale = locale;
+
+ mTempDate = getCalendarForLocale(mTempDate, locale);
+ mMinDate = getCalendarForLocale(mMinDate, locale);
+ mMaxDate = getCalendarForLocale(mMaxDate, locale);
+ mCurrentDate = getCalendarForLocale(mCurrentDate, locale);
+
+ mNumberOfMonths = mTempDate.getActualMaximum(Calendar.MONTH) + 1;
+ mShortMonths = new String[mNumberOfMonths];
+ for (int i = 0; i < mNumberOfMonths; i++) {
+ mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i,
+ DateUtils.LENGTH_MEDIUM);
+ }
+ }
+
+ /**
+ * Gets a calendar for locale bootstrapped with the value of a given calendar.
+ *
+ * @param oldCalendar The old calendar.
+ * @param locale The locale.
+ */
+ private Calendar getCalendarForLocale(Calendar oldCalendar, Locale locale) {
+ if (oldCalendar == null) {
+ return Calendar.getInstance(locale);
+ } else {
+ final long currentTimeMillis = oldCalendar.getTimeInMillis();
+ Calendar newCalendar = Calendar.getInstance(locale);
+ newCalendar.setTimeInMillis(currentTimeMillis);
+ return newCalendar;
+ }
+ }
+
+ /**
* Reorders the spinners according to the date format that is
* explicitly set by the user and if no such is set fall back
* to the current locale's default format.
@@ -507,23 +559,6 @@
}
}
- /**
- * @return The short month abbreviations.
- */
- private String[] getShortMonths() {
- final Locale currentLocale = Locale.getDefault();
- if (currentLocale.equals(mMonthLocale)) {
- return mShortMonths;
- } else {
- for (int i = 0; i < mNumberOfMonths; i++) {
- mShortMonths[i] = DateUtils.getMonthString(Calendar.JANUARY + i,
- DateUtils.LENGTH_MEDIUM);
- }
- mMonthLocale = currentLocale;
- return mShortMonths;
- }
- }
-
private boolean isNewDate(int year, int month, int dayOfMonth) {
return (mCurrentDate.get(Calendar.YEAR) != year
|| mCurrentDate.get(Calendar.MONTH) != dayOfMonth
@@ -569,7 +604,7 @@
// make sure the month names are a zero based array
// with the months in the month spinner
- String[] displayedValues = Arrays.copyOfRange(getShortMonths(),
+ String[] displayedValues = Arrays.copyOfRange(mShortMonths,
mMonthSpinner.getMinValue(), mMonthSpinner.getMaxValue() + 1);
mMonthSpinner.setDisplayedValues(displayedValues);
diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java
index 423e735c..0547438 100644
--- a/core/java/android/widget/TimePicker.java
+++ b/core/java/android/widget/TimePicker.java
@@ -20,6 +20,7 @@
import android.annotation.Widget;
import android.content.Context;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
@@ -32,6 +33,7 @@
import java.text.DateFormatSymbols;
import java.util.Calendar;
+import java.util.Locale;
/**
* A view for selecting the time of day, in either 24 hour or AM/PM mode. The
@@ -92,6 +94,8 @@
private Calendar mTempCalendar;
+ private Locale mCurrentLocale;
+
/**
* The callback interface used to indicate the time has been adjusted.
*/
@@ -116,6 +120,9 @@
public TimePicker(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ // initialization based on locale
+ setCurrentLocale(Locale.getDefault());
+
// process style attributes
TypedArray attributesArray = context.obtainStyledAttributes(
attrs, R.styleable.TimePicker, defStyle, 0);
@@ -211,8 +218,6 @@
updateHourControl();
updateAmPmControl();
- // initialize to current time
- mTempCalendar = Calendar.getInstance();
setOnTimeChangedListener(NO_OP_CHANGE_LISTENER);
// set to current time
@@ -248,6 +253,25 @@
return mIsEnabled;
}
+ @Override
+ protected void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ setCurrentLocale(newConfig.locale);
+ }
+
+ /**
+ * Sets the current locale.
+ *
+ * @param locale The current locale.
+ */
+ private void setCurrentLocale(Locale locale) {
+ if (locale.equals(mCurrentLocale)) {
+ return;
+ }
+ mCurrentLocale = locale;
+ mTempCalendar = Calendar.getInstance(locale);
+ }
+
/**
* Used to save / restore state of time picker
*/
diff --git a/include/media/stagefright/MetadataBufferType.h b/include/media/stagefright/MetadataBufferType.h
index 275c19f..52a3257 100644
--- a/include/media/stagefright/MetadataBufferType.h
+++ b/include/media/stagefright/MetadataBufferType.h
@@ -17,7 +17,11 @@
#ifndef METADATA_BUFFER_TYPE_H
#define METADATA_BUFFER_TYPE_H
+#ifdef __cplusplus
+extern "C" {
namespace android {
+#endif
+
/*
* MetadataBufferType defines the type of the metadata buffers that
* can be passed to video encoder component for encoding, via Stagefright
@@ -72,6 +76,9 @@
} MetadataBufferType;
+#ifdef __cplusplus
} // namespace android
+}
+#endif
#endif // METADATA_BUFFER_TYPE_H
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java
index 32d1a23..3f547fd 100644
--- a/opengl/java/android/opengl/GLSurfaceView.java
+++ b/opengl/java/android/opengl/GLSurfaceView.java
@@ -88,7 +88,7 @@
* well as how many bits are allocated to each channel. Therefore, the first thing
* GLSurfaceView has to do when starting to render is choose what EGLConfig to use.
* <p>
- * By default GLSurfaceView chooses a EGLConfig that has an RGB_656 pixel format,
+ * By default GLSurfaceView chooses a EGLConfig that has an RGB_565 pixel format,
* with at least a 16-bit depth buffer and no stencil.
* <p>
* If you would prefer a different EGLConfig