diff options
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | core/java/android/widget/DatePicker.java | 29 | ||||
-rw-r--r-- | core/java/android/widget/DatePickerCalendarDelegate.java (renamed from core/java/android/widget/DatePickerDelegate.java) | 4 | ||||
-rw-r--r-- | core/java/android/widget/TimePicker.java | 21 | ||||
-rw-r--r-- | core/java/android/widget/TimePickerClockDelegate.java (renamed from core/java/android/widget/LegacyTimePickerDelegate.java) | 6 | ||||
-rw-r--r-- | core/java/android/widget/TimePickerSpinnerDelegate.java (renamed from core/java/android/widget/TimePickerDelegate.java) | 6 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 22 | ||||
-rw-r--r-- | core/res/res/values/public.xml | 3 | ||||
-rw-r--r-- | core/res/res/values/styles.xml | 4 | ||||
-rw-r--r-- | core/res/res/values/styles_holo.xml | 8 | ||||
-rw-r--r-- | core/res/res/values/styles_leanback.xml | 4 | ||||
-rw-r--r-- | core/res/res/values/styles_material.xml | 4 |
12 files changed, 73 insertions, 40 deletions
diff --git a/api/current.txt b/api/current.txt index d4f2cc5..a51216e3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -479,6 +479,7 @@ package android { field public static final int dashWidth = 16843174; // 0x10101a6 field public static final int data = 16842798; // 0x101002e field public static final int datePickerDialogTheme = 16843951; // 0x10104af + field public static final int datePickerMode = 16843958; // 0x10104b6 field public static final int datePickerStyle = 16843612; // 0x101035c field public static final int dateTextAppearance = 16843593; // 0x1010349 field public static final int dayOfWeekBackgroundColor = 16843926; // 0x1010496 @@ -1313,6 +1314,7 @@ package android { field public static final int tileModeX = 16843897; // 0x1010479 field public static final int tileModeY = 16843898; // 0x101047a field public static final int timePickerDialogTheme = 16843936; // 0x10104a0 + field public static final int timePickerMode = 16843959; // 0x10104b7 field public static final int timePickerStyle = 16843935; // 0x101049f field public static final int timeZone = 16843724; // 0x10103cc field public static final int tint = 16843041; // 0x1010121 diff --git a/core/java/android/widget/DatePicker.java b/core/java/android/widget/DatePicker.java index 74c66c8..d0a2eab 100644 --- a/core/java/android/widget/DatePicker.java +++ b/core/java/android/widget/DatePicker.java @@ -84,6 +84,9 @@ import libcore.icu.ICU; public class DatePicker extends FrameLayout { private static final String LOG_TAG = DatePicker.class.getSimpleName(); + private static final int MODE_SPINNER = 1; + private static final int MODE_CALENDAR = 2; + private final DatePickerDelegate mDelegate; /** @@ -120,24 +123,28 @@ public class DatePicker extends FrameLayout { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DatePicker, defStyleAttr, defStyleRes); - final boolean legacyMode = a.getBoolean(R.styleable.DatePicker_legacyMode, true); + int mode = a.getInt(R.styleable.DatePicker_datePickerMode, MODE_SPINNER); a.recycle(); - if (legacyMode) { - mDelegate = createLegacyUIDelegate(context, attrs, defStyleAttr, defStyleRes); - } else { - mDelegate = createNewUIDelegate(context, attrs, defStyleAttr, defStyleRes); + switch (mode) { + case MODE_CALENDAR: + mDelegate = createCalendarUIDelegate(context, attrs, defStyleAttr, defStyleRes); + break; + case MODE_SPINNER: + default: + mDelegate = createSpinnerUIDelegate(context, attrs, defStyleAttr, defStyleRes); + break; } } - private DatePickerDelegate createLegacyUIDelegate(Context context, AttributeSet attrs, + private DatePickerDelegate createSpinnerUIDelegate(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - return new LegacyDatePickerDelegate(this, context, attrs, defStyleAttr, defStyleRes); + return new DatePickerSpinnerDelegate(this, context, attrs, defStyleAttr, defStyleRes); } - private DatePickerDelegate createNewUIDelegate(Context context, AttributeSet attrs, + private DatePickerDelegate createCalendarUIDelegate(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - return new android.widget.DatePickerDelegate(this, context, attrs, defStyleAttr, + return new DatePickerCalendarDelegate(this, context, attrs, defStyleAttr, defStyleRes); } @@ -454,7 +461,7 @@ public class DatePicker extends FrameLayout { /** * A delegate implementing the basic DatePicker */ - private static class LegacyDatePickerDelegate extends AbstractDatePickerDelegate { + private static class DatePickerSpinnerDelegate extends AbstractDatePickerDelegate { private static final String DATE_FORMAT = "MM/dd/yyyy"; @@ -500,7 +507,7 @@ public class DatePicker extends FrameLayout { private boolean mIsEnabled = DEFAULT_ENABLED_STATE; - LegacyDatePickerDelegate(DatePicker delegator, Context context, AttributeSet attrs, + DatePickerSpinnerDelegate(DatePicker delegator, Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(delegator, context); diff --git a/core/java/android/widget/DatePickerDelegate.java b/core/java/android/widget/DatePickerCalendarDelegate.java index ddc565d..c0c76ac 100644 --- a/core/java/android/widget/DatePickerDelegate.java +++ b/core/java/android/widget/DatePickerCalendarDelegate.java @@ -52,7 +52,7 @@ import java.util.Locale; /** * A delegate for picking up a date (day / month / year). */ -class DatePickerDelegate extends DatePicker.AbstractDatePickerDelegate implements +class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate implements View.OnClickListener, DatePickerController { private static final int UNINITIALIZED = -1; @@ -113,7 +113,7 @@ class DatePickerDelegate extends DatePicker.AbstractDatePickerDelegate implement private HashSet<OnDateChangedListener> mListeners = new HashSet<OnDateChangedListener>(); - public DatePickerDelegate(DatePicker delegator, Context context, AttributeSet attrs, + public DatePickerCalendarDelegate(DatePicker delegator, Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(delegator, context); diff --git a/core/java/android/widget/TimePicker.java b/core/java/android/widget/TimePicker.java index 026a8ee..c488666 100644 --- a/core/java/android/widget/TimePicker.java +++ b/core/java/android/widget/TimePicker.java @@ -45,6 +45,9 @@ import java.util.Locale; */ @Widget public class TimePicker extends FrameLayout { + private static final int MODE_SPINNER = 1; + private static final int MODE_CLOCK = 2; + private final TimePickerDelegate mDelegate; /** @@ -77,15 +80,19 @@ public class TimePicker extends FrameLayout { final TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.TimePicker, defStyleAttr, defStyleRes); - final boolean legacyMode = a.getBoolean(R.styleable.TimePicker_legacyMode, true); + int mode = a.getInt(R.styleable.TimePicker_timePickerMode, MODE_SPINNER); a.recycle(); - if (legacyMode) { - mDelegate = new LegacyTimePickerDelegate( - this, context, attrs, defStyleAttr, defStyleRes); - } else { - mDelegate = new android.widget.TimePickerDelegate( - this, context, attrs, defStyleAttr, defStyleRes); + switch (mode) { + case MODE_CLOCK: + mDelegate = new TimePickerSpinnerDelegate( + this, context, attrs, defStyleAttr, defStyleRes); + break; + case MODE_SPINNER: + default: + mDelegate = new TimePickerClockDelegate( + this, context, attrs, defStyleAttr, defStyleRes); + break; } } diff --git a/core/java/android/widget/LegacyTimePickerDelegate.java b/core/java/android/widget/TimePickerClockDelegate.java index 70db211..59ec6d3 100644 --- a/core/java/android/widget/LegacyTimePickerDelegate.java +++ b/core/java/android/widget/TimePickerClockDelegate.java @@ -44,7 +44,7 @@ import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES; /** * A delegate implementing the basic TimePicker */ -class LegacyTimePickerDelegate extends TimePicker.AbstractTimePickerDelegate { +class TimePickerClockDelegate extends TimePicker.AbstractTimePickerDelegate { private static final boolean DEFAULT_ENABLED_STATE = true; @@ -100,8 +100,8 @@ class LegacyTimePickerDelegate extends TimePicker.AbstractTimePickerDelegate { } }; - public LegacyTimePickerDelegate(TimePicker delegator, Context context, AttributeSet attrs, - int defStyleAttr, int defStyleRes) { + public TimePickerClockDelegate(TimePicker delegator, Context context, AttributeSet attrs, + int defStyleAttr, int defStyleRes) { super(delegator, context); // process style attributes diff --git a/core/java/android/widget/TimePickerDelegate.java b/core/java/android/widget/TimePickerSpinnerDelegate.java index c68619c..4e9a39f 100644 --- a/core/java/android/widget/TimePickerDelegate.java +++ b/core/java/android/widget/TimePickerSpinnerDelegate.java @@ -51,7 +51,7 @@ import java.util.Locale; /** * A view for selecting the time of day, in either 24 hour or AM/PM mode. */ -class TimePickerDelegate extends TimePicker.AbstractTimePickerDelegate implements +class TimePickerSpinnerDelegate extends TimePicker.AbstractTimePickerDelegate implements RadialTimePickerView.OnValueSelectedListener { private static final String TAG = "TimePickerDelegate"; @@ -119,8 +119,8 @@ class TimePickerDelegate extends TimePicker.AbstractTimePickerDelegate implement private Calendar mTempCalendar; - public TimePickerDelegate(TimePicker delegator, Context context, AttributeSet attrs, - int defStyleAttr, int defStyleRes) { + public TimePickerSpinnerDelegate(TimePicker delegator, Context context, AttributeSet attrs, + int defStyleAttr, int defStyleRes) { super(delegator, context); // process style attributes diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 2baa599..771690e 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -4260,8 +4260,6 @@ <attr name="internalLayout" format="reference" /> <!-- @hide The layout of the legacy DatePicker. --> <attr name="legacyLayout" /> - <!-- @hide Enables or disable the use of the legacy layout for the DatePicker. --> - <attr name="legacyMode" /> <!-- The background color for the date selector 's day of week. --> <attr name="dayOfWeekBackgroundColor" format="color" /> <!-- The text color for the date selector's day of week. --> @@ -4288,6 +4286,15 @@ if the text color does not explicitly have a color set for the selected state. --> <attr name="calendarSelectedTextColor" format="color" /> + <!-- Defines the look of the widget. Prior to the L release, the only choice was + spinner. As of L, with the Material theme selected, the default layout is calendar, + but this attribute can be used to force spinner to be used instead. --> + <attr name="datePickerMode"> + <!-- Date picker with spinner controls to select the date. --> + <enum name="spinner" value="1" /> + <!-- Date picker with calendar to select the date. --> + <enum name="calendar" value="2" /> + </attr> </declare-styleable> <declare-styleable name="TwoLineListItem"> @@ -4557,8 +4564,6 @@ </declare-styleable> <declare-styleable name="TimePicker"> - <!-- @hide Enables or disable the use of the legacy layout for the TimePicker. --> - <attr name="legacyMode" format="boolean" /> <!-- @hide The layout of the legacy time picker. --> <attr name="legacyLayout" format="reference" /> <!-- @hide The layout of the time picker. --> @@ -4587,6 +4592,15 @@ <attr name="amPmSelectedBackgroundColor" format="color" /> <!-- The color for the hours/minutes selector of the TimePicker. --> <attr name="numbersSelectorColor" format="color" /> + <!-- Defines the look of the widget. Prior to the L release, the only choice was + spinner. As of L, with the Material theme selected, the default layout is clock, + but this attribute can be used to force spinner to be used instead. --> + <attr name="timePickerMode"> + <!-- Time picker with spinner controls to select the time. --> + <enum name="spinner" value="1" /> + <!-- Time picker with clock face to select the time. --> + <enum name="clock" value="2" /> + </attr> </declare-styleable> <!-- ========================= --> diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index 08398f0..73aaafd 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -2562,4 +2562,7 @@ <public type="raw" name="nodomain"/> <public type="attr" name="contentRatingSystemXml"/> + + <public type="attr" name="datePickerMode"/> + <public type="attr" name="timePickerMode"/> </resources> diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index 4a70952..a5cac6b 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -568,12 +568,12 @@ please see styles_device_defaults.xml. </style> <style name="Widget.TimePicker"> - <item name="legacyMode">true</item> + <item name="timePickerMode">spinner</item> <item name="legacyLayout">@layout/time_picker_legacy</item> </style> <style name="Widget.DatePicker"> - <item name="legacyMode">true</item> + <item name="datePickerMode">spinner</item> <item name="legacyLayout">@layout/date_picker_legacy</item> <item name="calendarViewShown">false</item> </style> diff --git a/core/res/res/values/styles_holo.xml b/core/res/res/values/styles_holo.xml index d79e46d..2a54ccf 100644 --- a/core/res/res/values/styles_holo.xml +++ b/core/res/res/values/styles_holo.xml @@ -462,7 +462,7 @@ please see styles_device_defaults.xml. </style> <style name="Widget.Holo.TimePicker" parent="Widget.TimePicker"> - <item name="legacyMode">true</item> + <item name="timePickerMode">spinner</item> <item name="legacyLayout">@layout/time_picker_legacy_holo</item> <!-- Attributes for new-style TimePicker. --> <item name="internalLayout">@layout/time_picker_holo</item> @@ -479,7 +479,7 @@ please see styles_device_defaults.xml. </style> <style name="Widget.Holo.DatePicker" parent="Widget.DatePicker"> - <item name="legacyMode">true</item> + <item name="datePickerMode">spinner</item> <item name="legacyLayout">@layout/date_picker_legacy_holo</item> <item name="internalLayout">@layout/date_picker_holo</item> <item name="calendarViewShown">true</item> @@ -886,7 +886,7 @@ please see styles_device_defaults.xml. <style name="Widget.Holo.Light.NumberPicker" parent="Widget.Holo.NumberPicker" /> <style name="Widget.Holo.Light.TimePicker" parent="Widget.TimePicker"> - <item name="legacyMode">true</item> + <item name="timePickerMode">spinner</item> <item name="legacyLayout">@layout/time_picker_legacy_holo</item> <!-- Non-legacy styling --> <item name="internalLayout">@layout/time_picker_holo</item> @@ -903,7 +903,7 @@ please see styles_device_defaults.xml. </style> <style name="Widget.Holo.Light.DatePicker" parent="Widget.DatePicker"> - <item name="legacyMode">true</item> + <item name="datePickerMode">spinner</item> <item name="legacyLayout">@layout/date_picker_legacy_holo</item> <item name="internalLayout">@layout/date_picker_holo</item> <item name="calendarViewShown">true</item> diff --git a/core/res/res/values/styles_leanback.xml b/core/res/res/values/styles_leanback.xml index a899c4d..256ef00 100644 --- a/core/res/res/values/styles_leanback.xml +++ b/core/res/res/values/styles_leanback.xml @@ -23,12 +23,12 @@ </style> <style name="Widget.Leanback.TimePicker" parent="Widget.Material.TimePicker"> - <item name="legacyMode">true</item> + <item name="timePickerMode">spinner</item> <item name="legacyLayout">@layout/time_picker_legacy_leanback</item> </style> <style name="Widget.Leanback.DatePicker" parent="Widget.Material.DatePicker"> - <item name="legacyMode">true</item> + <item name="datePickerMode">spinner</item> </style> <style name="Widget.Leanback.NumberPicker" parent="Widget.Material.NumberPicker"> diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml index 2dc0438..97d4bf6 100644 --- a/core/res/res/values/styles_material.xml +++ b/core/res/res/values/styles_material.xml @@ -587,7 +587,7 @@ please see styles_device_defaults.xml. </style> <style name="Widget.Material.TimePicker" parent="Widget.TimePicker"> - <item name="legacyMode">false</item> + <item name="timePickerMode">clock</item> <item name="legacyLayout">@layout/time_picker_legacy_holo</item> <!-- Attributes for new-style TimePicker. --> <item name="internalLayout">@layout/time_picker_holo</item> @@ -604,7 +604,7 @@ please see styles_device_defaults.xml. </style> <style name="Widget.Material.DatePicker" parent="Widget.DatePicker"> - <item name="legacyMode">false</item> + <item name="datePickerMode">calendar</item> <item name="legacyLayout">@layout/date_picker_legacy_holo</item> <!-- Attributes for new-style DatePicker. --> <item name="internalLayout">@layout/date_picker_holo</item> |