Tweaking timepicker and fixing bugs.

Fixed some bugs in Timepicker, and made tweaks to match redlines.

Change-Id: I239a6294a7b2a7cd2fa200dc776a6d4f2fb24949
diff --git a/res/layout-land/time_picker_dialog.xml b/res/layout-land/time_picker_dialog.xml
index 7409c6e..2eb400f 100644
--- a/res/layout-land/time_picker_dialog.xml
+++ b/res/layout-land/time_picker_dialog.xml
@@ -16,7 +16,7 @@
   -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="@dimen/dialog_height"
     android:orientation="horizontal"
     android:background="@color/gray" >
     <LinearLayout
@@ -88,7 +88,7 @@
         <View
             android:layout_width="match_parent"
             android:layout_height="1dip"
-            android:background="@color/lighter_gray" />
+            android:background="@color/black_20" />
         <LinearLayout
             style="?android:attr/buttonBarStyle"
             android:layout_width="match_parent"
diff --git a/res/layout-sw600dp/time_picker_dialog.xml b/res/layout-sw600dp/time_picker_dialog.xml
index ae01ad0..3b5459f 100644
--- a/res/layout-sw600dp/time_picker_dialog.xml
+++ b/res/layout-sw600dp/time_picker_dialog.xml
@@ -89,7 +89,7 @@
     <View
         android:layout_width="match_parent"
         android:layout_height="1dip"
-        android:background="@color/lighter_gray" />
+        android:background="@color/black_20" />
     <LinearLayout
         style="?android:attr/buttonBarStyle"
         android:layout_width="match_parent"
diff --git a/res/layout/time_picker_dialog.xml b/res/layout/time_picker_dialog.xml
index ae01ad0..d1069dc 100644
--- a/res/layout/time_picker_dialog.xml
+++ b/res/layout/time_picker_dialog.xml
@@ -89,7 +89,7 @@
     <View
         android:layout_width="match_parent"
         android:layout_height="1dip"
-        android:background="@color/lighter_gray" />
+        android:background="@color/black_20" />
     <LinearLayout
         style="?android:attr/buttonBarStyle"
         android:layout_width="match_parent"
@@ -97,9 +97,11 @@
         android:orientation="horizontal" >
         <Button
             android:id="@+id/done_button"
-            style="?android:attr/buttonBarButtonStyle"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="@string/done_label" />
+            android:text="@string/done_label"
+            android:textSize="@dimen/done_label_size"
+            android:textColor="@color/black_60"
+            style="?android:attr/buttonBarButtonStyle" />
     </LinearLayout>
 </LinearLayout>
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index dca1757..c8e4f98 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -20,9 +20,6 @@
 <resources
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
     xmlns:android="http://schemas.android.com/apk/res/android" >
-    <dimen name="time_label_right_padding">10sp</dimen>
-    <dimen name="time_label_size">40sp</dimen>
-    <dimen name="ampm_label_size">14sp</dimen>
-    <dimen name="header_height">64dip</dimen>
-    <dimen name="footer_height">48dip</dimen>
+    <dimen name="dialog_height">300dip</dimen>
+    <dimen name="left_side_width">270dip</dimen>
 </resources>
\ No newline at end of file
diff --git a/res/values-v14/strings.xml b/res/values-v14/strings.xml
new file mode 100644
index 0000000..66faff9
--- /dev/null
+++ b/res/values-v14/strings.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+</resources>
diff --git a/res/values-v16/strings.xml b/res/values-v16/strings.xml
new file mode 100644
index 0000000..5875d80
--- /dev/null
+++ b/res/values-v16/strings.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- DO NOT TRANSLATE -->
+    <string name="radial_numbers_typeface">sans-serif-light</string>
+</resources>
diff --git a/res/values-v16/styles.xml b/res/values-v16/styles.xml
index beada7b..88ee2a2 100644
--- a/res/values-v16/styles.xml
+++ b/res/values-v16/styles.xml
@@ -16,7 +16,11 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
     <!-- Style for dialog labels. -->
-    <style name="label">
+    <style name="time_label_thin">
+        <item name="android:fontFamily">sans-serif-light</item>
+    </style>
+
+    <style name="done_button_light">
         <item name="android:fontFamily">sans-serif-light</item>
     </style>
 </resources>
