Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 435616f1 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 1787

* changes:
  resolved conflicts w/ 5bd644ca merge....
parents aaf0718c d2146d4a
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -220,3 +220,54 @@ the Apache2 License.

   END OF TERMS AND CONDITIONS



UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE

Unicode Data Files include all data files under the directories
http://www.unicode.org/Public/, http://www.unicode.org/reports/,
and http://www.unicode.org/cldr/data/ . Unicode Software includes any
source code published in the Unicode Standard or under the directories
http://www.unicode.org/Public/, http://www.unicode.org/reports/, and
http://www.unicode.org/cldr/data/.

NOTICE TO USER: Carefully read the following legal agreement. BY
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S DATA
FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), YOU UNEQUIVOCALLY
ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE TERMS AND CONDITIONS OF
THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY,
DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.

COPYRIGHT AND PERMISSION NOTICE

Copyright © 1991-2008 Unicode, Inc. All rights reserved. Distributed
under the Terms of Use in http://www.unicode.org/copyright.html.

Permission is hereby granted, free of charge, to any person obtaining
a copy of the Unicode data files and any associated documentation (the
"Data Files") or Unicode software and any associated documentation (the
"Software") to deal in the Data Files or Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, and/or sell copies of the Data Files or Software,
and to permit persons to whom the Data Files or Software are furnished to
do so, provided that (a) the above copyright notice(s) and this permission
notice appear with all copies of the Data Files or Software, (b) both the
above copyright notice(s) and this permission notice appear in associated
documentation, and (c) there is clear notice in each modified Data File
or in the Software as well as in the documentation associated with the
Data File(s) or Software that the data or software has been modified.

THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.

Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in these Data Files or Software without prior written
authorization of the copyright holder.
+0 −2
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,
    private final DatePicker mDatePicker;
    private final OnDateSetListener mCallBack;
    private final Calendar mCalendar;
    private final java.text.DateFormat mDateFormat;
    private final java.text.DateFormat mTitleDateFormat;
    private final String[] mWeekDays;

@@ -108,7 +107,6 @@ public class DatePickerDialog extends AlertDialog implements OnClickListener,
        DateFormatSymbols symbols = new DateFormatSymbols();
        mWeekDays = symbols.getShortWeekdays();
        
        mDateFormat = DateFormat.getMediumDateFormat(context);
        mTitleDateFormat = java.text.DateFormat.
                                getDateInstance(java.text.DateFormat.FULL);
        mCalendar = Calendar.getInstance();
+7 −7
Original line number Diff line number Diff line
@@ -408,13 +408,13 @@ public class EventRecurrence
    
    private String dayToString(Resources r, int day) {
        switch (day) {
        case SU: return r.getString(com.android.internal.R.string.sunday);
        case MO: return r.getString(com.android.internal.R.string.monday);
        case TU: return r.getString(com.android.internal.R.string.tuesday);
        case WE: return r.getString(com.android.internal.R.string.wednesday);
        case TH: return r.getString(com.android.internal.R.string.thursday);
        case FR: return r.getString(com.android.internal.R.string.friday);
        case SA: return r.getString(com.android.internal.R.string.saturday);
        case SU: return r.getString(com.android.internal.R.string.day_of_week_long_sunday);
        case MO: return r.getString(com.android.internal.R.string.day_of_week_long_monday);
        case TU: return r.getString(com.android.internal.R.string.day_of_week_long_tuesday);
        case WE: return r.getString(com.android.internal.R.string.day_of_week_long_wednesday);
        case TH: return r.getString(com.android.internal.R.string.day_of_week_long_thursday);
        case FR: return r.getString(com.android.internal.R.string.day_of_week_long_friday);
        case SA: return r.getString(com.android.internal.R.string.day_of_week_long_saturday);
        default: throw new IllegalArgumentException("bad day argument: " + day);
        }
    }
