diff --git a/res/layout/grid_picker_dialog.xml b/res/layout/grid_picker_dialog.xml
index f152ba12622..023f12ead3d 100644
--- a/res/layout/grid_picker_dialog.xml
+++ b/res/layout/grid_picker_dialog.xml
@@ -15,19 +15,12 @@
limitations under the License.
-->
-
-
-
-
-
+ android:layout_height="300dp"
+ android:columnWidth="112dp"
+ android:numColumns="auto_fit"
+ android:paddingTop="16dp"
+ android:stretchMode="spacingWidthUniform"
+ android:verticalSpacing="16dp" />
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index dbdc4b38f30..72a6b157e13 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -759,7 +759,6 @@
- @string/color_white
- - @string/color_gray
- @string/color_black
- @string/color_red
- @string/color_yellow
@@ -772,35 +771,6 @@
- 0xFFFFFFFF
- - 0xFF808080
- - 0xFF000000
- - 0xFFFF0000
- - 0xFFFFFF00
- - 0xFF00FF00
- - 0xFF00FFFF
- - 0xFF0000FF
- - 0xFFFF00FF
-
-
-
-
- - @string/color_none
- - @string/color_white
- - @string/color_gray
- - @string/color_black
- - @string/color_red
- - @string/color_yellow
- - @string/color_green
- - @string/color_cyan
- - @string/color_blue
- - @string/color_magenta
-
-
-
-
- - 0x00000000
- - 0xFFFFFFFF
- - 0xFF808080
- 0xFF000000
- 0xFFFF0000
- 0xFFFFFF00
@@ -808,6 +778,62 @@
- 0xFF00FFFF
- 0xFF0000FF
- 0xFFFF00FF
+ - 0xFF000055
+ - 0xFF0000AA
+ - 0xFF005500
+ - 0xFF005555
+ - 0xFF0055AA
+ - 0xFF0055FF
+ - 0xFF00AA00
+ - 0xFF00AA55
+ - 0xFF00AAAA
+ - 0xFF00AAFF
+ - 0xFF00FF55
+ - 0xFF00FFAA
+ - 0xFF550000
+ - 0xFF550055
+ - 0xFF5500AA
+ - 0xFF5500FF
+ - 0xFF555500
+ - 0xFF555555
+ - 0xFF5555AA
+ - 0xFF5555FF
+ - 0xFF55AA00
+ - 0xFF55AA55
+ - 0xFF55AAAA
+ - 0xFF55AAFF
+ - 0xFF55FF00
+ - 0xFF55FF55
+ - 0xFF55FFAA
+ - 0xFF55FFFF
+ - 0xFFAA0000
+ - 0xFFAA0055
+ - 0xFFAA00AA
+ - 0xFFAA00FF
+ - 0xFFAA5500
+ - 0xFFAA5555
+ - 0xFFAA55AA
+ - 0xFFAA55FF
+ - 0xFFAAAA00
+ - 0xFFAAAA55
+ - 0xFFAAAAAA
+ - 0xFFAAAAFF
+ - 0xFFAAFF00
+ - 0xFFAAFF55
+ - 0xFFAAFFAA
+ - 0xFFAAFFFF
+ - 0xFFFF0055
+ - 0xFFFF00AA
+ - 0xFFFF5500
+ - 0xFFFF5555
+ - 0xFFFF55AA
+ - 0xFFFF55FF
+ - 0xFFFFAA00
+ - 0xFFFFAA55
+ - 0xFFFFAAAA
+ - 0xFFFFAAFF
+ - 0xFFFFFF55
+ - 0xFFFFFFAA
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6b9cf74e417..fcb7de3ddb9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3299,6 +3299,8 @@
Yellow
Magenta
+
+ #%1$02X%2$02X%3$02X
diff --git a/res/xml/captioning_settings.xml b/res/xml/captioning_settings.xml
index 664505acb11..97739430798 100644
--- a/res/xml/captioning_settings.xml
+++ b/res/xml/captioning_settings.xml
@@ -47,7 +47,6 @@
android:key="custom"
android:title="@string/captioning_custom_options_title" >
@@ -73,7 +70,6 @@
android:persistent="false"
android:title="@string/captioning_edge_color" />
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index 1b53374bd77..c744a9f427d 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -22,6 +22,7 @@ import android.graphics.Color;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
+import android.preference.PreferenceCategory;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
import android.view.accessibility.CaptioningManager;
@@ -50,6 +51,9 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
private ColorPreference mEdgeColor;
private ColorPreference mBackgroundColor;
private ColorPreference mBackgroundOpacity;
+ private PreferenceCategory mCustom;
+
+ private boolean mShowingCustom;
@Override
public void onCreate(Bundle icicle) {
@@ -57,6 +61,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
addPreferencesFromResource(R.xml.captioning_settings);
initializeAllPreferences();
updateAllPreferences();
+ refreshShowingCustom();
installUpdateListeners();
}
@@ -70,6 +75,9 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
}
private void initializeAllPreferences() {
+ mLocale = (LocalePreference) findPreference("captioning_locale");
+ mFontSize = (ListPreference) findPreference("captioning_font_size");
+
final Resources res = getResources();
final int[] presetValues = res.getIntArray(R.array.captioning_preset_selector_values);
final String[] presetTitles = res.getStringArray(R.array.captioning_preset_selector_titles);
@@ -77,34 +85,39 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
mPreset.setValues(presetValues);
mPreset.setTitles(presetTitles);
+ mCustom = (PreferenceCategory) findPreference("custom");
+ mShowingCustom = true;
+
final int[] colorValues = res.getIntArray(R.array.captioning_color_selector_values);
final String[] colorTitles = res.getStringArray(R.array.captioning_color_selector_titles);
- mForegroundColor = (ColorPreference) findPreference("captioning_foreground_color");
+ mForegroundColor = (ColorPreference) mCustom.findPreference("captioning_foreground_color");
mForegroundColor.setTitles(colorTitles);
mForegroundColor.setValues(colorValues);
- mEdgeColor = (ColorPreference) findPreference("captioning_edge_color");
+ mEdgeColor = (ColorPreference) mCustom.findPreference("captioning_edge_color");
mEdgeColor.setTitles(colorTitles);
mEdgeColor.setValues(colorValues);
- final int[] bgColorValues = res.getIntArray(
- R.array.captioning_background_color_selector_values);
- final String[] bgColorTitles = res.getStringArray(
- R.array.captioning_background_color_selector_titles);
- mBackgroundColor = (ColorPreference) findPreference("captioning_background_color");
+ // Add "none" as an additional option for backgrounds.
+ final int[] bgColorValues = new int[colorValues.length + 1];
+ final String[] bgColorTitles = new String[colorTitles.length + 1];
+ System.arraycopy(colorValues, 0, bgColorValues, 1, colorValues.length);
+ System.arraycopy(colorTitles, 0, bgColorTitles, 1, colorTitles.length);
+ bgColorValues[0] = Color.TRANSPARENT;
+ bgColorTitles[0] = getString(R.string.color_none);
+ mBackgroundColor = (ColorPreference) mCustom.findPreference("captioning_background_color");
mBackgroundColor.setTitles(bgColorTitles);
mBackgroundColor.setValues(bgColorValues);
final int[] opacityValues = res.getIntArray(R.array.captioning_opacity_selector_values);
final String[] opacityTitles = res.getStringArray(
R.array.captioning_opacity_selector_titles);
- mBackgroundOpacity = (ColorPreference) findPreference("captioning_background_opacity");
+ mBackgroundOpacity = (ColorPreference) mCustom.findPreference(
+ "captioning_background_opacity");
mBackgroundOpacity.setTitles(opacityTitles);
mBackgroundOpacity.setValues(opacityValues);
- mEdgeType = (EdgeTypePreference) findPreference("captioning_edge_type");
- mTypeface = (ListPreference) findPreference("captioning_typeface");
- mFontSize = (ListPreference) findPreference("captioning_font_size");
- mLocale = (LocalePreference) findPreference("captioning_locale");
+ mEdgeType = (EdgeTypePreference) mCustom.findPreference("captioning_edge_type");
+ mTypeface = (ListPreference) mCustom.findPreference("captioning_typeface");
}
private void installUpdateListeners() {
@@ -159,6 +172,17 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
}
}
+ private void refreshShowingCustom() {
+ final boolean customPreset = mPreset.getValue() == CaptionStyle.PRESET_CUSTOM;
+ if (!customPreset && mShowingCustom) {
+ getPreferenceScreen().removePreference(mCustom);
+ mShowingCustom = false;
+ } else if (customPreset && !mShowingCustom) {
+ getPreferenceScreen().addPreference(mCustom);
+ mShowingCustom = true;
+ }
+ }
+
@Override
public void onValueChanged(ListDialogPreference preference, int value) {
final ContentResolver cr = getActivity().getContentResolver();
@@ -180,6 +204,7 @@ public class CaptionPropertiesFragment extends SettingsPreferenceFragment
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_COLOR, value);
} else if (mPreset == preference) {
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, value);
+ refreshShowingCustom();
} else if (mEdgeType == preference) {
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_EDGE_TYPE, value);
}
diff --git a/src/com/android/settings/accessibility/ColorPreference.java b/src/com/android/settings/accessibility/ColorPreference.java
index 68af6b2c6d8..f4a5ba7fa1e 100644
--- a/src/com/android/settings/accessibility/ColorPreference.java
+++ b/src/com/android/settings/accessibility/ColorPreference.java
@@ -63,6 +63,21 @@ public class ColorPreference extends ListDialogPreference {
return getValue() == Color.TRANSPARENT || super.shouldDisableDependents();
}
+ @Override
+ protected CharSequence getTitleAt(int index) {
+ final CharSequence title = super.getTitleAt(index);
+ if (title != null) {
+ return title;
+ }
+
+ // If no title was supplied, format title using RGB values.
+ final int value = getValueAt(index);
+ final int r = Color.red(value);
+ final int g = Color.green(value);
+ final int b = Color.blue(value);
+ return getContext().getString(R.string.color_custom, r, g, b);
+ }
+
@Override
protected void onBindView(View view) {
super.onBindView(view);