\ No newline at end of file
diff --git a/res/values-v17/styles.xml b/res/values-v17/styles.xml
index 4aadec9..043fe71 100644
--- a/res/values-v17/styles.xml
+++ b/res/values-v17/styles.xml
@@ -16,7 +16,7 @@
 
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
     <!-- Style for dialog labels. -->
-    <style name="label">
+    <style name="time_label_thin">
         <item name="android:fontFamily">sans-serif-thin</item>
     </style>
 </resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 03c35a7..bbc87e2 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -17,8 +17,9 @@
 <resources>
     <color name="white">#ffffff</color>
     <color name="gray">#08000000</color>
-    <color name="lighter_gray">#15000000</color>
-    <color name="dark_gray">#70000000</color>
-    <color name="black">#000000</color>
+    <color name="black_20">#33000000</color>
+    <color name="black_50">#7F000000</color>
+    <color name="black_60">#99000000</color>
+    <color name="black_80">#CC000000</color>
     <color name="blue">#33b5e5</color>
 </resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index cd5f2f9..86c163a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -20,24 +20,22 @@
 <resources
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
     xmlns:android="http://schemas.android.com/apk/res/android" >
-    <item name="circle_radius_multiplier" format="float" type="string">0.84</item>
-    <item name="circle_radius_multiplier_24HourMode" format="float" type="string">0.87</item>
-    <item name="selection_radius_multiplier" format="float" type="string">0.16</item>
-    <item name="ampm_circle_radius_multiplier" format="float" type="string">0.175</item>
-    <item name="numbers_radius_multiplier_normal" format="float" type="string">0.8</item>
-    <item name="numbers_radius_multiplier_inner" format="float" type="string">0.60</item>
-    <item name="numbers_radius_multiplier_outer" format="float" type="string">0.83</item>
-    <item name="text_size_multiplier_normal" format="float" type="string">0.2</item>
-    <item name="text_size_multiplier_inner" format="float" type="string">0.15</item>
+    <item name="circle_radius_multiplier" format="float" type="string">0.82</item>
+    <item name="circle_radius_multiplier_24HourMode" format="float" type="string">0.85    </item>
+    <item name="selection_radius_multiplier" format="float" type="string">0.14</item>
+    <item name="ampm_circle_radius_multiplier" format="float" type="string">0.19</item>
+    <item name="numbers_radius_multiplier_normal" format="float" type="string">0.81    </item>
+    <item name="numbers_radius_multiplier_inner" format="float" type="string">0.60    </item>
+    <item name="numbers_radius_multiplier_outer" format="float" type="string">0.83    </item>
+    <item name="text_size_multiplier_normal" format="float" type="string">0.14</item>
+    <item name="text_size_multiplier_inner" format="float" type="string">0.14</item>
     <item name="text_size_multiplier_outer" format="float" type="string">0.11</item>
     <dimen name="time_label_right_padding">12sp</dimen>
-    <dimen name="time_label_size">48sp</dimen>
+    <dimen name="time_label_size">60sp</dimen>
     <dimen name="ampm_label_size">16sp</dimen>
-    <dimen name="done_label_size">14sp</dimen>
-    <dimen name="ampm_left_padding">7dip</dimen>
+    <dimen name="done_label_size">16sp</dimen>
+    <dimen name="ampm_left_padding">6dip</dimen>
     <dimen name="separator_padding">4dip</dimen>
     <dimen name="header_height">96dip</dimen>
     <dimen name="footer_height">48dip</dimen>
-    <dimen name="left_side_width">250dip</dimen>
-    <dimen name="left_side_height">450dip</dimen>
 </resources>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9533ea7..3614c30 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -23,4 +23,8 @@
     <string name="done_label">Done</string>
     <string name="am_label">AM</string>
     <string name="pm_label">PM</string>
+
+    <!-- DO NOT TRANSLATE -->
+    <string name="radial_numbers_typeface">sans-serif</string>
+    <string name="sans_serif">sans-serif</string>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 767d8ee..b53c851 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -33,19 +33,18 @@
     </style>
 
     <!-- Styles for dialog labels. -->
