summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RadialTimePickerView.java
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-07-28 16:56:32 -0700
committerAlan Viverette <alanv@google.com>2014-07-29 12:49:50 -0700
commit60727e07c6ef72e2f494266939c02494a3df28f8 (patch)
tree93c4d59934335d43a9650819ea89e465a26c37d9 /core/java/android/widget/RadialTimePickerView.java
parentec9c7090f845e0804dab70a73307a747dca1ba3d (diff)
Clean up TimePicker and DatePicker styling
Removes the time and date picker specific themes and defaults their theme attributes to use the alert dialog theme attribute's value. BUG: 14973897 Change-Id: Id5cc74ea0c1a379fc1ee76b354a1bb5ba329585a
Diffstat (limited to 'core/java/android/widget/RadialTimePickerView.java')
-rw-r--r--core/java/android/widget/RadialTimePickerView.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/core/java/android/widget/RadialTimePickerView.java b/core/java/android/widget/RadialTimePickerView.java
index 1e30bfa3dcec..3d2f67f7c115 100644
--- a/core/java/android/widget/RadialTimePickerView.java
+++ b/core/java/android/widget/RadialTimePickerView.java
@@ -24,6 +24,7 @@ import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -104,6 +105,8 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
private static final int CENTER_RADIUS = 2;
+ private static final int[] STATE_SET_SELECTED = new int[] { R.attr.state_selected };
+
private static int[] sSnapPrefer30sMap = new int[361];
private final String[] mHours12Texts = new String[12];
@@ -323,10 +326,20 @@ public class RadialTimePickerView extends View implements View.OnTouchListener {
final TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.TimePicker,
defStyle, 0);
- mAmPmUnselectedColor = a.getColor(R.styleable.TimePicker_amPmUnselectedBackgroundColor,
- res.getColor(R.color.timepicker_default_ampm_unselected_background_color_material));
- mAmPmSelectedColor = a.getColor(R.styleable.TimePicker_amPmSelectedBackgroundColor,
+ ColorStateList amPmBackgroundColor = a.getColorStateList(
+ R.styleable.TimePicker_amPmBackgroundColor);
+ if (amPmBackgroundColor == null) {
+ amPmBackgroundColor = res.getColorStateList(
+ R.color.timepicker_default_ampm_unselected_background_color_material);
+ }
+
+ // Obtain the backup selected color. If the background color state
+ // list doesn't have a state for selected, we'll use this color.
+ final int amPmSelectedColor = a.getColor(R.styleable.TimePicker_amPmSelectedBackgroundColor,
res.getColor(R.color.timepicker_default_ampm_selected_background_color_material));
+ mAmPmSelectedColor = amPmBackgroundColor.getColorForState(
+ STATE_SET_SELECTED, amPmSelectedColor);
+ mAmPmUnselectedColor = amPmBackgroundColor.getDefaultColor();
mAmPmTextColor = a.getColor(R.styleable.TimePicker_amPmTextColor,
res.getColor(R.color.timepicker_default_text_color_material));