Merge "Tune Dashboard layouts following UX spec - part 2" into lmp-preview-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f16ba34..a2a0e70 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -734,7 +734,8 @@
         </activity>
 
         <activity android:name="Settings$NotificationStationActivity"
-                android:label="@string/sound_category_notification_title"
+                android:theme="@android:style/Theme.DeviceDefault"
+                android:label="@string/notification_log_title"
                 android:taskAffinity=""
                 android:excludeFromRecents="true">
             <intent-filter>
diff --git a/res/layout/captioning_preview.xml b/res/layout/captioning_preview.xml
index 0963ee9..b90c3a5 100644
--- a/res/layout/captioning_preview.xml
+++ b/res/layout/captioning_preview.xml
@@ -21,6 +21,7 @@
     android:orientation="vertical" >
 
     <FrameLayout
+        android:id="@+id/preview_viewport"
         android:layout_width="match_parent"
         android:layout_height="@dimen/captioning_preview_height" >
 
diff --git a/res/layout/notification_log_row.xml b/res/layout/notification_log_row.xml
index 702e6b8..57f5a79 100644
--- a/res/layout/notification_log_row.xml
+++ b/res/layout/notification_log_row.xml
@@ -51,6 +51,7 @@
             android:layout_toEndOf="@android:id/icon"
             android:ellipsize="end"
             android:singleLine="true"
+            android:textColor="?android:attr/textColorPrimary"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textStyle="bold"
             android:textAlignment="viewStart"
@@ -66,6 +67,7 @@
             android:layout_centerVertical="true"
             android:ellipsize="end"
             android:singleLine="true"
+            android:textColor="?android:attr/textColorPrimary"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textAlignment="viewEnd"
             />
@@ -79,6 +81,7 @@
         android:layout_marginStart="30dp"
         android:ellipsize="end"
         android:singleLine="true"
+        android:textColor="?android:attr/textColorPrimary"
         android:textAppearance="?android:attr/textAppearanceSmall"
         android:textAlignment="viewStart"
         />
@@ -109,6 +112,7 @@
             android:layout_gravity="left|center_vertical"
             android:ellipsize="end"
             android:singleLine="true"
+            android:textColor="?android:attr/textColorPrimary"
             android:textAppearance="?android:attr/textAppearanceSmall"
             android:textAlignment="viewStart"
             />
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 508e799..c960c88 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -736,6 +736,7 @@
 
     <!-- Titles for captioning character edge type preference. [CHAR LIMIT=35] -->
     <string-array name="captioning_edge_type_selector_titles">
+        <item>Default</item>
         <item>None</item>
         <item>Outline</item>
         <item>Drop shadow</item>
@@ -745,6 +746,7 @@
 
     <!-- Values for captioning character edge type preference. -->
     <integer-array name="captioning_edge_type_selector_values" translatable="false" >
+        <item>-1</item>
         <item>0</item>
         <item>1</item>
         <item>2</item>
@@ -754,6 +756,7 @@
 
     <!-- Titles for captioning color preference. -->
     <string-array name="captioning_color_selector_titles" translatable="false" >
+        <item>@string/color_unspecified</item>
         <item>@string/color_white</item>
         <item>@string/color_black</item>
         <item>@string/color_red</item>
@@ -766,6 +769,7 @@
 
     <!-- Values for captioning color preference. -->
     <integer-array name="captioning_color_selector_values" translatable="false" >
+        <item>0x00000100</item>
         <item>0xFFFFFFFF</item>
         <item>0xFF000000</item>
         <item>0xFFFF0000</item>
@@ -850,6 +854,7 @@
 
     <!-- Titles for captioning text style preset preference. [CHAR LIMIT=35] -->
     <string-array name="captioning_preset_selector_titles" >
+        <item>Use app defaults</item>
         <item>White on black</item>
         <item>Black on white</item>
         <item>Yellow on black</item>
@@ -859,6 +864,7 @@
 
     <!-- Values for captioning text style preset preference. -->
     <integer-array name="captioning_preset_selector_values" translatable="false" >
+        <item>4</item>
         <item>0</item>
         <item>1</item>
         <item>2</item>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 02e08c6..c58dffc 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -42,7 +42,10 @@
     <color name="circle_avatar_frame_shadow_color">#80000000</color>
     <color name="circle_avatar_frame_pressed_color">#ffffffff</color>
 
