Changes styling on number, date and time pickers.

Makes them more usable on a watch by decreasing their size
to be less than the height of small watches.

bug: 29939405
Change-Id: I16d4312c834336c29cd178c6a65369cde79d990c
This commit is contained in:
Matthew Tait
2016-08-01 17:15:47 +01:00
parent 6d0c9ffc5c
commit 87f8b8c545
11 changed files with 79 additions and 32 deletions

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2007 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.
-->
<DatePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/datePicker"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:spinnersShown="true"
android:calendarViewShown="false"
android:datePickerMode="@integer/date_picker_mode" />

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
** **
** Copyright 2012, The Android Open Source Project ** Copyright 2007, The Android Open Source Project
** **
** Licensed under the Apache License, Version 2.0 (the "License"); ** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License. ** you may not use this file except in compliance with the License.
@@ -17,15 +17,10 @@
*/ */
--> -->
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <TimePicker xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/timePicker"
<view class="android.widget.NumberPicker$CustomEditText" android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_horizontal"
android:id="@+id/numberpicker_input" android:layout_width="wrap_content"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:timePickerMode="@integer/time_picker_mode" />
android:gravity="center"
android:singleLine="true"
android:background="@null" />
</merge>

View File

@@ -41,8 +41,8 @@
android:id="@+id/month" android:id="@+id/month"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dip" android:layout_marginTop="@dimen/picker_top_margin"
android:layout_marginBottom="16dip" android:layout_marginBottom="@dimen/picker_bottom_margin"
android:layout_marginStart="8dip" android:layout_marginStart="8dip"
android:layout_marginEnd="8dip" android:layout_marginEnd="8dip"
android:focusable="true" android:focusable="true"
@@ -54,8 +54,8 @@
android:id="@+id/day" android:id="@+id/day"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dip" android:layout_marginTop="@dimen/picker_top_margin"
android:layout_marginBottom="16dip" android:layout_marginBottom="@dimen/picker_bottom_margin"
android:layout_marginStart="8dip" android:layout_marginStart="8dip"
android:layout_marginEnd="8dip" android:layout_marginEnd="8dip"
android:focusable="true" android:focusable="true"
@@ -67,8 +67,8 @@
android:id="@+id/year" android:id="@+id/year"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dip" android:layout_marginTop="@dimen/picker_top_margin"
android:layout_marginBottom="16dip" android:layout_marginBottom="@dimen/picker_bottom_margin"
android:layout_marginStart="8dip" android:layout_marginStart="8dip"
android:layout_marginEnd="16dip" android:layout_marginEnd="16dip"
android:focusable="true" android:focusable="true"

View File

@@ -22,4 +22,4 @@
android:gravity="center" android:gravity="center"
android:singleLine="true" android:singleLine="true"
android:background="@null" android:background="@null"
android:textAppearance="@style/TextAppearance.Material.Body1" /> android:textAppearance="@style/TextAppearance.Material.NumberPicker" />

View File

@@ -40,8 +40,8 @@
android:id="@+id/hour" android:id="@+id/hour"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dip" android:layout_marginTop="@dimen/picker_top_margin"
android:layout_marginBottom="16dip" android:layout_marginBottom="@dimen/picker_bottom_margin"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
/> />
@@ -62,8 +62,8 @@
android:id="@+id/minute" android:id="@+id/minute"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dip" android:layout_marginTop="@dimen/picker_top_margin"
android:layout_marginBottom="16dip" android:layout_marginBottom="@dimen/picker_bottom_margin"
android:focusable="true" android:focusable="true"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
/> />
@@ -75,8 +75,8 @@
android:id="@+id/amPm" android:id="@+id/amPm"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dip" android:layout_marginTop="@dimen/picker_top_margin"
android:layout_marginBottom="16dip" android:layout_marginBottom="@dimen/picker_bottom_margin"
android:layout_marginStart="8dip" android:layout_marginStart="8dip"
android:layout_marginEnd="8dip" android:layout_marginEnd="8dip"
android:focusable="true" android:focusable="true"