+20 −30
Original line number Diff line number Diff line
@@ -242,64 +242,48 @@ public class DateFormat {

    /**
     * Returns a {@link java.text.DateFormat} object that can format the time according
     * to the current user preference. 
     * to the current locale. 
     * @param context the application context
     * @return the {@link java.text.DateFormat} object that properly formats the time.
     */
    public static final java.text.DateFormat getTimeFormat(Context context) {
        boolean b24 = is24HourFormat(context);
        int res;

        if (b24) {
            res = R.string.twenty_four_hour_time_format;
        } else {
            res = R.string.twelve_hour_time_format;
        }

        return new java.text.SimpleDateFormat(context.getString(res));
        return java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT);
    }

    /**
     * Returns a {@link java.text.DateFormat} object that can format the date according
     * to the current user preference.
     * Returns a {@link java.text.DateFormat} object that can format the date 
     * in short form (such as 12/31/1999) according
     * to the current locale.
     * @param context the application context
     * @return the {@link java.text.DateFormat} object that properly formats the date.
     */
    public static final java.text.DateFormat getDateFormat(Context context) {
        String value = getDateFormatString(context);
        /*
         * We use a resource string here instead of just DateFormat.SHORT
         * so that we get a four-digit year instead a two-digit year.
         */
        String value = context.getString(R.string.numeric_date_format);
        return new java.text.SimpleDateFormat(value);
    }
    
    /**
     * Returns a {@link java.text.DateFormat} object that can format the date
     * in long form (such as December 31, 1999) based on user preference.
     * in long form (such as December 31, 1999) for the current locale.
     * @param context the application context
     * @return the {@link java.text.DateFormat} object that formats the date in long form.
     */
    public static final java.text.DateFormat getLongDateFormat(Context context) {
        String value = getDateFormatString(context);
        if (value.indexOf('M') < value.indexOf('d')) {
            value = context.getString(R.string.full_date_month_first);
        } else {
            value = context.getString(R.string.full_date_day_first);
        }
        return new java.text.SimpleDateFormat(value);
        return java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG);
    }

    /**
     * Returns a {@link java.text.DateFormat} object that can format the date
     * in medium form (such as Dec. 31, 1999) based on user preference.
     * in medium form (such as Dec. 31, 1999) for the current locale.
     * @param context the application context
     * @return the {@link java.text.DateFormat} object that formats the date in long form.
     */
    public static final java.text.DateFormat getMediumDateFormat(Context context) {
        String value = getDateFormatString(context);
        if (value.indexOf('M') < value.indexOf('d')) {
            value = context.getString(R.string.medium_date_month_first);
        } else {
            value = context.getString(R.string.medium_date_day_first);
        }
        return new java.text.SimpleDateFormat(value);
        return java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM);
    }

    /**
@@ -338,6 +322,12 @@ public class DateFormat {
    }
    
    private static String getDateFormatString(Context context) {
        java.text.DateFormat df;
        df = java.text.DateFormat.getDateInstance(java.text.DateFormat.SHORT);
        if (df instanceof SimpleDateFormat) {
            return ((SimpleDateFormat) df).toPattern();
        }

        String value = Settings.System.getString(context.getContentResolver(),
                Settings.System.DATE_FORMAT);
        if (value == null || value.length() < 6) {
+70 −30
Original line number Diff line number Diff line
@@ -62,15 +62,6 @@ public class DateUtils
            com.android.internal.R.string.day_of_week_short_friday,
            com.android.internal.R.string.day_of_week_short_saturday,
        };
    private static final int[] sDaysShorter = new int[] {
            com.android.internal.R.string.day_of_week_shorter_sunday,
            com.android.internal.R.string.day_of_week_shorter_monday,
            com.android.internal.R.string.day_of_week_shorter_tuesday,
            com.android.internal.R.string.day_of_week_shorter_wednesday,
            com.android.internal.R.string.day_of_week_shorter_thursday,
            com.android.internal.R.string.day_of_week_shorter_friday,
            com.android.internal.R.string.day_of_week_shorter_saturday,
        };
    private static final int[] sDaysShortest = new int[] {
            com.android.internal.R.string.day_of_week_shortest_sunday,
            com.android.internal.R.string.day_of_week_shortest_monday,
@@ -80,6 +71,20 @@ public class DateUtils
            com.android.internal.R.string.day_of_week_shortest_friday,
            com.android.internal.R.string.day_of_week_shortest_saturday,
        };
    private static final int[] sMonthsStandaloneLong = new int [] {
            com.android.internal.R.string.month_long_standalone_january,
            com.android.internal.R.string.month_long_standalone_february,
            com.android.internal.R.string.month_long_standalone_march,
            com.android.internal.R.string.month_long_standalone_april,
            com.android.internal.R.string.month_long_standalone_may,
            com.android.internal.R.string.month_long_standalone_june,
            com.android.internal.R.string.month_long_standalone_july,
            com.android.internal.R.string.month_long_standalone_august,
            com.android.internal.R.string.month_long_standalone_september,
            com.android.internal.R.string.month_long_standalone_october,
            com.android.internal.R.string.month_long_standalone_november,
            com.android.internal.R.string.month_long_standalone_december,
        };
    private static final int[] sMonthsLong = new int [] {
            com.android.internal.R.string.month_long_january,
            com.android.internal.R.string.month_long_february,
@@ -127,7 +132,7 @@ public class DateUtils
            com.android.internal.R.string.pm,
        };
    private static Configuration sLastConfig;
    private static String sStatusTimeFormat;
    private static java.text.DateFormat sStatusTimeFormat;
    private static String sElapsedFormatMMSS;
    private static String sElapsedFormatHMMSS;
    
@@ -255,18 +260,15 @@ public class DateUtils
     * For use with the 'abbrev' parameter of {@link #getDayOfWeekString} and {@link #getMonthString}.
     * @more
     * <p>e.g. "Su" or "Jan"
     * <p>In some languages, the results returned for LENGTH_SHORT may be the same as
     * return for {@link #LENGTH_MEDIUM}.
     * <p>In most languages, the results returned for LENGTH_SHORT will be the same as
     * the results returned for {@link #LENGTH_MEDIUM}.
     */
    public static final int LENGTH_SHORT = 30;

    /**
     * Request an even shorter abbreviated version of the name.
     * For use with the 'abbrev' parameter of {@link #getDayOfWeekString} and {@link #getMonthString}.
     * @more
     * <p>e.g. "M", "Tu", "Th" or "J"
     * <p>In some languages, the results returned for LENGTH_SHORTEST may be the same as
     * return for {@link #LENGTH_SHORTER}.
     * Do not use this.  Currently this will always return the same result
     * as {@link #LENGTH_SHORT}.
     */
    public static final int LENGTH_SHORTER = 40;

