<!-- Values for captioning font size preference. -->
<string-array name="captioning_font_size_selector_values" translatable="false" >
- <item>12.0</item>
- <item>24.0</item>
- <item>48.0</item>
- <item>72.0</item>
- <item>96.0</item>
+ <item>0.25</item>
+ <item>0.5</item>
+ <item>1.0</item>
+ <item>1.5</item>
+ <item>2.0</item>
</string-array>
<!-- Titles for captioning character edge type preference. [CHAR LIMIT=35] -->
package com.android.settings.accessibility;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
public class CaptionPropertiesFragment extends SettingsPreferenceFragment
implements OnPreferenceChangeListener, OnValueChangedListener {
private ToggleCaptioningPreferenceFragment mParent;
+ private CaptioningManager mCaptioningManager;
// Standard options.
private LocalePreference mLocale;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
+
+ mCaptioningManager = (CaptioningManager) getSystemService(Context.CAPTIONING_SERVICE);
+
addPreferencesFromResource(R.xml.captioning_settings);
initializeAllPreferences();
updateAllPreferences();
}
private void updateAllPreferences() {
- final ContentResolver cr = getContentResolver();
- final int preset = CaptionStyle.getRawPreset(cr);
+ final int preset = mCaptioningManager.getRawUserStyle();
mPreset.setValue(preset);
- final float fontSize = CaptioningManager.getFontSize(cr);
+ final float fontSize = mCaptioningManager.getFontScale();
mFontSize.setValue(Float.toString(fontSize));
+ final ContentResolver cr = getContentResolver();
final CaptionStyle attrs = CaptionStyle.getCustomStyle(cr);
mForegroundColor.setValue(attrs.foregroundColor);
mEdgeType.setValue(attrs.edgeType);
final String rawTypeface = attrs.mRawTypeface;
mTypeface.setValue(rawTypeface == null ? "" : rawTypeface);
- final String rawLocale = CaptioningManager.getRawLocale(cr);
+ final String rawLocale = mCaptioningManager.getRawLocale();
mLocale.setValue(rawLocale == null ? "" : rawLocale);
}
cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE, (String) value);
} else if (mFontSize == preference) {
Settings.Secure.putFloat(
- cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SIZE,
+ cr, Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
Float.parseFloat((String) value));
} else if (mLocale == preference) {
Settings.Secure.putString(
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
-import android.view.accessibility.CaptioningManager;
import android.view.accessibility.CaptioningManager.CaptionStyle;
import android.widget.TextView;
* Grid preference that allows the user to pick a captioning edge type.
*/
public class EdgeTypePreference extends ListDialogPreference {
+ private static final int DEFAULT_FOREGROUND_COLOR = Color.WHITE;
+ private static final int DEFAULT_BACKGROUND_COLOR = Color.TRANSPARENT;
+ private static final int DEFAULT_EDGE_COLOR = Color.BLACK;
+ private static final float DEFAULT_FONT_SIZE = 96f;
+
public EdgeTypePreference(Context context, AttributeSet attrs) {
super(context, attrs);
@Override
protected void onBindListItem(View view, int index) {
- final float fontSize = CaptioningManager.getFontSize(getContext().getContentResolver());
final SubtitleView preview = (SubtitleView) view.findViewById(R.id.preview);
- preview.setForegroundColor(Color.WHITE);
- preview.setBackgroundColor(Color.TRANSPARENT);
- preview.setTextSize(fontSize);
+ preview.setForegroundColor(DEFAULT_FOREGROUND_COLOR);
+ preview.setBackgroundColor(DEFAULT_BACKGROUND_COLOR);
+ preview.setTextSize(DEFAULT_FONT_SIZE);
final int value = getValueAt(index);
preview.setEdgeType(value);
- preview.setEdgeColor(Color.BLACK);
+ preview.setEdgeColor(DEFAULT_EDGE_COLOR);
final CharSequence title = getTitleAt(index);
if (title != null) {
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
+import android.view.accessibility.CaptioningManager;
import android.view.accessibility.CaptioningManager.CaptionStyle;
import android.widget.TextView;
import com.android.settings.R;
public class PresetPreference extends ListDialogPreference {
+ private static final float DEFAULT_FONT_SIZE = 96f;
+
+ private final CaptioningManager mCaptioningManager;
+
public PresetPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogLayoutResource(R.layout.grid_picker_dialog);
setListItemLayoutResource(R.layout.preset_picker_item);
+
+ mCaptioningManager = (CaptioningManager) context.getSystemService(
+ Context.CAPTIONING_SERVICE);
}
@Override
protected void onBindListItem(View view, int index) {
final SubtitleView previewText = (SubtitleView) view.findViewById(R.id.preview);
final int value = getValueAt(index);
- ToggleCaptioningPreferenceFragment.applyCaptionProperties(previewText, value);
+ ToggleCaptioningPreferenceFragment.applyCaptionProperties(
+ mCaptioningManager, previewText, value);
+
+ previewText.setTextSize(DEFAULT_FONT_SIZE);
final CharSequence title = getTitleAt(index);
if (title != null) {
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.CaptioningManager;
-import android.view.accessibility.CaptioningManager.CaptionStyle;
import com.android.internal.widget.SubtitleView;
import com.android.settings.R;
import java.util.Locale;
public class ToggleCaptioningPreferenceFragment extends Fragment {
+ private static final float DEFAULT_FONT_SIZE = 48f;
+
private CaptionPropertiesFragment mPropsFragment;
private SubtitleView mPreviewText;
+ private CaptioningManager mCaptioningManager;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mCaptioningManager = (CaptioningManager) getActivity()
+ .getSystemService(Context.CAPTIONING_SERVICE);
+ }
@Override
public View onCreateView(
if (preview != null) {
final Activity activity = getActivity();
final ContentResolver cr = activity.getContentResolver();
- final int styleId = CaptionStyle.getRawPreset(cr);
- applyCaptionProperties(preview, styleId);
+ final int styleId = mCaptioningManager.getRawUserStyle();
+ applyCaptionProperties(mCaptioningManager, preview, styleId);
- final Locale locale = CaptioningManager.getLocale(cr);
+ final Locale locale = mCaptioningManager.getLocale();
if (locale != null) {
final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
activity, locale, R.string.captioning_preview_text);
}
}
- public static void applyCaptionProperties(SubtitleView previewText, int styleId) {
+ public static void applyCaptionProperties(
+ CaptioningManager manager, SubtitleView previewText, int styleId) {
previewText.setStyle(styleId);
final Context context = previewText.getContext();
final ContentResolver cr = context.getContentResolver();
- final float fontSize = CaptioningManager.getFontSize(cr);
- previewText.setTextSize(fontSize);
+ final float fontScale = manager.getFontScale();
+ previewText.setTextSize(fontScale * DEFAULT_FONT_SIZE);
- final Locale locale = CaptioningManager.getLocale(cr);
+ final Locale locale = manager.getLocale();
if (locale != null) {
final CharSequence localizedText = AccessibilityUtils.getTextForLocale(
context, locale, R.string.captioning_preview_characters);
Gravity.CENTER_VERTICAL | Gravity.END);
actionBar.setCustomView(toggleSwitch, params);
- final boolean enabled = CaptioningManager.isEnabled(getActivity().getContentResolver());
+ final boolean enabled = mCaptioningManager.isEnabled();
mPropsFragment.getPreferenceScreen().setEnabled(enabled);
mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
toggleSwitch.setCheckedInternal(enabled);