View File

@@ -35,4 +35,8 @@
<dimen name="text_size_small_material">12sp</dimen> <dimen name="text_size_small_material">12sp</dimen>
<item name="text_line_spacing_multiplier_material" format="float" type="dimen">1.2</item> <item name="text_line_spacing_multiplier_material" format="float" type="dimen">1.2</item>
<!-- Date and time picker legacy dimens -->
<dimen name="picker_top_margin">1dip</dimen>
<dimen name="picker_bottom_margin">1dip</dimen>
</resources> </resources>

View File

@@ -26,4 +26,10 @@
<!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. Override from base which says "Body Sensors". [CHAR_LIMIT=25] --> <!-- Title of a category of application permissions, listed so the user can choose whether they want to allow the application to do this. Override from base which says "Body Sensors". [CHAR_LIMIT=25] -->
<string name="permgrouplab_sensors">Sensors</string> <string name="permgrouplab_sensors">Sensors</string>
<!-- Do not translate. timepicker mode, overridden for watch -->
<string name="time_picker_mode" translatable="false">"spinner"</string>
<!-- Do not translate. datepicker mode, overridden for watch -->
<string name="date_picker_mode" translatable="false">"spinner"</string>
</resources> </resources>

View File

@@ -70,6 +70,10 @@ please see styles_device_defaults.xml.
<style name="Widget.Material.ButtonBar" parent="Widget.Material.BaseButtonBar" /> <style name="Widget.Material.ButtonBar" parent="Widget.Material.BaseButtonBar" />
<style name="TextAppearance.Material.NumberPicker" parent="TextAppearance.Material.Body1">
<item name="textSize">@dimen/text_size_medium_material</item>
</style>
<!-- Alert dialog button bar button --> <!-- Alert dialog button bar button -->
<style name="Widget.Material.Button.ButtonBar.AlertDialog" parent="Widget.Material.Button.Borderless.Small"> <style name="Widget.Material.Button.ButtonBar.AlertDialog" parent="Widget.Material.Button.Borderless.Small">
<item name="paddingStart">@dimen/list_item_padding_start_material</item> <item name="paddingStart">@dimen/list_item_padding_start_material</item>
@@ -85,9 +89,9 @@ please see styles_device_defaults.xml.
<item name="solidColor">@color/transparent</item> <item name="solidColor">@color/transparent</item>
<item name="selectionDivider">@drawable/numberpicker_selection_divider</item> <item name="selectionDivider">@drawable/numberpicker_selection_divider</item>
<item name="selectionDividerHeight">2dp</item> <item name="selectionDividerHeight">2dp</item>
<item name="selectionDividersDistance">48dp</item> <item name="selectionDividersDistance">24dp</item>
<item name="internalMinWidth">64dp</item> <item name="internalMinWidth">32dp</item>
<item name="internalMaxHeight">180dp</item> <item name="internalMaxHeight">90dp</item>
<item name="virtualButtonPressedDrawable">?selectableItemBackground</item> <item name="virtualButtonPressedDrawable">?selectableItemBackground</item>
<item name="descendantFocusability">blocksDescendants</item> <item name="descendantFocusability">blocksDescendants</item>
</style> </style>

View File

@@ -189,4 +189,8 @@
<dimen name="day_picker_button_margin_top">0dp</dimen> <dimen name="day_picker_button_margin_top">0dp</dimen>
<dimen name="datepicker_view_animator_height">226dp</dimen> <dimen name="datepicker_view_animator_height">226dp</dimen>
<!-- Date and time picker legacy dimens -->
<dimen name="picker_top_margin">16dip</dimen>
<dimen name="picker_bottom_margin">16dip</dimen>
</resources> </resources>

View File