-    <style name="label" />
+    <style name="time_label_thin" />
+    <style name="done_button_light" />
 
-    <style name="time_label" parent="label">
+    <style name="time_label" parent="time_label_thin">
         <item name="android:textSize">@dimen/time_label_size</item>
+        <item name="android:textColor">@color/black_80</item>
     </style>
 
-    <style name="ampm_label" parent="label">
+    <style name="ampm_label">
         <item name="android:textSize">@dimen/ampm_label_size</item>
         <item name="android:textAllCaps">true</item>
-        <item name="android:textColor">@color/black</item>
+        <item name="android:textColor">@color/black_50</item>
     </style>
 
-    <style name="done_label" parent="label">
-        <item name="android:textSize">@dimen/done_label_size</item>
-    </style>
 </resources>
\ No newline at end of file
diff --git a/src/com/android/datetimepicker/AmPmCirclesView.java b/src/com/android/datetimepicker/AmPmCirclesView.java
index cb04cad..0e2bdb4 100644
--- a/src/com/android/datetimepicker/AmPmCirclesView.java
+++ b/src/com/android/datetimepicker/AmPmCirclesView.java
@@ -35,7 +35,7 @@
 
     private final Paint mPaint = new Paint();
     private int mWhite;
-    private int mDarkGray;
+    private int mBlack50;
     private int mBlue;
     private float mCircleRadiusMultiplier;
     private float mAmPmCircleRadiusMultiplier;
@@ -67,9 +67,10 @@
 
         Resources res = context.getResources();
         mWhite = res.getColor(R.color.white);
-        mDarkGray = res.getColor(R.color.dark_gray);
+        mBlack50 = res.getColor(R.color.black_50);
         mBlue = res.getColor(R.color.blue);
-        Typeface tf = Typeface.create("sans-serif-thin", Typeface.NORMAL);
+        String typefaceFamily = res.getString(R.string.sans_serif);
+        Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
         mPaint.setTypeface(tf);
         mPaint.setAntiAlias(true);
         mPaint.setTextAlign(Align.CENTER);
@@ -150,10 +151,10 @@
         int pmAlpha = 255;
         if (mAmOrPm == AM) {
             amColor = mBlue;
-            amAlpha = 45;
+            amAlpha = 38;
         } else if (mAmOrPm == PM) {
             pmColor = mBlue;
-            pmAlpha = 45;
+            pmAlpha = 38;
         }
         if (mAmOrPmPressed == AM) {
             amColor = mBlue;
@@ -170,7 +171,7 @@
         mPaint.setAlpha(pmAlpha);
         canvas.drawCircle(mPmXCenter, mAmPmYCenter, mAmPmCircleRadius, mPaint);
 
-        mPaint.setColor(mDarkGray);
+        mPaint.setColor(mBlack50);
         int textYCenter = mAmPmYCenter - (int) (mPaint.descent() + mPaint.ascent()) / 2;
         canvas.drawText(mAmText, mAmXCenter, textYCenter, mPaint);
         canvas.drawText(mPmText, mPmXCenter, textYCenter, mPaint);
diff --git a/src/com/android/datetimepicker/CircleView.java b/src/com/android/datetimepicker/CircleView.java
index cd89410..d7ec92a 100644
--- a/src/com/android/datetimepicker/CircleView.java
+++ b/src/com/android/datetimepicker/CircleView.java
@@ -36,7 +36,7 @@
     private final Paint mPaint = new Paint();
     private boolean mIs24HourMode;
     private int mWhite;
-    private int mBlack;
+    private int mBlack80;
     private float mCircleRadiusMultiplier;
     private float mAmPmCircleRadiusMultiplier;
     private boolean mIsInitialized;
@@ -51,7 +51,7 @@
 
         Resources res = context.getResources();
         mWhite = res.getColor(R.color.white);
-        mBlack = res.getColor(R.color.black);
+        mBlack80 = res.getColor(R.color.black_80);
         mPaint.setAntiAlias(true);
 
         mIsInitialized = false;
@@ -105,7 +105,7 @@
         mPaint.setColor(mWhite);
         canvas.drawCircle(mXCenter, mYCenter, mCircleRadius, mPaint);
 
-        mPaint.setColor(mBlack);
+        mPaint.setColor(mBlack80);
         canvas.drawCircle(mXCenter, mYCenter, 2, mPaint);
     }
 }