-    <color name="lock_pattern_background">#8000</color>
+    <color name="lock_pattern_background">#00000000</color>
+    <color name="lock_pattern_view_regular_color">#ff37474f</color>
+    <color name="lock_pattern_view_success_color">#ff009688</color>
+    <color name="lock_pattern_view_error_color">#fff4511e</color>
 
     <color name="quantum_blue_grey_50">#ffeceff1</color>
     <color name="quantum_blue_grey_100">#ffcfd8dc</color>
@@ -61,7 +64,11 @@
     <color name="quantum_accent_color_dark">#FF80CBC4</color>
     <color name="quantum_empty_color_light">#FFCED7DB</color>
 
-    <color name="actionbar_background_color">#ff263238</color>
+    <!-- Palette colors referenced by top-level themes and manually copied into base theme. -->
+    <color name="theme_primary">#ff263238</color>
+    <color name="theme_primary_dark">@color/theme_primary</color>
+    <color name="theme_accent">@color/quantum_accent_color_light</color>
+
     <color name="dashboard_background_color">#ffe1e1e0</color>
     <color name="switchbar_background_color">#ff384248</color>
     <color name="switch_accent_color">#ff7fcac3</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d957d8b..b8fe0df 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -125,4 +125,6 @@
     <!-- Search title (recent / results) padding start -->
     <dimen name="search_title_padding_start">16dp</dimen>
 
+    <!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. -->
+    <dimen name="caption_preview_text_size">48dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3f4b706..fd25212 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3369,7 +3369,9 @@
     <!-- Label for the default device locale. [CHAR LIMIT=35] -->
     <string name="locale_default">Default</string>
 
-    <!-- Label for no color. [CHAR LIMIT=35] -->
+    <!-- Label for default color. This lets the app pick the color. [CHAR LIMIT=35] -->
+    <string name="color_unspecified">Default</string>
+    <!-- Label for no color (transparent). [CHAR LIMIT=35] -->
     <string name="color_none">None</string>
     <!-- Label for the color white. [CHAR LIMIT=35] -->
     <string name="color_white">White</string>
@@ -4101,7 +4103,7 @@
     <string name="untitled_apn">Untitled</string>
 
     <string name="sound_category_sound_title">General</string>
-    <string name="sound_category_notification_title">Notifications</string>
+    <string name="notification_log_title">Notification log</string>
 
     <!-- Category title for phone call's ringtone and vibration settings in the Sound Setting.
          [CHAR LIMIT=40] -->
@@ -5067,120 +5069,120 @@
 
     <!-- Sounds and Notifications -->
 
-    <!-- Sounds & notifications: Settings header. [CHAR LIMIT=20] -->
-    <string name="notification_settings">Sounds &amp; Notifications</string>
+    <!-- Sound & notifications: Settings header. [CHAR LIMIT=20] -->
+    <string name="notification_settings">Sound &amp; Notifications</string>
 
-    <!-- Sounds & notifications: Title for the option managing media volume. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option managing media volume. [CHAR LIMIT=30] -->
     <string name="media_volume_option_title">Media volume</string>
 
-    <!-- Sounds & notifications: Title for the option managing alarm volume. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option managing alarm volume. [CHAR LIMIT=30] -->
     <string name="alarm_volume_option_title">Alarm volume</string>
 
-    <!-- Sounds & notifications: Title for the option managing ringer volume. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option managing ringer volume. [CHAR LIMIT=30] -->
     <string name="ring_volume_option_title">Ring volume</string>
 
-    <!-- Sounds & notifications: Title for the option managing notification volume. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option managing notification volume. [CHAR LIMIT=30] -->
     <string name="notification_volume_option_title">Notification volume</string>
 
-    <!-- Sounds & notifications: Title for the Do not disturb option and associated settings page. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the Do not disturb option and associated settings page. [CHAR LIMIT=30] -->
     <string name="zen_mode_settings_title">Do not disturb</string>
 
-    <!-- Sounds & notifications: Title for the ringer mode option. [CHAR LIMIT=60] -->
+    <!-- Sound & notifications: Title for the ringer mode option. [CHAR LIMIT=60] -->
     <string name="ringer_mode_title">When calls and notifications arrive</string>
 
-    <!-- Sounds & notifications: Title for the ringer mode option on devices without voice. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the ringer mode option on devices without voice. [CHAR LIMIT=30] -->
     <string name="ringer_mode_title_novoice">When notifications arrive</string>
 