@@ -1953,7 +1953,7 @@
<string name="lockscreen_access_pattern_cleared">Pattern cleared</string> <string name="lockscreen_access_pattern_cleared">Pattern cleared</string>
<!-- Accessibility description sent when user adds a dot to the pattern. [CHAR LIMIT=NONE] --> <!-- Accessibility description sent when user adds a dot to the pattern. [CHAR LIMIT=NONE] -->
<string name="lockscreen_access_pattern_cell_added">Cell added</string> <string name="lockscreen_access_pattern_cell_added">Cell added</string>
<!-- Accessibility description sent when user adds a dot to the pattern. Announces the <!-- Accessibility description sent when user adds a dot to the pattern. Announces the
actual cell when headphones are connected [CHAR LIMIT=NONE] --> actual cell when headphones are connected [CHAR LIMIT=NONE] -->
<string name="lockscreen_access_pattern_cell_added_verbose"> <string name="lockscreen_access_pattern_cell_added_verbose">
Cell <xliff:g id="cell_index" example="3">%1$s</xliff:g> added</string> Cell <xliff:g id="cell_index" example="3">%1$s</xliff:g> added</string>
@@ -2033,6 +2033,12 @@
<!-- Button to restart the device after the factory test. --> <!-- Button to restart the device after the factory test. -->
<string name="factorytest_reboot">Reboot</string> <string name="factorytest_reboot">Reboot</string>
<!-- Do not translate. timepicker mode, overridden for watch -->
<string name="time_picker_mode" translatable="false">"clock"</string>
<!-- Do not translate. datepicker mode, overridden for watch -->
<string name="date_picker_mode" translatable="false">"calendar"</string>
<!-- Do not translate. WebView User Agent string --> <!-- Do not translate. WebView User Agent string -->
<string name="web_user_agent" translatable="false">Mozilla/5.0 (Linux; U; <xliff:g id="x">Android %s</xliff:g>) <string name="web_user_agent" translatable="false">Mozilla/5.0 (Linux; U; <xliff:g id="x">Android %s</xliff:g>)
AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 <xliff:g id="mobile">%s</xliff:g>Safari/534.30</string> AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 <xliff:g id="mobile">%s</xliff:g>Safari/534.30</string>

View File

@@ -255,6 +255,8 @@ please see styles_device_defaults.xml.
<item name="textColor">?attr/textColorPrimary</item> <item name="textColor">?attr/textColorPrimary</item>
</style> </style>
<style name="TextAppearance.Material.NumberPicker" parent="TextAppearance.Material.Body1"/>
<!-- Deprecated text styles --> <!-- Deprecated text styles -->
<style name="TextAppearance.Material.Inverse"> <style name="TextAppearance.Material.Inverse">
@@ -687,7 +689,7 @@ please see styles_device_defaults.xml.
</style> </style>
<style name="Widget.Material.TimePicker"> <style name="Widget.Material.TimePicker">
<item name="timePickerMode">clock</item> <item name="timePickerMode">@string/time_picker_mode</item>
<item name="legacyLayout">@layout/time_picker_legacy_material</item> <item name="legacyLayout">@layout/time_picker_legacy_material</item>
<!-- Attributes for new-style TimePicker. --> <!-- Attributes for new-style TimePicker. -->
<item name="internalLayout">@layout/time_picker_material</item> <item name="internalLayout">@layout/time_picker_material</item>
@@ -701,7 +703,7 @@ please see styles_device_defaults.xml.
</style> </style>
<style name="Widget.Material.DatePicker"> <style name="Widget.Material.DatePicker">
<item name="datePickerMode">calendar</item> <item name="datePickerMode">@string/date_picker_mode</item>
<item name="legacyLayout">@layout/date_picker_legacy_holo</item> <item name="legacyLayout">@layout/date_picker_legacy_holo</item>
<item name="calendarViewShown">true</item> <item name="calendarViewShown">true</item>
<!-- Attributes for new-style DatePicker. --> <!-- Attributes for new-style DatePicker. -->