diff --git a/src/com/android/datetimepicker/RadialSelectorView.java b/src/com/android/datetimepicker/RadialSelectorView.java
index 5f56b56..bb1f78a 100644
--- a/src/com/android/datetimepicker/RadialSelectorView.java
+++ b/src/com/android/datetimepicker/RadialSelectorView.java
@@ -141,6 +141,11 @@
         mDrawLine = drawLine;
     }
 
+    @Override
+    public boolean hasOverlappingRendering() {
+        return false;
+    }
+
     public void setAnimationRadiusMultiplier(float animationRadiusMultiplier) {
         mAnimationRadiusMultiplier = animationRadiusMultiplier;
     }
@@ -250,13 +255,13 @@
         int pointX = mXCenter + (int) (mLineLength * Math.sin(mSelectionRadians));
         int pointY = mYCenter - (int) (mLineLength * Math.cos(mSelectionRadians));
 
-        mPaint.setAlpha(75);
+        mPaint.setAlpha(60);
         canvas.drawCircle(pointX, pointY, mSelectionRadius, mPaint);
 
         if (mForceDrawDot | mSelectionDegrees % 30 != 0) {
             // We're not on a direct tick.
             mPaint.setAlpha(255);
-            canvas.drawCircle(pointX, pointY, mSelectionRadius / 4, mPaint);
+            canvas.drawCircle(pointX, pointY, (mSelectionRadius * 2 / 7), mPaint);
         } else {
             int lineLength = mLineLength;
             lineLength -= mSelectionRadius;
diff --git a/src/com/android/datetimepicker/RadialTextsView.java b/src/com/android/datetimepicker/RadialTextsView.java
index 6909d5c..b128d0d 100644
--- a/src/com/android/datetimepicker/RadialTextsView.java
+++ b/src/com/android/datetimepicker/RadialTextsView.java
@@ -43,6 +43,8 @@
     private boolean mDrawValuesReady;
     private boolean mIsInitialized;
 
+    private Typeface mTypefaceLight;
+    private Typeface mTypefaceRegular;
     private String[] mTexts;
     private String[] mInnerTexts;
     private boolean mIs24HourMode;
@@ -84,10 +86,12 @@
             return;
         }
 
-        int black = res.getColor(R.color.black);
-        mPaint.setColor(black);
-        Typeface tf = Typeface.create("sans-serif-thin", Typeface.NORMAL);
-        mPaint.setTypeface(tf);
+        int black80 = res.getColor(R.color.black_80);
+        mPaint.setColor(black80);
+        String typefaceFamily = res.getString(R.string.radial_numbers_typeface);
+        mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
+        String typefaceFamilyRegular = res.getString(R.string.sans_serif);
+        mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
         mPaint.setAntiAlias(true);
         mPaint.setTextAlign(Align.CENTER);
 
@@ -136,6 +140,11 @@
         mIsInitialized = true;
     }
 
+    @Override
+    public boolean hasOverlappingRendering() {
+        return false;
+    }
+
     public void setAnimationRadiusMultiplier(float animationRadiusMultiplier) {
         mAnimationRadiusMultiplier = animationRadiusMultiplier;
         mTextGridValuesDirty = true;
@@ -187,9 +196,9 @@
             mTextGridValuesDirty = false;
         }
 
-        drawTexts(canvas, mTextSize, mTexts, mTextGridWidths, mTextGridHeights);
+        drawTexts(canvas, mTextSize, mTypefaceLight, mTexts, mTextGridWidths, mTextGridHeights);
         if (mHasInnerCircle) {
-            drawTexts(canvas, mInnerTextSize, mInnerTexts,
+            drawTexts(canvas, mInnerTextSize, mTypefaceRegular, mInnerTexts,
                     mInnerTextGridWidths, mInnerTextGridHeights);
         }
     }