-    <!-- Sounds & notifications: Value for the ringer mode option when audible. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Value for the ringer mode option when audible. [CHAR LIMIT=30] -->
     <string name="ringer_mode_audible">Ring</string>
 
-    <!-- Sounds & notifications: Value for the ringer mode option when vibrate. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Value for the ringer mode option when vibrate. [CHAR LIMIT=30] -->
     <string name="ringer_mode_vibrate">Vibrate instead of ringing</string>
 
-    <!-- Sounds & notifications: Value for the ringer mode option when silent. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Value for the ringer mode option when silent. [CHAR LIMIT=30] -->
     <string name="ringer_mode_silent">Don\'t ring or vibrate</string>
 
-    <!-- Sounds & notifications: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option defining the phone ringtone. [CHAR LIMIT=30] -->
     <string name="ringtone_title">Phone ringtone</string>
 
-    <!-- Sounds & notifications: Title for the option defining the default notification ringtone. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option defining the default notification ringtone. [CHAR LIMIT=30] -->
     <string name="notification_ringtone_title">Default notification ringtone</string>
 
-    <!-- Sounds & notifications: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the option managing whether or not to vibrate when ringing. [CHAR LIMIT=30] -->
     <string name="vibrate_when_ringing_title">Vibrate when ringing</string>
 
-    <!-- Sounds & notifications: Title for the showing notifications option and associated settings page. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the showing notifications option and associated settings page. [CHAR LIMIT=30] -->
     <string name="notification_display_settings">Showing notifications</string>
 
-    <!-- Sounds & notifications > Showing notifications: Title for the pulse notification light option. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Showing notifications: Title for the pulse notification light option. [CHAR LIMIT=30] -->
     <string name="notification_pulse_title">Pulse notification light</string>
 
-    <!-- Sounds & notifications > Showing notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Showing notifications: Title for the option controlling notifications on the lockscreen. [CHAR LIMIT=30] -->
     <string name="lock_screen_notifications_title">When device is locked</string>
 
-    <!-- Sounds & notifications > Showing notifications: Value for lockscreen notifications:  all information will be
+    <!-- Sound & notifications > Showing notifications: Value for lockscreen notifications:  all information will be
          shown in notifications shown on a secure lock screen
          [CHAR LIMIT=50] -->
     <string name="lock_screen_notifications_summary_show">Show all notification content</string>
 
-    <!-- Sounds & notifications > Showing notifications: Value for lockscreen notifications: sensitive information will be
+    <!-- Sound & notifications > Showing notifications: Value for lockscreen notifications: sensitive information will be
          hidden or redacted from notifications shown on a secure lock screen
          [CHAR LIMIT=50] -->
     <string name="lock_screen_notifications_summary_hide">Hide sensitive notification content</string>
 
-    <!-- Sounds & notifications > Showing notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
+    <!-- Sound & notifications > Showing notifications: Value for lockscreen notifications: notifications will not appear on a secure lock screen
          [CHAR LIMIT=50] -->
     <string name="lock_screen_notifications_summary_disable">Don\'t show notifications at all</string>
 
-    <!-- Sounds & notifications > Showing notifications: Title for the option managing notification display in zen mode. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Showing notifications: Title for the option managing notification display in zen mode. [CHAR LIMIT=30] -->
     <string name="zen_mode_notifications_title">When do not disturb is on</string>
 
-    <!-- Sounds & notifications > Showing notifications: Value for zen mode notifications: notifications will be suppressed in zen mode [CHAR LIMIT=50] -->
+    <!-- Sound & notifications > Showing notifications: Value for zen mode notifications: notifications will be suppressed in zen mode [CHAR LIMIT=50] -->
     <string name="zen_mode_notifications_summary_hide">Hide new notifications from the list</string>
 
-    <!-- Sounds & notifications > Showing notifications: Value for zen mode notifications: notifications will be displayed in zen mode [CHAR LIMIT=50] -->
+    <!-- Sound & notifications > Showing notifications: Value for zen mode notifications: notifications will be displayed in zen mode [CHAR LIMIT=50] -->
     <string name="zen_mode_notifications_summary_show">Show all notifications in the list</string>
 
-    <!-- Sounds & notifications > Showing notifications: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Showing notifications: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
     <string name="app_notifications_title">App notifications</string>
 