@@ -275,8 +277,8 @@ public class DateUtils
     * For use with the 'abbrev' parameter of {@link #getDayOfWeekString} and {@link #getMonthString}.
     * @more
     * <p>e.g. "S", "T", "T" or "J"
     * <p>In some languages, the results returned for LENGTH_SHORTEST may be the same as
     * return for {@link #LENGTH_SHORTER}.
     * <p>In some languages, the results returned for LENGTH_SHORTEST will be the same as
     * the results returned for {@link #LENGTH_SHORT}.
     */
    public static final int LENGTH_SHORTEST = 50;

@@ -284,9 +286,12 @@ public class DateUtils
     * Return a string for the day of the week.
     * @param dayOfWeek One of {@link Calendar#SUNDAY Calendar.SUNDAY},
     *               {@link Calendar#MONDAY Calendar.MONDAY}, etc.
     * @param abbrev One of {@link #LENGTH_LONG}, {@link #LENGTH_SHORT}, {@link #LENGTH_SHORTER}
     *               or {@link #LENGTH_SHORTEST}.  For forward compatibility, anything else
     *               will return the same as {#LENGTH_MEDIUM}.
     * @param abbrev One of {@link #LENGTH_LONG}, {@link #LENGTH_SHORT},
     *               {@link #LENGTH_MEDIUM}, or {@link #LENGTH_SHORTEST}.
     *               Note that in most languages, {@link #LENGTH_SHORT}
     *               will return the same as {@link #LENGTH_MEDIUM}.
     *               Undefined lengths will return {@link #LENGTH_MEDIUM}
     *               but may return something different in the future.
     * @throws IndexOutOfBoundsException if the dayOfWeek is out of bounds.
     */
    public static String getDayOfWeekString(int dayOfWeek, int abbrev) {
@@ -295,7 +300,7 @@ public class DateUtils
            case LENGTH_LONG:       list = sDaysLong;       break;
            case LENGTH_MEDIUM:     list = sDaysMedium;     break;
            case LENGTH_SHORT:      list = sDaysShort;      break;
            case LENGTH_SHORTER:    list = sDaysShorter;    break;
            case LENGTH_SHORTER:    list = sDaysShort;      break;
            case LENGTH_SHORTEST:   list = sDaysShortest;   break;
            default:                list = sDaysMedium;     break;
        }
@@ -316,13 +321,14 @@ public class DateUtils
    }

    /**
     * Return a localized string for the day of the week.
     * Return a localized string for the month of the year.
     * @param month One of {@link Calendar#JANUARY Calendar.JANUARY},
     *               {@link Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
     * @param abbrev One of {@link #LENGTH_LONG}, {@link #LENGTH_SHORT}, {@link #LENGTH_SHORTER}
     *               or {@link #LENGTH_SHORTEST}.  For forward compatibility, anything else
     *               will return the same as {#LENGTH_MEDIUM}.
     * @return Localized day of the week.
     * @param abbrev One of {@link #LENGTH_LONG}, {@link #LENGTH_MEDIUM},
     *               or {@link #LENGTH_SHORTEST}.
     *               Undefined lengths will return {@link #LENGTH_MEDIUM}
     *               but may return something different in the future.
     * @return Localized month of the year.
     */
    public static String getMonthString(int month, int abbrev) {
        // Note that here we use sMonthsMedium for MEDIUM, SHORT and SHORTER. 
@@ -343,6 +349,40 @@ public class DateUtils
        return r.getString(list[month - Calendar.JANUARY]);
    }

    /**
     * Return a localized string for the month of the year, for
     * contexts where the month is not formatted together with
     * a day of the month.
     *
     * @param month One of {@link Calendar#JANUARY Calendar.JANUARY},
     *               {@link Calendar#FEBRUARY Calendar.FEBRUARY}, etc.
     * @param abbrev One of {@link #LENGTH_LONG}, {@link #LENGTH_MEDIUM},
     *               or {@link #LENGTH_SHORTEST}.
     *               Undefined lengths will return {@link #LENGTH_MEDIUM}
     *               but may return something different in the future.
     * @return Localized month of the year.
     * @hide Pending API council approval
     */
    public static String getStandaloneMonthString(int month, int abbrev) {
        // Note that here we use sMonthsMedium for MEDIUM, SHORT and SHORTER. 
        // This is a shortcut to not spam the translators with too many variations
        // of the same string.  If we find that in a language the distinction
        // is necessary, we can can add more without changing this API.
        int[] list;
        switch (abbrev) {
            case LENGTH_LONG:       list = sMonthsStandaloneLong;
                                                            break;
            case LENGTH_MEDIUM:     list = sMonthsMedium;   break;
            case LENGTH_SHORT:      list = sMonthsMedium;   break;
            case LENGTH_SHORTER:    list = sMonthsMedium;   break;
            case LENGTH_SHORTEST:   list = sMonthsShortest; break;
            default:                list = sMonthsMedium;   break;
        }

        Resources r = Resources.getSystem();
        return r.getString(list[month - Calendar.JANUARY]);
    }

    /**
     * Returns a string describing the elapsed time since startTime.
     * @param startTime some time in the past.
@@ -572,7 +612,7 @@ public class DateUtils
            Configuration cfg = r.getConfiguration();
            if (sLastConfig == null || !sLastConfig.equals(cfg)) {
                sLastConfig = cfg;
                sStatusTimeFormat = r.getString(com.android.internal.R.string.status_bar_time_format);
                sStatusTimeFormat = java.text.DateFormat.getTimeInstance(java.text.DateFormat.SHORT);
                sElapsedFormatMMSS = r.getString(com.android.internal.R.string.elapsed_time_short_format_mm_ss);
                sElapsedFormatHMMSS = r.getString(com.android.internal.R.string.elapsed_time_short_format_h_mm_ss);
            }
@@ -586,7 +626,7 @@ public class DateUtils
     */
    public static final CharSequence timeString(long millis) {
        initFormatStrings();
        return DateFormat.format(sStatusTimeFormat, millis);
        return sStatusTimeFormat.format(millis);
    }

    /**
Loading