summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/PendingIntent.java18
-rw-r--r--core/java/android/content/res/Configuration.java8
-rw-r--r--core/java/android/database/DatabaseUtils.java12
-rw-r--r--core/java/android/database/sqlite/SQLiteConnection.java2
-rw-r--r--core/java/android/net/EthernetDataTracker.java1
-rw-r--r--core/java/android/preference/Preference.java3
-rw-r--r--core/java/android/text/format/DateFormat.java31
-rw-r--r--core/java/android/view/View.java5
-rw-r--r--core/java/android/view/ViewGroup.java2
-rw-r--r--core/java/android/widget/CalendarView.java2
-rw-r--r--core/java/android/widget/DatePicker.java42
-rw-r--r--core/java/android/widget/HeaderViewListAdapter.java12
12 files changed, 75 insertions, 63 deletions
diff --git a/core/java/android/app/PendingIntent.java b/core/java/android/app/PendingIntent.java
index 2897ee0..97de4f4 100644
--- a/core/java/android/app/PendingIntent.java
+++ b/core/java/android/app/PendingIntent.java
@@ -202,8 +202,7 @@ public final class PendingIntent implements Parcelable {
*
* @param context The Context in which this PendingIntent should start
* the activity.
- * @param requestCode Private request code for the sender (currently
- * not used).
+ * @param requestCode Private request code for the sender
* @param intent Intent of the activity to be launched.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
@@ -229,8 +228,7 @@ public final class PendingIntent implements Parcelable {
*
* @param context The Context in which this PendingIntent should start
* the activity.
- * @param requestCode Private request code for the sender (currently
- * not used).
+ * @param requestCode Private request code for the sender
* @param intent Intent of the activity to be launched.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
@@ -315,8 +313,7 @@ public final class PendingIntent implements Parcelable {
*
* @param context The Context in which this PendingIntent should start
* the activity.
- * @param requestCode Private request code for the sender (currently
- * not used).
+ * @param requestCode Private request code for the sender
* @param intents Array of Intents of the activities to be launched.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
@@ -361,8 +358,7 @@ public final class PendingIntent implements Parcelable {
*
* @param context The Context in which this PendingIntent should start
* the activity.
- * @param requestCode Private request code for the sender (currently
- * not used).
+ * @param requestCode Private request code for the sender
* @param intents Array of Intents of the activities to be launched.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
@@ -425,8 +421,7 @@ public final class PendingIntent implements Parcelable {
*
* @param context The Context in which this PendingIntent should perform
* the broadcast.
- * @param requestCode Private request code for the sender (currently
- * not used).
+ * @param requestCode Private request code for the sender
* @param intent The Intent to be broadcast.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
@@ -475,8 +470,7 @@ public final class PendingIntent implements Parcelable {
*
* @param context The Context in which this PendingIntent should start
* the service.
- * @param requestCode Private request code for the sender (currently
- * not used).
+ * @param requestCode Private request code for the sender
* @param intent An Intent describing the service to be started.
* @param flags May be {@link #FLAG_ONE_SHOT}, {@link #FLAG_NO_CREATE},
* {@link #FLAG_CANCEL_CURRENT}, {@link #FLAG_UPDATE_CURRENT},
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index 86d6ee7..add8399 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -853,11 +853,13 @@ public final class Configuration implements Parcelable, Comparable<Configuration
changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
screenHeightDp = delta.screenHeightDp;
}
- if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED) {
- changed |= ActivityInfo.CONFIG_SCREEN_SIZE;
+ if (delta.smallestScreenWidthDp != SMALLEST_SCREEN_WIDTH_DP_UNDEFINED
+ && smallestScreenWidthDp != delta.smallestScreenWidthDp) {
+ changed |= ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
smallestScreenWidthDp = delta.smallestScreenWidthDp;
}
- if (delta.densityDpi != DENSITY_DPI_UNDEFINED) {
+ if (delta.densityDpi != DENSITY_DPI_UNDEFINED &&
+ densityDpi != delta.densityDpi) {
changed |= ActivityInfo.CONFIG_DENSITY;
densityDpi = delta.densityDpi;
}
diff --git a/core/java/android/database/DatabaseUtils.java b/core/java/android/database/DatabaseUtils.java
index 1fc1226..e2d9724 100644
--- a/core/java/android/database/DatabaseUtils.java
+++ b/core/java/android/database/DatabaseUtils.java
@@ -792,6 +792,18 @@ public class DatabaseUtils {
}
/**
+ * Query the table to check whether a table is empty or not
+ * @param db the database the table is in
+ * @param table the name of the table to query
+ * @return True if the table is empty
+ * @hide
+ */
+ public static boolean queryIsEmpty(SQLiteDatabase db, String table) {
+ long isEmpty = longForQuery(db, "select exists(select 1 from " + table + ")", null);
+ return isEmpty == 0;
+ }
+
+ /**
* Utility method to run the query on the db and return the value in the
* first column of the first row.
*/
diff --git a/core/java/android/database/sqlite/SQLiteConnection.java b/core/java/android/database/sqlite/SQLiteConnection.java
index 0017c46..747f162 100644
--- a/core/java/android/database/sqlite/SQLiteConnection.java
+++ b/core/java/android/database/sqlite/SQLiteConnection.java
@@ -30,9 +30,9 @@ import android.util.Log;
import android.util.LruCache;
import android.util.Printer;
-import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Map;
import java.util.regex.Pattern;
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 37601fc..d587e68 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -178,6 +178,7 @@ public class EthernetDataTracker implements NetworkStateTracker {
mLinkProperties = dhcpInfoInternal.makeLinkProperties();
mLinkProperties.setInterfaceName(mIface);
+ mNetworkInfo.setIsAvailable(true);
mNetworkInfo.setDetailedState(DetailedState.CONNECTED, null, mHwAddr);
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
msg.sendToTarget();
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index e343e83..6c02965 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -1072,6 +1072,9 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
|| (mOrder == DEFAULT_ORDER && another.mOrder != DEFAULT_ORDER)) {
// Do order comparison
return mOrder - another.mOrder;
+ } else if (mTitle == another.mTitle) {
+ // If titles are null or share same object comparison
+ return 0;
} else if (mTitle == null) {
return 1;
} else if (another.mTitle == null) {
diff --git a/core/java/android/text/format/DateFormat.java b/core/java/android/text/format/DateFormat.java
index 50b1a29..ff5106a 100644
--- a/core/java/android/text/format/DateFormat.java
+++ b/core/java/android/text/format/DateFormat.java
@@ -31,6 +31,7 @@ import java.util.Locale;
import java.util.TimeZone;
import java.text.SimpleDateFormat;
+import libcore.icu.ICU;
import libcore.icu.LocaleData;
/**
@@ -278,39 +279,13 @@ public class DateFormat {
* Gets the current date format stored as a char array. The array will contain
* 3 elements ({@link #DATE}, {@link #MONTH}, and {@link #YEAR}) in the order
* specified by the user's format preference. Note that this order is
- * only appropriate for all-numeric dates; spelled-out (MEDIUM and LONG)
+ * <i>only</i> appropriate for all-numeric dates; spelled-out (MEDIUM and LONG)
* dates will generally contain other punctuation, spaces, or words,
* not just the day, month, and year, and not necessarily in the same
* order returned here.
*/
public static char[] getDateFormatOrder(Context context) {
- char[] order = new char[] {DATE, MONTH, YEAR};
- String value = getDateFormatString(context);
- int index = 0;
- boolean foundDate = false;
- boolean foundMonth = false;
- boolean foundYear = false;
-
- for (char c : value.toCharArray()) {
- if (!foundDate && (c == DATE)) {
- foundDate = true;
- order[index] = DATE;
- index++;
- }
-
- if (!foundMonth && (c == MONTH || c == STANDALONE_MONTH)) {
- foundMonth = true;
- order[index] = MONTH;
- index++;
- }
-
- if (!foundYear && (c == YEAR)) {
- foundYear = true;
- order[index] = YEAR;
- index++;
- }
- }
- return order;
+ return ICU.getDateFormatOrder(getDateFormatString(context));
}
private static String getDateFormatString(Context context) {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 0d2141f..75b8e97 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -10525,8 +10525,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* handler can be used to pump events in the UI events queue.
*/
public Handler getHandler() {
- if (mAttachInfo != null) {
- return mAttachInfo.mHandler;
+ final AttachInfo attachInfo = mAttachInfo;
+ if (attachInfo != null) {
+ return attachInfo.mHandler;
}
return null;
}
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index dbbcde6..c2676f1 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -1472,9 +1472,9 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
if (lastHoverTarget != null) {
lastHoverTarget.next = hoverTarget;
} else {
- lastHoverTarget = hoverTarget;
mFirstHoverTarget = hoverTarget;
}
+ lastHoverTarget = hoverTarget;
// Dispatch the event to the child.
if (action == MotionEvent.ACTION_HOVER_ENTER) {
diff --git a/core/java/android/widget/CalendarView.java b/core/java/android/widget/CalendarView.java
index 361eca4..a19c6a8 100644
--- a/core/java/android/widget/CalendarView.java
+++ b/core/java/android/widget/CalendarView.java
@@ -247,7 +247,7 @@ public class CalendarView extends FrameLayout {
/**
* Which month should be displayed/highlighted [0-11].
*/
- private int mCurrentMonthDisplayed;
+ private int mCurrentMonthDisplayed = -1;
/**
* Used for tracking during a scroll.
diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java
index 07d3a7a..fdf8e78 100644
--- a/core/java/android/widget/DatePicker.java
+++ b/core/java/android/widget/DatePicker.java
@@ -23,6 +23,7 @@ import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
+import android.text.InputType;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.util.AttributeSet;
@@ -38,6 +39,7 @@ import android.widget.NumberPicker.OnValueChangeListener;
import com.android.internal.R;
+import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
@@ -45,6 +47,8 @@ import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
+import libcore.icu.ICU;
+
/**
* This class is a widget for selecting a date. The date can be selected by a
* year, month, and day spinners or a {@link CalendarView}. The set of spinners
@@ -477,14 +481,27 @@ public class DatePicker extends FrameLayout {
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);
+ mShortMonths = new DateFormatSymbols().getShortMonths();
+
+ if (usingNumericMonths()) {
+ // We're in a locale where a date should either be all-numeric, or all-text.
+ // All-text would require custom NumberPicker formatters for day and year.
+ mShortMonths = new String[mNumberOfMonths];
+ for (int i = 0; i < mNumberOfMonths; ++i) {
+ mShortMonths[i] = String.format("%d", i + 1);
+ }
}
}
/**
+ * Tests whether the current locale is one where there are no real month names,
+ * such as Chinese, Japanese, or Korean locales.
+ */
+ private boolean usingNumericMonths() {
+ return Character.isDigit(mShortMonths[Calendar.JANUARY].charAt(0));
+ }
+
+ /**
* Gets a calendar for locale bootstrapped with the value of a given calendar.
*
* @param oldCalendar The old calendar.
@@ -508,24 +525,27 @@ public class DatePicker extends FrameLayout {
*/
private void reorderSpinners() {
mSpinners.removeAllViews();
- char[] order = DateFormat.getDateFormatOrder(getContext());
+ // We use numeric spinners for year and day, but textual months. Ask icu4c what
+ // order the user's locale uses for that combination. http://b/7207103.
+ String pattern = ICU.getBestDateTimePattern("yyyyMMMdd", Locale.getDefault().toString());
+ char[] order = ICU.getDateFormatOrder(pattern);
final int spinnerCount = order.length;
for (int i = 0; i < spinnerCount; i++) {
switch (order[i]) {
- case DateFormat.DATE:
+ case 'd':
mSpinners.addView(mDaySpinner);
setImeOptions(mDaySpinner, spinnerCount, i);
break;
- case DateFormat.MONTH:
+ case 'M':
mSpinners.addView(mMonthSpinner);
setImeOptions(mMonthSpinner, spinnerCount, i);
break;
- case DateFormat.YEAR:
+ case 'y':
mSpinners.addView(mYearSpinner);
setImeOptions(mYearSpinner, spinnerCount, i);
break;
default:
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException(Arrays.toString(order));
}
}
}
@@ -660,6 +680,10 @@ public class DatePicker extends FrameLayout {
mYearSpinner.setValue(mCurrentDate.get(Calendar.YEAR));
mMonthSpinner.setValue(mCurrentDate.get(Calendar.MONTH));
mDaySpinner.setValue(mCurrentDate.get(Calendar.DAY_OF_MONTH));
+
+ if (usingNumericMonths()) {
+ mMonthSpinnerInput.setRawInputType(InputType.TYPE_CLASS_NUMBER);
+ }
}
/**
diff --git a/core/java/android/widget/HeaderViewListAdapter.java b/core/java/android/widget/HeaderViewListAdapter.java
index 0685e61..222f108 100644
--- a/core/java/android/widget/HeaderViewListAdapter.java
+++ b/core/java/android/widget/HeaderViewListAdapter.java
@@ -145,7 +145,7 @@ public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
}
public boolean isEnabled(int position) {
- // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+ // Header (negative positions will throw an IndexOutOfBoundsException)
int numHeaders = getHeadersCount();
if (position < numHeaders) {
return mHeaderViewInfos.get(position).isSelectable;
@@ -161,12 +161,12 @@ public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
}
}
- // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+ // Footer (off-limits positions will throw an IndexOutOfBoundsException)
return mFooterViewInfos.get(adjPosition - adapterCount).isSelectable;
}
public Object getItem(int position) {
- // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+ // Header (negative positions will throw an IndexOutOfBoundsException)
int numHeaders = getHeadersCount();
if (position < numHeaders) {
return mHeaderViewInfos.get(position).data;
@@ -182,7 +182,7 @@ public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
}
}
- // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+ // Footer (off-limits positions will throw an IndexOutOfBoundsException)
return mFooterViewInfos.get(adjPosition - adapterCount).data;
}
@@ -206,7 +206,7 @@ public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
}
public View getView(int position, View convertView, ViewGroup parent) {
- // Header (negative positions will throw an ArrayIndexOutOfBoundsException)
+ // Header (negative positions will throw an IndexOutOfBoundsException)
int numHeaders = getHeadersCount();
if (position < numHeaders) {
return mHeaderViewInfos.get(position).view;
@@ -222,7 +222,7 @@ public class HeaderViewListAdapter implements WrapperListAdapter, Filterable {
}
}
- // Footer (off-limits positions will throw an ArrayIndexOutOfBoundsException)
+ // Footer (off-limits positions will throw an IndexOutOfBoundsException)
return mFooterViewInfos.get(adjPosition - adapterCount).view;
}