@@ -225,9 +234,10 @@
         textGridWidths[6] = xCenter + offset1;
     }
 
-    private void drawTexts(Canvas canvas, float textSize, String[] texts,
+    private void drawTexts(Canvas canvas, float textSize, Typeface typeface, String[] texts,
             float[] textGridWidths, float[] textGridHeights) {
         mPaint.setTextSize(textSize);
+        mPaint.setTypeface(typeface);
         canvas.drawText(texts[0], textGridWidths[3], textGridHeights[0], mPaint);
         canvas.drawText(texts[1], textGridWidths[4], textGridHeights[1], mPaint);
         canvas.drawText(texts[2], textGridWidths[5], textGridHeights[2], mPaint);
diff --git a/src/com/android/datetimepicker/TimePicker.java b/src/com/android/datetimepicker/TimePicker.java
index 201ba75..3f4b4ef 100644
--- a/src/com/android/datetimepicker/TimePicker.java
+++ b/src/com/android/datetimepicker/TimePicker.java
@@ -114,8 +114,6 @@
         mMinuteRadialSelectorView = new RadialSelectorView(context);
         addView(mMinuteRadialSelectorView);
 
-        setCurrentItemShowing(HOUR_INDEX, false);
-
         mReselectSelectorRunnable = new ReselectSelectorRunnable(this);
 
         mVibrator = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
diff --git a/src/com/android/datetimepicker/TimePickerDialog.java b/src/com/android/datetimepicker/TimePickerDialog.java
index d76ebd4..2b3960d 100644
--- a/src/com/android/datetimepicker/TimePickerDialog.java
+++ b/src/com/android/datetimepicker/TimePickerDialog.java
@@ -54,6 +54,7 @@
     private static final String KEY_HOUR_OF_DAY = "hour_of_day";
     private static final String KEY_MINUTE = "minute";
     private static final String KEY_IS_24_HOUR_VIEW = "is_24_hour_view";
+    private static final String KEY_CURRENT_ITEM_SHOWING = "current_item_showing";
     public static final int HOUR_INDEX = 0;
     public static final int MINUTE_INDEX = 1;
     public static final int AMPM_INDEX = 2; // NOT a real index for the purpose of what's showing.
@@ -64,7 +65,7 @@
 
     private OnTimeSetListener mCallback;
 
-    private Button mDoneButton;
+    private TextView mDoneButton;
     private TextView mHourView;
     private TextView mMinuteView;
     private TextView mAmPmTextView;
@@ -145,7 +146,7 @@
         Resources res = getResources();
 
         mBlue = res.getColor(R.color.blue);
-        mBlack = res.getColor(R.color.black);
+        mBlack = res.getColor(R.color.black_80);
 
         mHourView = (TextView) view.findViewById(R.id.hours);
         mMinuteView = (TextView) view.findViewById(R.id.minutes);
@@ -156,9 +157,14 @@
         mTimePicker = (TimePicker) view.findViewById(R.id.time_picker);
         mTimePicker.setOnValueSelectedListener(this);
         mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode);
+        int currentItemShowing = HOUR_INDEX;
+        if (savedInstanceState != null &&
+                savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
+            currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
+        }
+        setCurrentItemShowing(currentItemShowing, false);
         mTimePicker.invalidate();
 
-        mHourView.setTextColor(mBlue);
         mHourView.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -166,7 +172,6 @@
                 mTimePicker.tryVibrate();
             }
         });
-        mMinuteView.setTextColor(mBlack);
         mMinuteView.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -175,7 +180,7 @@
             }
         });
 
-        mDoneButton = (Button) view.findViewById(R.id.done_button);
+        mDoneButton = (TextView) view.findViewById(R.id.done_button);
         mDoneButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -241,6 +246,7 @@
             outState.putInt(KEY_HOUR_OF_DAY, mTimePicker.getHours());
             outState.putInt(KEY_MINUTE, mTimePicker.getMinutes());
             outState.putBoolean(KEY_IS_24_HOUR_VIEW, mIs24HourMode);
+            outState.putInt(KEY_CURRENT_ITEM_SHOWING, mTimePicker.getCurrentItemShowing());
         }
     }