-    <!-- Sounds & notifications: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for the other sounds option and associated settings page. [CHAR LIMIT=30] -->
     <string name="other_sound_settings">Other sounds</string>
 
-    <!-- Sounds & notifications > Other sounds: Title for the option enabling touch sounds for dial pad tones. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Title for the option enabling touch sounds for dial pad tones. [CHAR LIMIT=30] -->
     <string name="dial_pad_tones_title">Dial pad tones</string>
 
-    <!-- Sounds & notifications > Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
     <string name="screen_locking_sounds_title">Screen locking sounds</string>
 
-    <!-- Sounds & notifications > Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
     <string name="docking_sounds_title">Docking sounds</string>
 
-    <!-- Sounds & notifications > Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
     <string name="touch_sounds_title">Touch sounds</string>
 
-    <!-- Sounds & notifications > Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
     <string name="vibrate_on_touch_title">Vibrate on touch</string>
 
-    <!-- Sounds & notifications > Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=30] -->
     <string name="dock_audio_media_title">Dock speaker plays</string>
 
-    <!-- Sounds & notifications > Other sounds: Value for the dock audio media with value 0: disabled. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Value for the dock audio media with value 0: disabled. [CHAR LIMIT=30] -->
     <string name="dock_audio_media_disabled">All audio</string>
 
-    <!-- Sounds & notifications > Other sounds: Value for the dock audio media with value 1: enabled. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Value for the dock audio media with value 1: enabled. [CHAR LIMIT=30] -->
     <string name="dock_audio_media_enabled">Media audio only</string>
 
-    <!-- Sounds & notifications > Other sounds: Value for the emergency tone option with value 0: silent. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Value for the emergency tone option with value 0: silent. [CHAR LIMIT=30] -->
     <string name="emergency_tone_silent">Silent</string>
 
-    <!-- Sounds & notifications > Other sounds: Value for the emergency tone option with value 1: alert. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Value for the emergency tone option with value 1: alert. [CHAR LIMIT=30] -->
     <string name="emergency_tone_alert">Alert</string>
 
-    <!-- Sounds & notifications > Other sounds: Value for the emergency tone option with value 2: vibrate. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications > Other sounds: Value for the emergency tone option with value 2: vibrate. [CHAR LIMIT=30] -->
     <string name="emergency_tone_vibrate">Vibrate</string>
 
-    <!-- Sounds & notifications: Title for managing notification listeners option. [CHAR LIMIT=30] -->
+    <!-- Sound & notifications: Title for managing notification listeners option. [CHAR LIMIT=30] -->
     <string name="manage_notification_access_title">Notification access</string>
 
     <!-- Summary of preference to manage notification listeners, when none are enabled -->
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 402f6dd..246e253 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -59,8 +59,18 @@
         <item name="wifi_signal">@drawable/wifi_signal_light</item>
     </style>
 
-    <!-- Theme with no local references, used by AccountPreferenceBase. -->
-    <style name="Theme.SettingsBase" parent="@android:style/Theme.Quantum.Light.DarkActionBar" />
+    <!-- Theme with no local references, used by AccountPreferenceBase where we have to inflate
+         layouts against a remote context using our local theme colors. Due to the implementation
+         details of Theme, we can't reference any local resources and MUST instead use the values
+         directly. So use #ff263238 instead of @color/theme_primary and so on. -->
+    <style name="Theme.SettingsBase" parent="@android:style/Theme.Quantum.Light.DarkActionBar">
+        <!-- Should match @color/theme_primary. -->
+        <item name="android:colorPrimary">#ff263238</item>
+        <!-- Should match @color/theme_primary_dark. -->
+        <item name="android:colorPrimaryDark">#ff263238</item>
+        <!-- Should match @color/theme_accent. -->
+        <item name="android:colorAccent">#ff009688</item>
+    </style>
 
     <style name="Theme.Settings" parent="Theme.SettingsBase">
         <item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
@@ -74,15 +84,16 @@
         <item name="ic_wps">@drawable/ic_wps_dark</item>
         <item name="wifi_signal">@drawable/wifi_signal_dark</item>
 
