OSDN Git Service

Resolve issues with AlertDialog layout for watch devices.
authorMichael Kwan <mkwan@google.com>
Fri, 29 Jul 2016 00:25:00 +0000 (17:25 -0700)
committerMichael Kwan <mkwan@google.com>
Fri, 29 Jul 2016 01:17:46 +0000 (18:17 -0700)
- Ensure button bar always snaps to bottom
- Set message TextAppearance to use Subhead styling
- Added additional bottom padding to title panel

Bug: 30483771
Change-Id: I515e0096f3dc49b56753b3426f8eda5193d4255c

core/res/res/layout-notround-watch/alert_dialog_title_material.xml [moved from core/res/res/layout-notround-watch/alert_dialog_header_micro.xml with 85% similarity]
core/res/res/layout-round-watch/alert_dialog_title_material.xml [moved from core/res/res/layout-round-watch/alert_dialog_header_micro.xml with 84% similarity]
core/res/res/layout-watch/alert_dialog_material.xml
core/res/res/values-notround-watch/config_material.xml [moved from core/res/res/values-notround-watch/styles_material.xml with 55% similarity]
core/res/res/values-round-watch/config_material.xml
core/res/res/values-round-watch/styles_material.xml [deleted file]
core/res/res/values-watch/config_material.xml
core/res/res/values-watch/styles_material.xml
core/res/res/values/config_material.xml
core/res/res/values/styles_material.xml

             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:src="@null" />
-    <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
+    <TextView android:id="@+id/alertTitle"
             style="?android:attr/windowTitleStyle"
-            android:ellipsize="end"
-            android:layout_marginStart="8dp"
             android:layout_marginBottom="8dp"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:textAlignment="viewStart" />
+            android:layout_height="wrap_content" />
 </LinearLayout>
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:src="@null" />
-    <com.android.internal.widget.DialogTitle android:id="@+id/alertTitle"
+    <TextView android:id="@+id/alertTitle"
             style="?android:attr/windowTitleStyle"
-            android:ellipsize="end"
             android:layout_marginTop="36dp"
-            android:layout_marginBottom="4dp"
+            android:layout_marginBottom="8dp"
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:textAlignment="center" />
+            android:layout_height="wrap_content" />
 </FrameLayout>
index ce8e20a..002dde8 100644 (file)
@@ -39,7 +39,7 @@
                 <include android:id="@+id/title_template"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
-                        layout="@layout/alert_dialog_header_micro"/>
+                        layout="@layout/alert_dialog_title_material"/>
             </FrameLayout>
 
             <!-- Content Panel -->
@@ -50,7 +50,8 @@
                 <TextView android:id="@+id/message"
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
-                        android:textAppearance="@style/TextAppearance.Material.Body1"
+                        android:gravity="@integer/config_dialogTextGravity"
+                        android:textAppearance="@style/TextAppearance.Material.Subhead"
                         android:paddingStart="?dialogPreferredPadding"
                         android:paddingEnd="?dialogPreferredPadding"
                         android:paddingTop="8dip"
@@ -77,6 +78,7 @@
                 <LinearLayout
                         android:layout_width="match_parent"
                         android:layout_height="wrap_content"
+                        android:layout_gravity="bottom"
                         android:orientation="vertical"
                         android:minHeight="@dimen/alert_dialog_button_bar_height"
                         android:paddingBottom="?dialogPreferredPadding"
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!-- Copyright (C) 2016 The Android Open Source Project
 
      Licensed under the Apache License, Version 2.0 (the "License");
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<resources>
-    <style name="TextAppearance.Material.AlertDialogMessage" parent="TextAppearance.Material.Body1"/>
+
+<!-- These resources are around just to allow their values to be customized
+     for different hardware and product builds, only for Material theme.  Do not translate.
+
+     NOTE: The naming convention is "config_camelCaseValue".  -->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <!-- Gravity that should be used for dialog text styles. Equivalent to: Gravity.START | Gravity.TOP -->
+    <integer name="config_dialogTextGravity">0x00800033</integer>
 </resources>
index bf445ef..871e910 100644 (file)
@@ -19,4 +19,7 @@
 <resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <!-- Don't clip on round screens so the list can scroll past the rounded edges. -->
     <bool name="config_preferenceFragmentClipToPadding">false</bool>
+
+    <!-- Gravity that should be used for dialog text styles. Equivalent to: Gravity.CENTER_HORIZONTAL | Gravity.TOP -->
+    <integer name="config_dialogTextGravity">0x00000031</integer>
 </resources>
diff --git a/core/res/res/values-round-watch/styles_material.xml b/core/res/res/values-round-watch/styles_material.xml
deleted file mode 100644 (file)
index a2f3c02..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright (C) 2016 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>
-    <style name="TextAppearance.Material.AlertDialogMessage" parent="TextAppearance.Material.Body1">
-        <item name="textAlignment">center</item>
-    </style>
-</resources>
index 81b53e7..104d122 100644 (file)
@@ -29,7 +29,4 @@
 
     <!-- Always overscan by default to ensure onApplyWindowInsets will always be called. -->
     <bool name="config_windowOverscanByDefault">true</bool>
-
-    <!-- Due to the smaller screen size, have dialog titles occupy more than 1 line. -->
-    <integer name="config_dialogWindowTitleMaxLines">3</integer>
 </resources>
index f5735e6..e22862e 100644 (file)
@@ -89,6 +89,14 @@ please see styles_device_defaults.xml.
         <item name="descendantFocusability">blocksDescendants</item>
     </style>
 
+    <style name="DialogWindowTitle.Material">
+        <item name="maxLines">3</item>
+        <item name="scrollHorizontally">false</item>
+        <item name="textAppearance">@style/TextAppearance.Material.DialogWindowTitle</item>
+        <item name="gravity">@integer/config_dialogTextGravity</item>
+        <item name="ellipsize">end</item>
+    </style>
+
     <!-- DO NOTE TRANSLATE Spans within this text are applied to style composing regions
     within an EditText widget. The text content is ignored and not used.
     Note: This is @color/material_deep_teal_200, cannot use @color references here. -->
index a37be83..397635f 100644 (file)
@@ -32,9 +32,6 @@
     <!-- True if windowOverscan should be on by default. -->
     <bool name="config_windowOverscanByDefault">false</bool>
 
-    <!-- Max number of lines for the dialog title. -->
-    <integer name="config_dialogWindowTitleMaxLines">1</integer>
-
     <!-- True if preference fragment should clip to padding. -->
     <bool name="config_preferenceFragmentClipToPadding">true</bool>
 </resources>
index 4435537..5e5712a 100644 (file)
@@ -1246,7 +1246,7 @@ please see styles_device_defaults.xml.
     <style name="DialogWindowTitleBackground.Material.Light" />
 
     <style name="DialogWindowTitle.Material">
-        <item name="maxLines">@integer/config_dialogWindowTitleMaxLines</item>
+        <item name="maxLines">1</item>
         <item name="scrollHorizontally">true</item>
         <item name="textAppearance">@style/TextAppearance.Material.DialogWindowTitle</item>
     </style>