-        <item name="android:colorPrimary">@color/actionbar_background_color</item>
-        <!-- Used by the StatusBar and NavBar -->
-        <item name="android:colorPrimaryDark">@color/actionbar_background_color</item>
-        <!-- Redefine control activited color for progress bars and the like -->
-        <item name="android:colorAccent">@color/quantum_accent_color_light</item>
         <!-- Redefine the ActionBar style for contentInsetStart -->
         <item name="android:actionBarStyle">@style/Theme.ActionBar</item>
 
         <item name="android:alertDialogTheme">@style/Theme.AlertDialog</item>
+
+        <!-- LockPatternView colors -->
+        <item name="@*android:regularColor">@color/lock_pattern_view_regular_color</item>
+        <item name="@*android:successColor">@color/lock_pattern_view_success_color</item>
+        <item name="@*android:errorColor">@color/lock_pattern_view_error_color</item>
+
     </style>
 
     <style name="Theme.ActionBar" parent="@android:style/Widget.Quantum.Light.ActionBar.Solid">
@@ -90,11 +101,13 @@
     </style>
 
     <style name="Theme.DialogWhenLarge" parent="android:style/Theme.Quantum.Light.DialogWhenLarge">
-        <item name="android:colorPrimary">@color/actionbar_background_color</item>
-        <!-- Used by the StatusBar and NavBar -->
-        <item name="android:colorPrimaryDark">@color/actionbar_background_color</item>
-        <!-- Redefine control activited color for progress bars and the like -->
-        <item name="android:colorAccent">@color/quantum_accent_color_light</item>
+        <!-- Used by the ActionBar -->
+        <item name="android:colorPrimary">@color/theme_primary</item>
+        <!-- Used by the StatusBar -->
+        <item name="android:colorPrimaryDark">@color/theme_primary_dark</item>
+        <!-- Used by controls, e.g. CheckBox, ProgressBar, etc. -->
+        <item name="android:colorAccent">@color/theme_accent</item>
+
         <!-- Redefine the ActionBar style for contentInsetStart -->
         <item name="android:actionBarStyle">@style/Theme.ActionBar</item>
     </style>
@@ -107,11 +120,13 @@
     <style name="Theme.AlertDialog" parent="@*android:style/Theme.Quantum.Light.Dialog.Alert">
         <item name="android:windowSoftInputMode">adjustResize</item>
 
-        <item name="android:colorPrimary">@color/actionbar_background_color</item>
-        <!-- Used by the StatusBar and NavBar -->
-        <item name="android:colorPrimaryDark">@color/actionbar_background_color</item>
-        <!-- Redefine control activited color for progress bars and the like -->
-        <item name="android:colorAccent">@color/quantum_accent_color_light</item>
+        <!-- Used by the ActionBar -->
+        <item name="android:colorPrimary">@color/theme_primary</item>
+        <!-- Used by the StatusBar -->
+        <item name="android:colorPrimaryDark">@color/theme_primary_dark</item>
+        <!-- Used by controls, e.g. CheckBox, ProgressBar, etc. -->
+        <item name="android:colorAccent">@color/theme_accent</item>
+
         <!-- Redefine the ActionBar style for contentInsetStart -->
         <item name="android:actionBarStyle">@style/Theme.ActionBar</item>
     </style>
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index 5dcf121..41c80ae 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -29,6 +29,7 @@
 import android.provider.Settings;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.View.OnLayoutChangeListener;
 import android.view.ViewGroup;
 import android.view.ViewGroup.LayoutParams;
 import android.view.accessibility.CaptioningManager;
@@ -64,11 +65,13 @@
     private static final String PREF_PRESET = "captioning_preset";
     private static final String PREF_CUSTOM = "custom";
 
-    private static final float DEFAULT_FONT_SIZE = 48f;
+    /** WebVtt specifies line height as 5.3% of the viewport height. */
+    private static final float LINE_HEIGHT_RATIO = 0.0533f;
 
     private CaptioningManager mCaptioningManager;
     private SubtitleView mPreviewText;
     private View mPreviewWindow;
+    private View mPreviewViewport;
     private SwitchBar mSwitchBar;
     private ToggleSwitch mToggleSwitch;
 
@@ -130,13 +133,21 @@
         mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
         mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
 
+        mPreviewWindow = view.findViewById(R.id.preview_window);
+        mPreviewViewport = view.findViewById(R.id.preview_viewport);
+        mPreviewViewport.addOnLayoutChangeListener(new OnLayoutChangeListener() {
+            @Override
+            public void onLayoutChange(View v, int left, int top, int right, int bottom,
+                    int oldLeft, int oldTop, int oldRight, int oldBottom) {
+                refreshPreviewText();
+            }
+        });
+
         SettingsActivity activity = (SettingsActivity) getActivity();
         mSwitchBar = activity.getSwitchBar();
         mToggleSwitch = mSwitchBar.getSwitch();
         mToggleSwitch.setCheckedInternal(enabled);
 
-        mPreviewWindow = view.findViewById(R.id.preview_window);
-
         getPreferenceScreen().setEnabled(enabled);
 
         refreshPreviewText();
@@ -164,7 +175,7 @@
         final SubtitleView preview = mPreviewText;
         if (preview != null) {
             final int styleId = mCaptioningManager.getRawUserStyle();
-            applyCaptionProperties(mCaptioningManager, preview, styleId);
+            applyCaptionProperties(mCaptioningManager, preview, mPreviewViewport, styleId);
 
             final Locale locale = mCaptioningManager.getLocale();
             if (locale != null) {
@@ -176,18 +187,29 @@
             }
 
             final CaptionStyle style = mCaptioningManager.getUserStyle();
-            mPreviewWindow.setBackgroundColor(style.windowColor);
+            if (style.hasWindowColor()) {
+                mPreviewWindow.setBackgroundColor(style.windowColor);
+            } else {
+                final CaptionStyle defStyle = CaptionStyle.DEFAULT;
+                mPreviewWindow.setBackgroundColor(defStyle.windowColor);
+            }
         }
     }
 
-    public static void applyCaptionProperties(
-            CaptioningManager manager, SubtitleView previewText, int styleId) {
+    public static void applyCaptionProperties(CaptioningManager manager, SubtitleView previewText,
+            View previewWindow, int styleId) {
         previewText.setStyle(styleId);
 
         final Context context = previewText.getContext();
         final ContentResolver cr = context.getContentResolver();
         final float fontScale = manager.getFontScale();
-        previewText.setTextSize(fontScale * DEFAULT_FONT_SIZE);
+        if (previewWindow != null) {
+            previewText.setTextSize(previewWindow.getHeight() * LINE_HEIGHT_RATIO * fontScale);
+        } else {
+            final float textSize = context.getResources().getDimension(
+                    R.dimen.caption_preview_text_size);
+            previewText.setTextSize(textSize * fontScale);
+        }
 
         final Locale locale = manager.getLocale();
         if (locale != null) {
@@ -341,7 +363,7 @@
         final int opacityValue = opacity.getValue();
         final int value;
         if (Color.alpha(colorValue) == 0) {
-            value = Color.alpha(opacityValue);
+            value = colorValue & 0x00FFFF00 | Color.alpha(opacityValue);
         } else {
             value = colorValue & 0x00FFFFFF | opacityValue & 0xFF000000;
         }
diff --git a/src/com/android/settings/accessibility/ColorPreference.java b/src/com/android/settings/accessibility/ColorPreference.java
index f4a5ba7..39e555a 100644
--- a/src/com/android/settings/accessibility/ColorPreference.java
+++ b/src/com/android/settings/accessibility/ColorPreference.java
@@ -60,7 +60,7 @@
 
     @Override
     public boolean shouldDisableDependents() {
-        return getValue() == Color.TRANSPARENT || super.shouldDisableDependents();
+        return Color.alpha(getValue()) == 0 || super.shouldDisableDependents();
     }
 
     @Override
diff --git a/src/com/android/settings/accessibility/PresetPreference.java b/src/com/android/settings/accessibility/PresetPreference.java
index 9f1aee3..fe5ca68 100644
--- a/src/com/android/settings/accessibility/PresetPreference.java
+++ b/src/com/android/settings/accessibility/PresetPreference.java
@@ -49,10 +49,11 @@
 
     @Override
     protected void onBindListItem(View view, int index) {
+        final View previewViewport = view.findViewById(R.id.preview_viewport);
         final SubtitleView previewText = (SubtitleView) view.findViewById(R.id.preview);
         final int value = getValueAt(index);
         CaptionPropertiesFragment.applyCaptionProperties(
-                mCaptioningManager, previewText, value);
+                mCaptioningManager, previewText, previewViewport, value);
 
         final float density = getContext().getResources().getDisplayMetrics().density;
         previewText.setTextSize(DEFAULT_FONT_SIZE * density);